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.
Unified · Split
| @@ -506,8 +506,14 @@ static int query_formats(AVFilterContext *ctx) · 505 unmodified lines | ||
| 506 | 506 | if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 || |
| 507 | 507 | (ret = ff_set_common_color_spaces(ctx, color_spaces)) < 0) |
| 508 | 508 | return ret; |
| 509 | − if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0 || | |
| 510 | − (ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0) | |
| 509 | + if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0) | |
| 510 | + return ret; | |
| 511 | + if (c->color_range == AVCOL_RANGE_UNSPECIFIED) { | |
| 512 | + /* allow implicitly promoting unspecified to mpeg */ | |
| 513 | + if ((ret = ff_add_format(&color_ranges, AVCOL_RANGE_MPEG)) < 0) | |
| 514 | + return ret; | |
| 515 | + } | |
| 516 | + if ((ret = ff_set_common_color_ranges(ctx, color_ranges)) < 0) | |
| 511 | 517 | return ret; |
| 512 | 518 | } |
| 513 | 519 | break; |