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/7] lavu/pixfmt: summarize yuv naming conventions
@ 2022-08-02 16:54 Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 2/7] lavfi/graphdump: add plain listing output Nicolas George
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Nicolas George @ 2022-08-02 16:54 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavutil/pixfmt.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)


Identical to the one I posted last week.


diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 2d3927cc3f..3d0f92ed4d 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -60,6 +60,23 @@
  * For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like
  * for pal8. This palette is filled in automatically by the function
  * allocating the picture.
+ *
+ * @par
+ * Summary of the naming conventions for YUV formats:
+ *    444         422         440         420         411         410
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
+ * where
+ * ┼─┼ = luma pixel  ╋━╋ = chroma pixel
+ * ┼─┼               ╋━╋
+ *
+ * yuv4ab →
+ *  log2_chroma_w = log₂(4/a)
+ *  log2_chroma_h = b == a ? 0 : b == 0 ? log2_chroma_w : unused
+ * i.e. a = horizontally, number of luma pixels for four chroma pixels
  */
 enum AVPixelFormat {
     AV_PIX_FMT_NONE = -1,
-- 
2.35.1

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 2/7] lavfi/graphdump: add plain listing output
  2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
@ 2022-08-02 16:54 ` Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 3/7] fftools: add -lavfi_dump option Nicolas George
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Nicolas George @ 2022-08-02 16:54 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavfilter/avfilter.h  |  5 ++-
 libavfilter/graphdump.c | 79 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 80 insertions(+), 4 deletions(-)


Identical to the one posted months ago.


diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 2e8197c9a6..ad38f1bdc2 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -1163,7 +1163,10 @@ int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const
  * Dump a graph into a human-readable string representation.
  *
  * @param graph    the graph to dump
- * @param options  formatting options; currently ignored
+ * @param options  formatting options; can be NULL, empty
+ *                 or "f=aa" for clumsy ascii-art drawing,
+ *                 or "f=tech" for plain listing;
+ *                 other values silently ignored
  * @return  a string, or NULL in case of memory allocation failure;
  *          the string must be freed using av_free
  */
diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
index 80f7bf6c98..992183a882 100644
--- a/libavfilter/graphdump.c
+++ b/libavfilter/graphdump.c
@@ -27,6 +27,9 @@
 #include "avfilter.h"
 #include "internal.h"
 
+#define FORMAT_AA 0
+#define FORMAT_TECH 1
+
 static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
 {
     const char *format;
@@ -62,7 +65,51 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
     return buf->len;
 }
 
-static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph)
+static inline const char *fcname(const AVFilterContext *filter)
+{
+    return filter->name ? filter->name : "<unnamed>";
+}
+
+static void dump_tech(AVBPrint *buf, AVFilterGraph *graph)
+{
+    unsigned i, j;
+
+    for (i = 0; i < graph->nb_filters; i++) {
+        AVFilterContext *filter = graph->filters[i];
+
+        if (i)
+            av_bprintf(buf, "\n");
+        av_bprintf(buf, "Filter: %s (%s)\n", fcname(filter), filter->filter->name);
+
+        for (j = 0; j < filter->nb_inputs; j++) {
+            AVFilterPad *pad = &filter->input_pads[j];
+            AVFilterLink *link = filter->inputs[j];
+            AVFilterPad *ppad = link->srcpad;
+            AVFilterContext *peer = link->src;
+
+            av_bprintf(buf, "  in %d: %s ← %s.%d:%s ",
+                       j, pad->name,
+                       fcname(peer), FF_OUTLINK_IDX(link), ppad->name);
+            print_link_prop(buf, link);
+            av_bprintf(buf, "\n");
+        }
+
+        for (j = 0; j < filter->nb_outputs; j++) {
+            AVFilterPad *pad = &filter->output_pads[j];
+            AVFilterLink *link = filter->outputs[j];
+            AVFilterPad *ppad = link->dstpad;
+            AVFilterContext *peer = link->dst;
+
+            av_bprintf(buf, "  out %d: %s → %s.%d:%s ",
+                       j, pad->name,
+                       fcname(peer), FF_INLINK_IDX(link), ppad->name);
+            print_link_prop(buf, link);
+            av_bprintf(buf, "\n");
+        }
+    }
+}
+
+static void dump_ascii_art(AVBPrint *buf, AVFilterGraph *graph)
 {
     unsigned i, j, x, e;
 
@@ -154,17 +201,43 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph)
     }
 }
 
+static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph, const char *options)
+{
+    unsigned format = FORMAT_AA;
+
+    /* For a very long time, options was ignored.
+       Having a string for that task was a mistake, but it is not important.
+       It is not worth a proper parsing.
+     */
+    if (options && *options) {
+        if (!strcmp("f=aa", options)) {
+            format = FORMAT_AA;
+        } else if (!strcmp("f=tech", options)) {
+            format = FORMAT_TECH;
+        }
+        /* ignore other values */
+    }
+    switch (format) {
+    case FORMAT_AA:
+        dump_ascii_art(buf, graph);
+        break;
+    case FORMAT_TECH:
+        dump_tech(buf, graph);
+        break;
+    }
+}
+
 char *avfilter_graph_dump(AVFilterGraph *graph, const char *options)
 {
     AVBPrint buf;
     char *dump = NULL;
 
     av_bprint_init(&buf, 0, AV_BPRINT_SIZE_COUNT_ONLY);
-    avfilter_graph_dump_to_buf(&buf, graph);
+    avfilter_graph_dump_to_buf(&buf, graph, options);
     dump = av_malloc(buf.len + 1);
     if (!dump)
         return NULL;
     av_bprint_init_for_buffer(&buf, dump, buf.len + 1);
-    avfilter_graph_dump_to_buf(&buf, graph);
+    avfilter_graph_dump_to_buf(&buf, graph, options);
     return dump;
 }
-- 
2.35.1

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 3/7] fftools: add -lavfi_dump option
  2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 2/7] lavfi/graphdump: add plain listing output Nicolas George
@ 2022-08-02 16:54 ` Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 4/7] lavfi/(a)format: factor finding the delimiter Nicolas George
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Nicolas George @ 2022-08-02 16:54 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Nicolas George <george@nsup.org>
---
 doc/ffmpeg.texi         |  4 ++++
 fftools/ffmpeg.h        |  1 +
 fftools/ffmpeg_filter.c | 14 ++++++++++++++
 fftools/ffmpeg_opt.c    |  3 +++
 4 files changed, 22 insertions(+)


