[FFmpeg-cvslog] avcodec/binkaudio: Properly flush the decoder

Andreas Rheinhardt git at videolan.org
Thu Oct 28 11:31:20 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Oct 11 17:36:41 2021 +0200| [e84c83ef982042b4441b517a8f23d8427f2b5494] | committer: Paul B Mahol

avcodec/binkaudio: Properly flush the decoder

The packets delivered to this decoder are often decoded to more than
one frame and if the internal buffer packet is not unreferenced,
the decoder will still output frames derived from the old packet (from
before the flush).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e84c83ef982042b4441b517a8f23d8427f2b5494
---

 libavcodec/binkaudio.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 5915ba6ffb..59ecab25c6 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -337,6 +337,14 @@ fail:
     return ret;
 }
 
+static void decode_flush(AVCodecContext *avctx)
+{
+    BinkAudioContext *const s = avctx->priv_data;
+
+    av_packet_unref(s->pkt);
+    s->first = 1;
+}
+
 const AVCodec ff_binkaudio_rdft_decoder = {
     .name           = "binkaudio_rdft",
     .long_name      = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)"),
@@ -344,6 +352,7 @@ const AVCodec ff_binkaudio_rdft_decoder = {
     .id             = AV_CODEC_ID_BINKAUDIO_RDFT,
     .priv_data_size = sizeof(BinkAudioContext),
     .init           = decode_init,
+    .flush          = decode_flush,
     .close          = decode_end,
     .receive_frame  = binkaudio_receive_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
@@ -357,6 +366,7 @@ const AVCodec ff_binkaudio_dct_decoder = {
     .id             = AV_CODEC_ID_BINKAUDIO_DCT,
     .priv_data_size = sizeof(BinkAudioContext),
     .init           = decode_init,
+    .flush          = decode_flush,
     .close          = decode_end,
     .receive_frame  = binkaudio_receive_frame,
     .capabilities   = AV_CODEC_CAP_DR1,



More information about the ffmpeg-cvslog mailing list