From 45987380ec7868529b9db77d646429fe873e605e Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Tue, 8 Feb 2011 22:44:43 -0800 Subject: [PATCH] 1) cleanup for VA_FOOL 2) initial EGL support 3) libva.spec update for RPM build Signed-off-by: Guoliang Ji Signed-off-by: Jason Hu Signed-off-by: Stephen Ware Signed-off-by: Austin Yuan --- Makefile.am | 4 +-- config.h | 12 ++++++-- configure.ac | 2 ++ libva.spec | 51 ++++++++++++++++++------------ va/Android.mk | 3 +- va/Makefile.am | 16 +++++++--- va/egl/Makefile.am | 38 +++++++++++++++++++++++ va/egl/va_backend_egl.h | 41 +++++++++++++++++++++++++ va/egl/va_egl.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ va/egl/va_egl.h | 27 ++++++++++++++++ va/va.h | 19 ++++++++---- va/va_backend.h | 24 +++++++++++++-- va/va_fool.c | 24 ++++++++++++--- va/va_fool_getframe.c | 26 +++++++++------- va/va_version.h | 6 ++-- 15 files changed, 318 insertions(+), 57 deletions(-) create mode 100644 va/egl/Makefile.am create mode 100644 va/egl/va_backend_egl.h create mode 100644 va/egl/va_egl.c create mode 100644 va/egl/va_egl.h diff --git a/Makefile.am b/Makefile.am index cf57b8f..1be7da0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,7 @@ if BUILD_I965_DRIVER SUBDIRS += i965_drv_video endif -pcfiles = libva.pc libva-tpi.pc +pcfiles = libva.pc libva-tpi.pc libva-egl.pc pcfiles += libva-x11.pc if USE_GLX pcfiles += libva-glx.pc @@ -39,6 +39,6 @@ endif pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = $(pcfiles) -EXTRA_DIST = libva.pc.in libva-tpi.pc.in libva-x11.pc.in libva-glx.pc.in +EXTRA_DIST = libva.pc.in libva-tpi.pc.in libva-x11.pc.in libva-glx.pc.in libva-egl.pc.in CLEANFILES = $(pcfiles) diff --git a/config.h b/config.h index 00adfd1..943469d 100644 --- a/config.h +++ b/config.h @@ -51,7 +51,7 @@ #define PACKAGE_NAME "libva" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libva 0.32.1" +#define PACKAGE_STRING "libva 0.32.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libva" @@ -60,13 +60,19 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.32.1" +#define PACKAGE_VERSION "0.32.0" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 +/* Defined to the versioned __vaDriverInit function name */ +#define VA_DRIVER_INIT_FUNC __vaDriverInit_0_32 + +/* Defined to the versioned __vaDriverInit function name (in string form) */ +#define VA_DRIVER_INIT_FUNC_S "__vaDriverInit_0_32" + /* Version number of package */ -#define VERSION "0.32.1" +#define VERSION "0.32.0" /* Number of bits in a file offset, on hosts where this is settable. */ #define _FILE_OFFSET_BITS 64 diff --git a/configure.ac b/configure.ac index 96a0239..74c08f8 100644 --- a/configure.ac +++ b/configure.ac @@ -162,6 +162,7 @@ AC_OUTPUT([ va/va_version.h va/x11/Makefile va/glx/Makefile + va/egl/Makefile va/dummy/Makefile dummy_drv_video/Makefile i965_drv_video/Makefile @@ -181,6 +182,7 @@ AC_OUTPUT([ libva.pc libva-x11.pc libva-glx.pc + libva-egl.pc libva-tpi.pc ]) diff --git a/libva.spec b/libva.spec index 5d45216..70fbaf4 100644 --- a/libva.spec +++ b/libva.spec @@ -1,9 +1,10 @@ #%define moduledir %(pkg-config xorg-server --variable=moduledir) +%define libversion 1.0.8 Name: libva -Version: 1.0.6 +Version: %{libversion} Release: 0.0 -License: MIT license +License: MIT Source: %{name}-%{version}.tar.bz2 NoSource: 0 Group: Development/Libraries @@ -13,9 +14,27 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires: xorg-x11-server-Xorg -BuildRequires: libtool xorg-x11-server-devel pkgconfig(xv) pkgconfig(xrandr) -BuildRequires: libdrm-devel libX11-devel libXext-devel libXdamage-devel libXfixes-devel xorg-x11-proto-dri2proto -BuildRequires: xorg-x11-proto-damageproto xorg-x11-proto-kbproto xorg-x11-proto-xproto xorg-x11-proto-xextproto xorg-x11-proto-fixesproto +Requires: /sbin/ldconfig +BuildRequires: pkgconfig(xv) +BuildRequires: pkgconfig(xrandr) +BuildRequires: pkgconfig(xorg-server) +BuildRequires: pkgconfig(libdrm) +BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(xext) +BuildRequires: pkgconfig(xdamage) +BuildRequires: pkgconfig(xfixes) +BuildRequires: pkgconfig(dri2proto) +BuildRequires: pkgconfig(damageproto) +BuildRequires: pkgconfig(kbproto) +BuildRequires: pkgconfig(xextproto) +BuildRequires: pkgconfig(fixesproto) +BuildRequires: pkgconfig(xproto) +BuildRequires: pkgconfig(gl) +BuildRequires: libtool + + + + %description The libva library implements the Video Acceleration (VA) API for Linux. @@ -53,13 +72,13 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %{_libdir}/libva.so.1 -%{_libdir}/libva.so.%{version} +%{_libdir}/libva.so.%{libversion} %{_libdir}/libva-tpi.so.1 -%{_libdir}/libva-tpi.so.%{version} +%{_libdir}/libva-tpi.so.%{libversion} %{_libdir}/libva-x11.so.1 -%{_libdir}/libva-x11.so.%{version} +%{_libdir}/libva-x11.so.%{libversion} %{_libdir}/libva-glx.so.1 -%{_libdir}/libva-glx.so.%{version} +%{_libdir}/libva-glx.so.%{libversion} %{_bindir}/vainfo %{_bindir}/test_* %{_bindir}/h264encode @@ -68,17 +87,6 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/dri/dummy_drv_video.so -%{_includedir}/va/va_tpi.h -%{_includedir}/va/va_x11.h -%{_includedir}/va/va_version.h -%{_includedir}/va/va_backend.h -%{_includedir}/va/va_dri2.h -%{_includedir}/va/va_dummy.h -%{_includedir}/va/va_backend_tpi.h -%{_includedir}/va/va.h -%{_includedir}/va/va_dricommon.h -%{_includedir}/va/va_dri.h - %files devel %defattr(-,root,root,-) %dir %{_includedir}/va @@ -86,12 +94,15 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libva.so %{_libdir}/libva-tpi.so %{_libdir}/libva-x11.so +%{_libdir}/libva-glx.so %{_libdir}/pkgconfig/libva.pc %{_libdir}/pkgconfig/libva-tpi.pc %{_libdir}/pkgconfig/libva-x11.pc %{_libdir}/pkgconfig/libva-glx.pc %changelog +* Tue Jan 25 2011 Austin Yuan 1.0.1 +- Updated libva source to 1.0.8 * Wed Dec 23 2009 Prajwal Mohan 1.0.1 - Updated libva source to IMG Alpha7 * Fri Dec 18 2009 Prajwal Mohan 0.31.0 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 +#include + +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 + +#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: -- 2.7.4