Identical to the one posted months ago.


diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 2fb0bc8ffa..1a342846c2 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1902,6 +1902,10 @@ The default is the number of available CPUs.
 Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
 outputs. Equivalent to @option{-filter_complex}.
 
+@anchor{lavfi_dump option}
+@item -lavfi_dump (@emph{global})
+Dump the filter graphs and their negotiated formats to standard output.
+
 @item -filter_complex_script @var{filename} (@emph{global})
 This option is similar to @option{-filter_complex}, the only difference is that
 its argument is the name of the file from which a complex filtergraph
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6417db03bd..d2ec8ea257 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -654,6 +654,7 @@ extern char *filter_nbthreads;
 extern int filter_complex_nbthreads;
 extern int vstats_version;
 extern int auto_conversion_filters;
+extern int dump_filtergraphs;
 
 extern const AVIOInterruptCB int_cb;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index f9ae76f76d..973de34b5f 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1070,6 +1070,20 @@ int configure_filtergraph(FilterGraph *fg)
         avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);
     if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
         goto fail;
+    if (dump_filtergraphs) {
+        char *dump = avfilter_graph_dump(fg->graph, "f=tech");
+        if (!dump)
+            return AVERROR(ENOMEM);
+        if (simple) {
+            OutputStream *ost = fg->outputs[0]->ost;
+            printf("Dump of filter graph for output #%d:%d:", ost->file_index, ost->index);
+        } else {
+            printf("Dump of complex filter graph #%d:", fg->index);
+        }
+        printf("\n\n%s\n", dump);
+        av_free(dump);
+        fflush(stdout);
+    }
 
     fg->is_meta = graph_is_meta(fg->graph);
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index a96bcf9b8a..6404412f5a 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -178,6 +178,7 @@ char *filter_nbthreads;
 int filter_complex_nbthreads = 0;
 int vstats_version = 2;
 int auto_conversion_filters = 1;
+int dump_filtergraphs = 0;
 int64_t stats_period = 500000;
 
 
@@ -3947,6 +3948,8 @@ const OptionDef options[] = {
         "number of threads for -filter_complex" },
     { "lavfi",          HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_filter_complex },
         "create a complex filtergraph", "graph_description" },
+    { "lavfi_dump",     OPT_BOOL | OPT_EXPERT,                       { &dump_filtergraphs },
+        "dump filter graphs to standard output" },
     { "filter_complex_script", HAS_ARG | OPT_EXPERT,                 { .func_arg = opt_filter_complex_script },
         "read complex filtergraph description from a file", "filename" },
     { "auto_conversion_filters", OPT_BOOL | OPT_EXPERT,              { &auto_conversion_filters },
-- 
2.35.1

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 4/7] lavfi/(a)format: factor finding the delimiter
  2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 2/7] lavfi/graphdump: add plain listing output Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 3/7] fftools: add -lavfi_dump option Nicolas George
