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

Git pushed a commit to branch master
in repository ffmpeg.

commit 8215e9bbea07173b59e842a860df58aca18ff01a
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Jun 8 14:44:01 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Jun 20 03:08:07 2026 +0200

    swscale/filters: add option for adding an input pixel offset
    
    This is needed for chroma subsampling, which requires a different filter
    offset for chroma subsamples (according to the frame's chroma location).
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/filters.c | 3 ++-
 libswscale/filters.h | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libswscale/filters.c b/libswscale/filters.c
index 7e8865659e..81a388e692 100644
--- a/libswscale/filters.c
+++ b/libswscale/filters.c
@@ -75,7 +75,7 @@ static void compute_row(SwsFilterWeights *f, const 
SwsFilterFunction *fun,
      * the entire square from (0,0) to (1,1). When normalizing between 
different
      * image sizes, we therefore need to add/subtract off these 0.5 offsets.
      */
-    const double src_pos = (dst_pos + 0.5) * ratio_inv - 0.5;
+    const double src_pos = (dst_pos + 0.5) * ratio_inv - 0.5 + f->offset;
     if (f->filter_size == 1) {
         *pos = fmin(fmax(round(src_pos), 0.0), f->src_size - 1);
         *out = SWS_FILTER_SCALE;
@@ -257,6 +257,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->offset = params->offset;
     filter->filter_size = filter_size;
     if (filter->filter_size == 1)
         filter->sum_positive = SWS_FILTER_SCALE;
diff --git a/libswscale/filters.h b/libswscale/filters.h
index 1bfdb196b8..143fc2c5e3 100644
--- a/libswscale/filters.h
+++ b/libswscale/filters.h
@@ -56,6 +56,13 @@ typedef struct SwsFilterParams {
      */
     int src_size;
     int dst_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
+     * the output to the top/left by one whole source pixel.
+     */
+    double offset;
 } SwsFilterParams;
 
 /**
@@ -88,6 +95,7 @@ typedef struct SwsFilterWeights {
      */
     int src_size;
     int dst_size;
+    double offset;
 
     /**
      * Extra metadata about the filter, used to inform the optimizer / range

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

Reply via email to