diff options
author | David Schleef <ds@schleef.org> | 2010-09-18 19:21:47 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2010-09-18 19:27:07 -0700 |
commit | 62a93835278d5b4167b54133207276d896462e4a (patch) | |
tree | 4d0257906d0c987137871cd05c0a31750bad2410 /gst-libs | |
parent | dbbf1182dcb41f057eb5e26355df52ec87811c0e (diff) | |
download | gstreamer-plugins-bad-62a93835278d5b4167b54133207276d896462e4a.tar.gz |
basevideodecoder: add capture pattern handling
Move typical scan_for_sync() usage into base class, which just
calls gst_adapter_masked_scan_uint32().
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/video/gstbasevideodecoder.c | 52 | ||||
-rw-r--r-- | gst-libs/gst/video/gstbasevideodecoder.h | 5 |
2 files changed, 38 insertions, 19 deletions
diff --git a/gst-libs/gst/video/gstbasevideodecoder.c b/gst-libs/gst/video/gstbasevideodecoder.c index 198b3a886..42e7b11bc 100644 --- a/gst-libs/gst/video/gstbasevideodecoder.c +++ b/gst-libs/gst/video/gstbasevideodecoder.c @@ -862,32 +862,36 @@ gst_base_video_decoder_chain (GstPad * pad, GstBuffer * buf) GST_DEBUG ("no sync, scanning"); n = gst_adapter_available (base_video_decoder->input_adapter); - m = klass->scan_for_sync (base_video_decoder, FALSE, 0, n); + if (klass->capture_mask != 0) { + m = gst_adapter_masked_scan_uint32 (base_video_decoder->input_adapter, + klass->capture_mask, klass->capture_pattern, 0, n - 3); + } else if (klass->scan_for_sync) { + m = klass->scan_for_sync (base_video_decoder, FALSE, 0, n); + } else { + m = 0; + } if (m == -1) { + GST_ERROR ("scan returned no sync"); + gst_adapter_flush (base_video_decoder->input_adapter, n - 3); + gst_object_unref (base_video_decoder); return GST_FLOW_OK; - } - - if (m < 0) { - g_warning ("subclass returned negative scan %d", m); - } - - if (m >= n) { - GST_ERROR ("subclass scanned past end %d >= %d", m, n); - } + } else { + if (m > 0) { + if (m >= n) { + GST_ERROR ("subclass scanned past end %d >= %d", m, n); + } - gst_adapter_flush (base_video_decoder->input_adapter, m); + gst_adapter_flush (base_video_decoder->input_adapter, m); - if (m < n) { - GST_DEBUG ("found possible sync after %d bytes (of %d)", m, n); + if (m < n) { + GST_DEBUG ("found possible sync after %d bytes (of %d)", m, n); - /* this is only "maybe" sync */ - base_video_decoder->have_sync = TRUE; - } + /* this is only "maybe" sync */ + base_video_decoder->have_sync = TRUE; + } + } - if (!base_video_decoder->have_sync) { - gst_object_unref (base_video_decoder); - return GST_FLOW_OK; } } @@ -1496,3 +1500,13 @@ gst_base_video_decoder_get_max_decode_time (GstBaseVideoDecoder * return deadline; } + +void +gst_base_video_decoder_class_set_capture_pattern (GstBaseVideoDecoderClass * + base_video_decoder_class, guint32 mask, guint32 pattern) +{ + g_return_if_fail (((~mask) & pattern) == 0); + + base_video_decoder_class->capture_mask = mask; + base_video_decoder_class->capture_pattern = pattern; +} diff --git a/gst-libs/gst/video/gstbasevideodecoder.h b/gst-libs/gst/video/gstbasevideodecoder.h index 6bc606d9c..f996a587e 100644 --- a/gst-libs/gst/video/gstbasevideodecoder.h +++ b/gst-libs/gst/video/gstbasevideodecoder.h @@ -137,10 +137,15 @@ struct _GstBaseVideoDecoderClass GstFlowReturn (*shape_output) (GstBaseVideoDecoder *coder, GstVideoFrame *frame); GstCaps *(*get_caps) (GstBaseVideoDecoder *coder); + guint32 capture_mask; + guint32 capture_pattern; }; GType gst_base_video_decoder_get_type (void); +void gst_base_video_decoder_class_set_capture_pattern (GstBaseVideoDecoderClass *klass, + guint32 mask, guint32 pattern); + int gst_base_video_decoder_get_width (GstBaseVideoDecoder *coder); int gst_base_video_decoder_get_height (GstBaseVideoDecoder *coder); |