@ 2022-08-02 16:54 ` Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 5/7] lavfi/(a)format: support slash as a delimiter Nicolas George
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Nicolas George @ 2022-08-02 16:54 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavfilter/af_aformat.c | 8 +++++---
 libavfilter/internal.h   | 9 +++++++++
 libavfilter/vf_format.c  | 9 ++++-----
 3 files changed, 18 insertions(+), 8 deletions(-)


Identical to the one posted months ago.


diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index a14e4c1240..addabafbfa 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -65,10 +65,12 @@ do {                                                                        \
     char *next, *cur = str;                                                 \
     int ret;                                                                \
                                                                             \
-    while (cur) {                                                           \
+    if (!cur)                                                               \
+        break;                                                              \
+    while (*cur) {                                                          \
         type fmt;                                                           \
-        next = strchr(cur, '|');                                            \
-        if (next)                                                           \
+        next = ff_formats_list_find_delimiter(cur);                         \
+        if (*next)                                                          \
             *next++ = 0;                                                    \
                                                                             \
         if ((fmt = get_fmt(cur)) == none) {                                 \
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 0f8da367d0..6dbe7ecee0 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -405,4 +405,13 @@ int ff_filter_process_command(AVFilterContext *ctx, const char *cmd,
 int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
                              int default_pool_size);
 
+/**
+ * Find the next delimiter in a string of formats.
+ * The delimiter is '|' or the end of the string.
+ */
+static inline char *ff_formats_list_find_delimiter(const char *str)
+{
+    return (char *)str + strcspn(str, "|");
+}
+
 #endif /* AVFILTER_INTERNAL_H */
diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c
index 24b1c9ca61..b3f168a531 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -69,10 +69,9 @@ static av_cold int init(AVFilterContext *ctx)
 
     /* count the formats */
     cur = s->pix_fmts;
-    while ((cur = strchr(cur, '|'))) {
+    while (*(cur = ff_formats_list_find_delimiter(cur))) {
         nb_formats++;
-        if (*cur)
-            cur++;
+        cur++;
     }
 
     s->formats = av_malloc_array(nb_formats + 1, sizeof(*s->formats));
@@ -82,8 +81,8 @@ static av_cold int init(AVFilterContext *ctx)
     /* parse the list of formats */
     cur = s->pix_fmts;
     for (i = 0; i < nb_formats; i++) {
-        sep = strchr(cur, '|');
-        if (sep)
+        sep = ff_formats_list_find_delimiter(cur);
+        if (*sep)
             *sep++ = 0;
 
         if ((ret = ff_parse_pixel_format(&s->formats[i], cur, ctx)) < 0)
-- 
2.35.1

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 5/7] lavfi/(a)format: support slash as a delimiter
  2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
                   ` (2 preceding siblings ...)
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 4/7] lavfi/(a)format: factor finding the delimiter Nicolas George
@ 2022-08-02 16:54 ` Nicolas George
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring Nicolas George
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Nicolas George @ 2022-08-02 16:54 UTC (permalink / raw)
  To: ffmpeg-devel

Unlike pipe, slash does not require escaping.

Signed-off-by: Nicolas George <george@nsup.org>
---
 doc/filters.texi       | 8 ++++----
 libavfilter/internal.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)


Identical to the one posted months ago.


diff --git a/doc/filters.texi b/doc/filters.texi
index 4a5412c91d..e334ac0e16 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1693,13 +1693,13 @@ It accepts the following parameters:
 @table @option
 
 @item sample_fmts, f
-A '|'-separated list of requested sample formats.
+A '|'- or '/'-separated list of requested sample formats.
 
 @item sample_rates, r
-A '|'-separated list of requested sample rates.
+A '|'- or '/'-separated list of requested sample rates.
 
 @item channel_layouts, cl
-A '|'-separated list of requested channel layouts.
+A '|'- or '/'-separated list of requested channel layouts.
 
 See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
 for the required syntax.
@@ -13379,7 +13379,7 @@ It accepts the following parameters:
 @table @option
 
 @item pix_fmts
-A '|'-separated list of pixel format names, such as
+A '|'- or '/'-separated list of pixel format names, such as
 "pix_fmts=yuv420p|monow|rgb24".
 
 @end table
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 6dbe7ecee0..cfb748f7db 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -411,7 +411,7 @@ int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
  */
 static inline char *ff_formats_list_find_delimiter(const char *str)
 {
-    return (char *)str + strcspn(str, "|");
+    return (char *)str + strcspn(str, "|/");
 }
 
 #endif /* AVFILTER_INTERNAL_H */
-- 
2.35.1

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring
  2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
                   ` (3 preceding siblings ...)
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 5/7] lavfi/(a)format: support slash as a delimiter Nicolas George
@ 2022-08-02 16:54 ` Nicolas George
  2022-08-04 13:52   ` Michael Niedermayer
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 7/7] tests: add coverage for libavfilter's format negotiation Nicolas George
  2022-08-04 13:49 ` [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Michael Niedermayer
  6 siblings, 1 reply; 12+ messages in thread
From: Nicolas George @ 2022-08-02 16:54 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavutil/pixdesc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 6e57a82cb6..923a61b0ab 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2866,6 +2866,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
     else
         nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
 
+    // Penalty for losing depth
     for (i = 0; i < nb_components; i++) {
         int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : (dst_desc->comp[i].depth - 1);
         if (src_desc->comp[i].depth - 1 > depth_minus1 && (consider & FF_LOSS_DEPTH)) {
@@ -2874,6 +2875,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
         }
     }
 
+    // Penalty for subsampling
     if (consider & FF_LOSS_RESOLUTION) {
         if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) {
             loss |= FF_LOSS_RESOLUTION;
@@ -2890,6 +2892,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
         }
     }
 
+    // Penalty for changing colorspace
     if(consider & FF_LOSS_COLORSPACE)
     switch(dst_color) {
     case FF_COLOR_RGB:
@@ -2920,15 +2923,18 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
     if(loss & FF_LOSS_COLORSPACE)
         score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth - 1, src_desc->comp[0].depth - 1);
 
+    // Penalty for changing chroma
     if (dst_color == FF_COLOR_GRAY &&
         src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) {
         loss |= FF_LOSS_CHROMA;
         score -= 2 * 65536;
     }
+    // Penalty for losing alpha
     if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) {
         loss |= FF_LOSS_ALPHA;
         score -= 65536;
     }
+    // Penalty for using a palette
     if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) &&
         (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) {
         loss |= FF_LOSS_COLORQUANT;
-- 
2.35.1

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 7/7] tests: add coverage for libavfilter's format negotiation
  2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
                   ` (4 preceding siblings ...)
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring Nicolas George
@ 2022-08-02 16:54 ` Nicolas George
  2022-08-04 13:49 ` [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Michael Niedermayer
  6 siblings, 0 replies; 12+ messages in thread
From: Nicolas George @ 2022-08-02 16:54 UTC (permalink / raw)
  To: ffmpeg-devel

Added coverage for the video part of pick_format().

Signed-off-by: Nicolas George <george@nsup.org>
---


Only video for now, I would like to push before working on audio.
Audio is easier because there are fewer formats.
But audio is also harder because I need to test cases where format
incompatibilities detected in two places for different aspects.

Once I have good coverage, I can reorganise the negotiation process
without risking breaking cases that were previously fixed.

Note: the tests are very fast, since they only init the graph and do not
filter anything.


 tests/Makefile                                |  1 +
 tests/fate-run.sh                             |  4 +
 tests/fate/libavfilter.mak                    | 86 +++++++++++++++++++
 tests/ref/fate/libavfilter-negotiation-alpha  | 20 +++++
 ...avfilter-negotiation-alpha-over-chroma-rgb | 20 +++++
 ...avfilter-negotiation-alpha-over-chroma-yuv | 20 +++++
 .../libavfilter-negotiation-avoid-subsample   | 20 +++++
 .../fate/libavfilter-negotiation-chroma-rgb   | 20 +++++
 .../fate/libavfilter-negotiation-chroma-yuv   | 20 +++++
 .../libavfilter-negotiation-chroma-yuv420     | 20 +++++
 ...ibavfilter-negotiation-chroma1-over-depth1 | 20 +++++
 ...ilter-negotiation-chroma2-over-colorspace8 | 20 +++++
 ...libavfilter-negotiation-colorspace-rgb-yuv | 20 +++++
 ...libavfilter-negotiation-colorspace-yuv-rgb | 20 +++++
 ...vfilter-negotiation-colorspace8-over-alpha | 20 +++++
 .../fate/libavfilter-negotiation-depth-rgb    | 20 +++++
 .../fate/libavfilter-negotiation-depth-yuv    | 20 +++++
 ...libavfilter-negotiation-depth1-over-depth2 | 20 +++++
 .../libavfilter-negotiation-depth2-over-alpha | 20 +++++
 .../fate/libavfilter-negotiation-palette-rgb  | 20 +++++
 .../fate/libavfilter-negotiation-palette-yuv  | 20 +++++
 21 files changed, 451 insertions(+)
 create mode 100644 tests/fate/libavfilter.mak
 create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha
 create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-avoid-subsample
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma-yuv420
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma1-over-depth1
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma2-over-colorspace8
 create mode 100644 tests/ref/fate/libavfilter-negotiation-colorspace-rgb-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-colorspace-yuv-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-colorspace8-over-alpha
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth1-over-depth2
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth2-over-alpha
 create mode 100644 tests/ref/fate/libavfilter-negotiation-palette-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-palette-yuv

diff --git a/tests/Makefile b/tests/Makefile
index d9c509a415..c4e01a26e9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -202,6 +202,7 @@ include $(SRC_PATH)/tests/fate/imf.mak
 include $(SRC_PATH)/tests/fate/indeo.mak
 include $(SRC_PATH)/tests/fate/libavcodec.mak
 include $(SRC_PATH)/tests/fate/libavdevice.mak
+include $(SRC_PATH)/tests/fate/libavfilter.mak
 include $(SRC_PATH)/tests/fate/libavformat.mak
 include $(SRC_PATH)/tests/fate/libavutil.mak
 include $(SRC_PATH)/tests/fate/libswresample.mak
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 4008bcbc16..53dcbb563b 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -571,6 +571,10 @@ venc_data(){
     run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type}
 }
 
