From 0f171b208657ffac0d060e9ae140a32b3738aafd Mon Sep 17 00:00:00 2001 From: Benjamin Gaignard Date: Fri, 20 Sep 2024 10:30:01 +0200 Subject: [PATCH] codecs: vp9 decoder: Drain output buffers before resolution change We must drain the pending output picture so that subclass can renegotiate the caps. Not doing so while still renegotiating would mean that the subclass would have to do an allocation query before pushing the caps. Pushing the caps now without this would also not work since these caps won't match the pending buffers format. Part-of: --- .../gst-libs/gst/codecs/gstvp9decoder.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c index e50115078f..88983f03f6 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c @@ -500,6 +500,24 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder, picture->data = map.data; picture->size = map.size; + /* If changing of resolution drain all output buffers. + * This will allow subclass to renegotiate immediatly. */ + if (priv->support_non_kf_change + && gst_vp9_decoder_is_format_change (self, &frame_hdr)) { + gst_vp9_decoder_drain_output_queue (self, 0, &ret); + if (ret != GST_FLOW_OK) { + GST_WARNING_OBJECT (self, "Failed to drain pending frames, returned %s", + gst_flow_get_name (ret)); + goto unmap_and_error; + } + + priv->frame_width = frame_hdr.width; + priv->frame_height = frame_hdr.height; + priv->render_width = frame_hdr.render_width; + priv->render_height = frame_hdr.render_height; + priv->profile = frame_hdr.profile; + } + if (klass->new_picture) { ret = klass->new_picture (self, frame, picture); if (ret != GST_FLOW_OK) {