[FFmpeg-cvslog] avfilter/buffersrc: allow promoting color range to MPEG
Niklas Haas
git at videolan.org
Tue Feb 13 20:44:24 EET 2024
ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Fri Jan 12 09:16:16 2024 +0100| [d2ae2aad8c6731ea5a5e6a4891fbb4fe17a77665] | committer: Niklas Haas
avfilter/buffersrc: allow promoting color range to MPEG
Otherwise, passing an UNSPECIFIED frame to am MPEG-only filter graph
would trigger insertion of an unnecessary vf_scale filter, which would
perform a memcpy to convert between the two.
This is safe to do because unspecified YUV frames are already
universally assumed to be MPEG range, in particular by swscale.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d2ae2aad8c6731ea5a5e6a4891fbb4fe17a77665
---
libavfilter/buffersrc.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 93fadab65f..a6a000df1e 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -506,8 +506,14 @@ static int query_formats(AVFilterContext *ctx)
if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 ||
(ret = ff_set_common_color_spaces(ctx, color_spaces)) < 0)
return ret;
- if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0 ||
- (ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0)
+ if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0)
+ return ret;
+ if (c->color_range == AVCOL_RANGE_UNSPECIFIED) {
+ /* allow implicitly promoting unspecified to mpeg */
+ if ((ret = ff_add_format(&color_ranges, AVCOL_RANGE_MPEG)) < 0)
+ return ret;
+ }
+ if ((ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0)
return ret;
}
break;
More information about the ffmpeg-cvslog
mailing list