+lavfi_dump(){
+    run ffmpeg${PROGSUF}${EXECSUF} -lavfi_dump -lavfi "$@" -f null -
+}
+
 null(){
     :
 }
diff --git a/tests/fate/libavfilter.mak b/tests/fate/libavfilter.mak
new file mode 100644
index 0000000000..b7d3786942
--- /dev/null
+++ b/tests/fate/libavfilter.mak
@@ -0,0 +1,86 @@
+NEGO_PIXFMT = lavfi_dump  testsrc2=d=0,format=$(1),scale,format=$(2)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : losing alpha
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha
+fate-libavfilter-negotiation-alpha: CMD = $(call NEGO_PIXFMT,rgba,yuv444p/yuva444p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : subsampling
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-avoid-subsample
+fate-libavfilter-negotiation-avoid-subsample: CMD = $(call NEGO_PIXFMT,yuv444p,yuv420p10le/yuva444p10le)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : losing depth (yuv)
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-depth-yuv
+fate-libavfilter-negotiation-depth-yuv: CMD = $(call NEGO_PIXFMT,yuv444p10le,yuv444p9le/yuva444p12le)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : losing depth (rgb)
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-depth-rgb
+fate-libavfilter-negotiation-depth-rgb: CMD = $(call NEGO_PIXFMT,rgb24,rgb555le/rgb48le)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : changing colorspace (yuv → rgb)
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-colorspace-yuv-rgb
+fate-libavfilter-negotiation-colorspace-yuv-rgb: CMD = $(call NEGO_PIXFMT,yuv444p,rgb24/yuv444p9)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : changing colorspace (rgb → yuv)
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-colorspace-rgb-yuv
+fate-libavfilter-negotiation-colorspace-rgb-yuv: CMD = $(call NEGO_PIXFMT,rgb24,yuv444p/rgb0)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : losing chroma (yuv)
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-chroma-yuv
+fate-libavfilter-negotiation-chroma-yuv: CMD = $(call NEGO_PIXFMT,yuv444p,gray8/rgb24)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : losing chroma (rgb)
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-chroma-rgb
+fate-libavfilter-negotiation-chroma-rgb: CMD = $(call NEGO_PIXFMT,rgb24,gray8/yuv444p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : avoid palette (yuv)
+# FIXME yuv → pal8 always loses depth
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-palette-yuv
+fate-libavfilter-negotiation-palette-yuv: CMD = $(call NEGO_PIXFMT,yuv444p,pal8/rgb24)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : avoid palette (rgb)
+# FIXME rgb → pal8 always loses depth
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-palette-rgb
+fate-libavfilter-negotiation-palette-rgb: CMD = $(call NEGO_PIXFMT,rgb24,pal8/yuv444p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : yuv420 exception
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-chroma-yuv420
+fate-libavfilter-negotiation-chroma-yuv420: CMD = $(call NEGO_PIXFMT,yuv444p,yuv422p/yuv420p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : chroma subsampling -1 > depth -1
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-chroma1-over-depth1
+fate-libavfilter-negotiation-chroma1-over-depth1: CMD = $(call NEGO_PIXFMT,yuv444p10le,yuv444p9le/yuv440p10le)
+
+# FIXME depth -1 > chroma subsampling -2 → impossible to test without triggering the exception for 420
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : depth -1 > depth -2
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-depth1-over-depth2
+fate-libavfilter-negotiation-depth1-over-depth2: CMD = $(call NEGO_PIXFMT,yuv444p10le,yuv444p/yuv444p9le)
+
+# FIXME chroma subsampling -2 > depth -2 → impossible to test without triggering the exception for 420
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : chroma subsampling -2 > colorspace 8
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-chroma2-over-colorspace8
+fate-libavfilter-negotiation-chroma2-over-colorspace8: CMD = $(call NEGO_PIXFMT,yuv444p,rgb24/yuv411p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : depth -2 > lose alpha
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-depth2-over-alpha
+fate-libavfilter-negotiation-depth2-over-alpha: CMD = $(call NEGO_PIXFMT,yuva444p10le,yuv444p10le/yuva444p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : colorspace 8 > lose alpha
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-colorspace8-over-alpha
+fate-libavfilter-negotiation-colorspace8-over-alpha: CMD = $(call NEGO_PIXFMT,yuva444p,yuv444p/rgba)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : lose alpha > lose chroma
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha-over-chroma-yuv
+fate-libavfilter-negotiation-alpha-over-chroma-yuv: CMD = $(call NEGO_PIXFMT,yuva444p,gray8a/yuv444p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : lose alpha > lose chroma
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha-over-chroma-rgb
+fate-libavfilter-negotiation-alpha-over-chroma-rgb: CMD = $(call NEGO_PIXFMT,rgba,gray8a/rgb24)
+
+FATE_LIBAVFILTER_NEGOTIATION-$(call ALLYES, TESTSRC2_FILTER FORMAT_FILTER SCALE_FILTER) += $(FATE_LIBAVFILTER_NEGOTIATION_VIDEO)
+FATE_LIBAVFILTER-yes += $(FATE_LIBAVFILTER_NEGOTIATION-yes)
+
+fate-libavfilter: $(FATE_LIBAVFILTER-yes)
+fate-libavfilter-negotiation: $(FATE_LIBAVFILTER_NEGOTIATION-yes)
+FATE_FFMPEG += $(FATE_LIBAVFILTER-yes)
diff --git a/tests/ref/fate/libavfilter-negotiation-alpha b/tests/ref/fate/libavfilter-negotiation-alpha
new file mode 100644
index 0000000000..00175f65cb
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-alpha
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgba]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgba]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgba]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgba]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuva444p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuva444p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuva444p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuva444p]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-rgb b/tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-rgb
new file mode 100644
index 0000000000..38d4670ac4
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-rgb
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgba]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgba]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgba]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgba]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 rgb24]
+  out 0: default → out_0_0.0:default [320x240 1:1 rgb24]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 rgb24]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-yuv b/tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-yuv
new file mode 100644
index 0000000000..fecb493f88
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-yuv
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuva444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuva444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuva444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuva444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv444p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv444p]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-avoid-subsample b/tests/ref/fate/libavfilter-negotiation-avoid-subsample
new file mode 100644
index 0000000000..eafb6f04b2
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-avoid-subsample
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuva444p10le]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuva444p10le]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuva444p10le]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuva444p10le]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-chroma-rgb b/tests/ref/fate/libavfilter-negotiation-chroma-rgb
new file mode 100644
index 0000000000..f317cc85cd
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-chroma-rgb
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv444p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv444p]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-chroma-yuv b/tests/ref/fate/libavfilter-negotiation-chroma-yuv
new file mode 100644
index 0000000000..ff3e54aa84
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-chroma-yuv
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 rgb24]
+  out 0: default → out_0_0.0:default [320x240 1:1 rgb24]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 rgb24]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-chroma-yuv420 b/tests/ref/fate/libavfilter-negotiation-chroma-yuv420
new file mode 100644
index 0000000000..f93f15d1b1
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-chroma-yuv420
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv420p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv420p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv420p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv420p]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-chroma1-over-depth1 b/tests/ref/fate/libavfilter-negotiation-chroma1-over-depth1
new file mode 100644
index 0000000000..01e3e0df56
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-chroma1-over-depth1
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p10le]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p10le]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p10le]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p10le]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv440p10le]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv440p10le]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv440p10le]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv440p10le]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-chroma2-over-colorspace8 b/tests/ref/fate/libavfilter-negotiation-chroma2-over-colorspace8
new file mode 100644
index 0000000000..9c78d1cf94
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-chroma2-over-colorspace8
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv411p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv411p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv411p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv411p]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-colorspace-rgb-yuv b/tests/ref/fate/libavfilter-negotiation-colorspace-rgb-yuv
new file mode 100644
index 0000000000..8e69fb572a
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-colorspace-rgb-yuv
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 rgb0]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 rgb0]
+  out 0: default → out_0_0.0:default [320x240 1:1 rgb0]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 rgb0]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-colorspace-yuv-rgb b/tests/ref/fate/libavfilter-negotiation-colorspace-yuv-rgb
new file mode 100644
index 0000000000..00a4b25599
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-colorspace-yuv-rgb
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv444p9le]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv444p9le]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv444p9le]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv444p9le]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-colorspace8-over-alpha b/tests/ref/fate/libavfilter-negotiation-colorspace8-over-alpha
new file mode 100644
index 0000000000..7376f40526
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-colorspace8-over-alpha
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuva444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuva444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuva444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuva444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 rgba]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 rgba]
+  out 0: default → out_0_0.0:default [320x240 1:1 rgba]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 rgba]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-depth-rgb b/tests/ref/fate/libavfilter-negotiation-depth-rgb
new file mode 100644
index 0000000000..aa8c9a3a5c
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-depth-rgb
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 rgb48le]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 rgb48le]
+  out 0: default → out_0_0.0:default [320x240 1:1 rgb48le]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 rgb48le]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-depth-yuv b/tests/ref/fate/libavfilter-negotiation-depth-yuv
new file mode 100644
index 0000000000..b4570fbd22
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-depth-yuv
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p10le]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p10le]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p10le]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p10le]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuva444p12le]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuva444p12le]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuva444p12le]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuva444p12le]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-depth1-over-depth2 b/tests/ref/fate/libavfilter-negotiation-depth1-over-depth2
new file mode 100644
index 0000000000..dc6aff0817
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-depth1-over-depth2
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p10le]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p10le]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p10le]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p10le]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv444p9le]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv444p9le]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv444p9le]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv444p9le]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-depth2-over-alpha b/tests/ref/fate/libavfilter-negotiation-depth2-over-alpha
new file mode 100644
index 0000000000..96867239f8
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-depth2-over-alpha
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuva444p10le]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuva444p10le]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuva444p10le]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuva444p10le]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuva444p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuva444p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuva444p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuva444p]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-palette-rgb b/tests/ref/fate/libavfilter-negotiation-palette-rgb
new file mode 100644
index 0000000000..f317cc85cd
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-palette-rgb
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgb24]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuv444p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuv444p]
+
diff --git a/tests/ref/fate/libavfilter-negotiation-palette-yuv b/tests/ref/fate/libavfilter-negotiation-palette-yuv
new file mode 100644
index 0000000000..ff3e54aa84
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-palette-yuv
@@ -0,0 +1,20 @@
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 yuv444p]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 yuv444p]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 rgb24]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 rgb24]
+  out 0: default → out_0_0.0:default [320x240 1:1 rgb24]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 rgb24]
+
-- 
2.35.1

