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