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
1 changed files with 1 additions and 1 deletions

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_APM ||
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
pkt_size = avctx->block_align;
if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)