• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/libva


Commit MetaInfo

Revision881b49c5f154ee6603eee4aebb8becae6097a4bd (tree)
Zeit2010-10-28 08:18:18
AutorAustin Yuan <shengquan.yuan@gmai...>
CommiterAustin Yuan

Log Message

libva-1.0.6

1) Refinement for VA_TRACE, new LIBVA_FOOL, see the description in va_trace.c/va_fool.c
2) vaPutSurface flag VA_ENABLE_BLEND to blend the surface with a color
3) libva.spec for RPM package
4) Update VAAPI for dynamic bit rate control/AIR/maximum slice size ctrl
5) Added VA_STATUS_ERROR_DECODING/ENCODING_ERROR to report decode/encode error
6) Add config.h/va_vesion.h for Android
7) Update "vainfo.c" for Android

Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
Signed-off-by: Binglin Chen <binglin.chen@intel.com>
Signed-off-by: Fei Jiang <fei.jiang@intel.com>
Signed-off-by: Elaine Wang <elaine.wang@intel.com>
Signed-off-by: Ren Zhaohan <zhaohan.ren@intel.com>
Signed-off-by: Jerry Dong <jerry.dong@intel.com>

Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>

Ändern Zusammenfassung

Diff

--- a/Android.mk
+++ b/Android.mk
@@ -1,5 +1,7 @@
11 # Recursive call sub-folder Android.mk
22 #
3+# include $(call all-subdir-makefiles)
34 LOCAL_PATH := $(my-dir)
45
56 include $(LOCAL_PATH)/va/Android.mk
7+
--- a/COPYING
+++ b/COPYING
@@ -5,11 +5,11 @@
55 distribute, sub license, and/or sell copies of the Software, and to
66 permit persons to whom the Software is furnished to do so, subject to
77 the following conditions:
8-
8+
99 The above copyright notice and this permission notice (including the
1010 next paragraph) shall be included in all copies or substantial portions
1111 of the Software.
12-
12+
1313 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1414 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1515 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
--- a/configure.ac
+++ b/configure.ac
@@ -7,11 +7,11 @@
77 # distribute, sub license, and/or sell copies of the Software, and to
88 # permit persons to whom the Software is furnished to do so, subject to
99 # the following conditions:
10-#
10+#
1111 # The above copyright notice and this permission notice (including the
1212 # next paragraph) shall be included in all copies or substantial portions
1313 # of the Software.
14-#
14+#
1515 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1616 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1717 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -29,7 +29,7 @@ m4_define([libva_version],
2929 [libva_major_version.libva_minor_version.libva_micro_version])
3030
3131 # if the library source code has changed, increment revision
32-m4_define([libva_lt_revision], [5])
32+m4_define([libva_lt_revision], [6])
3333 # if any interface was added/removed/changed, then inc current, reset revision
3434 m4_define([libva_lt_current], [1])
3535 # if any interface was added since last public release, then increment age
--- a/dummy_drv_video/dummy_drv_video.c
+++ b/dummy_drv_video/dummy_drv_video.c
@@ -1058,7 +1058,7 @@ VAStatus dummy_PutSurface(
10581058 Drawable drawable = (Drawable)draw;
10591059
10601060 (void)drawable;
1061-
1061+
10621062 return VA_STATUS_ERROR_UNKNOWN;
10631063 }
10641064
--- a/test/vainfo.c
+++ b/test/vainfo.c
@@ -22,7 +22,12 @@
2222 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323 */
2424
25+#ifndef ANDROID
2526 #include <va/va_x11.h>
27+#else
28+#include "va/va_android.h"
29+#define Display unsigned int
30+#endif
2631
2732 #include <stdarg.h>
2833 #include <stdio.h>
@@ -87,7 +92,11 @@ int main(int argc, const char* argv[])
8792 else
8893 name = argv[0];
8994
95+#ifndef ANDROID
9096 dpy = XOpenDisplay(":0.0");
97+#else
98+ dpy = (Display*)malloc(sizeof(Display));
99+#endif
91100 if (NULL == dpy)
92101 {
93102 fprintf(stderr, "%s: Error, can't open display: '%s'\n", name, display ? display : "");
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -13,6 +13,7 @@ include $(CLEAR_VARS)
1313 LOCAL_SRC_FILES := \
1414 va.c \
1515 va_trace.c \
16+ va_fool.c
1617
1718 LOCAL_CFLAGS += \
1819 -DANDROID \
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -27,7 +27,7 @@ INCLUDES = \
2727 LDADD = \
2828 $(LIBVA_LT_LDFLAGS)
2929
30-libva_la_SOURCES = va.c va_trace.c
30+libva_la_SOURCES = va.c va_trace.c va_fool.c
3131 libva_ladir = $(libdir)
3232 libva_la_LDFLAGS = $(LDADD) -no-undefined
3333 libva_la_LIBADD = $(LIBVA_LIBS) -ldl
--- a/va/android/va_android.cpp
+++ b/va/android/va_android.cpp
@@ -250,7 +250,7 @@ VADisplay vaGetDisplay (
250250 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
251251 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
252252 pDisplayContexts = pDisplayContext;
253- pDriverContext->dri_state = dri_state;
253+ pDriverContext->dri_state = dri_state;
254254 dpy = (VADisplay)pDisplayContext;
255255 }
256256 else
@@ -272,6 +272,33 @@ VADisplay vaGetDisplay (
272272
273273
274274 #ifdef ANDROID
275+extern "C" {
276+ extern int fool_postp; /* do nothing for vaPutSurface if set */
277+ extern int trace_flag; /* trace vaPutSurface parameters */
278+
279+ void va_TracePutSurface (
280+ VADisplay dpy,
281+ VASurfaceID surface,
282+ void *draw, /* the target Drawable */
283+ short srcx,
284+ short srcy,
285+ unsigned short srcw,
286+ unsigned short srch,
287+ short destx,
288+ short desty,
289+ unsigned short destw,
290+ unsigned short desth,
291+ VARectangle *cliprects, /* client supplied clip list */
292+ unsigned int number_cliprects, /* number of clip rects in the clip list */
293+ unsigned int flags /* de-interlacing flags */
294+ );
295+}
296+
297+#define VA_TRACE(trace_func,...) \
298+ if (trace_flag) { \
299+ trace_func(__VA_ARGS__); \
300+ }
301+
275302 VAStatus vaPutSurface (
276303 VADisplay dpy,
277304 VASurfaceID surface,
@@ -291,8 +318,16 @@ VAStatus vaPutSurface (
291318 {
292319 VADriverContextP ctx;
293320
321+ if (fool_postp)
322+ return VA_STATUS_SUCCESS;
323+
294324 CHECK_DISPLAY(dpy);
295325 ctx = CTX(dpy);
326+
327+ VA_TRACE(va_TracePutSurface, dpy, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch,
328+ destx, desty, destw, desth,
329+ cliprects, number_cliprects, flags );
330+
296331 return ctx->vtable.vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch,
297332 destx, desty, destw, desth,
298333 cliprects, number_cliprects, flags );
--- a/va/va.c
+++ b/va/va.c
@@ -26,6 +26,7 @@
2626 #include "va.h"
2727 #include "va_backend.h"
2828 #include "va_trace.h"
29+#include "va_fool.h"
2930 #include "config.h"
3031
3132 #include <assert.h>
@@ -57,17 +58,65 @@
5758 extern int trace_flag;
5859 #define VA_TRACE(trace_func,...) \
5960 if (trace_flag) { \
60- va_TraceMsg("========%s========\n", __func__); \
6161 trace_func(__VA_ARGS__); \
6262 }
6363
64+/*
65+ * read a config "env" for libva.conf or from environment setting
66+ * liva.conf has higher priority
67+ * return 0: the "env" is set, and the value is copied into env_value
68+ * 1: the env is not set
69+ */
70+int va_parseConfig(char *env, char *env_value)
71+{
72+ char *token, *value, *saveptr;
73+ char oneline[1024];
74+ FILE *fp=NULL;
75+
76+
77+ if (env == NULL)
78+ return 1;
79+
80+ fp = fopen("/etc/libva.conf", "r");
81+ while (fp && (fgets(oneline, 1024, fp) != NULL)) {
82+ if (strlen(oneline) == 1)
83+ continue;
84+ token = strtok_r(oneline, "=\n", &saveptr);
85+ value = strtok_r(NULL, "=\n", &saveptr);
86+
87+ if (NULL == token || NULL == value)
88+ continue;
89+
90+ if (strcmp(token, env) == 0) {
91+ if (env_value)
92+ strncpy(env_value,value, 1024);
93+
94+ fclose(fp);
95+
96+ return 0;
97+ }
98+ }
99+ if (fp)
100+ fclose(fp);
101+
102+ /* no setting in config file, use env setting */
103+ if (getenv(env)) {
104+ if (env_value)
105+ strncpy(env_value, getenv(env), 1024);
106+
107+ return 0;
108+ }
109+
110+ return 1;
111+}
112+
64113 int vaDisplayIsValid(VADisplay dpy)
65114 {
66115 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
67116 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
68117 }
69118
70-static void va_errorMessage(const char *msg, ...)
119+void va_errorMessage(const char *msg, ...)
71120 {
72121 va_list args;
73122
@@ -77,7 +126,7 @@ static void va_errorMessage(const char *msg, ...)
77126 va_end(args);
78127 }
79128
80-static void va_infoMessage(const char *msg, ...)
129+void va_infoMessage(const char *msg, ...)
81130 {
82131 va_list args;
83132
@@ -340,7 +389,9 @@ VAStatus vaInitialize (
340389
341390 CHECK_DISPLAY(dpy);
342391
343- va_TraceInit();
392+ va_TraceInit(dpy);
393+
394+ va_FoolInit(dpy);
344395
345396 va_infoMessage("libva version %s\n", VA_VERSION_S);
346397
@@ -397,7 +448,9 @@ VAStatus vaTerminate (
397448 if (VA_STATUS_SUCCESS == vaStatus)
398449 pDisplayContext->vaDestroy(pDisplayContext);
399450
400- va_TraceEnd();
451+ va_TraceEnd(dpy);
452+
453+ va_FoolEnd(dpy);
401454
402455 return vaStatus;
403456 }
@@ -511,6 +564,7 @@ VAStatus vaCreateConfig (
511564 ctx = CTX(dpy);
512565
513566 VA_TRACE(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
567+ va_FoolCreateConfig(dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
514568 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
515569 }
516570
@@ -552,11 +606,15 @@ VAStatus vaCreateSurfaces (
552606 )
553607 {
554608 VADriverContextP ctx;
609+ VAStatus ret;
555610 CHECK_DISPLAY(dpy);
556611 ctx = CTX(dpy);
557612
558613 VA_TRACE(va_TraceCreateSurface, dpy, width, height, format, num_surfaces, surfaces);
559- return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
614+
615+ ret = ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
616+ va_FoolCreateSurfaces(dpy, width, height, format, num_surfaces, surfaces);
617+ return ret;
560618 }
561619
562620
@@ -619,6 +677,8 @@ VAStatus vaCreateBuffer (
619677 CHECK_DISPLAY(dpy);
620678 ctx = CTX(dpy);
621679
680+ if (va_FoolCreateBuffer(dpy, context, type, size, num_elements, data, buf_id))
681+ return VA_STATUS_SUCCESS;
622682 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
623683 }
624684
@@ -643,10 +703,19 @@ VAStatus vaMapBuffer (
643703 )
644704 {
645705 VADriverContextP ctx;
706+ VAStatus va_status;
707+
646708 CHECK_DISPLAY(dpy);
647709 ctx = CTX(dpy);
710+
711+ if (va_FoolMapBuffer(dpy, buf_id, pbuf))
712+ return VA_STATUS_SUCCESS;
713+ va_status = ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
648714
649- return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
715+ if (va_status == VA_STATUS_SUCCESS)
716+ VA_TRACE(va_TraceMapBuffer, dpy, buf_id, pbuf);
717+
718+ return va_status;
650719 }
651720
652721 VAStatus vaUnmapBuffer (
@@ -658,6 +727,8 @@ VAStatus vaUnmapBuffer (
658727 CHECK_DISPLAY(dpy);
659728 ctx = CTX(dpy);
660729
730+ if (va_FoolUnmapBuffer(dpy, buf_id))
731+ return VA_STATUS_SUCCESS;
661732 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
662733 }
663734
@@ -699,7 +770,11 @@ VAStatus vaBeginPicture (
699770 CHECK_DISPLAY(dpy);
700771 ctx = CTX(dpy);
701772
702- VA_TRACE(va_TraceBeginPicture, ctx, context, render_target);
773+ VA_TRACE(va_TraceBeginPicture, dpy, context, render_target);
774+
775+ if (va_FoolBeginPicture(dpy, context, render_target))
776+ return VA_STATUS_SUCCESS;
777+
703778 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
704779 }
705780
@@ -714,7 +789,11 @@ VAStatus vaRenderPicture (
714789 CHECK_DISPLAY(dpy);
715790 ctx = CTX(dpy);
716791
792+ if (va_FoolRenderPicture(dpy, context, buffers, num_buffers))
793+ return VA_STATUS_SUCCESS;
794+
717795 VA_TRACE(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
796+
718797 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
719798 }
720799
@@ -728,8 +807,15 @@ VAStatus vaEndPicture (
728807 CHECK_DISPLAY(dpy);
729808 ctx = CTX(dpy);
730809
810+ if (va_FoolEndPicture(dpy, context)) {
811+ VA_TRACE(va_TraceEndPicture, dpy, context);
812+ return VA_STATUS_SUCCESS;
813+ }
814+
731815 va_status = ctx->vtable.vaEndPicture( ctx, context );
816+
732817 VA_TRACE(va_TraceEndPicture, dpy, context);
818+
733819 return va_status;
734820 }
735821
@@ -742,6 +828,9 @@ VAStatus vaSyncSurface (
742828 CHECK_DISPLAY(dpy);
743829 ctx = CTX(dpy);
744830
831+ if (va_FoolSyncSurface( dpy, render_target))
832+ return VA_STATUS_SUCCESS;
833+
745834 return ctx->vtable.vaSyncSurface( ctx, render_target );
746835 }
747836
@@ -953,6 +1042,8 @@ VAStatus vaQuerySubpictureFormats (
9531042 CHECK_DISPLAY(dpy);
9541043 ctx = CTX(dpy);
9551044
1045+ if (va_FoolQuerySubpictureFormats(dpy, format_list, flags, num_formats))
1046+ return VA_STATUS_SUCCESS;
9561047 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
9571048 }
9581049
@@ -1096,10 +1187,16 @@ int vaMaxNumDisplayAttributes (
10961187 VADisplay dpy
10971188 )
10981189 {
1190+ int tmp;
1191+
10991192 if( !vaDisplayIsValid(dpy) )
11001193 return 0;
11011194
1102- return CTX(dpy)->max_display_attributes;
1195+ tmp = CTX(dpy)->max_display_attributes;
1196+
1197+ VA_TRACE(va_TraceMaxNumDisplayAttributes, dpy, tmp);
1198+
1199+ return tmp;
11031200 }
11041201
11051202 /*
@@ -1118,7 +1215,14 @@ VAStatus vaQueryDisplayAttributes (
11181215 CHECK_DISPLAY(dpy);
11191216 ctx = CTX(dpy);
11201217
1121- return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1218+ VAStatus va_status;
1219+
1220+ va_status = ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1221+
1222+ VA_TRACE(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes);
1223+
1224+ return va_status;
1225+
11221226 }
11231227
11241228 /*
@@ -1137,7 +1241,13 @@ VAStatus vaGetDisplayAttributes (
11371241 CHECK_DISPLAY(dpy);
11381242 ctx = CTX(dpy);
11391243
1140- return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1244+ VAStatus va_status;
1245+
1246+ va_status = ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1247+
1248+ VA_TRACE(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes);
1249+
1250+ return va_status;
11411251 }
11421252
11431253 /*
@@ -1156,6 +1266,9 @@ VAStatus vaSetDisplayAttributes (
11561266 CHECK_DISPLAY(dpy);
11571267 ctx = CTX(dpy);
11581268
1269+ VA_TRACE(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes);
1270+
1271+
11591272 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
11601273 }
11611274
--- a/va/va.h
+++ b/va/va.h
@@ -128,6 +128,8 @@ typedef int VAStatus; /* Return status type from functions */
128128 #define VA_STATUS_ERROR_UNIMPLEMENTED 0x00000014
129129 #define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING 0x00000015
130130 #define VA_STATUS_ERROR_INVALID_IMAGE_FORMAT 0x00000016
131+#define VA_STATUS_ERROR_DECODING_ERROR 0x00000017
132+#define VA_STATUS_ERROR_ENCODING_ERROR 0x00000018
131133 #define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
132134
133135 /* De-interlacing flags for vaPutSurface() */
@@ -136,11 +138,19 @@ typedef int VAStatus; /* Return status type from functions */
136138 #define VA_BOTTOM_FIELD 0x00000002
137139
138140 /*
141+ * Enabled the positioning/cropping/blending feature:
142+ * 1, specify the video playback position in the isurface
143+ * 2, specify the cropping info for video playback
144+ * 3, encoded video will blend with background color
145+ */
146+#define VA_ENABLE_BLEND 0x00000004 /* video area blend with the constant color */
147+
148+/*
139149 * Clears the drawable with background color.
140150 * for hardware overlay based implementation this flag
141151 * can be used to turn off the overlay
142152 */
143-#define VA_CLEAR_DRAWABLE 0x00000008
153+#define VA_CLEAR_DRAWABLE 0x00000008
144154
145155 /* Color space conversion flags for vaPutSurface() */
146156 #define VA_SRC_BT601 0x00000010
@@ -273,6 +283,7 @@ typedef struct _VAConfigAttrib {
273283 #define VA_RC_NONE 0x00000001
274284 #define VA_RC_CBR 0x00000002
275285 #define VA_RC_VBR 0x00000004
286+#define VA_RC_VCM 0x00000008 /* video conference mode */
276287
277288 /*
278289 * if an attribute is not applicable for a given
@@ -502,8 +513,75 @@ typedef enum
502513 VAEncSliceParameterBufferType = 24,
503514 VAEncH264VUIBufferType = 25,
504515 VAEncH264SEIBufferType = 26,
516+ VAEncMiscParameterBufferType = 27,
517+ VABufferTypeMax = 0xff
505518 } VABufferType;
506519
520+typedef enum
521+{
522+ VAEncMiscParameterTypeFrameRate = 0,
523+ VAEncMiscParameterTypeRateControl = 1,
524+ VAEncMiscParameterTypeMaxSliceSize = 2,
525+ VAEncMiscParameterTypeAIR = 3,
526+} VAEncMiscParameterType;
527+
528+/*
529+ * For application, e.g. set a new bitrate
530+ * VABufferID buf_id;
531+ * VAEncMiscParameterBuffer *misc_param;
532+ * VAEncMiscParameterRateControl *misc_rate_ctrl;
533+ *
534+ * vaCreateBuffer(dpy, context, VAEncMiscParameterBufferType,
535+ * sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl),
536+ * 1, NULL, &buf_id);
537+ *
538+ * vaMapBuffer(dpy,buf_id,(void **)&misc_param);
539+ * misc_param->type = VAEncMiscParameterTypeRateControl;
540+ * misc_rate_ctrl= (VAEncMiscParameterRateControl *)misc_param->data;
541+ * misc_rate_ctrl->bits_per_second = 6400000;
542+ * vaUnmapBuffer(dpy, buf_id);
543+ * vaRenderPicture(dpy, context, &buf_id, 1);
544+ */
545+typedef struct _VAEncMiscParameterBuffer
546+{
547+ VAEncMiscParameterType type;
548+ unsigned int data[0];
549+} VAEncMiscParameterBuffer;
550+
551+typedef struct _VAEncMiscParameterRateControl
552+{
553+ unsigned int bits_per_second; /* this is the maximum bit-rate to be constrained by the rate control implementation */
554+ unsigned int target_percentage; /* this is the bit-rate the rate control is targeting, as a percentage of the maximum bit-rate */
555+ /* for example if target_percentage is 95 then the rate control will target a bit-rate that is */
556+ /* 95% of the maximum bit-rate */
557+ unsigned int window_size; /* windows size in milliseconds. For example if this is set to 500, then the rate control will guarantee the */
558+ /* target bit-rate over a 500 ms window */
559+ unsigned int initial_qp; /* initial QP at I frames */
560+ unsigned int min_qp;
561+} VAEncMiscParameterRateControl;
562+
563+typedef struct _VAEncMiscParameterFrameRate
564+{
565+ unsigned int framerate;
566+} VAEncMiscParameterFrameRate;
567+
568+/*
569+ * Allow a maximum slice size to be specified (in bits).
570+ * The encoder will attempt to make sure that individual slices do not exceed this size
571+ * Or to signal applicate if the slice size exceed this size, see "status" of VACodedBufferSegment
572+ */
573+typedef struct _VAEncMiscParameterMaxSliceSize
574+{
575+ unsigned int max_slice_size;
576+} VAEncMiscParameterMaxSliceSize;
577+
578+typedef struct _VAEncMiscParameterAIR
579+{
580+ unsigned int air_num_mbs;
581+ unsigned int air_threshold;
582+ unsigned int air_auto; /* if set to 1 then hardware auto-tune the AIR threshold */
583+} VAEncMiscParameterAIR;
584+
507585
508586 /*
509587 * There will be cases where the bitstream buffer will not have enough room to hold
@@ -1115,6 +1193,8 @@ typedef struct _VAEncSequenceParameterBufferH264
11151193 unsigned char vui_flag;
11161194 } VAEncSequenceParameterBufferH264;
11171195
1196+#define H264_LAST_PICTURE_EOSEQ 0x01 /* the last picture in the sequence */
1197+#define H264_LAST_PICTURE_EOSTREAM 0x02 /* the last picture in the stream */
11181198 typedef struct _VAEncPictureParameterBufferH264
11191199 {
11201200 VASurfaceID reference_picture;
@@ -1122,9 +1202,7 @@ typedef struct _VAEncPictureParameterBufferH264
11221202 VABufferID coded_buf;
11231203 unsigned short picture_width;
11241204 unsigned short picture_height;
1125- unsigned char last_picture; /* if set to 1 it indicates the last picture in the sequence
1126- * if set to 2 it indicates the last picture of the stream
1127- */
1205+ unsigned char last_picture;
11281206 } VAEncPictureParameterBufferH264;
11291207
11301208 /****************************
@@ -1225,9 +1303,26 @@ VAStatus vaBufferSetNumElements (
12251303 /*
12261304 * device independent data structure for codedbuffer
12271305 */
1228-typedef struct _VACodedBufferSegment {
1229- unsigned int size; /* size of the data buffer in the coded buffer segment, in bytes */
1230- unsigned int bit_offset;/* bit offset into the data buffer where valid bitstream data begins */
1306+
1307+/*
1308+ * FICTURE_AVE_QP(bit7-0): The average Qp value used during this frame
1309+ * LARGE_SLICE(bit8):At least one slice in the current frame was large
1310+ * enough for the encoder to attempt to limit its size.
1311+ * SLICE_OVERFLOW(bit9): At least one slice in the current frame has
1312+ * exceeded the maximum slice size specified.
1313+ */
1314+#define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK 0xff
1315+#define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK 0x100
1316+#define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK 0x200
1317+
1318+/*
1319+ * device independent data structure for codedbuffer
1320+ */
1321+typedef struct _VACodedBufferSegment {
1322+ unsigned int size;/* size of the data buffer in the coded buffer segment, in bytes */
1323+ unsigned int bit_offset; /* bit offset into the data buffer where valid bitstream data begins */
1324+ unsigned int status; /* status set by the driver on the coded buffer*/
1325+ unsigned int reserved; /* for future use */
12311326 void *buf; /* pointer to the beginning of the data buffer in the coded buffer segment */
12321327 void *next; /* pointer to the next VACodedBufferSegment */
12331328 } VACodedBufferSegment;
@@ -1713,7 +1808,10 @@ typedef enum
17131808 VADisplayAttribContrast = 1,
17141809 VADisplayAttribHue = 2,
17151810 VADisplayAttribSaturation = 3,
1716- /* client can specifiy a background color for the target window */
1811+ /* client can specifiy a background color for the target window
1812+ * the new feature of video conference,
1813+ * the uncovered area of the surface is filled by this color
1814+ * also it will blend with the decoded video color*/
17171815 VADisplayAttribBackgroundColor = 4,
17181816 /*
17191817 * this is a gettable only attribute. For some implementations that use the
@@ -1739,7 +1837,15 @@ typedef enum
17391837 * For type VADisplayAttribCSCMatrix, "value" field is a pointer to the color
17401838 * conversion matrix. Each element in the matrix is float-point
17411839 */
1742- VADisplayAttribCSCMatrix = 12
1840+ VADisplayAttribCSCMatrix = 12,
1841+ /* specify the constant color used to blend with video surface
1842+ * Cd = Cv*Cc*Ac + Cb *(1 - Ac) C means the constant RGB
1843+ * d: the final color to overwrite into the frame buffer
1844+ * v: decoded video after color conversion,
1845+ * c: video color specified by VADisplayAttribBlendColor
1846+ * b: background color of the drawable
1847+ */
1848+ VADisplayAttribBlendColor = 13,
17431849 } VADisplayAttribType;
17441850
17451851 /* flags for VADisplayAttribute */
--- a/va/va_android.h
+++ b/va/va_android.h
@@ -19,8 +19,8 @@ VADisplay vaGetDisplay (
1919 #endif
2020
2121 #ifdef __cplusplus
22-#ifdef ANDROID
23-#include <ui/ISurface.h>
22+#ifdef ANDROID
23+#include <surfaceflinger/ISurface.h>
2424 using namespace android;
2525
2626 /*
--- a/va/va_trace.c
+++ b/va/va_trace.c
@@ -34,23 +34,87 @@
3434 #include <string.h>
3535 #include <dlfcn.h>
3636 #include <unistd.h>
37+#include <sys/types.h>
38+#include <sys/stat.h>
39+#include <unistd.h>
40+#include <time.h>
41+
42+
43+/*
44+ * Env. to debug some issue, e.g. the decode/encode issue in a video conference scenerio:
45+ * .LIBVA_TRACE=log_file: general VA parameters saved into log_file
46+ * .LIBVA_TRACE_BUFDATA: dump VA buffer data into log_file (if not set, just calculate a checksum)
47+ * .LIBVA_TRACE_CODEDBUF=coded_clip_file: save the coded clip into file coded_clip_file
48+ * .LIBVA_TRACE_SURFACE=decoded_yuv_file: save the decoded YUV file decoded_yuv_file
49+ * .LIBVA_TRACE_LOGSIZE=numeric number: truncate the log_file or coded_clip_file, or decoded_yuv_file
50+ * when the size is bigger than the number
51+ */
52+
3753
54+/* global settings */
55+
56+/* LIBVA_TRACE */
3857 unsigned int trace_flag = 0;
3958
40-static const char *trace_file = 0;
41-static FILE *trace_fp = 0;
59+/* LIBVA_TRACE_LOGSIZE */
60+static unsigned int trace_logsize = 0xffffffff; /* truncate the log when the size is bigger than it */
61+
62+/* LIBVA_TRACE_BUFDATA */
63+static unsigned int trace_buffer_data; /* dump buffer data or not */
64+
65+#define TRACE_CONTEXT_MAX 4
66+/* per context settings */
67+static struct _trace_context {
68+ VADisplay dpy; /* should use context as the key */
69+
70+ /* LIBVA_TRACE */
71+ FILE *trace_fp_log; /* save the log into a file */
72+ char trace_log_fn[1024]; /* file name */
73+
74+ /* LIBVA_TRACE_CODEDBUF */
75+ FILE *trace_fp_codedbuf; /* save the encode result into a file */
76+ char trace_codedbuf_fn[1024]; /* file name */
77+
78+ /* LIBVA_TRACE_SURFACE */
79+ FILE *trace_fp_surface; /* save the surface YUV into a file */
80+ char trace_surface_fn[1024]; /* file name */
81+
82+ VAContextID trace_context; /* current context */
83+
84+ VASurfaceID trace_rendertarget; /* current render target */
85+ VAProfile trace_profile; /* current profile for buffers */
86+ VAEntrypoint trace_entrypoint; /* current entrypoint */
87+ VABufferID trace_codedbuf;
88+
89+ unsigned int trace_frame_no; /* current frame NO */
90+ unsigned int trace_slice_no; /* current slice NO */
91+ unsigned int trace_slice_size; /* current slice buffer size */
92+
93+ unsigned int trace_frame_width; /* current frame width */
94+ unsigned int trace_frame_height; /* current frame height */
95+ unsigned int trace_sequence_start; /* get a new sequence for encoding or not */
96+} trace_context[TRACE_CONTEXT_MAX] = { {0} }; /* trace five context at the same time */
97+
98+#define DPY2INDEX(dpy) \
99+ int idx; \
100+ \
101+ for (idx = 0; idx < TRACE_CONTEXT_MAX; idx++) \
102+ if (trace_context[idx].dpy == dpy) \
103+ break; \
104+ \
105+ if (idx == TRACE_CONTEXT_MAX) \
106+ return;
107+
108+#define TRACE_FUNCNAME(idx) va_TraceMsg(idx, "==========%s\n", __func__);
42109
43-static VASurfaceID trace_rendertarget; /* current render target */
44-static VAProfile trace_profile; /* current entrypoint for buffers */
110+/* Prototype declarations (functions defined in va.c) */
45111
46-static unsigned int trace_frame;
47-static unsigned int trace_slice;
112+void va_errorMessage(const char *msg, ...);
113+void va_infoMessage(const char *msg, ...);
48114
49-static unsigned int trace_width;
50-static unsigned int trace_height;
115+int va_parseConfig(char *env, char *env_value);
51116
52-/* Prototypes (functions defined in va.c) */
53-VAStatus vaBufferInfo (
117+VAStatus vaBufferInfo(
54118 VADisplay dpy,
55119 VAContextID context, /* in */
56120 VABufferID buf_id, /* in */
@@ -76,45 +140,263 @@ VAStatus vaUnlockSurface(VADisplay dpy,
76140 VASurfaceID surface
77141 );
78142
79-void va_TraceInit(void)
143+
144+void va_TraceInit(VADisplay dpy)
80145 {
81- trace_file = (const char *)getenv("LIBVA_TRACE");
82- if (trace_file) {
83- trace_fp = fopen(trace_file, "w");
84- if (trace_fp)
85- trace_flag = 1;
146+ char env_value[1024];
147+ unsigned int suffix = 0xffff & ((unsigned int)time(NULL));
148+ int trace_index = 0;
149+ FILE *tmp;
150+
151+ for (trace_index = 0; trace_index < TRACE_CONTEXT_MAX; trace_index++)
152+ if (trace_context[trace_index].dpy == 0)
153+ break;
154+
155+ if (trace_index == TRACE_CONTEXT_MAX)
156+ return;
157+
158+ if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
159+ trace_flag = 1;
160+
161+ sprintf(env_value+strlen(env_value), ".%d.%d", trace_index, suffix);
162+
163+ tmp = fopen(env_value, "w");
164+ if (tmp) {
165+ trace_context[trace_index].trace_fp_log = tmp;
166+ strcpy(trace_context[trace_index].trace_log_fn, env_value);
167+ } else {
168+ trace_context[trace_index].trace_fp_log = stderr;
169+ strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
170+ }
171+ va_infoMessage("LIBVA_TRACE is on, save log into %s\n", trace_context[trace_index].trace_log_fn);
172+ }
173+
174+ if (trace_flag == 0)
175+ return;
176+
177+ /* may re-get the global settings for multiple context */
178+ if (va_parseConfig("LIBVA_TRACE_LOGSIZE", &env_value[0]) == 0) {
179+ trace_logsize = atoi(env_value);
180+ va_infoMessage("LIBVA_TRACE_LOGSIZE is on, size is %d\n", trace_logsize);
181+ }
182+
183+
184+ if (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0) {
185+ trace_buffer_data = 1; /* dump buffer data */
186+ va_infoMessage("LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n");
187+ }
188+
189+
190+ /* per-context setting */
191+ if (va_parseConfig("LIBVA_TRACE_CODEDBUF", &env_value[0]) == 0) {
192+ sprintf(env_value+strlen(env_value), ".%d.%d", trace_index, suffix);
193+
194+ tmp = fopen(env_value, "w");
195+
196+ if (tmp) {
197+ trace_context[trace_index].trace_fp_codedbuf = tmp;
198+ strcpy(trace_context[trace_index].trace_codedbuf_fn, env_value);
199+ } else {
200+ trace_context[trace_index].trace_fp_codedbuf = stderr;
201+ strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
202+ }
203+
204+ va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save coded clip into %s\n", trace_context[trace_index].trace_codedbuf_fn);
205+ }
206+
207+ if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) {
208+ sprintf(env_value+strlen(env_value), ".%d.%d", trace_index, suffix);
209+
210+ tmp = fopen(env_value, "w");
211+
212+ if (tmp) {
213+ trace_context[trace_index].trace_fp_surface = tmp;
214+ strcpy(trace_context[trace_index].trace_surface_fn, env_value);
215+ } else {
216+ trace_context[trace_index].trace_fp_surface = stderr;
217+ strcpy(trace_context[trace_index].trace_surface_fn, "/dev/stderr");
218+ }
219+
220+ va_infoMessage("LIBVA_TRACE_SURFACE is on, save coded clip into %s\n", trace_context[trace_index].trace_surface_fn);
86221 }
222+
223+ trace_context[trace_index].dpy = dpy;
87224 }
88225
89-void va_TraceEnd(void)
226+
227+void va_TraceEnd(VADisplay dpy)
90228 {
91- if (trace_file && trace_fp) {
92- fclose(trace_fp);
229+ DPY2INDEX(dpy);
230+
231+ if (trace_context[idx].trace_fp_log && (trace_context[idx].trace_fp_log != stderr))
232+ fclose(trace_context[idx].trace_fp_log);
233+
234+ if (trace_context[idx].trace_fp_codedbuf && (trace_context[idx].trace_fp_codedbuf != stderr))
235+ fclose(trace_context[idx].trace_fp_codedbuf);
236+
237+ if (trace_context[idx].trace_fp_surface && (trace_context[idx].trace_fp_surface != stderr))
238+ fclose(trace_context[idx].trace_fp_surface);
239+
240+ memset(&trace_context[idx], sizeof(struct _trace_context), 0);
241+}
93242
94- trace_file = NULL;
95- trace_fp = NULL;
243+static unsigned int file_size(FILE *fp)
244+{
245+ struct stat buf;
96246
97- trace_flag = 0;
247+ fstat(fileno(fp), &buf);
98248
99- trace_width = 0;
100- trace_height = 0;
101- }
249+ return buf.st_size;
102250 }
103251
104-void va_TraceMsg(const char *msg, ...)
252+
253+static void truncate_file(FILE *fp)
254+{
255+ ftruncate(fileno(fp), 0);
256+ rewind(fp);
257+}
258+
259+void va_TraceMsg(int idx, const char *msg, ...)
105260 {
106261 va_list args;
262+
263+ if (file_size(trace_context[idx].trace_fp_log) >= trace_logsize)
264+ truncate_file(trace_context[idx].trace_fp_log);
107265
108266 if (msg) {
109267 va_start(args, msg);
110- vfprintf(trace_fp, msg, args);
268+ vfprintf(trace_context[idx].trace_fp_log, msg, args);
111269 va_end(args);
112- } else {
113- fflush(trace_fp);
270+ } else
271+ fflush(trace_context[idx].trace_fp_log);
272+}
273+
274+void va_TraceCodedBuf(VADisplay dpy)
275+{
276+ VACodedBufferSegment *buf_list = NULL;
277+ VAStatus va_status;
278+ unsigned char check_sum = 0;
279+ DPY2INDEX(dpy);
280+
281+ /* can only truncate at a sequence boudary */
282+ if (((file_size(trace_context[idx].trace_fp_log) >= trace_logsize))
283+ && trace_context[idx].trace_sequence_start) {
284+ va_TraceMsg(idx, "==========truncate file %s\n", trace_context[idx].trace_codedbuf_fn);
285+ truncate_file(trace_context[idx].trace_fp_log);
114286 }
287+
288+
289+ trace_context[idx].trace_sequence_start = 0; /* only truncate coded file when meet next new sequence */
290+
291+ va_status = vaMapBuffer(dpy, trace_context[idx].trace_codedbuf, (void **)(&buf_list));
292+ if (va_status != VA_STATUS_SUCCESS)
293+ return;
294+
295+ va_TraceMsg(idx, "==========dump codedbuf into file %s\n", trace_context[idx].trace_codedbuf_fn);
296+
297+ while (buf_list != NULL) {
298+ unsigned int i;
299+
300+ va_TraceMsg(idx, "\tsize = %d\n", buf_list->size);
301+ if (trace_context[idx].trace_fp_log)
302+ fwrite(buf_list->buf, buf_list->size, 1, trace_context[idx].trace_fp_codedbuf);
303+
304+ for (i=0; i<buf_list->size; i++)
305+ check_sum ^= *((unsigned char *)buf_list->buf + i);
306+
307+ buf_list = buf_list->next;
308+ }
309+ vaUnmapBuffer(dpy,trace_context[idx].trace_codedbuf);
310+
311+ va_TraceMsg(idx, "\tchecksum = 0x%02x\n", check_sum);
115312 }
116313
117314
315+void va_TraceSurface(VADisplay dpy)
316+{
317+ unsigned int i, j;
318+ unsigned int fourcc; /* following are output argument */
319+ unsigned int luma_stride;
320+ unsigned int chroma_u_stride;
321+ unsigned int chroma_v_stride;
322+ unsigned int luma_offset;
323+ unsigned int chroma_u_offset;
324+ unsigned int chroma_v_offset;
325+ unsigned int buffer_name;
326+ void *buffer = NULL;
327+ unsigned char *Y_data, *UV_data, *tmp;
328+ VAStatus va_status;
329+ unsigned char check_sum = 0;
330+ DPY2INDEX(dpy);
331+
332+ va_TraceMsg(idx, "==========dump surface data in file %s\n", trace_context[idx].trace_surface_fn);
333+
334+ if ((file_size(trace_context[idx].trace_fp_surface) >= trace_logsize)) {
335+ va_TraceMsg(idx, "==========truncate file %s\n", trace_context[idx].trace_surface_fn);
336+ truncate_file(trace_context[idx].trace_fp_surface);
337+ }
338+
339+ va_status = vaLockSurface(dpy, trace_context[idx].trace_rendertarget, &fourcc,
340+ &luma_stride, &chroma_u_stride, &chroma_v_stride,
341+ &luma_offset, &chroma_u_offset, &chroma_v_offset,
342+ &buffer_name, &buffer);
343+
344+ if (va_status != VA_STATUS_SUCCESS) {
345+ va_TraceMsg(idx, "Error:vaLockSurface failed\n");
346+
347+ return;
348+ }
349+
350+ va_TraceMsg(idx, "\tfourcc = 0x%08x\n", fourcc);
351+ va_TraceMsg(idx, "\twidth = %d\n", trace_context[idx].trace_frame_width);
352+ va_TraceMsg(idx, "\theight = %d\n", trace_context[idx].trace_frame_height);
353+ va_TraceMsg(idx, "\tluma_stride = %d\n", luma_stride);
354+ va_TraceMsg(idx, "\tchroma_u_stride = %d\n", chroma_u_stride);
355+ va_TraceMsg(idx, "\tchroma_v_stride = %d\n", chroma_v_stride);
356+ va_TraceMsg(idx, "\tluma_offset = %d\n", luma_offset);
357+ va_TraceMsg(idx, "\tchroma_u_offset = %d\n", chroma_u_offset);
358+ va_TraceMsg(idx, "\tchroma_v_offset = %d\n", chroma_v_offset);
359+
360+ if (*(unsigned int *)buffer == 0) {
361+ va_TraceMsg(idx, "Error:vaLockSurface return NULL buffer\n");
362+
363+ vaUnlockSurface(dpy, trace_context[idx].trace_rendertarget);
364+ return;
365+ }
366+ va_TraceMsg(idx, "\tbuffer location = 0x%08x\n", buffer);
367+
368+ Y_data = buffer;
369+ UV_data = buffer + chroma_u_offset;
370+
371+ tmp = Y_data;
372+ for (i=0; i<trace_context[idx].trace_frame_height; i++) {
373+ for (j=0; j<trace_context[idx].trace_frame_width; j++)
374+ check_sum ^= tmp[j];
375+
376+ if (trace_context[idx].trace_fp_surface)
377+ fwrite(tmp, trace_context[idx].trace_frame_width, 1, trace_context[idx].trace_fp_surface);
378+
379+ tmp = Y_data + i * luma_stride;
380+ }
381+
382+ tmp = UV_data;
383+ if (fourcc == VA_FOURCC_NV12) {
384+ for (i=0; i<trace_context[idx].trace_frame_height/2; i++) {
385+ for (j=0; j<trace_context[idx].trace_frame_width; j++)
386+ check_sum ^= tmp[j];
387+
388+ if (trace_context[idx].trace_fp_surface)
389+ fwrite(tmp, trace_context[idx].trace_frame_width, 1, trace_context[idx].trace_fp_surface);
390+
391+ tmp = UV_data + i * chroma_u_stride;
392+ }
393+ }
394+
395+ vaUnlockSurface(dpy, trace_context[idx].trace_rendertarget);
396+
397+ va_TraceMsg(idx, "\tchecksum = 0x%02x\n", check_sum & 0xff);
398+}
399+
118400 void va_TraceCreateConfig(
119401 VADisplay dpy,
120402 VAProfile profile,
@@ -122,19 +404,23 @@ void va_TraceCreateConfig(
122404 VAConfigAttrib *attrib_list,
123405 int num_attribs,
124406 VAConfigID *config_id /* out */
125- )
407+)
126408 {
127409 int i;
410+ DPY2INDEX(dpy);
411+
412+ TRACE_FUNCNAME(idx);
128413
129- va_TraceMsg("\tprofile = %d\n", profile);
130- va_TraceMsg("\tentrypoint = %d\n", entrypoint);
131- va_TraceMsg("\tnum_attribs = %d\n", num_attribs);
414+ va_TraceMsg(idx, "\tprofile = %d\n", profile);
415+ va_TraceMsg(idx, "\tentrypoint = %d\n", entrypoint);
416+ va_TraceMsg(idx, "\tnum_attribs = %d\n", num_attribs);
132417 for (i = 0; i < num_attribs; i++) {
133- va_TraceMsg("\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type);
134- va_TraceMsg("\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value);
418+ va_TraceMsg(idx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type);
419+ va_TraceMsg(idx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value);
135420 }
136421
137- trace_profile = profile;
422+ trace_context[idx].trace_profile = profile;
423+ trace_context[idx].trace_entrypoint = entrypoint;
138424 }
139425
140426
@@ -145,17 +431,20 @@ void va_TraceCreateSurface(
145431 int format,
146432 int num_surfaces,
147433 VASurfaceID *surfaces /* out */
148- )
434+)
149435 {
150436 int i;
437+ DPY2INDEX(dpy);
438+
439+ TRACE_FUNCNAME(idx);
151440
152- va_TraceMsg("\twidth = %d\n", width);
153- va_TraceMsg("\theight = %d\n", height);
154- va_TraceMsg("\tformat = %d\n", format);
155- va_TraceMsg("\tnum_surfaces = %d\n", num_surfaces);
441+ va_TraceMsg(idx, "\twidth = %d\n", width);
442+ va_TraceMsg(idx, "\theight = %d\n", height);
443+ va_TraceMsg(idx, "\tformat = %d\n", format);
444+ va_TraceMsg(idx, "\tnum_surfaces = %d\n", num_surfaces);
156445
157446 for (i = 0; i < num_surfaces; i++)
158- va_TraceMsg("\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]);
447+ va_TraceMsg(idx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]);
159448 }
160449
161450
@@ -168,24 +457,29 @@ void va_TraceCreateContext(
168457 VASurfaceID *render_targets,
169458 int num_render_targets,
170459 VAContextID *context /* out */
171- )
460+)
172461 {
173462 int i;
463+ DPY2INDEX(dpy);
174464
175- va_TraceMsg("\twidth = %d\n", picture_width);
176- va_TraceMsg("\theight = %d\n", picture_height);
177- va_TraceMsg("\tflag = 0x%08x\n", flag);
178- va_TraceMsg("\tnum_render_targets = %d\n", num_render_targets);
465+ TRACE_FUNCNAME(idx);
466+
467+ va_TraceMsg(idx, "\twidth = %d\n", picture_width);
468+ va_TraceMsg(idx, "\theight = %d\n", picture_height);
469+ va_TraceMsg(idx, "\tflag = 0x%08x\n", flag);
470+ va_TraceMsg(idx, "\tnum_render_targets = %d\n", num_render_targets);
179471 for (i=0; i<num_render_targets; i++)
180- va_TraceMsg("\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]);
181- va_TraceMsg("\tcontext = 0x%08x\n", context);
472+ va_TraceMsg(idx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]);
473+ va_TraceMsg(idx, "\tcontext = 0x%08x\n", *context);
182474
183475
184- trace_frame = 0;
185- trace_slice = 0;
476+ trace_context[idx].trace_context = *context;
186477
187- trace_width = picture_width;
188- trace_height = picture_height;
478+ trace_context[idx].trace_frame_no = 0;
479+ trace_context[idx].trace_slice_no = 0;
480+
481+ trace_context[idx].trace_frame_width = picture_width;
482+ trace_context[idx].trace_frame_height = picture_height;
189483 }
190484
191485
@@ -207,12 +501,55 @@ static char * buffer_type_to_string(int type)
207501 case VAEncSequenceParameterBufferType: return "VAEncSequenceParameterBufferType";
208502 case VAEncPictureParameterBufferType: return "VAEncPictureParameterBufferType";
209503 case VAEncSliceParameterBufferType: return "VAEncSliceParameterBufferType";
504+ case VAEncMiscParameterBufferType: return "VAEncMiscParameterBufferType";
210505 default: return "UnknowBuffer";
211506 }
212507 }
213508
509+void va_TraceMapBuffer (
510+ VADisplay dpy,
511+ VABufferID buf_id, /* in */
512+ void **pbuf /* out */
513+)
514+{
515+ VABufferType type;
516+ unsigned int size;
517+ unsigned int num_elements;
518+
519+ VACodedBufferSegment *buf_list;
520+ int i = 0;
521+
522+ DPY2INDEX(dpy);
523+
524+ vaBufferInfo(dpy, trace_context[idx].trace_context, buf_id, &type, &size, &num_elements);
525+ /*
526+ va_TraceMsg(idx, "\tbuf_id=0x%x\n", buf_id);
527+ va_TraceMsg(idx, "\tbuf_type=%s\n", buffer_type_to_string(type));
528+ va_TraceMsg(idx, "\tbuf_size=%s\n", size);
529+ va_TraceMsg(idx, "\tbuf_elements=%s\n", &num_elements);
530+ */
531+
532+ /* only trace CodedBuffer */
533+ if (type != VAEncCodedBufferType)
534+ return;
535+
536+ buf_list = (VACodedBufferSegment *)(*pbuf);
537+ while (buf_list != NULL) {
538+ va_TraceMsg(idx, "\tCodedbuf[%d] =\n", i++);
539+
540+ va_TraceMsg(idx, "\t size = %d\n", buf_list->size);
541+ va_TraceMsg(idx, "\t bit_offset = %d\n", buf_list->bit_offset);
542+ va_TraceMsg(idx, "\t status = 0x%08x\n", buf_list->status);
543+ va_TraceMsg(idx, "\t reserved = 0x%08x\n", buf_list->reserved);
544+ va_TraceMsg(idx, "\t buf = 0x%08x\n", buf_list->buf);
545+
546+ buf_list = buf_list->next;
547+ }
548+
549+
550+}
214551
215-static int va_TraceVABuffers(
552+static void va_TraceVABuffers(
216553 VADisplay dpy,
217554 VAContextID context,
218555 VABufferID buffer,
@@ -220,21 +557,30 @@ static int va_TraceVABuffers(
220557 unsigned int size,
221558 unsigned int num_elements,
222559 void *pbuf
223- )
560+)
224561 {
225- int i;
562+ unsigned int i;
226563 unsigned char *p = pbuf;
227- unsigned int *pi = (unsigned int *)pbuf;
564+ unsigned char check_sum = 0;
565+ DPY2INDEX(dpy);
566+
567+ va_TraceMsg(idx, "%s\n", buffer_type_to_string(type));
228568
229- va_TraceMsg("***Buffer Data***");
230569 for (i=0; i<size; i++) {
231- if ((i%16) == 0)
232- va_TraceMsg("\n0x%08x:", i);
233- va_TraceMsg(" %02x", p[i]);
570+ unsigned char value = p[i];
571+
572+ if ((trace_buffer_data) && ((i%16) == 0))
573+ va_TraceMsg(idx, "\n0x%08x:", i);
574+
575+ if (trace_buffer_data)
576+ va_TraceMsg(idx, " %02x", value);
577+
578+ check_sum ^= value;
234579 }
235580
236- va_TraceMsg("\n");
237- return 0;
581+ va_TraceMsg(idx, "\tchecksum = 0x%02x\n", check_sum & 0xff);
582+
583+ return;
238584 }
239585
240586
@@ -247,6 +593,8 @@ static void va_TraceVAPictureParameterBufferMPEG2(
247593 unsigned int num_elements,
248594 void *data)
249595 {
596+ DPY2INDEX(dpy);
597+
250598 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
251599
252600 return;
@@ -262,6 +610,8 @@ static void va_TraceVAIQMatrixBufferMPEG2(
262610 unsigned int num_elements,
263611 void *data)
264612 {
613+ DPY2INDEX(dpy);
614+
265615 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
266616
267617 return;
@@ -277,6 +627,12 @@ static void va_TraceVASliceParameterBufferMPEG2(
277627 unsigned int num_elements,
278628 void *data)
279629 {
630+ DPY2INDEX(dpy);
631+
632+ trace_context[idx].trace_slice_no++;
633+
634+ /* todo: log TraceVASliceParameterBufferMPEG2 */
635+ /* trace_context[idx].trace_slice_size = p->slice_data_size; */
280636 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
281637
282638 return;
@@ -293,6 +649,8 @@ static void va_TraceVAPictureParameterBufferMPEG4(
293649 unsigned int num_elements,
294650 void *data)
295651 {
652+ DPY2INDEX(dpy);
653+
296654 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
297655
298656 return;
@@ -308,6 +666,9 @@ static void va_TraceVAIQMatrixBufferMPEG4(
308666 unsigned int num_elements,
309667 void *data)
310668 {
669+ DPY2INDEX(dpy);
670+
671+ /* todo: log VAIQMatrixBufferMPEG4 */
311672 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
312673
313674 return;
@@ -323,6 +684,12 @@ static void va_TraceVASliceParameterBufferMPEG4(
323684 unsigned int num_elements,
324685 void *data)
325686 {
687+ DPY2INDEX(dpy);
688+
689+ trace_context[idx].trace_slice_no++;
690+
691+ /* todo: log VASliceParameterBufferMPEG4 */
692+ /* trace_context[idx].trace_slice_size = p->slice_data_size; */
326693 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
327694
328695 return;
@@ -339,76 +706,59 @@ static void va_TraceVAPictureParameterBufferH264(
339706 void *data)
340707 {
341708 int i;
342-
709+ DPY2INDEX(dpy);
710+
343711 VAPictureParameterBufferH264 *p = (VAPictureParameterBufferH264*)data;
344712
345- va_TraceMsg ("==========H264PicParameterBuffer============\n");
346-
347-#if 0
348- if (p->num_ref_frames > 4)
349- {
350- int num = 0;
351- for (i = 15; i >= 0; i--)
352- {
353- if (p->ReferenceFrames[i].flags != VA_PICTURE_H264_INVALID)
354- {
355- num++;
356- }
357- if (num > 4)
358- {
359- p->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID;
360- }
361- }
362- p->num_ref_frames = 4;
363- }
364-#endif
365-
366-#if 1
367- va_TraceMsg("picture id: %d\n", p->CurrPic.picture_id);
368- va_TraceMsg("frame idx: %d\n", p->CurrPic.frame_idx);
369- va_TraceMsg("picture flags: %d\n", p->CurrPic.flags);
370- va_TraceMsg("top field order count: %d\n", p->CurrPic.TopFieldOrderCnt);
371- va_TraceMsg("bottom field order count: %d\n", p->CurrPic.BottomFieldOrderCnt);
713+ va_TraceMsg(idx, "VAPictureParameterBufferH264\n");
372714
715+ va_TraceMsg(idx, "\tCurrPic.picture_id = %d\n", p->CurrPic.picture_id);
716+ va_TraceMsg(idx, "\tCurrPic.frame_idx = %d\n", p->CurrPic.frame_idx);
717+ va_TraceMsg(idx, "\tCurrPic.flags = %d\n", p->CurrPic.flags);
718+ va_TraceMsg(idx, "\tCurrPic.TopFieldOrderCnt = %d\n", p->CurrPic.TopFieldOrderCnt);
719+ va_TraceMsg(idx, "\tCurrPic.BottomFieldOrderCnt = %d\n", p->CurrPic.BottomFieldOrderCnt);
373720
374- va_TraceMsg("Reference frames: \n");
721+ va_TraceMsg(idx, "\tReferenceFrames (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx:\n");
375722 for (i = 0; i < 16; i++)
376723 {
377- if (p->ReferenceFrames[i].flags != VA_PICTURE_H264_INVALID)
378- {
379- //va_TraceMsg("%d-%d; ", p->ReferenceFrames[i].TopFieldOrderCnt, p->ReferenceFrames[i].BottomFieldOrderCnt);
380- va_TraceMsg("%d-%d-%d-%d; ", p->ReferenceFrames[i].TopFieldOrderCnt, p->ReferenceFrames[i].BottomFieldOrderCnt, p->ReferenceFrames[i].picture_id, p->ReferenceFrames[i].frame_idx);
381- }
724+ if (p->ReferenceFrames[i].flags != VA_PICTURE_H264_INVALID) {
725+ va_TraceMsg(idx, "\t\t%d-%d-%d-%d\n",
726+ p->ReferenceFrames[i].TopFieldOrderCnt,
727+ p->ReferenceFrames[i].BottomFieldOrderCnt,
728+ p->ReferenceFrames[i].picture_id,
729+ p->ReferenceFrames[i].frame_idx);
730+ } else
731+ va_TraceMsg(idx, "\t\t%inv-%inv-%inv-%inv\n");
382732 }
383- va_TraceMsg("\n");
384-#endif
385- va_TraceMsg("picture_width_in_mbs_minus1: %d\n", p->picture_width_in_mbs_minus1);
386- va_TraceMsg("picture_height_in_mbs_minus1: %d\n", p->picture_height_in_mbs_minus1);
387- va_TraceMsg("bit_depth_luma_minus8: %d\n", p->bit_depth_luma_minus8);
388- va_TraceMsg("bit_depth_chroma_minus8: %d\n", p->bit_depth_chroma_minus8);
389- va_TraceMsg("num_ref_frames: %d\n", p->num_ref_frames);
390- va_TraceMsg("seq fields: %d\n", p->seq_fields.value);
391- va_TraceMsg("\t chroma_format_idc: %d\n", p->seq_fields.bits.chroma_format_idc);
392- va_TraceMsg("\t residual_colour_transform_flag: %d\n", p->seq_fields.bits.residual_colour_transform_flag);
393- va_TraceMsg("\t frame_mbs_only_flag: %d\n", p->seq_fields.bits.frame_mbs_only_flag);
394- va_TraceMsg("\t mb_adaptive_frame_field_flag: %d\n", p->seq_fields.bits.mb_adaptive_frame_field_flag);
395- va_TraceMsg("\t direct_8x8_inference_flag: %d\n", p->seq_fields.bits.direct_8x8_inference_flag);
396- va_TraceMsg("\t MinLumaBiPredSize8x8: %d\n", p->seq_fields.bits.MinLumaBiPredSize8x8);
397- va_TraceMsg("num_slice_groups_minus1: %d\n", p->num_slice_groups_minus1);
398- va_TraceMsg("slice_group_map_type: %d\n", p->slice_group_map_type);
399- va_TraceMsg("slice_group_change_rate_minus1: %d\n", p->slice_group_change_rate_minus1);
400- va_TraceMsg("pic_init_qp_minus26: %d\n", p->pic_init_qp_minus26);
401- va_TraceMsg("pic_init_qs_minus26: %d\n", p->pic_init_qs_minus26);
402- va_TraceMsg("chroma_qp_index_offset: %d\n", p->chroma_qp_index_offset);
403- va_TraceMsg("second_chroma_qp_index_offset: %d\n", p->second_chroma_qp_index_offset);
404- va_TraceMsg("pic_fields: %d\n", p->pic_fields.value);
405- va_TraceMsg("\t entropy_coding_mode_flag: %d\n", p->pic_fields.bits.entropy_coding_mode_flag);
406- va_TraceMsg("\t weighted_pred_flag: %d\n", p->pic_fields.bits.weighted_pred_flag);
407- va_TraceMsg("\t weighted_bipred_idc: %d\n", p->pic_fields.bits.weighted_bipred_idc);
408- va_TraceMsg("\t transform_8x8_mode_flag: %d\n", p->pic_fields.bits.transform_8x8_mode_flag);
409- va_TraceMsg("\t field_pic_flag: %d\n", p->pic_fields.bits.field_pic_flag);
410- va_TraceMsg("\t constrained_intra_pred_flag: %d\n", p->pic_fields.bits.constrained_intra_pred_flag);
411- va_TraceMsg("frame_num: %d\n", p->frame_num);
733+ va_TraceMsg(idx, "\n");
734+
735+ va_TraceMsg(idx, "\tpicture_width_in_mbs_minus1 = %d\n", p->picture_width_in_mbs_minus1);
736+ va_TraceMsg(idx, "\tpicture_height_in_mbs_minus1 = %d\n", p->picture_height_in_mbs_minus1);
737+ va_TraceMsg(idx, "\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8);
738+ va_TraceMsg(idx, "\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8);
739+ va_TraceMsg(idx, "\tnum_ref_frames = %d\n", p->num_ref_frames);
740+ va_TraceMsg(idx, "\tseq fields = %d\n", p->seq_fields.value);
741+ va_TraceMsg(idx, "\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc);
742+ va_TraceMsg(idx, "\tresidual_colour_transform_flag = %d\n", p->seq_fields.bits.residual_colour_transform_flag);
743+ va_TraceMsg(idx, "\tframe_mbs_only_flag = %d\n", p->seq_fields.bits.frame_mbs_only_flag);
744+ va_TraceMsg(idx, "\tmb_adaptive_frame_field_flag = %d\n", p->seq_fields.bits.mb_adaptive_frame_field_flag);
745+ va_TraceMsg(idx, "\tdirect_8x8_inference_flag = %d\n", p->seq_fields.bits.direct_8x8_inference_flag);
746+ va_TraceMsg(idx, "\tMinLumaBiPredSize8x8 = %d\n", p->seq_fields.bits.MinLumaBiPredSize8x8);
747+ va_TraceMsg(idx, "\tnum_slice_groups_minus1 = %d\n", p->num_slice_groups_minus1);
748+ va_TraceMsg(idx, "\tslice_group_map_type = %d\n", p->slice_group_map_type);
749+ va_TraceMsg(idx, "\tslice_group_change_rate_minus1 = %d\n", p->slice_group_change_rate_minus1);
750+ va_TraceMsg(idx, "\tpic_init_qp_minus26 = %d\n", p->pic_init_qp_minus26);
751+ va_TraceMsg(idx, "\tpic_init_qs_minus26 = %d\n", p->pic_init_qs_minus26);
752+ va_TraceMsg(idx, "\tchroma_qp_index_offset = %d\n", p->chroma_qp_index_offset);
753+ va_TraceMsg(idx, "\tsecond_chroma_qp_index_offset = %d\n", p->second_chroma_qp_index_offset);
754+ va_TraceMsg(idx, "\tpic_fields = %d\n", p->pic_fields.value);
755+ va_TraceMsg(idx, "\tentropy_coding_mode_flag = %d\n", p->pic_fields.bits.entropy_coding_mode_flag);
756+ va_TraceMsg(idx, "\tweighted_pred_flag = %d\n", p->pic_fields.bits.weighted_pred_flag);
757+ va_TraceMsg(idx, "\tweighted_bipred_idc = %d\n", p->pic_fields.bits.weighted_bipred_idc);
758+ va_TraceMsg(idx, "\ttransform_8x8_mode_flag = %d\n", p->pic_fields.bits.transform_8x8_mode_flag);
759+ va_TraceMsg(idx, "\tfield_pic_flag = %d\n", p->pic_fields.bits.field_pic_flag);
760+ va_TraceMsg(idx, "\tconstrained_intra_pred_flag = %d\n", p->pic_fields.bits.constrained_intra_pred_flag);
761+ va_TraceMsg(idx, "\tframe_num = %d\n", p->frame_num);
412762
413763 return;
414764 }
@@ -424,93 +774,78 @@ static void va_TraceVASliceParameterBufferH264(
424774 {
425775 int i;
426776 VASliceParameterBufferH264* p = (VASliceParameterBufferH264*)data;
427-
428- va_TraceMsg ("========== SLICE HEADER ============.\n");
429- va_TraceMsg("slice_data_size: %d\n", p->slice_data_size);
430- va_TraceMsg("slice_data_offset: %d\n", p->slice_data_offset);
431- va_TraceMsg("slice_data_flag: %d\n", p->slice_data_flag);
432- va_TraceMsg("slice_data_bit_offset: %d\n", p->slice_data_bit_offset);
433- va_TraceMsg("first_mb_in_slice: %d\n", p->first_mb_in_slice);
434- va_TraceMsg("slice_type: %d\n", p->slice_type);
435- va_TraceMsg("direct_spatial_mv_pred_flag: %d\n", p->direct_spatial_mv_pred_flag);
436- va_TraceMsg("num_ref_idx_l0_active_minus1: %d\n", p->num_ref_idx_l0_active_minus1);
437- va_TraceMsg("num_ref_idx_l1_active_minus1: %d\n", p->num_ref_idx_l1_active_minus1);
438- va_TraceMsg("cabac_init_idc: %d\n", p->cabac_init_idc);
439- va_TraceMsg("slice_qp_delta: %d\n", p->slice_qp_delta);
440- va_TraceMsg("disable_deblocking_filter_idc: %d\n", p->disable_deblocking_filter_idc);
441- va_TraceMsg("slice_alpha_c0_offset_div2: %d\n", p->slice_alpha_c0_offset_div2);
442- va_TraceMsg("slice_beta_offset_div2: %d\n", p->slice_beta_offset_div2);
443-
444-#if 1
445- if (p->slice_type == 0 || p->slice_type == 1)
446- {
447- va_TraceMsg("RefPicList0:\n");
448- for (i = 0; i < p->num_ref_idx_l0_active_minus1 + 1; i++)
449- {
450- //va_TraceMsg("%d-%d; ", p->RefPicList0[i].TopFieldOrderCnt, p->RefPicList0[i].BottomFieldOrderCnt);
451- va_TraceMsg("%d-%d-%d-%d; ", p->RefPicList0[i].TopFieldOrderCnt, p->RefPicList0[i].BottomFieldOrderCnt, p->RefPicList0[i].picture_id, p->RefPicList0[i].frame_idx);
777+ DPY2INDEX(dpy);
778+
779+ trace_context[idx].trace_slice_no++;
780+ trace_context[idx].trace_slice_size = p->slice_data_size;
781+
782+ va_TraceMsg(idx, "VASliceParameterBufferH264\n");
783+ va_TraceMsg(idx, "\tslice_data_size = %d\n", p->slice_data_size);
784+ va_TraceMsg(idx, "\tslice_data_offset = %d\n", p->slice_data_offset);
785+ va_TraceMsg(idx, "\tslice_data_flag = %d\n", p->slice_data_flag);
786+ va_TraceMsg(idx, "\tslice_data_bit_offset = %d\n", p->slice_data_bit_offset);
787+ va_TraceMsg(idx, "\tfirst_mb_in_slice = %d\n", p->first_mb_in_slice);
788+ va_TraceMsg(idx, "\tslice_type = %d\n", p->slice_type);
789+ va_TraceMsg(idx, "\tdirect_spatial_mv_pred_flag = %d\n", p->direct_spatial_mv_pred_flag);
790+ va_TraceMsg(idx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1);
791+ va_TraceMsg(idx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1);
792+ va_TraceMsg(idx, "\tcabac_init_idc = %d\n", p->cabac_init_idc);
793+ va_TraceMsg(idx, "\tslice_qp_delta = %d\n", p->slice_qp_delta);
794+ va_TraceMsg(idx, "\tdisable_deblocking_filter_idc = %d\n", p->disable_deblocking_filter_idc);
795+ va_TraceMsg(idx, "\tslice_alpha_c0_offset_div2 = %d\n", p->slice_alpha_c0_offset_div2);
796+ va_TraceMsg(idx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2);
797+
798+ if (p->slice_type == 0 || p->slice_type == 1) {
799+ va_TraceMsg(idx, "\tRefPicList0 =");
800+ for (i = 0; i < p->num_ref_idx_l0_active_minus1 + 1; i++) {
801+ va_TraceMsg(idx, "%d-%d-%d-%d\n", p->RefPicList0[i].TopFieldOrderCnt, p->RefPicList0[i].BottomFieldOrderCnt, p->RefPicList0[i].picture_id, p->RefPicList0[i].frame_idx);
452802 }
453- va_TraceMsg("\n");
454- if (p->slice_type == 1)
455- {
456- va_TraceMsg("RefPicList1:\n");
803+ if (p->slice_type == 1) {
804+ va_TraceMsg(idx, "\tRefPicList1 =");
457805 for (i = 0; i < p->num_ref_idx_l1_active_minus1 + 1; i++)
458806 {
459- //va_TraceMsg("%d-%d; ", p->RefPicList1[i].TopFieldOrderCnt, p->RefPicList1[i].BottomFieldOrderCnt);
460- va_TraceMsg("%d-%d-%d-%d; ", p->RefPicList1[i].TopFieldOrderCnt, p->RefPicList1[i].BottomFieldOrderCnt, p->RefPicList1[i].picture_id, p->RefPicList1[i].frame_idx);
807+ va_TraceMsg(idx, "%d-%d-%d-%d\n", p->RefPicList1[i].TopFieldOrderCnt, p->RefPicList1[i].BottomFieldOrderCnt, p->RefPicList1[i].picture_id, p->RefPicList1[i].frame_idx);
461808 }
462809 }
463- va_TraceMsg("\n");
464810 }
465-#endif
466-
467- va_TraceMsg("luma_log2_weight_denom: %d\n", p->luma_log2_weight_denom);
468- va_TraceMsg("chroma_log2_weight_denom: %d\n", p->chroma_log2_weight_denom);
469- va_TraceMsg("luma_weight_l0_flag: %d\n", p->luma_weight_l0_flag);
470- if (p->luma_weight_l0_flag)
471- {
472- for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++)
473- {
474- va_TraceMsg("%d ", p->luma_weight_l0[i]);
475- va_TraceMsg("%d ", p->luma_offset_l0[i]);
811+
812+ va_TraceMsg(idx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom);
813+ va_TraceMsg(idx, "\tchroma_log2_weight_denom = %d\n", p->chroma_log2_weight_denom);
814+ va_TraceMsg(idx, "\tluma_weight_l0_flag = %d\n", p->luma_weight_l0_flag);
815+ if (p->luma_weight_l0_flag) {
816+ for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++) {
817+ va_TraceMsg(idx, "\t%d ", p->luma_weight_l0[i]);
818+ va_TraceMsg(idx, "\t%d ", p->luma_offset_l0[i]);
476819 }
477- va_TraceMsg("\n");
478820 }
479-
480821
481- va_TraceMsg("chroma_weight_l0_flag: %d\n", p->chroma_weight_l0_flag);
482- if (p->chroma_weight_l0_flag)
483- {
484- for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++)
485- {
486- va_TraceMsg("%d ", p->chroma_weight_l0[i][0]);
487- va_TraceMsg("%d ", p->chroma_offset_l0[i][0]);
488- va_TraceMsg("%d ", p->chroma_weight_l0[i][1]);
489- va_TraceMsg("%d ", p->chroma_offset_l0[i][1]);
822+ va_TraceMsg(idx, "\tchroma_weight_l0_flag = %d\n", p->chroma_weight_l0_flag);
823+ if (p->chroma_weight_l0_flag) {
824+ for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++) {
825+ va_TraceMsg(idx, "\t\t%d ", p->chroma_weight_l0[i][0]);
826+ va_TraceMsg(idx, "\t\t%d ", p->chroma_offset_l0[i][0]);
827+ va_TraceMsg(idx, "\t\t%d ", p->chroma_weight_l0[i][1]);
828+ va_TraceMsg(idx, "\t\t%d ", p->chroma_offset_l0[i][1]);
490829 }
491- va_TraceMsg("\n");
492830 }
493- va_TraceMsg("luma_weight_l1_flag: %d\n", p->luma_weight_l1_flag);
494- if (p->luma_weight_l1_flag)
495- {
496- for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++)
497- {
498- va_TraceMsg("%d ", p->luma_weight_l1[i]);
499- va_TraceMsg("%d ", p->luma_offset_l1[i]);
831+
832+ va_TraceMsg(idx, "\tluma_weight_l1_flag = %d\n", p->luma_weight_l1_flag);
833+ if (p->luma_weight_l1_flag) {
834+ for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++) {
835+ va_TraceMsg(idx, "\t\t%d ", p->luma_weight_l1[i]);
836+ va_TraceMsg(idx, "\t\t%d ", p->luma_offset_l1[i]);
500837 }
501- va_TraceMsg("\n");
502838 }
503- va_TraceMsg("chroma_weight_l1_flag: %d\n", p->chroma_weight_l1_flag);
504- if (p->chroma_weight_l1_flag)
505- {
506- for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++)
507- {
508- va_TraceMsg("%d ", p->chroma_weight_l1[i][0]);
509- va_TraceMsg("%d ", p->chroma_offset_l1[i][0]);
510- va_TraceMsg("%d ", p->chroma_weight_l1[i][1]);
511- va_TraceMsg("%d ", p->chroma_offset_l1[i][1]);
839+
840+ va_TraceMsg(idx, "\tchroma_weight_l1_flag = %d\n", p->chroma_weight_l1_flag);
841+ if (p->chroma_weight_l1_flag) {
842+ for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++) {
843+ va_TraceMsg(idx, "\t\t%d ", p->chroma_weight_l1[i][0]);
844+ va_TraceMsg(idx, "\t\t%d ", p->chroma_offset_l1[i][0]);
845+ va_TraceMsg(idx, "\t\t%d ", p->chroma_weight_l1[i][1]);
846+ va_TraceMsg(idx, "\t\t%d ", p->chroma_offset_l1[i][1]);
512847 }
513- va_TraceMsg("\n");
848+ va_TraceMsg(idx, "\n");
514849 }
515850 }
516851
@@ -524,30 +859,171 @@ static void va_TraceVAIQMatrixBufferH264(
524859 void *data
525860 )
526861 {
527- va_TraceMsg("========== IQMatrix ============.\n");
528862 VAIQMatrixBufferH264* p = (VAIQMatrixBufferH264* )data;
529863 int i, j;
530- for (i = 0; i < 6; i++)
531- {
532- for (j = 0; j < 16; j++)
533- {
534- va_TraceMsg("%d\t", p->ScalingList4x4[i][j]);
864+ DPY2INDEX(dpy);
865+
866+ va_TraceMsg(idx, "VAIQMatrixBufferH264\n");
867+
868+ va_TraceMsg(idx, "\tScalingList4x4[6][16]=\n");
869+ for (i = 0; i < 6; i++) {
870+ for (j = 0; j < 16; j++) {
871+ va_TraceMsg(idx, "\t%d\t", p->ScalingList4x4[i][j]);
535872 if ((j + 1) % 8 == 0)
536- va_TraceMsg("\n");
873+ va_TraceMsg(idx, "\n");
537874 }
538875 }
539876
540- for (i = 0; i < 2; i++)
541- {
542- for (j = 0; j < 64; j++)
543- {
544- va_TraceMsg("%d\t", p->ScalingList8x8[i][j]);
877+ va_TraceMsg(idx, "\tScalingList8x8[2][64]=\n");
878+ for (i = 0; i < 2; i++) {
879+ for (j = 0; j < 64; j++) {
880+ va_TraceMsg(idx, "\t%d", p->ScalingList8x8[i][j]);
545881 if ((j + 1) % 8 == 0)
546- va_TraceMsg("\n");
882+ va_TraceMsg(idx, "\n");
547883 }
548884 }
549885 }
550886
887+static void va_TraceVAEncSequenceParameterBufferH264(
888+ VADisplay dpy,
889+ VAContextID context,
890+ VABufferID buffer,
891+ VABufferType type,
892+ unsigned int size,
893+ unsigned int num_elements,
894+ void *data)
895+{
896+ VAEncSequenceParameterBufferH264 *p = (VAEncSequenceParameterBufferH264 *)data;
897+ DPY2INDEX(dpy);
898+
899+ va_TraceMsg(idx, "VAEncSequenceParameterBufferH264\n");
900+
901+ va_TraceMsg(idx, "\tseq_parameter_set_id = %d\n", p->seq_parameter_set_id);
902+ va_TraceMsg(idx, "\tlevel_idc = %d\n", p->level_idc);
903+ va_TraceMsg(idx, "\tintra_period = %d\n", p->intra_period);
904+ va_TraceMsg(idx, "\tintra_idr_period = %d\n", p->intra_idr_period);
905+ va_TraceMsg(idx, "\tpicture_width_in_mbs = %d\n", p->picture_width_in_mbs);
906+ va_TraceMsg(idx, "\tpicture_height_in_mbs = %d\n", p->picture_height_in_mbs);
907+ va_TraceMsg(idx, "\tbits_per_second = %d\n", p->bits_per_second);
908+ va_TraceMsg(idx, "\tframe_rate = %d\n", p->frame_rate);
909+ va_TraceMsg(idx, "\tinitial_qp = %d\n", p->initial_qp);
910+ va_TraceMsg(idx, "\tmin_qp = %d\n", p->min_qp);
911+ va_TraceMsg(idx, "\tbasic_unit_size = %d\n", p->basic_unit_size);
912+ va_TraceMsg(idx, "\tvui_flag = %d\n", p->vui_flag);
913+
914+ /* start a new sequce, coded log file can be truncated */
915+ trace_context[idx].trace_sequence_start = 1;
916+
917+ return;
918+}
919+
920+static void va_TraceVAEncPictureParameterBufferH264(
921+ VADisplay dpy,
922+ VAContextID context,
923+ VABufferID buffer,
924+ VABufferType type,
925+ unsigned int size,
926+ unsigned int num_elements,
927+ void *data)
928+{
929+ VAEncPictureParameterBufferH264 *p = (VAEncPictureParameterBufferH264 *)data;
930+ DPY2INDEX(dpy);
931+
932+ va_TraceMsg(idx, "VAEncSequenceParameterBufferH264\n");
933+ va_TraceMsg(idx, "\treference_picture = 0x%08x\n", p->reference_picture);
934+ va_TraceMsg(idx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
935+ va_TraceMsg(idx, "\tcoded_buf = %08x\n", p->coded_buf);
936+ va_TraceMsg(idx, "\tpicture_width = %d\n", p->picture_width);
937+ va_TraceMsg(idx, "\tpicture_height = %d\n", p->picture_height);
938+ va_TraceMsg(idx, "\tlast_picture = 0x%08x\n", p->last_picture);
939+
940+ trace_context[idx].trace_codedbuf = p->coded_buf;
941+
942+ return;
943+}
944+
945+
946+static void va_TraceVAEncSliceParameterBuffer(
947+ VADisplay dpy,
948+ VAContextID context,
949+ VABufferID buffer,
950+ VABufferType type,
951+ unsigned int size,
952+ unsigned int num_elements,
953+ void *data)
954+{
955+ VAEncSliceParameterBuffer* p = (VAEncSliceParameterBuffer*)data;
956+ DPY2INDEX(dpy);
957+
958+ va_TraceMsg(idx, "VAEncSliceParameterBuffer\n");
959+
960+ va_TraceMsg(idx, "\tstart_row_number = %d\n", p->start_row_number);
961+ va_TraceMsg(idx, "\tslice_height = %d\n", p->slice_height);
962+ va_TraceMsg(idx, "\tslice_flags.is_intra = %d\n", p->slice_flags.bits.is_intra);
963+ va_TraceMsg(idx, "\tslice_flags.disable_deblocking_filter_idc = %d\n", p->slice_flags.bits.disable_deblocking_filter_idc);
964+
965+ return;
966+}
967+
968+static void va_TraceVAEncMiscParameterBuffer(
969+ VADisplay dpy,
970+ VAContextID context,
971+ VABufferID buffer,
972+ VABufferType type,
973+ unsigned int size,
974+ unsigned int num_elements,
975+ void *data)
976+{
977+ VAEncMiscParameterBuffer* tmp = (VAEncMiscParameterBuffer*)data;
978+ DPY2INDEX(dpy);
979+
980+ switch (tmp->type) {
981+ case VAEncMiscParameterTypeFrameRate:
982+ {
983+ VAEncMiscParameterFrameRate *p = (VAEncMiscParameterFrameRate *)tmp->data;
984+ va_TraceMsg(idx, "VAEncMiscParameterFrameRate\n");
985+ va_TraceMsg(idx, "\tframerate = %d\n", p->framerate);
986+
987+ break;
988+ }
989+ case VAEncMiscParameterTypeRateControl:
990+ {
991+ VAEncMiscParameterRateControl *p = (VAEncMiscParameterRateControl *)tmp->data;
992+
993+ va_TraceMsg(idx, "VAEncMiscParameterRateControl\n");
994+ va_TraceMsg(idx, "\tbits_per_second = %d\n", p->bits_per_second);
995+ va_TraceMsg(idx, "\twindow_size = %d\n", p->window_size);
996+ va_TraceMsg(idx, "\tinitial_qp = %d\n", p->initial_qp);
997+ va_TraceMsg(idx, "\tmin_qp = %d\n", p->min_qp);
998+ break;
999+ }
1000+ case VAEncMiscParameterTypeMaxSliceSize:
1001+ {
1002+ VAEncMiscParameterMaxSliceSize *p = (VAEncMiscParameterMaxSliceSize *)tmp->data;
1003+
1004+ va_TraceMsg(idx, "VAEncMiscParameterTypeMaxSliceSize\n");
1005+ va_TraceMsg(idx, "\tmax_slice_size = %d\n", p->max_slice_size);
1006+ break;
1007+ }
1008+ case VAEncMiscParameterTypeAIR:
1009+ {
1010+ VAEncMiscParameterAIR *p = (VAEncMiscParameterAIR *)tmp->data;
1011+
1012+ va_TraceMsg(idx, "VAEncMiscParameterAIR\n");
1013+ va_TraceMsg(idx, "\tair_num_mbs = %d\n", p->air_num_mbs);
1014+ va_TraceMsg(idx, "\tair_threshold = %d\n", p->air_threshold);
1015+ va_TraceMsg(idx, "\tair_auto = %d\n", p->air_auto);
1016+ break;
1017+ }
1018+ default:
1019+ va_TraceMsg(idx, "invalid VAEncMiscParameterBuffer type = %d\n", tmp->type);
1020+ break;
1021+ }
1022+
1023+ return;
1024+}
1025+
1026+
5511027 static void va_TraceVAPictureParameterBufferVC1(
5521028 VADisplay dpy,
5531029 VAContextID context,
@@ -559,174 +1035,96 @@ static void va_TraceVAPictureParameterBufferVC1(
5591035 )
5601036 {
5611037 VAPictureParameterBufferVC1* p = (VAPictureParameterBufferVC1*)data;
562-
563- va_TraceMsg("\tforward_reference_picture = 0x%08x\n", p->forward_reference_picture);
564- va_TraceMsg("\tbackward_reference_picture = 0x%08x\n", p->backward_reference_picture);
565- va_TraceMsg("\tinloop_decoded_picture = 0x%08x\n", p->inloop_decoded_picture);
566-
567- va_TraceMsg("\tpulldown = %d\n", p->sequence_fields.bits.pulldown);
568- va_TraceMsg("\tinterlace = %d\n", p->sequence_fields.bits.interlace);
569- va_TraceMsg("\ttfcntrflag = %d\n", p->sequence_fields.bits.tfcntrflag);
570- va_TraceMsg("\tfinterpflag = %d\n", p->sequence_fields.bits.finterpflag);
571- va_TraceMsg("\tpsf = %d.\n",
572- p->sequence_fields.bits.psf);
573- va_TraceMsg("\tmultires = %d.\n",
574- p->sequence_fields.bits.multires);
575- va_TraceMsg("\toverlap = %d.\n",
576- p->sequence_fields.bits.overlap);
577- va_TraceMsg("\tsyncmarker = %d.\n",
578- p->sequence_fields.bits.syncmarker);
579- va_TraceMsg("\trangered = %d.\n",
580- p->sequence_fields.bits.rangered);
581- va_TraceMsg("\tmax_b_frames = %d.\n",
582- p->sequence_fields.bits.max_b_frames);
583- va_TraceMsg("\tcoded_width = %d.\n",
584- p->coded_width);
585- va_TraceMsg("\tcoded_height = %d.\n",
586- p->coded_height);
587- va_TraceMsg("\tclosed_entry = %d.\n",
588- p->entrypoint_fields.bits.closed_entry);
589- va_TraceMsg("\tbroken_link = %d.\n",
590- p->entrypoint_fields.bits.broken_link);
591- va_TraceMsg("\tclosed_entry = %d.\n",
592- p->entrypoint_fields.bits.closed_entry);
593- va_TraceMsg("\tpanscan_flag = %d.\n",
594- p->entrypoint_fields.bits.panscan_flag);
595- va_TraceMsg("\tloopfilter = %d.\n",
596- p->entrypoint_fields.bits.loopfilter);
597- va_TraceMsg("\tconditional_overlap_flag = %d.\n",
598- p->conditional_overlap_flag);
599- va_TraceMsg("\tfast_uvmc_flag = %d.\n",
600- p->fast_uvmc_flag);
601- va_TraceMsg("\trange_mapping_luma_flag = %d.\n",
602- p->range_mapping_fields.bits.luma_flag);
603- va_TraceMsg("\trange_mapping_luma = %d.\n",
604- p->range_mapping_fields.bits.luma);
605- va_TraceMsg("\trange_mapping_chroma_flag = %d.\n",
606- p->range_mapping_fields.bits.chroma_flag);
607- va_TraceMsg("\trange_mapping_chroma = %d.\n",
608- p->range_mapping_fields.bits.chroma);
609- va_TraceMsg("\tb_picture_fraction = %d.\n",
610- p->b_picture_fraction);
611- va_TraceMsg("\tcbp_table = %d.\n",
612- p->cbp_table);
613- va_TraceMsg("\tmb_mode_table = %d.\n",
614- p->mb_mode_table);
615- va_TraceMsg("\trange_reduction_frame = %d.\n",
616- p->range_reduction_frame);
617- va_TraceMsg("\trounding_control = %d.\n",
618- p->rounding_control);
619- va_TraceMsg("\tpost_processing = %d.\n",
620- p->post_processing);
621- va_TraceMsg("\tpicture_resolution_index = %d.\n",
622- p->picture_resolution_index);
623- va_TraceMsg("\tluma_scale = %d.\n",
624- p->luma_scale);
625- va_TraceMsg("\tluma_shift = %d.\n",
626- p->luma_shift);
627- va_TraceMsg("\tpicture_type = %d.\n",
628- p->picture_fields.bits.picture_type);
629- va_TraceMsg("\tframe_coding_mode = %d.\n",
630- p->picture_fields.bits.frame_coding_mode);
631- va_TraceMsg("\ttop_field_first = %d.\n",
632- p->picture_fields.bits.top_field_first);
633- va_TraceMsg("\tis_first_field = %d.\n",
634- p->picture_fields.bits.is_first_field);
635- va_TraceMsg("\tintensity_compensation = %d.\n",
636- p->picture_fields.bits.intensity_compensation);
637- va_TraceMsg(" ---------------------------------\n");
638- va_TraceMsg("\tmv_type_mb = %d.\n",
639- p->raw_coding.flags.mv_type_mb);
640- va_TraceMsg("\tdirect_mb = %d.\n",
641- p->raw_coding.flags.direct_mb);
642- va_TraceMsg("\tskip_mb = %d.\n",
643- p->raw_coding.flags.skip_mb);
644- va_TraceMsg("\tfield_tx = %d.\n",
645- p->raw_coding.flags.field_tx);
646- va_TraceMsg("\tforward_mb = %d.\n",
647- p->raw_coding.flags.forward_mb);
648- va_TraceMsg("\tac_pred = %d.\n",
649- p->raw_coding.flags.ac_pred);
650- va_TraceMsg("\toverflags = %d.\n",
651- p->raw_coding.flags.overflags);
652- va_TraceMsg(" ---------------------------------\n");
653- va_TraceMsg("\tbp_mv_type_mb = %d.\n",
654- p->bitplane_present.flags.bp_mv_type_mb);
655- va_TraceMsg("\tbp_direct_mb = %d.\n",
656- p->bitplane_present.flags.bp_direct_mb);
657- va_TraceMsg("\tbp_skip_mb = %d.\n",
658- p->bitplane_present.flags.bp_skip_mb);
659- va_TraceMsg("\tbp_field_tx = %d.\n",
660- p->bitplane_present.flags.bp_field_tx);
661- va_TraceMsg("\tbp_forward_mb = %d.\n",
662- p->bitplane_present.flags.bp_forward_mb);
663- va_TraceMsg("\tbp_ac_pred = %d.\n",
664- p->bitplane_present.flags.bp_ac_pred);
665- va_TraceMsg("\tbp_overflags = %d.\n",
666- p->bitplane_present.flags.bp_overflags);
667- va_TraceMsg(" ---------------------------------\n");
668- va_TraceMsg("\treference_distance_flag = %d.\n",
669- p->reference_fields.bits.reference_distance_flag);
670- va_TraceMsg("\treference_distance = %d.\n",
671- p->reference_fields.bits.reference_distance);
672- va_TraceMsg("\tnum_reference_pictures = %d.\n",
673- p->reference_fields.bits.num_reference_pictures);
674- va_TraceMsg("\treference_field_pic_indicator = %d.\n",
675- p->reference_fields.bits.reference_field_pic_indicator);
676- va_TraceMsg("\tmv_mode = %d.\n",
677- p->mv_fields.bits.mv_mode);
678- va_TraceMsg("\tmv_mode2 = %d.\n",
679- p->mv_fields.bits.mv_mode2);
680- va_TraceMsg("\tmv_table = %d.\n",
681- p->mv_fields.bits.mv_table);
682- va_TraceMsg("\ttwo_mv_block_pattern_table = %d.\n",
683- p->mv_fields.bits.two_mv_block_pattern_table);
684- va_TraceMsg("\tfour_mv_switch = %d.\n",
685- p->mv_fields.bits.four_mv_switch);
686- va_TraceMsg("\tfour_mv_block_pattern_table = %d.\n",
687- p->mv_fields.bits.four_mv_block_pattern_table);
688- va_TraceMsg("\textended_mv_flag = %d.\n",
689- p->mv_fields.bits.extended_mv_flag);
690- va_TraceMsg("\textended_mv_range = %d.\n",
691- p->mv_fields.bits.extended_mv_range);
692- va_TraceMsg("\textended_dmv_flag = %d.\n",
693- p->mv_fields.bits.extended_dmv_flag);
694- va_TraceMsg("\textended_dmv_range = %d.\n",
695- p->mv_fields.bits.extended_dmv_range);
696- va_TraceMsg("\tdquant = %d.\n",
697- p->pic_quantizer_fields.bits.dquant);
698- va_TraceMsg("\tquantizer = %d.\n",
699- p->pic_quantizer_fields.bits.quantizer);
700- va_TraceMsg("\thalf_qp = %d.\n",
701- p->pic_quantizer_fields.bits.half_qp);
702- va_TraceMsg("\tpic_quantizer_scale = %d.\n",
703- p->pic_quantizer_fields.bits.pic_quantizer_scale);
704- va_TraceMsg("\tpic_quantizer_type = %d.\n",
705- p->pic_quantizer_fields.bits.pic_quantizer_type);
706- va_TraceMsg("\tdq_frame = %d.\n",
707- p->pic_quantizer_fields.bits.dq_frame);
708- va_TraceMsg("\tdq_profile = %d.\n",
709- p->pic_quantizer_fields.bits.dq_profile);
710- va_TraceMsg("\tdq_sb_edge = %d.\n",
711- p->pic_quantizer_fields.bits.dq_sb_edge);
712- va_TraceMsg("\tdq_db_edge = %d.\n",
713- p->pic_quantizer_fields.bits.dq_db_edge);
714- va_TraceMsg("\tdq_binary_level = %d.\n",
715- p->pic_quantizer_fields.bits.dq_binary_level);
716- va_TraceMsg("\talt_pic_quantizer = %d.\n",
717- p->pic_quantizer_fields.bits.alt_pic_quantizer);
718- va_TraceMsg("\tvariable_sized_transform_flag = %d.\n",
719- p->transform_fields.bits.variable_sized_transform_flag);
720- va_TraceMsg("\tmb_level_transform_type_flag = %d.\n",
721- p->transform_fields.bits.mb_level_transform_type_flag);
722- va_TraceMsg("\tframe_level_transform_type = %d.\n",
723- p->transform_fields.bits.frame_level_transform_type);
724- va_TraceMsg("\ttransform_ac_codingset_idx1 = %d.\n",
725- p->transform_fields.bits.transform_ac_codingset_idx1);
726- va_TraceMsg("\ttransform_ac_codingset_idx2 = %d.\n",
727- p->transform_fields.bits.transform_ac_codingset_idx2);
728- va_TraceMsg("\tintra_transform_dc_table = %d.\n",
729- p->transform_fields.bits.intra_transform_dc_table);
1038+ DPY2INDEX(dpy);
1039+
1040+ va_TraceMsg(idx, "VAPictureParameterBufferVC1\n");
1041+
1042+ va_TraceMsg(idx, "\tforward_reference_picture = 0x%08x\n", p->forward_reference_picture);
1043+ va_TraceMsg(idx, "\tbackward_reference_picture = 0x%08x\n", p->backward_reference_picture);
1044+ va_TraceMsg(idx, "\tinloop_decoded_picture = 0x%08x\n", p->inloop_decoded_picture);
1045+
1046+ va_TraceMsg(idx, "\tpulldown = %d\n", p->sequence_fields.bits.pulldown);
1047+ va_TraceMsg(idx, "\tinterlace = %d\n", p->sequence_fields.bits.interlace);
1048+ va_TraceMsg(idx, "\ttfcntrflag = %d\n", p->sequence_fields.bits.tfcntrflag);
1049+ va_TraceMsg(idx, "\tfinterpflag = %d\n", p->sequence_fields.bits.finterpflag);
1050+ va_TraceMsg(idx, "\tpsf = %d\n", p->sequence_fields.bits.psf);
1051+ va_TraceMsg(idx, "\tmultires = %d\n", p->sequence_fields.bits.multires);
1052+ va_TraceMsg(idx, "\toverlap = %d\n", p->sequence_fields.bits.overlap);
1053+ va_TraceMsg(idx, "\tsyncmarker = %d\n", p->sequence_fields.bits.syncmarker);
1054+ va_TraceMsg(idx, "\trangered = %d\n", p->sequence_fields.bits.rangered);
1055+ va_TraceMsg(idx, "\tmax_b_frames = %d\n", p->sequence_fields.bits.max_b_frames);
1056+ va_TraceMsg(idx, "\tcoded_width = %d\n", p->coded_width);
1057+ va_TraceMsg(idx, "\tcoded_height = %d\n", p->coded_height);
1058+ va_TraceMsg(idx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry);
1059+ va_TraceMsg(idx, "\tbroken_link = %d\n", p->entrypoint_fields.bits.broken_link);
1060+ va_TraceMsg(idx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry);
1061+ va_TraceMsg(idx, "\tpanscan_flag = %d\n", p->entrypoint_fields.bits.panscan_flag);
1062+ va_TraceMsg(idx, "\tloopfilter = %d\n", p->entrypoint_fields.bits.loopfilter);
1063+ va_TraceMsg(idx, "\tconditional_overlap_flag = %d\n", p->conditional_overlap_flag);
1064+ va_TraceMsg(idx, "\tfast_uvmc_flag = %d\n", p->fast_uvmc_flag);
1065+ va_TraceMsg(idx, "\trange_mapping_luma_flag = %d\n", p->range_mapping_fields.bits.luma_flag);
1066+ va_TraceMsg(idx, "\trange_mapping_luma = %d\n", p->range_mapping_fields.bits.luma);
1067+ va_TraceMsg(idx, "\trange_mapping_chroma_flag = %d\n", p->range_mapping_fields.bits.chroma_flag);
1068+ va_TraceMsg(idx, "\trange_mapping_chroma = %d\n", p->range_mapping_fields.bits.chroma);
1069+ va_TraceMsg(idx, "\tb_picture_fraction = %d\n", p->b_picture_fraction);
1070+ va_TraceMsg(idx, "\tcbp_table = %d\n", p->cbp_table);
1071+ va_TraceMsg(idx, "\tmb_mode_table = %d\n", p->mb_mode_table);
1072+ va_TraceMsg(idx, "\trange_reduction_frame = %d\n", p->range_reduction_frame);
1073+ va_TraceMsg(idx, "\trounding_control = %d\n", p->rounding_control);
1074+ va_TraceMsg(idx, "\tpost_processing = %d\n", p->post_processing);
1075+ va_TraceMsg(idx, "\tpicture_resolution_index = %d\n", p->picture_resolution_index);
1076+ va_TraceMsg(idx, "\tluma_scale = %d\n", p->luma_scale);
1077+ va_TraceMsg(idx, "\tluma_shift = %d\n", p->luma_shift);
1078+ va_TraceMsg(idx, "\tpicture_type = %d\n", p->picture_fields.bits.picture_type);
1079+ va_TraceMsg(idx, "\tframe_coding_mode = %d\n", p->picture_fields.bits.frame_coding_mode);
1080+ va_TraceMsg(idx, "\ttop_field_first = %d\n", p->picture_fields.bits.top_field_first);
1081+ va_TraceMsg(idx, "\tis_first_field = %d\n", p->picture_fields.bits.is_first_field);
1082+ va_TraceMsg(idx, "\tintensity_compensation = %d\n", p->picture_fields.bits.intensity_compensation);
1083+ va_TraceMsg(idx, "\tmv_type_mb = %d\n", p->raw_coding.flags.mv_type_mb);
1084+ va_TraceMsg(idx, "\tdirect_mb = %d\n", p->raw_coding.flags.direct_mb);
1085+ va_TraceMsg(idx, "\tskip_mb = %d\n", p->raw_coding.flags.skip_mb);
1086+ va_TraceMsg(idx, "\tfield_tx = %d\n", p->raw_coding.flags.field_tx);
1087+ va_TraceMsg(idx, "\tforward_mb = %d\n", p->raw_coding.flags.forward_mb);
1088+ va_TraceMsg(idx, "\tac_pred = %d\n", p->raw_coding.flags.ac_pred);
1089+ va_TraceMsg(idx, "\toverflags = %d\n", p->raw_coding.flags.overflags);
1090+ va_TraceMsg(idx, "\tbp_mv_type_mb = %d\n", p->bitplane_present.flags.bp_mv_type_mb);
1091+ va_TraceMsg(idx, "\tbp_direct_mb = %d\n", p->bitplane_present.flags.bp_direct_mb);
1092+ va_TraceMsg(idx, "\tbp_skip_mb = %d\n", p->bitplane_present.flags.bp_skip_mb);
1093+ va_TraceMsg(idx, "\tbp_field_tx = %d\n", p->bitplane_present.flags.bp_field_tx);
1094+ va_TraceMsg(idx, "\tbp_forward_mb = %d\n", p->bitplane_present.flags.bp_forward_mb);
1095+ va_TraceMsg(idx, "\tbp_ac_pred = %d\n", p->bitplane_present.flags.bp_ac_pred);
1096+ va_TraceMsg(idx, "\tbp_overflags = %d\n", p->bitplane_present.flags.bp_overflags);
1097+ va_TraceMsg(idx, "\treference_distance_flag = %d\n", p->reference_fields.bits.reference_distance_flag);
1098+ va_TraceMsg(idx, "\treference_distance = %d\n", p->reference_fields.bits.reference_distance);
1099+ va_TraceMsg(idx, "\tnum_reference_pictures = %d\n", p->reference_fields.bits.num_reference_pictures);
1100+ va_TraceMsg(idx, "\treference_field_pic_indicator = %d\n", p->reference_fields.bits.reference_field_pic_indicator);
1101+ va_TraceMsg(idx, "\tmv_mode = %d\n", p->mv_fields.bits.mv_mode);
1102+ va_TraceMsg(idx, "\tmv_mode2 = %d\n", p->mv_fields.bits.mv_mode2);
1103+ va_TraceMsg(idx, "\tmv_table = %d\n", p->mv_fields.bits.mv_table);
1104+ va_TraceMsg(idx, "\ttwo_mv_block_pattern_table = %d\n", p->mv_fields.bits.two_mv_block_pattern_table);
1105+ va_TraceMsg(idx, "\tfour_mv_switch = %d\n", p->mv_fields.bits.four_mv_switch);
1106+ va_TraceMsg(idx, "\tfour_mv_block_pattern_table = %d\n", p->mv_fields.bits.four_mv_block_pattern_table);
1107+ va_TraceMsg(idx, "\textended_mv_flag = %d\n", p->mv_fields.bits.extended_mv_flag);
1108+ va_TraceMsg(idx, "\textended_mv_range = %d\n", p->mv_fields.bits.extended_mv_range);
1109+ va_TraceMsg(idx, "\textended_dmv_flag = %d\n", p->mv_fields.bits.extended_dmv_flag);
1110+ va_TraceMsg(idx, "\textended_dmv_range = %d\n", p->mv_fields.bits.extended_dmv_range);
1111+ va_TraceMsg(idx, "\tdquant = %d\n", p->pic_quantizer_fields.bits.dquant);
1112+ va_TraceMsg(idx, "\tquantizer = %d\n", p->pic_quantizer_fields.bits.quantizer);
1113+ va_TraceMsg(idx, "\thalf_qp = %d\n", p->pic_quantizer_fields.bits.half_qp);
1114+ va_TraceMsg(idx, "\tpic_quantizer_scale = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_scale);
1115+ va_TraceMsg(idx, "\tpic_quantizer_type = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_type);
1116+ va_TraceMsg(idx, "\tdq_frame = %d\n", p->pic_quantizer_fields.bits.dq_frame);
1117+ va_TraceMsg(idx, "\tdq_profile = %d\n", p->pic_quantizer_fields.bits.dq_profile);
1118+ va_TraceMsg(idx, "\tdq_sb_edge = %d\n", p->pic_quantizer_fields.bits.dq_sb_edge);
1119+ va_TraceMsg(idx, "\tdq_db_edge = %d\n", p->pic_quantizer_fields.bits.dq_db_edge);
1120+ va_TraceMsg(idx, "\tdq_binary_level = %d\n", p->pic_quantizer_fields.bits.dq_binary_level);
1121+ va_TraceMsg(idx, "\talt_pic_quantizer = %d\n", p->pic_quantizer_fields.bits.alt_pic_quantizer);
1122+ va_TraceMsg(idx, "\tvariable_sized_transform_flag = %d\n", p->transform_fields.bits.variable_sized_transform_flag);
1123+ va_TraceMsg(idx, "\tmb_level_transform_type_flag = %d\n", p->transform_fields.bits.mb_level_transform_type_flag);
1124+ va_TraceMsg(idx, "\tframe_level_transform_type = %d\n", p->transform_fields.bits.frame_level_transform_type);
1125+ va_TraceMsg(idx, "\ttransform_ac_codingset_idx1 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx1);
1126+ va_TraceMsg(idx, "\ttransform_ac_codingset_idx2 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx2);
1127+ va_TraceMsg(idx, "\tintra_transform_dc_table = %d\n", p->transform_fields.bits.intra_transform_dc_table);
7301128 }
7311129
7321130 static void va_TraceVASliceParameterBufferVC1(
@@ -740,13 +1138,17 @@ static void va_TraceVASliceParameterBufferVC1(
7401138 )
7411139 {
7421140 VASliceParameterBufferVC1 *p = (VASliceParameterBufferVC1*)data;
1141+ DPY2INDEX(dpy);
1142+
1143+ trace_context[idx].trace_slice_no++;
1144+ trace_context[idx].trace_slice_size = p->slice_data_size;
7431145
744- va_TraceMsg ("========== SLICE NUMBER ==========\n");
745- va_TraceMsg (" slice_data_size = %d\n", p->slice_data_size);
746- va_TraceMsg (" slice_data_offset = %d\n", p->slice_data_offset);
747- va_TraceMsg (" slice_data_flag = %d\n", p->slice_data_flag);
748- va_TraceMsg (" macroblock_offset = %d\n", p->macroblock_offset);
749- va_TraceMsg (" slice_vertical_position = %d\n", p->slice_vertical_position);
1146+ va_TraceMsg(idx, "VASliceParameterBufferVC1\n");
1147+ va_TraceMsg(idx, "\tslice_data_size = %d\n", p->slice_data_size);
1148+ va_TraceMsg(idx, "\tslice_data_offset = %d\n", p->slice_data_offset);
1149+ va_TraceMsg(idx, "\tslice_data_flag = %d\n", p->slice_data_flag);
1150+ va_TraceMsg(idx, "\tmacroblock_offset = %d\n", p->macroblock_offset);
1151+ va_TraceMsg(idx, "\tslice_vertical_position = %d\n", p->slice_vertical_position);
7501152 }
7511153
7521154 void va_TraceBeginPicture(
@@ -755,15 +1157,17 @@ void va_TraceBeginPicture(
7551157 VASurfaceID render_target
7561158 )
7571159 {
758- int i;
1160+ DPY2INDEX(dpy);
7591161
760- va_TraceMsg("\tcontext = 0x%08x\n", context);
761- va_TraceMsg("\t\trender_targets = 0x%08x\n", render_target);
1162+ TRACE_FUNCNAME(idx);
1163+
1164+ va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
1165+ va_TraceMsg(idx, "\trender_targets = 0x%08x\n", render_target);
7621166
763- trace_rendertarget = render_target; /* for surface data dump after vaEndPicture */
1167+ trace_context[idx].trace_rendertarget = render_target; /* for surface data dump after vaEndPicture */
7641168
765- trace_frame++;
766- trace_slice = 0;
1169+ trace_context[idx].trace_frame_no++;
1170+ trace_context[idx].trace_slice_no = 0;
7671171 }
7681172
7691173 static void va_TraceMPEG2Buf(
@@ -784,25 +1188,30 @@ static void va_TraceMPEG2Buf(
7841188 va_TraceVAIQMatrixBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
7851189 break;
7861190 case VABitPlaneBufferType:
1191+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
7871192 break;
7881193 case VASliceGroupMapBufferType:
1194+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
7891195 break;
7901196 case VASliceParameterBufferType:
791- trace_slice++;
7921197 va_TraceVASliceParameterBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
7931198 break;
7941199 case VASliceDataBufferType:
7951200 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
7961201 break;
7971202 case VAMacroblockParameterBufferType:
1203+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
7981204 break;
7991205 case VAResidualDataBufferType:
1206+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8001207 break;
8011208 case VADeblockingParameterBufferType:
1209+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8021210 break;
8031211 case VAImageBufferType:
8041212 break;
8051213 case VAProtectedSliceDataBufferType:
1214+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8061215 break;
8071216 case VAEncCodedBufferType:
8081217 break;
@@ -816,6 +1225,8 @@ static void va_TraceMPEG2Buf(
8161225 break;
8171226 case VAEncH264SEIBufferType:
8181227 break;
1228+ default:
1229+ break;
8191230 }
8201231 }
8211232
@@ -837,6 +1248,7 @@ static void va_TraceMPEG4Buf(
8371248 va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
8381249 break;
8391250 case VABitPlaneBufferType:
1251+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8401252 break;
8411253 case VASliceGroupMapBufferType:
8421254 break;
@@ -847,10 +1259,13 @@ static void va_TraceMPEG4Buf(
8471259 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8481260 break;
8491261 case VAMacroblockParameterBufferType:
1262+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8501263 break;
8511264 case VAResidualDataBufferType:
1265+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8521266 break;
8531267 case VADeblockingParameterBufferType:
1268+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8541269 break;
8551270 case VAImageBufferType:
8561271 break;
@@ -860,10 +1275,13 @@ static void va_TraceMPEG4Buf(
8601275 case VAEncCodedBufferType:
8611276 break;
8621277 case VAEncSequenceParameterBufferType:
1278+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8631279 break;
8641280 case VAEncPictureParameterBufferType:
1281+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8651282 break;
8661283 case VAEncSliceParameterBufferType:
1284+ va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
8671285 break;
8681286 case VAEncH264VUIBufferType:
8691287 break;
@@ -885,6 +1303,8 @@ static void va_TraceH264Buf(
8851303 void *pbuf
8861304 )
8871305 {
1306+ DPY2INDEX(dpy);
1307+
8881308 switch (type) {
8891309 case VAPictureParameterBufferType:
8901310 va_TraceVAPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
@@ -893,20 +1313,25 @@ static void va_TraceH264Buf(
8931313 va_TraceVAIQMatrixBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
8941314 break;
8951315 case VABitPlaneBufferType:
1316+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8961317 break;
8971318 case VASliceGroupMapBufferType:
1319+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
8981320 break;
8991321 case VASliceParameterBufferType:
9001322 va_TraceVASliceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
9011323 break;
9021324 case VASliceDataBufferType:
903- va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1325+ va_TraceVABuffers(dpy, context, buffer, type, trace_context[idx].trace_slice_size, num_elements, pbuf);
9041326 break;
9051327 case VAMacroblockParameterBufferType:
1328+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9061329 break;
9071330 case VAResidualDataBufferType:
1331+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9081332 break;
9091333 case VADeblockingParameterBufferType:
1334+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9101335 break;
9111336 case VAImageBufferType:
9121337 break;
@@ -916,14 +1341,22 @@ static void va_TraceH264Buf(
9161341 case VAEncCodedBufferType:
9171342 break;
9181343 case VAEncSequenceParameterBufferType:
1344+ va_TraceVAEncSequenceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
9191345 break;
9201346 case VAEncPictureParameterBufferType:
1347+ va_TraceVAEncPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
9211348 break;
9221349 case VAEncSliceParameterBufferType:
1350+ va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
9231351 break;
9241352 case VAEncH264VUIBufferType:
1353+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9251354 break;
9261355 case VAEncH264SEIBufferType:
1356+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1357+ break;
1358+ case VAEncMiscParameterBufferType:
1359+ va_TraceVAEncMiscParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
9271360 break;
9281361 default:
9291362 break;
@@ -941,6 +1374,8 @@ static void va_TraceVC1Buf(
9411374 void *pbuf
9421375 )
9431376 {
1377+ DPY2INDEX(dpy);
1378+
9441379 switch (type) {
9451380 case VAPictureParameterBufferType:
9461381 va_TraceVAPictureParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf);
@@ -951,18 +1386,22 @@ static void va_TraceVC1Buf(
9511386 va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9521387 break;
9531388 case VASliceGroupMapBufferType:
1389+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9541390 break;
9551391 case VASliceParameterBufferType:
9561392 va_TraceVASliceParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf);
9571393 break;
9581394 case VASliceDataBufferType:
959- va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1395+ va_TraceVABuffers(dpy, context, buffer, type, trace_context[idx].trace_slice_size, num_elements, pbuf);
9601396 break;
9611397 case VAMacroblockParameterBufferType:
1398+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9621399 break;
9631400 case VAResidualDataBufferType:
1401+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9641402 break;
9651403 case VADeblockingParameterBufferType:
1404+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9661405 break;
9671406 case VAImageBufferType:
9681407 break;
@@ -972,14 +1411,13 @@ static void va_TraceVC1Buf(
9721411 case VAEncCodedBufferType:
9731412 break;
9741413 case VAEncSequenceParameterBufferType:
1414+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9751415 break;
9761416 case VAEncPictureParameterBufferType:
1417+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9771418 break;
9781419 case VAEncSliceParameterBufferType:
979- break;
980- case VAEncH264VUIBufferType:
981- break;
982- case VAEncH264SEIBufferType:
1420+ va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
9831421 break;
9841422 default:
9851423 break;
@@ -997,44 +1435,74 @@ void va_TraceRenderPicture(
9971435 unsigned int size;
9981436 unsigned int num_elements;
9991437 int i;
1438+ DPY2INDEX(dpy);
10001439
1001- va_TraceMsg("\tcontext = 0x%08x\n", context);
1002- va_TraceMsg("\tnum_buffers = %d\n", num_buffers);
1440+ TRACE_FUNCNAME(idx);
1441+
1442+ va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
1443+ va_TraceMsg(idx, "\tnum_buffers = %d\n", num_buffers);
10031444 for (i = 0; i < num_buffers; i++) {
10041445 void *pbuf;
1005-
1446+ unsigned int j;
1447+
10061448 /* get buffer type information */
10071449 vaBufferInfo(dpy, context, buffers[i], &type, &size, &num_elements);
1008-
1009- va_TraceMsg("\t\tbuffers[%d] = 0x%08x\n", i, buffers[i]);
1010- va_TraceMsg("\t\t\ttype = %s\n", buffer_type_to_string(type));
1011- va_TraceMsg("\t\t\tsize = %d\n", size);
1012- va_TraceMsg("\t\t\tnum_elements = %d\n", num_elements);
10131450
1451+ va_TraceMsg(idx, "\t---------------------------\n");
1452+ va_TraceMsg(idx, "\tbuffers[%d] = 0x%08x\n", i, buffers[i]);
1453+ va_TraceMsg(idx, "\t type = %s\n", buffer_type_to_string(type));
1454+ va_TraceMsg(idx, "\t size = %d\n", size);
1455+ va_TraceMsg(idx, "\t num_elements = %d\n", num_elements);
10141456
10151457 vaMapBuffer(dpy, buffers[i], &pbuf);
10161458
1017- switch (trace_profile) {
1459+ switch (trace_context[idx].trace_profile) {
10181460 case VAProfileMPEG2Simple:
10191461 case VAProfileMPEG2Main:
1020- va_TraceMPEG2Buf(dpy, context, buffers[i], type, size, num_elements, pbuf);
1462+ for (j=0; j<num_elements; j++) {
1463+ va_TraceMsg(idx, "\t element[%d] = ", j);
1464+ va_TraceMsg(idx, "\t------------------", j);
1465+ va_TraceMPEG2Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
1466+ }
10211467 break;
10221468 case VAProfileMPEG4Simple:
10231469 case VAProfileMPEG4AdvancedSimple:
10241470 case VAProfileMPEG4Main:
1025- va_TraceMPEG4Buf(dpy, context, buffers[i], type, size, num_elements, pbuf);
1471+ for (j=0; j<num_elements; j++) {
1472+ va_TraceMsg(idx, "\t element[%d] = ", j);
1473+ va_TraceMsg(idx, "\t------------------", j);
1474+ va_TraceMPEG4Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
1475+ }
10261476 break;
10271477 case VAProfileH264Baseline:
10281478 case VAProfileH264Main:
10291479 case VAProfileH264High:
1030- va_TraceH264Buf(dpy, context, buffers[i], type, size, num_elements, pbuf);
1480+ for (j=0; j<num_elements; j++) {
1481+ va_TraceMsg(idx, "\t element[%d] = ", j);
1482+ va_TraceMsg(idx, "\t------------------", j);
1483+
1484+ va_TraceH264Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
1485+ }
10311486 break;
10321487 case VAProfileVC1Simple:
10331488 case VAProfileVC1Main:
10341489 case VAProfileVC1Advanced:
1035- va_TraceVC1Buf(dpy, context, buffers[i], type, size, num_elements, pbuf);
1490+ for (j=0; j<num_elements; j++) {
1491+ va_TraceMsg(idx, "\t element[%d] = ", j);
1492+ va_TraceMsg(idx, "\t------------------", j);
1493+
1494+ va_TraceVC1Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
1495+ }
10361496 break;
10371497 case VAProfileH263Baseline:
1498+ for (j=0; j<num_elements; j++) {
1499+ va_TraceMsg(idx, "\t element[%d] = ", j);
1500+ va_TraceMsg(idx, "\t------------------", j);
1501+
1502+ va_TraceMPEG4Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
1503+ }
1504+ break;
1505+ default:
10381506 break;
10391507 }
10401508
@@ -1048,80 +1516,149 @@ void va_TraceEndPicture(
10481516 VAContextID context
10491517 )
10501518 {
1051- int i, j;
1052- unsigned int fourcc; /* following are output argument */
1053- unsigned int luma_stride;
1054- unsigned int chroma_u_stride;
1055- unsigned int chroma_v_stride;
1056- unsigned int luma_offset;
1057- unsigned int chroma_u_offset;
1058- unsigned int chroma_v_offset;
1059- unsigned int buffer_name;
1060- void *buffer;
1061- char *Y_data, *UV_data, *tmp;
1062-
1063- VAStatus va_status;
1064-
1065- va_TraceMsg("\tcontext = 0x%08x\n", context);
1066- va_TraceMsg("\t\trender_targets = 0x%08x\n", trace_rendertarget);
1519+ DPY2INDEX(dpy);
1520+
1521+ TRACE_FUNCNAME(idx);
10671522
1068- /* force the pipleline finish rendering */
1069- vaSyncSurface(dpy, trace_rendertarget);
1523+ va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
1524+ va_TraceMsg(idx, "\trender_targets = 0x%08x\n", trace_context[idx].trace_rendertarget);
10701525
1071- va_TraceMsg("***dump surface data***\n", trace_rendertarget);
10721526
1073- va_status = vaLockSurface(dpy, trace_rendertarget, &fourcc, &luma_stride, &chroma_u_stride, &chroma_v_stride,
1074- &luma_offset, &chroma_u_offset, &chroma_v_offset, &buffer_name, &buffer);
1527+ /* want to trace codedbuf, and it is encode */
1528+ if (trace_context[idx].trace_fp_codedbuf &&
1529+ ((trace_context[idx].trace_entrypoint == VAEntrypointEncSlice) ||
1530+ (trace_context[idx].trace_entrypoint == VAEntrypointEncPicture))) {
1531+ /* force the pipleline finish rendering */
1532+ vaSyncSurface(dpy, trace_context[idx].trace_rendertarget);
1533+ va_TraceCodedBuf(dpy);
1534+ }
10751535
1076- if (va_status != VA_STATUS_SUCCESS)
1077- return;
1078-
1079- va_TraceMsg("\tfourcc=0x%08x\n", fourcc);
1080- va_TraceMsg("\twidth=%d\n", trace_width);
1081- va_TraceMsg("\theight=%d\n", trace_height);
1082- va_TraceMsg("\tluma_stride=%d\n", luma_stride);
1083- va_TraceMsg("\tchroma_u_stride=%d\n", chroma_u_stride);
1084- va_TraceMsg("\tchroma_v_stride=%d\n", chroma_v_stride);
1085- va_TraceMsg("\tluma_offset=%d\n", luma_offset);
1086- va_TraceMsg("\tchroma_u_offset=%d\n", chroma_u_offset);
1087- va_TraceMsg("\tchroma_v_offset=%d\n", chroma_v_offset);
1088-
1089- if (!buffer) {
1090- vaUnlockSurface(dpy, trace_rendertarget);
1091- return;
1536+ /* trace decoded surface for decoding, or the source sourface for encoding */
1537+ if (trace_context[idx].trace_fp_surface) {
1538+ /* force the pipleline finish rendering */
1539+ vaSyncSurface(dpy, trace_context[idx].trace_rendertarget);
1540+
1541+ va_TraceSurface(dpy);
10921542 }
1543+}
10931544
1094- Y_data = buffer;
1095- UV_data = buffer + luma_offset;
10961545
1097- tmp = Y_data;
1098- va_TraceMsg("**Y data**\n");
1099- for (i=0; i<trace_height; i++) {
1100- for (j=0; j<trace_width; j++) {
1101- if ((j%16) == 0)
1102- va_TraceMsg("\n0x%08x:", j + i*trace_width);
1103- va_TraceMsg(" %02x", tmp[j]);
1104- }
1546+void va_TraceMaxNumDisplayAttributes (
1547+ VADisplay dpy,
1548+ int number
1549+)
1550+{
1551+ DPY2INDEX(dpy);
11051552
1106- va_TraceMsg("\n");
1107- tmp = Y_data + i * luma_stride;
1553+ TRACE_FUNCNAME(idx);
1554+
1555+ va_TraceMsg(idx, "\t>max_display_attributes = %d\n", number);
1556+}
1557+
1558+void va_TraceQueryDisplayAttributes (
1559+ VADisplay dpy,
1560+ VADisplayAttribute *attr_list, /* out */
1561+ int *num_attributes /* out */
1562+)
1563+{
1564+ int i;
1565+
1566+ DPY2INDEX(dpy);
1567+
1568+ va_TraceMsg(idx, "\tnum_attributes = %d\n", *num_attributes);
1569+
1570+ for (i=0; i<*num_attributes; i++) {
1571+ va_TraceMsg(idx, "\tattr_list[%d] =\n");
1572+ va_TraceMsg(idx, "\t typ = 0x%08x\n", attr_list[i].type);
1573+ va_TraceMsg(idx, "\t min_value = %d\n", attr_list[i].min_value);
1574+ va_TraceMsg(idx, "\t max_value = %d\n", attr_list[i].max_value);
1575+ va_TraceMsg(idx, "\t value = %d\n", attr_list[i].value);
1576+ va_TraceMsg(idx, "\t flags = %d\n", attr_list[i].flags);
11081577 }
1578+}
11091579
1110- tmp = UV_data;
1111- if (fourcc == VA_FOURCC_NV12) {
1112- va_TraceMsg("**UV data**\n");
1113-
1114- for (i=0; i<trace_height/2; i++) {
1115- for (j=0; j<trace_width; j++) {
1116- if ((j%16) == 0)
1117- va_TraceMsg("\n0x%08x:", j + i*trace_width);
1118- va_TraceMsg(" %02x", tmp[j]);
1119- }
11201580
1121- va_TraceMsg("\n");
1122- tmp = UV_data + i * chroma_u_stride;
1123- }
1581+static void va_TraceDisplayAttributes (
1582+ VADisplay dpy,
1583+ VADisplayAttribute *attr_list,
1584+ int num_attributes
1585+)
1586+{
1587+ int i;
1588+
1589+ DPY2INDEX(dpy);
1590+
1591+ va_TraceMsg(idx, "\tnum_attributes = %d\n", num_attributes);
1592+ for (i=0; i<num_attributes; i++) {
1593+ va_TraceMsg(idx, "\tattr_list[%d] =\n");
1594+ va_TraceMsg(idx, "\t typ = 0x%08x\n", attr_list[i].type);
1595+ va_TraceMsg(idx, "\t min_value = %d\n", attr_list[i].min_value);
1596+ va_TraceMsg(idx, "\t max_value = %d\n", attr_list[i].max_value);
1597+ va_TraceMsg(idx, "\t value = %d\n", attr_list[i].value);
1598+ va_TraceMsg(idx, "\t flags = %d\n", attr_list[i].flags);
11241599 }
1600+}
1601+
1602+
1603+void va_TraceGetDisplayAttributes (
1604+ VADisplay dpy,
1605+ VADisplayAttribute *attr_list,
1606+ int num_attributes
1607+)
1608+{
1609+ DPY2INDEX(dpy);
11251610
1126- vaUnlockSurface(dpy, trace_rendertarget);
1611+ TRACE_FUNCNAME(idx);
1612+
1613+ va_TraceDisplayAttributes (dpy, attr_list, num_attributes);
1614+}
1615+
1616+void va_TraceSetDisplayAttributes (
1617+ VADisplay dpy,
1618+ VADisplayAttribute *attr_list,
1619+ int num_attributes
1620+)
1621+{
1622+ DPY2INDEX(dpy);
1623+
1624+ TRACE_FUNCNAME(idx);
1625+
1626+ va_TraceDisplayAttributes (dpy, attr_list, num_attributes);
1627+}
1628+
1629+
1630+void va_TracePutSurface (
1631+ VADisplay dpy,
1632+ VASurfaceID surface,
1633+ void *draw, /* the target Drawable */
1634+ short srcx,
1635+ short srcy,
1636+ unsigned short srcw,
1637+ unsigned short srch,
1638+ short destx,
1639+ short desty,
1640+ unsigned short destw,
1641+ unsigned short desth,
1642+ VARectangle *cliprects, /* client supplied clip list */
1643+ unsigned int number_cliprects, /* number of clip rects in the clip list */
1644+ unsigned int flags /* de-interlacing flags */
1645+)
1646+{
1647+ DPY2INDEX(dpy);
1648+
1649+ TRACE_FUNCNAME(idx);
1650+
1651+ va_TraceMsg(idx, "\tsurface = 0x%08x\n", surface);
1652+ va_TraceMsg(idx, "\tdraw = 0x%08x\n", draw);
1653+ va_TraceMsg(idx, "\tsrcx = %d\n", surface);
1654+ va_TraceMsg(idx, "\tsrcy = %d\n", surface);
1655+ va_TraceMsg(idx, "\tsrcw = %d\n", surface);
1656+ va_TraceMsg(idx, "\tsrch = %d\n", surface);
1657+ va_TraceMsg(idx, "\tdestx = %d\n", surface);
1658+ va_TraceMsg(idx, "\tdesty = %d\n", surface);
1659+ va_TraceMsg(idx, "\tdestw = %d\n", destw);
1660+ va_TraceMsg(idx, "\tdesth = %d\n", desth);
1661+ va_TraceMsg(idx, "\tcliprects = 0x%08x\n", cliprects);
1662+ va_TraceMsg(idx, "\tnumber_cliprects = %d\n", number_cliprects);
1663+ va_TraceMsg(idx, "\tflags = 0x%08x\n", flags);
11271664 }
--- a/va/va_trace.h
+++ b/va/va_trace.h
@@ -25,10 +25,10 @@
2525 #ifndef VA_TRACE_H
2626 #define VA_TRACE_H
2727
28-void va_TraceInit(void);
29-void va_TraceEnd(void);
28+void va_TraceInit(VADisplay dpy);
29+void va_TraceEnd(VADisplay dpy);
3030
31-void va_TraceMsg(const char *msg, ...);
31+void va_TraceMsg(int idx, const char *msg, ...);
3232
3333 void va_TraceCreateConfig(
3434 VADisplay dpy,
@@ -59,6 +59,14 @@ void va_TraceCreateContext(
5959 VAContextID *context /* out */
6060 );
6161
62+
63+void va_TraceMapBuffer (
64+ VADisplay dpy,
65+ VABufferID buf_id, /* in */
66+ void **pbuf /* out */
67+);
68+
69+
6270 void va_TraceBeginPicture(
6371 VADisplay dpy,
6472 VAContextID context,
@@ -77,4 +85,48 @@ void va_TraceEndPicture(
7785 VAContextID context
7886 );
7987
88+
89+void va_TraceMaxNumDisplayAttributes (
90+ VADisplay dpy,
91+ int number
92+);
93+
94+void va_TraceQueryDisplayAttributes (
95+ VADisplay dpy,
96+ VADisplayAttribute *attr_list, /* out */
97+ int *num_attributes /* out */
98+);
99+
100+void va_TraceGetDisplayAttributes (
101+ VADisplay dpy,
102+ VADisplayAttribute *attr_list,
103+ int num_attributes
104+);
105+
106+void va_TraceSetDisplayAttributes (
107+ VADisplay dpy,
108+ VADisplayAttribute *attr_list,
109+ int num_attributes
110+);
111+
112+/* extern function called by display side */
113+void va_TracePutSurface (
114+ VADisplay dpy,
115+ VASurfaceID surface,
116+ void *draw, /* the target Drawable */
117+ short srcx,
118+ short srcy,
119+ unsigned short srcw,
120+ unsigned short srch,
121+ short destx,
122+ short desty,
123+ unsigned short destw,
124+ unsigned short desth,
125+ VARectangle *cliprects, /* client supplied clip list */
126+ unsigned int number_cliprects, /* number of clip rects in the clip list */
127+ unsigned int flags /* de-interlacing flags */
128+);
129+
130+
131+
80132 #endif /* VA_TRACE_H */
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -231,6 +231,31 @@ VADisplay vaGetDisplay (
231231 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
232232 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
233233
234+extern int fool_postp; /* do nothing for vaPutSurface if set */
235+extern int trace_flag; /* trace vaPutSurface parameters */
236+#define VA_TRACE(trace_func,...) \
237+ if (trace_flag) { \
238+ trace_func(__VA_ARGS__); \
239+ }
240+
241+void va_TracePutSurface (
242+ VADisplay dpy,
243+ VASurfaceID surface,
244+ void *draw, /* the target Drawable */
245+ short srcx,
246+ short srcy,
247+ unsigned short srcw,
248+ unsigned short srch,
249+ short destx,
250+ short desty,
251+ unsigned short destw,
252+ unsigned short desth,
253+ VARectangle *cliprects, /* client supplied clip list */
254+ unsigned int number_cliprects, /* number of clip rects in the clip list */
255+ unsigned int flags /* de-interlacing flags */
256+);
257+
258+
234259 VAStatus vaPutSurface (
235260 VADisplay dpy,
236261 VASurfaceID surface,
@@ -250,9 +275,16 @@ VAStatus vaPutSurface (
250275 {
251276 VADriverContextP ctx;
252277
278+ if (fool_postp)
279+ return VA_STATUS_SUCCESS;
280+
253281 CHECK_DISPLAY(dpy);
254282 ctx = CTX(dpy);
255-
283+
284+ VA_TRACE(va_TracePutSurface, dpy, surface, (void *)draw, srcx, srcy, srcw, srch,
285+ destx, desty, destw, desth,
286+ cliprects, number_cliprects, flags );
287+
256288 return ctx->vtable.vaPutSurface( ctx, surface, (void *)draw, srcx, srcy, srcw, srch,
257289 destx, desty, destw, desth,
258290 cliprects, number_cliprects, flags );