Commit bffc8f9a authored by Andreas Rheinhardt's avatar Andreas Rheinhardt

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: 's avatarPaul B Mahol <onemda@gmail.com>
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
parent c9bd6ee5
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment