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

Git pushed a commit to branch master
in repository ffmpeg.

commit 36c31fd5ba8df09e1dae3f64b07ceb86a4020cbf
Author:     Niklas Haas <[email protected]>
AuthorDate: Wed Feb 18 16:44:01 2026 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Thu Mar 12 22:08:07 2026 +0100

    swscale: don't hard code number of scaler params
    
    In case we ever need to increase this number in the future.
    I won't bother bumping the ABI version for this new #define, since it 
doesn't
    affect ABI, and I'm about to bump the ABI version in a following commit.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/graph.c   |  4 ++--
 libswscale/swscale.h |  3 ++-
 libswscale/utils.c   | 16 +++++++---------
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/libswscale/graph.c b/libswscale/graph.c
index 2408fa93f8..145dfe2277 100644
--- a/libswscale/graph.c
+++ b/libswscale/graph.c
@@ -524,8 +524,8 @@ static int add_legacy_sws_pass(SwsGraph *graph, const 
SwsFormat *src,
     legacy_chr_pos(graph, &sws->dst_h_chr_pos, ctx->dst_h_chr_pos, &warned);
     legacy_chr_pos(graph, &sws->dst_v_chr_pos, ctx->dst_v_chr_pos, &warned);
 
-    sws->scaler_params[0] = ctx->scaler_params[0];
-    sws->scaler_params[1] = ctx->scaler_params[1];
+    for (int i = 0; i < SWS_NUM_SCALER_PARAMS; i++)
+        sws->scaler_params[i] = ctx->scaler_params[i];
 
     ret = sws_init_context(sws, NULL, NULL);
     if (ret < 0) {
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 1ee24c22ad..043b4c15ef 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -204,7 +204,8 @@ typedef struct SwsContext {
     /**
      * Extra parameters for fine-tuning certain scalers.
      */
-    double scaler_params[2];
+#define SWS_NUM_SCALER_PARAMS 2
+    double scaler_params[SWS_NUM_SCALER_PARAMS];
 
     /**
      * How many threads to use for processing, or 0 for automatic selection.
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 2b233cf0e6..9b9e667089 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -87,10 +87,8 @@ static SwsContext *alloc_set_opts(int srcW, int srcH, enum 
AVPixelFormat srcForm
     sws->src_format = srcFormat;
     sws->dst_format = dstFormat;
 
-    if (param) {
-        sws->scaler_params[0] = param[0];
-        sws->scaler_params[1] = param[1];
-    }
+    for (int i = 0; param && i < SWS_NUM_SCALER_PARAMS; i++)
+        sws->scaler_params[i] = param[i];
 
     return sws;
 }
@@ -200,7 +198,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t 
**filterPos,
                               int dstW, int filterAlign, int one,
                               int flags, int cpu_flags,
                               SwsVector *srcFilter, SwsVector *dstFilter,
-                              double param[2], int srcPos, int dstPos)
+                              double param[SWS_NUM_SCALER_PARAMS], int srcPos, 
int dstPos)
 {
     int i;
     int filterSize;
@@ -2375,8 +2373,8 @@ SwsContext *sws_getCachedContext(SwsContext *prev, int 
srcW,
                  prev->dst_h            == dstH      &&
                  prev->dst_format       == dstFormat &&
                  prev->flags            == flags     &&
-                 prev->scaler_params[0] == param[0]  &&
-                 prev->scaler_params[1] == param[1])) {
+                 !memcmp(prev->scaler_params, param,
+                         sizeof(prev->scaler_params)))) {
         return prev;
     }
 
@@ -2397,8 +2395,8 @@ SwsContext *sws_getCachedContext(SwsContext *prev, int 
srcW,
     sws->dst_h            = dstH;
     sws->dst_format       = dstFormat;
     sws->flags            = flags;
-    sws->scaler_params[0] = param[0];
-    sws->scaler_params[1] = param[1];
+    for (int i = 0; i < SWS_NUM_SCALER_PARAMS; i++)
+        sws->scaler_params[i] = param[i];
 
     if (sws_init_context(sws, srcFilter, dstFilter) < 0)
         sws_free_context(&sws);

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

Reply via email to