From: James Almer Date: Sun, 6 Jun 2021 15:40:37 +0000 (-0300) Subject: a52: add some padding bytes to outbuf X-Git-Tag: v1.2.6~30 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=29f88436a7f3296d8ae78972d698a27196b37715;p=alsa-plugins.git a52: add some padding bytes to outbuf Since it's used as AVPacket payload, the API requires it to be padded. BugLink: https://github.com/alsa-project/alsa-plugins/pull/23 Signed-off-by: James Almer Signed-off-by: Jaroslav Kysela --- diff --git a/a52/pcm_a52.c b/a52/pcm_a52.c index b6a8f55..2ccc478 100644 --- a/a52/pcm_a52.c +++ b/a52/pcm_a52.c @@ -62,6 +62,12 @@ #define AV_CODEC_ID_AC3 CODEC_ID_AC3 #endif +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56, 56, 0) +#ifndef AV_INPUT_BUFFER_PADDING_SIZE +#define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE +#endif +#endif + #if LIBAVCODEC_VERSION_INT < 0x371c01 #define av_frame_alloc avcodec_alloc_frame #define av_frame_free avcodec_free_frame @@ -623,9 +629,10 @@ static int a52_prepare(snd_pcm_ioplug_t *io) return -EINVAL; rec->outbuf_size = rec->avctx->frame_size * 4; - rec->outbuf = malloc(rec->outbuf_size); + rec->outbuf = malloc(rec->outbuf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (! rec->outbuf) return -ENOMEM; + memset(rec->outbuf + rec->outbuf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); if (alloc_input_buffer(io)) return -ENOMEM;