OSDN Git Service

vatrace/vafool: save the context data into display context
[android-x86/hardware-intel-common-libva.git] / va / va_trace.c
1 /*
2  * Copyright (c) 2009-2011 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24
25 #define _GNU_SOURCE 1
26 #include "va.h"
27 #include "va_enc_h264.h"
28 #include "va_backend.h"
29 #include "va_trace.h"
30 #include "va_enc_h264.h"
31 #include "va_dec_jpeg.h"
32 #include <assert.h>
33 #include <stdarg.h>
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <dlfcn.h>
38 #include <unistd.h>
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 #include <unistd.h>
42 #include <time.h>
43 #include <errno.h>
44
45 /*
46  * Env. to debug some issue, e.g. the decode/encode issue in a video conference scenerio:
47  * .LIBVA_TRACE=log_file: general VA parameters saved into log_file
48  * .LIBVA_TRACE_BUFDATA: dump VA buffer data into log_file (if not set, just calculate a checksum)
49  * .LIBVA_TRACE_CODEDBUF=coded_clip_file: save the coded clip into file coded_clip_file
50  * .LIBVA_TRACE_SURFACE=yuv_file: save surface YUV into file yuv_file. Use file name to determine
51  *                                decode/encode or jpeg surfaces
52  * .LIBVA_TRACE_SURFACE_GEOMETRY=WIDTHxHEIGHT+XOFF+YOFF: only save part of surface context into file
53  *                                due to storage bandwidth limitation
54  * .LIBVA_TRACE_LOGSIZE=numeric number: truncate the log_file or coded_clip_file, or decoded_yuv_file
55  *                                      when the size is bigger than the number
56  */
57
58 /* global settings */
59
60 /* LIBVA_TRACE */
61 int trace_flag = 0;
62
63 /* LIBVA_TRACE_LOGSIZE */
64 static unsigned int trace_logsize = 0xffffffff; /* truncate the log when the size is bigger than it */
65
66 /* per context settings */
67 struct trace_context {
68     /* LIBVA_TRACE */
69     FILE *trace_fp_log; /* save the log into a file */
70     char *trace_log_fn; /* file name */
71     
72     /* LIBVA_TRACE_CODEDBUF */
73     FILE *trace_fp_codedbuf; /* save the encode result into a file */
74     char *trace_codedbuf_fn; /* file name */
75     
76     /* LIBVA_TRACE_SURFACE */
77     FILE *trace_fp_surface; /* save the surface YUV into a file */
78     char *trace_surface_fn; /* file name */
79
80     VAContextID  trace_context; /* current context */
81     
82     VASurfaceID  trace_rendertarget; /* current render target */
83     VAProfile trace_profile; /* current profile for buffers */
84     VAEntrypoint trace_entrypoint; /* current entrypoint */
85     VABufferID trace_codedbuf;
86     
87     unsigned int trace_frame_no; /* current frame NO */
88     unsigned int trace_slice_no; /* current slice NO */
89     unsigned int trace_slice_size; /* current slice buffer size */
90
91     unsigned int trace_surface_width; /* surface dumping geometry */
92     unsigned int trace_surface_height;
93     unsigned int trace_surface_xoff;
94     unsigned int trace_surface_yoff;
95
96     unsigned int trace_frame_width; /* current frame width */
97     unsigned int trace_frame_height; /* current frame height */
98     unsigned int trace_sequence_start; /* get a new sequence for encoding or not */
99 };
100
101 #define TRACE_CTX(dpy) ((struct trace_context *)((VADisplayContextP)dpy)->vatrace)
102
103 #define DPY2TRACECTX(dpy)                               \
104     struct trace_context *trace_ctx = TRACE_CTX(dpy);   \
105                                                         \
106     if (trace_ctx == NULL)                              \
107         return;                                         \
108
109 #define TRACE_FUNCNAME(idx)    va_TraceMsg(trace_ctx, "==========%s\n", __func__); 
110
111 /* Prototype declarations (functions defined in va.c) */
112
113 void va_errorMessage(const char *msg, ...);
114 void va_infoMessage(const char *msg, ...);
115
116 int va_parseConfig(char *env, char *env_value);
117
118 VAStatus vaBufferInfo(
119     VADisplay dpy,
120     VAContextID context,        /* in */
121     VABufferID buf_id,          /* in */
122     VABufferType *type,         /* out */
123     unsigned int *size,         /* out */
124     unsigned int *num_elements  /* out */
125     );
126
127 VAStatus vaLockSurface(VADisplay dpy,
128                        VASurfaceID surface,
129                        unsigned int *fourcc, /* following are output argument */
130                        unsigned int *luma_stride,
131                        unsigned int *chroma_u_stride,
132                        unsigned int *chroma_v_stride,
133                        unsigned int *luma_offset,
134                        unsigned int *chroma_u_offset,
135                        unsigned int *chroma_v_offset,
136                        unsigned int *buffer_name,
137                        void **buffer 
138                        );
139
140 VAStatus vaUnlockSurface(VADisplay dpy,
141                          VASurfaceID surface
142                          );
143
144 #define FILE_NAME_SUFFIX(env_value)                      \
145 do {                                                    \
146     int tmp = strnlen(env_value, sizeof(env_value));    \
147     int left = sizeof(env_value) - tmp;                 \
148                                                         \
149     snprintf(env_value+tmp,                             \
150              left,                                      \
151              ".%04d.%05d",                              \
152              trace_index,                               \
153              suffix);                                   \
154 } while (0)
155
156 void va_TraceInit(VADisplay dpy)
157 {
158     char env_value[1024];
159     unsigned short suffix = 0xffff & ((unsigned int)time(NULL));
160     int trace_index = 0;
161     FILE *tmp;    
162     struct trace_context *trace_ctx = calloc(sizeof(struct trace_context), 1);
163
164     if (trace_ctx == NULL)
165         return;
166     
167     if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
168         FILE_NAME_SUFFIX(env_value);
169         trace_ctx->trace_log_fn = strdup(env_value);
170         
171         tmp = fopen(env_value, "w");
172         if (tmp) {
173             trace_ctx->trace_fp_log = tmp;
174             va_infoMessage("LIBVA_TRACE is on, save log into %s\n", trace_ctx->trace_log_fn);
175             trace_flag = VA_TRACE_FLAG_LOG;
176         } else
177             va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
178     }
179
180     /* may re-get the global settings for multiple context */
181     if (va_parseConfig("LIBVA_TRACE_LOGSIZE", &env_value[0]) == 0) {
182         trace_logsize = atoi(env_value);
183         va_infoMessage("LIBVA_TRACE_LOGSIZE is on, size is %d\n", trace_logsize);
184     }
185
186     if ((trace_flag & VA_TRACE_FLAG_LOG) && (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0)) {
187         trace_flag |= VA_TRACE_FLAG_BUFDATA;
188         va_infoMessage("LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n");
189     }
190
191     /* per-context setting */
192     if (va_parseConfig("LIBVA_TRACE_CODEDBUF", &env_value[0]) == 0) {
193         FILE_NAME_SUFFIX(env_value);
194         trace_ctx->trace_codedbuf_fn = strdup(env_value);
195         va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save codedbuf into log file %s\n",
196                        trace_ctx->trace_codedbuf_fn);
197         trace_flag |= VA_TRACE_FLAG_CODEDBUF;
198     }
199
200     if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) {
201         FILE_NAME_SUFFIX(env_value);
202         trace_ctx->trace_surface_fn = strdup(env_value);
203
204         va_infoMessage("LIBVA_TRACE_SURFACE is on, save surface into %s\n",
205                        trace_ctx->trace_surface_fn);
206
207         /* for surface data dump, it is time-consume, and may
208          * cause some side-effect, so only trace the needed surfaces
209          * to trace encode surface, set the trace file name to sth like *enc*
210          * to trace decode surface, set the trace file name to sth like *dec*
211          * if no dec/enc in file name, set both
212          */
213         if (strstr(env_value, "dec"))
214             trace_flag |= VA_TRACE_FLAG_SURFACE_DECODE;
215         if (strstr(env_value, "enc"))
216             trace_flag |= VA_TRACE_FLAG_SURFACE_ENCODE;
217         if (strstr(env_value, "jpeg") || strstr(env_value, "jpg"))
218             trace_flag |= VA_TRACE_FLAG_SURFACE_JPEG;
219
220         if (va_parseConfig("LIBVA_TRACE_SURFACE_GEOMETRY", &env_value[0]) == 0) {
221             char *p = env_value, *q;
222
223             trace_ctx->trace_surface_width = strtod(p, &q);
224             p = q+1; /* skip "x" */
225             trace_ctx->trace_surface_height = strtod(p, &q);
226             p = q+1; /* skip "+" */
227             trace_ctx->trace_surface_xoff = strtod(p, &q);
228             p = q+1; /* skip "+" */
229             trace_ctx->trace_surface_yoff = strtod(p, &q);
230
231             va_infoMessage("LIBVA_TRACE_SURFACE_GEOMETRY is on, only dump surface %dx%d+%d+%d content\n",
232                            trace_ctx->trace_surface_width,
233                            trace_ctx->trace_surface_height,
234                            trace_ctx->trace_surface_xoff,
235                            trace_ctx->trace_surface_yoff);
236         }
237     }
238
239     ((VADisplayContextP)dpy)->vatrace = trace_ctx;
240 }
241
242
243 void va_TraceEnd(VADisplay dpy)
244 {
245     DPY2TRACECTX(dpy);
246     
247     if (trace_ctx->trace_fp_log)
248         fclose(trace_ctx->trace_fp_log);
249     
250     if (trace_ctx->trace_fp_codedbuf)
251         fclose(trace_ctx->trace_fp_codedbuf);
252     
253     if (trace_ctx->trace_fp_surface)
254         fclose(trace_ctx->trace_fp_surface);
255
256     if (trace_ctx->trace_log_fn)
257         free(trace_ctx->trace_log_fn);
258     
259     if (trace_ctx->trace_codedbuf_fn)
260         free(trace_ctx->trace_codedbuf_fn);
261     
262     if (trace_ctx->trace_surface_fn)
263         free(trace_ctx->trace_surface_fn);
264     
265     free(trace_ctx);
266     ((VADisplayContextP)dpy)->vatrace = NULL;
267 }
268
269
270 static unsigned int file_size(FILE *fp)
271 {
272     struct stat buf;
273
274     fstat(fileno(fp), &buf);
275
276     return buf.st_size;
277 }
278
279
280 static void truncate_file(FILE *fp)
281 {
282     ftruncate(fileno(fp), 0);
283     rewind(fp);
284 }
285
286 void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
287 {
288     va_list args;
289
290     if (!(trace_flag & VA_TRACE_FLAG_LOG))
291         return;
292
293     if (file_size(trace_ctx->trace_fp_log) >= trace_logsize)
294         truncate_file(trace_ctx->trace_fp_log);
295     if (msg)  {
296         va_start(args, msg);
297         vfprintf(trace_ctx->trace_fp_log, msg, args);
298         va_end(args);
299     } else
300         fflush(trace_ctx->trace_fp_log);
301 }
302
303 void va_TraceCodedBuf(VADisplay dpy)
304 {
305     VACodedBufferSegment *buf_list = NULL;
306     VAStatus va_status;
307     unsigned char check_sum = 0;
308     DPY2TRACECTX(dpy);
309     
310     /* can only truncate at a sequence boudary */
311     if (((file_size(trace_ctx->trace_fp_log) >= trace_logsize))
312         && trace_ctx->trace_sequence_start) {
313         va_TraceMsg(trace_ctx, "==========truncate file %s\n", trace_ctx->trace_codedbuf_fn);
314         truncate_file(trace_ctx->trace_fp_log);
315     }
316     
317
318     trace_ctx->trace_sequence_start = 0; /* only truncate coded file when meet next new sequence */
319     
320     va_status = vaMapBuffer(dpy, trace_ctx->trace_codedbuf, (void **)(&buf_list));
321     if (va_status != VA_STATUS_SUCCESS)
322         return;
323
324     va_TraceMsg(trace_ctx, "==========dump codedbuf into file %s\n", trace_ctx->trace_codedbuf_fn);
325     
326     while (buf_list != NULL) {
327         unsigned int i;
328         
329         va_TraceMsg(trace_ctx, "\tsize = %d\n", buf_list->size);
330         if (trace_ctx->trace_fp_codedbuf)
331             fwrite(buf_list->buf, buf_list->size, 1, trace_ctx->trace_fp_codedbuf);
332
333         for (i=0; i<buf_list->size; i++)
334             check_sum ^= *((unsigned char *)buf_list->buf + i);
335
336         buf_list = buf_list->next;
337     }
338     vaUnmapBuffer(dpy,trace_ctx->trace_codedbuf);
339     
340     va_TraceMsg(trace_ctx, "\tchecksum = 0x%02x\n", check_sum);
341     va_TraceMsg(trace_ctx, NULL);
342 }
343
344
345 void va_TraceSurface(VADisplay dpy)
346 {
347     unsigned int i, j;
348     unsigned int fourcc; /* following are output argument */
349     unsigned int luma_stride;
350     unsigned int chroma_u_stride;
351     unsigned int chroma_v_stride;
352     unsigned int luma_offset;
353     unsigned int chroma_u_offset;
354     unsigned int chroma_v_offset;
355     unsigned int buffer_name;
356     void *buffer = NULL;
357     unsigned char *Y_data, *UV_data, *tmp;
358     VAStatus va_status;
359     unsigned char check_sum = 0;
360     DPY2TRACECTX(dpy);
361
362     va_TraceMsg(trace_ctx, "==========dump surface data in file %s\n", trace_ctx->trace_surface_fn);
363
364     if ((file_size(trace_ctx->trace_fp_surface) >= trace_logsize)) {
365         va_TraceMsg(trace_ctx, "==========truncate file %s\n", trace_ctx->trace_surface_fn);
366         truncate_file(trace_ctx->trace_fp_surface);
367     }
368     va_TraceMsg(trace_ctx, NULL);
369
370     va_status = vaLockSurface(
371         dpy,
372         trace_ctx->trace_rendertarget,
373         &fourcc,
374         &luma_stride, &chroma_u_stride, &chroma_v_stride,
375         &luma_offset, &chroma_u_offset, &chroma_v_offset,
376         &buffer_name, &buffer);
377
378     if (va_status != VA_STATUS_SUCCESS) {
379         va_TraceMsg(trace_ctx, "Error:vaLockSurface failed\n");
380         return;
381     }
382
383     va_TraceMsg(trace_ctx, "\tfourcc = 0x%08x\n", fourcc);
384     va_TraceMsg(trace_ctx, "\twidth = %d\n", trace_ctx->trace_frame_width);
385     va_TraceMsg(trace_ctx, "\theight = %d\n", trace_ctx->trace_frame_height);
386     va_TraceMsg(trace_ctx, "\tluma_stride = %d\n", luma_stride);
387     va_TraceMsg(trace_ctx, "\tchroma_u_stride = %d\n", chroma_u_stride);
388     va_TraceMsg(trace_ctx, "\tchroma_v_stride = %d\n", chroma_v_stride);
389     va_TraceMsg(trace_ctx, "\tluma_offset = %d\n", luma_offset);
390     va_TraceMsg(trace_ctx, "\tchroma_u_offset = %d\n", chroma_u_offset);
391     va_TraceMsg(trace_ctx, "\tchroma_v_offset = %d\n", chroma_v_offset);
392
393     if (buffer == NULL) {
394         va_TraceMsg(trace_ctx, "Error:vaLockSurface return NULL buffer\n");
395         va_TraceMsg(trace_ctx, NULL);
396
397         vaUnlockSurface(dpy, trace_ctx->trace_rendertarget);
398         return;
399     }
400     va_TraceMsg(trace_ctx, "\tbuffer location = 0x%08x\n", buffer);
401     va_TraceMsg(trace_ctx, NULL);
402
403     Y_data = (unsigned char*)buffer;
404     UV_data = (unsigned char*)buffer + chroma_u_offset;
405
406     tmp = Y_data + luma_stride * trace_ctx->trace_surface_yoff;
407     for (i=0; i<trace_ctx->trace_surface_height; i++) {
408         if (trace_ctx->trace_fp_surface)
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             if (trace_ctx->trace_fp_surface)
419                 fwrite(tmp + trace_ctx->trace_surface_xoff,
420                        trace_ctx->trace_surface_width,
421                        1, trace_ctx->trace_fp_surface);
422             
423             tmp += chroma_u_stride;
424         }
425     }
426
427     vaUnlockSurface(dpy, trace_ctx->trace_rendertarget);
428
429     va_TraceMsg(trace_ctx, NULL);
430 }
431
432
433 void va_TraceInitialize (
434     VADisplay dpy,
435     int *major_version,     /* out */
436     int *minor_version      /* out */
437 )
438 {
439     DPY2TRACECTX(dpy);    
440     TRACE_FUNCNAME(idx);
441 }
442
443 void va_TraceTerminate (
444     VADisplay dpy
445 )
446 {
447     DPY2TRACECTX(dpy);    
448     TRACE_FUNCNAME(idx);
449 }
450
451
452 void va_TraceCreateConfig(
453     VADisplay dpy,
454     VAProfile profile, 
455     VAEntrypoint entrypoint, 
456     VAConfigAttrib *attrib_list,
457     int num_attribs,
458     VAConfigID *config_id /* out */
459 )
460 {
461     int i;
462     int encode, decode, jpeg;
463     DPY2TRACECTX(dpy);
464
465     TRACE_FUNCNAME(idx);
466     
467     va_TraceMsg(trace_ctx, "\tprofile = %d\n", profile);
468     va_TraceMsg(trace_ctx, "\tentrypoint = %d\n", entrypoint);
469     va_TraceMsg(trace_ctx, "\tnum_attribs = %d\n", num_attribs);
470     if (attrib_list) {
471         for (i = 0; i < num_attribs; i++) {
472             va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type);
473             va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value);
474         }
475     }
476     va_TraceMsg(trace_ctx, NULL);
477
478     trace_ctx->trace_profile = profile;
479     trace_ctx->trace_entrypoint = entrypoint;
480
481     /* avoid to create so many empty files */
482     encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice);
483     decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD);
484     jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture);
485     if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE)) ||
486         (decode && (trace_flag & VA_TRACE_FLAG_SURFACE_DECODE)) ||
487         (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) {
488         FILE *tmp = fopen(trace_ctx->trace_surface_fn, "w");
489         
490         if (tmp)
491             trace_ctx->trace_fp_surface = tmp;
492         else {
493             va_errorMessage("Open file %s failed (%s)\n",
494                             trace_ctx->trace_surface_fn,
495                             strerror(errno));
496             trace_ctx->trace_fp_surface = NULL;
497             trace_flag &= ~(VA_TRACE_FLAG_SURFACE);
498         }
499     }
500
501     if (encode && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) {
502         FILE *tmp = fopen(trace_ctx->trace_codedbuf_fn, "w");
503         
504         if (tmp)
505             trace_ctx->trace_fp_codedbuf = tmp;
506         else {
507             va_errorMessage("Open file %s failed (%s)\n",
508                             trace_ctx->trace_codedbuf_fn,
509                             strerror(errno));
510             trace_ctx->trace_fp_codedbuf = NULL;
511             trace_flag &= ~VA_TRACE_FLAG_CODEDBUF;
512         }
513     }
514 }
515
516 static void va_TraceSurfaceAttributes(
517     struct trace_context *trace_ctx,
518     VASurfaceAttrib    *attrib_list,
519     unsigned int       *num_attribs
520 )
521 {
522     int i, num;
523     VASurfaceAttrib *p;
524     
525     if (!attrib_list || !num_attribs)
526         return;
527     
528     p = attrib_list;
529     num = *num_attribs;
530     if (num > VASurfaceAttribCount)
531         num = VASurfaceAttribCount;
532
533     for (i=0; i<num; i++) {
534         va_TraceMsg(trace_ctx, "\tattrib_list[%i] =\n", i);
535         
536         va_TraceMsg(trace_ctx, "\t\ttype = %d\n", p->type);
537         va_TraceMsg(trace_ctx, "\t\tflags = %d\n", p->flags);
538         va_TraceMsg(trace_ctx, "\t\tvalue.type = %d\n", p->value.type);
539         if (p->value.type == VAGenericValueTypeInteger)
540             va_TraceMsg(trace_ctx, "\t\tvalue.value.i = 0x%08x\n", p->value.value.i);
541         else if (p->value.type == VAGenericValueTypeFloat)
542         va_TraceMsg(trace_ctx, "\t\tvalue.value.f = %f\n", p->value.value.f);
543         else if (p->value.type == VAGenericValueTypePointer)
544             va_TraceMsg(trace_ctx, "\t\tvalue.value.p = %p\n", p->value.value.p);
545         else if (p->value.type == VAGenericValueTypeFunc)
546             va_TraceMsg(trace_ctx, "\t\tvalue.value.fn = %p\n", p->value.value.fn);
547
548         p++;
549     }
550 }
551
552 void va_TraceCreateSurfaces(
553     VADisplay dpy,
554     int width,
555     int height,
556     int format,
557     int num_surfaces,
558     VASurfaceID *surfaces,    /* out */
559     VASurfaceAttrib    *attrib_list,
560     unsigned int        num_attribs
561 )
562 {
563     int i;
564     DPY2TRACECTX(dpy);
565
566     TRACE_FUNCNAME(idx);
567     
568     va_TraceMsg(trace_ctx, "\twidth = %d\n", width);
569     va_TraceMsg(trace_ctx, "\theight = %d\n", height);
570     va_TraceMsg(trace_ctx, "\tformat = %d\n", format);
571     va_TraceMsg(trace_ctx, "\tnum_surfaces = %d\n", num_surfaces);
572
573     if (surfaces) {
574         for (i = 0; i < num_surfaces; i++)
575             va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]);
576     }
577     
578     va_TraceSurfaceAttributes(trace_ctx, attrib_list, &num_attribs);
579
580     va_TraceMsg(trace_ctx, NULL);
581 }
582
583
584 void va_TraceDestroySurfaces(
585     VADisplay dpy,
586     VASurfaceID *surface_list,
587     int num_surfaces
588 )
589 {
590     int i;
591     DPY2TRACECTX(dpy);
592
593     TRACE_FUNCNAME(idx);
594
595     if (surface_list) {
596         for (i = 0; i < num_surfaces; i++)
597             va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surface_list[i]);
598     }
599     
600     va_TraceMsg(trace_ctx, NULL);
601 }
602
603
604 void va_TraceCreateContext(
605     VADisplay dpy,
606     VAConfigID config_id,
607     int picture_width,
608     int picture_height,
609     int flag,
610     VASurfaceID *render_targets,
611     int num_render_targets,
612     VAContextID *context        /* out */
613 )
614 {
615     int i;
616     DPY2TRACECTX(dpy);
617
618     TRACE_FUNCNAME(idx);
619
620     va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id);
621     va_TraceMsg(trace_ctx, "\twidth = %d\n", picture_width);
622     va_TraceMsg(trace_ctx, "\theight = %d\n", picture_height);
623     va_TraceMsg(trace_ctx, "\tflag = 0x%08x\n", flag);
624     va_TraceMsg(trace_ctx, "\tnum_render_targets = %d\n", num_render_targets);
625     if (render_targets) {
626         for (i=0; i<num_render_targets; i++)
627             va_TraceMsg(trace_ctx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]);
628     }
629     if (context) {
630         va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", *context);
631         trace_ctx->trace_context = *context;
632     } else
633         trace_ctx->trace_context = VA_INVALID_ID;
634     
635     trace_ctx->trace_frame_no = 0;
636     trace_ctx->trace_slice_no = 0;
637
638     trace_ctx->trace_frame_width = picture_width;
639     trace_ctx->trace_frame_height = picture_height;
640
641     if (trace_ctx->trace_surface_width == 0)
642         trace_ctx->trace_surface_width = picture_width;
643     if (trace_ctx->trace_surface_height == 0)
644         trace_ctx->trace_surface_height = picture_height;
645 }
646
647
648 static char * buffer_type_to_string(int type)
649 {
650     switch (type) {
651     case VAPictureParameterBufferType: return "VAPictureParameterBufferType";
652     case VAIQMatrixBufferType: return "VAIQMatrixBufferType";
653     case VABitPlaneBufferType: return "VABitPlaneBufferType";
654     case VASliceGroupMapBufferType: return "VASliceGroupMapBufferType";
655     case VASliceParameterBufferType: return "VASliceParameterBufferType";
656     case VASliceDataBufferType: return "VASliceDataBufferType";
657     case VAProtectedSliceDataBufferType: return "VAProtectedSliceDataBufferType";
658     case VAMacroblockParameterBufferType: return "VAMacroblockParameterBufferType";
659     case VAResidualDataBufferType: return "VAResidualDataBufferType";
660     case VADeblockingParameterBufferType: return "VADeblockingParameterBufferType";
661     case VAImageBufferType: return "VAImageBufferType";
662     case VAQMatrixBufferType: return "VAQMatrixBufferType";
663     case VAHuffmanTableBufferType: return "VAHuffmanTableBufferType";
664 /* Following are encode buffer types */
665     case VAEncCodedBufferType: return "VAEncCodedBufferType";
666     case VAEncSequenceParameterBufferType: return "VAEncSequenceParameterBufferType";
667     case VAEncPictureParameterBufferType: return "VAEncPictureParameterBufferType";
668     case VAEncSliceParameterBufferType: return "VAEncSliceParameterBufferType";
669     case VAEncPackedHeaderParameterBufferType: return "VAEncPackedHeaderParameterBufferType";
670     case VAEncPackedHeaderDataBufferType: return "VAEncPackedHeaderDataBufferType";
671     case VAEncMiscParameterBufferType: return "VAEncMiscParameterBufferType";
672     case VAEncMacroblockParameterBufferType: return "VAEncMacroblockParameterBufferType";
673     case VAProcPipelineParameterBufferType: return "VAProcPipelineParameterBufferType";
674     case VAProcFilterParameterBufferType: return "VAProcFilterParameterBufferType";
675     default: return "UnknowBuffer";
676     }
677 }
678
679 void va_TraceCreateBuffer (
680     VADisplay dpy,
681     VAContextID context,        /* in */
682     VABufferType type,          /* in */
683     unsigned int size,          /* in */
684     unsigned int num_elements,  /* in */
685     void *data,                 /* in */
686     VABufferID *buf_id          /* out */
687 )
688 {
689     DPY2TRACECTX(dpy);
690
691     /* only trace CodedBuffer */
692     if (type != VAEncCodedBufferType)
693         return;
694
695     TRACE_FUNCNAME(idx);
696     va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type));
697     if (buf_id)
698         va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", *buf_id);
699     va_TraceMsg(trace_ctx, "\tsize=%d\n", size);
700     va_TraceMsg(trace_ctx, "\tnum_elements=%d\n", num_elements);
701     
702     va_TraceMsg(trace_ctx, NULL);
703 }
704
705 void va_TraceDestroyBuffer (
706     VADisplay dpy,
707     VABufferID buf_id    /* in */
708 )
709 {
710     VABufferType type;
711     unsigned int size;
712     unsigned int num_elements;
713     
714     VACodedBufferSegment *buf_list;
715     int i = 0;
716     
717     DPY2TRACECTX(dpy);
718
719     vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements);    
720     
721     /* only trace CodedBuffer */
722     if (type != VAEncCodedBufferType)
723         return;
724
725     TRACE_FUNCNAME(idx);
726     va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type));
727     va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
728     va_TraceMsg(trace_ctx, "\tsize=%d\n", size);
729     va_TraceMsg(trace_ctx, "\tnum_elements=%d\n", num_elements);
730     
731     va_TraceMsg(trace_ctx, NULL);
732 }
733
734
735 void va_TraceMapBuffer (
736     VADisplay dpy,
737     VABufferID buf_id,    /* in */
738     void **pbuf           /* out */
739 )
740 {
741     VABufferType type;
742     unsigned int size;
743     unsigned int num_elements;
744     
745     VACodedBufferSegment *buf_list;
746     int i = 0;
747     
748     DPY2TRACECTX(dpy);
749
750     vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements);    
751     
752     /* only trace CodedBuffer */
753     if (type != VAEncCodedBufferType)
754         return;
755
756     TRACE_FUNCNAME(idx);
757     va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
758     va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type));
759     if ((pbuf == NULL) || (*pbuf == NULL))
760         return;
761     
762     buf_list = (VACodedBufferSegment *)(*pbuf);
763     while (buf_list != NULL) {
764         va_TraceMsg(trace_ctx, "\tCodedbuf[%d] =\n", i++);
765         
766         va_TraceMsg(trace_ctx, "\t   size = %d\n", buf_list->size);
767         va_TraceMsg(trace_ctx, "\t   bit_offset = %d\n", buf_list->bit_offset);
768         va_TraceMsg(trace_ctx, "\t   status = 0x%08x\n", buf_list->status);
769         va_TraceMsg(trace_ctx, "\t   reserved = 0x%08x\n", buf_list->reserved);
770         va_TraceMsg(trace_ctx, "\t   buf = 0x%08x\n", buf_list->buf);
771
772         buf_list = buf_list->next;
773     }
774     va_TraceMsg(trace_ctx, NULL);
775 }
776
777 static void va_TraceVABuffers(
778     VADisplay dpy,
779     VAContextID context,
780     VABufferID buffer,
781     VABufferType type,
782     unsigned int size,
783     unsigned int num_elements,
784     void *pbuf
785 )
786 {
787     unsigned int i;
788     unsigned char *p = pbuf;
789     unsigned char  check_sum = 0;
790     DPY2TRACECTX(dpy);
791     
792     va_TraceMsg(trace_ctx, "%s",  buffer_type_to_string(type));
793
794     for (i=0; i<size; i++) {
795         unsigned char value =  p[i];
796             
797         if ((trace_flag & VA_TRACE_FLAG_BUFDATA) && ((i%16) == 0))
798             va_TraceMsg(trace_ctx, "\n\t0x%08x:", i);
799
800         if (trace_flag & VA_TRACE_FLAG_BUFDATA)
801             va_TraceMsg(trace_ctx, " %02x", value);
802
803         check_sum ^= value;
804     }
805
806     va_TraceMsg(trace_ctx, "\n\tchecksum = 0x%02x\n", check_sum & 0xff);
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, "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, "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, "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             va_TraceMsg(trace_ctx, "\t\tinv-inv-inv-inv-inv\n");
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, "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, "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, "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, "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             va_TraceMsg(trace_ctx, "\t\tinv-inv-inv-inv-inv\n");
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, "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     va_TraceMsg(trace_ctx, "VAEncSliceParameterBufferH264\n");
1616     va_TraceMsg(trace_ctx, "\tmacroblock_address = %d\n", p->macroblock_address);
1617     va_TraceMsg(trace_ctx, "\tnum_macroblocks = %d\n", p->num_macroblocks);
1618     va_TraceMsg(trace_ctx, "\tmacroblock_info = %08x\n", p->macroblock_info);
1619     va_TraceMsg(trace_ctx, "\tslice_type = %d\n", p->slice_type);
1620     va_TraceMsg(trace_ctx, "\tpic_parameter_set_id = %d\n", p->pic_parameter_set_id);
1621     va_TraceMsg(trace_ctx, "\tidr_pic_id = %d\n", p->idr_pic_id);
1622     va_TraceMsg(trace_ctx, "\tpic_order_cnt_lsb = %d\n", p->pic_order_cnt_lsb);
1623     va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt_bottom = %d\n", p->delta_pic_order_cnt_bottom);
1624     va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt[0] = %d\n", p->delta_pic_order_cnt[0]);
1625     va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt[1] = %d\n", p->delta_pic_order_cnt[1]);
1626     va_TraceMsg(trace_ctx, "\tdirect_spatial_mv_pred_flag = %d\n", p->direct_spatial_mv_pred_flag);
1627     va_TraceMsg(trace_ctx, "\tnum_ref_idx_active_override_flag = %d\n", p->num_ref_idx_active_override_flag);
1628     va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1);
1629     va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2);
1630
1631     va_TraceMsg(trace_ctx, "\tRefPicList0 (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n");
1632     for (i = 0; i < 32; i++) {
1633         if ((p->RefPicList0[i].picture_id != VA_INVALID_SURFACE) &&
1634             ((p->RefPicList0[i].flags & VA_PICTURE_H264_INVALID) == 0))
1635             va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08x\n",
1636                         p->RefPicList0[i].TopFieldOrderCnt,
1637                         p->RefPicList0[i].BottomFieldOrderCnt,
1638                         p->RefPicList0[i].picture_id,
1639                         p->RefPicList0[i].frame_idx,
1640                         p->RefPicList0[i].flags);
1641         else
1642             break;
1643     }
1644     
1645     va_TraceMsg(trace_ctx, "\tRefPicList1 (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n");
1646     for (i = 0; i < 32; i++) {
1647         if ((p->RefPicList1[i].picture_id != VA_INVALID_SURFACE) &&
1648             ((p->RefPicList1[i].flags & VA_PICTURE_H264_INVALID) == 0))
1649             va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08d\n",
1650                         p->RefPicList1[i].TopFieldOrderCnt,
1651                         p->RefPicList1[i].BottomFieldOrderCnt,
1652                         p->RefPicList1[i].picture_id,
1653                         p->RefPicList1[i].frame_idx,
1654                         p->RefPicList1[i].flags
1655                         );
1656         else
1657             break;
1658     }
1659     
1660     va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom);
1661     va_TraceMsg(trace_ctx, "\tchroma_log2_weight_denom = %d\n", p->chroma_log2_weight_denom);
1662     va_TraceMsg(trace_ctx, "\tluma_weight_l0_flag = %d\n", p->luma_weight_l0_flag);
1663     if (p->luma_weight_l0_flag) {
1664         for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) {
1665             va_TraceMsg(trace_ctx, "\t%d ", p->luma_weight_l0[i]);
1666             va_TraceMsg(trace_ctx, "\t%d ", p->luma_offset_l0[i]);
1667         }
1668         if (p->num_ref_idx_l0_active_minus1 >=0)
1669             va_TraceMsg(trace_ctx, "\n");
1670     }
1671
1672     va_TraceMsg(trace_ctx, "\tchroma_weight_l0_flag = %d\n", p->chroma_weight_l0_flag);
1673     if (p->chroma_weight_l0_flag) {
1674         for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) {
1675             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l0[i][0]);
1676             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l0[i][0]);
1677             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l0[i][1]);
1678             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l0[i][1]);
1679         }
1680         if (p->num_ref_idx_l0_active_minus1 >= 0)
1681             va_TraceMsg(trace_ctx, "\n");
1682     }
1683
1684     va_TraceMsg(trace_ctx, "\tluma_weight_l1_flag = %d\n", p->luma_weight_l1_flag);
1685     if (p->luma_weight_l1_flag) {
1686         for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) {
1687             va_TraceMsg(trace_ctx, "\t\t%d ", p->luma_weight_l1[i]);
1688             va_TraceMsg(trace_ctx, "\t\t%d ", p->luma_offset_l1[i]);
1689         }
1690         if (p->num_ref_idx_l1_active_minus1 >= 0)
1691             va_TraceMsg(trace_ctx, "\n");
1692     }
1693
1694     va_TraceMsg(trace_ctx, "\tchroma_weight_l1_flag = %d\n", p->chroma_weight_l1_flag);
1695     if (p->chroma_weight_l1_flag && p->num_ref_idx_l1_active_minus1 < 32) {
1696         for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) {
1697             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l1[i][0]);
1698             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l1[i][0]);
1699             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_weight_l1[i][1]);
1700             va_TraceMsg(trace_ctx, "\t%d ", p->chroma_offset_l1[i][1]);
1701         }
1702         if ( p->num_ref_idx_l1_active_minus1 >=0)
1703             va_TraceMsg(trace_ctx, "\n");
1704     }
1705     va_TraceMsg(trace_ctx, NULL);
1706
1707     va_TraceMsg(trace_ctx, "\tcabac_init_idc = %d\n", p->cabac_init_idc);
1708     va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta);
1709     va_TraceMsg(trace_ctx, "\tdisable_deblocking_filter_idc = %d\n", p->disable_deblocking_filter_idc);
1710     va_TraceMsg(trace_ctx, "\tslice_alpha_c0_offset_div2 = %d\n", p->slice_alpha_c0_offset_div2);
1711     va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2);
1712     va_TraceMsg(trace_ctx, NULL);
1713
1714     return;
1715 }
1716
1717
1718 static void va_TraceVAEncPackedHeaderParameterBufferType(
1719     VADisplay dpy,
1720     VAContextID context,
1721     VABufferID buffer,
1722     VABufferType type,
1723     unsigned int size,
1724     unsigned int num_elements,
1725     void *data)
1726 {
1727     VAEncPackedHeaderParameterBuffer* p = (VAEncPackedHeaderParameterBuffer*)data;
1728     DPY2TRACECTX(dpy);
1729     int i;
1730
1731     if (!p)
1732         return;
1733     va_TraceMsg(trace_ctx, "VAEncPackedHeaderParameterBuffer\n");
1734     va_TraceMsg(trace_ctx, "\ttype = 0x%08x\n", p->type);
1735     va_TraceMsg(trace_ctx, "\tbit_length = %d\n", p->bit_length);
1736     va_TraceMsg(trace_ctx, "\thas_emulation_bytes = %d\n", p->has_emulation_bytes);
1737     va_TraceMsg(trace_ctx, NULL);
1738
1739     return;
1740 }
1741
1742 static void va_TraceVAEncMiscParameterBuffer(
1743     VADisplay dpy,
1744     VAContextID context,
1745     VABufferID buffer,
1746     VABufferType type,
1747     unsigned int size,
1748     unsigned int num_elements,
1749     void *data)
1750 {
1751     VAEncMiscParameterBuffer* tmp = (VAEncMiscParameterBuffer*)data;
1752     DPY2TRACECTX(dpy);
1753     
1754     switch (tmp->type) {
1755     case VAEncMiscParameterTypeFrameRate:
1756     {
1757         VAEncMiscParameterFrameRate *p = (VAEncMiscParameterFrameRate *)tmp->data;
1758         va_TraceMsg(trace_ctx, "VAEncMiscParameterFrameRate\n");
1759         va_TraceMsg(trace_ctx, "\tframerate = %d\n", p->framerate);
1760         
1761         break;
1762     }
1763     case VAEncMiscParameterTypeRateControl:
1764     {
1765         VAEncMiscParameterRateControl *p = (VAEncMiscParameterRateControl *)tmp->data;
1766
1767         va_TraceMsg(trace_ctx, "VAEncMiscParameterRateControl\n");
1768         va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
1769         va_TraceMsg(trace_ctx, "\ttarget_percentage = %d\n", p->target_percentage);
1770         va_TraceMsg(trace_ctx, "\twindow_size = %d\n", p->window_size);
1771         va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp);
1772         va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
1773         va_TraceMsg(trace_ctx, "\tbasic_unit_size = %d\n", p->basic_unit_size);
1774         va_TraceMsg(trace_ctx, "\trc_flags.reset = %d \n", p->rc_flags.bits.reset);
1775         va_TraceMsg(trace_ctx, "\trc_flags.disable_frame_skip = %d\n", p->rc_flags.bits.disable_frame_skip);
1776         va_TraceMsg(trace_ctx, "\trc_flags.disable_bit_stuffing = %d\n", p->rc_flags.bits.disable_bit_stuffing);
1777         break;
1778     }
1779     case VAEncMiscParameterTypeMaxSliceSize:
1780     {
1781         VAEncMiscParameterMaxSliceSize *p = (VAEncMiscParameterMaxSliceSize *)tmp->data;
1782         
1783         va_TraceMsg(trace_ctx, "VAEncMiscParameterTypeMaxSliceSize\n");
1784         va_TraceMsg(trace_ctx, "\tmax_slice_size = %d\n", p->max_slice_size);
1785         break;
1786     }
1787     case VAEncMiscParameterTypeAIR:
1788     {
1789         VAEncMiscParameterAIR *p = (VAEncMiscParameterAIR *)tmp->data;
1790         
1791         va_TraceMsg(trace_ctx, "VAEncMiscParameterAIR\n");
1792         va_TraceMsg(trace_ctx, "\tair_num_mbs = %d\n", p->air_num_mbs);
1793         va_TraceMsg(trace_ctx, "\tair_threshold = %d\n", p->air_threshold);
1794         va_TraceMsg(trace_ctx, "\tair_auto = %d\n", p->air_auto);
1795         break;
1796     }
1797     case VAEncMiscParameterTypeHRD:
1798     {
1799         VAEncMiscParameterHRD *p = (VAEncMiscParameterHRD *)tmp->data;
1800
1801         va_TraceMsg(trace_ctx, "VAEncMiscParameterHRD\n");
1802         va_TraceMsg(trace_ctx, "\tinitial_buffer_fullness = %d\n", p->initial_buffer_fullness);
1803         va_TraceMsg(trace_ctx, "\tbuffer_size = %d\n", p->buffer_size);
1804         break;
1805     }
1806     default:
1807         va_TraceMsg(trace_ctx, "Unknown VAEncMiscParameterBuffer(type = %d):", tmp->type);
1808         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
1809         break;
1810     }
1811     va_TraceMsg(trace_ctx, NULL);
1812
1813     return;
1814 }
1815
1816
1817 static void va_TraceVAPictureParameterBufferVC1(
1818     VADisplay dpy,
1819     VAContextID context,
1820     VABufferID buffer,
1821     VABufferType type,
1822     unsigned int size,
1823     unsigned int num_elements,
1824     void *data
1825 )
1826 {
1827     VAPictureParameterBufferVC1* p = (VAPictureParameterBufferVC1*)data;
1828     DPY2TRACECTX(dpy);
1829     
1830     va_TraceMsg(trace_ctx, "VAPictureParameterBufferVC1\n");
1831     
1832     va_TraceMsg(trace_ctx, "\tforward_reference_picture = 0x%08x\n", p->forward_reference_picture);
1833     va_TraceMsg(trace_ctx, "\tbackward_reference_picture = 0x%08x\n", p->backward_reference_picture);
1834     va_TraceMsg(trace_ctx, "\tinloop_decoded_picture = 0x%08x\n", p->inloop_decoded_picture);
1835     
1836     va_TraceMsg(trace_ctx, "\tpulldown = %d\n", p->sequence_fields.bits.pulldown);
1837     va_TraceMsg(trace_ctx, "\tinterlace = %d\n", p->sequence_fields.bits.interlace);
1838     va_TraceMsg(trace_ctx, "\ttfcntrflag = %d\n", p->sequence_fields.bits.tfcntrflag);
1839     va_TraceMsg(trace_ctx, "\tfinterpflag = %d\n", p->sequence_fields.bits.finterpflag);
1840     va_TraceMsg(trace_ctx, "\tpsf = %d\n", p->sequence_fields.bits.psf);
1841     va_TraceMsg(trace_ctx, "\tmultires = %d\n", p->sequence_fields.bits.multires);
1842     va_TraceMsg(trace_ctx, "\toverlap = %d\n", p->sequence_fields.bits.overlap);
1843     va_TraceMsg(trace_ctx, "\tsyncmarker = %d\n", p->sequence_fields.bits.syncmarker);
1844     va_TraceMsg(trace_ctx, "\trangered = %d\n", p->sequence_fields.bits.rangered);
1845     va_TraceMsg(trace_ctx, "\tmax_b_frames = %d\n", p->sequence_fields.bits.max_b_frames);
1846     va_TraceMsg(trace_ctx, "\tprofile = %d\n", p->sequence_fields.bits.profile);
1847     va_TraceMsg(trace_ctx, "\tcoded_width = %d\n", p->coded_width);
1848     va_TraceMsg(trace_ctx, "\tcoded_height = %d\n", p->coded_height);
1849     va_TraceMsg(trace_ctx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry);
1850     va_TraceMsg(trace_ctx, "\tbroken_link = %d\n", p->entrypoint_fields.bits.broken_link);
1851     va_TraceMsg(trace_ctx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry);
1852     va_TraceMsg(trace_ctx, "\tpanscan_flag = %d\n", p->entrypoint_fields.bits.panscan_flag);
1853     va_TraceMsg(trace_ctx, "\tloopfilter = %d\n", p->entrypoint_fields.bits.loopfilter);
1854     va_TraceMsg(trace_ctx, "\tconditional_overlap_flag = %d\n", p->conditional_overlap_flag);
1855     va_TraceMsg(trace_ctx, "\tfast_uvmc_flag = %d\n", p->fast_uvmc_flag);
1856     va_TraceMsg(trace_ctx, "\trange_mapping_luma_flag = %d\n", p->range_mapping_fields.bits.luma_flag);
1857     va_TraceMsg(trace_ctx, "\trange_mapping_luma = %d\n", p->range_mapping_fields.bits.luma);
1858     va_TraceMsg(trace_ctx, "\trange_mapping_chroma_flag = %d\n", p->range_mapping_fields.bits.chroma_flag);
1859     va_TraceMsg(trace_ctx, "\trange_mapping_chroma = %d\n", p->range_mapping_fields.bits.chroma);
1860     va_TraceMsg(trace_ctx, "\tb_picture_fraction = %d\n", p->b_picture_fraction);
1861     va_TraceMsg(trace_ctx, "\tcbp_table = %d\n", p->cbp_table);
1862     va_TraceMsg(trace_ctx, "\tmb_mode_table = %d\n", p->mb_mode_table);
1863     va_TraceMsg(trace_ctx, "\trange_reduction_frame = %d\n", p->range_reduction_frame);
1864     va_TraceMsg(trace_ctx, "\trounding_control = %d\n", p->rounding_control);
1865     va_TraceMsg(trace_ctx, "\tpost_processing = %d\n", p->post_processing);
1866     va_TraceMsg(trace_ctx, "\tpicture_resolution_index = %d\n", p->picture_resolution_index);
1867     va_TraceMsg(trace_ctx, "\tluma_scale = %d\n", p->luma_scale);
1868     va_TraceMsg(trace_ctx, "\tluma_shift = %d\n", p->luma_shift);
1869     va_TraceMsg(trace_ctx, "\tpicture_type = %d\n", p->picture_fields.bits.picture_type);
1870     va_TraceMsg(trace_ctx, "\tframe_coding_mode = %d\n", p->picture_fields.bits.frame_coding_mode);
1871     va_TraceMsg(trace_ctx, "\ttop_field_first = %d\n", p->picture_fields.bits.top_field_first);
1872     va_TraceMsg(trace_ctx, "\tis_first_field = %d\n", p->picture_fields.bits.is_first_field);
1873     va_TraceMsg(trace_ctx, "\tintensity_compensation = %d\n", p->picture_fields.bits.intensity_compensation);
1874     va_TraceMsg(trace_ctx, "\tmv_type_mb = %d\n", p->raw_coding.flags.mv_type_mb);
1875     va_TraceMsg(trace_ctx, "\tdirect_mb = %d\n", p->raw_coding.flags.direct_mb);
1876     va_TraceMsg(trace_ctx, "\tskip_mb = %d\n", p->raw_coding.flags.skip_mb);
1877     va_TraceMsg(trace_ctx, "\tfield_tx = %d\n", p->raw_coding.flags.field_tx);
1878     va_TraceMsg(trace_ctx, "\tforward_mb = %d\n", p->raw_coding.flags.forward_mb);
1879     va_TraceMsg(trace_ctx, "\tac_pred = %d\n", p->raw_coding.flags.ac_pred);
1880     va_TraceMsg(trace_ctx, "\toverflags = %d\n", p->raw_coding.flags.overflags);
1881     va_TraceMsg(trace_ctx, "\tbp_mv_type_mb = %d\n", p->bitplane_present.flags.bp_mv_type_mb);
1882     va_TraceMsg(trace_ctx, "\tbp_direct_mb = %d\n", p->bitplane_present.flags.bp_direct_mb);
1883     va_TraceMsg(trace_ctx, "\tbp_skip_mb = %d\n", p->bitplane_present.flags.bp_skip_mb);
1884     va_TraceMsg(trace_ctx, "\tbp_field_tx = %d\n", p->bitplane_present.flags.bp_field_tx);
1885     va_TraceMsg(trace_ctx, "\tbp_forward_mb = %d\n", p->bitplane_present.flags.bp_forward_mb);
1886     va_TraceMsg(trace_ctx, "\tbp_ac_pred = %d\n", p->bitplane_present.flags.bp_ac_pred);
1887     va_TraceMsg(trace_ctx, "\tbp_overflags = %d\n", p->bitplane_present.flags.bp_overflags);
1888     va_TraceMsg(trace_ctx, "\treference_distance_flag = %d\n", p->reference_fields.bits.reference_distance_flag);
1889     va_TraceMsg(trace_ctx, "\treference_distance = %d\n", p->reference_fields.bits.reference_distance);
1890     va_TraceMsg(trace_ctx, "\tnum_reference_pictures = %d\n", p->reference_fields.bits.num_reference_pictures);
1891     va_TraceMsg(trace_ctx, "\treference_field_pic_indicator = %d\n", p->reference_fields.bits.reference_field_pic_indicator);
1892     va_TraceMsg(trace_ctx, "\tmv_mode = %d\n", p->mv_fields.bits.mv_mode);
1893     va_TraceMsg(trace_ctx, "\tmv_mode2 = %d\n", p->mv_fields.bits.mv_mode2);
1894     va_TraceMsg(trace_ctx, "\tmv_table = %d\n", p->mv_fields.bits.mv_table);
1895     va_TraceMsg(trace_ctx, "\ttwo_mv_block_pattern_table = %d\n", p->mv_fields.bits.two_mv_block_pattern_table);
1896     va_TraceMsg(trace_ctx, "\tfour_mv_switch = %d\n", p->mv_fields.bits.four_mv_switch);
1897     va_TraceMsg(trace_ctx, "\tfour_mv_block_pattern_table = %d\n", p->mv_fields.bits.four_mv_block_pattern_table);
1898     va_TraceMsg(trace_ctx, "\textended_mv_flag = %d\n", p->mv_fields.bits.extended_mv_flag);
1899     va_TraceMsg(trace_ctx, "\textended_mv_range = %d\n", p->mv_fields.bits.extended_mv_range);
1900     va_TraceMsg(trace_ctx, "\textended_dmv_flag = %d\n", p->mv_fields.bits.extended_dmv_flag);
1901     va_TraceMsg(trace_ctx, "\textended_dmv_range = %d\n", p->mv_fields.bits.extended_dmv_range);
1902     va_TraceMsg(trace_ctx, "\tdquant = %d\n", p->pic_quantizer_fields.bits.dquant);
1903     va_TraceMsg(trace_ctx, "\tquantizer = %d\n", p->pic_quantizer_fields.bits.quantizer);
1904     va_TraceMsg(trace_ctx, "\thalf_qp = %d\n", p->pic_quantizer_fields.bits.half_qp);
1905     va_TraceMsg(trace_ctx, "\tpic_quantizer_scale = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_scale);
1906     va_TraceMsg(trace_ctx, "\tpic_quantizer_type = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_type);
1907     va_TraceMsg(trace_ctx, "\tdq_frame = %d\n", p->pic_quantizer_fields.bits.dq_frame);
1908     va_TraceMsg(trace_ctx, "\tdq_profile = %d\n", p->pic_quantizer_fields.bits.dq_profile);
1909     va_TraceMsg(trace_ctx, "\tdq_sb_edge = %d\n", p->pic_quantizer_fields.bits.dq_sb_edge);
1910     va_TraceMsg(trace_ctx, "\tdq_db_edge = %d\n", p->pic_quantizer_fields.bits.dq_db_edge);
1911     va_TraceMsg(trace_ctx, "\tdq_binary_level = %d\n", p->pic_quantizer_fields.bits.dq_binary_level);
1912     va_TraceMsg(trace_ctx, "\talt_pic_quantizer = %d\n", p->pic_quantizer_fields.bits.alt_pic_quantizer);
1913     va_TraceMsg(trace_ctx, "\tvariable_sized_transform_flag = %d\n", p->transform_fields.bits.variable_sized_transform_flag);
1914     va_TraceMsg(trace_ctx, "\tmb_level_transform_type_flag = %d\n", p->transform_fields.bits.mb_level_transform_type_flag);
1915     va_TraceMsg(trace_ctx, "\tframe_level_transform_type = %d\n", p->transform_fields.bits.frame_level_transform_type);
1916     va_TraceMsg(trace_ctx, "\ttransform_ac_codingset_idx1 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx1);
1917     va_TraceMsg(trace_ctx, "\ttransform_ac_codingset_idx2 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx2);
1918     va_TraceMsg(trace_ctx, "\tintra_transform_dc_table = %d\n", p->transform_fields.bits.intra_transform_dc_table);
1919     va_TraceMsg(trace_ctx, NULL);
1920 }
1921
1922 static void va_TraceVASliceParameterBufferVC1(
1923     VADisplay dpy,
1924     VAContextID context,
1925     VABufferID buffer,
1926     VABufferType type,
1927     unsigned int size,
1928     unsigned int num_elements,
1929     void* data
1930 )
1931 {
1932     VASliceParameterBufferVC1 *p = (VASliceParameterBufferVC1*)data;
1933     DPY2TRACECTX(dpy);
1934
1935     trace_ctx->trace_slice_no++;
1936     trace_ctx->trace_slice_size = p->slice_data_size;
1937
1938     va_TraceMsg(trace_ctx, "VASliceParameterBufferVC1\n");
1939     va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size);
1940     va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset);
1941     va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag);
1942     va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset);
1943     va_TraceMsg(trace_ctx, "\tslice_vertical_position = %d\n", p->slice_vertical_position);
1944     va_TraceMsg(trace_ctx, NULL);
1945 }
1946
1947 void va_TraceBeginPicture(
1948     VADisplay dpy,
1949     VAContextID context,
1950     VASurfaceID render_target
1951 )
1952 {
1953     DPY2TRACECTX(dpy);
1954
1955     TRACE_FUNCNAME(idx);
1956
1957     va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
1958     va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", render_target);
1959     va_TraceMsg(trace_ctx, "\tframe_count  = #%d\n", trace_ctx->trace_frame_no);
1960     va_TraceMsg(trace_ctx, NULL);
1961
1962     trace_ctx->trace_rendertarget = render_target; /* for surface data dump after vaEndPicture */
1963
1964     trace_ctx->trace_frame_no++;
1965     trace_ctx->trace_slice_no = 0;
1966 }
1967
1968 static void va_TraceMPEG2Buf(
1969     VADisplay dpy,
1970     VAContextID context,
1971     VABufferID buffer,
1972     VABufferType type,
1973     unsigned int size,
1974     unsigned int num_elements,
1975     void *pbuf
1976 )
1977 {
1978     switch (type) {
1979     case VAPictureParameterBufferType:
1980         va_TraceVAPictureParameterBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
1981         break;
1982     case VAIQMatrixBufferType:
1983         va_TraceVAIQMatrixBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
1984         break;
1985     case VABitPlaneBufferType:
1986         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1987         break;
1988     case VASliceGroupMapBufferType:
1989         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1990         break;
1991     case VASliceParameterBufferType:
1992         va_TraceVASliceParameterBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf);
1993         break;
1994     case VASliceDataBufferType:
1995         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1996         break;
1997     case VAMacroblockParameterBufferType:
1998         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
1999         break;
2000     case VAResidualDataBufferType:
2001         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2002         break;
2003     case VADeblockingParameterBufferType:
2004         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2005         break;
2006     case VAImageBufferType:
2007         break;
2008     case VAProtectedSliceDataBufferType:
2009         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2010         break;
2011     case VAEncCodedBufferType:
2012         break;
2013     case VAEncSequenceParameterBufferType:
2014         break;
2015     case VAEncPictureParameterBufferType:
2016         break;
2017     case VAEncSliceParameterBufferType:
2018         break;
2019     default:
2020         break;
2021     }
2022 }
2023
2024 static void va_TraceVAEncSequenceParameterBufferH263(
2025     VADisplay dpy,
2026     VAContextID context,
2027     VABufferID buffer,
2028     VABufferType type,
2029     unsigned int size,
2030     unsigned int num_elements,
2031     void *data)
2032 {
2033     VAEncSequenceParameterBufferH263 *p = (VAEncSequenceParameterBufferH263 *)data;
2034     DPY2TRACECTX(dpy);
2035     
2036     va_TraceMsg(trace_ctx, "VAEncSequenceParameterBufferH263\n");
2037     
2038     va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
2039     va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
2040     va_TraceMsg(trace_ctx, "\tframe_rate = %d\n", p->frame_rate);
2041     va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp);
2042     va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
2043     va_TraceMsg(trace_ctx, NULL);
2044
2045     /* start a new sequce, coded log file can be truncated */
2046     trace_ctx->trace_sequence_start = 1;
2047
2048     return;
2049 }
2050
2051
2052 static void va_TraceVAEncPictureParameterBufferH263(
2053     VADisplay dpy,
2054     VAContextID context,
2055     VABufferID buffer,
2056     VABufferType type,
2057     unsigned int size,
2058     unsigned int num_elements,
2059     void *data)
2060 {
2061     VAEncPictureParameterBufferH263 *p = (VAEncPictureParameterBufferH263 *)data;
2062     DPY2TRACECTX(dpy);
2063     
2064     va_TraceMsg(trace_ctx, "VAEncPictureParameterBufferH263\n");
2065     va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture);
2066     va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
2067     va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf);
2068     va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width);
2069     va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height);
2070     va_TraceMsg(trace_ctx, "\tpicture_type = 0x%08x\n", p->picture_type);
2071     va_TraceMsg(trace_ctx, NULL);
2072
2073     trace_ctx->trace_codedbuf =  p->coded_buf;
2074     
2075     return;
2076 }
2077
2078 static void va_TraceVAEncPictureParameterBufferJPEG(
2079     VADisplay dpy,
2080     VAContextID context,
2081     VABufferID buffer,
2082     VABufferType type,
2083     unsigned int size,
2084     unsigned int num_elements,
2085     void *data)
2086 {
2087     VAEncPictureParameterBufferJPEG *p = (VAEncPictureParameterBufferJPEG *)data;
2088     int i;
2089     
2090     DPY2TRACECTX(dpy);
2091     
2092     va_TraceMsg(trace_ctx, "VAEncPictureParameterBufferJPEG\n");
2093     va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
2094     va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf);
2095     va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width);
2096     va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height);
2097
2098     va_TraceMsg(trace_ctx, NULL);
2099
2100     trace_ctx->trace_codedbuf =  p->coded_buf;
2101     
2102     return;
2103 }
2104
2105 static void va_TraceVAEncQMatrixBufferJPEG(
2106     VADisplay dpy,
2107     VAContextID context,
2108     VABufferID buffer,
2109     VABufferType type,
2110     unsigned int size,
2111     unsigned int num_elements,
2112     void *data)
2113 {
2114     VAQMatrixBufferJPEG *p = (VAQMatrixBufferJPEG *)data;
2115     DPY2TRACECTX(dpy);
2116     
2117     va_TraceMsg(trace_ctx, "VAQMatrixBufferJPEG\n");
2118     va_TraceMsg(trace_ctx, "\tload_lum_quantiser_matrix = %d", p->load_lum_quantiser_matrix);
2119     if (p->load_lum_quantiser_matrix) {
2120         int i;
2121         for (i = 0; i < 64; i++) {
2122             if ((i % 8) == 0)
2123                 va_TraceMsg(trace_ctx, "\n\t");
2124             va_TraceMsg(trace_ctx, "\t0x%02x", p->lum_quantiser_matrix[i]);
2125         }
2126         va_TraceMsg(trace_ctx, "\n");
2127     }
2128     va_TraceMsg(trace_ctx, "\tload_chroma_quantiser_matrix = %08x\n", p->load_chroma_quantiser_matrix);
2129     if (p->load_chroma_quantiser_matrix) {
2130         int i;
2131         for (i = 0; i < 64; i++) {
2132             if ((i % 8) == 0)
2133                 va_TraceMsg(trace_ctx, "\n\t");
2134             va_TraceMsg(trace_ctx, "\t0x%02x", p->chroma_quantiser_matrix[i]);
2135         }
2136         va_TraceMsg(trace_ctx, "\n");
2137     }
2138     
2139     va_TraceMsg(trace_ctx, NULL);
2140     
2141     return;
2142 }
2143
2144 static void va_TraceH263Buf(
2145     VADisplay dpy,
2146     VAContextID context,
2147     VABufferID buffer,
2148     VABufferType type,
2149     unsigned int size,
2150     unsigned int num_elements,
2151     void *pbuf
2152 )
2153 {
2154     switch (type) {
2155     case VAPictureParameterBufferType:/* print MPEG4 buffer */
2156         va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2157         break;
2158     case VAIQMatrixBufferType:/* print MPEG4 buffer */
2159         va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2160         break;
2161     case VABitPlaneBufferType:/* print MPEG4 buffer */
2162         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2163         break;
2164     case VASliceGroupMapBufferType:
2165         break;
2166     case VASliceParameterBufferType:/* print MPEG4 buffer */
2167         va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2168         break;
2169     case VASliceDataBufferType:
2170         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2171         break;
2172     case VAMacroblockParameterBufferType:
2173         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2174         break;
2175     case VAResidualDataBufferType:
2176         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2177         break;
2178     case VADeblockingParameterBufferType:
2179         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2180         break;
2181     case VAImageBufferType:
2182         break;
2183     case VAProtectedSliceDataBufferType:
2184         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2185         break;
2186     case VAEncCodedBufferType:
2187         break;
2188     case VAEncSequenceParameterBufferType:
2189         va_TraceVAEncSequenceParameterBufferH263(dpy, context, buffer, type, size, num_elements, pbuf);
2190         break;
2191     case VAEncPictureParameterBufferType:
2192         va_TraceVAEncPictureParameterBufferH263(dpy, context, buffer, type, size, num_elements, pbuf);
2193         break;
2194     case VAEncSliceParameterBufferType:
2195         va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2196         break;
2197     case VAEncPackedHeaderParameterBufferType:
2198         va_TraceVAEncPackedHeaderParameterBufferType(dpy, context, buffer, type, size, num_elements, pbuf);
2199         break;
2200     default:
2201         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2202         break;
2203     }
2204 }
2205
2206
2207 static void va_TraceJPEGBuf(
2208     VADisplay dpy,
2209     VAContextID context,
2210     VABufferID buffer,
2211     VABufferType type,
2212     unsigned int size,
2213     unsigned int num_elements,
2214     void *pbuf
2215 )
2216 {
2217     switch (type) {
2218     case VABitPlaneBufferType:
2219     case VASliceGroupMapBufferType:
2220     case VASliceDataBufferType:
2221     case VAMacroblockParameterBufferType:
2222     case VAResidualDataBufferType:
2223     case VADeblockingParameterBufferType:
2224     case VAImageBufferType:
2225     case VAProtectedSliceDataBufferType:
2226     case VAEncCodedBufferType:
2227     case VAEncSequenceParameterBufferType:
2228         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2229         break;
2230     case VAEncSliceParameterBufferType:
2231         va_TraceVAEncPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2232         break;
2233     case VAPictureParameterBufferType:
2234         va_TraceVAPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2235         break;
2236     case VAIQMatrixBufferType:
2237         va_TraceVAIQMatrixBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2238         break;
2239     case VASliceParameterBufferType:
2240         va_TraceVASliceParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2241         break;
2242     case VAHuffmanTableBufferType:
2243         va_TraceVAHuffmanTableBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2244         break;
2245     case VAEncPictureParameterBufferType:
2246         va_TraceVAEncPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2247         break;
2248     case VAQMatrixBufferType:
2249         va_TraceVAEncQMatrixBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
2250         break;
2251     default:
2252         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2253         break;
2254     }
2255 }
2256
2257 static void va_TraceMPEG4Buf(
2258     VADisplay dpy,
2259     VAContextID context,
2260     VABufferID buffer,
2261     VABufferType type,
2262     unsigned int size,
2263     unsigned int num_elements,
2264     void *pbuf
2265 )
2266 {
2267     switch (type) {
2268     case VAPictureParameterBufferType:
2269         va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2270         break;
2271     case VAIQMatrixBufferType:
2272         va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2273         break;
2274     case VABitPlaneBufferType:
2275         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2276         break;
2277     case VASliceGroupMapBufferType:
2278         break;
2279     case VASliceParameterBufferType:
2280         va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2281         break;
2282     case VASliceDataBufferType:
2283         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2284         break;
2285     case VAMacroblockParameterBufferType:
2286         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2287         break;
2288     case VAResidualDataBufferType:
2289         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2290         break;
2291     case VADeblockingParameterBufferType:
2292         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2293         break;
2294     case VAImageBufferType:
2295         break;
2296     case VAProtectedSliceDataBufferType:
2297         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2298         break;
2299     case VAEncCodedBufferType:
2300         break;
2301     case VAEncSequenceParameterBufferType:
2302         va_TraceVAEncSequenceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2303         break;
2304     case VAEncPictureParameterBufferType:
2305         va_TraceVAEncPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
2306         break;
2307     case VAEncSliceParameterBufferType:
2308         va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2309         break;
2310     default:
2311         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2312         break;
2313     }
2314 }
2315
2316
2317 static void va_TraceH264Buf(
2318     VADisplay dpy,
2319     VAContextID context,
2320     VABufferID buffer,
2321     VABufferType type,
2322     unsigned int size,
2323     unsigned int num_elements,
2324     void *pbuf
2325 )
2326 {
2327     DPY2TRACECTX(dpy);
2328     
2329     switch (type) {
2330     case VAPictureParameterBufferType:
2331         va_TraceVAPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2332         break;
2333     case VAIQMatrixBufferType:
2334         va_TraceVAIQMatrixBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2335         break;
2336     case VABitPlaneBufferType:
2337         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);        
2338         break;
2339     case VASliceGroupMapBufferType:
2340         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2341         break;
2342     case VASliceParameterBufferType:
2343         va_TraceVASliceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2344         break;
2345     case VASliceDataBufferType:
2346         va_TraceVABuffers(dpy, context, buffer, type, trace_ctx->trace_slice_size, num_elements, pbuf);
2347         break;
2348     case VAMacroblockParameterBufferType:
2349         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);        
2350         break;
2351     case VAResidualDataBufferType:
2352         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);        
2353         break;
2354     case VADeblockingParameterBufferType:
2355         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2356         break;
2357     case VAImageBufferType:
2358         break;
2359     case VAProtectedSliceDataBufferType:
2360         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2361         break;
2362     case VAEncCodedBufferType:
2363         break;
2364     case VAEncSequenceParameterBufferType:
2365         va_TraceVAEncSequenceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2366         break;
2367     case VAEncPictureParameterBufferType:
2368         va_TraceVAEncPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2369         break;
2370     case VAEncSliceParameterBufferType:
2371         if (size == sizeof(VAEncSliceParameterBuffer))
2372             va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2373         else
2374             va_TraceVAEncSliceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf);
2375         break;
2376     case VAEncPackedHeaderParameterBufferType:
2377         va_TraceVAEncPackedHeaderParameterBufferType(dpy, context, buffer, type, size, num_elements, pbuf);
2378         break;
2379         
2380     case VAEncMiscParameterBufferType:
2381         va_TraceVAEncMiscParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf);
2382         break;
2383     default:
2384         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2385         break;
2386     }
2387 }
2388
2389
2390 static void va_TraceVC1Buf(
2391     VADisplay dpy,
2392     VAContextID context,
2393     VABufferID buffer,
2394     VABufferType type,
2395     unsigned int size,
2396     unsigned int num_elements,
2397     void *pbuf
2398 )
2399 {
2400     DPY2TRACECTX(dpy);
2401
2402     switch (type) {
2403     case VAPictureParameterBufferType:
2404         va_TraceVAPictureParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf);
2405         break;
2406     case VAIQMatrixBufferType:
2407         break;
2408     case VABitPlaneBufferType:
2409         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2410         break;
2411     case VASliceGroupMapBufferType:
2412         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2413         break;
2414     case VASliceParameterBufferType:
2415         va_TraceVASliceParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf);
2416         break;
2417     case VASliceDataBufferType:
2418         va_TraceVABuffers(dpy, context, buffer, type, trace_ctx->trace_slice_size, num_elements, pbuf);
2419         break;
2420     case VAMacroblockParameterBufferType:
2421         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2422         break;
2423     case VAResidualDataBufferType:
2424         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2425         break;
2426     case VADeblockingParameterBufferType:
2427         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2428         break;
2429     case VAImageBufferType:
2430         break;
2431     case VAProtectedSliceDataBufferType:
2432         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2433         break;
2434     case VAEncCodedBufferType:
2435         break;
2436     case VAEncSequenceParameterBufferType:
2437         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2438         break;
2439     case VAEncPictureParameterBufferType:
2440         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2441         break;
2442     case VAEncSliceParameterBufferType:
2443         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2444         break;
2445     default:
2446         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
2447         break;
2448     }
2449 }
2450
2451 void va_TraceRenderPicture(
2452     VADisplay dpy,
2453     VAContextID context,
2454     VABufferID *buffers,
2455     int num_buffers
2456 )
2457 {
2458     VABufferType type;
2459     unsigned int size;
2460     unsigned int num_elements;
2461     int i;
2462     DPY2TRACECTX(dpy);
2463
2464     TRACE_FUNCNAME(idx);
2465     
2466     va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
2467     va_TraceMsg(trace_ctx, "\tnum_buffers = %d\n", num_buffers);
2468     if (buffers == NULL)
2469         return;
2470     
2471     for (i = 0; i < num_buffers; i++) {
2472         unsigned char *pbuf = NULL;
2473         unsigned int j;
2474         
2475         /* get buffer type information */
2476         vaBufferInfo(dpy, context, buffers[i], &type, &size, &num_elements);
2477
2478         va_TraceMsg(trace_ctx, "\t---------------------------\n");
2479         va_TraceMsg(trace_ctx, "\tbuffers[%d] = 0x%08x\n", i, buffers[i]);
2480         va_TraceMsg(trace_ctx, "\t  type = %s\n", buffer_type_to_string(type));
2481         va_TraceMsg(trace_ctx, "\t  size = %d\n", size);
2482         va_TraceMsg(trace_ctx, "\t  num_elements = %d\n", num_elements);
2483
2484         vaMapBuffer(dpy, buffers[i], (void **)&pbuf);
2485         if (pbuf == NULL)
2486             continue;
2487         
2488         switch (trace_ctx->trace_profile) {
2489         case VAProfileMPEG2Simple:
2490         case VAProfileMPEG2Main:
2491             for (j=0; j<num_elements; j++) {
2492                 va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
2493                 va_TraceMPEG2Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2494             }
2495             break;
2496         case VAProfileMPEG4Simple:
2497         case VAProfileMPEG4AdvancedSimple:
2498         case VAProfileMPEG4Main:
2499             for (j=0; j<num_elements; j++) {
2500                 va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
2501                 va_TraceMPEG4Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2502             }
2503             break;
2504         case VAProfileH264Baseline:
2505         case VAProfileH264Main:
2506         case VAProfileH264High:
2507         case VAProfileH264ConstrainedBaseline:
2508             for (j=0; j<num_elements; j++) {
2509                 va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
2510                 
2511                 va_TraceH264Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2512             }
2513             break;
2514         case VAProfileVC1Simple:
2515         case VAProfileVC1Main:
2516         case VAProfileVC1Advanced:
2517             for (j=0; j<num_elements; j++) {
2518                 va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
2519                 
2520                 va_TraceVC1Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2521             }
2522             break;
2523         case VAProfileH263Baseline:
2524             for (j=0; j<num_elements; j++) {
2525                 va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
2526                 
2527                 va_TraceH263Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2528             }
2529             break;
2530         case VAProfileJPEGBaseline:
2531             for (j=0; j<num_elements; j++) {
2532                 va_TraceMsg(trace_ctx, "\telement[%d] = ", j);
2533                 
2534                 va_TraceJPEGBuf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
2535             }
2536             break;
2537         default:
2538             break;
2539         }
2540
2541         vaUnmapBuffer(dpy, buffers[i]);
2542     }
2543
2544     va_TraceMsg(trace_ctx, NULL);
2545 }
2546
2547 void va_TraceEndPicture(
2548     VADisplay dpy,
2549     VAContextID context,
2550     int endpic_done
2551 )
2552 {
2553     int encode, decode, jpeg;
2554     DPY2TRACECTX(dpy);
2555
2556     TRACE_FUNCNAME(idx);
2557
2558     va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
2559     va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", trace_ctx->trace_rendertarget);
2560
2561     /* avoid to create so many empty files */
2562     encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice);
2563     decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD);
2564     jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture);
2565
2566     /* trace encode source surface, can do it before HW completes rendering */
2567     if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE))||
2568             (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG)))
2569         va_TraceSurface(dpy);
2570     
2571     /* trace coded buffer, do it after HW completes rendering */
2572     if ((encode || jpeg) && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) {
2573         vaSyncSurface(dpy, trace_ctx->trace_rendertarget);
2574         va_TraceCodedBuf(dpy);
2575     }
2576
2577     /* trace decoded surface, do it after HW completes rendering */
2578     if (decode && ((trace_flag & VA_TRACE_FLAG_SURFACE_DECODE))) {
2579         vaSyncSurface(dpy, trace_ctx->trace_rendertarget);
2580         va_TraceSurface(dpy);
2581     }
2582
2583     va_TraceMsg(trace_ctx, NULL);
2584 }
2585
2586
2587 void va_TraceSyncSurface(
2588     VADisplay dpy,
2589     VASurfaceID render_target
2590 )
2591 {
2592     DPY2TRACECTX(dpy);
2593
2594     TRACE_FUNCNAME(idx);
2595
2596     va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target);
2597     va_TraceMsg(trace_ctx, NULL);
2598 }
2599
2600 void va_TraceQuerySurfaceAttributes(
2601     VADisplay           dpy,
2602     VAConfigID          config,
2603     VASurfaceAttrib    *attrib_list,
2604     unsigned int       *num_attribs
2605 )
2606 {
2607     DPY2TRACECTX(dpy);
2608
2609     TRACE_FUNCNAME(idx);
2610     va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config);
2611     va_TraceSurfaceAttributes(trace_ctx, attrib_list, num_attribs);
2612     
2613     va_TraceMsg(trace_ctx, NULL);
2614
2615 }
2616
2617
2618 void va_TraceQuerySurfaceStatus(
2619     VADisplay dpy,
2620     VASurfaceID render_target,
2621     VASurfaceStatus *status    /* out */
2622 )
2623 {
2624     DPY2TRACECTX(dpy);
2625
2626     TRACE_FUNCNAME(idx);
2627
2628     va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target);
2629     if (status)
2630         va_TraceMsg(trace_ctx, "\tstatus = 0x%08x\n", *status);
2631     va_TraceMsg(trace_ctx, NULL);
2632 }
2633
2634
2635 void va_TraceQuerySurfaceError(
2636     VADisplay dpy,
2637     VASurfaceID surface,
2638     VAStatus error_status,
2639     void **error_info       /*out*/
2640 )
2641 {
2642     DPY2TRACECTX(dpy);
2643
2644     TRACE_FUNCNAME(idx);
2645     va_TraceMsg(trace_ctx, "\tsurface = 0x%08x\n", surface);
2646     va_TraceMsg(trace_ctx, "\terror_status = 0x%08x\n", error_status);
2647     if (error_info && (error_status == VA_STATUS_ERROR_DECODING_ERROR)) {
2648         VASurfaceDecodeMBErrors *p = *error_info;
2649         while (p && (p->status != -1)) {
2650             va_TraceMsg(trace_ctx, "\t\tstatus = %d\n", p->status);
2651             va_TraceMsg(trace_ctx, "\t\tstart_mb = %d\n", p->start_mb);
2652             va_TraceMsg(trace_ctx, "\t\tend_mb = %d\n", p->end_mb);
2653             p++; /* next error record */
2654         }
2655     }
2656     va_TraceMsg(trace_ctx, NULL);
2657 }
2658
2659 void va_TraceMaxNumDisplayAttributes (
2660     VADisplay dpy,
2661     int number
2662 )
2663 {
2664     DPY2TRACECTX(dpy);
2665
2666     TRACE_FUNCNAME(idx);
2667     
2668     va_TraceMsg(trace_ctx, "\tmax_display_attributes = %d\n", number);
2669     va_TraceMsg(trace_ctx, NULL);
2670 }
2671
2672 void va_TraceQueryDisplayAttributes (
2673     VADisplay dpy,
2674     VADisplayAttribute *attr_list,    /* out */
2675     int *num_attributes               /* out */
2676 )
2677 {
2678     int i;
2679     
2680     DPY2TRACECTX(dpy);
2681     
2682     if (attr_list == NULL || num_attributes == NULL)
2683         return;
2684
2685     va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", *num_attributes);
2686     
2687     for (i=0; i<*num_attributes; i++) {
2688         va_TraceMsg(trace_ctx, "\tattr_list[%d] =\n");
2689         va_TraceMsg(trace_ctx, "\t  typ = 0x%08x\n", attr_list[i].type);
2690         va_TraceMsg(trace_ctx, "\t  min_value = %d\n", attr_list[i].min_value);
2691         va_TraceMsg(trace_ctx, "\t  max_value = %d\n", attr_list[i].max_value);
2692         va_TraceMsg(trace_ctx, "\t  value = %d\n", attr_list[i].value);
2693         va_TraceMsg(trace_ctx, "\t  flags = %d\n", attr_list[i].flags);
2694     }
2695     va_TraceMsg(trace_ctx, NULL);
2696 }
2697
2698
2699 static void va_TraceDisplayAttributes (
2700     VADisplay dpy,
2701     VADisplayAttribute *attr_list,
2702     int num_attributes
2703 )
2704 {
2705     int i;
2706     
2707     DPY2TRACECTX(dpy);
2708     
2709     va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", num_attributes);
2710     if (attr_list == NULL)
2711         return;
2712     
2713     for (i=0; i<num_attributes; i++) {
2714         va_TraceMsg(trace_ctx, "\tattr_list[%d] =\n");
2715         va_TraceMsg(trace_ctx, "\t  typ = 0x%08x\n", attr_list[i].type);
2716         va_TraceMsg(trace_ctx, "\t  min_value = %d\n", attr_list[i].min_value);
2717         va_TraceMsg(trace_ctx, "\t  max_value = %d\n", attr_list[i].max_value);
2718         va_TraceMsg(trace_ctx, "\t  value = %d\n", attr_list[i].value);
2719         va_TraceMsg(trace_ctx, "\t  flags = %d\n", attr_list[i].flags);
2720     }
2721     va_TraceMsg(trace_ctx, NULL);
2722 }
2723
2724
2725 void va_TraceGetDisplayAttributes (
2726     VADisplay dpy,
2727     VADisplayAttribute *attr_list,
2728     int num_attributes
2729 )
2730 {
2731     DPY2TRACECTX(dpy);
2732
2733     TRACE_FUNCNAME(idx);
2734
2735     va_TraceDisplayAttributes (dpy, attr_list, num_attributes);
2736 }
2737
2738 void va_TraceSetDisplayAttributes (
2739     VADisplay dpy,
2740     VADisplayAttribute *attr_list,
2741     int num_attributes
2742 )
2743 {
2744     DPY2TRACECTX(dpy);
2745
2746     TRACE_FUNCNAME(idx);
2747
2748     va_TraceDisplayAttributes (dpy, attr_list, num_attributes);
2749 }
2750
2751
2752 void va_TracePutSurface (
2753     VADisplay dpy,
2754     VASurfaceID surface,
2755     void *draw, /* the target Drawable */
2756     short srcx,
2757     short srcy,
2758     unsigned short srcw,
2759     unsigned short srch,
2760     short destx,
2761     short desty,
2762     unsigned short destw,
2763     unsigned short desth,
2764     VARectangle *cliprects, /* client supplied clip list */
2765     unsigned int number_cliprects, /* number of clip rects in the clip list */
2766     unsigned int flags /* de-interlacing flags */
2767 )
2768 {
2769     DPY2TRACECTX(dpy);
2770
2771     TRACE_FUNCNAME(idx);
2772     
2773     va_TraceMsg(trace_ctx, "\tsurface = 0x%08x\n", surface);
2774     va_TraceMsg(trace_ctx, "\tdraw = 0x%08x\n", draw);
2775     va_TraceMsg(trace_ctx, "\tsrcx = %d\n", srcx);
2776     va_TraceMsg(trace_ctx, "\tsrcy = %d\n", srcy);
2777     va_TraceMsg(trace_ctx, "\tsrcw = %d\n", srcw);
2778     va_TraceMsg(trace_ctx, "\tsrch = %d\n", srch);
2779     va_TraceMsg(trace_ctx, "\tdestx = %d\n", destx);
2780     va_TraceMsg(trace_ctx, "\tdesty = %d\n", desty);
2781     va_TraceMsg(trace_ctx, "\tdestw = %d\n", destw);
2782     va_TraceMsg(trace_ctx, "\tdesth = %d\n", desth);
2783     va_TraceMsg(trace_ctx, "\tcliprects = 0x%08x\n", cliprects);
2784     va_TraceMsg(trace_ctx, "\tnumber_cliprects = %d\n", number_cliprects);
2785     va_TraceMsg(trace_ctx, "\tflags = 0x%08x\n", flags);
2786     va_TraceMsg(trace_ctx, NULL);
2787 }