diff options
author | Alessandro Decina <alessandro.decina@collabora.co.uk> | 2011-09-26 18:08:31 +0200 |
---|---|---|
committer | Alessandro Decina <alessandro.decina@collabora.co.uk> | 2011-09-26 18:10:42 +0200 |
commit | 1f8309add820c88538235928576715d9265e4642 (patch) | |
tree | 5acc46eaf9a12bcedd0aa4a57ea3e618beb8248f | |
parent | 715be6037e33571097037368fb3e9a143727962c (diff) |
ducativc1dec: add debugging code to optionally forge frame headers
Add code to inject frame headers if params->frameLayerDataPresentFlag is set to
TRUE. Disabled by default, useful for debugging.
-rw-r--r-- | src/gstducativc1dec.c | 58 | ||||
-rw-r--r-- | src/gstducativc1dec.h | 1 |
2 files changed, 57 insertions, 2 deletions
diff --git a/src/gstducativc1dec.c b/src/gstducativc1dec.c index b2d5a84..0c3b87d 100644 --- a/src/gstducativc1dec.c +++ b/src/gstducativc1dec.c @@ -136,6 +136,12 @@ static GstBuffer * gst_ducati_vc1dec_push_input (GstDucatiVidDec * vdec, GstBuffer * buf) { GstDucatiVC1Dec *self = GST_DUCATIVC1DEC (vdec); + IVC1VDEC_Params *params = (IVC1VDEC_Params *) vdec->params; + guint32 val; + + /* need a base ts for frame layer timestamps */ + if (self->first_ts == GST_CLOCK_TIME_NONE) + self->first_ts = GST_BUFFER_TIMESTAMP (buf); if (G_UNLIKELY (vdec->first_in_buffer) && vdec->codec_data) { if (self->level == 4) { @@ -145,8 +151,6 @@ gst_ducati_vc1dec_push_input (GstDucatiVidDec * vdec, GstBuffer * buf) push_input (vdec, GST_BUFFER_DATA (vdec->codec_data) + 1, GST_BUFFER_SIZE (vdec->codec_data) - 1); } else { - guint32 val; - /* for VC-1 Simple and Main Profile, build the Table 265 Sequence * Layer Data Structure header (refer to VC-1 spec, Annex L): */ @@ -186,6 +190,17 @@ gst_ducati_vc1dec_push_input (GstDucatiVidDec * vdec, GstBuffer * buf) static guint8 sc[] = { 0x00, 0x00, 0x01, 0x0d }; /* start code */ push_input (vdec, sc, sizeof (sc)); } + + if (params->frameLayerDataPresentFlag) { + val = GST_BUFFER_SIZE (buf); + if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT)) + val |= 0x80 << 24; + else + val |= 0x00 << 24; + push_input (vdec, (guint8 *) & val, 4); + val = GST_TIME_AS_MSECONDS (GST_BUFFER_TIMESTAMP (buf) - self->first_ts); + push_input (vdec, (guint8 *) & val, 4); + } push_input (vdec, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); gst_buffer_unref (buf); @@ -193,6 +208,38 @@ gst_ducati_vc1dec_push_input (GstDucatiVidDec * vdec, GstBuffer * buf) return NULL; } +/* GstElement vmethod implementations */ + +static GstStateChangeReturn +gst_ducati_vc1dec_change_state (GstElement * element, + GstStateChange transition) +{ + GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; + GstDucatiVC1Dec *self = GST_DUCATIVC1DEC (element); + + GST_INFO_OBJECT (self, "begin: changing state %s -> %s", + gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), + gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); + + ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + + if (ret == GST_STATE_CHANGE_FAILURE) + goto leave; + + switch (transition) { + case GST_STATE_CHANGE_PAUSED_TO_READY: + self->level = -1; + self->first_ts = GST_CLOCK_TIME_NONE; + break; + default: + break; + } + +leave: + GST_LOG_OBJECT (self, "end"); + + return ret; +} /* GObject vmethod implementations */ @@ -215,6 +262,11 @@ static void gst_ducati_vc1dec_class_init (GstDucatiVC1DecClass * klass) { GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass); + GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); + + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_ducati_vc1dec_change_state); + bclass->codec_name = "ivahd_vc1vdec"; bclass->parse_caps = GST_DEBUG_FUNCPTR (gst_ducati_vc1dec_parse_caps); @@ -230,4 +282,6 @@ static void gst_ducati_vc1dec_init (GstDucatiVC1Dec * self, GstDucatiVC1DecClass * gclass) { + self->level = -1; + self->first_ts = GST_CLOCK_TIME_NONE; } diff --git a/src/gstducativc1dec.h b/src/gstducativc1dec.h index b5729c6..36ad8bb 100644 --- a/src/gstducativc1dec.h +++ b/src/gstducativc1dec.h @@ -40,6 +40,7 @@ struct _GstDucatiVC1Dec { GstDucatiVidDec parent; + GstClockTime first_ts; gint level; }; |