summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-09-11 17:03:33 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-09-11 17:08:47 +0200
commit5549dbc3c058e7072a480db6d4efb17c595c8580 (patch)
treef50b0ec85add5125a50ca5e33a113cc7ffdbc86b
parent2b71db30598634dc17c3d45689a0f63528b3767c (diff)
vaapidecode: don't reset decoder if codec type is the same.
Reset, i.e. destroy then create, the decoder in _setcaps() handler only if the underlying codec type actually changed. This makes it possible to be more tolerant with certain MPEG-2 streams that get parsed to form caps that are compatible with the previous state but minor changes to "codec-data".
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder.c16
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder.h3
-rw-r--r--gst/vaapi/gstvaapidecode.c14
3 files changed, 29 insertions, 4 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.c b/gst-libs/gst/vaapi/gstvaapidecoder.c
index c63bb149..d2ee86cb 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder.c
@@ -362,6 +362,22 @@ gst_vaapi_decoder_init(GstVaapiDecoder *decoder)
}
/**
+ * gst_vaapi_decoder_get_codec:
+ * @decoder: a #GstVaapiDecoder
+ *
+ * Retrieves the @decoder codec type.
+ *
+ * Return value: the #GstVaapiCodec type for @decoder
+ */
+GstVaapiCodec
+gst_vaapi_decoder_get_codec(GstVaapiDecoder *decoder)
+{
+ g_return_val_if_fail(GST_VAAPI_IS_DECODER(decoder), (GstVaapiCodec)0);
+
+ return decoder->priv->codec;
+}
+
+/**
* gst_vaapi_decoder_get_caps:
* @decoder: a #GstVaapiDecoder
*
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.h b/gst-libs/gst/vaapi/gstvaapidecoder.h
index deeb6926..b5a397bd 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder.h
+++ b/gst-libs/gst/vaapi/gstvaapidecoder.h
@@ -116,6 +116,9 @@ struct _GstVaapiDecoderClass {
GType
gst_vaapi_decoder_get_type(void) G_GNUC_CONST;
+GstVaapiCodec
+gst_vaapi_decoder_get_codec(GstVaapiDecoder *decoder);
+
GstCaps *
gst_vaapi_decoder_get_caps(GstVaapiDecoder *decoder);
diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c
index d79eaa1c..1cc94c77 100644
--- a/gst/vaapi/gstvaapidecode.c
+++ b/gst/vaapi/gstvaapidecode.c
@@ -393,10 +393,16 @@ gst_vaapidecode_destroy(GstVaapiDecode *decode)
static gboolean
gst_vaapidecode_reset(GstVaapiDecode *decode, GstCaps *caps)
{
- if (decode->decoder &&
- decode->decoder_caps &&
- gst_caps_is_always_compatible(caps, decode->decoder_caps))
- return TRUE;
+ GstVaapiCodec codec;
+
+ /* Only reset decoder if codec type changed */
+ if (decode->decoder && decode->decoder_caps) {
+ if (gst_caps_is_always_compatible(caps, decode->decoder_caps))
+ return TRUE;
+ codec = gst_vaapi_codec_from_caps(caps);
+ if (codec == gst_vaapi_decoder_get_codec(decode->decoder))
+ return TRUE;
+ }
gst_vaapidecode_destroy(decode);
return gst_vaapidecode_create(decode, caps);