PR #25809 opened by kitarisu.de
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25809
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25809.patch

# Summary of changes

When building FFmpeg 9.0.2 with flags that don't enable `CONFIG_UNSTABLE` for 
libswscale it creates a `libswscale.so.10` file that cannot be used at runtime, 
as it misses the `ff_sws_chroma_pos` symbol.

The fix is already in master, therefore just cherry-picking it on top of 9.0 .


From d4070a14cecc7e29eb278f9b6036c2284255f70d Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 30 Jun 2026 21:44:27 +0200
Subject: [PATCH] swscale/format: Build ff_sws_chroma_pos() even without
 CONFIG_UNSTABLE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is used in add_legacy_sws_pass() in graph.c.

Signed-off-by: Andreas Rheinhardt <[email protected]>
Signed-off-by: Sven Püschel <[email protected]>
(cherry picked from commit fad1db043d45d4d3cc482934ac6cd579f556a6e8)
---
 libswscale/format.c | 82 ++++++++++++++++++++++-----------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/libswscale/format.c b/libswscale/format.c
index b03cfff44aa..70cc813dd76 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -551,6 +551,47 @@ bool ff_infer_colors(SwsColor *src, SwsColor *dst)
     return incomplete;
 }
 
+void ff_sws_chroma_pos(const SwsFormat *fmt, bool *incomplete,
+                       int *out_x_pos, int *out_y_pos)
+{
+    enum AVChromaLocation chroma_loc = fmt->loc;
+    const int sub_x = fmt->desc->log2_chroma_w;
+    const int sub_y = fmt->desc->log2_chroma_h;
+    int x_pos, y_pos;
+
+    /* Explicitly default to center siting for compatibility with swscale */
+    if (chroma_loc == AVCHROMA_LOC_UNSPECIFIED) {
+        chroma_loc = AVCHROMA_LOC_CENTER;
+        *incomplete |= sub_x || sub_y;
+    }
+
+    /* av_chroma_location_enum_to_pos() always gives us values in the range 
from
+     * 0 to 256, but we need to adjust this to the true value range of the
+     * subsampling grid, which may be larger for h/v_sub > 1 */
+    av_chroma_location_enum_to_pos(&x_pos, &y_pos, chroma_loc);
+    x_pos *= (1 << sub_x) - 1;
+    y_pos *= (1 << sub_y) - 1;
+
+    /* Fix vertical chroma position for interlaced frames */
+    if (sub_y && fmt->interlaced) {
+        /* When vertically subsampling, chroma samples are effectively only
+         * placed next to even rows. To access them from the odd field, we need
+         * to account for this shift by offsetting the distance of one luma 
row.
+         *
+         * For 4x vertical subsampling (v_sub == 2), they are only placed
+         * next to every *other* even row, so we need to shift by three luma
+         * rows to get to the chroma sample. */
+        if (fmt->field == FIELD_BOTTOM)
+            y_pos += (256 << sub_y) - 256;
+
+        /* Luma row distance is doubled for fields, so halve offsets */
+        y_pos >>= 1;
+    }
+
+    *out_x_pos = x_pos;
+    *out_y_pos = y_pos;
+}
+
 /* Variant of sws_test_format() for the ops-based code */
 static int test_format_ops(enum AVPixelFormat format, int output);
 static int test_format_legacy(enum AVPixelFormat format, int output)
@@ -1434,47 +1475,6 @@ linear_mat3(const AVRational m00, const AVRational m01, 
const AVRational m02,
     return c;
 }
 
-void ff_sws_chroma_pos(const SwsFormat *fmt, bool *incomplete,
-                       int *out_x_pos, int *out_y_pos)
-{
-    enum AVChromaLocation chroma_loc = fmt->loc;
-    const int sub_x = fmt->desc->log2_chroma_w;
-    const int sub_y = fmt->desc->log2_chroma_h;
-    int x_pos, y_pos;
-
-    /* Explicitly default to center siting for compatibility with swscale */
-    if (chroma_loc == AVCHROMA_LOC_UNSPECIFIED) {
-        chroma_loc = AVCHROMA_LOC_CENTER;
-        *incomplete |= sub_x || sub_y;
-    }
-
-    /* av_chroma_location_enum_to_pos() always gives us values in the range 
from
-     * 0 to 256, but we need to adjust this to the true value range of the
-     * subsampling grid, which may be larger for h/v_sub > 1 */
-    av_chroma_location_enum_to_pos(&x_pos, &y_pos, chroma_loc);
-    x_pos *= (1 << sub_x) - 1;
-    y_pos *= (1 << sub_y) - 1;
-
-    /* Fix vertical chroma position for interlaced frames */
-    if (sub_y && fmt->interlaced) {
-        /* When vertically subsampling, chroma samples are effectively only
-         * placed next to even rows. To access them from the odd field, we need
-         * to account for this shift by offsetting the distance of one luma 
row.
-         *
-         * For 4x vertical subsampling (v_sub == 2), they are only placed
-         * next to every *other* even row, so we need to shift by three luma
-         * rows to get to the chroma sample. */
-        if (fmt->field == FIELD_BOTTOM)
-            y_pos += (256 << sub_y) - 256;
-
-        /* Luma row distance is doubled for fields, so halve offsets */
-        y_pos >>= 1;
-    }
-
-    *out_x_pos = x_pos;
-    *out_y_pos = y_pos;
-}
-
 int ff_sws_decode_colors(SwsContext *ctx, SwsPixelType type,
                          SwsOpList *ops, const SwsFormat *fmt, bool 
*incomplete)
 {
-- 
2.54.0

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

Reply via email to