1. add interface VARenderDevice for output the video into an external device...
authorAustin Yuan <shengquan.yuan@gmail.com>
Fri, 1 Apr 2011 03:34:47 +0000 (11:34 +0800)
committerAustin Yuan <shengquan.yuan@gmail.com>
Fri, 1 Apr 2011 03:34:47 +0000 (11:34 +0800)
    2. add interface VARenderMode for APP to swith between overlay and GPU post-processing
    3. add VADisplayAttribOverlayColorKey/VADisplayAttribOverlayAutoPaintColorKey which is simliar to Xv for overlay post-processing
    4. fix the build issue on Android 2.3

Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
Signed-off-by: Jason Hu <jason.hu@intel.com>
Signed-off-by: Zhaohan Ren <zhaohan.ren@intel.com>
17 files changed:
i965_drv_video/i965_drv_video.c
libva.spec
style_unify [new file with mode: 0755]
test/putsurface/Android.mk
test/putsurface/loadsurface.h
test/vainfo/Android.mk
va/Android.mk
va/Makefile.am
va/android/Makefile.am
va/android/va_android.cpp
va/va.c
va/va.h
va/va_backend.h
va/va_backend_tpi.h
va/va_fool.c
va/va_trace.c
va/va_trace.h

index 31f19dd..4a7397f 100644 (file)
@@ -956,7 +956,7 @@ i965_BufferSetNumElements(VADriverContextP ctx,
     } else {
         obj_buffer->num_elements = num_elements;
         if (obj_buffer->buffer_store != NULL) {
-            obj_buffer->buffer_store->num_elements = num_elements; 
+            obj_buffer->buffer_store->num_elements = num_elements;
         }
     }
 
index bb51806..28842a3 100644 (file)
@@ -79,6 +79,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libva-x11.so.%{libversion}
 %{_libdir}/libva-glx.so.1
 %{_libdir}/libva-glx.so.%{libversion}
+%{_libdir}/libva-egl.so.1
+%{_libdir}/libva-egl.so.%{libversion}
 %{_bindir}/vainfo
 %{_bindir}/test_*
 %{_bindir}/h264encode
@@ -95,10 +97,12 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libva-tpi.so
 %{_libdir}/libva-x11.so
 %{_libdir}/libva-glx.so
+%{_libdir}/libva-egl.so
 %{_libdir}/pkgconfig/libva.pc
 %{_libdir}/pkgconfig/libva-tpi.pc
 %{_libdir}/pkgconfig/libva-x11.pc
 %{_libdir}/pkgconfig/libva-glx.pc
+%{_libdir}/pkgconfig/libva-egl.pc
 
 %changelog
 * Tue Jan 25 2011 Austin Yuan <shengquan.yuan@intel.com> 1.0.1
diff --git a/style_unify b/style_unify
new file mode 100755 (executable)
index 0000000..4915e63
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+file=$(find . -name "*.[ch]" -o -name "*.cpp")
+for i in $file
+do 
+    echo $i 
+    astyle --style=linux -s4 -c -s -p -U -H -n $i
+done
+
+
+
index 9bf1438..8bcfd0c 100644 (file)
@@ -14,6 +14,7 @@ LOCAL_CFLAGS += \
 LOCAL_C_INCLUDES += \
   $(TARGET_OUT_HEADERS)/libva
 
+LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := putsurface
 
 LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
