Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/6] swscale: document SWS_FULL_CHR_H_* flags
@ 2024-07-04 11:51 Niklas Haas
  2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 2/6] avfilter/vf_setparams: allow setting chroma location Niklas Haas
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Niklas Haas @ 2024-07-04 11:51 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

Based on my best understanding of what they do, given the source code.
---
 libswscale/swscale.h | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 9d4612aaf3..e22931cab4 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -82,11 +82,35 @@ const char *swscale_license(void);
 #define SWS_PRINT_INFO              0x1000
 
 //the following 3 flags are not completely implemented
-//internal chrominance subsampling info
+
+/**
+ * Perform full chroma upsampling when converting to RGB as part of scaling.
+ *
+ * For example, when converting 50x50 yuv420p to 100x100 rgba, setting this flag
+ * will scale the chroma plane from 25x25 to 100x100 (4:4:4), and then convert
+ * the 100x100 yuv444p image to rgba in the final output step.
+ *
+ * Without this flag, the chroma plane is instead scaled to 50x100 (4:2:2),
+ * with a single chroma sample being re-used for both horizontally adjacent RGBA
+ * output pixels.
+ */
 #define SWS_FULL_CHR_H_INT    0x2000
-//input subsampling info
+
+/**
+ * Perform full chroma interpolation when downscaling RGB sources.
+ *
+ * For example, when converting a 100x100 rgba source to 50x50 yuv444p, setting
+ * this flag will generate a 100x100 (4:4:4) chroma plane, which is then
+ * downscaled to the required 50x50.
+ *
+ * Without this flag, the chroma plane is instead generated at 50x100 (dropping
+ * every other pixel), before then being downscaled to the required 50x50
+ * resolution.
+ */
 #define SWS_FULL_CHR_H_INP    0x4000
+
 #define SWS_DIRECT_BGR        0x8000
+
 #define SWS_ACCURATE_RND      0x40000
 #define SWS_BITEXACT          0x80000
 #define SWS_ERROR_DIFFUSION  0x800000
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 2/6] avfilter/vf_setparams: allow setting chroma location
  2024-07-04 11:51 [FFmpeg-devel] [PATCH 1/6] swscale: document SWS_FULL_CHR_H_* flags Niklas Haas
@ 2024-07-04 11:51 ` Niklas Haas
  2024-07-04 15:09   ` Paul B Mahol
  2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 3/6] avfilter/swscale: always fix interlaced " Niklas Haas
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Niklas Haas @ 2024-07-04 11:51 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

Shockingly, there isn't currently _any_ filter for overriding this.
---
 doc/filters.texi           | 17 +++++++++++++++++
 libavfilter/vf_setparams.c | 19 ++++++++++++++++---
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index c9c4f7cf6b..ca8f6e461a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -22073,6 +22073,23 @@ Keep the same colorspace property (default).
 @item chroma-derived-c
 @item ictcp
 @end table
+
+@item chroma_location
+Set the chroma sample location.
+Available values are:
+
+@table @samp
+@item auto
+Keep the same chroma location (default).
+
+@item unspecified, unknown
+@item left
+@item center
+@item topleft
+@item top
+@item bottomleft
+@item bottom
+@end table
 @end table
 
 @section sharpen_npp
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index b7da8eb54b..ba32a6699c 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -41,6 +41,7 @@ typedef struct SetParamsContext {
     int color_primaries;
     int color_trc;
     int colorspace;
+    int chroma_location;
 } SetParamsContext;
 
 #define OFFSET(x) offsetof(SetParamsContext, x)
@@ -119,6 +120,17 @@ static const AVOption setparams_options[] = {
     {"chroma-derived-c",           NULL,  0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
     {"ictcp",                      NULL,  0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP},             INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
     {"ipt-c2",                     NULL,  0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2},            INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
+
+    {"chroma_location", "select chroma sample location", OFFSET(chroma_location), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCHROMA_LOC_NB-1, FLAGS, .unit = "chroma_location"},
+    {"auto", "keep the same chroma location",  0, AV_OPT_TYPE_CONST, {.i64=-1},                       INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"unspecified",                      NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"unknown",                          NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"left",                             NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_LEFT},        INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"center",                           NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_CENTER},      INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"topleft",                          NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOPLEFT},     INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"top",                              NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP},         INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"bottomleft",                       NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT},  INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
+    {"bottom",                           NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM},      INT_MIN, INT_MAX, FLAGS, .unit = "chroma_location"},
     {NULL}
 };
 
@@ -174,17 +186,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
             frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
     }
 
-    /* set range */
+    /* set straightforward parameters */
     if (s->color_range >= 0)
         frame->color_range = s->color_range;
-
-    /* set color prim, trc, space */
     if (s->color_primaries >= 0)
         frame->color_primaries = s->color_primaries;
     if (s->color_trc >= 0)
         frame->color_trc = s->color_trc;
     if (s->colorspace >= 0)
         frame->colorspace = s->colorspace;
+    if (s->chroma_location >= 0)
+        frame->chroma_location = s->chroma_location;
+
     return ff_filter_frame(ctx->outputs[0], frame);
 }
 
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 3/6] avfilter/swscale: always fix interlaced chroma location
  2024-07-04 11:51 [FFmpeg-devel] [PATCH 1/6] swscale: document SWS_FULL_CHR_H_* flags Niklas Haas
  2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 2/6] avfilter/vf_setparams: allow setting chroma location Niklas Haas
@ 2024-07-04 11:51 ` Niklas Haas
  2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 4/6] avfilter/vf_scale: add in/out_chroma_loc Niklas Haas
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Niklas Haas @ 2024-07-04 11:51 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

The current logic only fixes it when the user does not explicitly
specify the chroma location. However, this does not make a lot of sense.
Since there is no way to specify this property per-field, it effectively
*prevents* the user from being able to correctly scale interlaced frames
with top-aligned chroma.

It makes more sense to consider the user setting in the progressive case
only, and automatically adapt it to the correct interlaced field
positions, following the details of the MPEG specification.
---
 libavfilter/vf_scale.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 841075193e..0b6701673f 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -709,12 +709,18 @@ static int config_props(AVFilterLink *outlink)
              * chroma positions. MPEG chroma positions are used by convention.
              * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
              * locations, since they share a vertical alignment */
-            if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) {
-                in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
+            if (desc->log2_chroma_h == 1) {
+                if (in_v_chr_pos == -513)
+                    in_v_chr_pos = 128; /* explicitly default missing info */
+                in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */
+                in_v_chr_pos >>= i > 0; /* double luma row distance */
             }
 
-            if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) {
-                out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
+            if (outdesc->log2_chroma_h == 1) {
+                if (out_v_chr_pos == -513)
+                    out_v_chr_pos = 128;
+                out_v_chr_pos += 256 * (i == 2);
+                out_v_chr_pos >>= i > 0;
             }
 
             av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0);
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 4/6] avfilter/vf_scale: add in/out_chroma_loc
  2024-07-04 11:51 [FFmpeg-devel] [PATCH 1/6] swscale: document SWS_FULL_CHR_H_* flags Niklas Haas
  2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 2/6] avfilter/vf_setparams: allow setting chroma location Niklas Haas
  2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 3/6] avfilter/swscale: always fix interlaced " Niklas Haas
@ 2024-07-04 11:52 ` Niklas Haas
  2024-07-04 12:52   ` Niklas Haas
  2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 5/6] avfilter/vf_zscale: remove unused fields Niklas Haas
  2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 6/6] fate/scalechroma: switch to standard chroma location Niklas Haas
  4 siblings, 1 reply; 8+ messages in thread
From: Niklas Haas @ 2024-07-04 11:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

Currently, this just functions as a more principled and user-friendly
replacement for the (undocumented and hard to use) *_chr_pos fields.

However, the goal is to automatically infer these values from the input
frames' chroma location, and deprecate the manual use of *_chr_pos
altogether. (Indeed, my plans for an swscale replacement will most
likely also end up limiting the set of legal chroma locations to those
permissible by AVFrame properties)
---
 doc/filters.texi       | 15 +++++++++
 libavfilter/vf_scale.c | 75 ++++++++++++++++++++++++++++--------------
 2 files changed, 66 insertions(+), 24 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ca8f6e461a..3cff4eec1c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21137,6 +21137,21 @@ Set full range (0-255 in case of 8-bit luma).
 Set "MPEG" range (16-235 in case of 8-bit luma).
 @end table
 
+@item in_chroma_loc
+@item out_chroma_loc
+Set in/output chroma sample location. If not specified, center-sited chroma
+is used by default. Possible values:
+
+@table @samp
+@item auto, unknown
+@item left
+@item center
+@item topleft
+@item top
+@item bottomleft
+@item bottom
+@end table
+
 @item force_original_aspect_ratio
 Enable decreasing or increasing output video width or height if necessary to
 keep the original aspect ratio. Possible values:
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 0b6701673f..f0de0261db 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -168,6 +168,8 @@ typedef struct ScaleContext {
     int in_range;
     int out_range;
 
+    int in_chroma_loc;
+    int out_chroma_loc;
     int out_h_chr_pos;
     int out_v_chr_pos;
     int in_h_chr_pos;
@@ -617,6 +619,29 @@ fail:
     return ret;
 }
 
+static void calc_chroma_pos(int *h_pos, int *v_pos, int chroma_loc,
+                            int h_pos_default, int v_pos_default,
+                            int h_sub, int v_sub, int index)
+{
+    *h_pos = h_pos_default;
+    *v_pos = v_pos_default;
+    if (chroma_loc != AVCHROMA_LOC_UNSPECIFIED)
+        av_chroma_location_enum_to_pos(h_pos, v_pos, chroma_loc);
+
+    if (h_sub && index > 0 /* interlaced fields */) {
+        if (*v_pos == -513)
+            *v_pos = 128; /* explicitly default missing info */
+        *v_pos += 256 * (index == 2); /* offset by one luma row for odd rows */
+        *v_pos >>= 1; /* double luma row distance */
+    }
+
+    /* Avoid offsetting chroma for progressive content */
+    if (!h_sub)
+        *h_pos = -513;
+    if (!v_sub)
+        *v_pos = -513;
+}
+
 static int config_props(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
@@ -673,15 +698,16 @@ static int config_props(AVFilterLink *outlink)
         inlink0->h == outlink->h &&
         in_range == outlink->color_range &&
         in_colorspace == outlink->colorspace &&
-        inlink0->format == outlink->format)
+        inlink0->format == outlink->format &&
+        scale->in_chroma_loc == scale->out_chroma_loc)
         ;
     else {
         struct SwsContext **swscs[3] = {&scale->sws, &scale->isws[0], &scale->isws[1]};
         int i;
 
         for (i = 0; i < 3; i++) {
-            int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos;
             int in_full, out_full, brightness, contrast, saturation;
+            int h_chr_pos, v_chr_pos;
             const int *inv_table, *table;
             struct SwsContext *const s = sws_alloc_context();
             if (!s)
@@ -705,28 +731,17 @@ static int config_props(AVFilterLink *outlink)
                 av_opt_set_int(s, "dst_range",
                                outlink->color_range == AVCOL_RANGE_JPEG, 0);
 
-            /* Override chroma location default settings to have the correct
-             * chroma positions. MPEG chroma positions are used by convention.
-             * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
-             * locations, since they share a vertical alignment */
-            if (desc->log2_chroma_h == 1) {
-                if (in_v_chr_pos == -513)
-                    in_v_chr_pos = 128; /* explicitly default missing info */
-                in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */
-                in_v_chr_pos >>= i > 0; /* double luma row distance */
-            }
-
-            if (outdesc->log2_chroma_h == 1) {
-                if (out_v_chr_pos == -513)
-                    out_v_chr_pos = 128;
-                out_v_chr_pos += 256 * (i == 2);
-                out_v_chr_pos >>= i > 0;
-            }
-
-            av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0);
-            av_opt_set_int(s, "src_v_chr_pos", in_v_chr_pos, 0);
-            av_opt_set_int(s, "dst_h_chr_pos", scale->out_h_chr_pos, 0);
-            av_opt_set_int(s, "dst_v_chr_pos", out_v_chr_pos, 0);
+            calc_chroma_pos(&h_chr_pos, &v_chr_pos, scale->in_chroma_loc,
+                            scale->in_h_chr_pos, scale->in_v_chr_pos,
+                            desc->log2_chroma_w, desc->log2_chroma_h, i);
+            av_opt_set_int(s, "src_h_chr_pos", h_chr_pos, 0);
+            av_opt_set_int(s, "src_v_chr_pos", v_chr_pos, 0);
+
+            calc_chroma_pos(&h_chr_pos, &v_chr_pos, scale->out_chroma_loc,
+                            scale->out_h_chr_pos, scale->out_v_chr_pos,
+                            outdesc->log2_chroma_w, outdesc->log2_chroma_h, i);
+            av_opt_set_int(s, "dst_h_chr_pos", h_chr_pos, 0);
+            av_opt_set_int(s, "dst_v_chr_pos", v_chr_pos, 0);
 
             if ((ret = sws_init_context(s, NULL, NULL)) < 0)
                 return ret;
@@ -987,6 +1002,8 @@ scale:
     out->height = outlink->h;
     out->color_range = outlink->color_range;
     out->colorspace = outlink->colorspace;
+    if (scale->out_chroma_loc != AVCHROMA_LOC_UNSPECIFIED)
+        out->chroma_location = scale->out_chroma_loc;
 
     if (scale->output_is_pal)
         avpriv_set_systematic_pal2((uint32_t*)out->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format);
@@ -1217,6 +1234,16 @@ static const AVOption scale_options[] = {
     { "mpeg",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range" },
     { "tv",     NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range" },
     { "pc",     NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range" },
+    { "in_chroma_loc",  "set input chroma sample location",  OFFSET(in_chroma_loc),  AV_OPT_TYPE_INT, { .i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, .flags = FLAGS, .unit = "chroma_loc" },
+    { "out_chroma_loc", "set output chroma sample location", OFFSET(out_chroma_loc), AV_OPT_TYPE_INT, { .i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, .flags = FLAGS, .unit = "chroma_loc" },
+        {"auto",          NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_loc"},
+        {"unknown",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_loc"},
+        {"left",          NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_LEFT},        0, 0, FLAGS, .unit = "chroma_loc"},
+        {"center",        NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_CENTER},      0, 0, FLAGS, .unit = "chroma_loc"},
+        {"topleft",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOPLEFT},     0, 0, FLAGS, .unit = "chroma_loc"},
+        {"top",           NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP},         0, 0, FLAGS, .unit = "chroma_loc"},
+        {"bottomleft",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT},  0, 0, FLAGS, .unit = "chroma_loc"},
+        {"bottom",        NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM},      0, 0, FLAGS, .unit = "chroma_loc"},
     { "in_v_chr_pos",   "input vertical chroma position in luma grid/256"  ,   OFFSET(in_v_chr_pos),  AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
     { "in_h_chr_pos",   "input horizontal chroma position in luma grid/256",   OFFSET(in_h_chr_pos),  AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
     { "out_v_chr_pos",   "output vertical chroma position in luma grid/256"  , OFFSET(out_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 5/6] avfilter/vf_zscale: remove unused fields
  2024-07-04 11:51 [FFmpeg-devel] [PATCH 1/6] swscale: document SWS_FULL_CHR_H_* flags Niklas Haas
                   ` (2 preceding siblings ...)
  2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 4/6] avfilter/vf_scale: add in/out_chroma_loc Niklas Haas
