1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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.
This commit is contained in:
Niklas Haas 2024-01-12 09:16:16 +01:00
parent 2303bf3232
commit d2ae2aad8c

View File

@ -506,8 +506,14 @@ static int query_formats(AVFilterContext *ctx)
if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 || if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 ||
(ret = ff_set_common_color_spaces(ctx, color_spaces)) < 0) (ret = ff_set_common_color_spaces(ctx, color_spaces)) < 0)
return ret; return ret;
if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0 || if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0)
(ret = ff_set_common_color_ranges(ctx, color_ranges)) < 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; return ret;
} }
break; break;