msdkdec: Fix decoding cases with resolution change (VP9)

The resolution of VP9 video can be changed without keyframe.
The change detected by MSDK/VPL should be negotiated with downstream.
Only the situation can be fixed here if the changed resolution is less than or equal to the initial surface resolution.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4450>
This commit is contained in:
Ma, Mingyang 2023-04-18 15:57:45 +08:00 committed by GStreamer Marge Bot
parent 10d2e8c545
commit a2e83a019a

View file

@ -917,6 +917,25 @@ gst_msdkdec_finish_task (GstMsdkDec * thiz, MsdkDecTask * task)
GST_DEBUG_OBJECT (thiz, "Decoded MFX TimeStamp: %" G_GUINT64_FORMAT,
(guint64) surface->surface->Data.TimeStamp);
pts = surface->surface->Data.TimeStamp;
if (thiz->param.mfx.CodecId == MFX_CODEC_VP9) {
GstVideoCodecState *output_state =
gst_video_decoder_get_output_state (GST_VIDEO_DECODER (thiz));
/* detect whether the resolution change and negotiate with downstream if so */
if ((surface->surface->Info.CropW && surface->surface->Info.CropH)
&& ((output_state->info.width != surface->surface->Info.CropW)
|| (output_state->info.height != surface->surface->Info.CropH))) {
output_state->info.width = surface->surface->Info.CropW;
output_state->info.height = surface->surface->Info.CropH;
output_state->caps = gst_video_info_to_caps (&output_state->info);
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (thiz))) {
GST_ERROR_OBJECT (thiz, "Failed to negotiate");
gst_video_codec_state_unref (output_state);
return GST_FLOW_NOT_NEGOTIATED;
}
}
gst_video_codec_state_unref (output_state);
}
}
if (G_LIKELY (task->sync_point || (surface && task->decode_only))) {