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

Git pushed a commit to branch master
in repository ffmpeg.

commit fa1ca69a8bde7a74e7c01777c75bb7c7e0754ee3
Author:     Niklas Haas <[email protected]>
AuthorDate: Fri Jun 19 15:36:08 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Jun 20 03:08:21 2026 +0200

    swscale/filters: add ability to set a virtual output size
    
    Odd-size luma planes are not exact multiples of the chroma plane; but the
    sample grid is still matched as though it were. We need to account for this
    when translating a luma sample to the corresponding chroma sample 
coordinates.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/filters.c |  7 ++++++-
 libswscale/filters.h | 15 +++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/libswscale/filters.c b/libswscale/filters.c
index 81a388e692..fb54d2bbd8 100644
--- a/libswscale/filters.c
+++ b/libswscale/filters.c
@@ -194,7 +194,11 @@ int ff_sws_filter_generate(void *log, const 
SwsFilterParams *params,
     if (scaler == SWS_SCALE_AUTO)
         scaler = SWS_SCALE_BICUBIC;
 
-    const double ratio = (double) params->dst_size / params->src_size;
+    double virtual_size = params->virtual_size;
+    if (!virtual_size)
+        virtual_size = params->dst_size;
+
+    const double ratio = virtual_size / params->src_size;
     double stretch = 1.0;
     if (ratio < 1.0 && scaler != SWS_SCALE_POINT) {
         /* Widen filter for downscaling (anti-aliasing) */
@@ -257,6 +261,7 @@ int ff_sws_filter_generate(void *log, const SwsFilterParams 
*params,
     memcpy(filter->name, fun.name, sizeof(filter->name));
     filter->src_size = params->src_size;
     filter->dst_size = params->dst_size;
+    filter->virtual_size = virtual_size;
     filter->offset = params->offset;
     filter->filter_size = filter_size;
     if (filter->filter_size == 1)
diff --git a/libswscale/filters.h b/libswscale/filters.h
index 143fc2c5e3..a10e6f3964 100644
--- a/libswscale/filters.h
+++ b/libswscale/filters.h
@@ -57,6 +57,20 @@ typedef struct SwsFilterParams {
     int src_size;
     int dst_size;
 
+    /**
+     * The virtual output size. If zero, this is assumed to be the same as
+     * `dst_size`. Matters for e.g. chroma subsampling, where the the luma
+     * plane may be smaller than the dst_size. For example, a 99x99 input
+     * image has a chroma size of 50x50, which would be 100x100 after
+     * chroma upscaling; but is sampled only at 99x99 resolution. In this
+     * instance, dst_size is 99x99 and virtual_size is 100x100.
+     *
+     * The upscaling offset from this shift is implicit and does not need
+     * to be accounted for in `offset`. In other words, `offset` is taken
+     * relative to the virtual size, not the sampled size.
+     */
+    double virtual_size;
+
     /**
      * The sample offset, in units of input pixels. This is added onto all
      * sampled coordinates directly, i.e. a value of offset = 1.0 would shift
@@ -95,6 +109,7 @@ typedef struct SwsFilterWeights {
      */
     int src_size;
     int dst_size;
+    double virtual_size;
     double offset;
 
     /**

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

Reply via email to