From 8fd1f69ad6bcdc4a3ce2bd243c7c15a4b60d6fa4 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 8 Nov 2012 14:21:57 +0000 Subject: [PATCH] ducatividdec: add a property for gathering debug info from the codec The actual info is codec dependent. This is not done unconditionally because it requires extra allocated memory, and potentially incurs a speed penalty. --- src/gstducatividdec.c | 41 ++++++++++++++++++++++++++++++++++++----- src/gstducatividdec.h | 2 ++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/gstducatividdec.c b/src/gstducatividdec.c index 7fe0847..d9c67e9 100644 --- a/src/gstducatividdec.c +++ b/src/gstducatividdec.c @@ -39,6 +39,7 @@ enum PROP_0, PROP_VERSION, PROP_MAX_REORDER_FRAMES, + PROP_CODEC_DEBUG_INFO }; /* helper functions */ @@ -148,7 +149,7 @@ codec_delete (GstDucatiVidDec * self) static gboolean codec_create (GstDucatiVidDec * self) { - gint err; + gint err, n; const gchar *codec_name; codec_delete (self); @@ -192,6 +193,16 @@ codec_create (GstDucatiVidDec * self) self->inBufs->numBufs = 1; self->inBufs->descs[0].buf = (XDAS_Int8 *) omap_bo_handle (self->input_bo); + /* Actual buffers will be set later, as they will be different for every + frame. We allow derived classes to add their own buffers, however, so + we initialize the number of outBufs here, counting the number of extra + buffers required, including "holes" in planes, which may not be filled + if not assigned. */ + self->outBufs->numBufs = 2; /* luma and chroma planes, always */ + for (n = 0; n < 3; n++) + if (self->params->metadataType[n] != IVIDEO_METADATAPLANE_NONE) + self->outBufs->numBufs = 2 + n + 1; + return TRUE; } @@ -260,7 +271,8 @@ codec_prepare_outbuf (GstDucatiVidDec * self, GstBuffer ** buf, return codec_prepare_outbuf (self, buf, FALSE); } - self->outBufs->numBufs = 2; + /* There are at least two buffers. Derived classes may add codec specific + buffers (eg, debug info) after these two if they want to. */ self->outBufs->descs[0].memType = XDM_MEMTYPE_BO; self->outBufs->descs[0].buf = (XDAS_Int8 *) omap_bo_handle (priv->bo); self->outBufs->descs[0].bufSize.bytes = priv->uv_offset; @@ -539,6 +551,7 @@ gboolean gst_ducati_viddec_codec_flush (GstDucatiVidDec * self, gboolean eos) { gint err = FALSE; + int prev_num_in_bufs, prev_num_out_bufs; GST_DEBUG_OBJECT (self, "flush: eos=%d", eos); @@ -575,6 +588,9 @@ gst_ducati_viddec_codec_flush (GstDucatiVidDec * self, gboolean eos) goto out; } + prev_num_in_bufs = self->inBufs->numBufs; + prev_num_out_bufs = self->outBufs->numBufs; + self->inBufs->descs[0].bufSize.bytes = 0; self->inBufs->numBufs = 0; self->inArgs->numBytes = 0; @@ -596,9 +612,9 @@ gst_ducati_viddec_codec_flush (GstDucatiVidDec * self, gboolean eos) self->dynParams->newFrameFlag = XDAS_TRUE; - /* Reset the push buffer and YUV buffers */ - self->inBufs->numBufs = 1; - self->outBufs->numBufs = 2; + /* Reset the push buffer and YUV buffers, plus any codec specific buffers */ + self->inBufs->numBufs = prev_num_in_bufs; + self->outBufs->numBufs = prev_num_out_bufs; /* on a flush, it is normal (and not an error) for the last _process() call * to return an error.. @@ -1366,6 +1382,9 @@ gst_ducati_viddec_get_property (GObject * obj, case PROP_MAX_REORDER_FRAMES: g_value_set_int (value, self->backlog_max_maxframes); break; + case PROP_CODEC_DEBUG_INFO: + g_value_set_boolean (value, self->codec_debug_info); + break; default:{ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -1383,6 +1402,9 @@ gst_ducati_viddec_set_property (GObject * obj, case PROP_MAX_REORDER_FRAMES: self->backlog_max_maxframes = g_value_get_int (value); break; + case PROP_CODEC_DEBUG_INFO: + self->codec_debug_info = g_value_get_boolean (value); + break; default:{ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -1457,6 +1479,13 @@ gst_ducati_viddec_class_init (GstDucatiVidDecClass * klass) "will cause extra latency.", 0, MAX_BACKLOG_FRAMES, MAX_BACKLOG_FRAMES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, PROP_CODEC_DEBUG_INFO, + g_param_spec_boolean ("codec-debug-info", + "Gather debug info from the codec", + "Gather and log relevant debug information from the codec. " + "What is gathered is typically codec specific", FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); } static void @@ -1523,6 +1552,8 @@ gst_ducati_viddec_init (GstDucatiVidDec * self, GstDucatiVidDecClass * klass) self->backlog_nframes = 0; self->backlog_max_maxframes = MAX_BACKLOG_FRAMES; + self->codec_debug_info = FALSE; + self->passed_in_bufs = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) gst_buffer_unref); } diff --git a/src/gstducatividdec.h b/src/gstducatividdec.h index 19a9b33..5998b0e 100644 --- a/src/gstducatividdec.h +++ b/src/gstducatividdec.h @@ -143,6 +143,8 @@ struct _GstDucatiVidDec gint backlog_maxframes; gint backlog_nframes; gint backlog_max_maxframes; + + gboolean codec_debug_info; }; struct _GstDucatiVidDecClass -- 2.39.2