summaryrefslogtreecommitdiff
path: root/va
diff options
context:
space:
mode:
Diffstat (limited to 'va')
-rwxr-xr-xva/Android.mk3
-rw-r--r--va/Makefile.am16
-rw-r--r--va/egl/Makefile.am38
-rw-r--r--va/egl/va_backend_egl.h41
-rw-r--r--va/egl/va_egl.c82
-rw-r--r--va/egl/va_egl.h27
-rw-r--r--va/va.h19
-rw-r--r--va/va_backend.h24
-rw-r--r--va/va_fool.c24
-rw-r--r--va/va_fool_getframe.c26
-rw-r--r--va/va_version.h6
11 files changed, 274 insertions, 32 deletions
diff --git a/va/Android.mk b/va/Android.mk
index 4d14cd6..f5be3d0 100755
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -13,7 +13,8 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
va.c \
va_trace.c \
- va_fool.c
+ va_fool.c \
+ va_fool_getframe.c
LOCAL_CFLAGS += \
-DANDROID \
diff --git a/va/Makefile.am b/va/Makefile.am
index 5018ef0..ddb53a2 100644
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -74,14 +74,22 @@ libva_glx_backend =
libva_glx_backenddir =
endif
-lib_LTLIBRARIES = libva.la libva-tpi.la $(libva_x11_backend) $(libva_dummy_backend) $(libva_glx_backend)
+# tbd: make it configurable?
+libva_egl_backend = libva-egl.la
+libva_egl_backenddir = egl
+libva_egl_la_SOURCES =
+libva_egl_la_LIBADD = $(libvacorelib) egl/libva_egl.la libva-x11.la $(GL_DEPS_LIBS) -ldl
+libva_egl_la_LDFLAGS = $(LDADD)
+libva_egl_la_DEPENDENCIES = $(libvacorelib) egl/libva_egl.la libva-x11.la
-DIST_SUBDIRS = x11 glx dummy
+lib_LTLIBRARIES = libva.la libva-tpi.la $(libva_x11_backend) $(libva_dummy_backend) $(libva_glx_backend) $(libva_egl_backend)
-SUBDIRS = $(libva_x11_backenddir) $(libva_dummy_backenddir) $(libva_glx_backenddir)
+DIST_SUBDIRS = x11 glx egl dummy
+
+SUBDIRS = $(libva_x11_backenddir) $(libva_dummy_backenddir) $(libva_glx_backenddir) $(libva_egl_backenddir)
libvaincludedir = ${includedir}/va
-libvainclude_HEADERS = va.h va_tpi.h va_x11.h va_backend.h va_backend_tpi.h va_dummy.h va_version.h
+libvainclude_HEADERS = va.h va_tpi.h va_x11.h va_backend.h va_dummy.h va_version.h va_backend_tpi.h
DISTCLEANFILES = \
va_version.h
diff --git a/va/egl/Makefile.am b/va/egl/Makefile.am
new file mode 100644
index 0000000..5b5abd4
--- /dev/null
+++ b/va/egl/Makefile.am
@@ -0,0 +1,38 @@
+# Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11
+
+source_c = \
+ va_egl.c
+
+source_h = \
+ va_egl.h \
+ va_backend_egl.h
+
+source_h_priv =
+
+noinst_LTLIBRARIES = libva_egl.la
+libva_eglincludedir = ${includedir}/va
+libva_eglinclude_HEADERS = $(source_h)
+libva_egl_la_SOURCES = $(source_c)
+noinst_HEADERS = $(source_h_priv)
diff --git a/va/egl/va_backend_egl.h b/va/egl/va_backend_egl.h
new file mode 100644
index 0000000..925d933
--- /dev/null
+++ b/va/egl/va_backend_egl.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_BACKEND_EGL_H
+#define VA_BACKEND_EGL_H
+
+#include <va/va.h>
+#include <va/va_backend.h>
+
+struct VADriverVTableEGL {
+ /* Get EGL ClientBufer buffer index and device id from surface id*/
+ VAStatus (*vaGetEGLClientBufferFromSurface) (
+ VADriverContextP ctx,
+ VASurfaceID surface,
+ void **buffer
+ );
+ /* TBD: more APIs for EGL */
+};
+
+#endif /* VA_BACKEND_EGL_H */
diff --git a/va/egl/va_egl.c b/va/egl/va_egl.c
new file mode 100644
index 0000000..36e5504
--- /dev/null
+++ b/va/egl/va_egl.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Initial EGL backend, and subject to change
+ *
+ * Gstreamer gst-gltexture has a framework to support associating a buffer
+ * to a texture via EGL_KHR_image_base and GL_OES_EGL_image_external.
+ *
+ * EGL_KHR_image_base:
+ * EGLImageKHR eglCreateImageKHR(
+ * EGLDisplay dpy,
+ * EGLContext ctx,
+ * EGLenum target,
+ * EGLClientBuffer buffer,
+ * const EGLint *attrib_list)
+ *
+ * GL_OES_EGL_image_external:
+ * This extension provides a mechanism for creating EGLImage texture targets
+ * from EGLImages. This extension defines a new texture target TEXTURE_EXTERNAL_OES.
+ * This texture target can only be specified using an EGLImage.
+ * The first eglCreateImageKHR will create an EGLImage from an EGLClientBufferm, and with
+ * an EGLImage, gst-gltexture can use GL_OES_EGL_image_external extension to create textures.
+ *
+ * eglCreateImageKHR and GL_OES_EGL_image_external are all called directly from gst-gltexture,
+ * thus the simplest way to support gst-gltexture is defining a new API to pass EGLClientBuffer
+ * to gst-gltexture.
+ *
+ * EGLClientBuffer is gfx/video driver implementation specific (?). It means we need to pass up
+ * the low-level buffer ID (or handle) of the decoded surface to gst-gltexture, and gst-gltexture
+ * then pass down it to gfx driver.
+ *
+ * Bellow API vaGetEGLClientBufferFromSurface is for this purpose
+ */
+
+#include "va.h"
+#include "va_backend_egl.h"
+#include "va_egl.h"
+
+#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
+#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
+
+VAStatus vaGetEGLClientBufferFromSurface (
+ VADisplay dpy,
+ VASurfaceID surface,
+ EGLClientBuffer *buffer /* out*/
+)
+{
+ VADriverContextP ctx;
+ struct VADriverVTableEGL *va_egl;
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+
+ va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl;
+ if (va_egl && va_egl->vaGetEGLClientBufferFromSurface) {
+ return va_egl->vaGetEGLClientBufferFromSurface(ctx, surface, buffer);
+ } else
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+
diff --git a/va/egl/va_egl.h b/va/egl/va_egl.h
new file mode 100644
index 0000000..4243d0b
--- /dev/null
+++ b/va/egl/va_egl.h
@@ -0,0 +1,27 @@
+#ifndef _VA_EGL_H_
+#define _VA_EGL_H_
+
+#include <va/va.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* EGLClientBuffer;
+
+/*This function is used to get EGLClientBuffer
+ * (lower 16bits is buffer index, upper 16bits
+ * is BC device id.) from surface id. Application
+ * should maintain EGLClientBuffer itself.*/
+
+VAStatus vaGetEGLClientBufferFromSurface (
+ VADisplay dpy,
+ VASurfaceID surface,
+ EGLClientBuffer *buffer /* out*/
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VA_EGL_H_ */
diff --git a/va/va.h b/va/va.h
index aeada02..596ee5a 100644
--- a/va/va.h
+++ b/va/va.h
@@ -56,8 +56,12 @@
* rev 0.31 (09/02/2009 Gwenole Beauchesne) - VC-1/H264 fields change for VDPAU and XvBA backend
* Application needs to relink with the new library.
*
- * rev 0.31.1 (03/29/2009) - Data structure for JPEG encode
- *
+ * rev 0.31.1 (03/29/2009) - Data structure for JPEG encode
+ * rev 0.31.2 (01/13/2011 Anthony Pabon)- Added a flag to indicate Subpicture coordinates are screen
+ * screen relative rather than source video relative.
+ * rev 0.32.0 (01/13/2011 Xiang Haihao) - Add profile into VAPictureParameterBufferVC1
+ * update VAAPI to 0.32.0
+ *
* Acknowledgements:
* Some concepts borrowed from XvMC and XvImage.
* Waldo Bastian (Intel), Matt Sottek (Intel), Austin Yuan (Intel), and Gwenole Beauchesne (SDS)
@@ -1689,8 +1693,9 @@ int vaMaxNumSubpictureFormats (
);
/* flags for subpictures */
-#define VA_SUBPICTURE_CHROMA_KEYING 0x0001
-#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
+#define VA_SUBPICTURE_CHROMA_KEYING 0x0001
+#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
+#define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD 0x0004
/*
* Query supported subpicture formats
* The caller must provide a "format_list" array that can hold at
@@ -1699,8 +1704,10 @@ int vaMaxNumSubpictureFormats (
* number of formats returned in "format_list" is returned in "num_formats".
* flags: returned value to indicate addtional capabilities
* VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying
- * VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
+ * VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha
+ * VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD - supports unscaled screen relative subpictures for On Screen Display
*/
+
VAStatus vaQuerySubpictureFormats (
VADisplay dpy,
VAImageFormat *format_list, /* out */
@@ -1784,7 +1791,7 @@ VAStatus vaAssociateSubpicture (
unsigned short dest_width,
unsigned short dest_height,
/*
- * whether to enable chroma-keying or global-alpha
+ * whether to enable chroma-keying, global-alpha, or screen relative mode
* see VA_SUBPICTURE_XXX values
*/
unsigned int flags
diff --git a/va/va_backend.h b/va/va_backend.h
index a588462..736c680 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -181,8 +181,8 @@ struct VADriverVTable
VAStatus (*vaQuerySurfaceError) (
VADriverContextP ctx,
VASurfaceID render_target,
- VAStatus error_status,
- void **error_info /*out*/
+ VAStatus error_status,
+ void **error_info /*out*/
);
VAStatus (*vaPutSurface) (
@@ -400,7 +400,23 @@ struct VADriverContext
*/
struct VADriverVTableGLX *vtable_glx;
- void *vtable_tpi; /* the structure is malloc-ed */
+ /**
+ * The VA/EGL implementation hooks.
+ *
+ * This structure is intended for drivers that implement the
+ * VA/EGL API. The driver implementation is responsible for the
+ * allocation and deallocation of this structure.
+ */
+ struct VADriverVTableEGL *vtable_egl;
+
+ /**
+ * The third-party/private implementation hooks.
+ *
+ * This structure is intended for drivers that implement the
+ * private API. The driver implementation is responsible for the
+ * allocation and deallocation of this structure.
+ */
+ void *vtable_tpi;
void *native_dpy;
int x11_screen;
@@ -418,6 +434,8 @@ struct VADriverContext
void *dri_state;
void *glx; /* opaque for GLX code */
+
+ unsigned long reserved[45]; /* reserve for future add-ins, decrease the subscript accordingly */
};
#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
diff --git a/va/va_fool.c b/va/va_fool.c
index be2540b..b2d7449 100644
--- a/va/va_fool.c
+++ b/va/va_fool.c
@@ -80,6 +80,7 @@ static struct _fool_context {
FILE *fool_fp_codedclip; /* load a clip from disk for fooling encode*/
char *frame_buf;
+ VACodedBufferSegment *codebuf;
/* all buffers with same type share one malloc-ed memory
* bufferID = (buffer numbers with the same type << 8) || type
@@ -179,13 +180,17 @@ void va_FoolInit(VADisplay dpy)
fool_encode = 0;
if (fool_encode) /* malloc the buffer for fake clip */
+ {
fool_context[fool_index].frame_buf = malloc(MAX_FRAME*SLICE_NUM*NAL_BUF_SIZE*sizeof(char));
+ fool_context[fool_index].codebuf = malloc(sizeof(VACodedBufferSegment));
+ }
if (fool_context[fool_index].frame_buf == NULL)
fool_encode = 0;
if (fool_encode)
va_infoMessage("LIBVA_FOOL_ENCODE is on, dummy encode\n");
+
}
if (fool_encode || fool_decode)
@@ -209,6 +214,9 @@ int va_FoolEnd(VADisplay dpy)
if (fool_context[idx].frame_buf)
free(fool_context[idx].frame_buf);
+ if (fool_context[idx].codebuf)
+ free(fool_context[idx].codebuf);
+
memset(&fool_context[idx], sizeof(struct _fool_context), 0);
return 0;
}
@@ -422,7 +430,7 @@ VAStatus va_FoolMapBuffer (
)
{
VABufferType type;
- unsigned int size;
+ unsigned int size,frame_size = 0;
unsigned int num_elements;
DPY2INDEX(dpy);
@@ -443,9 +451,17 @@ VAStatus va_FoolMapBuffer (
/* expect APP to MapBuffer when get the the coded data */
if (*pbuf && (buf_idx == VAEncCodedBufferType)) { /* it is coded buffer */
/* read from a clip */
- va_FoolGetFrame(fool_context[idx].fool_fp_codedclip,
- fool_context[idx].frame_buf);
- *pbuf = fool_context[idx].frame_buf;
+ frame_size = va_FoolGetFrame(fool_context[idx].fool_fp_codedclip,
+ fool_context[idx].frame_buf);
+
+ memset(fool_context[idx].codebuf,0,sizeof(VACodedBufferSegment));
+ fool_context[idx].codebuf->size = frame_size;
+ fool_context[idx].codebuf->bit_offset = 0;
+ fool_context[idx].codebuf->status = 0;
+ fool_context[idx].codebuf->reserved = 0;
+ fool_context[idx].codebuf->buf = fool_context[idx].frame_buf;
+ fool_context[idx].codebuf->next = NULL;
+ *pbuf = fool_context[idx].codebuf;
}
return 1; /* don't call into driver */
}
diff --git a/va/va_fool_getframe.c b/va/va_fool_getframe.c
index 07b42d7..045bfb2 100644
--- a/va/va_fool_getframe.c
+++ b/va/va_fool_getframe.c
@@ -15,6 +15,7 @@ typedef struct _nal_unit {
int nal_unit_type;
unsigned char *last_rbsp_byte;
} nal_unit;
+
typedef struct _slice_header {
int first_mb_in_slice;
} slice_header;
@@ -32,9 +33,8 @@ static int input_remain = 0;
static int ring_pos = 0;
static int nal_pos;
static int nal_bit;
-static int frame_no = 0, cur_frame_no = 0;
+static int frame_no = 0;
-#define SLICE_NUM 4
#define RING_MOD ((RING_BUF_SIZE)-1)
#define HALF_RING ((RING_BUF_SIZE)/2)
@@ -178,10 +178,8 @@ int va_FoolGetFrame(FILE *input_fp, char *frame_buf)
int i = 0, frame_pos = 0;
static slice_header sh;
static nal_unit nalu;
+ char nal_head[4] = {0x00,0x00,0x00,0x01};
- /* save the current frame number */
- cur_frame_no = frame_no;
-
/* read the clip , here is the first frame,
* &let the clip go on frame by frame
*/
@@ -189,18 +187,24 @@ int va_FoolGetFrame(FILE *input_fp, char *frame_buf)
input_read(input_fp, ring_buf,RING_BUF_SIZE);
while (get_next_nal_unit(input_fp, &nalu)) {
- if (nalu.nal_unit_type == 1 || nalu.nal_unit_type == 5) {
+ if (nalu.nal_unit_type == 7 || nalu.nal_unit_type == 8) {
+ memcpy(frame_buf+frame_pos, nal_head, sizeof(char)*4);
+ frame_pos = frame_pos + 4;
+ memcpy(frame_buf+frame_pos, nal_buf, sizeof(char)*(nalu.NumBytesInNALunit));
+ frame_pos += nalu.NumBytesInNALunit;
+ }
+ else if (nalu.nal_unit_type == 1 || nalu.nal_unit_type == 5) {
decode_slice_header(&sh);
if (0 == sh.first_mb_in_slice) {
++frame_no;
- frame_pos = 0;
}
- if (frame_no > (cur_frame_no+1))
- break;
- memcpy(frame_buf+frame_pos, nal_buf+1, sizeof(char)*(nalu.NumBytesInNALunit-1));
+ memcpy(frame_buf+frame_pos, nal_head, sizeof(char)*4);
+ frame_pos = frame_pos + 4;
+ memcpy(frame_buf+frame_pos, nal_buf, sizeof(char)*(nalu.NumBytesInNALunit));
frame_pos += nalu.NumBytesInNALunit;
+ break;
}
}
- return 1;
+ return frame_pos;
}
diff --git a/va/va_version.h b/va/va_version.h
index 20675b6..41d542c 100644
--- a/va/va_version.h
+++ b/va/va_version.h
@@ -44,14 +44,14 @@
*
* The micro version of the VA library (3, if %VA_VERSION is 1.2.3)
*/
-#define VA_MICRO_VERSION (1)
+#define VA_MICRO_VERSION (0)
/**
* VA_VERSION:
*
* The full version of the VA library, like 1.2.3
*/
-#define VA_VERSION 0.32.1
+#define VA_VERSION 0.32.0
/**
* VA_VERSION_S:
@@ -59,7 +59,7 @@
* The full version of the VA library, in string form (suited for
* string concatenation)
*/
-#define VA_VERSION_S "0.32.1"
+#define VA_VERSION_S "0.32.0"
/**
* VA_VERSION_HEX: