summaryrefslogtreecommitdiff
path: root/va/va_trace.c
diff options
context:
space:
mode:
authorAustin Yuan <shengquan.yuan@intel.com>2013-06-08 10:22:36 +0800
committerbuildbot <buildbot@intel.com>2013-07-09 19:28:36 -0700
commit7d9a3d51091eff4c2c32653ad011ecae99dad4fe (patch)
tree2e10579bc758a7fa033dd1ec87bffcaf006a0ffd /va/va_trace.c
parent7b38de70eec885e25c0603c56732bd80db48e911 (diff)
downloadlibva-7d9a3d51091eff4c2c32653ad011ecae99dad4fe.tar.gz
Sync with new fdo staging branch
BZ: 119038 Change-Id: I4bf6b90e3bf0bee8f09a919d0a5fd548a1be5238 Signed-off-by: Austin Yuan <shengquan.yuan@intel.com> Signed-off-by: pingshix <pingx.shi@intel.com> Reviewed-on: http://android.intel.com:8080/115742 Reviewed-by: Sun, Jing A <jing.a.sun@intel.com> Reviewed-by: Guo, Nana N <nana.n.guo@intel.com> Reviewed-by: Wang, Kun K <kun.k.wang@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'va/va_trace.c')
-rwxr-xr-xva/va_trace.c209
1 files changed, 182 insertions, 27 deletions
diff --git a/va/va_trace.c b/va/va_trace.c
index 6c8aa15..936d4b6 100755
--- a/va/va_trace.c
+++ b/va/va_trace.c
@@ -28,6 +28,7 @@
#include "va_backend.h"
#include "va_trace.h"
#include "va_enc_h264.h"
+#include "va_enc_jpeg.h"
#include "va_dec_jpeg.h"
#include <assert.h>
#include <stdarg.h>
@@ -41,6 +42,7 @@
#include <unistd.h>
#include <time.h>
#include <errno.h>
+#include <pthread.h>
/*
* Env. to debug some issue, e.g. the decode/encode issue in a video conference scenerio:
@@ -100,6 +102,7 @@ static struct _trace_context {
unsigned int trace_frame_height; /* current frame height */
unsigned int trace_sequence_start; /* get a new sequence for encoding or not */
} trace_context[TRACE_CONTEXT_MAX]; /* trace five context at the same time */
+static pthread_mutex_t ctx_mutex = PTHREAD_MUTEX_INITIALIZER;
#define DPY2INDEX(dpy) \
int idx; \
@@ -164,15 +167,18 @@ void va_TraceInit(VADisplay dpy)
unsigned short suffix = 0xffff & ((unsigned int)time(NULL));
int trace_index = 0;
FILE *tmp;
-
+
+ pthread_mutex_lock(&ctx_mutex);
for (trace_index = 0; trace_index < TRACE_CONTEXT_MAX; trace_index++)
if (trace_context[trace_index].dpy == 0)
break;
-
- if (trace_index == TRACE_CONTEXT_MAX)
+ if (trace_index < TRACE_CONTEXT_MAX)
+ trace_context[trace_index].dpy = dpy;
+ pthread_mutex_unlock(&ctx_mutex);
+
+ if (trace_index == TRACE_CONTEXT_MAX)
return;
- memset(&trace_context[trace_index], 0, sizeof(struct _trace_context));
if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
FILE_NAME_SUFFIX(env_value);
trace_context[trace_index].trace_log_fn = strdup(env_value);
@@ -244,8 +250,6 @@ void va_TraceInit(VADisplay dpy)
trace_context[trace_index].trace_surface_yoff);
}
}
-
- trace_context[trace_index].dpy = dpy;
}
@@ -475,9 +479,11 @@ void va_TraceCreateConfig(
va_TraceMsg(idx, "\tprofile = %d\n", profile);
va_TraceMsg(idx, "\tentrypoint = %d\n", entrypoint);
va_TraceMsg(idx, "\tnum_attribs = %d\n", num_attribs);
- for (i = 0; i < num_attribs; i++) {
- va_TraceMsg(idx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type);
- va_TraceMsg(idx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value);
+ if (attrib_list) {
+ for (i = 0; i < num_attribs; i++) {
+ va_TraceMsg(idx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type);
+ va_TraceMsg(idx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value);
+ }
}
va_TraceMsg(idx, NULL);
@@ -519,6 +525,41 @@ void va_TraceCreateConfig(
}
}
+static void va_TraceSurfaceAttributes(
+ int idx,
+ 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++) {
+ va_TraceMsg(idx, "\tattrib_list[%i] =\n", i);
+
+ va_TraceMsg(idx, "\t\ttype = %d\n", p->type);
+ va_TraceMsg(idx, "\t\tflags = %d\n", p->flags);
+ va_TraceMsg(idx, "\t\tvalue.type = %d\n", p->value.type);
+ if (p->value.type == VAGenericValueTypeInteger)
+ va_TraceMsg(idx, "\t\tvalue.value.i = 0x%08x\n", p->value.value.i);
+ else if (p->value.type == VAGenericValueTypeFloat)
+ va_TraceMsg(idx, "\t\tvalue.value.f = %f\n", p->value.value.f);
+ else if (p->value.type == VAGenericValueTypePointer)
+ va_TraceMsg(idx, "\t\tvalue.value.p = %p\n", p->value.value.p);
+ else if (p->value.type == VAGenericValueTypeFunc)
+ va_TraceMsg(idx, "\t\tvalue.value.fn = %p\n", p->value.value.fn);
+
+ p++;
+ }
+}
void va_TraceCreateSurfaces(
VADisplay dpy,
@@ -541,13 +582,37 @@ void va_TraceCreateSurfaces(
va_TraceMsg(idx, "\tformat = %d\n", format);
va_TraceMsg(idx, "\tnum_surfaces = %d\n", num_surfaces);
- for (i = 0; i < num_surfaces; i++)
- va_TraceMsg(idx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]);
+ if (surfaces) {
+ for (i = 0; i < num_surfaces; i++)
+ va_TraceMsg(idx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]);
+ }
+
+ va_TraceSurfaceAttributes(idx, attrib_list, &num_attribs);
va_TraceMsg(idx, NULL);
}
+void va_TraceDestroySurfaces(
+ VADisplay dpy,
+ VASurfaceID *surface_list,
+ int num_surfaces
+)
+{
+ int i;
+ DPY2INDEX(dpy);
+
+ TRACE_FUNCNAME(idx);
+
+ if (surface_list) {
+ for (i = 0; i < num_surfaces; i++)
+ va_TraceMsg(idx, "\t\tsurfaces[%d] = 0x%08x\n", i, surface_list[i]);
+ }
+
+ va_TraceMsg(idx, NULL);
+}
+
+
void va_TraceCreateContext(
VADisplay dpy,
VAConfigID config_id,
@@ -563,18 +628,22 @@ void va_TraceCreateContext(
DPY2INDEX(dpy);
TRACE_FUNCNAME(idx);
-
+
+ va_TraceMsg(idx, "\tconfig = 0x%08x\n", config_id);
va_TraceMsg(idx, "\twidth = %d\n", picture_width);
va_TraceMsg(idx, "\theight = %d\n", picture_height);
va_TraceMsg(idx, "\tflag = 0x%08x\n", flag);
va_TraceMsg(idx, "\tnum_render_targets = %d\n", num_render_targets);
- for (i=0; i<num_render_targets; i++)
- va_TraceMsg(idx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]);
- va_TraceMsg(idx, "\tcontext = 0x%08x\n", *context);
- va_TraceMsg(idx, NULL);
-
- trace_context[idx].trace_context = *context;
-
+ if (render_targets) {
+ for (i=0; i<num_render_targets; i++)
+ va_TraceMsg(idx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]);
+ }
+ if (context) {
+ va_TraceMsg(idx, "\tcontext = 0x%08x\n", *context);
+ trace_context[idx].trace_context = *context;
+ } else
+ trace_context[idx].trace_context = VA_INVALID_ID;
+
trace_context[idx].trace_frame_no = 0;
trace_context[idx].trace_slice_no = 0;
@@ -638,7 +707,8 @@ void va_TraceCreateBuffer (
TRACE_FUNCNAME(idx);
va_TraceMsg(idx, "\tbuf_type=%s\n", buffer_type_to_string(type));
- va_TraceMsg(idx, "\tbuf_id=0x%x\n", *buf_id);
+ if (buf_id)
+ va_TraceMsg(idx, "\tbuf_id=0x%x\n", *buf_id);
va_TraceMsg(idx, "\tsize=%d\n", size);
va_TraceMsg(idx, "\tnum_elements=%d\n", num_elements);
@@ -699,6 +769,9 @@ void va_TraceMapBuffer (
TRACE_FUNCNAME(idx);
va_TraceMsg(idx, "\tbuf_id=0x%x\n", buf_id);
va_TraceMsg(idx, "\tbuf_type=%s\n", buffer_type_to_string(type));
+ if ((pbuf == NULL) || (*pbuf == NULL))
+ return;
+
buf_list = (VACodedBufferSegment *)(*pbuf);
while (buf_list != NULL) {
va_TraceMsg(idx, "\tCodedbuf[%d] =\n", i++);
@@ -2012,6 +2085,8 @@ static void va_TraceVAEncPictureParameterBufferJPEG(
void *data)
{
VAEncPictureParameterBufferJPEG *p = (VAEncPictureParameterBufferJPEG *)data;
+ int i;
+
DPY2INDEX(dpy);
va_TraceMsg(idx, "VAEncPictureParameterBufferJPEG\n");
@@ -2019,6 +2094,24 @@ static void va_TraceVAEncPictureParameterBufferJPEG(
va_TraceMsg(idx, "\tcoded_buf = %08x\n", p->coded_buf);
va_TraceMsg(idx, "\tpicture_width = %d\n", p->picture_width);
va_TraceMsg(idx, "\tpicture_height = %d\n", p->picture_height);
+ va_TraceMsg(idx, "\tpic_flags.bits.profile = %d\n", p->pic_flags.bits.profile);
+ va_TraceMsg(idx, "\tpic_flags.bits.progressive = %d\n", p->pic_flags.bits.profile);
+ va_TraceMsg(idx, "\tpic_flags.bits.huffman = %d\n", p->pic_flags.bits.huffman);
+ va_TraceMsg(idx, "\tpic_flags.bits.interleaved = %d\n", p->pic_flags.bits.interleaved);
+ va_TraceMsg(idx, "\tpic_flags.bits.differential = %d\n", p->pic_flags.bits.differential);
+ va_TraceMsg(idx, "\tsample_bit_depth = %d\n", p->sample_bit_depth);
+ va_TraceMsg(idx, "\tnum_scan = %d\n", p->num_scan);
+ va_TraceMsg(idx, "\tnum_components = %d\n", p->num_components);
+ va_TraceMsg(idx, "\tcomponent_id[] = ");
+ for (i=0; i<4; i++)
+ va_TraceMsg(idx, "%d\t", p->component_id[i]);
+ va_TraceMsg(idx, "\n");
+ va_TraceMsg(idx, "\tquantiser_table_selector[] = ");
+ for (i=0; i<4; i++)
+ va_TraceMsg(idx, "%d\t", p->quantiser_table_selector[i]);
+ va_TraceMsg(idx, "\n");
+ va_TraceMsg(idx, "\tquality = %d\n", p->picture_height);
+
va_TraceMsg(idx, NULL);
trace_context[idx].trace_codedbuf = p->coded_buf;
@@ -2065,6 +2158,37 @@ static void va_TraceVAEncQMatrixBufferJPEG(
return;
}
+
+static void va_TraceVAEncSliceParameterBufferJPEG(
+ VADisplay dpy,
+ VAContextID context,
+ VABufferID buffer,
+ VABufferType type,
+ unsigned int size,
+ unsigned int num_elements,
+ void *data)
+{
+ VAEncSliceParameterBufferJPEG *p = (VAEncSliceParameterBufferJPEG *)data;
+ int i;
+
+ DPY2INDEX(dpy);
+
+ va_TraceMsg(idx, "VAEncSliceParameterBufferJPEG\n");
+ va_TraceMsg(idx, "\trestart_interval = 0x%04x\n", p->restart_interval);
+ va_TraceMsg(idx, "\tnum_components = 0x%08x\n", p->num_components);
+ for (i=0; i<4; i++) {
+ va_TraceMsg(idx, "\tcomponents[%i] =\n ");
+ va_TraceMsg(idx, "\t\tcomponent_selector = %d\n", p->components[i].component_selector);
+ va_TraceMsg(idx, "\t\tdc_table_selector = %d\n", p->components[i].dc_table_selector);
+ va_TraceMsg(idx, "\t\tac_table_selector = %d\n", p->components[i].ac_table_selector);
+ }
+
+ va_TraceMsg(idx, NULL);
+
+ return;
+}
+
+
static void va_TraceH263Buf(
VADisplay dpy,
VAContextID context,
@@ -2149,9 +2273,11 @@ static void va_TraceJPEGBuf(
case VAProtectedSliceDataBufferType:
case VAEncCodedBufferType:
case VAEncSequenceParameterBufferType:
- case VAEncSliceParameterBufferType:
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
break;
+ case VAEncSliceParameterBufferType:
+ va_TraceVAEncPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
+ break;
case VAPictureParameterBufferType:
va_TraceVAPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf);
break;
@@ -2387,8 +2513,11 @@ void va_TraceRenderPicture(
va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
va_TraceMsg(idx, "\tnum_buffers = %d\n", num_buffers);
+ if (buffers == NULL)
+ return;
+
for (i = 0; i < num_buffers; i++) {
- unsigned char *pbuf;
+ unsigned char *pbuf = NULL;
unsigned int j;
/* get buffer type information */
@@ -2401,7 +2530,9 @@ void va_TraceRenderPicture(
va_TraceMsg(idx, "\t num_elements = %d\n", num_elements);
vaMapBuffer(dpy, buffers[i], (void **)&pbuf);
-
+ if (pbuf == NULL)
+ continue;
+
switch (trace_context[idx].trace_profile) {
case VAProfileMPEG2Simple:
case VAProfileMPEG2Main:
@@ -2514,6 +2645,23 @@ void va_TraceSyncSurface(
va_TraceMsg(idx, NULL);
}
+void va_TraceQuerySurfaceAttributes(
+ VADisplay dpy,
+ VAConfigID config,
+ VASurfaceAttrib *attrib_list,
+ unsigned int *num_attribs
+)
+{
+ DPY2INDEX(dpy);
+
+ TRACE_FUNCNAME(idx);
+ va_TraceMsg(idx, "\tconfig = 0x%08x\n", config);
+ va_TraceSurfaceAttributes(idx, attrib_list, num_attribs);
+
+ va_TraceMsg(idx, NULL);
+
+}
+
void va_TraceQuerySurfaceStatus(
VADisplay dpy,
@@ -2526,7 +2674,8 @@ void va_TraceQuerySurfaceStatus(
TRACE_FUNCNAME(idx);
va_TraceMsg(idx, "\trender_target = 0x%08x\n", render_target);
- va_TraceMsg(idx, "\tstatus = 0x%08x\n", *status);
+ if (status)
+ va_TraceMsg(idx, "\tstatus = 0x%08x\n", *status);
va_TraceMsg(idx, NULL);
}
@@ -2543,9 +2692,9 @@ void va_TraceQuerySurfaceError(
TRACE_FUNCNAME(idx);
va_TraceMsg(idx, "\tsurface = 0x%08x\n", surface);
va_TraceMsg(idx, "\terror_status = 0x%08x\n", error_status);
- if (error_status == VA_STATUS_ERROR_DECODING_ERROR) {
+ if (error_info && (error_status == VA_STATUS_ERROR_DECODING_ERROR)) {
VASurfaceDecodeMBErrors *p = *error_info;
- while (p->status != -1) {
+ while (p && (p->status != -1)) {
va_TraceMsg(idx, "\t\tstatus = %d\n", p->status);
va_TraceMsg(idx, "\t\tstart_mb = %d\n", p->start_mb);
va_TraceMsg(idx, "\t\tend_mb = %d\n", p->end_mb);
@@ -2578,8 +2727,11 @@ void va_TraceQueryDisplayAttributes (
DPY2INDEX(dpy);
- va_TraceMsg(idx, "\tnum_attributes = %d\n", *num_attributes);
+ if (attr_list == NULL || num_attributes == NULL)
+ return;
+ va_TraceMsg(idx, "\tnum_attributes = %d\n", *num_attributes);
+
for (i=0; i<*num_attributes; i++) {
va_TraceMsg(idx, "\tattr_list[%d] =\n");
va_TraceMsg(idx, "\t typ = 0x%08x\n", attr_list[i].type);
@@ -2603,6 +2755,9 @@ static void va_TraceDisplayAttributes (
DPY2INDEX(dpy);
va_TraceMsg(idx, "\tnum_attributes = %d\n", num_attributes);
+ if (attr_list == NULL)
+ return;
+
for (i=0; i<num_attributes; i++) {
va_TraceMsg(idx, "\tattr_list[%d] =\n");
va_TraceMsg(idx, "\t typ = 0x%08x\n", attr_list[i].type);