[FFmpeg-trac] #11182(swscale:closed): yuvtestsrc and yuv444p->rgba->yuv444p conversion result in huge difference
FFmpeg
trac at avcodec.org
Fri Sep 13 18:37:31 EEST 2024
#11182: yuvtestsrc and yuv444p->rgba->yuv444p conversion result in huge difference
-------------------------------------+-------------------------------------
Reporter: Andrew-R | Owner: (none)
Type: defect | Status: closed
Priority: normal | Component: swscale
Version: unspecified | Resolution: invalid
Keywords: colorspace | Blocked By:
color_primaries |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by Andrew-R):
so, I modded ffmpeg like this:
```
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index df0d5708aa..c33082ca2a 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -538,9 +538,12 @@ av_cold void ff_sws_init_range_convert(SwsContext *c)
if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
if (c->dstBpc <= 14) {
if (c->srcRange) {
+ printf("luma range from full to limied\n");
c->lumConvertRange = lumRangeFromJpeg_c;
c->chrConvertRange = chrRangeFromJpeg_c;
} else {
+ printf("luma range from limited to full, srcrange %i
dstrange = %i \n", c->srcRange, c->dstRange);
+
c->lumConvertRange = lumRangeToJpeg_c;
c->chrConvertRange = chrRangeToJpeg_c;
}
```
and now it prints:
```
bash-5.1$ /dev/shm/ffmpeg/ffmpeg -color_range 2 -colorspace 5 -i /dev/shm
/yuv-mpeg-yuv444p.y4m -sws_dither 0 -vf format=rgb24 -pix_fmt yuv444p
-frames 2 -r 25 -color_range 2 -colorspace 5 /dev/shm/yuv-mpeg-rgba-
yuv444p.y4m -debug log
ffmpeg version N-115843-gc079ebdc57 Copyright (c) 2000-2024 the FFmpeg
developers
built with gcc 11.2.0 (GCC)
configuration: --disable-debug
libavutil 59. 36.100 / 59. 36.100
libavcodec 61. 13.100 / 61. 13.100
libavformat 61. 5.101 / 61. 5.101
libavdevice 61. 2.101 / 61. 2.101
libavfilter 10. 2.102 / 10. 2.102
libswscale 8. 2.100 / 8. 2.100
libswresample 5. 2.100 / 5. 2.100
matched as AVOption 'debug' with argument 'log'.
Trailing option(s) found in the command: may be ignored.
Finished splitting the commandline.
Parsing a group of options: global .
Successfully parsed a group of options.
Parsing a group of options: input url /dev/shm/yuv-mpeg-yuv444p.y4m.
Successfully parsed a group of options.
Opening an input file: /dev/shm/yuv-mpeg-yuv444p.y4m.
[AVFormatContext @ 0xc5baa00] Opening '/dev/shm/yuv-mpeg-yuv444p.y4m' for
reading
[file @ 0xc5bafc0] Setting default whitelist 'file,crypto,data'
[yuv4mpegpipe @ 0xc5baa00] Format yuv4mpegpipe probed with size=2048 and
score=100
[yuv4mpegpipe @ 0xc5baa00] Before avformat_find_stream_info() pos: 67
bytes read:32768 seeks:0 nb_streams:1
[yuv4mpegpipe @ 0xc5baa00] All info found
[yuv4mpegpipe @ 0xc5baa00] After avformat_find_stream_info() pos: 230473
bytes read:230473 seeks:0 frames:1
Input #0, yuv4mpegpipe, from '/dev/shm/yuv-mpeg-yuv444p.y4m':
Duration: 00:00:03.00, start: 0.000000, bitrate: 46081 kb/s
Stream #0:0, 1, 1/25: Video: rawvideo, 1 reference frame (444P /
0x50343434), yuv444p(pc, bt470bg/unknown/unknown, progressive), 320x240,
0/1, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 25 tbn
Successfully opened the file.
Parsing a group of options: output url /dev/shm/yuv-mpeg-rgba-yuv444p.y4m.
Applying option vf (alias for -filter:v (apply filters to video streams))
with argument format=rgb24.
Applying option pix_fmt (set pixel format) with argument yuv444p.
Applying option frames (set the number of frames to output) with argument
2.
Applying option r (override input framerate/convert to given output
framerate (Hz value, fraction or abbreviation)) with argument 25.
Successfully parsed a group of options.
Opening an output file: /dev/shm/yuv-mpeg-rgba-yuv444p.y4m.
[out#0/yuv4mpegpipe @ 0xc5bdb80] No explicit maps, mapping streams
automatically...
[vost#0:0/wrapped_avframe @ 0xc5be380] Created video stream from input
stream 0:0
[AVFilterGraph @ 0xc5bfc40] Setting 'pix_fmts' to value 'rgb24'
File '/dev/shm/yuv-mpeg-rgba-yuv444p.y4m' already exists. Overwrite? [y/N]
y
[file @ 0xc5c1d80] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> wrapped_avframe (native))
[vost#0:0/wrapped_avframe @ 0xc5be380] Starting thread...
[vf#0:0 @ 0xc5bf8c0] Starting thread...
[vist#0:0/rawvideo @ 0xc5bd540] [dec:rawvideo @ 0xc5c0ec0] Starting
thread...
[in#0/yuv4mpegpipe @ 0xc5ba740] Starting thread...
Press [q] to stop, [?] for help
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[AVFilterGraph @ 0xf5900a40] Setting 'pix_fmts' to value 'rgb24'
detected 4 logical cores
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[graph -1 input from stream 0:0 @ 0xf5901980] Setting 'video_size' to
value '320x240'
[graph -1 input from stream 0:0 @ 0xf5901980] Setting 'pix_fmt' to value
'5'
[graph -1 input from stream 0:0 @ 0xf5901980] Setting 'time_base' to value
'1/25'
[graph -1 input from stream 0:0 @ 0xf5901980] Setting 'pixel_aspect' to
value '1/1'
[graph -1 input from stream 0:0 @ 0xf5901980] Setting 'colorspace' to
value '5'
[graph -1 input from stream 0:0 @ 0xf5901980] Setting 'range' to value '2'
[graph -1 input from stream 0:0 @ 0xf5901980] Setting 'frame_rate' to
value '25/1'
[graph -1 input from stream 0:0 @ 0xf5901980] w:320 h:240 pixfmt:yuv444p
tb:1/25 fr:25/1 sar:1/1 csp:bt470bg range:pc
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[format @ 0xf5902a00] Setting 'pix_fmts' to value 'yuv444p'
[format @ 0xf5902a00] Setting 'color_spaces' to value 'bt470bg'
[format @ 0xf5902a00] Setting 'color_ranges' to value 'pc'
[auto_scale_0 @ 0xf5903e40] Setting 'sws_dither' to value '0'
[auto_scale_0 @ 0xf5903e40] w:iw h:ih flags:'' interl:0
[Parsed_format_0 @ 0xf5901440] auto-inserting filter 'auto_scale_0'
between the filter 'graph -1 input from stream 0:0' and the filter
'Parsed_format_0'
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[auto_scale_1 @ 0xf590ecc0] Setting 'sws_dither' to value '0'
[auto_scale_1 @ 0xf590ecc0] w:iw h:ih flags:'' interl:0
[format @ 0xf5902a00] auto-inserting filter 'auto_scale_1' between the
filter 'Parsed_format_0' and the filter 'format'
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[AVFilterGraph @ 0xf5900a40] query_formats: 4 queried, 3 merged, 6 already
done, 0 delayed
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[swscaler @ 0xf5919800] [swscaler @ 0xf5922d80] Forcing full internal H
chroma due to input having non subsampled chroma
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[swscaler @ 0xf5919800] [swscaler @ 0xf5937240] Forcing full internal H
chroma due to input having non subsampled chroma
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
Last message repeated 1 times
[swscaler @ 0xf5919800] [swscaler @ 0xf594af00] Forcing full internal H
chroma due to input having non subsampled chroma
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[swscaler @ 0xf5919800] [swscaler @ 0xf595efc0] Forcing full internal H
chroma due to input having non subsampled chroma
[swscaler @ 0xf5919800] [swscaler @ 0xf5973480] Forcing full internal H
chroma due to input having non subsampled chroma
[auto_scale_0 @ 0xf5903e40] w:320 h:240 fmt:yuv444p csp:bt470bg range:pc
sar:1/1 -> w:320 h:240 fmt:rgb24 csp:gbr range:pc sar:1/1 flags:0x00000004
[auto_scale_0 @ 0xf5903e40] [framesync @ 0xf5903f14] Selected 1/25 time
base
[auto_scale_0 @ 0xf5903e40] [framesync @ 0xf5903f14] Sync level 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
luma range from limited to full, srcrange 0 dstrange = 1
[auto_scale_1 @ 0xf590ecc0] w:320 h:240 fmt:rgb24 csp:gbr range:pc sar:1/1
-> w:320 h:240 fmt:yuv444p csp:bt470bg range:pc sar:1/1 flags:0x00000004
[auto_scale_1 @ 0xf590ecc0] [framesync @ 0xf590ed94] Selected 1/25 time
base
[auto_scale_1 @ 0xf590ecc0] [framesync @ 0xf590ed94] Sync level 1
[graph -1 input from stream 0:0 @ 0xf5901980] video frame properties
congruent with link at pts_time: 0
Output #0, yuv4mpegpipe, to '/dev/shm/yuv-mpeg-rgba-yuv444p.y4m':
Metadata:
encoder : Lavf61.5.101
Stream #0:0, 0, 1/25: Video: wrapped_avframe, 1 reference frame,
yuv444p(pc, bt470bg/unknown/unknown, progressive), 320x240 [SAR 1:1 DAR
4:3], 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn
Metadata:
encoder : Lavc61.13.100 wrapped_avframe
[out#0/yuv4mpegpipe @ 0xc5bdb80] Starting thread...
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: send 0 ts 0.04
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: receive 0 ts 0.04 queue head 0 ts
0.04
[rawvideo @ 0xc5c15c0] PACKET SIZE: 230400, STRIDE: 960
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: send 0 ts 0.08
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: 0 frames_max 2 reached
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: finish 0; head ts 0.08
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: finish queue
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: receive 0 ts 0.08 queue head 0 ts
0.08
[vf#0:0 @ 0xc5bf8c0] All consumers returned EOF
[vost#0:0/wrapped_avframe @ 0xc5be380] Encoder thread received EOF
[vost#0:0/wrapped_avframe @ 0xc5be380] Terminating thread with return code
0 (success)
[out#0/yuv4mpegpipe @ 0xc5bdb80] All streams finished
[out#0/yuv4mpegpipe @ 0xc5bdb80] Terminating thread with return code 0
(success)
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: 0 EOF
[out#0/yuv4mpegpipe @ 0xc5bdb80] sq: finish queue
[vf#0:0 @ 0xc5bf8c0] Terminating thread with return code 0 (success)
[vist#0:0/rawvideo @ 0xc5bd540] [dec:rawvideo @ 0xc5c0ec0] Decoder
returned EOF, finishing
[vist#0:0/rawvideo @ 0xc5bd540] [dec:rawvideo @ 0xc5c0ec0] Terminating
thread with return code 0 (success)
[vist#0:0/rawvideo @ 0xc5bd540] All consumers of this stream are done
[in#0/yuv4mpegpipe @ 0xc5ba740] All consumers are done
[in#0/yuv4mpegpipe @ 0xc5ba740] Terminating thread with return code 0
(success)
[AVIOContext @ 0xc5bf5c0] Statistics: 460879 bytes written, 0 seeks, 2
writeouts
[out#0/yuv4mpegpipe @ 0xc5bdb80] Output file #0 (/dev/shm/yuv-mpeg-rgba-
yuv444p.y4m):
[out#0/yuv4mpegpipe @ 0xc5bdb80] Output stream #0:0 (video): 2 frames
encoded; 2 packets muxed (616 bytes);
[out#0/yuv4mpegpipe @ 0xc5bdb80] Total: 2 packets (616 bytes) muxed
[out#0/yuv4mpegpipe @ 0xc5bdb80] video:1KiB audio:0KiB subtitle:0KiB other
streams:0KiB global headers:0KiB muxing overhead: 74718.019481%
frame= 2 fps=0.0 q=-0.0 Lsize= 450KiB time=00:00:00.08
bitrate=46087.9kbits/s speed=4.72x
[in#0/yuv4mpegpipe @ 0xc5ba740] Input file #0 (/dev/shm/yuv-mpeg-
yuv444p.y4m):
[in#0/yuv4mpegpipe @ 0xc5ba740] Input stream #0:0 (video): 20 packets
read (4608000 bytes); 11 frames decoded; 0 decode errors;
[in#0/yuv4mpegpipe @ 0xc5ba740] Total: 20 packets (4608000 bytes)
demuxed
[AVIOContext @ 0xc5c3240] Statistics: 4608187 bytes read, 0 seeks
```
why it calls limited to full if src already in full range ?
--
Ticket URL: <https://trac.ffmpeg.org/ticket/11182#comment:32>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list