diff mbox series

[FFmpeg-devel,16/25] avfilter/vf_format: allow empty pix_fmts list

Message ID 20231109122534.124157-17-ffmpeg@haasn.xyz
State New
Headers show
Series YUVJ removal + filter negotiation | expand

Commit Message

Niklas Haas Nov. 9, 2023, 12:19 p.m. UTC
From: Niklas Haas <git@haasn.dev>

Which will impose no restriction. This makes sense when using e.g.
`color_ranges=pc` to limit the color range, without also limiting the
pixel format.
---
 libavfilter/vf_format.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Anton Khirnov Dec. 13, 2023, 11:38 a.m. UTC | #1
Quoting Niklas Haas (2023-11-09 13:19:48)
> From: Niklas Haas <git@haasn.dev>
> 
> Which will impose no restriction. This makes sense when using e.g.
> `color_ranges=pc` to limit the color range, without also limiting the
> pixel format.
> ---
>  libavfilter/vf_format.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)

Looks ok
diff mbox series

Patch

diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c
index d1bb9daa97..3a353bbb0d 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -91,11 +91,6 @@  static av_cold int init(AVFilterContext *ctx)
     enum AVPixelFormat pix_fmt;
     int ret;
 
-    if (!s->pix_fmts) {
-        av_log(ctx, AV_LOG_ERROR, "Empty output format string.\n");
-        return AVERROR(EINVAL);
-    }
-
     for (char *sep, *cur = s->pix_fmts; cur; cur = sep) {
         sep = strchr(cur, '|');
         if (sep && *sep)
@@ -131,7 +126,7 @@  static av_cold int init(AVFilterContext *ctx)
     }
 
     /* hold on to a ref for the lifetime of the filter */
-    if ((ret = ff_formats_ref(s->formats, &s->formats)) < 0 ||
+    if (s->formats      && (ret = ff_formats_ref(s->formats,      &s->formats)) < 0 ||
         s->color_spaces && (ret = ff_formats_ref(s->color_spaces, &s->color_spaces)) < 0 ||
         s->color_ranges && (ret = ff_formats_ref(s->color_ranges, &s->color_ranges)) < 0)
         return ret;
@@ -144,7 +139,7 @@  static int query_formats(AVFilterContext *ctx)
     FormatContext *s = ctx->priv;
     int ret;
 
-    if ((ret = ff_set_common_formats(ctx, s->formats)) < 0 ||
+    if (s->formats      && (ret = ff_set_common_formats(ctx,      s->formats)) < 0 ||
         s->color_spaces && (ret = ff_set_common_color_spaces(ctx, s->color_spaces)) < 0 ||
         s->color_ranges && (ret = ff_set_common_color_ranges(ctx, s->color_ranges)) < 0)
         return ret;