index b14241f..1aac393 100644 (file)
@@ -99,8 +99,8 @@ static int upload_surface(VADisplay va_dpy, VASurfaceID surface_id,
     vaMapBuffer(va_dpy,surface_image.buf,&surface_p);
     assert(VA_STATUS_SUCCESS == va_status);
         
-    U_start = surface_p + surface_image.offsets[1];
-    V_start = surface_p + surface_image.offsets[2];
+    U_start = (char *)surface_p + surface_image.offsets[1];
+    V_start = (char *)surface_p + surface_image.offsets[2];
 
     /* assume surface is planar format */
     yuvgen_planar(surface_image.width, surface_image.height,
index b7c0c0b..0aac2cf 100644 (file)
@@ -14,6 +14,7 @@ LOCAL_CFLAGS += \
 LOCAL_C_INCLUDES += \
   $(TARGET_OUT_HEADERS)/libva
 
+LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := vainfo
 
 LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils
index f5be3d0..a5ff8d2 100755 (executable)
@@ -14,7 +14,7 @@ LOCAL_SRC_FILES := \
        va.c \
        va_trace.c \
        va_fool.c \
-       va_fool_getframe.c 
+       va_fool_getframe.c
 
 LOCAL_CFLAGS += \
        -DANDROID \
@@ -34,6 +34,7 @@ LOCAL_COPY_HEADERS := \
 
 LOCAL_COPY_HEADERS_TO := libva/va
 
+LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := libva
 
 LOCAL_SHARED_LIBRARIES := libdl libdrm libcutils
@@ -69,6 +70,7 @@ LOCAL_COPY_HEADERS_TO := libva/va
 
 LOCAL_COPY_HEADERS := va_android.h             
 
+LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := libva-android
 
 LOCAL_SHARED_LIBRARIES := libva
@@ -76,6 +78,33 @@ LOCAL_SHARED_LIBRARIES := libva
 include $(BUILD_SHARED_LIBRARY)
 
 
+# For libva-egl
+# =====================================================
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+       egl/va_egl.c
+
+LOCAL_CFLAGS += \
+       -DANDROID
+
+LOCAL_C_INCLUDES += \
+       $(TARGET_OUT_HEADERS)/libva \
+       $(LOCAL_PATH)/x11
+
+LOCAL_COPY_HEADERS_TO := libva/va
+
+LOCAL_COPY_HEADERS := egl/va_egl.h egl/va_backend_egl.h
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libva-egl
+
+LOCAL_SHARED_LIBRARIES := libva
+
+include $(BUILD_SHARED_LIBRARY)
+
+
 # For libva-tpi
 # =====================================================
 
@@ -97,6 +126,7 @@ LOCAL_COPY_HEADERS := \
 
 LOCAL_SHARED_LIBRARIES := libva
 
+LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := libva-tpi
 
 include $(BUILD_SHARED_LIBRARY)
index a73fde7..0d955c4 100644 (file)
@@ -93,7 +93,7 @@ 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_dummy.h va_version.h va_backend_tpi.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
index d86ea86..f7ca6f1 100644 (file)
@@ -10,8 +10,8 @@
 # secret laws and treaty provisions. No part of the Material may be used,
 # copied, reproduced, modified, published, uploaded, posted, transmitted,
 # distributed, or disclosed in any way without Intel's prior express written
-# permission. 
-# 
+# permission.
+#
 # No license under any patent, copyright, trade secret or other intellectual
 # property right is granted to or conferred upon you by disclosure or delivery
 # of the Materials, either expressly, by implication, inducement, estoppel or
index b4727aa..c0c2ded 100644 (file)
@@ -328,7 +328,7 @@ VAStatus vaPutSurface (
              destx, desty, destw, desth,
              cliprects, number_cliprects, flags );
     
-    return ctx->vtable.vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch, 
+    return ctx->vtable->vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch, 
                                      destx, desty, destw, desth,
                                      cliprects, number_cliprects, flags );
 }
diff --git a/va/va.c b/va/va.c
index 2eea02b..f0f0082 100644 (file)
--- a/va/va.c
+++ b/va/va.c
@@ -28,6 +28,7 @@
 #include "va_backend.h"
 #include "va_trace.h"
 #include "va_fool.h"
+#include "config.h"
 
 #include <assert.h>
 #include <stdarg.h>
@@ -191,7 +192,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
     }
 
     search_path = strdup((const char *)search_path);