_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions
  2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
                   ` (5 preceding siblings ...)
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 7/7] tests: add coverage for libavfilter's format negotiation Nicolas George
@ 2022-08-04 13:49 ` Michael Niedermayer
  2022-08-04 13:57   ` Nicolas George
  6 siblings, 1 reply; 12+ messages in thread
From: Michael Niedermayer @ 2022-08-04 13:49 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 2819 bytes --]

On Tue, Aug 02, 2022 at 06:54:15PM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  libavutil/pixfmt.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> 
> Identical to the one I posted last week.
> 
> 
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index 2d3927cc3f..3d0f92ed4d 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -60,6 +60,23 @@
>   * For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like
>   * for pal8. This palette is filled in automatically by the function
>   * allocating the picture.
> + *
> + * @par
> + * Summary of the naming conventions for YUV formats:
> + *    444         422         440         420         411         410
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
> + * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
> + * where
> + * ┼─┼ = luma pixel  ╋━╋ = chroma pixel
> + * ┼─┼               ╋━╋
> + *
> + * yuv4ab →
> + *  log2_chroma_w = log₂(4/a)
> + *  log2_chroma_h = b == a ? 0 : b == 0 ? log2_chroma_w : unused
> + * i.e. a = horizontally, number of luma pixels for four chroma pixels
>   */

You seem to describe samples as rectangular areas of constant value IIUC.
If you look at the ITU/ISO specs (mpeg2, h264 or others) they are described
by point samples. The desity of samples matches. While the default locations
do not.
What you list above are where probably most sane people would place the
samples. But ISO/ITU, probably because of historic TV standard reasons and
interlacing convertion reasons place the chroma samples in a more crooked way
I think either the ascii art should be adapted or the text should clarify
this difference

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring
  2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring Nicolas George
@ 2022-08-04 13:52   ` Michael Niedermayer
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Niedermayer @ 2022-08-04 13:52 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 446 bytes --]

