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