-    driver_dir = strtok_r((const char *)search_path, ":", &saveptr);
+    gdriver_dir = strtok_r((const char *)search_path, ":", &saveptr);
     while(driver_dir)
     {
         void *handle = NULL;
@@ -430,6 +431,9 @@ VAStatus vaInitialize (
 
     if (driver_name)
         free(driver_name);
+    
+    VA_TRACE(va_Initialize, dpy, major_version, minor_version);
+
     return vaStatus;
 }
 
@@ -459,6 +463,8 @@ VAStatus vaTerminate (
   if (VA_STATUS_SUCCESS == vaStatus)
       pDisplayContext->vaDestroy(pDisplayContext);
 
+  VA_TRACE(va_Terminate, dpy);
+
   va_TraceEnd(dpy);
 
   va_FoolEnd(dpy);
@@ -578,7 +584,7 @@ VAStatus vaCreateConfig (
   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);
@@ -626,7 +632,7 @@ VAStatus vaCreateSurfaces (
   VADriverContextP ctx;
   VAStatus vaStatus;
   int ret = 0;
-  
+
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
 
@@ -704,11 +710,11 @@ VAStatus vaCreateBuffer (
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
   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);
 }
 
@@ -742,7 +748,7 @@ VAStatus vaMapBuffer (
   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)
@@ -760,11 +766,11 @@ VAStatus vaUnmapBuffer (
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
   int ret = 0;
-  
+
   VA_FOOL(va_FoolUnmapBuffer, dpy, buf_id);
   if (ret)
       return VA_STATUS_SUCCESS;
-  
+
   return ctx->vtable->vaUnmapBuffer( ctx, buf_id );
 }
 
@@ -804,7 +810,7 @@ VAStatus vaBeginPicture (
 {
   VADriverContextP ctx;
   int ret = 0;
-  
+
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
 
@@ -826,7 +832,7 @@ VAStatus vaRenderPicture (
 {
   VADriverContextP ctx;
   int ret = 0;
-  
+
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
 
@@ -847,7 +853,7 @@ VAStatus vaEndPicture (
   VAStatus va_status;
   VADriverContextP ctx;
   int ret = 0;
-  
+
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
 
@@ -872,7 +878,7 @@ VAStatus vaSyncSurface (
   VAStatus va_status;
   VADriverContextP ctx;
   int ret = 0;
-  
+
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
 
@@ -1116,14 +1122,14 @@ VAStatus vaQuerySubpictureFormats (
 {
   VADriverContextP ctx;
   int ret = 0;
-  
+
   CHECK_DISPLAY(dpy);
   ctx = CTX(dpy);
-  
+
   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);
 }
 
diff --git a/va/va.h b/va/va.h
index 596ee5a..0cf0117 100644 (file)
--- a/va/va.h
+++ b/va/va.h
@@ -60,7 +60,7 @@
  * 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 
+ *                                        update VAAPI to 0.32.0
  *
  * Acknowledgements:
  *  Some concepts borrowed from XvMC and XvImage.
@@ -1320,12 +1320,14 @@ VAStatus vaBufferSetNumElements (
  * 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.
+ * BITRATE_HIGH(bit11): The frame size got within the safety margin of the maximum size (VCM only)
  * 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_BITRATE_HIGH               0x800
 #define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD      0xff0000
 
 /*
@@ -1447,6 +1449,12 @@ VAStatus vaQuerySurfaceStatus (
     VASurfaceStatus *status    /* out */
 );
 
+typedef enum
+{
+    VA_DECODE_SLICE_MISSING            = 0,
+    VA_DECODE_MB_ERROR                 = 1,
+} VA_DECODE_ERROR_TYPE;
+
 /*
  * 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
@@ -1456,6 +1464,7 @@ 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 */
+    VA_DECODE_ERROR_TYPE decode_error_type;
 } VASurfaceDecodeMBErrors;
 
 /*
@@ -1842,6 +1851,23 @@ typedef enum
 #define VA_OOL_DEBLOCKING_FALSE 0x00000000
 #define VA_OOL_DEBLOCKING_TRUE  0x00000001
 
+/* Render mode */
+typedef enum
+{
+    VARenderModeUndefined          = 0,
+    VARenderModeLocalOverlay       = 1,
+    VARenderModeLocalGPU           = 2,
+    VARenderModeExternalOverlay    = 4,
+    VARenderModeExternalGPU        = 8
+} VARenderMode;
+
+/* Render device */
+typedef enum
+{
+    VARenderDeviceUndefined     = 0,
+    VARenderDeviceLocal         = 1,
+    VARenderDeviceExternal      = 2
+} VARenderDevice;
 
 /* Currently defined display attribute types */
 typedef enum
@@ -1853,7 +1879,8 @@ typedef enum
     /* client can specifiy a background color for the target window
      * the new feature of video conference,
      * the uncovered area of the surface is filled by this color
-     * also it will blend with the decoded video color*/
+     * also it will blend with the decoded video color
+     */
     VADisplayAttribBackgroundColor      = 4,
     /*
      * this is a gettable only attribute. For some implementations that use the
@@ -1888,6 +1915,32 @@ typedef enum
      *      b: background color of the drawable
      */
     VADisplayAttribBlendColor          = 13,
+    /*
+     * Indicate driver to skip painting color key or not.
+     * only applicable if the render is overlay
+     */
+    VADisplayAttribOverlayAutoPaintColorKey   = 14,
+    /*
+     * customized overlay color key, the format is RGB888
+     * [23:16] = Red, [15:08] = Green, [07:00] = Blue.
+     */
+    VADisplayAttribOverlayColorKey     = 15,
+    /*
+     * The hint for the implementation of vaPutSurface
+     * normally, the driver could use an overlay or GPU to render the surface on the screen
+     * this flag provides APP the flexibity to switch the render dynamically
+     */
+    VADisplayAttribRenderMode           = 16,
+    /*
+     * specify if vaPutSurface needs to render into specified monitors
+     * one example is that one external monitor (e.g. HDMI) is enabled, 
+     * but the window manager is not aware of it, and there is no associated drawable
+     */
+    VADisplayAttribRenderDevice        = 17,
+    /*
+     * specify vaPutSurface render area if there is no drawable on the monitor
+     */
+    VADisplayAttribRenderRect          = 18,
 } VADisplayAttribType;
 
 /* flags for VADisplayAttribute */
index 736c680..060afd3 100644 (file)
@@ -416,7 +416,7 @@ struct VADriverContext
      * private API. The driver implementation is responsible for the
      * allocation and deallocation of this structure.
      */
-    void *vtable_tpi; 
+    void *vtable_tpi;
 
     void *native_dpy;
     int x11_screen;
@@ -434,7 +434,7 @@ struct VADriverContext
     
     void *dri_state;
     void *glx;                         /* opaque for GLX code */
-    
+
     unsigned long reserved[45];         /* reserve for future add-ins, decrease the subscript accordingly */
 };
 
index 52f2073..f67b30f 100644 (file)
@@ -52,7 +52,7 @@ struct VADriverVTableTPI
         );
 
         VAStatus (*vaCreateSurfacesForUserPtr)(
-                VADisplay dpy,
+               VADriverContextP ctx,
                 int width,
                 int height,
                 int format,
@@ -70,7 +70,7 @@ struct VADriverVTableTPI
 
 
        VAStatus (*vaPutSurfaceBuf) (
-               VADisplay dpy,
+               VADriverContextP ctx,
                VASurfaceID surface,
                unsigned char* data,
                int* data_len,
index b2d7449..2d1ec4c 100644 (file)
@@ -139,7 +139,7 @@ VAStatus vaLockSurface(VADisplay dpy,
         unsigned int *chroma_u_offset,
         unsigned int *chroma_v_offset,
         unsigned int *buffer_name,
-        void **buffer 
+        void **buffer
 );
 
 VAStatus vaUnlockSurface(VADisplay dpy,
@@ -265,7 +265,7 @@ static int yuvgen_planar(
 
         /* fill garbage data into the other field */
         if (((field == VA_TOP_FIELD) && (row &1))
-                || ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) { 
+                || ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) {
             memset(Y_row, 0xff, width);
             continue;
         }
@@ -554,7 +554,7 @@ VAStatus va_FoolUnmapBuffer(
 
     if (FOOL_ENCODE(idx) || FOOL_DECODE(idx))
         return 1; /* fool buffer creation */
-    
+
     return 0;
 }
 
index 553da70..c0c0d3f 100644 (file)
@@ -404,6 +404,30 @@ void va_TraceSurface(VADisplay dpy)
     va_TraceMsg(idx, "\tchecksum = 0x%02x\n", check_sum & 0xff);
 }
 
+
+VAStatus va_TraceInitialize (
+    VADisplay dpy,
+    int *major_version,         /* out */
+    int *minor_version          /* out */
+)
+{
+    int i;
+    DPY2INDEX(dpy);
+
+    TRACE_FUNCNAME(idx);
+}
+
+VAStatus va_TraceTerminate (
+    VADisplay dpy
+)
+{
+    int i;
+    DPY2INDEX(dpy);
+
+    TRACE_FUNCNAME(idx);
+}
+
+
 void va_TraceCreateConfig(
     VADisplay dpy,
     VAProfile profile, 
@@ -1273,9 +1297,10 @@ void va_TraceBeginPicture(
     DPY2INDEX(dpy);
 
     TRACE_FUNCNAME(idx);
-    
+
     va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
     va_TraceMsg(idx, "\trender_targets = 0x%08x\n", render_target);
+    va_TraceMsg(idx, "\tframe_count  = #%d\n", trace_context[idx].trace_frame_no);
 
     trace_context[idx].trace_rendertarget = render_target; /* for surface data dump after vaEndPicture */
 
index 73f6f99..74c44c8 100644 (file)
@@ -30,6 +30,16 @@ void va_TraceEnd(VADisplay dpy);
 
 void va_TraceMsg(int idx, const char *msg, ...);
 
+VAStatus va_TraceInitialize (
+    VADisplay dpy,
+    int *major_version,         /* out */
+    int *minor_version          /* out */
+);
+
+VAStatus va_TraceTerminate (
+    VADisplay dpy
+);
+
 void va_TraceCreateConfig(
     VADisplay dpy,
     VAProfile profile,