diff mbox series

[FFmpeg-devel,02/10] avcodec/binkaudio: Properly flush the decoder

Message ID AM7PR03MB6660F93258C0B92BBD3C77318FB59@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,01/10] avcodec/binkaudio: Remove AV_CODEC_CAP_DELAY
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 11, 2021, 3:36 p.m. UTC
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@outlook.com>
---
 libavcodec/binkaudio.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Paul B Mahol Oct. 11, 2021, 4:02 p.m. UTC | #1
lgtm
diff mbox series

Patch

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,