Commit b7849f39 authored by Austin Yuan's avatar Austin Yuan

Refine VA_FOOL, and delete the hard coded clip va_fool_264.h

    Move test/vainfo into test/vainfo/*
    Add prototype of vaCreateSurfacesForUserPtr for V4L2 user pointer support
    Fix klocwork critical issues. Use strnlen and snprintf instead of strlen and sprintf.
    New interface vaQuerySrufaceError for decode error report and concealment
    Encode data structure change (long term reference picture interface)
    Add h264 constrained baseline profile support.
Signed-off-by: default avatarElaine Wang <elaine.wang@intel.com>
Signed-off-by: default avatarBignlin Chen <binglin.chen.wang@intel.com>
Signed-off-by: default avatarYan Zhuang <yanx.zhunag@intel.com>
Signed-off-by: default avatarGuoliang Ji <guoliangx.ji@intel.com>
parent aa7a8a0b
# Recursive call sub-folder Android.mk
#
# include $(call all-subdir-makefiles)
LOCAL_PATH := $(my-dir)
include $(LOCAL_PATH)/va/Android.mk
include $(call all-subdir-makefiles)
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <GL/glx.h> header file. */
#define HAVE_GL_GLX_H 1
/* Define to 1 if you have the <GL/gl.h> header file. */
#define HAVE_GL_GL_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libva"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "waldo.bastian@intel.com"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libva"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libva 0.31.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libva"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.31.1"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "0.31.1"
/* Number of bits in a file offset, on hosts where this is settable. */
#define _FILE_OFFSET_BITS 64
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
......@@ -170,6 +170,7 @@ AC_OUTPUT([
test/decode/Makefile
test/putsurface/Makefile
test/encode/Makefile
test/vainfo/Makefile
libva.pc
libva-x11.pc
libva-glx.pc
......
#%define moduledir %(pkg-config xorg-server --variable=moduledir)
%define driverdir %{_libdir}/
%define reldate 04282009
Name: libva
Version: 1.0.6
Release: 0.0
License: MIT
License: MIT license
Source: %{name}-%{version}.tar.bz2
NoSource: 0
Group: Development/Libraries
Summary: Video Acceleration (VA) API for Linux
URL: http://freedesktop.org/wiki/Software/vaapi
......@@ -44,37 +42,7 @@ unset LD_AS_NEEDED
make
%install
rm -rf $RPM_BUILD_ROOT
%make_install
mkdir -p $RPM_BUILD_ROOT%{driverdir}
install -m 755 ./dummy_drv_video/.libs/dummy_drv_video.so $RPM_BUILD_ROOT%{driverdir}/dummy_drv_video.so
install -m 755 ./va/.libs/libva.so.1 $RPM_BUILD_ROOT%{driverdir}/libva.so.1
install -m 755 ./va/.libs/libva.so.1.0.6 $RPM_BUILD_ROOT%{driverdir}/libva.so.1.0.6
install -m 755 ./va/.libs/libva-tpi.so.1 $RPM_BUILD_ROOT%{driverdir}/libva-tpi.so.1
install -m 755 ./va/.libs/libva-tpi.so.1.0.6 $RPM_BUILD_ROOT%{driverdir}/libva-tpi.so.1.0.6
install -m 755 ./va/.libs/libva-x11.so.1 $RPM_BUILD_ROOT%{driverdir}/libva-x11.so.1
install -m 755 ./va/.libs/libva-x11.so.1.0.6 $RPM_BUILD_ROOT%{driverdir}/libva-x11.so.1.0.6
install -m 755 ./va/.libs/libva-glx.so.1 $RPM_BUILD_ROOT%{driverdir}/libva-glx.so.1
install -m 755 ./va/.libs/libva-glx.so.1.0.6 $RPM_BUILD_ROOT%{driverdir}/libva-glx.so.1.0.6
install -m 555 ./test/vainfo $RPM_BUILD_ROOT%{_bindir}/vainfo
install -m 555 ./test/basic/test_* $RPM_BUILD_ROOT%{_bindir}/
install -m 555 ./test/decode/mpeg2vldemo $RPM_BUILD_ROOT%{_bindir}/mpeg4vldemo
install -m 555 ./test/encode/h264encode $RPM_BUILD_ROOT%{_bindir}/h264encode
install -m 555 ./test/putsurface/putsurface $RPM_BUILD_ROOT%{_bindir}/putsurface
install -m 666 ./va/va_tpi.h $RPM_BUILD_ROOT%{_includedir}/va/va_tpi.h
install -m 666 ./va/va_x11.h $RPM_BUILD_ROOT%{_includedir}/va/va_x11.h
install -m 666 ./va/va_version.h $RPM_BUILD_ROOT%{_includedir}/va/va_version.h
install -m 666 ./va/va_backend.h $RPM_BUILD_ROOT%{_includedir}/va/va_backend.h
install -m 666 ./va/x11/va_dri2.h $RPM_BUILD_ROOT%{_includedir}/va/x11/va_dri2.h
install -m 666 ./va/va_dummy.h $RPM_BUILD_ROOT%{_includedir}/va/va_dummy.h
install -m 666 ./va/va_backend_tpi.h $RPM_BUILD_ROOT%{_includedir}/va/va_backend_tpi.h
install -m 666 ./va/va.h $RPM_BUILD_ROOT%{_includedir}/va/va.h
install -m 666 ./va/x11/va_dricommon.h $RPM_BUILD_ROOT%{_includedir}/va/va_dricommon.h
install -m 666 ./va/x11/va_dri.h $RPM_BUILD_ROOT%{_includedir}/va/va_dri.h
install -m 666 ./va/glx/va_glx.h $RPM_BUILD_ROOT%{_includedir}/va/va_glx.h
install -m 666 ./va/glx/va_backend_glx.h $RPM_BUILD_ROOT%{_includedir}/va/va_backend_glx.h
%clean
rm -rf $RPM_BUILD_ROOT
......@@ -85,33 +53,31 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%{_libdir}/libva.so.1
%{_libdir}/libva.so.1.0.6
%{_libdir}/libva.so.%{version}
%{_libdir}/libva-tpi.so.1
%{_libdir}/libva-tpi.so.1.0.6
%{_libdir}/libva-tpi.so.%{version}
%{_libdir}/libva-x11.so.1
%{_libdir}/libva-x11.so.1.0.6
%{_libdir}/libva-x11.so.%{version}
%{_libdir}/libva-glx.so.1
%{_libdir}/libva-glx.so.1.0.6
%{_libdir}/libva-glx.so.%{version}
%{_bindir}/vainfo
%{_bindir}/test_*
%{_bindir}/h264encode
%{_bindir}/mpeg2vldemo
%{_bindir}/putsurface
%{driverdir}/dummy_drv_video.so
%{_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/x11/va_dri2.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
%{_includedir}/va/va_glx.h
%{_includedir}/va/va_backend_glx.h
%files devel
%defattr(-,root,root,-)
......@@ -120,9 +86,10 @@ 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
* Wed Dec 23 2009 Prajwal Mohan <prajwal.karur.mohan@intel.com> 1.0.1
......
# For vainfo
# =====================================================
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
vainfo.c
LOCAL_CFLAGS += \
-DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva
LOCAL_MODULE := vainfo
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils
include $(BUILD_EXECUTABLE)
# Recursive call sub-folder Android.mk
#
include $(call all-subdir-makefiles)
......@@ -21,15 +21,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bin_PROGRAMS = vainfo
AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11
vainfo_LDADD = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
vainfo_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
vainfo_SOURCES = vainfo.c
SUBDIRS = basic decode encode putsurface
SUBDIRS = basic decode encode putsurface vainfo
valgrind: vainfo
valgrind --leak-check=full --show-reachable=yes .libs/vainfo;
......@@ -112,7 +112,7 @@ static int save_coded_buf(VABufferID coded_buf, int current_frame, int frame_ski
va_status = vaMapBuffer(va_dpy,coded_buf,(void **)(&buf_list));
CHECK_VASTATUS(va_status,"vaMapBuffer");
while (buf_list != NULL) {
printf("Write %d bytes\n", buf_list->size);
printf("Write %d bytes", buf_list->size);
coded_size += write(coded_fd, buf_list->buf, buf_list->size);
buf_list = buf_list->next;
}
......
# For putsurface
# =====================================================
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
putsurface-android.cpp
LOCAL_CFLAGS += \
-DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva
LOCAL_MODULE := putsurface
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
include $(BUILD_EXECUTABLE)
......@@ -21,8 +21,6 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
static int yuvgen_planar(int width, int height,
unsigned char *Y_start, int Y_pitch,
unsigned char *U_start, int U_pitch,
......@@ -106,9 +104,9 @@ static int upload_surface(VADisplay va_dpy, VASurfaceID surface_id,
/* assume surface is planar format */
yuvgen_planar(surface_image.width, surface_image.height,
surface_p, surface_image.pitches[0],
U_start, surface_image.pitches[1],
V_start, surface_image.pitches[2],
(unsigned char *)surface_p, surface_image.pitches[0],
(unsigned char *)U_start, surface_image.pitches[1],
(unsigned char *)V_start, surface_image.pitches[2],
(surface_image.format.fourcc==VA_FOURCC_NV12),
box_width, row_shift, field);
......
This diff is collapsed.
......@@ -98,8 +98,8 @@ static Pixmap create_pixmap(int width, int height)
XGetWindowAttributes (x11_display, root, &attr);
printf("Create a pixmap from ROOT window %dx%d\n\n", attr.width, attr.height);
pixmap = XCreatePixmap(x11_display, root, attr.width, attr.height,
printf("Create a pixmap from ROOT window %dx%d, pixmap size %dx%d\n\n", attr.width, attr.height, width, height);
pixmap = XCreatePixmap(x11_display, root, width, height,
DefaultDepth(x11_display, DefaultScreen(x11_display)));
return pixmap;
......
# For vainfo
# =====================================================
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
vainfo.c
LOCAL_CFLAGS += \
-DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva
LOCAL_MODULE := vainfo
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils
include $(BUILD_EXECUTABLE)
# 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.
bin_PROGRAMS = vainfo
AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11
vainfo_LDADD = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
vainfo_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
vainfo_SOURCES = vainfo.c
valgrind: vainfo
valgrind --leak-check=full --show-reachable=yes .libs/vainfo;
......@@ -56,6 +56,7 @@ static char * profile_string(VAProfile profile)
case VAProfileVC1Main: return "VAProfileVC1Main";
case VAProfileVC1Advanced: return "VAProfileVC1Advanced";
case VAProfileH263Baseline: return "VAProfileH263Baseline";
case VAProfileH264ConstrainedBaseline: return "VAProfileH264ConstrainedBaseline";
}
return "<unknown profile>";
}
......
......@@ -10,35 +10,15 @@ include $(CLEAR_VARS)
#LIBVA_MINOR_VERSION := 31
#LIBVA_MAJOR_VERSION := 0
LOCAL_MODULE := libva
LOCAL_SHARED_LIBRARIES := libdl libdrm libcutils
include $(BUILD_SHARED_LIBRARY)
intermediates := $(local-intermediates-dir)
GEN := $(intermediates)/va_version.h
$(GEN): PRIVATE_GEN_VERSION := $(LOCAL_PATH)/../build/gen_version.sh
$(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/va_version.h.in
$(GEN): PRIVATE_CUSTOM_TOOL = sh $(PRIVATE_GEN_VERSION) $(LOCAL_PATH)/.. $(PRIVATE_INPUT_FILE) > $@
$(GEN): $(LOCAL_PATH)/va_version.h
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
LOCAL_SRC_FILES := \
va.c \
va_trace.c \
va_fool.c
va_fool.c
LOCAL_CFLAGS += \
-DANDROID \
-DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\""
LOCAL_COPY_HEADERS_TO := libva/va
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(LOCAL_PATH)/x11 \
......@@ -51,7 +31,23 @@ LOCAL_COPY_HEADERS := \
va_version.h.in \
x11/va_dricommon.h
LOCAL_COPY_HEADERS_TO := libva/va
LOCAL_MODULE := libva
LOCAL_SHARED_LIBRARIES := libdl libdrm libcutils
include $(BUILD_SHARED_LIBRARY)
intermediates := $(local-intermediates-dir)
GEN := $(intermediates)/va_version.h
$(GEN): PRIVATE_GEN_VERSION := $(LOCAL_PATH)/../build/gen_version.sh
$(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/va_version.h.in
$(GEN): PRIVATE_CUSTOM_TOOL = sh $(PRIVATE_GEN_VERSION) $(LOCAL_PATH)/.. $(PRIVATE_INPUT_FILE) > $@
$(GEN): $(LOCAL_PATH)/va_version.h
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
# For libva-android
# =====================================================
......
......@@ -27,7 +27,7 @@ INCLUDES = \
LDADD = \
$(LIBVA_LT_LDFLAGS)
libva_la_SOURCES = va.c va_trace.c va_fool.c
libva_la_SOURCES = va.c va_trace.c va_fool.c va_fool_getframe.c
libva_ladir = $(libdir)
libva_la_LDFLAGS = $(LDADD) -no-undefined
libva_la_LIBADD = $(LIBVA_LIBS) -ldl
......
......@@ -55,6 +55,13 @@ extern int trace_flag;
trace_func(__VA_ARGS__); \
}
extern int fool_decode;
extern int fool_encode;
#define VA_FOOL(fool_func,...) \
if (fool_decode || fool_encode) { \
ret = fool_func(__VA_ARGS__); \
}
/*
* read a config "env" for libva.conf or from environment setting
* liva.conf has higher priority
......@@ -432,8 +439,7 @@ VAStatus vaTerminate (
CHECK_DISPLAY(dpy);
old_ctx = CTX(dpy);
if (old_ctx->handle)
{
if (old_ctx->handle) {
vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
dlclose(old_ctx->handle);
old_ctx->handle = NULL;
......@@ -554,12 +560,19 @@ VAStatus vaCreateConfig (
)
{
VADriverContextP ctx;
VAStatus vaStatus = VA_STATUS_SUCCESS;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
VA_FOOL(va_FoolCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
vaStatus = ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
VA_TRACE(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
va_FoolCreateConfig(dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
return vaStatus;
}
VAStatus vaDestroyConfig (
......@@ -600,15 +613,19 @@ VAStatus vaCreateSurfaces (
)
{
VADriverContextP ctx;
VAStatus ret;
VAStatus vaStatus;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
vaStatus = ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
VA_TRACE(va_TraceCreateSurface, dpy, width, height, format, num_surfaces, surfaces);
ret = ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
va_FoolCreateSurfaces(dpy, width, height, format, num_surfaces, surfaces);
return ret;
VA_FOOL(va_FoolCreateSurfaces, dpy, width, height, format, num_surfaces, surfaces);
return vaStatus;
}
......@@ -637,12 +654,17 @@ VAStatus vaCreateContext (
)
{
VADriverContextP ctx;
VAStatus vaStatus;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
VA_TRACE(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
vaStatus = ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
flag, render_targets, num_render_targets, context );
VA_TRACE(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
return vaStatus;
}
VAStatus vaDestroyContext (
......@@ -670,9 +692,12 @@ VAStatus vaCreateBuffer (
VADriverContextP ctx;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
if (va_FoolCreateBuffer(dpy, context, type, size, num_elements, data, buf_id))
int ret = 0;
VA_FOOL(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data, buf_id);
if (ret)
return VA_STATUS_SUCCESS;
return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
}
......@@ -698,12 +723,15 @@ VAStatus vaMapBuffer (
{
VADriverContextP ctx;
VAStatus va_status;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
if (va_FoolMapBuffer(dpy, buf_id, pbuf))
VA_FOOL(va_FoolMapBuffer, dpy, buf_id, pbuf);
if (ret)
return VA_STATUS_SUCCESS;
va_status = ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
if (va_status == VA_STATUS_SUCCESS)
......@@ -720,9 +748,12 @@ VAStatus vaUnmapBuffer (
VADriverContextP ctx;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
if (va_FoolUnmapBuffer(dpy, buf_id))
int ret = 0;
VA_FOOL(va_FoolUnmapBuffer, dpy, buf_id);
if (ret)
return VA_STATUS_SUCCESS;
return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
}
......@@ -761,12 +792,15 @@ VAStatus vaBeginPicture (
)
{
VADriverContextP ctx;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
VA_TRACE(va_TraceBeginPicture, dpy, context, render_target);
if (va_FoolBeginPicture(dpy, context, render_target))
VA_FOOL(va_FoolBeginPicture, dpy, context, render_target);
if (ret)
return VA_STATUS_SUCCESS;
return ctx->vtable.vaBeginPicture( ctx, context, render_target );
......@@ -780,10 +814,13 @@ VAStatus vaRenderPicture (
)
{
VADriverContextP ctx;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
if (va_FoolRenderPicture(dpy, context, buffers, num_buffers))
VA_FOOL(va_FoolRenderPicture, dpy, context, buffers, num_buffers);
if (ret)
return VA_STATUS_SUCCESS;
VA_TRACE(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
......@@ -798,12 +835,15 @@ VAStatus vaEndPicture (
{
VAStatus va_status;
VADriverContextP ctx;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
if (va_FoolEndPicture(dpy, context)) {
VA_TRACE(va_TraceEndPicture, dpy, context);
return VA_STATUS_SUCCESS;
VA_FOOL(va_FoolEndPicture, dpy, context);
if (ret) {
VA_TRACE(va_TraceEndPicture, dpy, context);
return VA_STATUS_SUCCESS;
}
va_status = ctx->vtable.vaEndPicture( ctx, context );
......@@ -818,14 +858,21 @@ VAStatus vaSyncSurface (
VASurfaceID render_target
)
{
VAStatus va_status;
VADriverContextP ctx;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
if (va_FoolSyncSurface( dpy, render_target))
return VA_STATUS_SUCCESS;
VA_FOOL(va_FoolSyncSurface, dpy, render_target);
if (ret)
return VA_STATUS_SUCCESS;
return ctx->vtable.vaSyncSurface( ctx, render_target );
va_status = ctx->vtable.vaSyncSurface( ctx, render_target );
VA_TRACE(va_TraceSyncSurface, dpy, render_target);
return va_status;
}
VAStatus vaQuerySurfaceStatus (
......@@ -834,11 +881,35 @@ VAStatus vaQuerySurfaceStatus (
VASurfaceStatus *status /* out */
)
{
VAStatus va_status;
VADriverContextP ctx;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
va_status = ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
VA_TRACE(va_TraceQuerySurfaceStatus, dpy, render_target, status);
return va_status;
}
VAStatus vaQuerySurfaceError (
VADisplay dpy,
VASurfaceID surface,
VAStatus error_status,
void **error_info /*out*/
)
{
VAStatus va_status;
VADriverContextP ctx;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
va_status = ctx->vtable.vaQuerySurfaceError( ctx, surface, error_status, error_info );
VA_TRACE(va_TraceQuerySurfaceError, dpy, surface, error_status, error_info);
return va_status;
}
/* Get maximum number of image formats supported by the implementation */
......@@ -1033,11 +1104,15 @@ VAStatus vaQuerySubpictureFormats (
)
{
VADriverContextP ctx;
int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
if (va_FoolQuerySubpictureFormats(dpy, format_list, flags, num_formats))
VA_FOOL(va_FoolQuerySubpictureFormats, dpy, format_list, flags, num_formats);
if (ret)
return VA_STATUS_SUCCESS;
return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
}
......
......@@ -234,7 +234,8 @@ typedef enum
VAProfileVC1Main = 9,
VAProfileVC1Advanced = 10,
VAProfileH263Baseline = 11,
VAProfileJPEGBaseline = 12
VAProfileJPEGBaseline = 12,
VAProfileH264ConstrainedBaseline = 13
} VAProfile;
/*
......@@ -1168,6 +1169,8 @@ typedef struct _VAEncSliceParameterBuffer
struct {
unsigned int is_intra : 1;
unsigned int disable_deblocking_filter_idc : 2;
unsigned int uses_long_term_ref :1;
unsigned int is_long_term_ref :1;
} bits;
unsigned int value;
} slice_flags;
......@@ -1183,6 +1186,7 @@ typedef struct _VAEncSequenceParameterBufferH264
unsigned char level_idc;
unsigned int intra_period;
unsigned int intra_idr_period;
unsigned int max_num_ref_frames;
unsigned int picture_width_in_mbs;
unsigned int picture_height_in_mbs;
unsigned int bits_per_second;
......@@ -1310,10 +1314,14 @@ VAStatus vaBufferSetNumElements (
* enough for the encoder to attempt to limit its size.
* SLICE_OVERFLOW(bit9): At least one slice in the current frame has
* exceeded the maximum slice size specified.
* BITRATE_OVERFLOW(bit10): The peak bitrate was exceeded for this frame.
* AIR_MB_OVER_THRESHOLD: the number of MBs adapted to Intra MB
*/
#define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK 0xff
#define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK 0x100
#define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK 0x200
#define VA_CODED_BUF_STATUS_BITRATE_OVERFLOW 0x400
#define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD 0xff0000
/*
* device independent data structure for codedbuffer
......@@ -1434,6 +1442,32 @@ VAStatus vaQuerySurfaceStatus (
VASurfaceStatus *status /* out */
);
/*
* Client calls vaQuerySurfaceError with VA_STATUS_ERROR_DECODING_ERROR, server side returns
* an array of structure VASurfaceDecodeMBErrors, and the array is terminated by setting status=-1
*/
typedef struct _VASurfaceDecodeMBErrors
{
int status; /* 1 if hardware has returned detailed info below, -1 means this record is invalid */
unsigned int start_mb; /* start mb address with errors */
unsigned int end_mb; /* end mb address with errors */
} VASurfaceDecodeMBErrors;
/*
* After the application gets VA_STATUS_ERROR_DECODING_ERROR after calling vaSyncSurface(),
* it can call vaQuerySurfaceError to find out further details on the particular error.
* VA_STATUS_ERROR_DECODING_ERROR should be passed in as "error_status",
* upon the return, error_info will point to an array of _VASurfaceDecodeMBErrors structure,
* which is allocated and filled by libVA with detailed information on the missing or error macroblocks.
* The array is terminated if "status==-1" is detected.
*/
VAStatus vaQuerySurfaceError(
VADisplay dpy,
VASurfaceID surface,
VAStatus error_status,
void **error_info
);
/*
* Images and Subpictures
* VAImage is used to either get the surface data to client memory, or
......
......@@ -178,6 +178,13 @@ struct VADriverVTable
VASurfaceStatus *status /* out */
);
VAStatus (*vaQuerySurfaceError) (
VADriverContextP ctx,
VASurfaceID render_target,
VAStatus error_status,
void **error_info /*out*/
);
VAStatus (*vaPutSurface) (
VADriverContextP ctx,
VASurfaceID surface,
......
......@@ -51,6 +51,24 @@ struct VADriverVTableTPI
VASurfaceID *surface /* out */
);
VAStatus (*vaCreateSurfacesForUserPtr)(
VADisplay dpy,
int width,
int height,
int format,
int num_surfaces,
VASurfaceID *surfaces, /* out */
unsigned size, /* total buffer size need to be allocated */
unsigned int fourcc, /* expected fourcc */
unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
unsigned int chroma_u_stride, /* chroma stride */
unsigned int chroma_v_stride,
unsigned int luma_offset, /* could be 0 */
unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
unsigned int chroma_v_offset
);
VAStatus (*vaPutSurfaceBuf) (
VADisplay dpy,
VASurfaceID surface,
......
This diff is collapsed.
......@@ -26,12 +26,18 @@
#ifndef VA_FOOL_H
#define VA_FOOL_H
#include <stdio.h>
void va_FoolInit(VADisplay dpy);
int va_FoolEnd(VADisplay dpy);
int va_FoolGetFrame(FILE *input_fp, char *frame_buf);
int va_FoolCodedBuf(VADisplay dpy);
int va_FoolCreateConfig(
VADisplay dpy,
VAProfile profile,
......
This diff is collapsed.
/* The code refers to
* http://keyj.s2000.at/files/projects/h264-src.tar.gz
*/
#include <string.h>
#include <stdio.h>
#define SLICE_NUM 4
#define NAL_BUF_SIZE 65536 // maximum NAL unit size
#define RING_BUF_SIZE 8192 // input ring buffer size, MUST be a power of two!
typedef struct _nal_unit {
int NumBytesInNALunit;
int forbidden_zero_bit;
int nal_ref_idc;
int nal_unit_type;
unsigned char *last_rbsp_byte;
} nal_unit;
typedef struct _slice_header {
int first_mb_in_slice;
} slice_header;
static int get_next_nal_unit(FILE *input_fp, nal_unit *nalu);
static int get_unsigned_exp_golomb();
static void decode_slice_header(slice_header *sh);
static void input_read(FILE *input_fp, unsigned char *dest, int size);
static int input_get_bits(int bit_count);
static unsigned char nal_buf[NAL_BUF_SIZE];
static unsigned char ring_buf[RING_BUF_SIZE];
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;
#define SLICE_NUM 4
#define RING_MOD ((RING_BUF_SIZE)-1)
#define HALF_RING ((RING_BUF_SIZE)/2)
#define gnn_advance() do { \
ring_pos = (ring_pos+1)&RING_MOD; \
--input_remain; \
if (ring_pos==0) input_read(input_fp, &ring_buf[HALF_RING],HALF_RING); \
if (ring_pos==HALF_RING) input_read(input_fp, &ring_buf[0],HALF_RING); \
} while(0)
#define gnn_add_segment(end) do { \
int size = end-segment_start; \
if (size>0) { \
memcpy(&nal_buf[nalu_size],&ring_buf[segment_start],size); \
nalu_size += size; \
} \
segment_start = end&RING_MOD; \
} while(0)
static int input_get_bits(int bit_count)
{
int res = 0;
register unsigned int x =
(nal_buf[nal_pos]<<24)|
(nal_buf[nal_pos+1]<<16)|
(nal_buf[nal_pos+2]<<8)|
nal_buf[nal_pos+3];
res = (x>>(32-bit_count-nal_bit))&((1<<bit_count)-1);
nal_bit += bit_count;
nal_pos += nal_bit>>3;
nal_bit &= 7;
return res;
}
static int input_get_one_bit()
{
int res = (nal_buf[nal_pos]>>(7-nal_bit))&1;
if (++nal_bit>7) {
++nal_pos;
nal_bit = 0;
}
return res;
}
static int get_unsigned_exp_golomb()
{
int exp;
for(exp = 0; !input_get_one_bit(); ++exp);
if (exp)
return (1<<exp) - 1 + input_get_bits(exp);
else
return 0;
}
static void decode_slice_header(slice_header *sh )
{
memset((void*)sh,0,sizeof(slice_header));
sh->first_mb_in_slice = get_unsigned_exp_golomb();
}
static void input_read(FILE *input_fp, unsigned char *dest, int size)
{
int count = fread(dest, 1, size, input_fp);
input_remain += count;
}
static int get_next_nal_unit(FILE *input_fp, nal_unit *nalu)
{
int i,segment_start;
int nalu_size = 0;
int NumBytesInRbsp = 0;
/* search for the next NALU start
* here is the sync that the start of the NALU is 0x00000001
*/
for (;;) {
if (input_remain<= 4) {
/* clip restart */
memset(ring_buf,0,sizeof(char)*RING_BUF_SIZE);
memset(nal_buf,0,sizeof(char)*NAL_BUF_SIZE);
fseek(input_fp,0,SEEK_SET);
input_remain = 0;
input_read(input_fp, ring_buf, RING_BUF_SIZE);
ring_pos = 0;
return 1;
}
if ((!ring_buf[ring_pos]) &&
(!ring_buf[(ring_pos+1)&RING_MOD]) &&
(!ring_buf[(ring_pos+2)&RING_MOD]) &&
( ring_buf[(ring_pos+3)&RING_MOD]==1))
break;
gnn_advance();
}
for(i=0;i<4;++i)
gnn_advance();
/* add bytes to the NALU until the end is found */
segment_start = ring_pos;
while (input_remain) {
if ((!ring_buf[ring_pos]) &&
(!ring_buf[(ring_pos+1)&RING_MOD]) &&
(!ring_buf[(ring_pos+2)&RING_MOD]))
break;
ring_pos = (ring_pos+1)&RING_MOD;
--input_remain;
if (ring_pos==0) {
gnn_add_segment(RING_BUF_SIZE);
input_read(input_fp, &ring_buf[HALF_RING],HALF_RING);
}
if (ring_pos==HALF_RING) {
gnn_add_segment(HALF_RING);
input_read(input_fp, &ring_buf[0], HALF_RING);
}
}
gnn_add_segment(ring_pos);
/* read the NAL unit */
nal_pos = 0; nal_bit = 0;
nalu->forbidden_zero_bit = input_get_bits(1);
nalu->nal_ref_idc = input_get_bits(2);
nalu->nal_unit_type = input_get_bits(5);
nalu->last_rbsp_byte = &nal_buf[nalu_size-1];
nalu->NumBytesInNALunit = nalu_size;
return 1;
}
int va_FoolGetFrame(FILE *input_fp, char *frame_buf)
{
int i = 0, frame_pos = 0;
static slice_header sh;
static nal_unit nalu;
/* 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
*/
if (!frame_no)
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) {
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));
frame_pos += nalu.NumBytesInNALunit;
}
}
return 1;
}
......@@ -98,6 +98,48 @@ VAStatus vaCreateSurfaceFromV4L2Buf(
return VA_STATUS_ERROR_UNIMPLEMENTED;
}
/*
* The surfaces could be shared and accessed with extern devices
* which has special requirements, e.g. stride alignment
* This API is used to force libVA video surfaces are allocated
* according to these external requirements
* Special API for V4L2 user pointer support
*/
VAStatus vaCreateSurfacesForUserPtr(
VADisplay dpy,
int width,
int height,
int format,
int num_surfaces,
VASurfaceID *surfaces, /* out */
unsigned size, /* total buffer size need to be allocated */
unsigned int fourcc, /* expected fourcc */
unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
unsigned int chroma_u_stride, /* chroma stride */
unsigned int chroma_v_stride,
unsigned int luma_offset, /* could be 0 */
unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
unsigned int chroma_v_offset
)
{
VADriverContextP ctx;
struct VADriverVTableTPI *tpi;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
tpi = (struct VADriverVTableTPI *)ctx->vtable_tpi;
if (tpi && tpi->vaCreateSurfacesForUserPtr) {
return tpi->vaCreateSurfacesForUserPtr( ctx, width, height, format, num_surfaces,
surfaces,size, fourcc, luma_stride, chroma_u_stride,
chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset );
} else
return VA_STATUS_ERROR_UNIMPLEMENTED;
}
VAStatus vaPutSurfaceBuf (
VADisplay dpy,
VASurfaceID surface,
......
......@@ -68,6 +68,31 @@ VAStatus vaPutSurfaceBuf (
unsigned int flags /* de-interlacing flags */
);
/*
* The surfaces could be shared and accessed with extern devices
* which has special requirements, e.g. stride alignment
* This API is used to force libVA video surfaces are allocated
* according to these external requirements
* Special API for V4L2 user pointer support
*/
VAStatus vaCreateSurfacesForUserPtr(
VADisplay dpy,
int width,
int height,
int format,
int num_surfaces,
VASurfaceID *surfaces, /* out */
unsigned size, /* total buffer size need to be allocated */
unsigned int fourcc, /* expected fourcc */
unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
unsigned int chroma_u_stride, /* chroma stride */
unsigned int chroma_v_stride,
unsigned int luma_offset, /* could be 0 */
unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
unsigned int chroma_v_offset
);
#ifdef __cplusplus
}
#endif
This diff is collapsed.
......@@ -85,6 +85,24 @@ void va_TraceEndPicture(
VAContextID context
);
void va_TraceSyncSurface(
VADisplay dpy,
VASurfaceID render_target
);
void va_TraceQuerySurfaceStatus(
VADisplay dpy,
VASurfaceID render_target,
VASurfaceStatus *status /* out */
);
void va_TraceQuerySurfaceError(
VADisplay dpy,
VASurfaceID surface,
VAStatus error_status,
void **error_info /*out*/
);
void va_TraceMaxNumDisplayAttributes (
VADisplay dpy,
......
/*
* 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_VERSION_H
#define VA_VERSION_H
/**
* VA_MAJOR_VERSION:
*
* The major version of the VA library (1, if %VA_VERSION is 1.2.3)
*/
#define VA_MAJOR_VERSION (0)
/**
* VA_MINOR_VERSION:
*
* The minor version of the VA library (2, if %VA_VERSION is 1.2.3)
*/
#define VA_MINOR_VERSION (31)
/**
* VA_MICRO_VERSION:
*
* The micro version of the VA library (3, if %VA_VERSION is 1.2.3)
*/
#define VA_MICRO_VERSION (1)
/**
* VA_VERSION:
*
* The full version of the VA library, like 1.2.3
*/
#define VA_VERSION 0.31.1
/**
* VA_VERSION_S:
*
* The full version of the VA library, in string form (suited for
* string concatenation)
*/
#define VA_VERSION_S "0.31.1"
/**
* VA_VERSION_HEX:
*
* Numerically encoded version of the VA library, like 0x010203
*/
#define VA_VERSION_HEX ((VA_MAJOR_VERSION << 24) | \
(VA_MINOR_VERSION << 16) | \
(VA_MICRO_VERSION << 8))
/**
* VA_CHECK_VERSION:
* @major: major version, like 1 in 1.2.3
* @minor: minor version, like 2 in 1.2.3
* @micro: micro version, like 3 in 1.2.3
*
* Evaluates to %TRUE if the version of the VA library is greater
* than @major, @minor and @micro
*/
#define VA_CHECK_VERSION(major,minor,micro) \
(VA_MAJOR_VERSION > (major) || \
(VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \
(VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro)))
#endif /* VA_VERSION_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment