OSDN Git Service

17bf1134e31f7ee5146ebf352602a0c4fe1c68c2
[android-x86/hardware-intel-common-libva.git] / va / va_trace.c
1
2 /*
3  * Copyright (c) 2009-2011 Intel Corporation. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  * 
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  * 
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26 #define _GNU_SOURCE 1
27 #include "va.h"
28 #include "va_enc_h264.h"
29 #include "va_backend.h"
30 #include "va_trace.h"
31 #include "va_enc_h264.h"
32 #include "va_dec_jpeg.h"
33 #include <assert.h>
34 #include <stdarg.h>
35 #include <stdlib.h>
36 #include <stdio.h>
37 #include <string.h>
38 #include <dlfcn.h>
39 #include <unistd.h>
40 #include <sys/types.h>
41 #include <sys/stat.h>
42 #include <unistd.h>
43 #include <time.h>
44 #include <errno.h>
45
46 /*
47  * Env. to debug some issue, e.g. the decode/encode issue in a video conference scenerio:
48  * .LIBVA_TRACE=log_file: general VA parameters saved into log_file
49  * .LIBVA_TRACE_BUFDATA: dump all VA data buffer into log_file
50  * .LIBVA_TRACE_CODEDBUF=coded_clip_file: save the coded clip into file coded_clip_file
51  * .LIBVA_TRACE_SURFACE=yuv_file: save surface YUV into file yuv_file. Use file name to determine
52  *                                decode/encode or jpeg surfaces
53  * .LIBVA_TRACE_SURFACE_GEOMETRY=WIDTHxHEIGHT+XOFF+YOFF: only save part of surface context into file
54  *                                due to storage bandwidth limitation
55  * .LIBVA_TRACE_LOGSIZE=numeric number: truncate the log_file or coded_clip_file, or decoded_yuv_file
56  *                                      when the size is bigger than the number
57  */
58
59 /* global settings */
60
61 /* LIBVA_TRACE */
62 int trace_flag = 0;
63
64 /* LIBVA_TRACE_LOGSIZE */
65 static unsigned int trace_logsize = 0xffffffff; /* truncate the log when the size is bigger than it */
66
67 /* per context settings */
68 struct trace_context {
69     /* LIBVA_TRACE */
70     FILE *trace_fp_log; /* save the log into a file */
71     char *trace_log_fn; /* file name */
72     
73     /* LIBVA_TRACE_CODEDBUF */
74     FILE *trace_fp_codedbuf; /* save the encode result into a file */
75     char *trace_codedbuf_fn; /* file name */
76     
77     /* LIBVA_TRACE_SURFACE */
78     FILE *trace_fp_surface; /* save the surface YUV into a file */
79     char *trace_surface_fn; /* file name */
80
81     VAContextID  trace_context; /* current context */
82     
83     VASurfaceID  trace_rendertarget; /* current render target */
84     VAProfile trace_profile; /* current profile for buffers */
85     VAEntrypoint trace_entrypoint; /* current entrypoint */
86     VABufferID trace_codedbuf;
87     
88     unsigned int trace_frame_no; /* current frame NO */
89     unsigned int trace_slice_no; /* current slice NO */
90     unsigned int trace_slice_size; /* current slice buffer size */
91
92     unsigned int trace_surface_width; /* surface dumping geometry */
93     unsigned int trace_surface_height;
94     unsigned int trace_surface_xoff;
95     unsigned int trace_surface_yoff;
96
97     unsigned int trace_frame_width; /* current frame width */
98     unsigned int trace_frame_height; /* current frame height */
99     unsigned int trace_sequence_start; /* get a new sequence for encoding or not */
100 };
101
102 #define TRACE_CTX(dpy) ((struct trace_context *)((VADisplayContextP)dpy)->vatrace)
103
104 #define DPY2TRACECTX(dpy)                               \
105     struct trace_context *trace_ctx = TRACE_CTX(dpy);   \
106                                                         \
107     if (trace_ctx == NULL)                              \
108         return;                                         \
109
110 #define TRACE_FUNCNAME(idx)    va_TraceMsg(trace_ctx, "==========%s\n", __func__); 
111
112 /* Prototype declarations (functions defined in va.c) */
113
114 void va_errorMessage(const char *msg, ...);
115 void va_infoMessage(const char *msg, ...);
116
117 int va_parseConfig(char *env, char *env_value);
118
119 VAStatus vaBufferInfo(
120     VADisplay dpy,
121     VAContextID context,        /* in */
122     VABufferID buf_id,          /* in */
123     VABufferType *type,         /* out */
124     unsigned int *size,         /* out */
125     unsigned int *num_elements  /* out */
126     );
127
128 VAStatus vaLockSurface(VADisplay dpy,
129                        VASurfaceID surface,
130                        unsigned int *fourcc, /* following are output argument */
131                        unsigned int *luma_stride,
132                        unsigned int *chroma_u_stride,
133                        unsigned int *chroma_v_stride,
134                        unsigned int *luma_offset,
135                        unsigned int *chroma_u_offset,
136                        unsigned int *chroma_v_offset,
137                        unsigned int *buffer_name,
138                        void **buffer 
139                        );
140
141 VAStatus vaUnlockSurface(VADisplay dpy,
142                          VASurfaceID surface
143                          );
144
145 #define FILE_NAME_SUFFIX(env_value)                      \
146 do {                                                    \
147     int tmp = strnlen(env_value, sizeof(env_value));    \
148     int left = sizeof(env_value) - tmp;                 \
149                                                         \
150     snprintf(env_value+tmp,                             \
151              left,                                      \
152              ".%04d.%08lx",                             \
153              suffix,                                    \
154              (unsigned long)trace_ctx);                 \
155 } while (0)
156
157 void va_TraceInit(VADisplay dpy)
158 {
159     char env_value[1024];
160     unsigned short suffix = 0xffff & ((unsigned int)time(NULL));
161     int trace_index = 0;
162     FILE *tmp;    
163     struct trace_context *trace_ctx = calloc(sizeof(struct trace_context), 1);
164
165     if (trace_ctx == NULL)
166         return;
167     
168     if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
169         FILE_NAME_SUFFIX(env_value);
170         trace_ctx->trace_log_fn = strdup(env_value);
171         
172         tmp = fopen(env_value, "w");
173         if (tmp) {
174             trace_ctx->trace_fp_log = tmp;
175             va_infoMessage("LIBVA_TRACE is on, save log into %s\n", trace_ctx->trace_log_fn);
176             trace_flag = VA_TRACE_FLAG_LOG;
177         } else
178             va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
179     }
180
181     /* may re-get the global settings for multiple context */
182     if (va_parseConfig("LIBVA_TRACE_LOGSIZE", &env_value[0]) == 0) {
183         trace_logsize = atoi(env_value);
184         va_infoMessage("LIBVA_TRACE_LOGSIZE is on, size is %d\n", trace_logsize);
185     }
186
187     if ((trace_flag & VA_TRACE_FLAG_LOG) && (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0)) {
188         trace_flag |= VA_TRACE_FLAG_BUFDATA;
189         va_infoMessage("LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n");
190     }
191
192     /* per-context setting */
193     if (va_parseConfig("LIBVA_TRACE_CODEDBUF", &env_value[0]) == 0) {
194         FILE_NAME_SUFFIX(env_value);
195         trace_ctx->trace_codedbuf_fn = strdup(env_value);
196         va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save codedbuf into log file %s\n",
197                        trace_ctx->trace_codedbuf_fn);
198         trace_flag |= VA_TRACE_FLAG_CODEDBUF;
199     }
200
201     if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) {
202         FILE_NAME_SUFFIX(env_value);
203         trace_ctx->trace_surface_fn = strdup(env_value);
204
205         va_infoMessage("LIBVA_TRACE_SURFACE is on, save surface into %s\n",
206                        trace_ctx->trace_surface_fn);
207
208         /* for surface data dump, it is time-consume, and may
209          * cause some side-effect, so only trace the needed surfaces
210          * to trace encode surface, set the trace file name to sth like *enc*
211          * to trace decode surface, set the trace file name to sth like *dec*
212          * if no dec/enc in file name, set both
213          */
214         if (strstr(env_value, "dec"))
215             trace_flag |= VA_TRACE_FLAG_SURFACE_DECODE;
216         if (strstr(env_value, "enc"))
217             trace_flag |= VA_TRACE_FLAG_SURFACE_ENCODE;
218         if (strstr(env_value, "jpeg") || strstr(env_value, "jpg"))
219             trace_flag |= VA_TRACE_FLAG_SURFACE_JPEG;
220
221         if (va_parseConfig("LIBVA_TRACE_SURFACE_GEOMETRY", &env_value[0]) == 0) {
222             char *p = env_value, *q;
223
224             trace_ctx->trace_surface_width = strtod(p, &q);
225             p = q+1; /* skip "x" */
226             trace_ctx->trace_surface_height = strtod(p, &q);
227             p = q+1; /* skip "+" */
228             trace_ctx->trace_surface_xoff = strtod(p, &q);
229             p = q+1; /* skip "+" */
230             trace_ctx->trace_surface_yoff = strtod(p, &q);
231
232             va_infoMessage("LIBVA_TRACE_SURFACE_GEOMETRY is on, only dump surface %dx%d+%d+%d content\n",
233                            trace_ctx->trace_surface_width,
234                            trace_ctx->trace_surface_height,
235                            trace_ctx->trace_surface_xoff,
236                            trace_ctx->trace_surface_yoff);
237         }
238     }
239
240     ((VADisplayContextP)dpy)->vatrace = trace_ctx;
241 }
242
243
244 void va_TraceEnd(VADisplay dpy)
245 {
246     DPY2TRACECTX(dpy);
247     
248     if (trace_ctx->trace_fp_log)
249         fclose(trace_ctx->trace_fp_log);
250     
251     if (trace_ctx->trace_fp_codedbuf)
252         fclose(trace_ctx->trace_fp_codedbuf);
253     
254     if (trace_ctx->trace_fp_surface)
255         fclose(trace_ctx->trace_fp_surface);
256
257     if (trace_ctx->trace_log_fn)
258         free(trace_ctx->trace_log_fn);
259     
260     if (trace_ctx->trace_codedbuf_fn)
261         free(trace_ctx->trace_codedbuf_fn);
262     
263     if (trace_ctx->trace_surface_fn)
264         free(trace_ctx->trace_surface_fn);
265     
266     free(trace_ctx);
267     ((VADisplayContextP)dpy)->vatrace = NULL;
268 }
269
270
271 static unsigned int file_size(FILE *fp)
272 {
273     struct stat buf;
274
275     fstat(fileno(fp), &buf);
276
277     return buf.st_size;
278 }
279
280
281 static void truncate_file(FILE *fp)
282 {
283     ftruncate(fileno(fp), 0);
284     rewind(fp);
285 }
286
287 void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
288 {
289     va_list args;
290
291     if (!(trace_flag & VA_TRACE_FLAG_LOG))
292         return;
293
294     if (file_size(trace_ctx->trace_fp_log) >= trace_logsize)
295         truncate_file(trace_ctx->trace_fp_log);
296     if (msg)  {
297         struct timeval tv;
298
299         if (gettimeofday(&tv, NULL) == 0)
300             fprintf(trace_ctx->trace_fp_log, "[%04d:%06d] ",
301                     (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec);
302         va_start(args, msg);
303         vfprintf(trace_ctx->trace_fp_log, msg, args);
304         va_end(args);
305     } else
306         fflush(trace_ctx->trace_fp_log);
307 }
308
309 void va_TraceCodedBuf(VADisplay dpy)
310 {
311     VACodedBufferSegment *buf_list = NULL;
312     VAStatus va_status;
313     int i = 0;
314     
315     DPY2TRACECTX(dpy);
316     
317     /* can only truncate at a sequence boudary */
318     if (((file_size(trace_ctx->trace_fp_log) >= trace_logsize))
319         && trace_ctx->trace_sequence_start) {
320         va_TraceMsg(trace_ctx, "==========truncate file %s\n", trace_ctx->trace_codedbuf_fn);
321         truncate_file(trace_ctx->trace_fp_log);
322     }
323
324     trace_ctx->trace_sequence_start = 0; /* only truncate coded file when meet next new sequence */
325     
326     va_status = vaMapBuffer(dpy, trace_ctx->trace_codedbuf, (void **)(&buf_list));
327     if (va_status != VA_STATUS_SUCCESS)
328         return;
329
330     va_TraceMsg(trace_ctx, "==========dump codedbuf into file %s\n", trace_ctx->trace_codedbuf_fn);
331     
332     while (buf_list != NULL) {
333         va_TraceMsg(trace_ctx, "\tVACodedBufferSegment[%d].size = %d\n", i++, buf_list->size);
334         if (trace_ctx->trace_fp_codedbuf)
335             fwrite(buf_list->buf, buf_list->size, 1, trace_ctx->trace_fp_codedbuf);
336         buf_list = buf_list->next;
337     }
338     vaUnmapBuffer(dpy,trace_ctx->trace_codedbuf);
339     va_TraceMsg(trace_ctx, NULL);
340 }
341
342
343 void va_TraceSurface(VADisplay dpy)
344 {
345     unsigned int i, j;
346     unsigned int fourcc; /* following are output argument */
347     unsigned int luma_stride;
348     unsigned int chroma_u_stride;
349     unsigned int chroma_v_stride;
350     unsigned int luma_offset;
351     unsigned int chroma_u_offset;
352     unsigned int chroma_v_offset;
353     unsigned int buffer_name;
354     void *buffer = NULL;
355     unsigned char *Y_data, *UV_data, *tmp;
356     VAStatus va_status;
357     unsigned char check_sum = 0;
358     DPY2TRACECTX(dpy);
359
360     if (!trace_ctx->trace_fp_surface)
361         return;
362
363     va_TraceMsg(trace_ctx, "==========dump surface data in file %s\n", trace_ctx->trace_surface_fn);
364
365     if ((file_size(trace_ctx->trace_fp_surface) >= trace_logsize)) {
366         va_TraceMsg(trace_ctx, "==========truncate file %s\n", trace_ctx->trace_surface_fn);
367         truncate_file(trace_ctx->trace_fp_surface);
368     }
369     va_TraceMsg(trace_ctx, NULL);
370
371     va_status = vaLockSurface(
372         dpy,
373         trace_ctx->trace_rendertarget,
374         &fourcc,
375         &luma_stride, &chroma_u_stride, &chroma_v_stride,
376         &luma_offset, &chroma_u_offset, &chroma_v_offset,
377         &buffer_name, &buffer);
378
379     if (va_status != VA_STATUS_SUCCESS) {
380         va_TraceMsg(trace_ctx, "Error:vaLockSurface failed\n");
381         return;
382     }
383
384     va_TraceMsg(trace_ctx, "\tfourcc = 0x%08x\n", fourcc);
385     va_TraceMsg(trace_ctx, "\twidth = %d\n", trace_ctx->trace_frame_width);
386     va_TraceMsg(trace_ctx, "\theight = %d\n", trace_ctx->trace_frame_height);
387     va_TraceMsg(trace_ctx, "\tluma_stride = %d\n", luma_stride);
388     va_TraceMsg(trace_ctx, "\tchroma_u_stride = %d\n", chroma_u_stride);
389     va_TraceMsg(trace_ctx, "\tchroma_v_stride = %d\n", chroma_v_stride);
390     va_TraceMsg(trace_ctx, "\tluma_offset = %d\n", luma_offset);
391     va_TraceMsg(trace_ctx, "\tchroma_u_offset = %d\n", chroma_u_offset);
392     va_TraceMsg(trace_ctx, "\tchroma_v_offset = %d\n", chroma_v_offset);
393
394     if (buffer == NULL) {
395         va_TraceMsg(trace_ctx, "Error:vaLockSurface return NULL buffer\n");
396         va_TraceMsg(trace_ctx, NULL);
397
398         vaUnlockSurface(dpy, trace_ctx->trace_rendertarget);
399         return;
400     }
401     va_TraceMsg(trace_ctx, "\tbuffer location = 0x%08x\n", buffer);
402     va_TraceMsg(trace_ctx, NULL);
403
404     Y_data = (unsigned char*)buffer;
405     UV_data = (unsigned char*)buffer + chroma_u_offset;
406
407     tmp = Y_data + luma_stride * trace_ctx->trace_surface_yoff;
408     for (i=0; i<trace_ctx->trace_surface_height; i++) {
409         fwrite(tmp + trace_ctx->trace_surface_xoff,
410                trace_ctx->trace_surface_width,
411                1, trace_ctx->trace_fp_surface);
412         
413         tmp += luma_stride;
414     }
415     tmp = UV_data + chroma_u_stride * trace_ctx->trace_surface_yoff;
416     if (fourcc == VA_FOURCC_NV12) {
417         for (i=0; i<trace_ctx->trace_surface_height/2; i++) {
418             fwrite(tmp + trace_ctx->trace_surface_xoff,
419                    trace_ctx->trace_surface_width,
420                    1, trace_ctx->trace_fp_surface);
421             
422             tmp += chroma_u_stride;
423         }
424     }
425
426     vaUnlockSurface(dpy, trace_ctx->trace_rendertarget);
427
428     va_TraceMsg(trace_ctx, NULL);
429 }
430
431
432 void va_TraceInitialize (
433     VADisplay dpy,
434     int *major_version,     /* out */
435     int *minor_version      /* out */
436 )
437 {
438     DPY2TRACECTX(dpy);    
439     TRACE_FUNCNAME(idx);
440 }
441
442 void va_TraceTerminate (
443     VADisplay dpy
444 )
445 {
446     DPY2TRACECTX(dpy);    
447     TRACE_FUNCNAME(idx);
448 }
449
450
451 void va_TraceCreateConfig(
452     VADisplay dpy,
453     VAProfile profile, 
454     VAEntrypoint entrypoint, 
455     VAConfigAttrib *attrib_list,
456     int num_attribs,
457     VAConfigID *config_id /* out */
458 )
459 {
460     int i;
461     int encode, decode, jpeg;
462     DPY2TRACECTX(dpy);
463
464     TRACE_FUNCNAME(idx);
465     
466     va_TraceMsg(trace_ctx, "\tprofile = %d\n", profile);
467     va_TraceMsg(trace_ctx, "\tentrypoint = %d\n", entrypoint);
468     va_TraceMsg(trace_ctx, "\tnum_attribs = %d\n", num_attribs);
469     if (attrib_list) {
470         for (i = 0; i < num_attribs; i++) {
471             va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type);
472             va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value);
473         }
474     }
475     va_TraceMsg(trace_ctx, NULL);
476
477     trace_ctx->trace_profile = profile;
478     trace_ctx->trace_entrypoint = entrypoint;
479
480     /* avoid to create so many empty files */
481     encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice);
482     decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD);
483     jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture);
484     if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE)) ||
485         (decode && (trace_flag & VA_TRACE_FLAG_SURFACE_DECODE)) ||
486         (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) {
487         FILE *tmp = fopen(trace_ctx->trace_surface_fn, "w");
488         
489         if (tmp)
490             trace_ctx->trace_fp_surface = tmp;
491         else {
492             va_errorMessage("Open file %s failed (%s)\n",
493                             trace_ctx->trace_surface_fn,
494                             strerror(errno));
495             trace_ctx->trace_fp_surface = NULL;
496             trace_flag &= ~(VA_TRACE_FLAG_SURFACE);
497         }
498     }
499
500     if (encode && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) {
501         FILE *tmp = fopen(trace_ctx->trace_codedbuf_fn, "w");
502         
503         if (tmp)
504             trace_ctx->trace_fp_codedbuf = tmp;
505         else {
506             va_errorMessage("Open file %s failed (%s)\n",
507                             trace_ctx->trace_codedbuf_fn,
508                             strerror(errno));
509             trace_ctx->trace_fp_codedbuf = NULL;
510             trace_flag &= ~VA_TRACE_FLAG_CODEDBUF;
511         }
512     }
513 }
514
515 static void va_TraceSurfaceAttributes(
516     struct trace_context *trace_ctx,
517     VASurfaceAttrib    *attrib_list,
518     unsigned int       *num_attribs
519 )
520 {
521     int i, num;
522     VASurfaceAttrib *p;
523     
524     if (!attrib_list || !num_attribs)
525         return;
526     
527     p = attrib_list;
528     num = *num_attribs;
529     if (num > VASurfaceAttribCount)
530         num = VASurfaceAttribCount;
531
532     for (i=0; i<num; i++) {
533         va_TraceMsg(trace_ctx, "\tattrib_list[%i] =\n", i);
534         
535         va_TraceMsg(trace_ctx, "\t\ttype = %d\n", p->type);
536         va_TraceMsg(trace_ctx, "\t\tflags = %d\n", p->flags);
537         va_TraceMsg(trace_ctx, "\t\tvalue.type = %d\n", p->value.type);
538         if (p->value.type == VAGenericValueTypeInteger)
539             va_TraceMsg(trace_ctx, "\t\tvalue.value.i = 0x%08x\n", p->value.value.i);
540         else if (p->value.type == VAGenericValueTypeFloat)
541         va_TraceMsg(trace_ctx, "\t\tvalue.value.f = %f\n", p->value.value.f);
542         else if (p->value.type == VAGenericValueTypePointer)
543             va_TraceMsg(trace_ctx, "\t\tvalue.value.p = %p\n", p->value.value.p);
544         else if (p->value.type == VAGenericValueTypeFunc)
545             va_TraceMsg(trace_ctx, "\t\tvalue.value.fn = %p\n", p->value.value.fn);
546
547         p++;
548     }
549 }
550
551 void va_TraceCreateSurfaces(
552     VADisplay dpy,
553     int width,
554     int height,
555     int format,
556     int num_surfaces,
557     VASurfaceID *surfaces,    /* out */
558     VASurfaceAttrib    *attrib_list,
559     unsigned int        num_attribs
560 )
561 {
562     int i;
563     DPY2TRACECTX(dpy);
564
565     TRACE_FUNCNAME(idx);
566     
567     va_TraceMsg(trace_ctx, "\twidth = %d\n", width);
568     va_TraceMsg(trace_ctx, "\theight = %d\n", height);
569     va_TraceMsg(trace_ctx, "\tformat = %d\n", format);
570     va_TraceMsg(trace_ctx, "\tnum_surfaces = %d\n", num_surfaces);
571
572     if (surfaces) {
573         for (i = 0; i < num_surfaces; i++)
574             va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]);
575     }
576     
577     va_TraceSurfaceAttributes(trace_ctx, attrib_list, &num_attribs);
578
579     va_TraceMsg(trace_ctx, NULL);
580 }
581
582
583 void va_TraceDestroySurfaces(
584     VADisplay dpy,
585     VASurfaceID *surface_list,
586     int num_surfaces
587 )
588 {
589     int i;
590     DPY2TRACECTX(dpy);
591
592     TRACE_FUNCNAME(idx);
593
594     if (surface_list) {
595         for (i = 0; i < num_surfaces; i++)
596             va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surface_list[i]);
597     }
598     
599     va_TraceMsg(trace_ctx, NULL);
600 }
601
602
603 void va_TraceCreateContext(
604     VADisplay dpy,
605     VAConfigID config_id,
606     int picture_width,
607     int picture_height,
608     int flag,
609     VASurfaceID *render_targets,
610     int num_render_targets,
611     VAContextID *context        /* out */
612 )
613 {
614     int i;
615     DPY2TRACECTX(dpy);
616
617     TRACE_FUNCNAME(idx);
618
619     va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id);
620     va_TraceMsg(trace_ctx, "\twidth = %d\n", picture_width);
621     va_TraceMsg(trace_ctx, "\theight = %d\n", picture_height);
622     va_TraceMsg(trace_ctx, "\tflag = 0x%08x\n", flag);
623     va_TraceMsg(trace_ctx, "\tnum_render_targets = %d\n", num_render_targets);
624     if (render_targets) {
625         for (i=0; i<num_render_targets; i++)
626             va_TraceMsg(trace_ctx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]);
627     }
628     if (context) {
629         va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", *context);
630         trace_ctx->trace_context = *context;
631     } else
632         trace_ctx->trace_context = VA_INVALID_ID;
633     
634     trace_ctx->trace_frame_no = 0;
635     trace_ctx->trace_slice_no = 0;
636
637     trace_ctx->trace_frame_width = picture_width;
638     trace_ctx->trace_frame_height = picture_height;
639
640     if (trace_ctx->trace_surface_width == 0)
641         trace_ctx->trace_surface_width = picture_width;
642     if (trace_ctx->trace_surface_height == 0)
643         trace_ctx->trace_surface_height = picture_height;
644 }
645
646
647 static char * buffer_type_to_string(int type)
648 {
649     switch (type) {
650     case VAPictureParameterBufferType: return "VAPictureParameterBufferType";
651     case VAIQMatrixBufferType: return "VAIQMatrixBufferType";
652     case VABitPlaneBufferType: return "VABitPlaneBufferType";
653     case VASliceGroupMapBufferType: return "VASliceGroupMapBufferType";
654     case VASliceParameterBufferType: return "VASliceParameterBufferType";
655     case VASliceDataBufferType: return "VASliceDataBufferType";
656     case VAProtectedSliceDataBufferType: return "VAProtectedSliceDataBufferType";
657     case VAMacroblockParameterBufferType: return "VAMacroblockParameterBufferType";
658     case VAResidualDataBufferType: return "VAResidualDataBufferType";
659     case VADeblockingParameterBufferType: return "VADeblockingParameterBufferType";
660     case VAImageBufferType: return "VAImageBufferType";
661     case VAQMatrixBufferType: return "VAQMatrixBufferType";
662     case VAHuffmanTableBufferType: return "VAHuffmanTableBufferType";
663 /* Following are encode buffer types */
664     case VAEncCodedBufferType: return "VAEncCodedBufferType";
665     case VAEncSequenceParameterBufferType: return "VAEncSequenceParameterBufferType";
666     case VAEncPictureParameterBufferType: return "VAEncPictureParameterBufferType";
667     case VAEncSliceParameterBufferType: return "VAEncSliceParameterBufferType";
668     case VAEncPackedHeaderParameterBufferType: return "VAEncPackedHeaderParameterBufferType";
669     case VAEncPackedHeaderDataBufferType: return "VAEncPackedHeaderDataBufferType";
670     case VAEncMiscParameterBufferType: return "VAEncMiscParameterBufferType";
671     case VAEncMacroblockParameterBufferType: return "VAEncMacroblockParameterBufferType";
672     case VAProcPipelineParameterBufferType: return "VAProcPipelineParameterBufferType";
673     case VAProcFilterParameterBufferType: return "VAProcFilterParameterBufferType";
674     default: return "UnknowBuffer";
675     }
676 }
677
678 void va_TraceCreateBuffer (
679     VADisplay dpy,
680     VAContextID context,        /* in */
681     VABufferType type,          /* in */
682     unsigned int size,          /* in */
683     unsigned int num_elements,  /* in */
684     void *data,                 /* in */
685     VABufferID *buf_id          /* out */
686 )
687 {
688     DPY2TRACECTX(dpy);
689
690     /* only trace CodedBuffer */
691     if (type != VAEncCodedBufferType)
692         return;
693
694     TRACE_FUNCNAME(idx);
695     va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type));
696     if (buf_id)
697         va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", *buf_id);
698     va_TraceMsg(trace_ctx, "\tsize=%d\n", size);
699     va_TraceMsg(trace_ctx, "\tnum_elements=%d\n", num_elements);
700     
701     va_TraceMsg(trace_ctx, NULL);
702 }
703
704 void va_TraceDestroyBuffer (
705     VADisplay dpy,
706     VABufferID buf_id    /* in */
707 )
708 {
709     VABufferType type;
710     unsigned int size;
711     unsigned int num_elements;
712     
713     VACodedBufferSegment *buf_list;
714     int i = 0;
715     
716     DPY2TRACECTX(dpy);
717
718     vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements);    
719     
720     /* only trace CodedBuffer */
721     if (type != VAEncCodedBufferType)
722         return;
723
724     TRACE_FUNCNAME(idx);
725     va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type));
726     va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
727     va_TraceMsg(trace_ctx, "\tsize=%d\n", size);
728     va_TraceMsg(trace_ctx, "\tnum_elements=%d\n", num_elements);
729     
730     va_TraceMsg(trace_ctx, NULL);
731 }
732
733
734 void va_TraceMapBuffer (
735     VADisplay dpy,
736     VABufferID buf_id,    /* in */
737     void **pbuf           /* out */
738 )
739 {
740     VABufferType type;
741     unsigned int size;
742     unsigned int num_elements;
743     
744     VACodedBufferSegment *buf_list;
745     int i = 0;
746     
747     DPY2TRACECTX(dpy);
748
749     vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements);    
750     
751     /* only trace CodedBuffer */
752     if (type != VAEncCodedBufferType)
753         return;
754
755     TRACE_FUNCNAME(idx);
756     va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
757     va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type));
758     if ((pbuf == NULL) || (*pbuf == NULL))
759         return;
760     
761     buf_list = (VACodedBufferSegment *)(*pbuf);
762     while (buf_list != NULL) {
763         va_TraceMsg(trace_ctx, "\tCodedbuf[%d] =\n", i++);
764         
765         va_TraceMsg(trace_ctx, "\t   size = %d\n", buf_list->size);
766         va_TraceMsg(trace_ctx, "\t   bit_offset = %d\n", buf_list->bit_offset);
767         va_TraceMsg(trace_ctx, "\t   status = 0x%08x\n", buf_list->status);
768         va_TraceMsg(trace_ctx, "\t   reserved = 0x%08x\n", buf_list->reserved);
769         va_TraceMsg(trace_ctx, "\t   buf = 0x%08x\n", buf_list->buf);
770
771         buf_list = buf_list->next;
772     }
773     va_TraceMsg(trace_ctx, NULL);
774 }
775
776 static void va_TraceVABuffers(
777     VADisplay dpy,
778     VAContextID context,
779     VABufferID buffer,
780     VABufferType type,
781     unsigned int size,
782     unsigned int num_elements,
783     void *pbuf
784 )
785 {
786     unsigned int i;
787     unsigned char *p = pbuf;
788
789     DPY2TRACECTX(dpy);
790     
791     va_TraceMsg(trace_ctx, "--%s\n",  buffer_type_to_string(type));
792
793     if ((trace_flag & VA_TRACE_FLAG_BUFDATA) && trace_ctx->trace_fp_log) {
794         for (i=0; i<size; i++) {
795             unsigned char value =  p[i];
796
797             if (i==0)
798                 fprintf(trace_ctx->trace_fp_log, "\t\t0x%04x:", i);
799             else if ((i%16) == 0)
800                 fprintf(trace_ctx->trace_fp_log, "\n\t\t0x%04x:", i);
801
802             fprintf(trace_ctx->trace_fp_log, " %02x", value);
803         }
804         fprintf(trace_ctx->trace_fp_log, "\n");
805     }
806     
807     va_TraceMsg(trace_ctx, NULL);
808
809     return;
810 }
811
812
813 static void va_TraceVAPictureParameterBufferMPEG2(
814     VADisplay dpy,
815     VAContextID context,
816     VABufferID buffer,
817     VABufferType type,
818     unsigned int size,
819     unsigned int num_elements,
820     void *data)
821 {
822     VAPictureParameterBufferMPEG2 *p=(VAPictureParameterBufferMPEG2 *)data;
823     DPY2TRACECTX(dpy);
824
825     va_TraceMsg(trace_ctx,"VAPictureParameterBufferMPEG2\n");
826
827     va_TraceMsg(trace_ctx,"\thorizontal size= %d\n", p->horizontal_size);
828     va_TraceMsg(trace_ctx,"\tvertical size= %d\n", p->vertical_size);
829     va_TraceMsg(trace_ctx,"\tforward reference picture= %d\n", p->forward_reference_picture);
830     va_TraceMsg(trace_ctx,"\tbackward reference picture= %d\n", p->backward_reference_picture);
831     va_TraceMsg(trace_ctx,"\tpicture coding type= %d\n", p->picture_coding_type);
832     va_TraceMsg(trace_ctx,"\tf mode= %d\n", p->f_code);
833
834     va_TraceMsg(trace_ctx,"\tpicture coding extension = %d\n", p->picture_coding_extension.value);
835     va_TraceMsg(trace_ctx,"\tintra_dc_precision= %d\n", p->picture_coding_extension.bits.intra_dc_precision);
836     va_TraceMsg(trace_ctx,"\tpicture_structure= %d\n", p->picture_coding_extension.bits.picture_structure);
837     va_TraceMsg(trace_ctx,"\ttop_field_first= %d\n", p->picture_coding_extension.bits.top_field_first);
838     va_TraceMsg(trace_ctx,"\tframe_pred_frame_dct= %d\n", p->picture_coding_extension.bits.frame_pred_frame_dct);
839     va_TraceMsg(trace_ctx,"\tconcealment_motion_vectors= %d\n", p->picture_coding_extension.bits.concealment_motion_vectors);
840     va_TraceMsg(trace_ctx,"\tq_scale_type= %d\n", p->picture_coding_extension.bits.q_scale_type);
841     va_TraceMsg(trace_ctx,"\tintra_vlc_format= %d\n", p->picture_coding_extension.bits.intra_vlc_format);
842     va_TraceMsg(trace_ctx,"\talternate_scan= %d\n", p->picture_coding_extension.bits.alternate_scan);
843     va_TraceMsg(trace_ctx,"\trepeat_first_field= %d\n", p->picture_coding_extension.bits.repeat_first_field);
844     va_TraceMsg(trace_ctx,"\tprogressive_frame= %d\n", p->picture_coding_extension.bits.progressive_frame);
845     va_TraceMsg(trace_ctx,"\tis_first_field= %d\n", p->picture_coding_extension.bits.is_first_field);
846     va_TraceMsg(trace_ctx, NULL);
847
848     return;
849 }
850
851
852 static void va_TraceVAIQMatrixBufferMPEG2(
853     VADisplay dpy,
854     VAContextID context,
855     VABufferID buffer,
856     VABufferType type,
857     unsigned int size,
858     unsigned int num_elements,
859     void *data)
860 {
861     VAIQMatrixBufferMPEG2 *p=(VAIQMatrixBufferMPEG2 *)data;
862     DPY2TRACECTX(dpy);
863
864     va_TraceMsg(trace_ctx,"VAIQMatrixBufferMPEG2\n");
865
866     va_TraceMsg(trace_ctx,"\tload_intra_quantiser_matrix = %d\n", p->load_intra_quantiser_matrix);
867     va_TraceMsg(trace_ctx,"\tload_non_intra_quantiser_matrix = %d\n", p->load_non_intra_quantiser_matrix);
868     va_TraceMsg(trace_ctx,"\tload_chroma_intra_quantiser_matrix = %d\n", p->load_chroma_intra_quantiser_matrix);
869     va_TraceMsg(trace_ctx,"\tload_chroma_non_intra_quantiser_matrix = %d\n", p->load_chroma_non_intra_quantiser_matrix);
870     va_TraceMsg(trace_ctx,"\tintra_quantiser_matrix = %d\n", p->intra_quantiser_matrix);
871     va_TraceMsg(trace_ctx,"\tnon_intra_quantiser_matrix = %d\n", p->non_intra_quantiser_matrix);
872     va_TraceMsg(trace_ctx,"\tchroma_intra_quantiser_matrix = %d\n", p->chroma_intra_quantiser_matrix);
873     va_TraceMsg(trace_ctx,"\tchroma_non_intra_quantiser_matrix = %d\n", p->chroma_non_intra_quantiser_matrix);
874     va_TraceMsg(trace_ctx, NULL);
875
876     return;
877 }
878
879
880 static void va_TraceVASliceParameterBufferMPEG2(
881     VADisplay dpy,
882     VAContextID context,
883     VABufferID buffer,
884     VABufferType type,
885     unsigned int size,
886     unsigned int num_elements,
887     void *data)
888 {
889     VASliceParameterBufferMPEG2 *p=(VASliceParameterBufferMPEG2 *)data;
890
891     DPY2TRACECTX(dpy);
892
893     trace_ctx->trace_slice_no++;
894     
895     trace_ctx->trace_slice_size = p->slice_data_size;
896
897     va_TraceMsg(trace_ctx,"VASliceParameterBufferMPEG2\n");
898
899     va_TraceMsg(trace_ctx,"\tslice_data_size = %d\n", p->slice_data_size);
900     va_TraceMsg(trace_ctx,"\tslice_data_offset = %d\n", p->slice_data_offset);
901     va_TraceMsg(trace_ctx,"\tslice_data_flag = %d\n", p->slice_data_flag);
902     va_TraceMsg(trace_ctx,"\tmacroblock_offset = %d\n", p->macroblock_offset);
903     va_TraceMsg(trace_ctx,"\tslice_horizontal_position = %d\n", p->slice_horizontal_position);
904     va_TraceMsg(trace_ctx,"\tslice_vertical_position = %d\n", p->slice_vertical_position);
905     va_TraceMsg(trace_ctx,"\tquantiser_scale_code = %d\n", p->quantiser_scale_code);
906     va_TraceMsg(trace_ctx,"\tintra_slice_flag = %d\n", p->intra_slice_flag);
907     va_TraceMsg(trace_ctx, NULL);
908
909     return;
910 }
911
912 static void va_TraceVAPictureParameterBufferJPEG(
913     VADisplay dpy,
914     VAContextID context,
915     VABufferID buffer,
916     VABufferType type,
917     unsigned int size,
918     unsigned int num_elements,
919     void *data)
920 {
921     int i;
922     VAPictureParameterBufferJPEGBaseline *p=(VAPictureParameterBufferJPEGBaseline *)data;
923     DPY2TRACECTX(dpy);
924
925     va_TraceMsg(trace_ctx,"*VAPictureParameterBufferJPEG\n");
926     va_TraceMsg(trace_ctx,"\tpicture_width = %u\n", p->picture_width);
927     va_TraceMsg(trace_ctx,"\tpicture_height = %u\n", p->picture_height);
928     va_TraceMsg(trace_ctx,"\tcomponents = \n");
929     for (i = 0; i < p->num_components && i < 255; ++i) {
930         va_TraceMsg(trace_ctx,"\t\t[%d] component_id = %u\n", i, p->components[i].component_id);
931         va_TraceMsg(trace_ctx,"\t\t[%d] h_sampling_factor = %u\n", i, p->components[i].h_sampling_factor);
932         va_TraceMsg(trace_ctx,"\t\t[%d] v_sampling_factor = %u\n", i, p->components[i].v_sampling_factor);
933         va_TraceMsg(trace_ctx,"\t\t[%d] quantiser_table_selector = %u\n", i, p->components[i].quantiser_table_selector);
934     }
935 }
936
937 static void va_TraceVAIQMatrixBufferJPEG(
938     VADisplay dpy,
939     VAContextID context,
940     VABufferID buffer,
941     VABufferType type,
942     unsigned int size,
943     unsigned int num_elements,
944     void *data)
945 {
946     int i, j;
947     static char tmp[1024];
948     VAIQMatrixBufferJPEGBaseline *p=(VAIQMatrixBufferJPEGBaseline *)data;
949     DPY2TRACECTX(dpy);
950     va_TraceMsg(trace_ctx,"*VAIQMatrixParameterBufferJPEG\n");
951     va_TraceMsg(trace_ctx,"\tload_quantiser_table =\n");
952     for (i = 0; i < 4; ++i) {
953         va_TraceMsg(trace_ctx,"\t\t[%d] = %u\n", i, p->load_quantiser_table[i]);
954     }
955     va_TraceMsg(trace_ctx,"\tquantiser_table =\n");
956     for (i = 0; i < 4; ++i) {
957         memset(tmp, 0, sizeof tmp);
958         for (j = 0; j < 64; ++j) {
959             sprintf(tmp + strlen(tmp), "%u ", p->quantiser_table[i][j]);
960         }
961         va_TraceMsg(trace_ctx,"\t\t[%d] = %s\n", i, tmp);
962     }
963 }
964
965 static void va_TraceVASliceParameterBufferJPEG(
966     VADisplay dpy,
967     VAContextID context,
968     VABufferID buffer,
969     VABufferType type,
970     unsigned int size,
971     unsigned int num_elements,
972     void *data)
973 {
974     int i;
975     VASliceParameterBufferJPEGBaseline *p=(VASliceParameterBufferJPEGBaseline *)data;
976     DPY2TRACECTX(dpy);
977     va_TraceMsg(trace_ctx,"*VASliceParameterBufferJPEG\n");
978     va_TraceMsg(trace_ctx,"\tslice_data_size = %u\n", p->slice_data_size);
979     va_TraceMsg(trace_ctx,"\tslice_data_offset = %u\n", p->slice_data_offset);
980     va_TraceMsg(trace_ctx,"\tslice_data_flag = %u\n", p->slice_data_flag);
981     va_TraceMsg(trace_ctx,"\tslice_horizontal_position = %u\n", p->slice_horizontal_position);
982     va_TraceMsg(trace_ctx,"\tslice_vertical_position = %u\n", p->slice_vertical_position);
983     va_TraceMsg(trace_ctx,"\tcomponents = \n");
984     for (i = 0; i < p->num_components && i < 4; ++i) {
985         va_TraceMsg(trace_ctx,"\t\t[%d] component_selector = %u\n", i, p->components[i].component_selector);
986         va_TraceMsg(trace_ctx,"\t\t[%d] dc_table_selector = %u\n", i, p->components[i].dc_table_selector);
987         va_TraceMsg(trace_ctx,"\t\t[%d] ac_table_selector = %u\n", i, p->components[i].ac_table_selector);
988     }
989     va_TraceMsg(trace_ctx,"\trestart_interval = %u\n", p->restart_interval);
990     va_TraceMsg(trace_ctx,"\tnum_mcus = %u\n", p->num_mcus);
991 }
992
993 static void va_TraceVAHuffmanTableBufferJPEG(
994     VADisplay dpy,
995     VAContextID context,
996     VABufferID buffer,
997     VABufferType type,
998     unsigned int size,
999     unsigned int num_elements,
1000     void *data)
1001 {
1002     int i, j;
1003     static char tmp[1024];
1004     VAHuffmanTableBufferJPEGBaseline *p=(VAHuffmanTableBufferJPEGBaseline *)data;
1005     DPY2TRACECTX(dpy);
1006     va_TraceMsg(trace_ctx,"*VAHuffmanTableBufferJPEG\n");
1007
1008     for (i = 0; i < 2; ++i) {
1009         va_TraceMsg(trace_ctx,"\tload_huffman_table[%d] =%u\n", i, p->load_huffman_table[0]);
1010         va_TraceMsg(trace_ctx,"\thuffman_table[%d] =\n", i);
1011         memset(tmp, 0, sizeof tmp);
1012         for (j = 0; j < 16; ++j) {
1013             sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].num_dc_codes[j]);
1014         }
1015         va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp);
1016         memset(tmp, 0, sizeof tmp);
1017         for (j = 0; j < 12; ++j) {
1018             sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].dc_values[j]);
1019         }
1020         va_TraceMsg(trace_ctx,"\t\tdc_values =%s\n", tmp);
1021         memset(tmp, 0, sizeof tmp);
1022         for (j = 0; j < 16; ++j) {
1023             sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].num_ac_codes[j]);
1024         }
1025         va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp);
1026         memset(tmp, 0, sizeof tmp);
1027         for (j = 0; j < 162; ++j) {
1028             sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].ac_values[j]);
1029         }
1030         va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp);
1031         memset(tmp, 0, sizeof tmp);
1032         for (j = 0; j < 2; ++j) {
1033             sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].pad[j]);
1034         }
1035         va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp);
1036     }
1037 }
1038
1039 static void va_TraceVAPictureParameterBufferMPEG4(
1040     VADisplay dpy,
1041     VAContextID context,
1042     VABufferID buffer,
1043     VABufferType type,
1044     unsigned int size,
1045     unsigned int num_elements,
1046     void *data)
1047 {
1048     int i;
1049     VAPictureParameterBufferMPEG4 *p=(VAPictureParameterBufferMPEG4 *)data;
1050     
1051     DPY2TRACECTX(dpy);
1052
1053     va_TraceMsg(trace_ctx,"*VAPictureParameterBufferMPEG4\n");
1054     va_TraceMsg(trace_ctx,"\tvop_width = %d\n", p->vop_width);
1055     va_TraceMsg(trace_ctx,"\tvop_height = %d\n", p->vop_height);
1056     va_TraceMsg(trace_ctx,"\tforward_reference_picture = %d\n", p->forward_reference_picture);
1057     va_TraceMsg(trace_ctx,"\tbackward_reference_picture = %d\n", p->backward_reference_picture);
1058     va_TraceMsg(trace_ctx,"\tvol_fields value = %d\n", p->vol_fields.value);
1059     va_TraceMsg(trace_ctx,"\tshort_video_header= %d\n", p->vol_fields.bits.short_video_header);
1060     va_TraceMsg(trace_ctx,"\tchroma_format= %d\n", p->vol_fields.bits.chroma_format);
1061     va_TraceMsg(trace_ctx,"\tinterlaced= %d\n", p->vol_fields.bits.interlaced);
1062     va_TraceMsg(trace_ctx,"\tobmc_disable= %d\n", p->vol_fields.bits.obmc_disable);
1063     va_TraceMsg(trace_ctx,"\tsprite_enable= %d\n", p->vol_fields.bits.sprite_enable);
1064     va_TraceMsg(trace_ctx,"\tsprite_warping_accuracy= %d\n", p->vol_fields.bits.sprite_warping_accuracy);
1065     va_TraceMsg(trace_ctx,"\tquant_type= %d\n", p->vol_fields.bits.quant_type);
1066     va_TraceMsg(trace_ctx,"\tquarter_sample= %d\n", p->vol_fields.bits.quarter_sample);
1067     va_TraceMsg(trace_ctx,"\tdata_partitioned= %d\n", p->vol_fields.bits.data_partitioned);
1068     va_TraceMsg(trace_ctx,"\treversible_vlc= %d\n", p->vol_fields.bits.reversible_vlc);
1069     va_TraceMsg(trace_ctx,"\tresync_marker_disable= %d\n", p->vol_fields.bits.resync_marker_disable);
1070     va_TraceMsg(trace_ctx,"\tno_of_sprite_warping_points = %d\n", p->no_of_sprite_warping_points);
1071     va_TraceMsg(trace_ctx,"\tsprite_trajectory_du =");
1072     for(i=0;i<3;i++)
1073         va_TraceMsg(trace_ctx,"\t%d", p->sprite_trajectory_du[i]);
1074
1075     va_TraceMsg(trace_ctx,"\n");
1076     va_TraceMsg(trace_ctx,"\tsprite_trajectory_dv =");
1077     for(i=0;i<3;i++)
1078         va_TraceMsg(trace_ctx,"\t%d", p->sprite_trajectory_dv[i]);
1079     va_TraceMsg(trace_ctx,"\n");
1080     va_TraceMsg(trace_ctx,"\tvop_fields value = %d\n", p->vop_fields.value);
1081     va_TraceMsg(trace_ctx,"\tvop_coding_type= %d\n", p->vop_fields.bits.vop_coding_type);
1082     va_TraceMsg(trace_ctx,"\tbackward_reference_vop_coding_type= %d\n", p->vop_fields.bits.backward_reference_vop_coding_type);
1083     va_TraceMsg(trace_ctx,"\tvop_rounding_type= %d\n", p->vop_fields.bits.vop_rounding_type);
1084     va_TraceMsg(trace_ctx,"\tintra_dc_vlc_thr= %d\n", p->vop_fields.bits.intra_dc_vlc_thr);
1085     va_TraceMsg(trace_ctx,"\ttop_field_first= %d\n", p->vop_fields.bits.top_field_first);
1086     va_TraceMsg(trace_ctx,"\talternate_vertical_scan_flag= %d\n", p->vop_fields.bits.alternate_vertical_scan_flag);
1087     va_TraceMsg(trace_ctx,"\tvop_fcode_forward = %d\n", p->vop_fcode_forward);
1088     va_TraceMsg(trace_ctx,"\tvop_fcode_backward = %d\n", p->vop_fcode_backward);
1089     va_TraceMsg(trace_ctx,"\tnum_gobs_in_vop = %d\n", p->num_gobs_in_vop);
1090     va_TraceMsg(trace_ctx,"\tnum_macroblocks_in_gob = %d\n", p->num_macroblocks_in_gob);
1091     va_TraceMsg(trace_ctx,"\tTRB = %d\n", p->TRB);
1092     va_TraceMsg(trace_ctx,"\tTRD = %d\n", p->TRD);
1093     va_TraceMsg(trace_ctx, NULL);
1094
1095     return;
1096 }
1097
1098
1099 static void va_TraceVAIQMatrixBufferMPEG4(
1100     VADisplay dpy,
1101     VAContextID context,
1102     VABufferID buffer,
1103     VABufferType type,
1104     unsigned int size,
1105     unsigned int num_elements,
1106     void *data)
1107 {
1108     int i;
1109     VAIQMatrixBufferMPEG4 *p=(VAIQMatrixBufferMPEG4 *)data;
1110     DPY2TRACECTX(dpy);
1111
1112     va_TraceMsg(trace_ctx,"VAIQMatrixBufferMPEG4\n");
1113
1114     va_TraceMsg(trace_ctx,"\tload_intra_quant_mat = %d\n", p->load_intra_quant_mat);
1115     va_TraceMsg(trace_ctx,"\tload_non_intra_quant_mat = %d\n", p->load_non_intra_quant_mat);
1116     va_TraceMsg(trace_ctx,"\tintra_quant_mat =\n");
1117     for(i=0;i<64;i++)
1118         va_TraceMsg(trace_ctx,"\t\t%d\n", p->intra_quant_mat[i]);
1119
1120     va_TraceMsg(trace_ctx,"\tnon_intra_quant_mat =\n");
1121     for(i=0;i<64;i++)
1122         va_TraceMsg(trace_ctx,"\t\t%d\n", p->non_intra_quant_mat[i]);
1123     va_TraceMsg(trace_ctx, NULL);
1124
1125     return;
1126 }
1127
1128 static void va_TraceVAEncSequenceParameterBufferMPEG4(
1129     VADisplay dpy,
1130     VAContextID context,
1131     VABufferID buffer,
1132     VABufferType type,
1133     unsigned int size,
1134     unsigned int num_elements,
1135     void *data)
1136 {
1137     VAEncSequenceParameterBufferMPEG4 *p = (VAEncSequenceParameterBufferMPEG4 *)data;
1138     DPY2TRACECTX(dpy);
1139     
1140     va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferMPEG4\n");
1141     
1142     va_TraceMsg(trace_ctx, "\tprofile_and_level_indication = %d\n", p->profile_and_level_indication);
1143     va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
1144     va_TraceMsg(trace_ctx, "\tvideo_object_layer_width = %d\n", p->video_object_layer_width);
1145     va_TraceMsg(trace_ctx, "\tvideo_object_layer_height = %d\n", p->video_object_layer_height);
1146     va_TraceMsg(trace_ctx, "\tvop_time_increment_resolution = %d\n", p->vop_time_increment_resolution);
1147     va_TraceMsg(trace_ctx, "\tfixed_vop_rate = %d\n", p->fixed_vop_rate);
1148     va_TraceMsg(trace_ctx, "\tfixed_vop_time_increment = %d\n", p->fixed_vop_time_increment);
1149     va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
1150     va_TraceMsg(trace_ctx, "\tframe_rate = %d\n", p->frame_rate);
1151     va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp);
1152     va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
1153     va_TraceMsg(trace_ctx, NULL);
1154
1155     /* start a new sequce, coded log file can be truncated */
1156     trace_ctx->trace_sequence_start = 1;
1157
1158     return;
1159 }
1160
1161 static void va_TraceVAEncPictureParameterBufferMPEG4(
1162     VADisplay dpy,
1163     VAContextID context,
1164     VABufferID buffer,
1165     VABufferType type,
1166     unsigned int size,
1167     unsigned int num_elements,
1168     void *data)
1169 {
1170     VAEncPictureParameterBufferMPEG4 *p = (VAEncPictureParameterBufferMPEG4 *)data;
1171     DPY2TRACECTX(dpy);
1172     
1173     va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferMPEG4\n");
1174     va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture);
1175     va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
1176     va_TraceMsg(trace_ctx, "\tcoded_buf = 0x%08x\n", p->coded_buf);
1177     va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width);
1178     va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height);
1179     va_TraceMsg(trace_ctx, "\tmodulo_time_base = %d\n", p->modulo_time_base);
1180     va_TraceMsg(trace_ctx, "\tvop_time_increment = %d\n", p->vop_time_increment);
1181     va_TraceMsg(trace_ctx, "\tpicture_type = %d\n", p->picture_type);
1182     va_TraceMsg(trace_ctx, NULL);
1183
1184     trace_ctx->trace_codedbuf =  p->coded_buf;
1185     
1186     return;
1187 }
1188
1189
1190 static void va_TraceVASliceParameterBufferMPEG4(
1191     VADisplay dpy,
1192     VAContextID context,
1193     VABufferID buffer,
1194     VABufferType type,
1195     unsigned int size,
1196     unsigned int num_elements,
1197     void *data)
1198 {
1199     VASliceParameterBufferMPEG4 *p=(VASliceParameterBufferMPEG4 *)data;
1200     
1201     DPY2TRACECTX(dpy);
1202
1203     trace_ctx->trace_slice_no++;
1204
1205     trace_ctx->trace_slice_size = p->slice_data_size;
1206
1207     va_TraceMsg(trace_ctx,"VASliceParameterBufferMPEG4\n");
1208
1209     va_TraceMsg(trace_ctx,"\tslice_data_size = %d\n", p->slice_data_size);
1210     va_TraceMsg(trace_ctx,"\tslice_data_offset = %d\n", p->slice_data_offset);
1211     va_TraceMsg(trace_ctx,"\tslice_data_flag = %d\n", p->slice_data_flag);
1212     va_TraceMsg(trace_ctx,"\tmacroblock_offset = %d\n", p->macroblock_offset);
1213     va_TraceMsg(trace_ctx,"\tmacroblock_number = %d\n", p->macroblock_number);
1214     va_TraceMsg(trace_ctx,"\tquant_scale = %d\n", p->quant_scale);
1215     va_TraceMsg(trace_ctx, NULL);
1216
1217     return;
1218 }
1219
1220
1221 static inline void va_TraceFlagIfNotZero(
1222     struct trace_context *trace_ctx,
1223     const char *name,   /* in */
1224     unsigned int flag   /* in */
1225 )
1226 {
1227     if (flag != 0) {
1228         va_TraceMsg(trace_ctx, "%s = %x\n", name, flag);
1229     }
1230 }
1231
1232
1233 static void va_TraceVAPictureParameterBufferH264(
1234     VADisplay dpy,
1235     VAContextID context,
1236     VABufferID buffer,
1237     VABufferType type,
1238     unsigned int size,
1239     unsigned int num_elements,
1240     void *data)
1241 {
1242     int i;
1243     VAPictureParameterBufferH264 *p = (VAPictureParameterBufferH264*)data;
1244     
1245     DPY2TRACECTX(dpy);
1246
1247     va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferH264\n");
1248
1249     va_TraceMsg(trace_ctx, "\tCurrPic.picture_id = 0x%08x\n", p->CurrPic.picture_id);
1250     va_TraceMsg(trace_ctx, "\tCurrPic.frame_idx = %d\n", p->CurrPic.frame_idx);
1251     va_TraceMsg(trace_ctx, "\tCurrPic.flags = %d\n", p->CurrPic.flags);
1252     va_TraceMsg(trace_ctx, "\tCurrPic.TopFieldOrderCnt = %d\n", p->CurrPic.TopFieldOrderCnt);
1253     va_TraceMsg(trace_ctx, "\tCurrPic.BottomFieldOrderCnt = %d\n", p->CurrPic.BottomFieldOrderCnt);
1254
1255     va_TraceMsg(trace_ctx, "\tReferenceFrames (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags:\n");
1256     for (i = 0; i < 16; i++)
1257     {
1258         if ((p->ReferenceFrames[i].picture_id != VA_INVALID_SURFACE) &&
1259             ((p->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID) == 0)) {
1260             va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08x\n",
1261                         p->ReferenceFrames[i].TopFieldOrderCnt,
1262                         p->ReferenceFrames[i].BottomFieldOrderCnt,
1263                         p->ReferenceFrames[i].picture_id,
1264                         p->ReferenceFrames[i].frame_idx,
1265                         p->ReferenceFrames[i].flags);
1266         } else
1267             break;
1268     }
1269     va_TraceMsg(trace_ctx, "\n");
1270     
1271     va_TraceMsg(trace_ctx, "\tpicture_width_in_mbs_minus1 = %d\n", p->picture_width_in_mbs_minus1);
1272     va_TraceMsg(trace_ctx, "\tpicture_height_in_mbs_minus1 = %d\n", p->picture_height_in_mbs_minus1);
1273     va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8);
1274     va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8);
1275     va_TraceMsg(trace_ctx, "\tnum_ref_frames = %d\n", p->num_ref_frames);
1276     va_TraceMsg(trace_ctx, "\tseq fields = %d\n", p->seq_fields.value);
1277     va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc);
1278     va_TraceMsg(trace_ctx, "\tresidual_colour_transform_flag = %d\n", p->seq_fields.bits.residual_colour_transform_flag);
1279     va_TraceMsg(trace_ctx, "\tframe_mbs_only_flag = %d\n", p->seq_fields.bits.frame_mbs_only_flag);
1280     va_TraceMsg(trace_ctx, "\tmb_adaptive_frame_field_flag = %d\n", p->seq_fields.bits.mb_adaptive_frame_field_flag);
1281     va_TraceMsg(trace_ctx, "\tdirect_8x8_inference_flag = %d\n", p->seq_fields.bits.direct_8x8_inference_flag);
1282     va_TraceMsg(trace_ctx, "\tMinLumaBiPredSize8x8 = %d\n", p->seq_fields.bits.MinLumaBiPredSize8x8);
1283     va_TraceMsg(trace_ctx, "\tnum_slice_groups_minus1 = %d\n", p->num_slice_groups_minus1);
1284     va_TraceMsg(trace_ctx, "\tslice_group_map_type = %d\n", p->slice_group_map_type);
1285     va_TraceMsg(trace_ctx, "\tslice_group_change_rate_minus1 = %d\n", p->slice_group_change_rate_minus1);
1286     va_TraceMsg(trace_ctx, "\tpic_init_qp_minus26 = %d\n", p->pic_init_qp_minus26);
1287     va_TraceMsg(trace_ctx, "\tpic_init_qs_minus26 = %d\n", p->pic_init_qs_minus26);
1288     va_TraceMsg(trace_ctx, "\tchroma_qp_index_offset = %d\n", p->chroma_qp_index_offset);
1289     va_TraceMsg(trace_ctx, "\tsecond_chroma_qp_index_offset = %d\n", p->second_chroma_qp_index_offset);
1290     va_TraceMsg(trace_ctx, "\tpic_fields = 0x%03x\n", p->pic_fields.value);
1291     va_TraceFlagIfNotZero(trace_ctx, "\t\tentropy_coding_mode_flag", p->pic_fields.bits.entropy_coding_mode_flag);
1292     va_TraceFlagIfNotZero(trace_ctx, "\t\tweighted_pred_flag", p->pic_fields.bits.weighted_pred_flag);
1293     va_TraceFlagIfNotZero(trace_ctx, "\t\tweighted_bipred_idc", p->pic_fields.bits.weighted_bipred_idc);
1294     va_TraceFlagIfNotZero(trace_ctx, "\t\ttransform_8x8_mode_flag", p->pic_fields.bits.transform_8x8_mode_flag);
1295     va_TraceFlagIfNotZero(trace_ctx, "\t\tfield_pic_flag", p->pic_fields.bits.field_pic_flag);
1296     va_TraceFlagIfNotZero(trace_ctx, "\t\tconstrained_intra_pred_flag", p->pic_fields.bits.constrained_intra_pred_flag);
1297     va_TraceFlagIfNotZero(trace_ctx, "\t\tpic_order_present_flag", p->pic_fields.bits.pic_order_present_flag);
1298     va_TraceFlagIfNotZero(trace_ctx, "\t\tdeblocking_filter_control_present_flag", p->pic_fields.bits.deblocking_filter_control_present_flag);
1299     va_TraceFlagIfNotZero(trace_ctx, "\t\tredundant_pic_cnt_present_flag", p->pic_fields.bits.redundant_pic_cnt_present_flag);
1300     va_TraceFlagIfNotZero(trace_ctx, "\t\treference_pic_flag", p->pic_fields.bits.reference_pic_flag);
1301     va_TraceMsg(trace_ctx, "\tframe_num = %d\n", p->frame_num);
1302     va_TraceMsg(trace_ctx, NULL);
1303
1304     return;
1305 }
1306
1307 static void va_TraceVASliceParameterBufferH264(
1308     VADisplay dpy,
1309     VAContextID context,
1310     VABufferID buffer,
1311     VABufferType type,
1312     unsigned int size,
1313     unsigned int num_elements,
1314     void *data)
1315 {
1316     int i;
1317     VASliceParameterBufferH264* p = (VASliceParameterBufferH264*)data;
1318     DPY2TRACECTX(dpy);
1319
1320     trace_ctx->trace_slice_no++;
1321     trace_ctx->trace_slice_size = p->slice_data_size;
1322
1323     va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferH264\n");
1324     va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size);
1325     va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset);
1326     va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag);
1327     va_TraceMsg(trace_ctx, "\tslice_data_bit_offset = %d\n", p->slice_data_bit_offset);
1328     va_TraceMsg(trace_ctx, "\tfirst_mb_in_slice = %d\n", p->first_mb_in_slice);
1329     va_TraceMsg(trace_ctx, "\tslice_type = %d\n", p->slice_type);
1330     va_TraceMsg(trace_ctx, "\tdirect_spatial_mv_pred_flag = %d\n", p->direct_spatial_mv_pred_flag);
1331     va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1);
1332     va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1);
1333     va_TraceMsg(trace_ctx, "\tcabac_init_idc = %d\n", p->cabac_init_idc);
1334     va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta);
1335     va_TraceMsg(trace_ctx, "\tdisable_deblocking_filter_idc = %d\n", p->disable_deblocking_filter_idc);
1336     va_TraceMsg(trace_ctx, "\tslice_alpha_c0_offset_div2 = %d\n", p->slice_alpha_c0_offset_div2);
1337     va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2);
1338
1339     va_TraceMsg(trace_ctx, "\tRefPicList0 =");
1340     for (i = 0; i < 32; i++) {
1341         if ((p->RefPicList0[i].picture_id != VA_INVALID_SURFACE) &&
1342             ((p->RefPicList0[i].flags & VA_PICTURE_H264_INVALID) == 0))
1343         va_TraceMsg(trace_ctx, "%08d-%08d-0x%08x-%08d-0x%08x\n", p->RefPicList0[i].TopFieldOrderCnt, p->RefPicList0[i].BottomFieldOrderCnt, p->RefPicList0[i].picture_id, p->RefPicList0[i].frame_idx,  p->RefPicList0[i].flags);
1344         else
1345             break;
1346     }
1347     va_TraceMsg(trace_ctx, "\tRefPicList1 =");
1348     for (i = 0; i < 32; i++) {
1349         if ((p->RefPicList0[i].picture_id != VA_INVALID_SURFACE) &&
1350             ((p->RefPicList0[i].flags & VA_PICTURE_H264_INVALID) == 0))
1351             va_TraceMsg(trace_ctx, "%08d-%08d-0x%08x-%08d-0x%08x\n", p->RefPicList1[i].TopFieldOrderCnt, p->RefPicList1[i].BottomFieldOrderCnt, p->RefPicList1[i].picture_id, p->RefPicList1[i].frame_idx, p->RefPicList1[i].flags);
1352         else
1353             break;
1354     }
1355     
1356     va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom);
1357     va_TraceMsg(trace_ctx, "\tchroma_log2_weight_denom = %d\n", p->chroma_log2_weight_denom);
1358     va_TraceMsg(trace_ctx, "\tluma_weight_l0_flag = %d\n", p->luma_weight_l0_flag);
1359     if (p->luma_weight_l0_flag) {
1360         for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) {
1361             va_TraceMsg(trace_ctx, "\t%d ", p->luma_weight_l0[i]);
1362             va_TraceMsg(trace_ctx, "\t%d ", p->luma_offset_l0[i]);
1363         }
1364         if (p->num_ref_idx_l0_active_minus1 >= 0)
1365             va_TraceMsg(trace_ctx, "\n");
1366     }
1367
1368     va_TraceMsg(trace_ctx, "\tchroma_weight_l0_flag = %d\n", p->chroma_weight_l0_flag);
1369     if (p->chroma_weight_l0_flag) {
1370         for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) {
1371             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l0[i][0]);
1372             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l0[i][0]);
1373             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l0[i][1]);
1374             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l0[i][1]);
1375         }
1376         if (p->num_ref_idx_l0_active_minus1 >= 0)
1377             va_TraceMsg(trace_ctx, "\n");
1378     }
1379     
1380     va_TraceMsg(trace_ctx, "\tluma_weight_l1_flag = %d\n", p->luma_weight_l1_flag);
1381     if (p->luma_weight_l1_flag) {
1382         for (i = 0; (i <=  p->num_ref_idx_l1_active_minus1) && (i<32); i++) {
1383             va_TraceMsg(trace_ctx, "\t%d ", p->luma_weight_l1[i]);
1384             va_TraceMsg(trace_ctx, "\t%d ", p->luma_offset_l1[i]);
1385         }
1386         if (p->num_ref_idx_l1_active_minus1 >= 0)
1387             va_TraceMsg(trace_ctx, "\n");
1388     }
1389     
1390     va_TraceMsg(trace_ctx, "\tchroma_weight_l1_flag = %d\n", p->chroma_weight_l1_flag);
1391     if (p->chroma_weight_l1_flag) {
1392         for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) {
1393             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l1[i][0]);
1394             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l1[i][0]);
1395             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l1[i][1]);
1396             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l1[i][1]);
1397         }
1398         if (p->num_ref_idx_l1_active_minus1 >= 0)
1399             va_TraceMsg(trace_ctx, "\n");
1400     }
1401     va_TraceMsg(trace_ctx, NULL);
1402 }
1403
1404 static void va_TraceVAIQMatrixBufferH264(
1405     VADisplay dpy,
1406     VAContextID context,
1407     VABufferID buffer,
1408     VABufferType type,
1409     unsigned int size,
1410     unsigned int num_elements,
1411     void *data
1412 )
1413 {
1414     int i, j;    
1415     VAIQMatrixBufferH264* p = (VAIQMatrixBufferH264* )data;
1416
1417     DPY2TRACECTX(dpy);
1418
1419     va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferH264\n");
1420
1421     va_TraceMsg(trace_ctx, "\tScalingList4x4[6][16]=\n");
1422     for (i = 0; i < 6; i++) {
1423         for (j = 0; j < 16; j++) {
1424             va_TraceMsg(trace_ctx, "\t%d\t", p->ScalingList4x4[i][j]);
1425             if ((j + 1) % 8 == 0)
1426                 va_TraceMsg(trace_ctx, "\n");
1427         }
1428     }
1429
1430     va_TraceMsg(trace_ctx, "\tScalingList8x8[2][64]=\n");
1431     for (i = 0; i < 2; i++) {
1432         for (j = 0; j < 64; j++) {
1433             va_TraceMsg(trace_ctx, "\t%d", p->ScalingList8x8[i][j]);
1434             if ((j + 1) % 8 == 0)
1435                 va_TraceMsg(trace_ctx, "\n");
1436         }
1437     }
1438
1439     va_TraceMsg(trace_ctx, NULL);
1440 }
1441
1442
1443
1444 static void va_TraceVAEncSequenceParameterBufferH264(
1445     VADisplay dpy,
1446     VAContextID context,
1447     VABufferID buffer,
1448     VABufferType type,
1449     unsigned int size,
1450     unsigned int num_elements,
1451     void *data)
1452 {
1453     VAEncSequenceParameterBufferH264 *p = (VAEncSequenceParameterBufferH264 *)data;
1454     DPY2TRACECTX(dpy);
1455     int i;
1456
1457     va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferH264\n");
1458
1459     va_TraceMsg(trace_ctx, "\tseq_parameter_set_id = %d\n", p->seq_parameter_set_id);
1460     va_TraceMsg(trace_ctx, "\tlevel_idc = %d\n", p->level_idc);
1461     va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
1462     va_TraceMsg(trace_ctx, "\tintra_idr_period = %d\n", p->intra_idr_period);
1463     va_TraceMsg(trace_ctx, "\tip_period = %d\n", p->ip_period);
1464     va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
1465     va_TraceMsg(trace_ctx, "\tmax_num_ref_frames = %d\n", p->max_num_ref_frames);
1466     va_TraceMsg(trace_ctx, "\tpicture_width_in_mbs = %d\n", p->picture_width_in_mbs);
1467     va_TraceMsg(trace_ctx, "\tpicture_height_in_mbs = %d\n", p->picture_height_in_mbs);
1468     va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc);
1469     va_TraceMsg(trace_ctx, "\tframe_mbs_only_flag = %d\n", p->seq_fields.bits.frame_mbs_only_flag);
1470     va_TraceMsg(trace_ctx, "\tmb_adaptive_frame_field_flag = %d\n", p->seq_fields.bits.mb_adaptive_frame_field_flag);
1471     va_TraceMsg(trace_ctx, "\tseq_scaling_matrix_present_flag = %d\n", p->seq_fields.bits.seq_scaling_matrix_present_flag);
1472     va_TraceMsg(trace_ctx, "\tdirect_8x8_inference_flag = %d\n", p->seq_fields.bits.direct_8x8_inference_flag);
1473     va_TraceMsg(trace_ctx, "\tlog2_max_frame_num_minus4 = %d\n", p->seq_fields.bits.log2_max_frame_num_minus4);
1474     va_TraceMsg(trace_ctx, "\tpic_order_cnt_type = %d\n", p->seq_fields.bits.pic_order_cnt_type);
1475     va_TraceMsg(trace_ctx, "\tlog2_max_pic_order_cnt_lsb_minus4 = %d\n", p->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4);
1476     va_TraceMsg(trace_ctx, "\tdelta_pic_order_always_zero_flag = %d\n", p->seq_fields.bits.delta_pic_order_always_zero_flag);
1477     va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8);
1478     va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8);
1479     va_TraceMsg(trace_ctx, "\tnum_ref_frames_in_pic_order_cnt_cycle = %d\n", p->num_ref_frames_in_pic_order_cnt_cycle);
1480     va_TraceMsg(trace_ctx, "\toffset_for_non_ref_pic = %d\n", p->offset_for_non_ref_pic);
1481     va_TraceMsg(trace_ctx, "\toffset_for_top_to_bottom_field = %d\n", p->offset_for_top_to_bottom_field);
1482     for(i = 0; i< p->max_num_ref_frames; ++i)
1483         va_TraceMsg(trace_ctx, "\toffset_for_ref_frame[%d] = %d\n", i, p->offset_for_ref_frame[i]);
1484     va_TraceMsg(trace_ctx, "\tframe_cropping_flag = %d\n", p->frame_cropping_flag);
1485     va_TraceMsg(trace_ctx, "\tframe_crop_left_offset = %d\n", p->frame_crop_left_offset);
1486     va_TraceMsg(trace_ctx, "\tframe_crop_right_offset = %d\n", p->frame_crop_right_offset);
1487     va_TraceMsg(trace_ctx, "\tframe_crop_top_offset = %d\n", p->frame_crop_top_offset);
1488     va_TraceMsg(trace_ctx, "\tframe_crop_bottom_offset = %d\n", p->frame_crop_bottom_offset);
1489     va_TraceMsg(trace_ctx, "\tvui_parameters_present_flag = %d\n", p->vui_parameters_present_flag);
1490     va_TraceMsg(trace_ctx, "\taspect_ratio_info_present_flag = %d\n", p->vui_fields.bits.aspect_ratio_info_present_flag);
1491     va_TraceMsg(trace_ctx, "\ttiming_info_present_flag = %d\n", p->vui_fields.bits.timing_info_present_flag);
1492     va_TraceMsg(trace_ctx, "\tbitstream_restriction_flag = %d\n", p->vui_fields.bits.bitstream_restriction_flag);
1493     va_TraceMsg(trace_ctx, "\tlog2_max_mv_length_horizontal = %d\n", p->vui_fields.bits.log2_max_mv_length_horizontal);
1494     va_TraceMsg(trace_ctx, "\tlog2_max_mv_length_vertical = %d\n", p->vui_fields.bits.log2_max_mv_length_vertical);
1495     va_TraceMsg(trace_ctx, "\taspect_ratio_idc = %d\n", p->aspect_ratio_idc);
1496     va_TraceMsg(trace_ctx, "\tsar_width = %d\n", p->sar_width);
1497     va_TraceMsg(trace_ctx, "\tsar_height = %d\n", p->sar_height);
1498     va_TraceMsg(trace_ctx, "\tnum_units_in_tick = %d\n", p->num_units_in_tick);
1499     va_TraceMsg(trace_ctx, "\ttime_scale = %d\n", p->time_scale);
1500
1501     va_TraceMsg(trace_ctx, NULL);
1502
1503     /* start a new sequce, coded log file can be truncated */
1504     trace_ctx->trace_sequence_start = 1;
1505
1506     return;
1507 }
1508
1509
1510 static void va_TraceVAEncPictureParameterBufferH264(
1511     VADisplay dpy,
1512     VAContextID context,
1513     VABufferID buffer,
1514     VABufferType type,
1515     unsigned int size,
1516     unsigned int num_elements,
1517     void *data)
1518 {
1519     VAEncPictureParameterBufferH264 *p = (VAEncPictureParameterBufferH264 *)data;
1520     DPY2TRACECTX(dpy);
1521     int i;
1522
1523     va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferH264\n");
1524
1525     va_TraceMsg(trace_ctx, "\tCurrPic.picture_id = 0x%08x\n", p->CurrPic.picture_id);
1526     va_TraceMsg(trace_ctx, "\tCurrPic.frame_idx = %d\n", p->CurrPic.frame_idx);
1527     va_TraceMsg(trace_ctx, "\tCurrPic.flags = %d\n", p->CurrPic.flags);
1528     va_TraceMsg(trace_ctx, "\tCurrPic.TopFieldOrderCnt = %d\n", p->CurrPic.TopFieldOrderCnt);
1529     va_TraceMsg(trace_ctx, "\tCurrPic.BottomFieldOrderCnt = %d\n", p->CurrPic.BottomFieldOrderCnt);
1530     va_TraceMsg(trace_ctx, "\tReferenceFrames (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n");
1531     for (i = 0; i < 16; i++)
1532     {
1533         if ((p->ReferenceFrames[i].picture_id != VA_INVALID_SURFACE) &&
1534             ((p->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID) == 0)) {
1535             va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08x\n",
1536                         p->ReferenceFrames[i].TopFieldOrderCnt,
1537                         p->ReferenceFrames[i].BottomFieldOrderCnt,
1538                         p->ReferenceFrames[i].picture_id,
1539                         p->ReferenceFrames[i].frame_idx,
1540                         p->ReferenceFrames[i].flags
1541                         );
1542         } else
1543             break;
1544     }
1545     va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf);
1546     va_TraceMsg(trace_ctx, "\tpic_parameter_set_id = %d\n", p->pic_parameter_set_id);
1547     va_TraceMsg(trace_ctx, "\tseq_parameter_set_id = %d\n", p->seq_parameter_set_id);
1548     va_TraceMsg(trace_ctx, "\tlast_picture = 0x%08x\n", p->last_picture);
1549     va_TraceMsg(trace_ctx, "\tframe_num = %d\n", p->frame_num);
1550     va_TraceMsg(trace_ctx, "\tpic_init_qp = %d\n", p->pic_init_qp);
1551     va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1);
1552     va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1);
1553     va_TraceMsg(trace_ctx, "\tchroma_qp_index_offset = %d\n", p->chroma_qp_index_offset);
1554     va_TraceMsg(trace_ctx, "\tsecond_chroma_qp_index_offset = %d\n", p->second_chroma_qp_index_offset);
1555     va_TraceMsg(trace_ctx, "\tpic_fields = 0x%03x\n", p->pic_fields.value);
1556     va_TraceMsg(trace_ctx, "\tidr_pic_flag = %d\n", p->pic_fields.bits.idr_pic_flag);
1557     va_TraceMsg(trace_ctx, "\treference_pic_flag = %d\n", p->pic_fields.bits.reference_pic_flag);
1558     va_TraceMsg(trace_ctx, "\tentropy_coding_mode_flag = %d\n", p->pic_fields.bits.entropy_coding_mode_flag);
1559     va_TraceMsg(trace_ctx, "\tweighted_pred_flag = %d\n", p->pic_fields.bits.weighted_pred_flag);
1560     va_TraceMsg(trace_ctx, "\tweighted_bipred_idc = %d\n", p->pic_fields.bits.weighted_bipred_idc);
1561     va_TraceMsg(trace_ctx, "\tconstrained_intra_pred_flag = %d\n", p->pic_fields.bits.constrained_intra_pred_flag);
1562     va_TraceMsg(trace_ctx, "\ttransform_8x8_mode_flag = %d\n", p->pic_fields.bits.transform_8x8_mode_flag);
1563     va_TraceMsg(trace_ctx, "\tdeblocking_filter_control_present_flag = %d\n", p->pic_fields.bits.deblocking_filter_control_present_flag);
1564     va_TraceMsg(trace_ctx, "\tredundant_pic_cnt_present_flag = %d\n", p->pic_fields.bits.redundant_pic_cnt_present_flag);
1565     va_TraceMsg(trace_ctx, "\tpic_order_present_flag = %d\n", p->pic_fields.bits.pic_order_present_flag);
1566     va_TraceMsg(trace_ctx, "\tpic_scaling_matrix_present_flag = %d\n", p->pic_fields.bits.pic_scaling_matrix_present_flag);
1567
1568     va_TraceMsg(trace_ctx, NULL);
1569
1570     trace_ctx->trace_codedbuf =  p->coded_buf;
1571
1572     return;
1573 }
1574
1575 static void va_TraceVAEncSliceParameterBuffer(
1576     VADisplay dpy,
1577     VAContextID context,
1578     VABufferID buffer,
1579     VABufferType type,
1580     unsigned int size,
1581     unsigned int num_elements,
1582     void *data)
1583 {
1584     VAEncSliceParameterBuffer* p = (VAEncSliceParameterBuffer*)data;
1585     DPY2TRACECTX(dpy);
1586     
1587     va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBuffer\n");
1588     
1589     va_TraceMsg(trace_ctx, "\tstart_row_number = %d\n", p->start_row_number);
1590     va_TraceMsg(trace_ctx, "\tslice_height = %d\n", p->slice_height);
1591     va_TraceMsg(trace_ctx, "\tslice_flags.is_intra = %d\n", p->slice_flags.bits.is_intra);
1592     va_TraceMsg(trace_ctx, "\tslice_flags.disable_deblocking_filter_idc = %d\n", p->slice_flags.bits.disable_deblocking_filter_idc);
1593     va_TraceMsg(trace_ctx, "\tslice_flags.uses_long_term_ref = %d\n", p->slice_flags.bits.uses_long_term_ref);
1594     va_TraceMsg(trace_ctx, "\tslice_flags.is_long_term_ref = %d\n", p->slice_flags.bits.is_long_term_ref);
1595     va_TraceMsg(trace_ctx, NULL);
1596
1597     return;
1598 }
1599
1600 static void va_TraceVAEncSliceParameterBufferH264(
1601     VADisplay dpy,
1602     VAContextID context,
1603     VABufferID buffer,
1604     VABufferType type,
1605     unsigned int size,
1606     unsigned int num_elements,
1607     void *data)
1608 {
1609     VAEncSliceParameterBufferH264* p = (VAEncSliceParameterBufferH264*)data;
1610     DPY2TRACECTX(dpy);
1611     int i;
1612
1613     if (!p)
1614         return;
1615     
1616     va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBufferH264\n");
1617     va_TraceMsg(trace_ctx, "\tmacroblock_address = %d\n", p->macroblock_address);
1618     va_TraceMsg(trace_ctx, "\tnum_macroblocks = %d\n", p->num_macroblocks);
1619     va_TraceMsg(trace_ctx, "\tmacroblock_info = %08x\n", p->macroblock_info);
1620     va_TraceMsg(trace_ctx, "\tslice_type = %d\n", p->slice_type);
1621     va_TraceMsg(trace_ctx, "\tpic_parameter_set_id = %d\n", p->pic_parameter_set_id);
1622     va_TraceMsg(trace_ctx, "\tidr_pic_id = %d\n", p->idr_pic_id);
1623     va_TraceMsg(trace_ctx, "\tpic_order_cnt_lsb = %d\n", p->pic_order_cnt_lsb);
1624     va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt_bottom = %d\n", p->delta_pic_order_cnt_bottom);
1625     va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt[0] = %d\n", p->delta_pic_order_cnt[0]);
1626     va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt[1] = %d\n", p->delta_pic_order_cnt[1]);
1627     va_TraceMsg(trace_ctx, "\tdirect_spatial_mv_pred_flag = %d\n", p->direct_spatial_mv_pred_flag);
1628     va_TraceMsg(trace_ctx, "\tnum_ref_idx_active_override_flag = %d\n", p->num_ref_idx_active_override_flag);
1629     va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1);
1630     va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2);
1631
1632     va_TraceMsg(trace_ctx, "\tRefPicList0 (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n");
1633
1634     
1635     
1636     for (i = 0; i < 32; i++) {
1637         if ((p->RefPicList0[i].picture_id != VA_INVALID_SURFACE) &&
1638             ((p->RefPicList0[i].flags & VA_PICTURE_H264_INVALID) == 0))
1639             va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08x\n",
1640                         p->RefPicList0[i].TopFieldOrderCnt,
1641                         p->RefPicList0[i].BottomFieldOrderCnt,
1642                         p->RefPicList0[i].picture_id,
1643                         p->RefPicList0[i].frame_idx,
1644                         p->RefPicList0[i].flags);
1645         else
1646             break;
1647     }
1648     
1649     va_TraceMsg(trace_ctx, "\tRefPicList1 (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n");
1650     for (i = 0; i < 32; i++) {
1651         if ((p->RefPicList1[i].picture_id != VA_INVALID_SURFACE) &&
1652             ((p->RefPicList1[i].flags & VA_PICTURE_H264_INVALID) == 0))
1653             va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08d\n",
1654                         p->RefPicList1[i].TopFieldOrderCnt,
1655                         p->RefPicList1[i].BottomFieldOrderCnt,
1656                         p->RefPicList1[i].picture_id,
1657                         p->RefPicList1[i].frame_idx,
1658                         p->RefPicList1[i].flags
1659                         );
1660         else
1661             break;
1662     }
1663     
1664     va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom);
1665     va_TraceMsg(trace_ctx, "\tchroma_log2_weight_denom = %d\n", p->chroma_log2_weight_denom);
1666     va_TraceMsg(trace_ctx, "\tluma_weight_l0_flag = %d\n", p->luma_weight_l0_flag);
1667     if (p->luma_weight_l0_flag) {
1668         for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) {
1669             va_TraceMsg(trace_ctx, "\t%d ", p->luma_weight_l0[i]);
1670             va_TraceMsg(trace_ctx, "\t%d ", p->luma_offset_l0[i]);
1671         }
1672         if (p->num_ref_idx_l0_active_minus1 >=0)
1673             va_TraceMsg(trace_ctx, "\n");
1674     }
1675
1676     va_TraceMsg(trace_ctx, "\tchroma_weight_l0_flag = %d\n", p->chroma_weight_l0_flag);
1677     if (p->chroma_weight_l0_flag) {
1678         for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) {
1679             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l0[i][0]);
1680             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l0[i][0]);
1681             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l0[i][1]);
1682             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l0[i][1]);
1683         }
1684         if (p->num_ref_idx_l0_active_minus1 >= 0)
1685             va_TraceMsg(trace_ctx, "\n");
1686     }
1687
1688     va_TraceMsg(trace_ctx, "\tluma_weight_l1_flag = %d\n", p->luma_weight_l1_flag);
1689     if (p->luma_weight_l1_flag) {
1690         for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) {
1691             va_TraceMsg(trace_ctx, "\t\t%d ", p->luma_weight_l1[i]);
1692             va_TraceMsg(trace_ctx, "\t\t%d ", p->luma_offset_l1[i]);
1693         }
1694         if (p->num_ref_idx_l1_active_minus1 >= 0)
1695             va_TraceMsg(trace_ctx, "\n");
1696     }
1697
1698     va_TraceMsg(trace_ctx, "\tchroma_weight_l1_flag = %d\n", p->chroma_weight_l1_flag);
1699     if (p->chroma_weight_l1_flag && p->num_ref_idx_l1_active_minus1 < 32) {
1700         for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) {
1701             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l1[i][0]);
1702             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l1[i][0]);
1703             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l1[i][1]);
1704             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l1[i][1]);
1705         }
1706         if ( p->num_ref_idx_l1_active_minus1 >=0)
1707             va_TraceMsg(trace_ctx, "\n");
1708     }
1709     va_TraceMsg(trace_ctx, NULL);
1710
1711     va_TraceMsg(trace_ctx, "\tcabac_init_idc = %d\n", p->cabac_init_idc);
1712     va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta);
1713     va_TraceMsg(trace_ctx, "\tdisable_deblocking_filter_idc = %d\n", p->disable_deblocking_filter_idc);
1714     va_TraceMsg(trace_ctx, "\tslice_alpha_c0_offset_div2 = %d\n", p->slice_alpha_c0_offset_div2);
1715     va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2);
1716     va_TraceMsg(trace_ctx, NULL);
1717
1718     return;
1719 }
1720
1721
1722 static void va_TraceVAEncPackedHeaderParameterBufferType(
1723     VADisplay dpy,
1724     VAContextID context,
1725     VABufferID buffer,
1726     VABufferType type,
1727     unsigned int size,
1728     unsigned int num_elements,
1729     void *data)
1730 {
1731     VAEncPackedHeaderParameterBuffer* p = (VAEncPackedHeaderParameterBuffer*)data;
1732     DPY2TRACECTX(dpy);
1733     int i;
1734
1735     if (!p)
1736         return;
1737     va_TraceMsg(trace_ctx, "\t--VAEncPackedHeaderParameterBuffer\n");
1738     va_TraceMsg(trace_ctx, "\ttype = 0x%08x\n", p->type);
1739     va_TraceMsg(trace_ctx, "\tbit_length = %d\n", p->bit_length);
1740     va_TraceMsg(trace_ctx, "\thas_emulation_bytes = %d\n", p->has_emulation_bytes);
1741     va_TraceMsg(trace_ctx, NULL);
1742
1743     return;
1744 }
1745
1746 static void va_TraceVAEncMiscParameterBuffer(
1747     VADisplay dpy,
1748     VAContextID context,
1749     VABufferID buffer,
1750     VABufferType type,
1751     unsigned int size,
1752     unsigned int num_elements,
1753     void *data)
1754 {
1755     VAEncMiscParameterBuffer* tmp = (VAEncMiscParameterBuffer*)data;
1756     DPY2TRACECTX(dpy);
1757     
1758     switch (tmp->type) {
1759     case VAEncMiscParameterTypeFrameRate:
1760     {
1761         VAEncMiscParameterFrameRate *p = (VAEncMiscParameterFrameRate *)tmp->data;
1762         va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterFrameRate\n");
1763         va_TraceMsg(trace_ctx, "\tframerate = %d\n", p->framerate);
1764         
1765         break;
1766     }
1767     case VAEncMiscParameterTypeRateControl:
1768     {
1769         VAEncMiscParameterRateControl *p = (VAEncMiscParameterRateControl *)tmp->data;
1770
1771         va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterRateControl\n");
1772         va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
1773         va_TraceMsg(trace_ctx, "\ttarget_percentage = %d\n", p->target_percentage);
1774         va_TraceMsg(trace_ctx, "\twindow_size = %d\n", p->window_size);
1775         va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp);
1776         va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
1777         va_TraceMsg(trace_ctx, "\tbasic_unit_size = %d\n", p->basic_unit_size);
1778         va_TraceMsg(trace_ctx, "\trc_flags.reset = %d \n", p->rc_flags.bits.reset);
1779         va_TraceMsg(trace_ctx, "\trc_flags.disable_frame_skip = %d\n", p->rc_flags.bits.disable_frame_skip);
1780         va_TraceMsg(trace_ctx, "\trc_flags.disable_bit_stuffing = %d\n", p->rc_flags.bits.disable_bit_stuffing);
1781         break;
1782     }
1783     case VAEncMiscParameterTypeMaxSliceSize:
1784     {
1785         VAEncMiscParameterMaxSliceSize *p = (VAEncMiscParameterMaxSliceSize *)tmp->data;
1786         
1787         va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterTypeMaxSliceSize\n");
1788         va_TraceMsg(trace_ctx, "\tmax_slice_size = %d\n", p->max_slice_size);
1789         break;
1790     }
1791     case VAEncMiscParameterTypeAIR:
1792     {
1793         VAEncMiscParameterAIR *p = (VAEncMiscParameterAIR *)tmp->data;
1794         
1795         va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterAIR\n");
1796         va_TraceMsg(trace_ctx, "\tair_num_mbs = %d\n", p->air_num_mbs);
1797         va_TraceMsg(trace_ctx, "\tair_threshold = %d\n", p->air_threshold);
1798         va_TraceMsg(trace_ctx, "\tair_auto = %d\n", p->air_auto);
1799         break;
1800     }
1801     case VAEncMiscParameterTypeHRD:
1802     {
1803         VAEncMiscParameterHRD *p = (VAEncMiscParameterHRD *)tmp->data;
1804
1805         va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterHRD\n");
1806         va_TraceMsg(trace_ctx, "\tinitial_buffer_fullness = %d\n", p->initial_buffer_fullness);
1807         va_TraceMsg(trace_ctx, "\tbuffer_size = %d\n", p->buffer_size);
1808         break;
1809     }
1810     default:
1811         va_TraceMsg(trace_ctx, "Unknown VAEncMiscParameterBuffer(type = %d):\n", tmp->type);
1812         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
1813         break;
1814     }
1815     va_TraceMsg(trace_ctx, NULL);
1816
1817     return;
1818 }
1819
1820
1821 static void va_TraceVAPictureParameterBufferVC1(
1822     VADisplay dpy,
1823     VAContextID context,
1824     VABufferID buffer,
1825     VABufferType type,
1826     unsigned int size,
1827     unsigned int num_elements,
1828     void *data
1829 )
1830 {
1831     VAPictureParameterBufferVC1* p = (VAPictureParameterBufferVC1*)data;
1832     DPY2TRACECTX(dpy);
1833     
1834     va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVC1\n");
1835     
1836     va_TraceMsg(trace_ctx, "\tforward_reference_picture = 0x%08x\n", p->forward_reference_picture);
1837     va_TraceMsg(trace_ctx, "\tbackward_reference_picture = 0x%08x\n", p->backward_reference_picture);
1838     va_TraceMsg(trace_ctx, "\tinloop_decoded_picture = 0x%08x\n", p->inloop_decoded_picture);
1839     
1840     va_TraceMsg(trace_ctx, "\tpulldown = %d\n", p->sequence_fields.bits.pulldown);
1841     va_TraceMsg(trace_ctx, "\tinterlace = %d\n", p->sequence_fields.bits.interlace);
1842     va_TraceMsg(trace_ctx, "\ttfcntrflag = %d\n", p->sequence_fields.bits.tfcntrflag);
1843     va_TraceMsg(trace_ctx, "\tfinterpflag = %d\n", p->sequence_fields.bits.finterpflag);
1844     va_TraceMsg(trace_ctx, "\tpsf = %d\n", p->sequence_fields.bits.psf);
1845     va_TraceMsg(trace_ctx, "\tmultires = %d\n", p->sequence_fields.bits.multires);
1846     va_TraceMsg(trace_ctx, "\toverlap = %d\n", p->sequence_fields.bits.overlap);
1847     va_TraceMsg(trace_ctx, "\tsyncmarker = %d\n", p->sequence_fields.bits.syncmarker);
1848     va_TraceMsg(trace_ctx, "\trangered = %d\n", p->sequence_fields.bits.rangered);
1849     va_TraceMsg(trace_ctx, "\tmax_b_frames = %d\n", p->sequence_fields.bits.max_b_frames);
1850     va_TraceMsg(trace_ctx, "\tprofile = %d\n", p->sequence_fields.bits.profile);
1851     va_TraceMsg(trace_ctx, "\tcoded_width = %d\n", p->coded_width);
1852     va_TraceMsg(trace_ctx, "\tcoded_height = %d\n", p->coded_height);
1853     va_TraceMsg(trace_ctx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry);
1854     va_TraceMsg(trace_ctx, "\tbroken_link = %d\n", p->entrypoint_fields.bits.broken_link);
1855     va_TraceMsg(trace_ctx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry);
1856     va_TraceMsg(trace_ctx, "\tpanscan_flag = %d\n", p->entrypoint_fields.bits.panscan_flag);
1857     va_TraceMsg(trace_ctx, "\tloopfilter = %d\n", p->entrypoint_fields.bits.loopfilter);
1858     va_TraceMsg(trace_ctx, "\tconditional_overlap_flag = %d\n", p->conditional_overlap_flag);
1859     va_TraceMsg(trace_ctx, "\tfast_uvmc_flag = %d\n", p->fast_uvmc_flag);
1860     va_TraceMsg(trace_ctx, "\trange_mapping_luma_flag = %d\n", p->range_mapping_fields.bits.luma_flag);
1861     va_TraceMsg(trace_ctx, "\trange_mapping_luma = %d\n", p->range_mapping_fields.bits.luma);
1862     va_TraceMsg(trace_ctx, "\trange_mapping_chroma_flag = %d\n", p->range_mapping_fields.bits.chroma_flag);
1863     va_TraceMsg(trace_ctx, "\trange_mapping_chroma = %d\n", p->range_mapping_fields.bits.chroma);
1864     va_TraceMsg(trace_ctx, "\tb_picture_fraction = %d\n", p->b_picture_fraction);
1865     va_TraceMsg(trace_ctx, "\tcbp_table = %d\n", p->cbp_table);
1866     va_TraceMsg(trace_ctx, "\tmb_mode_table = %d\n", p->mb_mode_table);
1867     va_TraceMsg(trace_ctx, "\trange_reduction_frame = %d\n", p->range_reduction_frame);
1868     va_TraceMsg(trace_ctx, "\trounding_control = %d\n", p->rounding_control);
1869     va_TraceMsg(trace_ctx, "\tpost_processing = %d\n", p->post_processing);
1870     va_TraceMsg(trace_ctx, "\tpicture_resolution_index = %d\n", p->picture_resolution_index);
1871     va_TraceMsg(trace_ctx, "\tluma_scale = %d\n", p->luma_scale);
1872     va_TraceMsg(trace_ctx, "\tluma_shift = %d\n", p->luma_shift);
1873     va_TraceMsg(trace_ctx, "\tpicture_type = %d\n", p->picture_fields.bits.picture_type);
1874     va_TraceMsg(trace_ctx, "\tframe_coding_mode = %d\n", p->picture_fields.bits.frame_coding_mode);
1875     va_TraceMsg(trace_ctx, "\ttop_field_first = %d\n", p->picture_fields.bits.top_field_first);
1876     va_TraceMsg(trace_ctx, "\tis_first_field = %d\n", p->picture_fields.bits.is_first_field);
1877     va_TraceMsg(trace_ctx, "\tintensity_compensation = %d\n", p->picture_fields.bits.intensity_compensation);
1878     va_TraceMsg(trace_ctx, "\tmv_type_mb = %d\n", p->raw_coding.flags.mv_type_mb);
1879     va_TraceMsg(trace_ctx, "\tdirect_mb = %d\n", p->raw_coding.flags.direct_mb);
1880     va_TraceMsg(trace_ctx, "\tskip_mb = %d\n", p->raw_coding.flags.skip_mb);
1881     va_TraceMsg(trace_ctx, "\tfield_tx = %d\n", p->raw_coding.flags.field_tx);
1882     va_TraceMsg(trace_ctx, "\tforward_mb = %d\n", p->raw_coding.flags.forward_mb);
1883     va_TraceMsg(trace_ctx, "\tac_pred = %d\n", p->raw_coding.flags.ac_pred);
1884     va_TraceMsg(trace_ctx, "\toverflags = %d\n", p->raw_coding.flags.overflags);
1885     va_TraceMsg(trace_ctx, "\tbp_mv_type_mb = %d\n", p->bitplane_present.flags.bp_mv_type_mb);
1886     va_TraceMsg(trace_ctx, "\tbp_direct_mb = %d\n", p->bitplane_present.flags.bp_direct_mb);
1887     va_TraceMsg(trace_ctx, "\tbp_skip_mb = %d\n", p->bitplane_present.flags.bp_skip_mb);
1888     va_TraceMsg(trace_ctx, "\tbp_field_tx = %d\n", p->bitplane_present.flags.bp_field_tx);
1889     va_TraceMsg(trace_ctx, "\tbp_forward_mb = %d\n", p->bitplane_present.flags.bp_forward_mb);
1890     va_TraceMsg(trace_ctx, "\tbp_ac_pred = %d\n", p->bitplane_present.flags.bp_ac_pred);
1891     va_TraceMsg(trace_ctx, "\tbp_overflags = %d\n", p->bitplane_present.flags.bp_overflags);
1892     va_TraceMsg(trace_ctx, "\treference_distance_flag = %d\n", p->reference_fields.bits.reference_distance_flag);
1893     va_TraceMsg(trace_ctx, "\treference_distance = %d\n", p->reference_fields.bits.reference_distance);
1894     va_TraceMsg(trace_ctx, "\tnum_reference_pictures = %d\n", p->reference_fields.bits.num_reference_pictures);
1895     va_TraceMsg(trace_ctx, "\treference_field_pic_indicator = %d\n", p->reference_fields.bits.reference_field_pic_indicator);
1896     va_TraceMsg(trace_ctx, "\tmv_mode = %d\n", p->mv_fields.bits.mv_mode);
1897     va_TraceMsg(trace_ctx, "\tmv_mode2 = %d\n", p->mv_fields.bits.mv_mode2);
1898     va_TraceMsg(trace_ctx, "\tmv_table = %d\n", p->mv_fields.bits.mv_table);
1899     va_TraceMsg(trace_ctx, "\ttwo_mv_block_pattern_table = %d\n", p->mv_fields.bits.two_mv_block_pattern_table);
1900     va_TraceMsg(trace_ctx, "\tfour_mv_switch = %d\n", p->mv_fields.bits.four_mv_switch);
1901     va_TraceMsg(trace_ctx, "\tfour_mv_block_pattern_table = %d\n", p->mv_fields.bits.four_mv_block_pattern_table);
1902     va_TraceMsg(trace_ctx, "\textended_mv_flag = %d\n", p->mv_fields.bits.extended_mv_flag);
1903     va_TraceMsg(trace_ctx, "\textended_mv_range = %d\n", p->mv_fields.bits.extended_mv_range);
1904     va_TraceMsg(trace_ctx, "\textended_dmv_flag = %d\n", p->mv_fields.bits.extended_dmv_flag);
1905     va_TraceMsg(trace_ctx, "\textended_dmv_range = %d\n", p->mv_fields.bits.extended_dmv_range);
1906     va_TraceMsg(trace_ctx, "\tdquant = %d\n", p->pic_quantizer_fields.bits.dquant);
1907     va_TraceMsg(trace_ctx, "\tquantizer = %d\n", p->pic_quantizer_fields.bits.quantizer);
1908     va_TraceMsg(trace_ctx, "\thalf_qp = %d\n", p->pic_quantizer_fields.bits.half_qp);
1909     va_TraceMsg(trace_ctx, "\tpic_quantizer_scale = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_scale);
1910     va_TraceMsg(trace_ctx, "\tpic_quantizer_type = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_type);
1911     va_TraceMsg(trace_ctx, "\tdq_frame = %d\n", p->pic_quantizer_fields.bits.dq_frame);
1912     va_TraceMsg(trace_ctx, "\tdq_profile = %d\n", p->pic_quantizer_fields.bits.dq_profile);
1913     va_TraceMsg(trace_ctx, "\tdq_sb_edge = %d\n", p->pic_quantizer_fields.bits.dq_sb_edge);
1914     va_TraceMsg(trace_ctx, "\tdq_db_edge = %d\n", p->pic_quantizer_fields.bits.dq_db_edge);
1915     va_TraceMsg(trace_ctx, "\tdq_binary_level = %d\n", p->pic_quantizer_fields.bits.dq_binary_level);
1916     va_TraceMsg(trace_ctx, "\talt_pic_quantizer = %d\n", p->pic_quantizer_fields.bits.alt_pic_quantizer);
1917     va_TraceMsg(trace_ctx, "\tvariable_sized_transform_flag = %d\n", p->transform_fields.bits.variable_sized_transform_flag);
1918     va_TraceMsg(trace_ctx, "\tmb_level_transform_type_flag = %d\n", p->transform_fields.bits.mb_level_transform_type_flag);
1919     va_TraceMsg(trace_ctx, "\tframe_level_transform_type = %d\n", p->transform_fields.bits.frame_level_transform_type);
1920     va_TraceMsg(trace_ctx, "\ttransform_ac_codingset_idx1 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx1);
1921     va_TraceMsg(trace_ctx, "\ttransform_ac_codingset_idx2 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx2);
1922     va_TraceMsg(trace_ctx, "\tintra_transform_dc_table = %d\n", p->transform_fields.bits.intra_transform_dc_table);
1923     va_TraceMsg(trace_ctx, NULL);
1924 }
1925
1926 static void va_TraceVASliceParameterBufferVC1(
1927     VADisplay dpy,
1928     VAContextID context,
1929     VABufferID buffer,
1930     VABufferType type,
1931     unsigned int size,
1932     unsigned int num_elements,
1933     void* data
1934 )
1935 {
1936     VASliceParameterBufferVC1 *p = (VASliceParameterBufferVC1*)data;
1937     DPY2TRACECTX(dpy);
1938
1939     trace_ctx->trace_slice_no++;
1940     trace_ctx->trace_slice_size = p->slice_data_size;
1941
1942     va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVC1\n");
1943     va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size);
1944     va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset);
1945     va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag);
1946     va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset);
1947     va_TraceMsg(trace_ctx, "\tslice_vertical_position = %d\n", p->slice_vertical_position);
1948     va_TraceMsg(trace_ctx, NULL);
1949 }
1950
1951 void va_TraceBeginPicture(
1952     VADisplay dpy,
1953     VAContextID context,
1954     VASurfaceID render_target
1955 )
1956 {
1957     DPY2TRACECTX(dpy);
1958
1959     TRACE_FUNCNAME(idx);
1960
1961     va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
1962     va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", render_target);
1963     va_TraceMsg(trace_ctx, "\tframe_count  = #%d\n", trace_ctx->trace_frame_no);
1964     va_TraceMsg(trace_ctx, NULL);
1965
1966     trace_ctx->trace_rendertarget = render_target; /* for surface data dump after vaEndPicture */
1967
1968     trace_ctx->trace_frame_no++;
1969     trace_ctx->trace_slice_no = 0;
1970 }
1971
1972 static void va_TraceMPEG2Buf(
1973     VADisplay dpy,
1974     VAContextID context,
1975     VABufferID buffer,
1976     VABufferType type,
1977     unsigned int size,
1978     unsigned int num_elements,
1979     void *pbuf
1980 )
1981 {
1982     switch (type) {
1983     case VAPictureParameterBufferType:
1984         va_TraceVAPictureParameterBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
1985         break;
1986     case VAIQMatrixBufferType:
1987         va_TraceVAIQMatrixBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
1988         break;
1989     case VABitPlaneBufferType:
1990         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1991         break;
1992     case VASliceGroupMapBufferType:
1993         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1994         break;
1995     case VASliceParameterBufferType:
1996         va_TraceVASliceParameterBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
1997         break;
1998     case VASliceDataBufferType:
1999         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2000         break;
2001     case VAMacroblockParameterBufferType:
2002         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2003         break;
2004     case VAResidualDataBufferType:
2005         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2006         break;
2007     case VADeblockingParameterBufferType:
2008         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2009         break;
2010     case VAImageBufferType:
2011         break;
2012     case VAProtectedSliceDataBufferType:
2013         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2014         break;
2015     case VAEncCodedBufferType:
2016         break;
2017     case VAEncSequenceParameterBufferType:
2018         break;
2019     case VAEncPictureParameterBufferType:
2020         break;
2021     case VAEncSliceParameterBufferType:
2022         break;
2023     default:
2024         break;
2025     }
2026 }
2027
2028 static void va_TraceVAEncSequenceParameterBufferH263(
2029     VADisplay dpy,
2030     VAContextID context,
2031     VABufferID buffer,
2032     VABufferType type,
2033     unsigned int size,
2034     unsigned int num_elements,
2035     void *data)
2036 {
2037     VAEncSequenceParameterBufferH263 *p = (VAEncSequenceParameterBufferH263 *)data;
2038     DPY2TRACECTX(dpy);
2039     
2040     va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferH263\n");
2041     
2042     va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
2043     va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
2044     va_TraceMsg(trace_ctx, "\tframe_rate = %d\n", p->frame_rate);
2045     va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp);
2046     va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
2047     va_TraceMsg(trace_ctx, NULL);
2048
2049     /* start a new sequce, coded log file can be truncated */
2050     trace_ctx->trace_sequence_start = 1;
2051
2052     return;
2053 }
2054
2055
2056 static void va_TraceVAEncPictureParameterBufferH263(
2057     VADisplay dpy,
2058     VAContextID context,
2059     VABufferID buffer,
2060     VABufferType type,
2061     unsigned int size,
2062     unsigned int num_elements,
2063     void *data)
2064 {
2065     VAEncPictureParameterBufferH263 *p = (VAEncPictureParameterBufferH263 *)data;
2066     DPY2TRACECTX(dpy);
2067     
2068     va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferH263\n");
2069     va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture);
2070     va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
2071     va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf);
2072     va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width);
2073     va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height);
2074     va_TraceMsg(trace_ctx, "\tpicture_type = 0x%08x\n", p->picture_type);
2075     va_TraceMsg(trace_ctx, NULL);
2076
2077     trace_ctx->trace_codedbuf =  p->coded_buf;
2078     
2079     return;
2080 }
2081
2082 static void va_TraceVAEncPictureParameterBufferJPEG(
2083     VADisplay dpy,
2084     VAContextID context,
2085     VABufferID buffer,
2086     VABufferType type,
2087     unsigned int size,
2088     unsigned int num_elements,
2089     void *data)
2090 {
2091     VAEncPictureParameterBufferJPEG *p = (VAEncPictureParameterBufferJPEG *)data;
2092     int i;
2093     
2094     DPY2TRACECTX(dpy);
2095     
2096     va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferJPEG\n");
2097     va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
2098     va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf);
2099     va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width);
2100     va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height);
2101
2102     va_TraceMsg(trace_ctx, NULL);
2103
2104     trace_ctx->trace_codedbuf =  p->coded_buf;
2105     
2106     return;
2107 }
2108
2109 static void va_TraceVAEncQMatrixBufferJPEG(
2110     VADisplay dpy,
2111     VAContextID context,
2112     VABufferID buffer,
2113     VABufferType type,
2114     unsigned int size,
2115     unsigned int num_elements,
2116     void *data)
2117 {
2118     VAQMatrixBufferJPEG *p = (VAQMatrixBufferJPEG *)data;
2119     DPY2TRACECTX(dpy);
2120     
2121     va_TraceMsg(trace_ctx, "\t--VAQMatrixBufferJPEG\n");
2122     va_TraceMsg(trace_ctx, "\tload_lum_quantiser_matrix = %d", p->load_lum_quantiser_matrix);
2123     if (p->load_lum_quantiser_matrix) {
2124         int i;
2125         for (i = 0; i < 64; i++) {
2126             if ((i % 8) == 0)
2127                 va_TraceMsg(trace_ctx, "\n\t");
2128             va_TraceMsg(trace_ctx, "\t0x%02x", p->lum_quantiser_matrix[i]);
2129         }
2130         va_TraceMsg(trace_ctx, "\n");
2131     }
2132     va_TraceMsg(trace_ctx, "\tload_chroma_quantiser_matrix = %08x\n", p->load_chroma_quantiser_matrix);
2133     if (p->load_chroma_quantiser_matrix) {
2134         int i;
2135         for (i = 0; i < 64; i++) {
2136             if ((i % 8) == 0)
2137                 va_TraceMsg(trace_ctx, "\n\t");
2138             va_TraceMsg(trace_ctx, "\t0x%02x", p->chroma_quantiser_matrix[i]);
2139         }
2140         va_TraceMsg(trace_ctx, "\n");
2141     }
2142     
2143     va_TraceMsg(trace_ctx, NULL);
2144     
2145     return;
2146 }
2147
2148 static void va_TraceH263Buf(
2149     VADisplay dpy,
2150     VAContextID context,
2151     VABufferID buffer,
2152     VABufferType type,
2153     unsigned int size,
2154     unsigned int num_elements,
2155     void *pbuf
2156 )
2157 {
2158     switch (type) {
2159     case VAPictureParameterBufferType:/* print MPEG4 buffer */
2160         va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2161         break;
2162     case VAIQMatrixBufferType:/* print MPEG4 buffer */
2163         va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2164         break;
2165     case VABitPlaneBufferType:/* print MPEG4 buffer */
2166         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2167         break;
2168     case VASliceGroupMapBufferType:
2169         break;
2170     case VASliceParameterBufferType:/* print MPEG4 buffer */
2171         va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2172         break;
2173     case VASliceDataBufferType:
2174         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2175         break;
2176     case VAMacroblockParameterBufferType:
2177         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2178         break;
2179     case VAResidualDataBufferType:
2180         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2181         break;
2182     case VADeblockingParameterBufferType:
2183         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2184         break;
2185     case VAImageBufferType:
2186         break;
2187     case VAProtectedSliceDataBufferType:
2188         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2189         break;
2190     case VAEncCodedBufferType:
2191         break;
2192     case VAEncSequenceParameterBufferType:
2193         va_TraceVAEncSequenceParameterBufferH263(dpy, context, buffer, type, size, num_elements, pbuf);
2194         break;
2195     case VAEncPictureParameterBufferType:
2196         va_TraceVAEncPictureParameterBufferH263(dpy, context, buffer, type, size, num_elements, pbuf);
2197         break;
2198     case VAEncSliceParameterBufferType:
2199         va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2200         break;
2201     case VAEncPackedHeaderParameterBufferType:
2202         va_TraceVAEncPackedHeaderParameterBufferType(dpy, context, buffer, type, size, num_elements, pbuf);
2203         break;
2204     default:
2205         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2206         break;
2207     }
2208 }
2209
2210
2211 static void va_TraceJPEGBuf(
2212     VADisplay dpy,
2213     VAContextID context,
2214     VABufferID buffer,
2215     VABufferType type,
2216     unsigned int size,
2217     unsigned int num_elements,
2218     void *pbuf
2219 )
2220 {
2221     switch (type) {
2222     case VABitPlaneBufferType:
2223     case VASliceGroupMapBufferType:
2224     case VASliceDataBufferType:
2225     case VAMacroblockParameterBufferType:
2226     case VAResidualDataBufferType:
2227     case VADeblockingParameterBufferType:
2228     case VAImageBufferType:
2229     case VAProtectedSliceDataBufferType:
2230     case VAEncCodedBufferType:
2231     case VAEncSequenceParameterBufferType:
2232         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2233         break;
2234     case VAEncSliceParameterBufferType:
2235         va_TraceVAEncPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2236         break;
2237     case VAPictureParameterBufferType:
2238         va_TraceVAPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2239         break;
2240     case VAIQMatrixBufferType:
2241         va_TraceVAIQMatrixBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2242         break;
2243     case VASliceParameterBufferType:
2244         va_TraceVASliceParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2245         break;
2246     case VAHuffmanTableBufferType:
2247         va_TraceVAHuffmanTableBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2248         break;
2249     case VAEncPictureParameterBufferType:
2250         va_TraceVAEncPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2251         break;
2252     case VAQMatrixBufferType:
2253         va_TraceVAEncQMatrixBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2254         break;
2255     default:
2256         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2257         break;
2258     }
2259 }
2260
2261 static void va_TraceMPEG4Buf(
2262     VADisplay dpy,
2263     VAContextID context,
2264     VABufferID buffer,
2265     VABufferType type,
2266     unsigned int size,
2267     unsigned int num_elements,
2268     void *pbuf
2269 )
2270 {
2271     switch (type) {
2272     case VAPictureParameterBufferType:
2273         va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2274         break;
2275     case VAIQMatrixBufferType:
2276         va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2277         break;
2278     case VABitPlaneBufferType:
2279         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2280         break;
2281     case VASliceGroupMapBufferType:
2282         break;
2283     case VASliceParameterBufferType:
2284         va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2285         break;
2286     case VASliceDataBufferType:
2287         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2288         break;
2289     case VAMacroblockParameterBufferType:
2290         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2291         break;
2292     case VAResidualDataBufferType:
2293         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2294         break;
2295     case VADeblockingParameterBufferType:
2296         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2297         break;
2298     case VAImageBufferType:
2299         break;
2300     case VAProtectedSliceDataBufferType:
2301         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2302         break;
2303     case VAEncCodedBufferType:
2304         break;
2305     case VAEncSequenceParameterBufferType:
2306         va_TraceVAEncSequenceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2307         break;
2308     case VAEncPictureParameterBufferType:
2309         va_TraceVAEncPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2310         break;
2311     case VAEncSliceParameterBufferType:
2312         va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2313         break;
2314     default:
2315         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2316         break;
2317     }
2318 }
2319
2320
2321 static void va_TraceH264Buf(
2322     VADisplay dpy,
2323     VAContextID context,
2324     VABufferID buffer,
2325     VABufferType type,
2326     unsigned int size,
2327     unsigned int num_elements,
2328     void *pbuf
2329 )
2330 {
2331     DPY2TRACECTX(dpy);
2332     
2333     switch (type) {
2334     case VAPictureParameterBufferType:
2335         va_TraceVAPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2336         break;
2337     case VAIQMatrixBufferType:
2338         va_TraceVAIQMatrixBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2339         break;
2340     case VABitPlaneBufferType:
2341         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);        
2342         break;
2343     case VASliceGroupMapBufferType:
2344         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2345         break;
2346     case VASliceParameterBufferType:
2347         va_TraceVASliceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2348         break;
2349     case VASliceDataBufferType:
2350         va_TraceVABuffers(dpy, context, buffer, type, trace_ctx->trace_slice_size, num_elements, pbuf);
2351         break;
2352     case VAMacroblockParameterBufferType:
2353         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);        
2354         break;
2355     case VAResidualDataBufferType:
2356         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);        
2357         break;
2358     case VADeblockingParameterBufferType:
2359         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2360         break;
2361     case VAImageBufferType:
2362         break;
2363     case VAProtectedSliceDataBufferType:
2364         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2365         break;
2366     case VAEncCodedBufferType:
2367         break;
2368     case VAEncSequenceParameterBufferType:
2369         va_TraceVAEncSequenceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2370         break;
2371     case VAEncPictureParameterBufferType:
2372         va_TraceVAEncPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2373         break;
2374     case VAEncSliceParameterBufferType:
2375         if (size == sizeof(VAEncSliceParameterBuffer))
2376             va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2377         else
2378             va_TraceVAEncSliceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2379         break;
2380     case VAEncPackedHeaderParameterBufferType:
2381         va_TraceVAEncPackedHeaderParameterBufferType(dpy, context, buffer, type, size, num_elements, pbuf);
2382         break;
2383         
2384     case VAEncMiscParameterBufferType:
2385         va_TraceVAEncMiscParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2386         break;
2387     default:
2388         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2389         break;
2390     }
2391 }
2392
2393
2394 static void va_TraceVC1Buf(
2395     VADisplay dpy,
2396     VAContextID context,
2397     VABufferID buffer,
2398     VABufferType type,
2399     unsigned int size,
2400     unsigned int num_elements,
2401     void *pbuf
2402 )
2403 {
2404     DPY2TRACECTX(dpy);
2405
2406     switch (type) {
2407     case VAPictureParameterBufferType:
2408         va_TraceVAPictureParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf);
2409         break;
2410     case VAIQMatrixBufferType:
2411         break;
2412     case VABitPlaneBufferType:
2413         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2414         break;
2415     case VASliceGroupMapBufferType:
2416         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2417         break;
2418     case VASliceParameterBufferType:
2419         va_TraceVASliceParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf);
2420         break;
2421     case VASliceDataBufferType:
2422         va_TraceVABuffers(dpy, context, buffer, type, trace_ctx->trace_slice_size, num_elements, pbuf);
2423         break;
2424     case VAMacroblockParameterBufferType:
2425         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2426         break;
2427     case VAResidualDataBufferType:
2428         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2429         break;
2430     case VADeblockingParameterBufferType:
2431         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2432         break;
2433     case VAImageBufferType:
2434         break;
2435     case VAProtectedSliceDataBufferType:
2436         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2437         break;
2438     case VAEncCodedBufferType:
2439         break;
2440     case VAEncSequenceParameterBufferType:
2441         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2442         break;
2443     case VAEncPictureParameterBufferType:
2444         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2445         break;
2446     case VAEncSliceParameterBufferType:
2447         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2448         break;
2449     default:
2450         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2451         break;
2452     }
2453 }
2454
2455 void va_TraceRenderPicture(
2456     VADisplay dpy,
2457     VAContextID context,
2458     VABufferID *buffers,
2459     int num_buffers
2460 )
2461 {
2462     VABufferType type;
2463     unsigned int size;
2464     unsigned int num_elements;
2465     int i;
2466     DPY2TRACECTX(dpy);
2467
2468     TRACE_FUNCNAME(idx);
2469     
2470     va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
2471     va_TraceMsg(trace_ctx, "\tnum_buffers = %d\n", num_buffers);
2472     if (buffers == NULL)
2473         return;
2474     
2475     for (i = 0; i < num_buffers; i++) {
2476         unsigned char *pbuf = NULL;
2477         unsigned int j;
2478         
2479         /* get buffer type information */
2480         vaBufferInfo(dpy, context, buffers[i], &type, &size, &num_elements);
2481
2482         va_TraceMsg(trace_ctx, "\t---------------------------\n");
2483         va_TraceMsg(trace_ctx, "\tbuffers[%d] = 0x%08x\n", i, buffers[i]);
2484         va_TraceMsg(trace_ctx, "\t  type = %s\n", buffer_type_to_string(type));
2485         va_TraceMsg(trace_ctx, "\t  size = %d\n", size);
2486         va_TraceMsg(trace_ctx, "\t  num_elements = %d\n", num_elements);
2487
2488         vaMapBuffer(dpy, buffers[i], (void **)&pbuf);
2489         if (pbuf == NULL)
2490             continue;
2491         
2492         switch (trace_ctx->trace_profile) {
2493         case VAProfileMPEG2Simple:
2494         case VAProfileMPEG2Main:
2495             for (j=0; j<num_elements; j++) {
2496                 va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
2497                 va_TraceMPEG2Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2498             }
2499             break;
2500         case VAProfileMPEG4Simple:
2501         case VAProfileMPEG4AdvancedSimple:
2502         case VAProfileMPEG4Main:
2503             for (j=0; j<num_elements; j++) {
2504                 va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
2505                 va_TraceMPEG4Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2506             }
2507             break;
2508         case VAProfileH264Baseline:
2509         case VAProfileH264Main:
2510         case VAProfileH264High:
2511         case VAProfileH264ConstrainedBaseline:
2512             for (j=0; j<num_elements; j++) {
2513                 va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
2514                 
2515                 va_TraceH264Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2516             }
2517             break;
2518         case VAProfileVC1Simple:
2519         case VAProfileVC1Main:
2520         case VAProfileVC1Advanced:
2521             for (j=0; j<num_elements; j++) {
2522                 va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
2523                 
2524                 va_TraceVC1Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2525             }
2526             break;
2527         case VAProfileH263Baseline:
2528             for (j=0; j<num_elements; j++) {
2529                 va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
2530                 
2531                 va_TraceH263Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2532             }
2533             break;
2534         case VAProfileJPEGBaseline:
2535             for (j=0; j<num_elements; j++) {
2536                 va_TraceMsg(trace_ctx, "\telement[%d] =\n", j);
2537                 
2538                 va_TraceJPEGBuf (dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2539             }
2540             break;
2541         default:
2542             break;
2543         }
2544
2545         vaUnmapBuffer(dpy, buffers[i]);
2546     }
2547
2548     va_TraceMsg(trace_ctx, NULL);
2549 }
2550
2551 void va_TraceEndPicture(
2552     VADisplay dpy,
2553     VAContextID context,
2554     int endpic_done
2555 )
2556 {
2557     int encode, decode, jpeg;
2558     DPY2TRACECTX(dpy);
2559
2560     TRACE_FUNCNAME(idx);
2561
2562     va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
2563     va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", trace_ctx->trace_rendertarget);
2564
2565     /* avoid to create so many empty files */
2566     encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice);
2567     decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD);
2568     jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture);
2569
2570     /* trace encode source surface, can do it before HW completes rendering */
2571     if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE))||
2572             (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG)))
2573         va_TraceSurface(dpy);
2574     
2575     /* trace coded buffer, do it after HW completes rendering */
2576     if ((encode || jpeg) && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) {
2577         vaSyncSurface(dpy, trace_ctx->trace_rendertarget);
2578         va_TraceCodedBuf(dpy);
2579     }
2580
2581     /* trace decoded surface, do it after HW completes rendering */
2582     if (decode && ((trace_flag & VA_TRACE_FLAG_SURFACE_DECODE))) {
2583         vaSyncSurface(dpy, trace_ctx->trace_rendertarget);
2584         va_TraceSurface(dpy);
2585     }
2586
2587     va_TraceMsg(trace_ctx, NULL);
2588 }
2589
2590
2591 void va_TraceSyncSurface(
2592     VADisplay dpy,
2593     VASurfaceID render_target
2594 )
2595 {
2596     DPY2TRACECTX(dpy);
2597
2598     TRACE_FUNCNAME(idx);
2599
2600     va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target);
2601     va_TraceMsg(trace_ctx, NULL);
2602 }
2603
2604 void va_TraceQuerySurfaceAttributes(
2605     VADisplay           dpy,
2606     VAConfigID          config,
2607     VASurfaceAttrib    *attrib_list,
2608     unsigned int       *num_attribs
2609 )
2610 {
2611     DPY2TRACECTX(dpy);
2612
2613     TRACE_FUNCNAME(idx);
2614     va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config);
2615     va_TraceSurfaceAttributes(trace_ctx, attrib_list, num_attribs);
2616     
2617     va_TraceMsg(trace_ctx, NULL);
2618
2619 }
2620
2621
2622 void va_TraceQuerySurfaceStatus(
2623     VADisplay dpy,
2624     VASurfaceID render_target,
2625     VASurfaceStatus *status    /* out */
2626 )
2627 {
2628     DPY2TRACECTX(dpy);
2629
2630     TRACE_FUNCNAME(idx);
2631
2632     va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target);
2633     if (status)
2634         va_TraceMsg(trace_ctx, "\tstatus = 0x%08x\n", *status);
2635     va_TraceMsg(trace_ctx, NULL);
2636 }
2637
2638
2639 void va_TraceQuerySurfaceError(
2640     VADisplay dpy,
2641     VASurfaceID surface,
2642     VAStatus error_status,
2643     void **error_info       /*out*/
2644 )
2645 {
2646     DPY2TRACECTX(dpy);
2647
2648     TRACE_FUNCNAME(idx);
2649     va_TraceMsg(trace_ctx, "\tsurface = 0x%08x\n", surface);
2650     va_TraceMsg(trace_ctx, "\terror_status = 0x%08x\n", error_status);
2651     if (error_info && (error_status == VA_STATUS_ERROR_DECODING_ERROR)) {
2652         VASurfaceDecodeMBErrors *p = *error_info;
2653         while (p && (p->status != -1)) {
2654             va_TraceMsg(trace_ctx, "\t\tstatus = %d\n", p->status);
2655             va_TraceMsg(trace_ctx, "\t\tstart_mb = %d\n", p->start_mb);
2656             va_TraceMsg(trace_ctx, "\t\tend_mb = %d\n", p->end_mb);
2657             p++; /* next error record */
2658         }
2659     }
2660     va_TraceMsg(trace_ctx, NULL);
2661 }
2662
2663 void va_TraceMaxNumDisplayAttributes (
2664     VADisplay dpy,
2665     int number
2666 )
2667 {
2668     DPY2TRACECTX(dpy);
2669
2670     TRACE_FUNCNAME(idx);
2671     
2672     va_TraceMsg(trace_ctx, "\tmax_display_attributes = %d\n", number);
2673     va_TraceMsg(trace_ctx, NULL);
2674 }
2675
2676 void va_TraceQueryDisplayAttributes (
2677     VADisplay dpy,
2678     VADisplayAttribute *attr_list,    /* out */
2679     int *num_attributes               /* out */
2680 )
2681 {
2682     int i;
2683     
2684     DPY2TRACECTX(dpy);
2685     
2686     if (attr_list == NULL || num_attributes == NULL)
2687         return;
2688
2689     va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", *num_attributes);
2690     
2691     for (i=0; i<*num_attributes; i++) {
2692         va_TraceMsg(trace_ctx, "\tattr_list[%d] =\n");
2693         va_TraceMsg(trace_ctx, "\t  typ = 0x%08x\n", attr_list[i].type);
2694         va_TraceMsg(trace_ctx, "\t  min_value = %d\n", attr_list[i].min_value);
2695         va_TraceMsg(trace_ctx, "\t  max_value = %d\n", attr_list[i].max_value);
2696         va_TraceMsg(trace_ctx, "\t  value = %d\n", attr_list[i].value);
2697         va_TraceMsg(trace_ctx, "\t  flags = %d\n", attr_list[i].flags);
2698     }
2699     va_TraceMsg(trace_ctx, NULL);
2700 }
2701
2702
2703 static void va_TraceDisplayAttributes (
2704     VADisplay dpy,
2705     VADisplayAttribute *attr_list,
2706     int num_attributes
2707 )
2708 {
2709     int i;
2710     
2711     DPY2TRACECTX(dpy);
2712     
2713     va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", num_attributes);
2714     if (attr_list == NULL)
2715         return;
2716     
2717     for (i=0; i<num_attributes; i++) {
2718         va_TraceMsg(trace_ctx, "\tattr_list[%d] =\n");
2719         va_TraceMsg(trace_ctx, "\t  typ = 0x%08x\n", attr_list[i].type);
2720         va_TraceMsg(trace_ctx, "\t  min_value = %d\n", attr_list[i].min_value);
2721         va_TraceMsg(trace_ctx, "\t  max_value = %d\n", attr_list[i].max_value);
2722         va_TraceMsg(trace_ctx, "\t  value = %d\n", attr_list[i].value);
2723         va_TraceMsg(trace_ctx, "\t  flags = %d\n", attr_list[i].flags);
2724     }
2725     va_TraceMsg(trace_ctx, NULL);
2726 }
2727
2728
2729 void va_TraceGetDisplayAttributes (
2730     VADisplay dpy,
2731     VADisplayAttribute *attr_list,
2732     int num_attributes
2733 )
2734 {
2735     DPY2TRACECTX(dpy);
2736
2737     TRACE_FUNCNAME(idx);
2738
2739     va_TraceDisplayAttributes (dpy, attr_list, num_attributes);
2740 }
2741
2742 void va_TraceSetDisplayAttributes (
2743     VADisplay dpy,
2744     VADisplayAttribute *attr_list,
2745     int num_attributes
2746 )
2747 {
2748     DPY2TRACECTX(dpy);
2749
2750     TRACE_FUNCNAME(idx);
2751
2752     va_TraceDisplayAttributes (dpy, attr_list, num_attributes);
2753 }
2754
2755
2756 void va_TracePutSurface (
2757     VADisplay dpy,
2758     VASurfaceID surface,
2759     void *draw, /* the target Drawable */
2760     short srcx,
2761     short srcy,
2762     unsigned short srcw,
2763     unsigned short srch,
2764     short destx,
2765     short desty,
2766     unsigned short destw,
2767     unsigned short desth,
2768     VARectangle *cliprects, /* client supplied clip list */
2769     unsigned int number_cliprects, /* number of clip rects in the clip list */
2770     unsigned int flags /* de-interlacing flags */
2771 )
2772 {
2773     DPY2TRACECTX(dpy);
2774
2775     TRACE_FUNCNAME(idx);
2776     
2777     va_TraceMsg(trace_ctx, "\tsurface = 0x%08x\n", surface);
2778     va_TraceMsg(trace_ctx, "\tdraw = 0x%08x\n", draw);
2779     va_TraceMsg(trace_ctx, "\tsrcx = %d\n", srcx);
2780     va_TraceMsg(trace_ctx, "\tsrcy = %d\n", srcy);
2781     va_TraceMsg(trace_ctx, "\tsrcw = %d\n", srcw);
2782     va_TraceMsg(trace_ctx, "\tsrch = %d\n", srch);
2783     va_TraceMsg(trace_ctx, "\tdestx = %d\n", destx);
2784     va_TraceMsg(trace_ctx, "\tdesty = %d\n", desty);
2785     va_TraceMsg(trace_ctx, "\tdestw = %d\n", destw);
2786     va_TraceMsg(trace_ctx, "\tdesth = %d\n", desth);
2787     va_TraceMsg(trace_ctx, "\tcliprects = 0x%08x\n", cliprects);
2788     va_TraceMsg(trace_ctx, "\tnumber_cliprects = %d\n", number_cliprects);
2789     va_TraceMsg(trace_ctx, "\tflags = 0x%08x\n", flags);
2790     va_TraceMsg(trace_ctx, NULL);
2791 }