[FFmpeg-cvslog] avcodec/ac3dec: add a flush callback for the ac3 and eac3 decoders
James Almer
git at videolan.org
Thu Feb 13 00:18:58 EET 2025
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Feb 12 19:04:30 2025 -0300| [045a8b15b19ec7f872fb01cfb986faeaa26cb8bb] | committer: James Almer
avcodec/ac3dec: add a flush callback for the ac3 and eac3 decoders
Fixes ticket #10732
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=045a8b15b19ec7f872fb01cfb986faeaa26cb8bb
---
libavcodec/ac3dec.c | 10 ++++++++++
libavcodec/ac3dec.h | 1 +
libavcodec/ac3dec_fixed.c | 1 +
libavcodec/ac3dec_float.c | 2 ++
4 files changed, 14 insertions(+)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index ff8cbfb0b4..2cf82abc19 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -252,6 +252,16 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
return 0;
}
+static av_cold void ac3_decode_flush(AVCodecContext *avctx)
+{
+ AC3DecodeContext *s = avctx->priv_data;
+
+ memset(&s->frame_type, 0, sizeof(*s) - offsetof(AC3DecodeContext, frame_type));
+
+ AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
+ av_lfg_init(&s->dith_state, 0);
+}
+
/**
* Parse the 'sync info' and 'bit stream info' from the AC-3 bitstream.
* GetBitContext within AC3DecodeContext must point to
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 0a6bba7c63..4042a99b80 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -96,6 +96,7 @@ typedef struct AC3DecodeContext {
SHORTFLOAT *downmix_coeffs[2]; ///< stereo downmix coefficients
// Start of flushable fields.
+// frame_type must be the flushable field, or the offset changed in ac3_decode_flush().
///@name Bit stream information
///@{
diff --git a/libavcodec/ac3dec_fixed.c b/libavcodec/ac3dec_fixed.c
index e0db9b2260..e284140e74 100644
--- a/libavcodec/ac3dec_fixed.c
+++ b/libavcodec/ac3dec_fixed.c
@@ -181,6 +181,7 @@ const FFCodec ff_ac3_fixed_decoder = {
.p.priv_class = &ac3_decoder_class,
.priv_data_size = sizeof (AC3DecodeContext),
.init = ac3_decode_init,
+ .flush = ac3_decode_flush,
.close = ac3_decode_end,
FF_CODEC_DECODE_CB(ac3_decode_frame),
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c
index 53d9d472c4..31f5590729 100644
--- a/libavcodec/ac3dec_float.c
+++ b/libavcodec/ac3dec_float.c
@@ -70,6 +70,7 @@ const FFCodec ff_ac3_decoder = {
.p.id = AV_CODEC_ID_AC3,
.priv_data_size = sizeof (AC3DecodeContext),
.init = ac3_decode_init,
+ .flush = ac3_decode_flush,
.close = ac3_decode_end,
FF_CODEC_DECODE_CB(ac3_decode_frame),
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
@@ -88,6 +89,7 @@ const FFCodec ff_eac3_decoder = {
.p.id = AV_CODEC_ID_EAC3,
.priv_data_size = sizeof (AC3DecodeContext),
.init = ac3_decode_init,
+ .flush = ac3_decode_flush,
.close = ac3_decode_end,
FF_CODEC_DECODE_CB(ac3_decode_frame),
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
More information about the ffmpeg-cvslog
mailing list