]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
a52: add some padding bytes to outbuf
authorJames Almer <jamrial@gmail.com>
Sun, 6 Jun 2021 15:40:37 +0000 (12:40 -0300)
committerJaroslav Kysela <perex@perex.cz>
Wed, 16 Jun 2021 06:53:24 +0000 (08:53 +0200)
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 <jamrial@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
a52/pcm_a52.c

index b6a8f5531c4a2c361beb6adfabc6278cacdbfe73..2ccc478d10c4740dd3516c0759ebfcf7d1c8221f 100644 (file)
 #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;