This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit e34071e7d5a65d6cd8a0ccbf2737d754cd91d9a2
Author:     Ramiro Polla <[email protected]>
AuthorDate: Fri Feb 27 22:14:25 2026 +0100
Commit:     Ramiro Polla <[email protected]>
CommitDate: Wed Mar 11 08:05:08 2026 +0000

    swscale/tests/swscale: split init_ref() out of main()
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Ramiro Polla <[email protected]>
---
 libswscale/tests/swscale.c | 57 +++++++++++++++++++++++++++++-----------------
 1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 4a49f5b51f..f17f160352 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -517,6 +517,40 @@ static int run_file_tests(const AVFrame *ref, FILE *fp, 
struct options opts)
     return 0;
 }
 
+static int init_ref(AVFrame *ref, const struct options *opts)
+{
+    SwsContext *ctx = sws_alloc_context();
+    AVFrame *rgb = av_frame_alloc();
+    AVLFG rand;
+    int ret = -1;
+
+    if (!ctx || !rgb)
+        goto error;
+
+    rgb->width  = opts->w / 12;
+    rgb->height = opts->h / 12;
+    rgb->format = AV_PIX_FMT_RGBA;
+    ret = av_frame_get_buffer(rgb, 32);
+    if (ret < 0)
+        goto error;
+
+    av_lfg_init(&rand, 1);
+    for (int y = 0; y < rgb->height; y++) {
+        for (int x = 0; x < rgb->width; x++) {
+            for (int c = 0; c < 4; c++)
+                rgb->data[0][y * rgb->linesize[0] + x * 4 + c] = 
av_lfg_get(&rand);
+        }
+    }
+
+    ctx->flags = SWS_BILINEAR;
+    ret = sws_scale_frame(ctx, ref, rgb);
+
+error:
+    sws_free_context(&ctx);
+    av_frame_free(&rgb);
+    return ret;
+}
+
 static int parse_options(int argc, char **argv, struct options *opts, FILE 
**fp)
 {
     for (int i = 1; i < argc; i += 2) {
@@ -628,16 +662,14 @@ int main(int argc, char **argv)
         .dither  = -1,
     };
 
-    AVFrame *rgb = NULL, *ref = NULL;
+    AVFrame *ref = NULL;
     FILE *fp = NULL;
-    AVLFG rand;
     int ret = -1;
 
     if (parse_options(argc, argv, &opts, &fp) < 0)
         goto error;
 
     ff_sfc64_init(&prng_state, 0, 0, 0, 12);
-    av_lfg_init(&rand, 1);
     signal(SIGINT, exit_handler);
 
     for (int i = 0; i < 3; i++) {
@@ -647,22 +679,6 @@ int main(int argc, char **argv)
         sws[i]->flags = SWS_BILINEAR;
     }
 
-    rgb = av_frame_alloc();
-    if (!rgb)
-        goto error;
-    rgb->width  = opts.w / 12;
-    rgb->height = opts.h / 12;
-    rgb->format = AV_PIX_FMT_RGBA;
-    if (av_frame_get_buffer(rgb, 32) < 0)
-        goto error;
-
-    for (int y = 0; y < rgb->height; y++) {
-        for (int x = 0; x < rgb->width; x++) {
-            for (int c = 0; c < 4; c++)
-                rgb->data[0][y * rgb->linesize[0] + x * 4 + c] = 
av_lfg_get(&rand);
-        }
-    }
-
     ref = av_frame_alloc();
     if (!ref)
         goto error;
@@ -670,7 +686,7 @@ int main(int argc, char **argv)
     ref->height = opts.h;
     ref->format = AV_PIX_FMT_YUVA444P;
 
-    if (sws_scale_frame(sws[0], ref, rgb) < 0)
+    if (init_ref(ref, &opts) < 0)
         goto error;
 
     ret = fp ? run_file_tests(ref, fp, opts)
@@ -680,7 +696,6 @@ int main(int argc, char **argv)
 error:
     for (int i = 0; i < 3; i++)
         sws_free_context(&sws[i]);
-    av_frame_free(&rgb);
     av_frame_free(&ref);
     if (fp)
         fclose(fp);

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to