From 29f88436a7f3296d8ae78972d698a27196b37715 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sun, 6 Jun 2021 12:40:37 -0300 Subject: [PATCH] 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 --- a52/pcm_a52.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; -- 2.47.1