From 1703bfa133ffebf0234a20199d54c27e0a5ffd0c Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 9 Oct 2023 21:16:15 +0200 Subject: [PATCH] avcodec/hcadec: implement proper .flush callback --- libavcodec/hcadec.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavcodec/hcadec.c b/libavcodec/hcadec.c index 4e30d553de..026b998341 100644 --- a/libavcodec/hcadec.c +++ b/libavcodec/hcadec.c @@ -65,7 +65,7 @@ typedef struct HCAContext { uint8_t stereo_band_count; uint8_t bands_per_hfr_group; - // Set during init() and freed on close(). Untouched on flush() + // Set during init() and freed on close(). Untouched on init_flush() av_tx_fn tx_fn; AVTXContext *tx_ctx; AVFloatDSPContext *fdsp; @@ -197,7 +197,7 @@ static inline unsigned ceil2(unsigned a, unsigned b) return (b > 0) ? (a / b + ((a % b) ? 1 : 0)) : 0; } -static av_cold void decode_flush(AVCodecContext *avctx) +static av_cold void init_flush(AVCodecContext *avctx) { HCAContext *c = avctx->priv_data; @@ -213,7 +213,7 @@ static int init_hca(AVCodecContext *avctx, const uint8_t *extradata, unsigned b, chunk; int version, ret; - decode_flush(avctx); + init_flush(avctx); if (extradata_size < 36) return AVERROR_INVALIDDATA; @@ -609,6 +609,14 @@ static av_cold int decode_close(AVCodecContext *avctx) return 0; } +static av_cold void decode_flush(AVCodecContext *avctx) +{ + HCAContext *c = avctx->priv_data; + + for (int ch = 0; ch < MAX_CHANNELS; ch++) + memset(c->ch[ch].imdct_prev, 0, sizeof(c->ch[ch].imdct_prev)); +} + const FFCodec ff_hca_decoder = { .p.name = "hca", CODEC_LONG_NAME("CRI HCA"),