[FFmpeg-devel] [PATCH] swscale/utils: Remove bpc==8 gating init_range_convert
neil.birkbeck at gmail.com
Wed Nov 29 03:14:37 EET 2017
On higher bit depth YUV inputs with range metadata signaled as PC/full levels,
this change makes the results of scaling without explicitly
setting the input range on vf_scale as if it were explicitly set.
For example, the results with implicit color settings from the frame:
Are the same as the correct result when set explicitly in the scaler:
The results are consistent with a similar yuv420p(pc) test input
(e.g., implicit and explicit setting of in_range on vf_scale both work).
Fate passes without the checks (or with a more specific check for >= 8).
If this seems sane, I'll write some tests.
I tried to reproduce the old results from before and after the commit
that I think the previous comment was referring to
but failed to repro (I may be testing the wrong thing). Using the samples
from (https://trac.ffmpeg.org/ticket/2939), without the check:
ffmpeg -i /tmp/progressive.jpg -vf format=rgb24 /tmp/progressive.png
is still treated as full range input (treating it as studio causes clipping
in the rgb).
There are still some other edge cases where range conversion doesn't work
unless explicitly set (e.g., when no scale is happening)
Signed-off-by: Neil Birkbeck <neil.birkbeck at gmail.com>
libswscale/utils.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 4df09306d3..f900e3bdef 100644
@@ -883,9 +883,7 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table,
c->srcRange = srcRange;
c->dstRange = dstRange;
- //The srcBpc check is possibly wrong but we seem to lack a definitive reference to test this
- //and what we have in ticket 2939 looks better with this check
- if (need_reinit && (c->srcBpc == 8 || !isYUV(c->srcFormat)))
+ if (need_reinit)
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
More information about the ffmpeg-devel