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