diff mbox series

[FFmpeg-devel,09/10] avcodec/magicyuvenc: Don't call functions twice due to macro

Message ID GV1P250MB07370D3C71A22AE1633036688F362@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 33b1c7ebbfc47b5755366a3b657edf0a6b9b7baa
Headers show
Series [FFmpeg-devel,01/10] doc/examples: Always use <> includes | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt March 25, 2024, 1:53 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/magicyuvenc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 3ae1ee2c71..93eabb9f9a 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -211,10 +211,13 @@  static av_cold int magy_encode_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
 
     if (s->correlate) {
-        s->decorrelate_buf[0] = av_calloc(2U * (s->nb_slices * s->slice_height), FFALIGN(avctx->width, av_cpu_max_align()));
+        size_t max_align = av_cpu_max_align();
+        size_t aligned_width = FFALIGN(avctx->width, max_align);
+        s->decorrelate_buf[0] = av_calloc(2U * (s->nb_slices * s->slice_height),
+                                          aligned_width);
         if (!s->decorrelate_buf[0])
             return AVERROR(ENOMEM);
-        s->decorrelate_buf[1] = s->decorrelate_buf[0] + (s->nb_slices * s->slice_height) * FFALIGN(avctx->width, av_cpu_max_align());
+        s->decorrelate_buf[1] = s->decorrelate_buf[0] + (s->nb_slices * s->slice_height) * aligned_width;
     }
 
     s->bitslice_size = avctx->width * s->slice_height + 2;
@@ -493,7 +496,8 @@  static int encode_slice(AVCodecContext *avctx, void *tdata,
 static int predict_slice(AVCodecContext *avctx, void *tdata,
                          int n, int threadnr)
 {
-    const int aligned_width = FFALIGN(avctx->width, av_cpu_max_align());
+    size_t max_align = av_cpu_max_align();
+    const int aligned_width = FFALIGN(avctx->width, max_align);
     MagicYUVContext *s = avctx->priv_data;
     const int slice_height = s->slice_height;
     const int last_height = FFMIN(slice_height, avctx->height - n * slice_height);