Fixes ticket #10732
Unified · Split
| @@ -252,6 +252,16 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) · 251 unmodified lines | ||
| 252 | 252 | return 0; |
| 253 | 253 | } |
| 254 | 254 | |
| 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 | + | |
| 255 | 265 | /** |
| 256 | 266 | * Parse the 'sync info' and 'bit stream info' from the AC-3 bitstream. |
| 257 | 267 | * GetBitContext within AC3DecodeContext must point to |
| @@ -96,6 +96,7 @@ typedef struct AC3DecodeContext { · 95 unmodified lines | ||
| 96 | 96 | SHORTFLOAT *downmix_coeffs[2]; ///< stereo downmix coefficients |
| 97 | 97 | |
| 98 | 98 | // Start of flushable fields. |
| 99 | +// frame_type must be the flushable field, or the offset changed in ac3_decode_flush(). | |
| 99 | 100 | |
| 100 | 101 | ///@name Bit stream information |
| 101 | 102 | ///@{ |
| @@ -181,6 +181,7 @@ const FFCodec ff_ac3_fixed_decoder = { · 180 unmodified lines | ||
| 181 | 181 | .p.priv_class = &ac3_decoder_class, |
| 182 | 182 | .priv_data_size = sizeof (AC3DecodeContext), |
| 183 | 183 | .init = ac3_decode_init, |
| 184 | + .flush = ac3_decode_flush, | |
| 184 | 185 | .close = ac3_decode_end, |
| 185 | 186 | FF_CODEC_DECODE_CB(ac3_decode_frame), |
| 186 | 187 | .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | |
| @@ -70,6 +70,7 @@ const FFCodec ff_ac3_decoder = { · 69 unmodified lines | ||
| 70 | 70 | .p.id = AV_CODEC_ID_AC3, |
| 71 | 71 | .priv_data_size = sizeof (AC3DecodeContext), |
| 72 | 72 | .init = ac3_decode_init, |
| 73 | + .flush = ac3_decode_flush, | |
| 73 | 74 | .close = ac3_decode_end, |
| 74 | 75 | FF_CODEC_DECODE_CB(ac3_decode_frame), |
| 75 | 76 | .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | |
| @@ -88,6 +89,7 @@ const FFCodec ff_eac3_decoder = { · 12 unmodified lines | ||
| 88 | 89 | .p.id = AV_CODEC_ID_EAC3, |
| 89 | 90 | .priv_data_size = sizeof (AC3DecodeContext), |
| 90 | 91 | .init = ac3_decode_init, |
| 92 | + .flush = ac3_decode_flush, | |
| 91 | 93 | .close = ac3_decode_end, |
| 92 | 94 | FF_CODEC_DECODE_CB(ac3_decode_frame), |
| 93 | 95 | .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | |