1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

avcodec/adpcmenc: Round up required buffer size

Otherwise the buffer might be too small. Fixes assert violations
when encoding mono audio with exactly one sample.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2022-09-15 17:42:25 +02:00
parent c9bd6ee5cb
commit bffc8f9af1

View File

@@ -614,7 +614,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_ALP || avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_ALP ||
avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM || avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM ||
avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_WS) avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_WS)
pkt_size = (frame->nb_samples * channels) / 2; pkt_size = (frame->nb_samples * channels + 1) / 2;
else else
pkt_size = avctx->block_align; pkt_size = avctx->block_align;
if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0) if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)