1
0
Fork 0

avcodec/hcadec: implement proper .flush callback

This commit is contained in:
Paul B Mahol 2023-10-09 21:16:15 +02:00
parent 8b6ee74d50
commit 1703bfa133
1 changed files with 11 additions and 3 deletions

View File

@ -65,7 +65,7 @@ typedef struct HCAContext {
uint8_t stereo_band_count; uint8_t stereo_band_count;
uint8_t bands_per_hfr_group; 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; av_tx_fn tx_fn;
AVTXContext *tx_ctx; AVTXContext *tx_ctx;
AVFloatDSPContext *fdsp; AVFloatDSPContext *fdsp;
@ -197,7 +197,7 @@ static inline unsigned ceil2(unsigned a, unsigned b)
return (b > 0) ? (a / b + ((a % b) ? 1 : 0)) : 0; 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; HCAContext *c = avctx->priv_data;
@ -213,7 +213,7 @@ static int init_hca(AVCodecContext *avctx, const uint8_t *extradata,
unsigned b, chunk; unsigned b, chunk;
int version, ret; int version, ret;
decode_flush(avctx); init_flush(avctx);
if (extradata_size < 36) if (extradata_size < 36)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -609,6 +609,14 @@ static av_cold int decode_close(AVCodecContext *avctx)
return 0; 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 = { const FFCodec ff_hca_decoder = {
.p.name = "hca", .p.name = "hca",
CODEC_LONG_NAME("CRI HCA"), CODEC_LONG_NAME("CRI HCA"),