diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 66c672a519d38c1e7da401a1ddc1624355a2b3e3..9cf989246b175c58a126f8b9171c67b92d1b4d0c 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -947,8 +947,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
     if (avctx->block_align >= UINT_MAX / 2)
         return AVERROR(EINVAL);
 
-    q->decoded_bytes_buffer = av_mallocz(avctx->block_align +
-                                         (4 - avctx->block_align % 4) +
+    q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
                                          FF_INPUT_BUFFER_PADDING_SIZE);
     if (q->decoded_bytes_buffer == NULL)
         return AVERROR(ENOMEM);