From caa75c6d5d323415647c93d1c7c1d5326f8cf825 Mon Sep 17 00:00:00 2001
From: Neil Birkbeck <neil.birkbeck@gmail.com>
Date: Tue, 28 Nov 2017 15:56:12 -0800
Subject: [PATCH] swscale/utils: Remove bpc==8 gating init_range_convert

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:
-vf scale=-1:-1:out_range=mpeg,format=yuv420p

Are the same as the correct result when set explicitly in the scaler:
-vf scale=-1:-1:in_range=jpeg:out_range=mpeg,format=yuv420p

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
4959a4fcf76e7c595dbb23c4e3bf59abf2e60ea4
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)

New fate samples from:
https://github.com/nbirkbeck/ffmpeg-test-samples/tree/master/color-range/data

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
---
 libswscale/utils.c                                 |  4 +-
 tests/fate/filter-video.mak                        | 67 ++++++++++++++++++++++
 .../filter-scale-yuv444p-pc-scaled-in-pc-out-tv    | 10 ++++
 ...filter-scale-yuv444p-pc-scaled-in-pc-out-unspec | 10 ++++
 ...filter-scale-yuv444p-pc-scaled-in-unspec-out-tv | 10 ++++
 ...er-scale-yuv444p-pc-scaled-in-unspec-out-unspec | 10 ++++
 .../filter-scale-yuv444p-pc-unscaled-in-pc-out-tv  | 10 ++++
 ...lter-scale-yuv444p-pc-unscaled-in-pc-out-unspec | 10 ++++
 ...lter-scale-yuv444p-pc-unscaled-in-unspec-out-tv | 10 ++++
 ...-scale-yuv444p-pc-unscaled-in-unspec-out-unspec | 10 ++++
 .../filter-scale-yuv444p10-pc-scaled-in-pc-out-tv  | 10 ++++
 ...lter-scale-yuv444p10-pc-scaled-in-pc-out-unspec | 10 ++++
 ...lter-scale-yuv444p10-pc-scaled-in-unspec-out-tv | 10 ++++
 ...-scale-yuv444p10-pc-scaled-in-unspec-out-unspec | 10 ++++
 ...filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv | 10 ++++
 ...er-scale-yuv444p10-pc-unscaled-in-pc-out-unspec | 10 ++++
 ...er-scale-yuv444p10-pc-unscaled-in-unspec-out-tv | 10 ++++
 ...cale-yuv444p10-pc-unscaled-in-unspec-out-unspec | 10 ++++
 18 files changed, 228 insertions(+), 3 deletions(-)
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-unspec
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-unspec
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-unspec
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-unspec
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-unspec
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-unspec
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-unspec
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-tv
 create mode 100644 tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-unspec

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 4df09306d3..f900e3bdef 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -883,9 +883,7 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
     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)
         ff_sws_init_range_convert(c);
 
     c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index c19f301ff8..283be001ec 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -464,6 +464,73 @@ FATE_FILTER_VSYNTH-$(CONFIG_SCALE_FILTER) += fate-filter-scalechroma
 fate-filter-scalechroma: tests/data/vsynth1.yuv
 fate-filter-scalechroma: CMD = framecrc -flags bitexact -s 352x288 -pix_fmt yuv444p -i tests/data/vsynth1.yuv -pix_fmt yuv420p -sws_flags +bitexact -vf scale=out_v_chr_pos=33:out_h_chr_pos=151
 
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-unscaled-in-unspec-out-unspec
+fate-filter-scale-yuv444p10-pc-unscaled-in-unspec-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-unscaled-in-unspec-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-unscaled-in-unspec-out-tv
+fate-filter-scale-yuv444p10-pc-unscaled-in-unspec-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-unscaled-in-unspec-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1:out_range=tv,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-unscaled-in-pc-out-unspec
+fate-filter-scale-yuv444p10-pc-unscaled-in-pc-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-unscaled-in-pc-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1:in_range=pc,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv
+fate-filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1:in_range=pc:out_range=tv,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-scaled-in-unspec-out-unspec
+fate-filter-scale-yuv444p10-pc-scaled-in-unspec-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-scaled-in-unspec-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=256:48,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-scaled-in-unspec-out-tv
+fate-filter-scale-yuv444p10-pc-scaled-in-unspec-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-scaled-in-unspec-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=256:48:out_range=tv,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-scaled-in-pc-out-tv
+fate-filter-scale-yuv444p10-pc-scaled-in-pc-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-scaled-in-pc-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -sws_flags +bitexact -vf scale=256:48:in_range=pc:out_range=tv,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p10-pc-scaled-in-pc-out-unspec
+fate-filter-scale-yuv444p10-pc-scaled-in-pc-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4
+fate-filter-scale-yuv444p10-pc-scaled-in-pc-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p10_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=256:48:in_range=pc,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-unscaled-in-unspec-out-unspec
+fate-filter-scale-yuv444p-pc-unscaled-in-unspec-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-unscaled-in-unspec-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-unscaled-in-unspec-out-tv
+fate-filter-scale-yuv444p-pc-unscaled-in-unspec-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-unscaled-in-unspec-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1:out_range=tv,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-unscaled-in-pc-out-unspec
+fate-filter-scale-yuv444p-pc-unscaled-in-pc-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-unscaled-in-pc-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1:in_range=pc,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-unscaled-in-pc-out-tv
+fate-filter-scale-yuv444p-pc-unscaled-in-pc-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-unscaled-in-pc-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=-1:-1:in_range=pc:out_range=tv,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-scaled-in-unspec-out-unspec
+fate-filter-scale-yuv444p-pc-scaled-in-unspec-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-scaled-in-unspec-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=256:48,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-scaled-in-unspec-out-tv
+fate-filter-scale-yuv444p-pc-scaled-in-unspec-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-scaled-in-unspec-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=256:48:out_range=tv,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-scaled-in-pc-out-unspec
+fate-filter-scale-yuv444p-pc-scaled-in-pc-out-unspec: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-scaled-in-pc-out-unspec: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=256:48:in_range=pc,format=yuv420p
+
+FATE_FILTER_SCALE_RANGE += fate-filter-scale-yuv444p-pc-scaled-in-pc-out-tv
+fate-filter-scale-yuv444p-pc-scaled-in-pc-out-tv: $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4
+fate-filter-scale-yuv444p-pc-scaled-in-pc-out-tv: CMD = framemd5 -flags bitexact -i $(TARGET_SAMPLES)/ffmpeg-synthetic/color/color_gradient_yuv444p_pc.mp4 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf scale=256:48:in_range=pc:out_range=tv,format=yuv420p
+
+FATE_FILTER_VSYNTH-$(CONFIG_SCALE_FILTER) += $(FATE_FILTER_SCALE_RANGE)
+fate-filter-scale-yuv444p: $(FATE_FILTER_SCALE_RANGE)
+
 FATE_FILTER_VSYNTH-$(CONFIG_VFLIP_FILTER) += fate-filter-vflip
 fate-filter-vflip: CMD = video_filter "vflip"
 
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-tv b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-tv
new file mode 100644
index 0000000000..d47a939446
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 52b748b1c1534972ce5a76bfdc2381c4
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-unspec b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-unspec
new file mode 100644
index 0000000000..d47a939446
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-pc-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 52b748b1c1534972ce5a76bfdc2381c4
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-tv b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-tv
new file mode 100644
index 0000000000..d47a939446
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 52b748b1c1534972ce5a76bfdc2381c4
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-unspec b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-unspec
new file mode 100644
index 0000000000..d47a939446
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-scaled-in-unspec-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 52b748b1c1534972ce5a76bfdc2381c4
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-tv b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-tv
new file mode 100644
index 0000000000..96138568a4
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, 79de32824aeec6331400ac1c6daed36d
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-unspec b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-unspec
new file mode 100644
index 0000000000..96138568a4
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-pc-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, 79de32824aeec6331400ac1c6daed36d
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-tv b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-tv
new file mode 100644
index 0000000000..96138568a4
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, 79de32824aeec6331400ac1c6daed36d
diff --git a/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-unspec b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-unspec
new file mode 100644
index 0000000000..96138568a4
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p-pc-unscaled-in-unspec-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, 79de32824aeec6331400ac1c6daed36d
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-tv b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-tv
new file mode 100644
index 0000000000..5645499b68
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 81a97e1446adf963e68d55131e939c6f
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-unspec b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-unspec
new file mode 100644
index 0000000000..5645499b68
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-pc-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 81a97e1446adf963e68d55131e939c6f
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-tv b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-tv
new file mode 100644
index 0000000000..5645499b68
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 81a97e1446adf963e68d55131e939c6f
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-unspec b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-unspec
new file mode 100644
index 0000000000..5645499b68
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-scaled-in-unspec-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 256x48
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    18432, 81a97e1446adf963e68d55131e939c6f
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv
new file mode 100644
index 0000000000..075f0a0308
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, f021b8d0eea2f66d6f44bbdbba63ae3d
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-unspec b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-unspec
new file mode 100644
index 0000000000..075f0a0308
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-pc-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, f021b8d0eea2f66d6f44bbdbba63ae3d
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-tv b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-tv
new file mode 100644
index 0000000000..075f0a0308
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-tv
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, f021b8d0eea2f66d6f44bbdbba63ae3d
diff --git a/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-unspec b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-unspec
new file mode 100644
index 0000000000..075f0a0308
--- /dev/null
+++ b/tests/ref/fate/filter-scale-yuv444p10-pc-unscaled-in-unspec-out-unspec
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 512x96
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,    73728, f021b8d0eea2f66d6f44bbdbba63ae3d
-- 
2.15.1.424.g9478a66081-goog