On Tue, Aug 02, 2022 at 06:54:20PM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  libavutil/pixdesc.c | 6 ++++++
>  1 file changed, 6 insertions(+)

probably ok

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions
  2022-08-04 13:49 ` [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Michael Niedermayer
@ 2022-08-04 13:57   ` Nicolas George
  2022-08-04 15:04     ` Michael Niedermayer
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas George @ 2022-08-04 13:57 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 872 bytes --]

Michael Niedermayer (12022-08-04):
> You seem to describe samples as rectangular areas of constant value IIUC.
> If you look at the ITU/ISO specs (mpeg2, h264 or others) they are described
> by point samples. The desity of samples matches. While the default locations
> do not.
> What you list above are where probably most sane people would place the
> samples. But ISO/ITU, probably because of historic TV standard reasons and
> interlacing convertion reasons place the chroma samples in a more crooked way
> I think either the ascii art should be adapted or the text should clarify
> this difference

I am not sure what exactly you explain.

The picture represents memory cells and how we think of them when we
implement generic functions, for example cropping or drawutils. Do we
need to fix all this code somehow?

Regards,

-- 
  Nicolas George

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions
  2022-08-04 13:57   ` Nicolas George
@ 2022-08-04 15:04     ` Michael Niedermayer
  2022-08-06 10:36       ` Nicolas George
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Niedermayer @ 2022-08-04 15:04 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 2061 bytes --]

