Also zero previous frame samples at allocation.
---
libavcodec/twinvq.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index ab22f64..cc67ca4 100644
--- a/libavcodec/twinvq.c
+++ b/libavcodec/twinvq.c
@@ -878,6 +878,16 @@ static int twin_decode_frame(AVCodecContext * avctx, void
*data,
return buf_size;
}
+static void twin_decode_flush(AVCodecContext *avctx)
+{
+ TwinContext *tctx = avctx->priv_data;
+
+ memset(tctx->prev_frame, 0,
+ 2 * tctx->mtab->size * avctx->channels * sizeof(*tctx->prev_frame));
+
+ tctx->last_block_pos[0] = tctx->last_block_pos[1] = 0;
+}
+
/**
* Init IMDCT and windowing tables
*/
@@ -906,9 +916,9 @@ static av_cold int init_mdct_win(TwinContext *tctx)
FF_ALLOC_OR_GOTO(tctx->avctx, tctx->curr_frame,
2 * mtab->size * channels * sizeof(*tctx->curr_frame),
alloc_fail);
- FF_ALLOC_OR_GOTO(tctx->avctx, tctx->prev_frame,
- 2 * mtab->size * channels * sizeof(*tctx->prev_frame),
- alloc_fail);
+ FF_ALLOCZ_OR_GOTO(tctx->avctx, tctx->prev_frame,
+ 2 * mtab->size * channels * sizeof(*tctx->prev_frame),
+ alloc_fail);
for (i = 0; i < 3; i++) {
int m = 4*mtab->size/mtab->fmode[i].sub;
@@ -1182,6 +1192,7 @@ AVCodec ff_twinvq_decoder = {
.init = twin_decode_init,
.close = twin_decode_close,
.decode = twin_decode_frame,
+ .flush = twin_decode_flush,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),
};
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel