diff options
author | Sreerenj Balachandran <sreerenj.balachandran@intel.com> | 2015-08-28 23:43:47 +0300 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2015-09-09 17:17:07 +0200 |
commit | 8b7b163ab11e2c69c4d345cb6b0aa88d57ef8090 (patch) | |
tree | 2482f9698a69c7fe1ae7c598c747d7d3a8e8b2d1 | |
parent | eade6bb5e7f8fedfd59421ba153fca254da603ce (diff) |
vaapidecode: Always keep a copy of input codec state
Currently we are sharing the input GstVideoCodecState with
GstVaapiDecoder(gst-libs/gst/vaapi) by just doing ref and unref for
each caps change. This is troublesome in many cases, for eg: if
resoultion changes with in a singe stream. Because, when ever there
is a resolution change, GstVideoDecoder will first change the Codec_state->caps
fields with new resolution, but since we are using the same codecstate (ref)
in gstvaapidecode.c, the caps check for input caps change will always fail.
https://bugzilla.gnome.org/show_bug.cgi?id=753914
-rw-r--r-- | gst/vaapi/gstvaapidecode.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 582368ec..b3974898 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -140,6 +140,37 @@ gst_vaapi_decoder_state_changed (GstVaapiDecoder * decoder, return; } +static GstVideoCodecState * +copy_video_codec_state (const GstVideoCodecState * in_state) +{ + GstVideoCodecState *state; + GstStructure *structure; + const GValue *codec_data; + + g_return_val_if_fail (in_state != NULL, NULL); + + state = g_slice_new0 (GstVideoCodecState); + state->ref_count = 1; + gst_video_info_init (&state->info); + if (G_UNLIKELY (!gst_video_info_from_caps (&state->info, in_state->caps))) + goto fail; + state->caps = gst_caps_copy (in_state->caps); + + structure = gst_caps_get_structure (state->caps, 0); + + codec_data = gst_structure_get_value (structure, "codec_data"); + if (codec_data && G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) + state->codec_data = GST_BUFFER (g_value_dup_boxed (codec_data)); + + return state; + +fail: + { + g_slice_free (GstVideoCodecState, state); + return NULL; + } +} + static gboolean gst_vaapi_decode_input_state_replace (GstVaapiDecode * decode, const GstVideoCodecState * new_state) @@ -154,8 +185,7 @@ gst_vaapi_decode_input_state_replace (GstVaapiDecode * decode, } if (new_state) - decode->input_state = gst_video_codec_state_ref - ((GstVideoCodecState *) new_state); + decode->input_state = copy_video_codec_state (new_state); else decode->input_state = NULL; |