On Thu, Aug 04, 2022 at 03:57:27PM +0200, Nicolas George wrote:
> Michael Niedermayer (12022-08-04):
> > You seem to describe samples as rectangular areas of constant value IIUC.
> > If you look at the ITU/ISO specs (mpeg2, h264 or others) they are described
> > by point samples. The desity of samples matches. While the default locations
> > do not.
> > What you list above are where probably most sane people would place the
> > samples. But ISO/ITU, probably because of historic TV standard reasons and
> > interlacing convertion reasons place the chroma samples in a more crooked way
> > I think either the ascii art should be adapted or the text should clarify
> > this difference
> 
> I am not sure what exactly you explain.

What i meant is what is also in AVChromaLocation
The chroma sample locations are shifted from where one would expect


> 
> The picture represents memory cells and how we think of them when we
> implement generic functions, for example cropping or drawutils. Do we
> need to fix all this code somehow?

I suspect several filters are somewhat "wrong"
for example hflip fliping 4:1:1
would turn a:   *--- into ---*
where * is teh chroma sample location, i dont think it updates the chroma
sample location metadata nor does it apply some filter to chroma to shift by
3/4 samples. so it looks wrong, one of the 2 is neeed.

vf_scale contains some code to handle this but iam not seeing code considering
the input and output frames chroma location metadata

