From 571aad39808af0d8be8d3527903d70a8679a7381 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 18 Sep 2021 22:51:53 +0900 Subject: [PATCH] codecs: {vp8,vp9}decoder: Drain on new_sequence() Decoder should drain queued frame (if any) and empty DPB before starting new sequence. Part-of: --- .../gst-plugins-bad/gst-libs/gst/codecs/gstvp8decoder.c | 8 ++++++++ .../gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp8decoder.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp8decoder.c index d99bd5e855..9f6c8978b3 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp8decoder.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp8decoder.c @@ -168,6 +168,14 @@ gst_vp8_decoder_check_codec_change (GstVp8Decoder * self, if (changed || !priv->had_sequence) { GstVp8DecoderClass *klass = GST_VP8_DECODER_GET_CLASS (self); + /* Drain before new sequence */ + ret = gst_vp8_decoder_drain_internal (self, FALSE); + if (ret != GST_FLOW_OK) { + GST_WARNING_OBJECT (self, "Failed to drain pending frames, returned %s", + gst_flow_get_name (ret)); + return ret; + } + priv->had_sequence = TRUE; if (klass->get_preferred_output_delay) 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 d8db0c1602..5fca5fabb7 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c @@ -193,6 +193,14 @@ gst_vp9_decoder_check_codec_change (GstVp9Decoder * self, if (changed || !priv->had_sequence) { GstVp9DecoderClass *klass = GST_VP9_DECODER_GET_CLASS (self); + /* Drain before new sequence */ + ret = gst_vp9_decoder_drain_internal (self, FALSE); + if (ret != GST_FLOW_OK) { + GST_WARNING_OBJECT (self, "Failed to drain pending frames, returned %s", + gst_flow_get_name (ret)); + return ret; + } + priv->had_sequence = TRUE; if (klass->get_preferred_output_delay) {