swscale: Take the destination range into account for yuv->rgb->yuv conversions
The range parameters need to be set up before calling sws_init_context (which selects which fastpaths can be used; this gets called by sws_getContext); solely passing them via sws_setColorspaceDetails isn't enough. This fixes producing full range YUV range output when doing YUV->YUV conversions between different YUV color spaces. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
8a00caf309
commit
c523724c69
@ -1037,11 +1037,16 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
|
||||
srcRange, table, dstRange,
|
||||
brightness, contrast, saturation);
|
||||
|
||||
c->cascaded_context[1] = sws_getContext(tmp_width, tmp_height, tmp_format,
|
||||
dstW, dstH, c->dstFormat,
|
||||
c->flags, NULL, NULL, c->param);
|
||||
c->cascaded_context[1] = sws_alloc_set_opts(tmp_width, tmp_height, tmp_format,
|
||||
dstW, dstH, c->dstFormat,
|
||||
c->flags, c->param);
|
||||
if (!c->cascaded_context[1])
|
||||
return -1;
|
||||
c->cascaded_context[1]->srcRange = srcRange;
|
||||
c->cascaded_context[1]->dstRange = dstRange;
|
||||
ret = sws_init_context(c->cascaded_context[1], NULL , NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sws_setColorspaceDetails(c->cascaded_context[1], inv_table,
|
||||
srcRange, table, dstRange,
|
||||
0, 1 << 16, 1 << 16);
|
||||
|
@ -17,6 +17,22 @@ $(SWS_SLICE_TEST-yes): tools/scale_slice_test$(EXESUF)
|
||||
$(SWS_SLICE_TEST-yes): REF = /dev/null
|
||||
FATE_LIBSWSCALE_SAMPLES += $(SWS_SLICE_TEST-yes)
|
||||
|
||||
FATE_LIBSWSCALE-$(CONFIG_RAWVIDEO_DEMUXER) += fate-sws-yuv-colorspace
|
||||
fate-sws-yuv-colorspace: tests/data/vsynth1.yuv
|
||||
fate-sws-yuv-colorspace: ffmpeg$(PROGSSUF)$(EXESUF)
|
||||
fate-sws-yuv-colorspace: CMD = framecrc \
|
||||
-f rawvideo -s 352x288 -pix_fmt yuv420p -i $(TARGET_PATH)/tests/data/vsynth1.yuv \
|
||||
-frames 1 \
|
||||
-vf scale=in_color_matrix=bt709:in_range=limited:out_color_matrix=bt601:out_range=full:flags=+accurate_rnd+bitexact
|
||||
|
||||
FATE_LIBSWSCALE-$(CONFIG_RAWVIDEO_DEMUXER) += fate-sws-yuv-range
|
||||
fate-sws-yuv-range: tests/data/vsynth1.yuv
|
||||
fate-sws-yuv-range: ffmpeg$(PROGSSUF)$(EXESUF)
|
||||
fate-sws-yuv-range: CMD = framecrc \
|
||||
-f rawvideo -s 352x288 -pix_fmt yuv420p -i $(TARGET_PATH)/tests/data/vsynth1.yuv \
|
||||
-frames 1 \
|
||||
-vf scale=in_color_matrix=bt601:in_range=limited:out_color_matrix=bt601:out_range=full:flags=+accurate_rnd+bitexact
|
||||
|
||||
FATE_LIBSWSCALE += $(FATE_LIBSWSCALE-yes)
|
||||
FATE_LIBSWSCALE_SAMPLES += $(FATE_LIBSWSCALE_SAMPLES-yes)
|
||||
FATE-$(CONFIG_SWSCALE) += $(FATE_LIBSWSCALE)
|
||||
|
6
tests/ref/fate/sws-yuv-colorspace
Normal file
6
tests/ref/fate/sws-yuv-colorspace
Normal file
@ -0,0 +1,6 @@
|
||||
#tb 0: 1/25
|
||||
#media_type 0: video
|
||||
#codec_id 0: rawvideo
|
||||
#dimensions 0: 352x288
|
||||
#sar 0: 0/1
|
||||
0, 0, 0, 1, 152064, 0xcbcb97b9
|
6
tests/ref/fate/sws-yuv-range
Normal file
6
tests/ref/fate/sws-yuv-range
Normal file
@ -0,0 +1,6 @@
|
||||
#tb 0: 1/25
|
||||
#media_type 0: video
|
||||
#codec_id 0: rawvideo
|
||||
#dimensions 0: 352x288
|
||||
#sar 0: 0/1
|
||||
0, 0, 0, 1, 152064, 0xe75c71a9
|
Loading…
x
Reference in New Issue
Block a user