All this leads to small errors, often probably not vissible
when you have one one chroma sample for 4 luma samples you will always have
some artifacts on sharp color edges, if the location of the chroma sample
is wrong the artifact would be more to one side of a diagonal edge than the
other. If the locations are correct it should be more symmetric in theory.

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions
  2022-08-04 15:04     ` Michael Niedermayer
@ 2022-08-06 10:36       ` Nicolas George
  0 siblings, 0 replies; 12+ messages in thread
From: Nicolas George @ 2022-08-06 10:36 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1179 bytes --]

Michael Niedermayer (12022-08-04):
> I suspect several filters are somewhat "wrong"
> for example hflip fliping 4:1:1
> would turn a:   *--- into ---*
> where * is teh chroma sample location, i dont think it updates the chroma
> sample location metadata nor does it apply some filter to chroma to shift by
> 3/4 samples. so it looks wrong, one of the 2 is neeed.
> 
> vf_scale contains some code to handle this but iam not seeing code considering
> the input and output frames chroma location metadata
> 
> All this leads to small errors, often probably not vissible
> when you have one one chroma sample for 4 luma samples you will always have
> some artifacts on sharp color edges, if the location of the chroma sample
> is wrong the artifact would be more to one side of a diagonal edge than the
> other. If the locations are correct it should be more symmetric in theory.

I think I understand. Would it be ok to apply this with the added
comment:

* Note: this is a quick mnemonic representation of the pixels; actual
* interaction between chroma and luma is more complex, see
* AVChromaLocation in pixfmt.h.

?

Regards,

-- 
  Nicolas George

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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] 12+ messages in thread

end of thread, other threads:[~2022-08-06 10:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 2/7] lavfi/graphdump: add plain listing output Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 3/7] fftools: add -lavfi_dump option Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 4/7] lavfi/(a)format: factor finding the delimiter Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 5/7] lavfi/(a)format: support slash as a delimiter Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring Nicolas George
2022-08-04 13:52   ` Michael Niedermayer
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 7/7] tests: add coverage for libavfilter's format negotiation Nicolas George
2022-08-04 13:49 ` [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Michael Niedermayer
2022-08-04 13:57   ` Nicolas George
2022-08-04 15:04     ` Michael Niedermayer
2022-08-06 10:36       ` Nicolas George

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