blob: 52a4a7cf830406146987afeebcf439d2456a28d4 [file] [log] [blame]
/*
* Copyright (c) 2009-2011 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define _GNU_SOURCE 1
#include "sysdeps.h"
#include "va.h"
#include "va_enc_h264.h"
#include "va_backend.h"
#include "va_internal.h"
#include "va_trace.h"
#include "va_enc_h264.h"
#include "va_enc_jpeg.h"
#include "va_enc_vp8.h"
#include "va_dec_jpeg.h"
#include "va_dec_vp8.h"
#include "va_dec_vp9.h"
#include "va_dec_hevc.h"
#include "va_str.h"
#include "va_vpp.h"
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/time.h>
#include <errno.h>
#if defined(__linux__)
#include <sys/syscall.h>
#elif defined(__DragonFly__) || defined(__FreeBSD__)
#include <pthread_np.h>
#elif defined(__NetBSD__)
#include <lwp.h>
#elif defined(__sun)
#include <thread.h>
#endif
/* bionic, glibc >= 2.30, musl >= 1.3 have gettid(), so add va_ prefix */
static pid_t va_gettid()
{
#if defined(__linux__)
return syscall(__NR_gettid);
#elif defined(__DragonFly__) || defined(__FreeBSD__)
return pthread_getthreadid_np();
#elif defined(__NetBSD__)
return _lwp_self();
#elif defined(__OpenBSD__)
return getthrid();
#elif defined(__sun)
return thr_self();
#elif defined(__Fuchsia__)
// Not implemented; Fuchsia needs 64 bits for thread ID
return 0;
#else
#warning "Cannot get kernel thread identifier on this platform."
return (intptr_t)pthread_self();
#endif
}
/*
* Env. to debug some issue, e.g. the decode/encode issue in a video conference scenerio:
* .LIBVA_TRACE=log_file: general VA parameters saved into log_file
* .LIBVA_TRACE_BUFDATA: dump all VA data buffer into log_file
* .LIBVA_TRACE_CODEDBUF=coded_clip_file: save the coded clip into file coded_clip_file
* .LIBVA_TRACE_SURFACE=yuv_file: save surface YUV into file yuv_file. Use file name to determine
* decode/encode or jpeg surfaces
* .LIBVA_TRACE_SURFACE_GEOMETRY=WIDTHxHEIGHT+XOFF+YOFF: only save part of surface context into file
* due to storage bandwidth limitation
*/
/* global settings */
/* LIBVA_TRACE */
int va_trace_flag = 0;
#define MAX_TRACE_CTX_NUM 64
#define TRACE_CTX_ID_MASK (MAX_TRACE_CTX_NUM - 1)
#define MAX_TRACE_THREAD_NUM 64
#define MAX_TRACE_BUF_INFO_HASH_SIZE 1024 // 1<<10
#define MAX_TRACE_BUF_INFO_HASH_LEVEL 3
#define TRACE_BUF_INFO_HASH_ID_MASK (MAX_TRACE_BUF_INFO_HASH_SIZE - 1)
struct trace_buf_info {
int valid;
VABufferID buf_id;
VAContextID ctx_id;
};
struct trace_buf_manager {
struct trace_buf_info *pbuf_info[MAX_TRACE_BUF_INFO_HASH_LEVEL];
};
struct trace_log_file {
pid_t thread_id;
int used;
char *fn_log;
FILE *fp_log;
};
struct trace_log_files_manager {
struct trace_log_file log_file[MAX_TRACE_THREAD_NUM];
};
/* per context settings */
struct trace_context {
struct trace_log_file *plog_file;
struct trace_log_file *plog_file_list[MAX_TRACE_THREAD_NUM];
/* LIBVA_TRACE_CODEDBUF */
FILE *trace_fp_codedbuf; /* save the encode result into a file */
char *trace_codedbuf_fn; /* file name */
/* LIBVA_TRACE_SURFACE */
FILE *trace_fp_surface; /* save the surface YUV into a file */
char *trace_surface_fn; /* file name */
VAContextID trace_context; /* current context */
VASurfaceID trace_rendertarget; /* current render target */
VAProfile trace_profile; /* current profile for buffers */
VAEntrypoint trace_entrypoint; /* current entrypoint */
unsigned int trace_frame_no; /* current frame NO */
unsigned int trace_slice_no; /* current slice NO */
unsigned int trace_slice_size; /* current slice buffer size */
unsigned int trace_surface_width; /* surface dumping geometry */
unsigned int trace_surface_height;
unsigned int trace_surface_xoff;
unsigned int trace_surface_yoff;
unsigned int trace_frame_width; /* current frame width */
unsigned int trace_frame_height; /* current frame height */
unsigned int pts; /* IVF header information */
pid_t created_thd_id;
};
struct trace_config_info {
int valid;
VAConfigID config_id;
VAProfile trace_profile;
VAEntrypoint trace_entrypoint;
pid_t created_thd_id;
};
struct va_trace {
struct trace_context *ptra_ctx[MAX_TRACE_CTX_NUM + 1];
int context_num;
struct trace_buf_manager buf_manager;
struct trace_log_files_manager log_files_manager;
struct trace_config_info config_info[MAX_TRACE_CTX_NUM];
char *fn_log_env;
char *fn_codedbuf_env;
char *fn_surface_env;
pthread_mutex_t resource_mutex;
pthread_mutex_t context_mutex;
VADisplay dpy;
};
#define LOCK_RESOURCE(pva_trace) \
if(pva_trace) \
pthread_mutex_lock(&pva_trace->resource_mutex)
#define UNLOCK_RESOURCE(pva_trace) \
if(pva_trace) \
pthread_mutex_unlock(&pva_trace->resource_mutex)
#define LOCK_CONTEXT(pva_trace) \
if(pva_trace) \
pthread_mutex_lock(&pva_trace->context_mutex)
#define UNLOCK_CONTEXT(pva_trace) \
if(pva_trace) \
pthread_mutex_unlock(&pva_trace->context_mutex)
#define DPY2TRACECTX(dpy, context, buf_id) \
struct va_trace *pva_trace = NULL; \
struct trace_context *trace_ctx = NULL; \
VAContextID ctx_id = context; \
\
pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); \
if(!pva_trace) \
return; \
\
if(ctx_id == VA_INVALID_ID) { \
if(buf_id != VA_INVALID_ID) \
ctx_id = get_ctx_by_buf(pva_trace, buf_id); \
else \
return; \
} \
\
if (ctx_id != VA_INVALID_ID) { \
int temp_idx = get_valid_ctx_idx(pva_trace, ctx_id); \
if(temp_idx < MAX_TRACE_CTX_NUM) \
trace_ctx = pva_trace->ptra_ctx[temp_idx]; \
} \
\
if(!trace_ctx \
|| trace_ctx->trace_context != context) { \
return; \
} \
refresh_log_file(pva_trace, trace_ctx)
#define DPY2TRACE_VIRCTX(dpy) \
struct va_trace *pva_trace = NULL; \
struct trace_context *trace_ctx = NULL; \
\
pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); \
if(!pva_trace) \
return; \
\
LOCK_CONTEXT(pva_trace); \
trace_ctx = pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM]; \
if(!trace_ctx) { \
UNLOCK_CONTEXT(pva_trace); \
return; \
} \
refresh_log_file(pva_trace, trace_ctx)
#define DPY2TRACE_VIRCTX_EXIT(pva_trace) \
UNLOCK_CONTEXT(pva_trace)
#define TRACE_FUNCNAME(idx) va_TraceMsg(trace_ctx, "==========%s\n", __func__);
#define TRACE_NEWLINE() do { \
va_TracePrint(trace_ctx, "\n"); \
va_TraceMsg(trace_ctx, "") ; \
} while (0)
VAStatus vaBufferInfo(
VADisplay dpy,
VAContextID context, /* in */
VABufferID buf_id, /* in */
VABufferType *type, /* out */
unsigned int *size, /* out */
unsigned int *num_elements /* out */
);
VAStatus vaLockSurface(VADisplay dpy,
VASurfaceID surface,
unsigned int *fourcc, /* following are output argument */
unsigned int *luma_stride,
unsigned int *chroma_u_stride,
unsigned int *chroma_v_stride,
unsigned int *luma_offset,
unsigned int *chroma_u_offset,
unsigned int *chroma_v_offset,
unsigned int *buffer_name,
void **buffer
);
VAStatus vaUnlockSurface(VADisplay dpy,
VASurfaceID surface
);
static int get_valid_config_idx(
struct va_trace *pva_trace,
VAConfigID config_id)
{
int idx = MAX_TRACE_CTX_NUM;
LOCK_RESOURCE(pva_trace);
for (idx = 0; idx < MAX_TRACE_CTX_NUM; idx++) {
if (pva_trace->config_info[idx].valid &&
pva_trace->config_info[idx].config_id == config_id)
break;
}
UNLOCK_RESOURCE(pva_trace);
return idx;
}
static void add_trace_config_info(
struct va_trace *pva_trace,
VAConfigID config_id,
VAProfile profile,
VAEntrypoint entrypoint)
{
struct trace_config_info *pconfig_info;
int idx = 0;
pid_t thd_id = va_gettid();
LOCK_RESOURCE(pva_trace);
for (idx = 0; idx < MAX_TRACE_CTX_NUM; idx++) {
if (!pva_trace->config_info[idx].valid ||
pva_trace->config_info[idx].config_id == config_id)
break;
}
if (idx < MAX_TRACE_CTX_NUM) {
pconfig_info = &pva_trace->config_info[idx];
pconfig_info->valid = 1;
pconfig_info->config_id = config_id;
pconfig_info->trace_profile = profile;
pconfig_info->trace_entrypoint = entrypoint;
pconfig_info->created_thd_id = thd_id;
}
UNLOCK_RESOURCE(pva_trace);
}
static void delete_trace_config_info(
struct va_trace *pva_trace,
VAConfigID config_id)
{
struct trace_config_info *pconfig_info;
int idx = 0;
LOCK_RESOURCE(pva_trace);
for (idx = 0; idx < MAX_TRACE_CTX_NUM; idx++) {
if (pva_trace->config_info[idx].valid &&
pva_trace->config_info[idx].config_id == config_id)
break;
}
if (idx < MAX_TRACE_CTX_NUM) {
pconfig_info = &pva_trace->config_info[idx];
pconfig_info->valid = 0;
pconfig_info->config_id = -1;
}
UNLOCK_RESOURCE(pva_trace);
}
static VAContextID get_ctx_by_buf(
struct va_trace *pva_trace,
VABufferID buf_id)
{
struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager;
struct trace_buf_info *pbuf_info = pbuf_mgr->pbuf_info[0];
VAContextID context = VA_INVALID_ID;
int i = 0, idx = 0;
LOCK_RESOURCE(pva_trace);
idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK;
for (i = 0; i < MAX_TRACE_BUF_INFO_HASH_LEVEL; i++) {
pbuf_info = pbuf_mgr->pbuf_info[i];
if (!pbuf_info)
break;
if (pbuf_info[idx].valid
&& pbuf_info[idx].buf_id == buf_id) {
context = pbuf_info[idx].ctx_id;
break;
}
}
UNLOCK_RESOURCE(pva_trace);
return context;
}
static void add_trace_buf_info(
struct va_trace *pva_trace,
VAContextID context,
VABufferID buf_id)
{
struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager;
struct trace_buf_info *pbuf_info = NULL;
int i = 0, idx = 0;
LOCK_RESOURCE(pva_trace);
idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK;
for (i = 0; i < MAX_TRACE_BUF_INFO_HASH_LEVEL; i++) {
pbuf_info = pbuf_mgr->pbuf_info[i];
if (!pbuf_info) {
pbuf_info = (struct trace_buf_info *)calloc(
sizeof(struct trace_buf_info) * MAX_TRACE_BUF_INFO_HASH_SIZE,
1);
if (!pbuf_info)
break;
pbuf_mgr->pbuf_info[i] = pbuf_info;
}
if (pbuf_info[idx].valid
&& pbuf_info[idx].buf_id != buf_id)
continue;
pbuf_info[idx].buf_id = buf_id;
pbuf_info[idx].ctx_id = context;
pbuf_info[idx].valid = 1;
break;
}
if (i >= MAX_TRACE_BUF_INFO_HASH_LEVEL)
va_errorMessage(pva_trace->dpy, "Add buf info failed\n");
UNLOCK_RESOURCE(pva_trace);
}
static void delete_trace_buf_info(
struct va_trace *pva_trace,
VABufferID buf_id)
{
struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager;
struct trace_buf_info *pbuf_info = NULL;
int i = 0, idx = 0;
LOCK_RESOURCE(pva_trace);
idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK;
for (i = 0; i < MAX_TRACE_BUF_INFO_HASH_LEVEL; i++) {
pbuf_info = pbuf_mgr->pbuf_info[i];
if (!pbuf_info)
break;
if (pbuf_info[idx].valid
&& pbuf_info[idx].buf_id == buf_id) {
pbuf_info[idx].valid = 0;
break;
}
}
UNLOCK_RESOURCE(pva_trace);
}
/*
static void delete_trace_all_context_buf(
struct va_trace *pva_trace,
VAContextID context)
{
struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager;
struct trace_buf_info *pbuf_info = NULL;
int i = 0, j = 0;
LOCK_RESOURCE(pva_trace);
for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) {
pbuf_info = pbuf_mgr->pbuf_info[i];
if(!pbuf_info)
break;
for(j = 0;j < MAX_TRACE_BUF_INFO_HASH_SIZE;j++)
if(pbuf_info[j].valid
&& pbuf_info[j].ctx_id == context)
pbuf_info[j].valid = 0;
}
UNLOCK_RESOURCE(pva_trace);
}
*/
static int get_free_ctx_idx(
struct va_trace *pva_trace,
VAContextID context)
{
int idx;
LOCK_RESOURCE(pva_trace);
for (idx = 0; idx < MAX_TRACE_CTX_NUM; idx++)
if (!pva_trace->ptra_ctx[idx] ||
pva_trace->ptra_ctx[idx]->trace_context == context)
break;
UNLOCK_RESOURCE(pva_trace);
return idx;
}
static int get_valid_ctx_idx(
struct va_trace *pva_trace,
VAContextID context)
{
int idx;
LOCK_RESOURCE(pva_trace);
for (idx = 0; idx < MAX_TRACE_CTX_NUM; idx++)
if (pva_trace->ptra_ctx[idx] &&
pva_trace->ptra_ctx[idx]->trace_context == context)
break;
UNLOCK_RESOURCE(pva_trace);
return idx;
}
static void FILE_NAME_SUFFIX(
char *env_value,
int max_size,
char *suffix_str,
unsigned int suffix_handle)
{
int tmp = strnlen(env_value, max_size);
int left = max_size - tmp;
struct timeval tv;
int size = 0;
if (suffix_str)
size = strlen(suffix_str);
if (left < (size + 8 + 10))
return;
if (gettimeofday(&tv, NULL) == 0) {
sprintf(env_value + tmp,
".%02d%02d%02d.",
(unsigned int)(tv.tv_sec / 3600) % 24,
(unsigned int)(tv.tv_sec / 60) % 60,
(unsigned int)tv.tv_sec % 60);
tmp += 8;
left -= 8;
}
if (suffix_str) {
strcat(env_value + tmp,
suffix_str);
tmp += size;
left -= size;
}
if (suffix_handle) {
sprintf(env_value + tmp,
"0x%08x",
suffix_handle);
}
}
static int open_tracing_specil_file(
struct va_trace *pva_trace,
struct trace_context *ptra_ctx,
int type) // 0: codedbuf, 1: surface
{
char *fn_env = type == 0 ?
pva_trace->fn_codedbuf_env : pva_trace->fn_surface_env;
char env_value[1024];
FILE *fp = NULL;
strncpy(env_value, fn_env, 1024);
env_value[1023] = '\0';
FILE_NAME_SUFFIX(env_value, 1024,
"ctx-", (unsigned int)ptra_ctx->trace_context);
fn_env = strdup(env_value);
if (!fn_env)
return -1;
fp = fopen(fn_env, "w");
if (!fp) {
free(fn_env);
return -1;
}
if (type == 0) {
ptra_ctx->trace_codedbuf_fn = fn_env;
ptra_ctx->trace_fp_codedbuf = fp;
va_infoMessage(pva_trace->dpy, "LIBVA_TRACE_CODEDBUF is on, save codedbuf into %s\n",
fn_env);
} else {
ptra_ctx->trace_surface_fn = fn_env;
ptra_ctx->trace_fp_surface = fp;
va_infoMessage(pva_trace->dpy, "LIBVA_TRACE_SURFACE is on, save surface into %s\n",
fn_env);
}
return 0;
}
static int open_tracing_log_file(
struct va_trace *pva_trace,
struct trace_log_file *plog_file,
pid_t thd_id)
{
FILE *pfp = NULL;
int new_fn_flag = 0;
if (plog_file->used && plog_file->thread_id != thd_id) {
va_errorMessage(pva_trace->dpy, "Try to open a busy log file occupied by other thread\n");
return -1;
}
if (plog_file->thread_id != thd_id) {
char env_value[1024];
strncpy(env_value, pva_trace->fn_log_env, 1024);
env_value[1023] = '\0';
FILE_NAME_SUFFIX(env_value, 1024,
"thd-", (unsigned int)thd_id);
if (plog_file->fn_log)
free(plog_file->fn_log);
plog_file->fn_log = strdup(env_value);
if (!plog_file->fn_log)
goto FAIL;
new_fn_flag = 1;
}
if (!plog_file->used) {
if (new_fn_flag)
pfp = fopen(plog_file->fn_log, "w");
else
pfp = fopen(plog_file->fn_log, "a");
if (!pfp)
goto FAIL;
va_infoMessage(pva_trace->dpy, "%s %s for the thread 0x%08x\n",
new_fn_flag ? "Open new log file" : "Append to log file",
plog_file->fn_log, thd_id);
plog_file->fp_log = pfp;
plog_file->thread_id = thd_id;
}
plog_file->used++;
return 0;
FAIL:
if (plog_file->fn_log) {
free(plog_file->fn_log);
plog_file->fn_log = NULL;
}
return -1;
}
static int get_log_file_idx_by_thd(
struct trace_log_files_manager *plog_files_mgr,
pid_t thd_id)
{
struct trace_log_file *plog_file = plog_files_mgr->log_file;
int first_free_idx = MAX_TRACE_THREAD_NUM;
int i = 0;
for (i = 0; i < MAX_TRACE_THREAD_NUM; i++) {
if (plog_file[i].thread_id == thd_id)
break;
else if (!plog_file[i].used &&
first_free_idx >= MAX_TRACE_THREAD_NUM)
first_free_idx = i;
}
if (i >= MAX_TRACE_THREAD_NUM)
i = first_free_idx;
return i;
}
static struct trace_log_file *start_tracing2log_file(
struct va_trace *pva_trace)
{
struct trace_log_files_manager *plog_files_mgr = NULL;
struct trace_log_file *plog_file = NULL;
pid_t thd_id = va_gettid();
int i = 0;
LOCK_RESOURCE(pva_trace);
plog_files_mgr = &pva_trace->log_files_manager;
i = get_log_file_idx_by_thd(plog_files_mgr, thd_id);
if (i < MAX_TRACE_THREAD_NUM) {
plog_file = &plog_files_mgr->log_file[i];
if (open_tracing_log_file(pva_trace, plog_file, thd_id) < 0) {
plog_file = NULL;
}
}
UNLOCK_RESOURCE(pva_trace);
return plog_file;
}
static void stop_tracing2log_file(
struct va_trace *pva_trace,
struct trace_log_file *plog_file)
{
LOCK_RESOURCE(pva_trace);
if (--plog_file->used <= 0) {
if (plog_file->fp_log) {
fclose(plog_file->fp_log);
plog_file->fp_log = NULL;
}
}
UNLOCK_RESOURCE(pva_trace);
}
static void refresh_log_file(
struct va_trace *pva_trace,
struct trace_context *ptra_ctx)
{
struct trace_log_file *plog_file = NULL;
pid_t thd_id = va_gettid();
int i = 0;
plog_file = ptra_ctx->plog_file;
if (plog_file && plog_file->thread_id != thd_id) {
plog_file = start_tracing2log_file(pva_trace);
if (plog_file) {
int first_free_idx = -1;
ptra_ctx->plog_file = plog_file;
for (i = 0; i < MAX_TRACE_THREAD_NUM; i++) {
if (!ptra_ctx->plog_file_list[i]) {
if (first_free_idx < 0)
first_free_idx = i;
} else if (ptra_ctx->plog_file_list[i]->thread_id == thd_id)
break;
}
if (i > MAX_TRACE_THREAD_NUM
&& first_free_idx >= 0)
ptra_ctx->plog_file_list[first_free_idx] = plog_file;
}
}
}
void va_TraceInit(VADisplay dpy)
{
char env_value[1024];
struct va_trace *pva_trace = calloc(sizeof(struct va_trace), 1);
struct trace_context *trace_ctx = calloc(sizeof(struct trace_context), 1);
if (pva_trace == NULL || trace_ctx == NULL) {
free(pva_trace);
free(trace_ctx);
return;
}
pva_trace->dpy = dpy;
pthread_mutex_init(&pva_trace->resource_mutex, NULL);
pthread_mutex_init(&pva_trace->context_mutex, NULL);
if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
pva_trace->fn_log_env = strdup(env_value);
trace_ctx->plog_file = start_tracing2log_file(pva_trace);
if (trace_ctx->plog_file) {
trace_ctx->plog_file_list[0] = trace_ctx->plog_file;
va_trace_flag = VA_TRACE_FLAG_LOG;
va_infoMessage(dpy, "LIBVA_TRACE is on, save log into %s\n",
trace_ctx->plog_file->fn_log);
} else
va_errorMessage(dpy, "Open file %s failed (%s)\n", env_value, strerror(errno));
}
/* may re-get the global settings for multiple context */
if ((va_trace_flag & VA_TRACE_FLAG_LOG) && (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0)) {
va_trace_flag |= VA_TRACE_FLAG_BUFDATA;
va_infoMessage(dpy, "LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n");
}
/* per-context setting */
if (va_parseConfig("LIBVA_TRACE_CODEDBUF", &env_value[0]) == 0) {
pva_trace->fn_codedbuf_env = strdup(env_value);
va_trace_flag |= VA_TRACE_FLAG_CODEDBUF;
}
if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) {
pva_trace->fn_surface_env = strdup(env_value);
/* for surface data dump, it is time-consume, and may
* cause some side-effect, so only trace the needed surfaces
* to trace encode surface, set the trace file name to sth like *enc*
* to trace decode surface, set the trace file name to sth like *dec*
* if no dec/enc in file name, set both
*/
if (strstr(env_value, "dec"))
va_trace_flag |= VA_TRACE_FLAG_SURFACE_DECODE;
if (strstr(env_value, "enc"))
va_trace_flag |= VA_TRACE_FLAG_SURFACE_ENCODE;
if (strstr(env_value, "jpeg") || strstr(env_value, "jpg"))
va_trace_flag |= VA_TRACE_FLAG_SURFACE_JPEG;
if (va_parseConfig("LIBVA_TRACE_SURFACE_GEOMETRY", &env_value[0]) == 0) {
char *p = env_value, *q;
trace_ctx->trace_surface_width = strtod(p, &q);
p = q + 1; /* skip "x" */
trace_ctx->trace_surface_height = strtod(p, &q);
p = q + 1; /* skip "+" */
trace_ctx->trace_surface_xoff = strtod(p, &q);
p = q + 1; /* skip "+" */
trace_ctx->trace_surface_yoff = strtod(p, &q);
va_infoMessage(dpy, "LIBVA_TRACE_SURFACE_GEOMETRY is on, only dump surface %dx%d+%d+%d content\n",
trace_ctx->trace_surface_width,
trace_ctx->trace_surface_height,
trace_ctx->trace_surface_xoff,
trace_ctx->trace_surface_yoff);
}
}
trace_ctx->trace_context = VA_INVALID_ID;
pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM] = trace_ctx;
((VADisplayContextP)dpy)->vatrace = (void *)pva_trace;
if (!va_trace_flag)
va_TraceEnd(dpy);
}
void va_TraceEnd(VADisplay dpy)
{
struct va_trace *pva_trace = NULL;
int i = 0;
pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace);
if (!pva_trace)
return;
if (pva_trace->fn_log_env)
free(pva_trace->fn_log_env);
if (pva_trace->fn_codedbuf_env)
free(pva_trace->fn_codedbuf_env);
if (pva_trace->fn_surface_env)
free(pva_trace->fn_surface_env);
for (i = 0; i < MAX_TRACE_BUF_INFO_HASH_LEVEL; i++)
if (pva_trace->buf_manager.pbuf_info[i])
free(pva_trace->buf_manager.pbuf_info[i]);
for (i = 0; i < MAX_TRACE_THREAD_NUM; i++) {
struct trace_log_file *plog_file = NULL;
plog_file = &pva_trace->log_files_manager.log_file[i];
if (plog_file) {
if (plog_file->fn_log)
free(plog_file->fn_log);
if (plog_file->fp_log)
fclose(plog_file->fp_log);
}
}
for (i = 0; i < MAX_TRACE_CTX_NUM; i++) {
struct trace_context *trace_ctx = NULL;
if (pva_trace->context_num <= 0)
break;
trace_ctx = pva_trace->ptra_ctx[i];
if (trace_ctx) {
if (trace_ctx->trace_codedbuf_fn)
free(trace_ctx->trace_codedbuf_fn);
if (trace_ctx->trace_fp_codedbuf)
fclose(trace_ctx->trace_fp_codedbuf);
if (trace_ctx->trace_surface_fn)
free(trace_ctx->trace_surface_fn);
if (trace_ctx->trace_fp_surface)
fclose(trace_ctx->trace_fp_surface);
free(pva_trace->ptra_ctx[i]);
pva_trace->context_num--;
}
}
free(pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM]);
pva_trace->dpy = NULL;
free(pva_trace);
((VADisplayContextP)dpy)->vatrace = NULL;
}
static void va_TraceVPrint(struct trace_context *trace_ctx, const char *msg, va_list args)
{
FILE *fp = NULL;
if (!(va_trace_flag & VA_TRACE_FLAG_LOG)
|| !trace_ctx->plog_file)
return;
fp = trace_ctx->plog_file->fp_log;
if (msg) {
vfprintf(fp, msg, args);
} else
fflush(fp);
}
static void va_TracePrint(struct trace_context *trace_ctx, const char *msg, ...)
{
va_list args;
va_start(args, msg);
va_TraceVPrint(trace_ctx, msg, args);
va_end(args);
}
static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
{
va_list args;
struct timeval tv;
if (!msg) {
va_TracePrint(trace_ctx, msg);
return;
}
if (gettimeofday(&tv, NULL) == 0)
va_TracePrint(trace_ctx, "[%04d.%06d]",
(unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec);
if (trace_ctx->trace_context != VA_INVALID_ID)
va_TracePrint(trace_ctx,
"[ctx 0x%08x]", trace_ctx->trace_context);
else
va_TracePrint(trace_ctx, "[ctx none]");
va_start(args, msg);
va_TraceVPrint(trace_ctx, msg, args);
va_end(args);
}
static void va_TraceSurface(VADisplay dpy, VAContextID context)
{
unsigned int i;
unsigned int fourcc; /* following are output argument */
unsigned int luma_stride;
unsigned int chroma_u_stride;
unsigned int chroma_v_stride;
unsigned int luma_offset;
unsigned int chroma_u_offset;
unsigned int chroma_v_offset;
unsigned int buffer_name;
void *buffer = NULL;
unsigned char *Y_data, *UV_data, *tmp;
unsigned int pixel_byte;
VAStatus va_status;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
if (!trace_ctx->trace_fp_surface)
return;
va_TraceMsg(trace_ctx, "==========dump surface data in file %s\n", trace_ctx->trace_surface_fn);
va_TraceMsg(trace_ctx, NULL);
va_status = vaLockSurface(
dpy,
trace_ctx->trace_rendertarget,
&fourcc,
&luma_stride, &chroma_u_stride, &chroma_v_stride,
&luma_offset, &chroma_u_offset, &chroma_v_offset,
&buffer_name, &buffer);
if (va_status != VA_STATUS_SUCCESS) {
va_TraceMsg(trace_ctx, "Error:vaLockSurface failed\n");
return;
}
va_TraceMsg(trace_ctx, "\tfourcc = 0x%08x\n", fourcc);
va_TraceMsg(trace_ctx, "\twidth = %d\n", trace_ctx->trace_frame_width);
va_TraceMsg(trace_ctx, "\theight = %d\n", trace_ctx->trace_frame_height);
va_TraceMsg(trace_ctx, "\tluma_stride = %d\n", luma_stride);
va_TraceMsg(trace_ctx, "\tchroma_u_stride = %d\n", chroma_u_stride);
va_TraceMsg(trace_ctx, "\tchroma_v_stride = %d\n", chroma_v_stride);
va_TraceMsg(trace_ctx, "\tluma_offset = %d\n", luma_offset);
va_TraceMsg(trace_ctx, "\tchroma_u_offset = %d\n", chroma_u_offset);
va_TraceMsg(trace_ctx, "\tchroma_v_offset = %d\n", chroma_v_offset);
if (buffer == NULL) {
va_TraceMsg(trace_ctx, "Error:vaLockSurface return NULL buffer\n");
va_TraceMsg(trace_ctx, NULL);
vaUnlockSurface(dpy, trace_ctx->trace_rendertarget);
return;
}
va_TraceMsg(trace_ctx, "\tbuffer location = 0x%p\n", buffer);
va_TraceMsg(trace_ctx, NULL);
Y_data = (unsigned char*)buffer;
UV_data = (unsigned char*)buffer + chroma_u_offset;
if (fourcc == VA_FOURCC_P010)
pixel_byte = 2;
else
pixel_byte = 1;
tmp = Y_data + luma_stride * trace_ctx->trace_surface_yoff;
for (i = 0; i < trace_ctx->trace_surface_height; i++) {
fwrite(tmp + trace_ctx->trace_surface_xoff,
trace_ctx->trace_surface_width,
pixel_byte, trace_ctx->trace_fp_surface);
tmp += luma_stride;
}
tmp = UV_data + chroma_u_stride * trace_ctx->trace_surface_yoff / 2;
if (fourcc == VA_FOURCC_NV12 || fourcc == VA_FOURCC_P010) {
for (i = 0; i < trace_ctx->trace_surface_height / 2; i++) {
fwrite(tmp + trace_ctx->trace_surface_xoff,
trace_ctx->trace_surface_width,
pixel_byte, trace_ctx->trace_fp_surface);
tmp += chroma_u_stride;
}
}
fflush(trace_ctx->trace_fp_surface);
vaUnlockSurface(dpy, trace_ctx->trace_rendertarget);
va_TraceMsg(trace_ctx, NULL);
}
void va_TraceInitialize(
VADisplay dpy,
int *major_version, /* out */
int *minor_version /* out */
)
{
DPY2TRACE_VIRCTX(dpy);
TRACE_FUNCNAME(idx);
DPY2TRACE_VIRCTX_EXIT(pva_trace);
}
void va_TraceTerminate(
VADisplay dpy
)
{
DPY2TRACE_VIRCTX(dpy);
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, NULL);
DPY2TRACE_VIRCTX_EXIT(pva_trace);
}
void va_TraceCreateConfig(
VADisplay dpy,
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib *attrib_list,
int num_attribs,
VAConfigID *config_id /* out */
)
{
int i;
DPY2TRACE_VIRCTX(dpy);
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tprofile = %d\n", profile);
va_TraceMsg(trace_ctx, "\tentrypoint = %d\n", entrypoint);
va_TraceMsg(trace_ctx, "\tnum_attribs = %d\n", num_attribs);
if (attrib_list) {
for (i = 0; i < num_attribs; i++) {
va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type);
va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value);
}
}
va_TraceMsg(trace_ctx, NULL);
add_trace_config_info(pva_trace, *config_id, profile, entrypoint);
DPY2TRACE_VIRCTX_EXIT(pva_trace);
}
void va_TraceDestroyConfig(
VADisplay dpy,
VAConfigID config_id
)
{
DPY2TRACE_VIRCTX(dpy);
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id);
va_TraceMsg(trace_ctx, NULL);
delete_trace_config_info(pva_trace, config_id);
DPY2TRACE_VIRCTX_EXIT(pva_trace);
}
static void va_TraceSurfaceAttributes(
struct trace_context *trace_ctx,
VASurfaceAttrib *attrib_list,
unsigned int *num_attribs
)
{
int i, num;
VASurfaceAttrib *p;
if (!attrib_list || !num_attribs)
return;
p = attrib_list;
num = *num_attribs;
if (num > VASurfaceAttribCount)
num = VASurfaceAttribCount;
for (i = 0; i < num; i++) {
int type = p->value.type;
va_TraceMsg(trace_ctx, "\tattrib_list[%i] =\n", i);
va_TraceMsg(trace_ctx, "\t\ttype = %d\n", p->type);
va_TraceMsg(trace_ctx, "\t\tflags = %d\n", p->flags);
va_TraceMsg(trace_ctx, "\t\tvalue.type = %d\n", type);
switch (type) {
case VAGenericValueTypeInteger:
va_TraceMsg(trace_ctx, "\t\tvalue.value.i = 0x%08x\n", p->value.value.i);
break;
case VAGenericValueTypeFloat:
va_TraceMsg(trace_ctx, "\t\tvalue.value.f = %f\n", p->value.value.f);
break;
case VAGenericValueTypePointer:
va_TraceMsg(trace_ctx, "\t\tvalue.value.p = %p\n", p->value.value.p);
if ((p->type == VASurfaceAttribExternalBufferDescriptor) && p->value.value.p) {
VASurfaceAttribExternalBuffers *tmp = (VASurfaceAttribExternalBuffers *) p->value.value.p;
uint32_t j;
va_TraceMsg(trace_ctx, "\t\t--VASurfaceAttribExternalBufferDescriptor\n");
va_TraceMsg(trace_ctx, "\t\t pixel_format=0x%08x\n", tmp->pixel_format);
va_TraceMsg(trace_ctx, "\t\t width=%d\n", tmp->width);
va_TraceMsg(trace_ctx, "\t\t height=%d\n", tmp->height);
va_TraceMsg(trace_ctx, "\t\t data_size=%d\n", tmp->data_size);
va_TraceMsg(trace_ctx, "\t\t num_planes=%d\n", tmp->num_planes);
va_TraceMsg(trace_ctx, "\t\t pitches[4]=%d %d %d %d\n",
tmp->pitches[0], tmp->pitches[1], tmp->pitches[2], tmp->pitches[3]);
va_TraceMsg(trace_ctx, "\t\t offsets[4]=%d %d %d %d\n",
tmp->offsets[0], tmp->offsets[1], tmp->offsets[2], tmp->offsets[3]);
va_TraceMsg(trace_ctx, "\t\t flags=0x%08x\n", tmp->flags);
va_TraceMsg(trace_ctx, "\t\t num_buffers=0x%08x\n", tmp->num_buffers);
va_TraceMsg(trace_ctx, "\t\t buffers=%p\n", tmp->buffers);
for (j = 0; j < tmp->num_buffers; j++) {
va_TraceMsg(trace_ctx, "\t\t\tbuffers[%d]=%p\n", j, tmp->buffers[j]);
}
}
break;
case VAGenericValueTypeFunc:
va_TraceMsg(trace_ctx, "\t\tvalue.value.fn = %p\n", p->value.value.fn);
break;
default:
break;
}
p++;
}
}
void va_TraceCreateSurfaces(
VADisplay dpy,
int width,
int height,
int format,
int num_surfaces,
VASurfaceID *surfaces, /* out */
VASurfaceAttrib *attrib_list,
unsigned int num_attribs
)
{
int i;
DPY2TRACE_VIRCTX(dpy);
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\twidth = %d\n", width);
va_TraceMsg(trace_ctx, "\theight = %d\n", height);
va_TraceMsg(trace_ctx, "\tformat = %d\n", format);
va_TraceMsg(trace_ctx, "\tnum_surfaces = %d\n", num_surfaces);
if (surfaces) {
for (i = 0; i < num_surfaces; i++)
va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]);
}
va_TraceSurfaceAttributes(trace_ctx, attrib_list, &num_attribs);
va_TraceMsg(trace_ctx, NULL);
DPY2TRACE_VIRCTX_EXIT(pva_trace);
}
void va_TraceDestroySurfaces(
VADisplay dpy,
VASurfaceID *surface_list,
int num_surfaces
)
{
int i;
DPY2TRACE_VIRCTX(dpy);
TRACE_FUNCNAME(idx);
if (surface_list) {
for (i = 0; i < num_surfaces; i++)
va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surface_list[i]);
}
va_TraceMsg(trace_ctx, NULL);
DPY2TRACE_VIRCTX_EXIT(pva_trace);
}
static void internal_TraceUpdateContext(
struct va_trace *pva_trace,
int tra_ctx_idx,
struct trace_context *new_trace_ctx,
VAContextID context,
int destroy_flag
)
{
struct trace_context *trace_ctx = NULL;
int i = 0, delete = 1;
pid_t thd_id = va_gettid();
if (tra_ctx_idx >= MAX_TRACE_CTX_NUM)
return;
LOCK_RESOURCE(pva_trace);
trace_ctx = pva_trace->ptra_ctx[tra_ctx_idx];
if (trace_ctx) {
if (!new_trace_ctx &&
trace_ctx->created_thd_id != thd_id
&& !destroy_flag) {
delete = 0;
} else {
pva_trace->context_num--;
pva_trace->ptra_ctx[tra_ctx_idx] = NULL;
}
}
if (new_trace_ctx) {
new_trace_ctx->created_thd_id = thd_id;
pva_trace->ptra_ctx[tra_ctx_idx] = new_trace_ctx;
pva_trace->context_num++;
}
UNLOCK_RESOURCE(pva_trace);
if (trace_ctx && delete) {
for (i = 0; i < MAX_TRACE_THREAD_NUM; i++)
if (trace_ctx->plog_file_list[i])
stop_tracing2log_file(pva_trace, trace_ctx->plog_file_list[i]);
if (trace_ctx->trace_codedbuf_fn)
free(trace_ctx->trace_codedbuf_fn);
if (trace_ctx->trace_fp_codedbuf)
fclose(trace_ctx->trace_fp_codedbuf);
if (trace_ctx->trace_surface_fn)
free(trace_ctx->trace_surface_fn);
if (trace_ctx->trace_fp_surface)
fclose(trace_ctx->trace_fp_surface);
//delete_trace_all_context_buf(pva_trace, context);
free(trace_ctx);
}
}
void va_TraceCreateContext(
VADisplay dpy,
VAConfigID config_id,
int picture_width,
int picture_height,
int flag,
VASurfaceID *render_targets,
int num_render_targets,
VAContextID *context /* out */
)
{
struct va_trace *pva_trace = NULL;
struct trace_context *trace_ctx = NULL;
int tra_ctx_id = 0;
int encode = 0, decode = 0, jpeg = 0;
int i;
pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace);
if (!context
|| *context == VA_INVALID_ID
|| !pva_trace) {
va_errorMessage(dpy, "Invalid context id 0x%08x\n",
context == NULL ? 0 : (int)*context);
return;
}
LOCK_CONTEXT(pva_trace);
tra_ctx_id = get_free_ctx_idx(pva_trace, *context);
if (tra_ctx_id >= MAX_TRACE_CTX_NUM) {
va_errorMessage(dpy, "Can't get trace context for ctx 0x%08x\n",
*context);
goto FAIL;
}
trace_ctx = calloc(sizeof(struct trace_context), 1);
if (trace_ctx == NULL) {
va_errorMessage(dpy, "Allocate trace context failed for ctx 0x%08x\n",
*context);
goto FAIL;
}
i = get_valid_config_idx(pva_trace, config_id);
if (i >= MAX_TRACE_CTX_NUM) {
va_errorMessage(dpy, "Can't get trace config id for ctx 0x%08x cfg %x\n",
*context, config_id);
goto FAIL;
}
trace_ctx->trace_profile = pva_trace->config_info[i].trace_profile;
trace_ctx->trace_entrypoint = pva_trace->config_info[i].trace_entrypoint;
if (va_trace_flag & VA_TRACE_FLAG_LOG) {
trace_ctx->plog_file = start_tracing2log_file(pva_trace);
if (!trace_ctx->plog_file) {
va_errorMessage(dpy, "Can't get trace log file for ctx 0x%08x\n",
*context);
goto FAIL;
} else
va_infoMessage(dpy, "Save context 0x%08x into log file %s\n", *context,
trace_ctx->plog_file->fn_log);
trace_ctx->plog_file_list[0] = trace_ctx->plog_file;
}
trace_ctx->trace_context = *context;
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tcontext = 0x%08x va_trace_flag 0x%x\n", *context, va_trace_flag);
va_TraceMsg(trace_ctx, "\tprofile = %d entrypoint = %d\n", trace_ctx->trace_profile,
trace_ctx->trace_entrypoint);
va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id);
va_TraceMsg(trace_ctx, "\twidth = %d\n", picture_width);
va_TraceMsg(trace_ctx, "\theight = %d\n", picture_height);
va_TraceMsg(trace_ctx, "\tflag = 0x%08x\n", flag);
va_TraceMsg(trace_ctx, "\tnum_render_targets = %d\n", num_render_targets);
if (render_targets) {
for (i = 0; i < num_render_targets; i++)
va_TraceMsg(trace_ctx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]);
}
trace_ctx->trace_frame_no = 0;
trace_ctx->trace_slice_no = 0;
trace_ctx->trace_frame_width = picture_width;
trace_ctx->trace_frame_height = picture_height;
if (trace_ctx->trace_surface_width == 0)
trace_ctx->trace_surface_width = picture_width;
if (trace_ctx->trace_surface_height == 0)
trace_ctx->trace_surface_height = picture_height;
/* avoid to create so many empty files */
encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice);
decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD);
jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture);
if ((encode && (va_trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE)) ||
(decode && (va_trace_flag & VA_TRACE_FLAG_SURFACE_DECODE)) ||
(jpeg && (va_trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) {
if (open_tracing_specil_file(pva_trace, trace_ctx, 1) < 0) {
va_errorMessage(dpy, "Open surface fail failed for ctx 0x%08x\n", *context);
va_trace_flag &= ~(VA_TRACE_FLAG_SURFACE);
}
}
if (encode && (va_trace_flag & VA_TRACE_FLAG_CODEDBUF)) {
if (open_tracing_specil_file(pva_trace, trace_ctx, 0) < 0) {
va_errorMessage(dpy, "Open codedbuf fail failed for ctx 0x%08x\n", *context);
va_trace_flag &= ~(VA_TRACE_FLAG_CODEDBUF);
}
}
internal_TraceUpdateContext(pva_trace, tra_ctx_id, trace_ctx, *context, 0);
UNLOCK_CONTEXT(pva_trace);
return;
FAIL:
internal_TraceUpdateContext(pva_trace, tra_ctx_id, NULL, *context, 1);
UNLOCK_CONTEXT(pva_trace);
if (trace_ctx)
free(trace_ctx);
}
void va_TraceDestroyContext(
VADisplay dpy,
VAContextID context
)
{
struct va_trace *pva_trace = NULL;
struct trace_context *trace_ctx = NULL;
int ctx_id = 0;
pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace);
if (!pva_trace)
return;
LOCK_CONTEXT(pva_trace);
ctx_id = get_valid_ctx_idx(pva_trace, context);
if (ctx_id < MAX_TRACE_CTX_NUM) {
trace_ctx = pva_trace->ptra_ctx[ctx_id];
if (trace_ctx) {
refresh_log_file(pva_trace, trace_ctx);
internal_TraceUpdateContext(pva_trace,
get_valid_ctx_idx(pva_trace, context),
NULL, context, 0);
}
}
UNLOCK_CONTEXT(pva_trace);
}
void va_TraceCreateMFContext(
VADisplay dpy,
VAMFContextID *mf_context /* out */
)
{
DPY2TRACECTX(dpy, VA_INVALID_ID, VA_INVALID_ID);
TRACE_FUNCNAME(idx);
if (mf_context) {
va_TraceMsg(trace_ctx, "\tmf_context = 0x%08x\n", *mf_context);
trace_ctx->trace_context = *mf_context;
} else
trace_ctx->trace_context = VA_INVALID_ID;
}
void va_TraceMFAddContext(
VADisplay dpy,
VAMFContextID mf_context,
VAContextID context
)
{
DPY2TRACECTX(dpy, mf_context, VA_INVALID_ID);
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tmf_context = 0x%08x\n", mf_context);
va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
}
void va_TraceMFReleaseContext(
VADisplay dpy,
VAMFContextID mf_context,
VAContextID context
)
{
DPY2TRACECTX(dpy, mf_context, VA_INVALID_ID);
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tmf_context = 0x%08x\n", mf_context);
va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
}
void va_TraceMFSubmit(
VADisplay dpy,
VAMFContextID mf_context,
VAContextID *contexts,
int num_contexts
)
{
int i;
DPY2TRACECTX(dpy, mf_context, VA_INVALID_ID);
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tmf_context = 0x%08x\n", mf_context);
for (i = 0; i < num_contexts; i++) {
va_TraceMsg(trace_ctx, "\t\tcontext[%d] = 0x%08x\n", i, contexts[i]);
}
}
void va_TraceCreateBuffer(
VADisplay dpy,
VAContextID context, /* in */
VABufferType type, /* in */
unsigned int size, /* in */
unsigned int num_elements, /* in */
void *data, /* in */
VABufferID *buf_id /* out */
)
{
if (!buf_id || *buf_id == VA_INVALID_ID)
return;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
add_trace_buf_info(pva_trace, context, *buf_id);
/* only trace CodedBuffer */
if (type != VAEncCodedBufferType)
return;
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", vaBufferTypeStr(type));
if (buf_id)
va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", *buf_id);
va_TraceMsg(trace_ctx, "\tsize=%u\n", size);
va_TraceMsg(trace_ctx, "\tnum_elements=%u\n", num_elements);
va_TraceMsg(trace_ctx, NULL);
}
void va_TraceDestroyBuffer(
VADisplay dpy,
VABufferID buf_id /* in */
)
{
VABufferType type;
unsigned int size;
unsigned int num_elements;
if (buf_id == VA_INVALID_ID)
return;
DPY2TRACECTX(dpy, VA_INVALID_ID, buf_id);
vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements);
delete_trace_buf_info(pva_trace, buf_id);
/* only trace CodedBuffer */
if (type != VAEncCodedBufferType)
return;
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", vaBufferTypeStr(type));
va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
va_TraceMsg(trace_ctx, "\tsize=%u\n", size);
va_TraceMsg(trace_ctx, "\tnum_elements=%u\n", num_elements);
va_TraceMsg(trace_ctx, NULL);
}
static void mem_put_le16(char *mem, unsigned int val)
{
mem[0] = val;
mem[1] = val >> 8;
}
static void mem_put_le32(char *mem, unsigned int val)
{
mem[0] = val;
mem[1] = val >> 8;
mem[2] = val >> 16;
mem[3] = val >> 24;
}
static void va_TraceCodedBufferIVFHeader(struct trace_context *trace_ctx, void **pbuf)
{
VACodedBufferSegment *buf_list;
unsigned int frame_length = 0;
char header[32];
buf_list = (VACodedBufferSegment *)(*pbuf);
if (ftell(trace_ctx->trace_fp_codedbuf) == 0) { /* write ivf header */
header[0] = 'D';
header[1] = 'K';
header[2] = 'I';
header[3] = 'F';
mem_put_le16(header + 4, 0); /* version */
mem_put_le16(header + 6, 32); /* headersize */
mem_put_le32(header + 8, 0x30385056); /* headersize */
/* write width and height of the first rc_param to IVF file header */
mem_put_le16(header + 12, trace_ctx->trace_frame_width); /* width */
mem_put_le16(header + 14, trace_ctx->trace_frame_height); /* height */
mem_put_le32(header + 16, 30); /* rate */
mem_put_le32(header + 20, 1); /* scale */
mem_put_le32(header + 24, 0xffffffff); /* length */
mem_put_le32(header + 28, 0); /* unused */
fwrite(header, 1, 32, trace_ctx->trace_fp_codedbuf);
}
/* write frame header */
while (buf_list != NULL) {
frame_length += buf_list->size;
buf_list = (VACodedBufferSegment *) buf_list->next;
}
mem_put_le32(header, frame_length);
mem_put_le32(header + 4, trace_ctx->pts & 0xFFFFFFFF);
mem_put_le32(header + 8, 0);
fwrite(header, 1, 12, trace_ctx->trace_fp_codedbuf);
trace_ctx->pts++;
fflush(trace_ctx->trace_fp_codedbuf);
}
void va_TraceMapBuffer(
VADisplay dpy,
VABufferID buf_id, /* in */
void **pbuf /* out */
)
{
VABufferType type;
unsigned int size;
unsigned int num_elements;
VACodedBufferSegment *buf_list;
int i = 0;
DPY2TRACECTX(dpy, VA_INVALID_ID, buf_id);
vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements);
/* only trace CodedBuffer */
if (type != VAEncCodedBufferType)
return;
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", vaBufferTypeStr(type));
if ((pbuf == NULL) || (*pbuf == NULL))
return;
if (trace_ctx->trace_profile == VAProfileVP8Version0_3) {
va_TraceMsg(trace_ctx, "\tAdd IVF header information\n");
va_TraceCodedBufferIVFHeader(trace_ctx, pbuf);
}
buf_list = (VACodedBufferSegment *)(*pbuf);
while (buf_list != NULL) {
va_TraceMsg(trace_ctx, "\tCodedbuf[%d] =\n", i++);
va_TraceMsg(trace_ctx, "\t size = %u\n", buf_list->size);
va_TraceMsg(trace_ctx, "\t bit_offset = %u\n", buf_list->bit_offset);
va_TraceMsg(trace_ctx, "\t status = 0x%08x\n", buf_list->status);
va_TraceMsg(trace_ctx, "\t reserved = 0x%08x\n", buf_list->reserved);
va_TraceMsg(trace_ctx, "\t buf = 0x%p\n", buf_list->buf);
if (trace_ctx->trace_fp_codedbuf) {
va_TraceMsg(trace_ctx, "\tDump the content to file\n");
fwrite(buf_list->buf, buf_list->size, 1, trace_ctx->trace_fp_codedbuf);
fflush(trace_ctx->trace_fp_codedbuf);
}
buf_list = buf_list->next;
}
va_TraceMsg(trace_ctx, NULL);
}
static void va_TraceVABuffers(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *pbuf
)
{
unsigned int i;
unsigned char *p = pbuf;
FILE *fp = NULL;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TracePrint(trace_ctx, "--%s\n", vaBufferTypeStr(type));
if (trace_ctx->plog_file)
fp = trace_ctx->plog_file->fp_log;
if ((va_trace_flag & VA_TRACE_FLAG_BUFDATA) && fp) {
for (i = 0; i < size; i++) {
unsigned char value = p[i];
if (i == 0)
fprintf(fp, "\t\t0x%04x:", i);
else if ((i % 16) == 0)
fprintf(fp, "\n\t\t0x%04x:", i);
fprintf(fp, " %02x", value);
}
fprintf(fp, "\n");
}
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVAPictureParameterBufferMPEG2(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VAPictureParameterBufferMPEG2 *p = (VAPictureParameterBufferMPEG2 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "VAPictureParameterBufferMPEG2\n");
va_TraceMsg(trace_ctx, "\thorizontal size= %d\n", p->horizontal_size);
va_TraceMsg(trace_ctx, "\tvertical size= %d\n", p->vertical_size);
va_TraceMsg(trace_ctx, "\tforward reference picture= %d\n", p->forward_reference_picture);
va_TraceMsg(trace_ctx, "\tbackward reference picture= %d\n", p->backward_reference_picture);
va_TraceMsg(trace_ctx, "\tpicture coding type= %d\n", p->picture_coding_type);
va_TraceMsg(trace_ctx, "\tf mode= %d\n", p->f_code);
va_TraceMsg(trace_ctx, "\tpicture coding extension = %d\n", p->picture_coding_extension.value);
va_TraceMsg(trace_ctx, "\tintra_dc_precision= %d\n", p->picture_coding_extension.bits.intra_dc_precision);
va_TraceMsg(trace_ctx, "\tpicture_structure= %d\n", p->picture_coding_extension.bits.picture_structure);
va_TraceMsg(trace_ctx, "\ttop_field_first= %d\n", p->picture_coding_extension.bits.top_field_first);
va_TraceMsg(trace_ctx, "\tframe_pred_frame_dct= %d\n", p->picture_coding_extension.bits.frame_pred_frame_dct);
va_TraceMsg(trace_ctx, "\tconcealment_motion_vectors= %d\n", p->picture_coding_extension.bits.concealment_motion_vectors);
va_TraceMsg(trace_ctx, "\tq_scale_type= %d\n", p->picture_coding_extension.bits.q_scale_type);
va_TraceMsg(trace_ctx, "\tintra_vlc_format= %d\n", p->picture_coding_extension.bits.intra_vlc_format);
va_TraceMsg(trace_ctx, "\talternate_scan= %d\n", p->picture_coding_extension.bits.alternate_scan);
va_TraceMsg(trace_ctx, "\trepeat_first_field= %d\n", p->picture_coding_extension.bits.repeat_first_field);
va_TraceMsg(trace_ctx, "\tprogressive_frame= %d\n", p->picture_coding_extension.bits.progressive_frame);
va_TraceMsg(trace_ctx, "\tis_first_field= %d\n", p->picture_coding_extension.bits.is_first_field);
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVAIQMatrixBufferMPEG2(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VAIQMatrixBufferMPEG2 *p = (VAIQMatrixBufferMPEG2 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
int i;
va_TraceMsg(trace_ctx, "VAIQMatrixBufferMPEG2\n");
va_TraceMsg(trace_ctx, "\tload_intra_quantiser_matrix = %d\n", p->load_intra_quantiser_matrix);
va_TraceMsg(trace_ctx, "\tload_non_intra_quantiser_matrix = %d\n", p->load_non_intra_quantiser_matrix);
va_TraceMsg(trace_ctx, "\tload_chroma_intra_quantiser_matrix = %d\n", p->load_chroma_intra_quantiser_matrix);
va_TraceMsg(trace_ctx, "\tload_chroma_non_intra_quantiser_matrix = %d\n", p->load_chroma_non_intra_quantiser_matrix);
va_TraceMsg(trace_ctx, "\tintra_quantiser_matrix[] = {\n");
for (i = 0; i < 64; i++) {
if (i % 8 == 0) {
if (i)
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\t %3d", p->intra_quantiser_matrix[i]);
} else {
va_TracePrint(trace_ctx, " %3d", p->intra_quantiser_matrix[i]);
}
}
va_TracePrint(trace_ctx, "}\n");
va_TraceMsg(trace_ctx, "\tnon_intra_quantiser_matrix[] = {\n");
for (i = 0; i < 64; i++) {
if (i % 8 == 0) {
if (i)
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\t %3d", p->non_intra_quantiser_matrix[i]);
} else {
va_TracePrint(trace_ctx, " %3d", p->non_intra_quantiser_matrix[i]);
}
}
va_TracePrint(trace_ctx, "}\n");
va_TraceMsg(trace_ctx, "\tchroma_intra_quantiser_matrix[] = {\n");
for (i = 0; i < 64; i++) {
if (i % 8 == 0) {
if (i)
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\t %3d", p->chroma_intra_quantiser_matrix[i]);
} else {
va_TracePrint(trace_ctx, " %3d", p->chroma_intra_quantiser_matrix[i]);
}
}
va_TracePrint(trace_ctx, "}\n");
va_TraceMsg(trace_ctx, "\tchroma_non_intra_quantiser_matrix[] = {\n");
for (i = 0; i < 64; i++) {
if (i % 8 == 0) {
if (i)
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(
trace_ctx, "\t %3d", p->chroma_non_intra_quantiser_matrix[i]);
} else {
va_TracePrint(
trace_ctx, " %3d", p->chroma_non_intra_quantiser_matrix[i]);
}
}
va_TracePrint(trace_ctx, "}\n");
return;
}
static void va_TraceVASliceParameterBufferMPEG2(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VASliceParameterBufferMPEG2 *p = (VASliceParameterBufferMPEG2 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
trace_ctx->trace_slice_no++;
trace_ctx->trace_slice_size = p->slice_data_size;
va_TraceMsg(trace_ctx, "VASliceParameterBufferMPEG2\n");
va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size);
va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset);
va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag);
va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset);
va_TraceMsg(trace_ctx, "\tslice_horizontal_position = %d\n", p->slice_horizontal_position);
va_TraceMsg(trace_ctx, "\tslice_vertical_position = %d\n", p->slice_vertical_position);
va_TraceMsg(trace_ctx, "\tquantiser_scale_code = %d\n", p->quantiser_scale_code);
va_TraceMsg(trace_ctx, "\tintra_slice_flag = %d\n", p->intra_slice_flag);
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVAPictureParameterBufferJPEG(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i;
VAPictureParameterBufferJPEGBaseline *p = (VAPictureParameterBufferJPEGBaseline *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "*VAPictureParameterBufferJPEG\n");
va_TraceMsg(trace_ctx, "\tpicture_width = %u\n", p->picture_width);
va_TraceMsg(trace_ctx, "\tpicture_height = %u\n", p->picture_height);
va_TraceMsg(trace_ctx, "\tcomponents = \n");
for (i = 0; i < p->num_components && i < 255; ++i) {
va_TraceMsg(trace_ctx, "\t\t[%d] component_id = %u\n", i, p->components[i].component_id);
va_TraceMsg(trace_ctx, "\t\t[%d] h_sampling_factor = %u\n", i, p->components[i].h_sampling_factor);
va_TraceMsg(trace_ctx, "\t\t[%d] v_sampling_factor = %u\n", i, p->components[i].v_sampling_factor);
va_TraceMsg(trace_ctx, "\t\t[%d] quantiser_table_selector = %u\n", i, p->components[i].quantiser_table_selector);
}
}
static void va_TraceVAIQMatrixBufferJPEG(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i, j;
static char tmp[1024];
VAIQMatrixBufferJPEGBaseline *p = (VAIQMatrixBufferJPEGBaseline *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "*VAIQMatrixParameterBufferJPEG\n");
va_TraceMsg(trace_ctx, "\tload_quantiser_table =\n");
for (i = 0; i < 4; ++i) {
va_TraceMsg(trace_ctx, "\t\t[%d] = %u\n", i, p->load_quantiser_table[i]);
}
va_TraceMsg(trace_ctx, "\tquantiser_table =\n");
for (i = 0; i < 4; ++i) {
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 64; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->quantiser_table[i][j]);
}
va_TraceMsg(trace_ctx, "\t\t[%d] = %s\n", i, tmp);
}
}
static void va_TraceVASliceParameterBufferJPEG(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i;
VASliceParameterBufferJPEGBaseline *p = (VASliceParameterBufferJPEGBaseline *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "*VASliceParameterBufferJPEG\n");
va_TraceMsg(trace_ctx, "\tslice_data_size = %u\n", p->slice_data_size);
va_TraceMsg(trace_ctx, "\tslice_data_offset = %u\n", p->slice_data_offset);
va_TraceMsg(trace_ctx, "\tslice_data_flag = %u\n", p->slice_data_flag);
va_TraceMsg(trace_ctx, "\tslice_horizontal_position = %u\n", p->slice_horizontal_position);
va_TraceMsg(trace_ctx, "\tslice_vertical_position = %u\n", p->slice_vertical_position);
va_TraceMsg(trace_ctx, "\tcomponents = \n");
for (i = 0; i < p->num_components && i < 4; ++i) {
va_TraceMsg(trace_ctx, "\t\t[%d] component_selector = %u\n", i, p->components[i].component_selector);
va_TraceMsg(trace_ctx, "\t\t[%d] dc_table_selector = %u\n", i, p->components[i].dc_table_selector);
va_TraceMsg(trace_ctx, "\t\t[%d] ac_table_selector = %u\n", i, p->components[i].ac_table_selector);
}
va_TraceMsg(trace_ctx, "\trestart_interval = %u\n", p->restart_interval);
va_TraceMsg(trace_ctx, "\tnum_mcus = %u\n", p->num_mcus);
}
static void va_TraceVAHuffmanTableBufferJPEG(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i, j;
static char tmp[1024];
VAHuffmanTableBufferJPEGBaseline *p = (VAHuffmanTableBufferJPEGBaseline *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "*VAHuffmanTableBufferJPEG\n");
for (i = 0; i < 2; ++i) {
va_TraceMsg(trace_ctx, "\tload_huffman_table[%d] =%u\n", i, p->load_huffman_table[i]);
va_TraceMsg(trace_ctx, "\thuffman_table[%d] =\n", i);
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 16; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].num_dc_codes[j]);
}
va_TraceMsg(trace_ctx, "\t\tnum_dc_codes =%s\n", tmp);
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 12; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].dc_values[j]);
}
va_TraceMsg(trace_ctx, "\t\tdc_values =%s\n", tmp);
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 16; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].num_ac_codes[j]);
}
va_TraceMsg(trace_ctx, "\t\tnum_ac_codes =%s\n", tmp);
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 162; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].ac_values[j]);
}
va_TraceMsg(trace_ctx, "\t\tac_values =%s\n", tmp);
memset(tmp, 0, sizeof tmp);
for (j = 0; j < 2; ++j) {
sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].pad[j]);
}
va_TraceMsg(trace_ctx, "\t\tpad =%s\n", tmp);
}
}
static void va_TraceVAPictureParameterBufferMPEG4(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i;
VAPictureParameterBufferMPEG4 *p = (VAPictureParameterBufferMPEG4 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "*VAPictureParameterBufferMPEG4\n");
va_TraceMsg(trace_ctx, "\tvop_width = %d\n", p->vop_width);
va_TraceMsg(trace_ctx, "\tvop_height = %d\n", p->vop_height);
va_TraceMsg(trace_ctx, "\tforward_reference_picture = %d\n", p->forward_reference_picture);
va_TraceMsg(trace_ctx, "\tbackward_reference_picture = %d\n", p->backward_reference_picture);
va_TraceMsg(trace_ctx, "\tvol_fields value = %d\n", p->vol_fields.value);
va_TraceMsg(trace_ctx, "\tshort_video_header= %d\n", p->vol_fields.bits.short_video_header);
va_TraceMsg(trace_ctx, "\tchroma_format= %d\n", p->vol_fields.bits.chroma_format);
va_TraceMsg(trace_ctx, "\tinterlaced= %d\n", p->vol_fields.bits.interlaced);
va_TraceMsg(trace_ctx, "\tobmc_disable= %d\n", p->vol_fields.bits.obmc_disable);
va_TraceMsg(trace_ctx, "\tsprite_enable= %d\n", p->vol_fields.bits.sprite_enable);
va_TraceMsg(trace_ctx, "\tsprite_warping_accuracy= %d\n", p->vol_fields.bits.sprite_warping_accuracy);
va_TraceMsg(trace_ctx, "\tquant_type= %d\n", p->vol_fields.bits.quant_type);
va_TraceMsg(trace_ctx, "\tquarter_sample= %d\n", p->vol_fields.bits.quarter_sample);
va_TraceMsg(trace_ctx, "\tdata_partitioned= %d\n", p->vol_fields.bits.data_partitioned);
va_TraceMsg(trace_ctx, "\treversible_vlc= %d\n", p->vol_fields.bits.reversible_vlc);
va_TraceMsg(trace_ctx, "\tresync_marker_disable= %d\n", p->vol_fields.bits.resync_marker_disable);
va_TraceMsg(trace_ctx, "\tno_of_sprite_warping_points = %d\n", p->no_of_sprite_warping_points);
va_TraceMsg(trace_ctx, "\tsprite_trajectory_du =");
for (i = 0; i < 3; i++)
va_TraceMsg(trace_ctx, "\t%d", p->sprite_trajectory_du[i]);
va_TraceMsg(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tsprite_trajectory_dv =");
for (i = 0; i < 3; i++)
va_TraceMsg(trace_ctx, "\t%d", p->sprite_trajectory_dv[i]);
va_TraceMsg(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tvop_fields value = %d\n", p->vop_fields.value);
va_TraceMsg(trace_ctx, "\tvop_coding_type= %d\n", p->vop_fields.bits.vop_coding_type);
va_TraceMsg(trace_ctx, "\tbackward_reference_vop_coding_type= %d\n", p->vop_fields.bits.backward_reference_vop_coding_type);
va_TraceMsg(trace_ctx, "\tvop_rounding_type= %d\n", p->vop_fields.bits.vop_rounding_type);
va_TraceMsg(trace_ctx, "\tintra_dc_vlc_thr= %d\n", p->vop_fields.bits.intra_dc_vlc_thr);
va_TraceMsg(trace_ctx, "\ttop_field_first= %d\n", p->vop_fields.bits.top_field_first);
va_TraceMsg(trace_ctx, "\talternate_vertical_scan_flag= %d\n", p->vop_fields.bits.alternate_vertical_scan_flag);
va_TraceMsg(trace_ctx, "\tvop_fcode_forward = %d\n", p->vop_fcode_forward);
va_TraceMsg(trace_ctx, "\tvop_fcode_backward = %d\n", p->vop_fcode_backward);
va_TraceMsg(trace_ctx, "\tnum_gobs_in_vop = %d\n", p->num_gobs_in_vop);
va_TraceMsg(trace_ctx, "\tnum_macroblocks_in_gob = %d\n", p->num_macroblocks_in_gob);
va_TraceMsg(trace_ctx, "\tTRB = %d\n", p->TRB);
va_TraceMsg(trace_ctx, "\tTRD = %d\n", p->TRD);
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVAIQMatrixBufferMPEG4(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i;
VAIQMatrixBufferMPEG4 *p = (VAIQMatrixBufferMPEG4 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "VAIQMatrixBufferMPEG4\n");
va_TraceMsg(trace_ctx, "\tload_intra_quant_mat = %d\n", p->load_intra_quant_mat);
va_TraceMsg(trace_ctx, "\tload_non_intra_quant_mat = %d\n", p->load_non_intra_quant_mat);
va_TraceMsg(trace_ctx, "\tintra_quant_mat =\n");
for (i = 0; i < 64; i++)
va_TraceMsg(trace_ctx, "\t\t%d\n", p->intra_quant_mat[i]);
va_TraceMsg(trace_ctx, "\tnon_intra_quant_mat =\n");
for (i = 0; i < 64; i++)
va_TraceMsg(trace_ctx, "\t\t%d\n", p->non_intra_quant_mat[i]);
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVAEncSequenceParameterBufferMPEG2(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VAEncSequenceParameterBufferMPEG2 *p = (VAEncSequenceParameterBufferMPEG2 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferMPEG2\n");
va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
va_TraceMsg(trace_ctx, "\tframe_rate = %f\n", p->frame_rate);
va_TraceMsg(trace_ctx, "\tvbv_buffer_size = %d\n", p->vbv_buffer_size);
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVAEncSequenceParameterBufferMPEG4(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VAEncSequenceParameterBufferMPEG4 *p = (VAEncSequenceParameterBufferMPEG4 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferMPEG4\n");
va_TraceMsg(trace_ctx, "\tprofile_and_level_indication = %d\n", p->profile_and_level_indication);
va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
va_TraceMsg(trace_ctx, "\tvideo_object_layer_width = %d\n", p->video_object_layer_width);
va_TraceMsg(trace_ctx, "\tvideo_object_layer_height = %d\n", p->video_object_layer_height);
va_TraceMsg(trace_ctx, "\tvop_time_increment_resolution = %d\n", p->vop_time_increment_resolution);
va_TraceMsg(trace_ctx, "\tfixed_vop_rate = %d\n", p->fixed_vop_rate);
va_TraceMsg(trace_ctx, "\tfixed_vop_time_increment = %d\n", p->fixed_vop_time_increment);
va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
va_TraceMsg(trace_ctx, "\tframe_rate = %d\n", p->frame_rate);
va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp);
va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp);
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVAEncPictureParameterBufferMPEG4(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VAEncPictureParameterBufferMPEG4 *p = (VAEncPictureParameterBufferMPEG4 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferMPEG4\n");
va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture);
va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture);
va_TraceMsg(trace_ctx, "\tcoded_buf = 0x%08x\n", p->coded_buf);
va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width);
va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height);
va_TraceMsg(trace_ctx, "\tmodulo_time_base = %d\n", p->modulo_time_base);
va_TraceMsg(trace_ctx, "\tvop_time_increment = %d\n", p->vop_time_increment);
va_TraceMsg(trace_ctx, "\tpicture_type = %d\n", p->picture_type);
va_TraceMsg(trace_ctx, NULL);
return;
}
static void va_TraceVASliceParameterBufferMPEG4(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VASliceParameterBufferMPEG4 *p = (VASliceParameterBufferMPEG4 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
trace_ctx->trace_slice_no++;
trace_ctx->trace_slice_size = p->slice_data_size;
va_TraceMsg(trace_ctx, "VASliceParameterBufferMPEG4\n");
va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size);
va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset);
va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag);
va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset);
va_TraceMsg(trace_ctx, "\tmacroblock_number = %d\n", p->macroblock_number);
va_TraceMsg(trace_ctx, "\tquant_scale = %d\n", p->quant_scale);
va_TraceMsg(trace_ctx, NULL);
return;
}
static inline void va_TraceFlagIfNotZero(
struct trace_context *trace_ctx,
const char *name, /* in */
unsigned int flag /* in */
)
{
if (flag != 0) {
va_TraceMsg(trace_ctx, "%s = %x\n", name, flag);
}
}
static inline void va_TraceIsRextProfile(
VADisplay dpy,
VAContextID context,
bool *isRext /* out */
)
{
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
*isRext = (\
trace_ctx->trace_profile == VAProfileHEVCMain12 || \
trace_ctx->trace_profile == VAProfileHEVCMain422_10 || \
trace_ctx->trace_profile == VAProfileHEVCMain422_12 || \
trace_ctx->trace_profile == VAProfileHEVCMain444 || \
trace_ctx->trace_profile == VAProfileHEVCMain444_10 || \
trace_ctx->trace_profile == VAProfileHEVCMain444_12 || \
trace_ctx->trace_profile == VAProfileHEVCSccMain || \
trace_ctx->trace_profile == VAProfileHEVCSccMain10 || \
trace_ctx->trace_profile == VAProfileHEVCSccMain444 || \
trace_ctx->trace_profile == VAProfileHEVCSccMain444_10 \
);
}
static inline void va_TraceIsSccProfile(
VADisplay dpy,
VAContextID context,
bool *isScc /* out */
)
{
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
*isScc = (\
trace_ctx->trace_profile == VAProfileHEVCSccMain || \
trace_ctx->trace_profile == VAProfileHEVCSccMain10 || \
trace_ctx->trace_profile == VAProfileHEVCSccMain444 || \
trace_ctx->trace_profile == VAProfileHEVCSccMain444_10 \
);
}
static void va_TraceVAPictureParameterBufferHEVC(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i, j;
bool isRext = false;
bool isScc = false;
VAPictureParameterBufferHEVC *p = NULL;
VAPictureParameterBufferHEVCRext *pRext = NULL;
VAPictureParameterBufferHEVCScc *pScc = NULL;
va_TraceIsRextProfile(dpy, context, &isRext);
va_TraceIsSccProfile(dpy, context, &isScc);
if (isRext) {
p = &((VAPictureParameterBufferHEVCExtension*)data)->base;
pRext = &((VAPictureParameterBufferHEVCExtension*)data)->rext;
if (isScc)
pScc = &((VAPictureParameterBufferHEVCExtension*)data)->scc;
} else
p = (VAPictureParameterBufferHEVC*)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TracePrint(trace_ctx, "VAPictureParameterBufferHEVC\n");
va_TraceMsg(trace_ctx, "\tCurrPic.picture_id = 0x%08x\n", p->CurrPic.picture_id);
va_TraceMsg(trace_ctx, "\tCurrPic.frame_idx = %d\n", p->CurrPic.pic_order_cnt);
va_TraceMsg(trace_ctx, "\tCurrPic.flags = %d\n", p->CurrPic.flags);
va_TraceMsg(trace_ctx, "\tReferenceFrames (picture_id-pic_order_cnt-flags):\n");
for (i = 0; i < 15; i++) {
if ((p->ReferenceFrames[i].picture_id != VA_INVALID_SURFACE) &&
((p->ReferenceFrames[i].flags & VA_PICTURE_HEVC_INVALID) == 0)) {
va_TraceMsg(trace_ctx, "\t\t0x%08x-%08d-0x%08x\n",
p->ReferenceFrames[i].picture_id,
p->ReferenceFrames[i].pic_order_cnt,
p->ReferenceFrames[i].flags);
} else
va_TraceMsg(trace_ctx, "\t\tinv-inv-inv-inv-inv\n");
}
va_TraceMsg(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tpic_width_in_luma_samples = %d\n", p->pic_width_in_luma_samples);
va_TraceMsg(trace_ctx, "\tpic_height_in_luma_samples = %d\n", p->pic_height_in_luma_samples);
va_TraceMsg(trace_ctx, "\tpic_fields = %d\n", p->pic_fields.value);
va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->pic_fields.bits.chroma_format_idc);
va_TraceMsg(trace_ctx, "\tseparate_colour_plane_flag = %d\n", p->pic_fields.bits.separate_colour_plane_flag);
va_TraceMsg(trace_ctx, "\tpcm_enabled_flag = %d\n", p->pic_fields.bits.pcm_enabled_flag);
va_TraceMsg(trace_ctx, "\tscaling_list_enabled_flag = %d\n", p->pic_fields.bits.scaling_list_enabled_flag);
va_TraceMsg(trace_ctx, "\ttransform_skip_enabled_flag = %d\n", p->pic_fields.bits.transform_skip_enabled_flag);
va_TraceMsg(trace_ctx, "\tamp_enabled_flag = %d\n", p->pic_fields.bits.amp_enabled_flag);
va_TraceMsg(trace_ctx, "\tstrong_intra_smoothing_enabled_flag = %d\n", p->pic_fields.bits.strong_intra_smoothing_enabled_flag);
va_TraceMsg(trace_ctx, "\tsign_data_hiding_enabled_flag = %d\n", p->pic_fields.bits.sign_data_hiding_enabled_flag);
va_TraceMsg(trace_ctx, "\tconstrained_intra_pred_flag = %d\n", p->pic_fields.bits.constrained_intra_pred_flag);
va_TraceMsg(trace_ctx, "\tcu_qp_delta_enabled_flag = %d\n", p->pic_fields.bits.cu_qp_delta_enabled_flag);
va_TraceMsg(trace_ctx, "\tweighted_pred_flag = %d\n", p->pic_fields.bits.weighted_pred_flag);
va_TraceMsg(trace_ctx, "\tweighted_bipred_flag = %d\n", p->pic_fields.bits.weighted_bipred_flag);
va_TraceMsg(trace_ctx, "\ttransquant_bypass_enabled_flag = %d\n", p->pic_fields.bits.transquant_bypass_enabled_flag);
va_TraceMsg(trace_ctx, "\ttiles_enabled_flag = %d\n", p->pic_fields.bits.tiles_enabled_flag);
va_TraceMsg(trace_ctx, "\tentropy_coding_sync_enabled_flag = %d\n", p->pic_fields.bits.entropy_coding_sync_enabled_flag);
va_TraceMsg(trace_ctx, "\tpps_loop_filter_across_slices_enabled_flag = %d\n", p->pic_fields.bits.pps_loop_filter_across_slices_enabled_flag);
va_TraceMsg(trace_ctx, "\tloop_filter_across_tiles_enabled_flag = %d\n", p->pic_fields.bits.loop_filter_across_tiles_enabled_flag);
va_TraceMsg(trace_ctx, "\tpcm_loop_filter_disabled_flag = %d\n", p->pic_fields.bits.pcm_loop_filter_disabled_flag);
va_TraceMsg(trace_ctx, "\tNoPicReorderingFlag = %d\n", p->pic_fields.bits.NoPicReorderingFlag);
va_TraceMsg(trace_ctx, "\tNoBiPredFlag = %d\n", p->pic_fields.bits.NoBiPredFlag);
va_TraceMsg(trace_ctx, "\tReservedBits = %d\n", p->pic_fields.bits.ReservedBits);
va_TraceMsg(trace_ctx, "\tsps_max_dec_pic_buffering_minus1 = %d\n", p->sps_max_dec_pic_buffering_minus1);
va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8);
va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8);
va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_luma_minus1 = %d\n", p->pcm_sample_bit_depth_luma_minus1);
va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_chroma_minus1 = %d\n", p->pcm_sample_bit_depth_chroma_minus1);
va_TraceMsg(trace_ctx, "\tlog2_min_luma_coding_block_size_minus3 = %d\n", p->log2_min_luma_coding_block_size_minus3);
va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_luma_coding_block_size = %d\n", p->log2_diff_max_min_luma_coding_block_size);
va_TraceMsg(trace_ctx, "\tlog2_min_transform_block_size_minus2 = %d\n", p->log2_min_transform_block_size_minus2);
va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_transform_block_size = %d\n", p->log2_diff_max_min_transform_block_size);
va_TraceMsg(trace_ctx, "\tlog2_min_pcm_luma_coding_block_size_minus3 = %d\n", p->log2_min_pcm_luma_coding_block_size_minus3);
va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_pcm_luma_coding_block_size = %d\n", p->log2_diff_max_min_pcm_luma_coding_block_size);
va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_intra = %d\n", p->max_transform_hierarchy_depth_intra);
va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_inter = %d\n", p->max_transform_hierarchy_depth_inter);
va_TraceMsg(trace_ctx, "\tinit_qp_minus26 = %d\n", p->init_qp_minus26);
va_TraceMsg(trace_ctx, "\tdiff_cu_qp_delta_depth = %d\n", p->diff_cu_qp_delta_depth);
va_TraceMsg(trace_ctx, "\tpps_cb_qp_offset = %d\n", p->pps_cb_qp_offset);
va_TraceMsg(trace_ctx, "\tpps_cr_qp_offset = %d\n", p->pps_cr_qp_offset);
va_TraceMsg(trace_ctx, "\tlog2_parallel_merge_level_minus2 = %d\n", p->log2_parallel_merge_level_minus2);
va_TraceMsg(trace_ctx, "\tnum_tile_columns_minus1 = %d\n", p->num_tile_columns_minus1);
va_TraceMsg(trace_ctx, "\tnum_tile_rows_minus1 = %d\n", p->num_tile_rows_minus1);
va_TraceMsg(trace_ctx, "\tcolumn_width_minus1[19]=\n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 19; i++) {
va_TracePrint(trace_ctx, "\t%d", p->column_width_minus1[i]);
if ((i + 1) % 8 == 0)
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\trow_height_minus1[21]=\n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 21; i++) {
va_TracePrint(trace_ctx, "\t%d", p->row_height_minus1[i]);
if ((i + 1) % 8 == 0)
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tslice_parsing_fields = %d\n", p->slice_parsing_fields.value);
va_TraceMsg(trace_ctx, "\tlists_modification_present_flag = %d\n", p->slice_parsing_fields.bits.lists_modification_present_flag);
va_TraceMsg(trace_ctx, "\tlong_term_ref_pics_present_flag = %d\n", p->slice_parsing_fields.bits.long_term_ref_pics_present_flag);
va_TraceMsg(trace_ctx, "\tsps_temporal_mvp_enabled_flag = %d\n", p->slice_parsing_fields.bits.sps_temporal_mvp_enabled_flag);
va_TraceMsg(trace_ctx, "\tcabac_init_present_flag = %d\n", p->slice_parsing_fields.bits.cabac_init_present_flag);
va_TraceMsg(trace_ctx, "\toutput_flag_present_flag = %d\n", p->slice_parsing_fields.bits.output_flag_present_flag);
va_TraceMsg(trace_ctx, "\tdependent_slice_segments_enabled_flag = %d\n", p->slice_parsing_fields.bits.dependent_slice_segments_enabled_flag);
va_TraceMsg(trace_ctx, "\tpps_slice_chroma_qp_offsets_present_flag = %d\n", p->slice_parsing_fields.bits.pps_slice_chroma_qp_offsets_present_flag);
va_TraceMsg(trace_ctx, "\tsample_adaptive_offset_enabled_flag = %d\n", p->slice_parsing_fields.bits.sample_adaptive_offset_enabled_flag);
va_TraceMsg(trace_ctx, "\tdeblocking_filter_override_enabled_flag = %d\n", p->slice_parsing_fields.bits.deblocking_filter_override_enabled_flag);
va_TraceMsg(trace_ctx, "\tpps_disable_deblocking_filter_flag = %d\n", p->slice_parsing_fields.bits.pps_disable_deblocking_filter_flag);
va_TraceMsg(trace_ctx, "\tslice_segment_header_extension_present_flag = %d\n", p->slice_parsing_fields.bits.slice_segment_header_extension_present_flag);
va_TraceMsg(trace_ctx, "\tRapPicFlag = %d\n", p->slice_parsing_fields.bits.RapPicFlag);
va_TraceMsg(trace_ctx, "\tIdrPicFlag = %d\n", p->slice_parsing_fields.bits.IdrPicFlag);
va_TraceMsg(trace_ctx, "\tIntraPicFlag = %d\n", p->slice_parsing_fields.bits.IntraPicFlag);
va_TraceMsg(trace_ctx, "\tReservedBits = %d\n", p->slice_parsing_fields.bits.ReservedBits);
va_TraceMsg(trace_ctx, "\tlog2_max_pic_order_cnt_lsb_minus4 = %d\n", p->log2_max_pic_order_cnt_lsb_minus4);
va_TraceMsg(trace_ctx, "\tnum_short_term_ref_pic_sets = %d\n", p->num_short_term_ref_pic_sets);
va_TraceMsg(trace_ctx, "\tnum_long_term_ref_pic_sps = %d\n", p->num_long_term_ref_pic_sps);
va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_default_active_minus1 = %d\n", p->num_ref_idx_l0_default_active_minus1);
va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_default_active_minus1 = %d\n", p->num_ref_idx_l1_default_active_minus1);
va_TraceMsg(trace_ctx, "\tpps_beta_offset_div2 = %d\n", p->pps_beta_offset_div2);
va_TraceMsg(trace_ctx, "\tpps_tc_offset_div2 = %d\n", p->pps_tc_offset_div2);
va_TraceMsg(trace_ctx, "\tnum_extra_slice_header_bits = %d\n", p->num_extra_slice_header_bits);
va_TraceMsg(trace_ctx, "\tst_rps_bits = %d\n", p->st_rps_bits);
if (isRext && pRext) {
va_TraceMsg(trace_ctx, "\trange_extension_pic_fields = %d\n", pRext->range_extension_pic_fields.value);
va_TraceMsg(trace_ctx, "\ttransform_skip_rotation_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.transform_skip_rotation_enabled_flag);
va_TraceMsg(trace_ctx, "\ttransform_skip_context_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.transform_skip_context_enabled_flag);
va_TraceMsg(trace_ctx, "\timplicit_rdpcm_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.implicit_rdpcm_enabled_flag);
va_TraceMsg(trace_ctx, "\texplicit_rdpcm_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.explicit_rdpcm_enabled_flag);
va_TraceMsg(trace_ctx, "\textended_precision_processing_flag = %d\n", pRext->range_extension_pic_fields.bits.extended_precision_processing_flag);
va_TraceMsg(trace_ctx, "\tintra_smoothing_disabled_flag = %d\n", pRext->range_extension_pic_fields.bits.intra_smoothing_disabled_flag);
va_TraceMsg(trace_ctx, "\thigh_precision_offsets_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.high_precision_offsets_enabled_flag);
va_TraceMsg(trace_ctx, "\tpersistent_rice_adaptation_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.persistent_rice_adaptation_enabled_flag);
va_TraceMsg(trace_ctx, "\tcabac_bypass_alignment_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.cabac_bypass_alignment_enabled_flag);
va_TraceMsg(trace_ctx, "\tcross_component_prediction_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.cross_component_prediction_enabled_flag);
va_TraceMsg(trace_ctx, "\tchroma_qp_offset_list_enabled_flag = %d\n", pRext->range_extension_pic_fields.bits.chroma_qp_offset_list_enabled_flag);
va_TraceMsg(trace_ctx, "\treserved = %d\n", pRext->range_extension_pic_fields.bits.reserved);
va_TraceMsg(trace_ctx, "\tdiff_cu_chroma_qp_offset_depth = %d\n", pRext->diff_cu_chroma_qp_offset_depth);
va_TraceMsg(trace_ctx, "\tchroma_qp_offset_list_len_minus1 = %d\n", pRext->chroma_qp_offset_list_len_minus1);
va_TraceMsg(trace_ctx, "\tlog2_sao_offset_scale_luma = %d\n", pRext->log2_sao_offset_scale_luma);
va_TraceMsg(trace_ctx, "\tlog2_sao_offset_scale_chroma = %d\n", pRext->log2_sao_offset_scale_chroma);
va_TraceMsg(trace_ctx, "\tlog2_max_transform_skip_block_size_minus2 = %d\n", pRext->log2_max_transform_skip_block_size_minus2);
va_TraceMsg(trace_ctx, "\tcb_qp_offset_list[6] = \n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 6; i++)
va_TracePrint(trace_ctx, "\t%d", pRext->cb_qp_offset_list[i]);
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tcr_qp_offset_list[] = \n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 6; i++)
va_TracePrint(trace_ctx, "\t%d", pRext->cr_qp_offset_list[i]);
va_TracePrint(trace_ctx, "\n");
}
if (isScc && pScc) {
va_TraceMsg(trace_ctx, "\tscreen_content_pic_fields = %d\n", pScc->screen_content_pic_fields.value);
va_TraceMsg(trace_ctx, "\tpps_curr_pic_ref_enabled_flag = %d\n", pScc->screen_content_pic_fields.bits.pps_curr_pic_ref_enabled_flag);
va_TraceMsg(trace_ctx, "\tpalette_mode_enabled_flag = %d\n", pScc->screen_content_pic_fields.bits.palette_mode_enabled_flag);
va_TraceMsg(trace_ctx, "\tmotion_vector_resolution_control_idc = %d\n", pScc->screen_content_pic_fields.bits.motion_vector_resolution_control_idc);
va_TraceMsg(trace_ctx, "\tintra_boundary_filtering_disabled_flag = %d\n", pScc->screen_content_pic_fields.bits.intra_boundary_filtering_disabled_flag);
va_TraceMsg(trace_ctx, "\tresidual_adaptive_colour_transform_enabled_flag = %d\n", pScc->screen_content_pic_fields.bits.residual_adaptive_colour_transform_enabled_flag);
va_TraceMsg(trace_ctx, "\tpps_slice_act_qp_offsets_present_flag = %d\n", pScc->screen_content_pic_fields.bits.pps_slice_act_qp_offsets_present_flag);
va_TraceMsg(trace_ctx, "\treserved = %d\n", pScc->screen_content_pic_fields.bits.reserved);
va_TraceMsg(trace_ctx, "\tpalette_max_size = %d\n", pScc->palette_max_size);
va_TraceMsg(trace_ctx, "\tdelta_palette_max_predictor_size = %d\n", pScc->delta_palette_max_predictor_size);
va_TraceMsg(trace_ctx, "\tpredictor_palette_size = %d\n", pScc->predictor_palette_size);
va_TraceMsg(trace_ctx, "\tpredictor_palette_entries[3][128] = \n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 3; i++) {
for (j = 0; j < 128; j++) {
va_TracePrint(trace_ctx, "\t%d", pScc->predictor_palette_entries[i][j]);
if ((j + 1) % 8 == 0)
TRACE_NEWLINE();
}
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tpps_act_y_qp_offset_plus5 = %d\n", pScc->pps_act_y_qp_offset_plus5);
va_TraceMsg(trace_ctx, "\tpps_act_cb_qp_offset_plus5 = %d\n", pScc->pps_act_cb_qp_offset_plus5);
va_TraceMsg(trace_ctx, "\tpps_act_cr_qp_offset_plus3 = %d\n", pScc->pps_act_cr_qp_offset_plus3);
}
return;
}
static void va_TraceVASliceParameterBufferHEVC(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
int i, j;
bool isRext = false;
VASliceParameterBufferHEVC* p = NULL;
VASliceParameterBufferHEVCRext *pRext = NULL;
va_TraceIsRextProfile(dpy, context, &isRext);
if (isRext) {
p = &((VASliceParameterBufferHEVCExtension*)data)->base;
pRext = &((VASliceParameterBufferHEVCExtension*)data)->rext;
} else
p = (VASliceParameterBufferHEVC*)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
trace_ctx->trace_slice_no++;
trace_ctx->trace_slice_size = p->slice_data_size;
va_TracePrint(trace_ctx, "VASliceParameterBufferHEVC\n");
va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size);
va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset);
va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag);
va_TraceMsg(trace_ctx, "\tslice_data_byte_offset = %d\n", p->slice_data_byte_offset);
va_TraceMsg(trace_ctx, "\tslice_segment_address = %d\n", p->slice_segment_address);
va_TraceMsg(trace_ctx, "\tRefPicList[2][15]=\n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 2; i++) {
for (j = 0; j < 15; j++) {
va_TracePrint(trace_ctx, "\t%d", p->RefPicList[i][j]);
if ((j + 1) % 8 == 0)
TRACE_NEWLINE();
}
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\tLongSliceFlags.value = %d\n", p->LongSliceFlags.value);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.LastSliceOfPic = %d\n", p->LongSliceFlags.fields.LastSliceOfPic);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.dependent_slice_segment_flag = %d\n", p->LongSliceFlags.fields.dependent_slice_segment_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_type = %d\n", p->LongSliceFlags.fields.slice_type);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.color_plane_id = %d\n", p->LongSliceFlags.fields.color_plane_id);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_sao_luma_flag = %d\n", p->LongSliceFlags.fields.slice_sao_luma_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_sao_chroma_flag = %d\n", p->LongSliceFlags.fields.slice_sao_chroma_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.mvd_l1_zero_flag = %d\n", p->LongSliceFlags.fields.mvd_l1_zero_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.cabac_init_flag = %d\n", p->LongSliceFlags.fields.cabac_init_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_temporal_mvp_enabled_flag = %d\n", p->LongSliceFlags.fields.slice_temporal_mvp_enabled_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_deblocking_filter_disabled_flag = %d\n", p->LongSliceFlags.fields.slice_deblocking_filter_disabled_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.collocated_from_l0_flag = %d\n", p->LongSliceFlags.fields.collocated_from_l0_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_loop_filter_across_slices_enabled_flag = %d\n", p->LongSliceFlags.fields.slice_loop_filter_across_slices_enabled_flag);
va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.reserved = %d\n", p->LongSliceFlags.fields.reserved);
va_TraceMsg(trace_ctx, "\tcollocated_ref_idx = %d\n", p->collocated_ref_idx);
va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta);
va_TraceMsg(trace_ctx, "\tslice_cb_qp_offset = %d\n", p->slice_cb_qp_offset);
va_TraceMsg(trace_ctx, "\tslice_cr_qp_offset = %d\n", p->slice_cr_qp_offset);
va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2);
va_TraceMsg(trace_ctx, "\tslice_tc_offset_div2 = %d\n", p->slice_tc_offset_div2);
va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom);
va_TraceMsg(trace_ctx, "\tdelta_chroma_log2_weight_denom = %d\n", p->delta_chroma_log2_weight_denom);
va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1);
for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++) {
va_TraceMsg(trace_ctx, "\t% d ", p->delta_luma_weight_l0[i]);
va_TracePrint(trace_ctx, "\t% d ", p->luma_offset_l0[i]);
va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l0[i][0]);
va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l0[i][1]);
va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL0[i][0]);
va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL0[i][1]);
va_TracePrint(trace_ctx, "\n");
}
va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1);
for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++) {
va_TraceMsg(trace_ctx, "\t% d ", p->delta_luma_weight_l1[i]);
va_TracePrint(trace_ctx, "\t% d ", p->luma_offset_l1[i]);
va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l1[i][0]);
va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l1[i][1]);
va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL1[i][0]);
va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL1[i][1]);
va_TracePrint(trace_ctx, "\n");
}
va_TraceMsg(trace_ctx, "\tfive_minus_max_num_merge_cand = %d\n", p->five_minus_max_num_merge_cand);
va_TraceMsg(trace_ctx, "\tnum_entry_point_offsets = %d\n", p->num_entry_point_offsets);
va_TraceMsg(trace_ctx, "\tentry_offset_to_subset_array = %d\n", p->entry_offset_to_subset_array);
va_TraceMsg(trace_ctx, "\tslice_data_num_emu_prevn_bytes = %d\n", p->slice_data_num_emu_prevn_bytes);
if (isRext && pRext) {
va_TraceMsg(trace_ctx, "\tluma_offset_l0[15] = \n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 15; i++) {
va_TracePrint(trace_ctx, "\t%d", pRext->luma_offset_l0[i]);
if ((i + 1) % 8 == 0)
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tChromaOffsetL0[15][2] = \n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 15; i++) {
for (j = 0; j < 2; j++) {
va_TracePrint(trace_ctx, "\t%d", pRext->ChromaOffsetL0[i][j]);
}
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tluma_offset_l1[15] = \n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 15; i++) {
va_TracePrint(trace_ctx, "\t%d", pRext->luma_offset_l1[i]);
if ((i + 1) % 8 == 0)
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tChromaOffsetL1[15][2] = \n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 15; i++) {
for (j = 0; j < 2; j++) {
va_TracePrint(trace_ctx, "\t%d", pRext->ChromaOffsetL1[i][j]);
}
TRACE_NEWLINE();
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tslice_ext_flags = %d\n", pRext->slice_ext_flags.value);
va_TraceMsg(trace_ctx, "\tcu_chroma_qp_offset_enabled_flag = %d\n", pRext->slice_ext_flags.bits.cu_chroma_qp_offset_enabled_flag);
va_TraceMsg(trace_ctx, "\tuse_integer_mv_flag = %d\n", pRext->slice_ext_flags.bits.use_integer_mv_flag);
va_TraceMsg(trace_ctx, "\treserved = %d\n", pRext->slice_ext_flags.bits.reserved);
va_TraceMsg(trace_ctx, "\tslice_act_y_qp_offset = %d\n", pRext->slice_act_y_qp_offset);
va_TraceMsg(trace_ctx, "\tslice_act_cb_qp_offset = %d\n", pRext->slice_act_cb_qp_offset);
va_TraceMsg(trace_ctx, "\tslice_act_cr_qp_offset = %d\n", pRext->slice_act_cr_qp_offset);
}
va_TraceMsg(trace_ctx, NULL);
}
static void va_TraceVAIQMatrixBufferHEVC(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data
)
{
int i, j;
VAIQMatrixBufferHEVC* p = (VAIQMatrixBufferHEVC*)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
va_TracePrint(trace_ctx, "VAIQMatrixBufferHEVC\n");
va_TraceMsg(trace_ctx, "\tScalingList4x4[6][16]=\n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 6; i++) {
for (j = 0; j < 16; j++) {
va_TracePrint(trace_ctx, "\t%d\t", p->ScalingList4x4[i][j]);
if ((j + 1) % 8 == 0)
TRACE_NEWLINE();
}
}
va_TracePrint(trace_ctx, "\tScalingList8x8[6][64]=\n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 6; i++) {
for (j = 0; j < 64; j++) {
va_TracePrint(trace_ctx, "\t%d", p->ScalingList8x8[i][j]);
if ((j + 1) % 8 == 0)
TRACE_NEWLINE();
}
}
va_TracePrint(trace_ctx, "\tScalingList16x16[6][64]=\n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 6; i++) {
for (j = 0; j < 64; j++) {
va_TracePrint(trace_ctx, "\t%d", p->ScalingList16x16[i][j]);
if ((j + 1) % 8 == 0)
TRACE_NEWLINE();
}
}
va_TracePrint(trace_ctx, "\tScalingList32x32[2][64]=\n");
va_TraceMsg(trace_ctx, "");
for (i = 0; i < 2; i++) {
for (j = 0; j < 64; j++) {
va_TracePrint(trace_ctx, "\t%d", p->ScalingList32x32[i][j]);
if ((j + 1) % 8 == 0)
TRACE_NEWLINE();
}
}
va_TracePrint(trace_ctx, "\tScalingListDC16x16[6]=\n");
va_TraceMsg(trace_ctx, "");
for (j = 0; j < 6; j++) {
va_TracePrint(trace_ctx, "\t%d", p->ScalingListDC16x16[j]);
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, "\tScalingListDC32x32[2]=\n");
va_TraceMsg(trace_ctx, "");
for (j = 0; j < 2; j++) {
va_TracePrint(trace_ctx, "\t%d", p->ScalingListDC32x32[j]);
}
va_TracePrint(trace_ctx, "\n");
va_TraceMsg(trace_ctx, NULL);
}
static void va_TraceVAEncSequenceParameterBufferHEVC(
VADisplay dpy,
VAContextID context,
VABufferID buffer,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void *data)
{
VAEncSequenceParameterBufferHEVC *p = (VAEncSequenceParameterBufferHEVC *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
if (!p)
return;
va_TracePrint(trace_ctx, "\t--VAEncSequenceParameterBufferHEVC\n");
va_TraceMsg(trace_ctx, "\tgeneral_profile_idc = %d\n", p->general_profile_idc);
va_TraceMsg(trace_ctx, "\tgeneral_level_idc = %d\n", p->general_level_idc);
va_TraceMsg(trace_ctx, "\tgeneral_tier_flag = %d\n", p->general_tier_flag);
va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period);
va_TraceMsg(trace_ctx, "\tintra_idr_period = %d\n", p->intra_idr_period);
va_TraceMsg(trace_ctx, "\tip_period = %d\n", p->ip_period);
va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second);
va_TraceMsg(trace_ctx, "\tpic_width_in_luma_samples = %d\n", p->pic_width_in_luma_samples);
va_TraceMsg(trace_ctx, "\tpic_height_in_luma_samples = %d\n", p->pic_height_in_luma_samples);
va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc);
va_TraceMsg(trace_ctx, "\tseparate_colour_plane_flag = %d\n", p->seq_fields.bits.separate_colour_plane_flag);
va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->seq_fields.bits.bit_depth_luma_minus8);
va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->seq_fields.bits.bit_depth_chroma_minus8);
va_TraceMsg(trace_ctx, "\tscaling_list_enabled_flag = %d\n", p->seq_fields.bits.scaling_list_enabled_flag);
va_TraceMsg(trace_ctx, "\tstrong_intra_smoothing_enabled_flag = %d\n", p->seq_fields.bits.strong_intra_smoothing_enabled_flag);
va_TraceMsg(trace_ctx, "\tamp_enabled_flag = %d\n", p->seq_fields.bits.amp_enabled_flag);
va_TraceMsg(trace_ctx, "\tsample_adaptive_offset_enabled_flag = %d\n", p->seq_fields.bits.sample_adaptive_offset_enabled_flag);
va_TraceMsg(trace_ctx, "\tpcm_enabled_flag = %d\n", p->seq_fields.bits.pcm_enabled_flag);
va_TraceMsg(trace_ctx, "\tpcm_loop_filter_disabled_flag = %d\n", p->seq_fields.bits.pcm_loop_filter_disabled_flag);
va_TraceMsg(trace_ctx, "\tsps_temporal_mvp_enabled_flag = %d\n", p->seq_fields.bits.sps_temporal_mvp_enabled_flag);
va_TraceMsg(trace_ctx, "\treserved_bits = %d\n", p->seq_fields.bits.reserved_bits);
va_TraceMsg(trace_ctx, "\tlog2_min_luma_coding_block_size_minus3 = %d\n", p->log2_min_luma_coding_block_size_minus3);
va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_luma_coding_block_size = %d\n", p->log2_diff_max_min_luma_coding_block_size);
va_TraceMsg(trace_ctx, "\tlog2_min_transform_block_size_minus2 = %d\n", p->log2_min_transform_block_size_minus2);
va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_transform_block_size = %d\n", p->log2_diff_max_min_transform_block_size);
va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_inter = %d\n", p->max_transform_hierarchy_depth_inter);
va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_intra = %d\n", p->max_transform_hierarchy_depth_intra);
va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_luma_minus1 = %d\n", p->pcm_sample_bit_depth_luma_minus1);
va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_chroma_minus1 = %d\n", p->pcm_sample_bit_depth_chroma_minus1);
va_TraceMsg(trace_ctx, "\tlog2_min_pcm_luma_coding_block_size_minus3 = %d\n", p->log2_min_pcm_luma_coding_block_size_minus3);
va_TraceMsg(trace_ctx, "\tlog2_max_pcm_luma_coding_block_size_minus3 = %d\n", p->log2_max_pcm_luma_coding_block_size_minus3);
va_TraceMsg(trace_ctx, "\tvui_parameters_present_flag = %d\n", p->vui_parameters_present_flag);
va_TraceMsg(trace_ctx, "\taspect_ratio_info_present_flag = %d\n", p->vui_fields.bits.aspect_ratio_info_present_flag);
va_TraceMsg(trace_ctx, "\tneutral_chroma_indication_flag = %d\n", p->vui_fields.bits.neutral_chroma_indication_flag);
va_TraceMsg(trace_ctx, "\tfield_seq_flag = %d\n", p->vui_fields.bits.field_seq_flag);
va_TraceMsg(