diff mbox series

[FFmpeg-devel,v2,01/13] avfilter/vf_scale: don't change range by default

Message ID 20231013142706.23971-2-ffmpeg@haasn.xyz
State New
Headers show
Series YUVJ removal | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Niklas Haas Oct. 13, 2023, 2:24 p.m. UTC
From: Niklas Haas <git@haasn.dev>

If we don't convert the pixel format, then we shouldn't touch the pixel
range by default, either. Ensures full-range YUV input comes out as
full-range YUV output, unless we go through a pixel format conversion.

In theory, we may also want to extend this logic to YUV->YUV
conversions, but a few special cases (YUVJ, Gray, RGB) make this more
annoying than it needs to be, so I'll defer it to a future commit.
---
 libavfilter/vf_scale.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index b0221e8538..9bbf0f8ed5 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -863,6 +863,8 @@  scale:
             in_full  = (in_range == AVCOL_RANGE_JPEG);
         if (scale->out_range != AVCOL_RANGE_UNSPECIFIED)
             out_full = (scale->out_range == AVCOL_RANGE_JPEG);
+        else if (in->format == out->format)
+            out_full = in_full; /* preserve pixel range by default */
 
         sws_setColorspaceDetails(scale->sws, inv_table, in_full,
                                  table, out_full,