From ad6162e99b8b06d11a783929720c7e94c113b57b Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Mon, 2 Jul 2018 16:48:11 -0800 Subject: [PATCH] msdkdec: Fix advanced profile vc1 decode when codec_data presents The gst-msdk decoders only support packetized formats for all codecs except VC1. For VC1, it supports codec_data for advanced profiles and this codec_data wan't submitting to MSDK's DecodeHeader APIs. Make sure the subclass deocders correctly configured so that the codec_data buffers are in place in the internal adapter for MediaSDK's DecoderHeader usage. --- sys/msdk/gstmsdkdec.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c index c78280d898..a9a82c4631 100644 --- a/sys/msdk/gstmsdkdec.c +++ b/sys/msdk/gstmsdkdec.c @@ -842,6 +842,30 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame) gsize data_size; gboolean hard_reset = FALSE; + /* configure the subclss inorder to fill the CodecID field of mfxVideoParam + * and also to load the PluginID for some of the codecs which is mandatory + * to invoke the MFXVideoDECODE_DecodeHeader API. + * + * For non packetized formats (currently only vc1), there + * could be headers received as codec_data which are not available + * instream and in that case subclass implementation will + * push it to the internal adapter. We invoke the subclass configure + * well early to make sure the codec_data received has been correctly + * pushed to the adapter by the subclasses before doing + * the DecodeHeader() later on + */ + if (!thiz->initialized || thiz->do_renego) { + /* Clear the internal adapter in renegotiation for non-packetized + * formats */ + if (!thiz->is_packetized) + gst_adapter_clear (thiz->adapter); + + if (!klass->configure || !klass->configure (thiz)) { + flow = GST_FLOW_OK; + goto error; + } + } + if (!gst_buffer_map (frame->input_buffer, &map_info, GST_MAP_READ)) return GST_FLOW_ERROR; @@ -871,14 +895,6 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame) if (!thiz->initialized || thiz->do_renego) { - /* configure the subclss inorder to fill the CodecID field of mfxVideoParam - * and also to load the PluginID for some of the codecs which is mandatory - * to invoke the MFXVideoDECODE_DecodeHeader API */ - if (!klass->configure || !klass->configure (thiz)) { - flow = GST_FLOW_OK; - goto error; - } - /* gstreamer caps will not bring all the necessary parameters * required for optimal decode configuration. For eg: the required numbers * of surfaces to be allocated can be calculated based on H264 SEI header