@ 2024-07-04 11:52 ` Niklas Haas
  2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 6/6] fate/scalechroma: switch to standard chroma location Niklas Haas
  4 siblings, 0 replies; 8+ messages in thread
From: Niklas Haas @ 2024-07-04 11:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

---
 libavfilter/vf_zscale.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 45f1bd25ce..dd0d1b7f46 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -108,11 +108,6 @@ typedef struct ZScaleContext {
     char *w_expr;               ///< width  expression string
     char *h_expr;               ///< height expression string
 
-    int out_h_chr_pos;
-    int out_v_chr_pos;
-    int in_h_chr_pos;
-    int in_v_chr_pos;
-
     int first_time;
     int force_original_aspect_ratio;
 
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 6/6] fate/scalechroma: switch to standard chroma location
  2024-07-04 11:51 [FFmpeg-devel] [PATCH 1/6] swscale: document SWS_FULL_CHR_H_* flags Niklas Haas
                   ` (3 preceding siblings ...)
  2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 5/6] avfilter/vf_zscale: remove unused fields Niklas Haas
@ 2024-07-04 11:52 ` Niklas Haas
  4 siblings, 0 replies; 8+ messages in thread
From: Niklas Haas @ 2024-07-04 11:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

Replace the manually specified chroma location by one using standard
notation, arbitrarily "bottomleft" as it is a less common path.

Required if we want to phase out the use of manual chroma locations.
---
 tests/fate/filter-video.mak       |  2 +-
 tests/ref/fate/filter-scalechroma | 50 +++++++++++++++----------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 7f8dc3aa27..cffd67b1f8 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -433,7 +433,7 @@ fate-filter-scale2ref_keep_aspect: CMD = framemd5 -frames:v 5 -/filter_complex $
 
 FATE_FILTER_VSYNTH-$(call FILTERDEMDEC, SCALE, RAWVIDEO, RAWVIDEO) += fate-filter-scalechroma
 fate-filter-scalechroma: tests/data/vsynth1.yuv
-fate-filter-scalechroma: CMD = framecrc -flags bitexact -s 352x288 -pix_fmt yuv444p -i $(TARGET_PATH)/tests/data/vsynth1.yuv -pix_fmt yuv420p -sws_flags +bitexact -vf scale=out_v_chr_pos=33:out_h_chr_pos=151
+fate-filter-scalechroma: CMD = framecrc -flags bitexact -s 352x288 -pix_fmt yuv444p -i $(TARGET_PATH)/tests/data/vsynth1.yuv -pix_fmt yuv420p -sws_flags +bitexact -vf scale=out_chroma_loc=bottomleft
 
 FATE_FILTER_VSYNTH_VIDEO_FILTER-$(CONFIG_VFLIP_FILTER) += fate-filter-vflip
 fate-filter-vflip: CMD = video_filter "vflip"
diff --git a/tests/ref/fate/filter-scalechroma b/tests/ref/fate/filter-scalechroma
index 842769c2d5..dbe08600ab 100644
--- a/tests/ref/fate/filter-scalechroma
+++ b/tests/ref/fate/filter-scalechroma
@@ -3,28 +3,28 @@
 #codec_id 0: rawvideo
 #dimensions 0: 352x288
 #sar 0: 0/1
-0,          0,          0,        1,   152064, 0xdcab783a
-0,          1,          1,        1,   152064, 0x79c7f1f6
-0,          2,          2,        1,   152064, 0x3b810afb
-0,          3,          3,        1,   152064, 0x892aca1d
-0,          4,          4,        1,   152064, 0x52fdd093
-0,          5,          5,        1,   152064, 0xaa643426
-0,          6,          6,        1,   152064, 0x9ad020ed
-0,          7,          7,        1,   152064, 0x5c179057
-0,          8,          8,        1,   152064, 0xa56bf155
-0,          9,          9,        1,   152064, 0x61dcffca
-0,         10,         10,        1,   152064, 0x0d51a1d3
-0,         11,         11,        1,   152064, 0x652f9e8d
-0,         12,         12,        1,   152064, 0xdc0bb4d8
-0,         13,         13,        1,   152064, 0x561437cf
-0,         14,         14,        1,   152064, 0x69ef8e4f
-0,         15,         15,        1,   152064, 0xe7244350
-0,         16,         16,        1,   152064, 0xe65651cf
-0,         17,         17,        1,   152064, 0xfc9ff646
-0,         18,         18,        1,   152064, 0x6ae10bc4
-0,         19,         19,        1,   152064, 0xd3d1898a
-0,         20,         20,        1,   152064, 0xf3f8b139
-0,         21,         21,        1,   152064, 0x68c129be
-0,         22,         22,        1,   152064, 0xc3922593
-0,         23,         23,        1,   152064, 0x2b14d96e
-0,         24,         24,        1,   152064, 0xab119489
+0,          0,          0,        1,   152064, 0x77bb80f8
+0,          1,          1,        1,   152064, 0x3a21f6e8
+0,          2,          2,        1,   152064, 0xcc0907b0
+0,          3,          3,        1,   152064, 0xaa5cd87b
+0,          4,          4,        1,   152064, 0x410bd74d
+0,          5,          5,        1,   152064, 0x7a763b14
+0,          6,          6,        1,   152064, 0x3e4020d4
+0,          7,          7,        1,   152064, 0x46be8b5d
+0,          8,          8,        1,   152064, 0x8021f16c
+0,          9,          9,        1,   152064, 0x82ca033d
+0,         10,         10,        1,   152064, 0xa76ca6ca
+0,         11,         11,        1,   152064, 0x49019bb7
+0,         12,         12,        1,   152064, 0x3590adf5
+0,         13,         13,        1,   152064, 0xf21235dc
+0,         14,         14,        1,   152064, 0x6b5f93a9
+0,         15,         15,        1,   152064, 0x4b8c5137
+0,         16,         16,        1,   152064, 0x698b67cc
+0,         17,         17,        1,   152064, 0x3cebef62
+0,         18,         18,        1,   152064, 0x77770da1
+0,         19,         19,        1,   152064, 0xecdd84d4
+0,         20,         20,        1,   152064, 0x873fbc32
+0,         21,         21,        1,   152064, 0x55043c82
+0,         22,         22,        1,   152064, 0xee2b3669
+0,         23,         23,        1,   152064, 0xa64ae990
+0,         24,         24,        1,   152064, 0xb3499e12
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/6] avfilter/vf_scale: add in/out_chroma_loc
  2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 4/6] avfilter/vf_scale: add in/out_chroma_loc Niklas Haas
@ 2024-07-04 12:52   ` Niklas Haas
  0 siblings, 0 replies; 8+ messages in thread
From: Niklas Haas @ 2024-07-04 12:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

On Thu, 04 Jul 2024 13:52:00 +0200 Niklas Haas <ffmpeg@haasn.xyz> wrote:
> From: Niklas Haas <git@haasn.dev>
> 
> Currently, this just functions as a more principled and user-friendly
> replacement for the (undocumented and hard to use) *_chr_pos fields.
> 
> However, the goal is to automatically infer these values from the input
> frames' chroma location, and deprecate the manual use of *_chr_pos
> altogether. (Indeed, my plans for an swscale replacement will most
> likely also end up limiting the set of legal chroma locations to those
> permissible by AVFrame properties)
> ---
>  doc/filters.texi       | 15 +++++++++
>  libavfilter/vf_scale.c | 75 ++++++++++++++++++++++++++++--------------
>  2 files changed, 66 insertions(+), 24 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index ca8f6e461a..3cff4eec1c 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -21137,6 +21137,21 @@ Set full range (0-255 in case of 8-bit luma).
>  Set "MPEG" range (16-235 in case of 8-bit luma).
>  @end table
>  
> +@item in_chroma_loc
> +@item out_chroma_loc
> +Set in/output chroma sample location. If not specified, center-sited chroma
> +is used by default. Possible values:
> +
> +@table @samp
> +@item auto, unknown
> +@item left
> +@item center
> +@item topleft
> +@item top
> +@item bottomleft
> +@item bottom
> +@end table
> +
>  @item force_original_aspect_ratio
>  Enable decreasing or increasing output video width or height if necessary to
>  keep the original aspect ratio. Possible values:
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index 0b6701673f..f0de0261db 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -168,6 +168,8 @@ typedef struct ScaleContext {
>      int in_range;
>      int out_range;
>  
> +    int in_chroma_loc;
> +    int out_chroma_loc;
>      int out_h_chr_pos;
>      int out_v_chr_pos;
>      int in_h_chr_pos;
> @@ -617,6 +619,29 @@ fail:
>      return ret;
>  }
>  
> +static void calc_chroma_pos(int *h_pos, int *v_pos, int chroma_loc,
> +                            int h_pos_default, int v_pos_default,
> +                            int h_sub, int v_sub, int index)
> +{
> +    *h_pos = h_pos_default;
> +    *v_pos = v_pos_default;
> +    if (chroma_loc != AVCHROMA_LOC_UNSPECIFIED)
> +        av_chroma_location_enum_to_pos(h_pos, v_pos, chroma_loc);
> +
> +    if (h_sub && index > 0 /* interlaced fields */) {
> +        if (*v_pos == -513)
> +            *v_pos = 128; /* explicitly default missing info */
> +        *v_pos += 256 * (index == 2); /* offset by one luma row for odd rows */
> +        *v_pos >>= 1; /* double luma row distance */
> +    }

This logic needs to be revisited for 4:1:0 subsampled material (i.e.
h_sub == 2). In this case, the luma grid is 4x4, so we need to adjust
the sample location relative to the 4x4 grid.

I'm not yet entirely sure how it would interact with interlaced content
in this setting. I'll try and find a spec, since MPEG doesn't allow
4:1:0.

> +
> +    /* Avoid offsetting chroma for progressive content */
> +    if (!h_sub)
> +        *h_pos = -513;
> +    if (!v_sub)
> +        *v_pos = -513;
> +}
> +
>  static int config_props(AVFilterLink *outlink)
>  {
>      AVFilterContext *ctx = outlink->src;
> @@ -673,15 +698,16 @@ static int config_props(AVFilterLink *outlink)
>          inlink0->h == outlink->h &&
>          in_range == outlink->color_range &&
>          in_colorspace == outlink->colorspace &&
> -        inlink0->format == outlink->format)
> +        inlink0->format == outlink->format &&
> +        scale->in_chroma_loc == scale->out_chroma_loc)
>          ;
>      else {
>          struct SwsContext **swscs[3] = {&scale->sws, &scale->isws[0], &scale->isws[1]};
>          int i;
>  
>          for (i = 0; i < 3; i++) {
> -            int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos;
>              int in_full, out_full, brightness, contrast, saturation;
> +            int h_chr_pos, v_chr_pos;
>              const int *inv_table, *table;
>              struct SwsContext *const s = sws_alloc_context();
>              if (!s)
> @@ -705,28 +731,17 @@ static int config_props(AVFilterLink *outlink)
>                  av_opt_set_int(s, "dst_range",
>                                 outlink->color_range == AVCOL_RANGE_JPEG, 0);
>  
> -            /* Override chroma location default settings to have the correct
> -             * chroma positions. MPEG chroma positions are used by convention.
> -             * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
> -             * locations, since they share a vertical alignment */
> -            if (desc->log2_chroma_h == 1) {
> -                if (in_v_chr_pos == -513)
> -                    in_v_chr_pos = 128; /* explicitly default missing info */
> -                in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */
> -                in_v_chr_pos >>= i > 0; /* double luma row distance */
> -            }
> -
> -            if (outdesc->log2_chroma_h == 1) {
> -                if (out_v_chr_pos == -513)
> -                    out_v_chr_pos = 128;
> -                out_v_chr_pos += 256 * (i == 2);
> -                out_v_chr_pos >>= i > 0;
> -            }
> -
> -            av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0);
> -            av_opt_set_int(s, "src_v_chr_pos", in_v_chr_pos, 0);
> -            av_opt_set_int(s, "dst_h_chr_pos", scale->out_h_chr_pos, 0);
> -            av_opt_set_int(s, "dst_v_chr_pos", out_v_chr_pos, 0);
> +            calc_chroma_pos(&h_chr_pos, &v_chr_pos, scale->in_chroma_loc,
> +                            scale->in_h_chr_pos, scale->in_v_chr_pos,
> +                            desc->log2_chroma_w, desc->log2_chroma_h, i);
> +            av_opt_set_int(s, "src_h_chr_pos", h_chr_pos, 0);
> +            av_opt_set_int(s, "src_v_chr_pos", v_chr_pos, 0);
> +
> +            calc_chroma_pos(&h_chr_pos, &v_chr_pos, scale->out_chroma_loc,
> +                            scale->out_h_chr_pos, scale->out_v_chr_pos,
> +                            outdesc->log2_chroma_w, outdesc->log2_chroma_h, i);
> +            av_opt_set_int(s, "dst_h_chr_pos", h_chr_pos, 0);
> +            av_opt_set_int(s, "dst_v_chr_pos", v_chr_pos, 0);
>  
>              if ((ret = sws_init_context(s, NULL, NULL)) < 0)
>                  return ret;
> @@ -987,6 +1002,8 @@ scale:
>      out->height = outlink->h;
>      out->color_range = outlink->color_range;
>      out->colorspace = outlink->colorspace;
> +    if (scale->out_chroma_loc != AVCHROMA_LOC_UNSPECIFIED)
> +        out->chroma_location = scale->out_chroma_loc;
>  
>      if (scale->output_is_pal)
>          avpriv_set_systematic_pal2((uint32_t*)out->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format);
> @@ -1217,6 +1234,16 @@ static const AVOption scale_options[] = {
>      { "mpeg",   NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range" },
>      { "tv",     NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range" },
>      { "pc",     NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range" },
> +    { "in_chroma_loc",  "set input chroma sample location",  OFFSET(in_chroma_loc),  AV_OPT_TYPE_INT, { .i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, .flags = FLAGS, .unit = "chroma_loc" },
> +    { "out_chroma_loc", "set output chroma sample location", OFFSET(out_chroma_loc), AV_OPT_TYPE_INT, { .i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, .flags = FLAGS, .unit = "chroma_loc" },
> +        {"auto",          NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_loc"},
> +        {"unknown",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_loc"},
> +        {"left",          NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_LEFT},        0, 0, FLAGS, .unit = "chroma_loc"},
> +        {"center",        NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_CENTER},      0, 0, FLAGS, .unit = "chroma_loc"},
> +        {"topleft",       NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOPLEFT},     0, 0, FLAGS, .unit = "chroma_loc"},
> +        {"top",           NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP},         0, 0, FLAGS, .unit = "chroma_loc"},
> +        {"bottomleft",    NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT},  0, 0, FLAGS, .unit = "chroma_loc"},
> +        {"bottom",        NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM},      0, 0, FLAGS, .unit = "chroma_loc"},
>      { "in_v_chr_pos",   "input vertical chroma position in luma grid/256"  ,   OFFSET(in_v_chr_pos),  AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
>      { "in_h_chr_pos",   "input horizontal chroma position in luma grid/256",   OFFSET(in_h_chr_pos),  AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
>      { "out_v_chr_pos",   "output vertical chroma position in luma grid/256"  , OFFSET(out_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
> -- 
> 2.45.2
> 
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/6] avfilter/vf_setparams: allow setting chroma location
  2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 2/6] avfilter/vf_setparams: allow setting chroma location Niklas Haas
@ 2024-07-04 15:09   ` Paul B Mahol
  0 siblings, 0 replies; 8+ messages in thread
From: Paul B Mahol @ 2024-07-04 15:09 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Niklas Haas

On Thu, Jul 4, 2024 at 1:54 PM Niklas Haas <ffmpeg@haasn.xyz> wrote:

> From: Niklas Haas <git@haasn.dev>
>
> Shockingly, there isn't currently _any_ filter for overriding this.
> ---
>  doc/filters.texi           | 17 +++++++++++++++++
>  libavfilter/vf_setparams.c | 19 ++++++++++++++++---
>  2 files changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index c9c4f7cf6b..ca8f6e461a 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -22073,6 +22073,23 @@ Keep the same colorspace property (default).
>  @item chroma-derived-c
>  @item ictcp
>  @end table
> +
> +@item chroma_location
> +Set the chroma sample location.
> +Available values are:
> +
> +@table @samp
> +@item auto
> +Keep the same chroma location (default).
> +
> +@item unspecified, unknown
> +@item left
> +@item center
> +@item topleft
> +@item top
> +@item bottomleft
> +@item bottom
> +@end table
>  @end table
>
>  @section sharpen_npp
> diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
> index b7da8eb54b..ba32a6699c 100644
> --- a/libavfilter/vf_setparams.c
> +++ b/libavfilter/vf_setparams.c
> @@ -41,6 +41,7 @@ typedef struct SetParamsContext {
>      int color_primaries;
>      int color_trc;
>      int colorspace;
> +    int chroma_location;
>  } SetParamsContext;
>
>  #define OFFSET(x) offsetof(SetParamsContext, x)
> @@ -119,6 +120,17 @@ static const AVOption setparams_options[] = {
>      {"chroma-derived-c",           NULL,  0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, FLAGS, .unit =
> "colorspace"},
>      {"ictcp",                      NULL,  0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_SPC_ICTCP},             INT_MIN, INT_MAX, FLAGS, .unit =
> "colorspace"},
>      {"ipt-c2",                     NULL,  0, AV_OPT_TYPE_CONST,
> {.i64=AVCOL_SPC_IPT_C2},            INT_MIN, INT_MAX, FLAGS, .unit =
> "colorspace"},
> +
> +    {"chroma_location", "select chroma sample location",
> OFFSET(chroma_location), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCHROMA_LOC_NB-1,
> FLAGS, .unit = "chroma_location"},
> +    {"auto", "keep the same chroma location",  0, AV_OPT_TYPE_CONST,
> {.i64=-1},                       INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"unspecified",                      NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_UNSPECIFIED}, INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"unknown",                          NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_UNSPECIFIED}, INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"left",                             NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_LEFT},        INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"center",                           NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_CENTER},      INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"topleft",                          NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_TOPLEFT},     INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"top",                              NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_TOP},         INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"bottomleft",                       NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_BOTTOMLEFT},  INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
> +    {"bottom",                           NULL, 0, AV_OPT_TYPE_CONST,
> {.i64=AVCHROMA_LOC_BOTTOM},      INT_MIN, INT_MAX, FLAGS, .unit =
> "chroma_location"},
>      {NULL}
>  };
>
>
Why TYPE_CONST options have this cargo cult INT_MIN, INT_MAX propagated
again? I do not remember ever writing such nonsense, at least I remove it
whenever I see it.




> @@ -174,17 +186,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
>              frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
>      }
>
> -    /* set range */
> +    /* set straightforward parameters */
>      if (s->color_range >= 0)
>          frame->color_range = s->color_range;
> -
> -    /* set color prim, trc, space */
>      if (s->color_primaries >= 0)
>          frame->color_primaries = s->color_primaries;
>      if (s->color_trc >= 0)
>          frame->color_trc = s->color_trc;
>      if (s->colorspace >= 0)
>          frame->colorspace = s->colorspace;
> +    if (s->chroma_location >= 0)
> +        frame->chroma_location = s->chroma_location;
> +
>      return ff_filter_frame(ctx->outputs[0], frame);
>  }
>
> --
> 2.45.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-07-04 15:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-04 11:51 [FFmpeg-devel] [PATCH 1/6] swscale: document SWS_FULL_CHR_H_* flags Niklas Haas
2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 2/6] avfilter/vf_setparams: allow setting chroma location Niklas Haas
2024-07-04 15:09   ` Paul B Mahol
2024-07-04 11:51 ` [FFmpeg-devel] [PATCH 3/6] avfilter/swscale: always fix interlaced " Niklas Haas
2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 4/6] avfilter/vf_scale: add in/out_chroma_loc Niklas Haas
2024-07-04 12:52   ` Niklas Haas
2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 5/6] avfilter/vf_zscale: remove unused fields Niklas Haas
2024-07-04 11:52 ` [FFmpeg-devel] [PATCH 6/6] fate/scalechroma: switch to standard chroma location Niklas Haas

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git