History

avcodec/ac3dec: add a flush callback for the ac3 and eac3 decoders

Fixes ticket #10732

James Almer committed 1 year ago

Commit 045a8b11 parent a9e85864 files · +14 −0Browse files

Unified · Split

4 files
  1. libavcodec/ac3dec.c +10 −0
  2. libavcodec/ac3dec.h +1 −0
  3. libavcodec/ac3dec_fixed.c +1 −0
  4. libavcodec/ac3dec_float.c +2 −0
libavcodec/ac3dec.c+10−0
@@ -252,6 +252,16 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) · 251 unmodified lines
252252 return 0;
253253 }
254254
255+static av_cold void ac3_decode_flush(AVCodecContext *avctx)
256+{
257+ AC3DecodeContext *s = avctx->priv_data;
258+
259+ memset(&s->frame_type, 0, sizeof(*s) - offsetof(AC3DecodeContext, frame_type));
260+
261+ AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
262+ av_lfg_init(&s->dith_state, 0);
263+}
264+
255265 /**
256266 * Parse the 'sync info' and 'bit stream info' from the AC-3 bitstream.
257267 * GetBitContext within AC3DecodeContext must point to
libavcodec/ac3dec.h+1−0
@@ -96,6 +96,7 @@ typedef struct AC3DecodeContext { · 95 unmodified lines
9696 SHORTFLOAT *downmix_coeffs[2]; ///< stereo downmix coefficients
9797
9898 // Start of flushable fields.
99+// frame_type must be the flushable field, or the offset changed in ac3_decode_flush().
99100
100101 ///@name Bit stream information
101102 ///@{
libavcodec/ac3dec_fixed.c+1−0
@@ -181,6 +181,7 @@ const FFCodec ff_ac3_fixed_decoder = { · 180 unmodified lines
181181 .p.priv_class = &ac3_decoder_class,
182182 .priv_data_size = sizeof (AC3DecodeContext),
183183 .init = ac3_decode_init,
184+ .flush = ac3_decode_flush,
184185 .close = ac3_decode_end,
185186 FF_CODEC_DECODE_CB(ac3_decode_frame),
186187 .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
libavcodec/ac3dec_float.c+2−0
@@ -70,6 +70,7 @@ const FFCodec ff_ac3_decoder = { · 69 unmodified lines
7070 .p.id = AV_CODEC_ID_AC3,
7171 .priv_data_size = sizeof (AC3DecodeContext),
7272 .init = ac3_decode_init,
73+ .flush = ac3_decode_flush,
7374 .close = ac3_decode_end,
7475 FF_CODEC_DECODE_CB(ac3_decode_frame),
7576 .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
@@ -88,6 +89,7 @@ const FFCodec ff_eac3_decoder = { · 12 unmodified lines
8889 .p.id = AV_CODEC_ID_EAC3,
8990 .priv_data_size = sizeof (AC3DecodeContext),
9091 .init = ac3_decode_init,
92+ .flush = ac3_decode_flush,
9193 .close = ac3_decode_end,
9294 FF_CODEC_DECODE_CB(ac3_decode_frame),
9395 .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t