diff mbox series

[FFmpeg-devel,v2,3/8] swscale/options: relax src/dst_h/v_chr_pos value range

Message ID 20240704143104.1821386-3-ffmpeg@haasn.xyz
State New
Headers show
Series [FFmpeg-devel,v2,1/8] swscale: document SWS_FULL_CHR_H_* flags | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Niklas Haas July 4, 2024, 2:30 p.m. UTC
From: Niklas Haas <git@haasn.dev>

When dealing with 4x subsampling ratios (log2 == 2), such as can arise
with 4:1:1 or 4:1:0, a value range of 512 is not enough to cover the
range of possible scenarios.

For example, bottom-sited chroma in 4:1:0 would require an offset of 768
(three luma rows). Simply double the limit to 1024. I don't see any
place in initFilter() that would experience overflow as a result of this
change, especially since get_local_pos() right-shifts it by the
subsampling ratio again.
---
 libswscale/options.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer July 7, 2024, 6:56 p.m. UTC | #1
On Thu, Jul 04, 2024 at 04:30:59PM +0200, Niklas Haas wrote:
> From: Niklas Haas <git@haasn.dev>
> 
> When dealing with 4x subsampling ratios (log2 == 2), such as can arise
> with 4:1:1 or 4:1:0, a value range of 512 is not enough to cover the
> range of possible scenarios.
> 
> For example, bottom-sited chroma in 4:1:0 would require an offset of 768
> (three luma rows). Simply double the limit to 1024. I don't see any
> place in initFilter() that would experience overflow as a result of this
> change, especially since get_local_pos() right-shifts it by the
> subsampling ratio again.
> ---
>  libswscale/options.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

maybe limit it to the max value you know is needed instead of simply doubling.
it can be bumped up more later if we run in cases needing more

either way
LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libswscale/options.c b/libswscale/options.c
index b36f13c872..53c4f0651b 100644
--- a/libswscale/options.c
+++ b/libswscale/options.c
@@ -62,10 +62,10 @@  static const AVOption swscale_options[] = {
     { "param0",          "scaler param 0",                OFFSET(param[0]),  AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT  }, INT_MIN, INT_MAX,        VE },
     { "param1",          "scaler param 1",                OFFSET(param[1]),  AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT  }, INT_MIN, INT_MAX,        VE },
 
-    { "src_v_chr_pos",   "source vertical chroma position in luma grid/256"  ,      OFFSET(src_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      512,             VE },
-    { "src_h_chr_pos",   "source horizontal chroma position in luma grid/256",      OFFSET(src_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      512,             VE },
-    { "dst_v_chr_pos",   "destination vertical chroma position in luma grid/256"  , OFFSET(dst_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      512,             VE },
-    { "dst_h_chr_pos",   "destination horizontal chroma position in luma grid/256", OFFSET(dst_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      512,             VE },
+    { "src_v_chr_pos",   "source vertical chroma position in luma grid/256"  ,      OFFSET(src_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      1024,             VE },
+    { "src_h_chr_pos",   "source horizontal chroma position in luma grid/256",      OFFSET(src_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      1024,             VE },
+    { "dst_v_chr_pos",   "destination vertical chroma position in luma grid/256"  , OFFSET(dst_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      1024,             VE },
+    { "dst_h_chr_pos",   "destination horizontal chroma position in luma grid/256", OFFSET(dst_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513 }, -513,      1024,             VE },
 
     { "sws_dither",      "set dithering algorithm",       OFFSET(dither),    AV_OPT_TYPE_INT,    { .i64  = SWS_DITHER_AUTO    }, 0,       NB_SWS_DITHER,  VE, .unit = "sws_dither" },
     { "auto",            "leave choice to sws",           0,                 AV_OPT_TYPE_CONST,  { .i64  = SWS_DITHER_AUTO    }, INT_MIN, INT_MAX,        VE, .unit = "sws_dither" },