[FFmpeg-trac] #3422(swscale:new): Black becomes dark gray when converting rgb24 to gray16le
FFmpeg
trac at avcodec.org
Thu Feb 27 12:03:39 CET 2014
#3422: Black becomes dark gray when converting rgb24 to gray16le
---------------------------------+---------------------------------------
Reporter: b_jonas | Type: defect
Status: new | Priority: normal
Component: swscale | Version: unspecified
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
---------------------------------+---------------------------------------
Summary of the bug:
This bug is very similar to the fixed bug #2684, the difference is that
we're using 16 bit depth output this time. I am using a newer version of
ffmpeg that has #2684 fixed already.
When converting from rgb24 color space to gray16le colorspace, black input
(represented as 0 0 0) becomes dary gray (represented as 4096) in the
output.
How to reproduce:
I've tried this on windows 7 with the zeranoe build ffmpeg version
N-60937-gb5005de built on Feb 26 2014 22:10:15 with gcc 4.8.2.
First, create a raw rgb24 input file with all zero contents, with the
following command:
{{{
perl -we "binmode STDOUT; print pack q/x/.(3*16*16);" > zero-in-rgb.raw
}}}
Then invoke ffmpeg with the following command.
{{{
ffmpeg -report -v 99 -f rawvideo -pix_fmt rgb24 -s 16x16 -i zero-in-
rgb.raw -f rawvideo -pix_fmt gray16le zero-out-gray16le.raw
}}}
Finally check the contents of the output with the following command.
{{{
perl -we "open F, q/</, shift or die; binmode F or die; local $/ =
\(16*2); while (<F>) { print join(q/ /, unpack q/v*/, $_), qq/\n/; }"
zero-out-gray16le.raw
}}}
The output shows the raw 16-bit little-endian words in the output, which
should be all zero but isn't:
{{{
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
4096
}}}
Following is the log the ffmpeg command has saved.
{{{
ffmpeg started on 2014-02-27 at 11:57:27
Report written to "ffmpeg-20140227-115727.log"
Command line:
"E:\\ambrus\\local\\ffmpeg-20140227-git-b5005de-
win64-shared\\bin\\ffmpeg.exe" -report -v 99 -f rawvideo -pix_fmt rgb24 -s
16x16 -i zero-in-rgb.raw -f rawvideo -pix_fmt gray16le zero-out-
gray16le.raw
ffmpeg version N-60937-gb5005de Copyright (c) 2000-2014 the FFmpeg
developers
built on Feb 26 2014 22:10:15 with gcc 4.8.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-
version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-
fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass
--enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm
--enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-
libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libopus --enable-librtmp --enable-libschroedinger --enable-
libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-
libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a
report) with argument '1'.
Reading option '-v' ... matched as option 'v' (set logging level) with
argument '99'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'rawvideo'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel
format) with argument 'rgb24'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or
abbreviation)) with argument '16x16'.
Reading option '-i' ... matched as input file with argument 'zero-in-
rgb.raw'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'rawvideo'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel
format) with argument 'gray16le'.
Reading option 'zero-out-gray16le.raw' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Applying option v (set logging level) with argument 99.
Successfully parsed a group of options.
Parsing a group of options: input file zero-in-rgb.raw.
Applying option f (force format) with argument rawvideo.
Applying option pix_fmt (set pixel format) with argument rgb24.
Applying option s (set frame size (WxH or abbreviation)) with argument
16x16.
Successfully parsed a group of options.
Opening an input file: zero-in-rgb.raw.
[rawvideo @ 000000000061ba60] Before avformat_find_stream_info() pos: 0
bytes read:768 seeks:0
[rawvideo @ 000000000061ba60] All info found
[rawvideo @ 000000000061ba60] Estimating duration from bitrate, this may
be inaccurate
[rawvideo @ 000000000061ba60] After avformat_find_stream_info() pos: 768
bytes read:768 seeks:0 frames:1
Input #0, rawvideo, from 'zero-in-rgb.raw':
Duration: 00:00:00.04, start: 0.000000, bitrate: 153 kb/s
Stream #0:0, 1, 1/25: Video: rawvideo (RGB[24] / 0x18424752), rgb24,
16x16, 1/25, 153 kb/s, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output file zero-out-gray16le.raw.
Applying option f (force format) with argument rawvideo.
Applying option pix_fmt (set pixel format) with argument gray16le.
Successfully parsed a group of options.
Opening an output file: zero-out-gray16le.raw.
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 00000000004cec80] Setting 'video_size' to
value '16x16'
[graph 0 input from stream 0:0 @ 00000000004cec80] Setting 'pix_fmt' to
value '2'
[graph 0 input from stream 0:0 @ 00000000004cec80] Setting 'time_base' to
value '1/25'
[graph 0 input from stream 0:0 @ 00000000004cec80] Setting 'pixel_aspect'
to value '0/1'
[graph 0 input from stream 0:0 @ 00000000004cec80] Setting 'sws_param' to
value 'flags=2'
[graph 0 input from stream 0:0 @ 00000000004cec80] Setting 'frame_rate' to
value '25/1'
[graph 0 input from stream 0:0 @ 00000000004cec80] w:16 h:16 pixfmt:rgb24
tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[format @ 00000000004ceac0] compat: called with args=[gray16le]
[format @ 00000000004ceac0] Setting 'pix_fmts' to value 'gray16le'
[auto-inserted scaler 0 @ 00000000004988a0] Setting 'flags' to value '0x4'
[auto-inserted scaler 0 @ 00000000004988a0] w:iw h:ih flags:'0x4' interl:0
[format @ 00000000004ceac0] auto-inserting filter 'auto-inserted scaler 0'
between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 000000000061fe00] query_formats: 4 queried, 2 merged, 1
already done, 0 delayed
[auto-inserted scaler 0 @ 00000000004988a0] w:16 h:16 fmt:rgb24 sar:0/1 ->
w:16 h:16 fmt:gray16le sar:0/1 flags:0x4
Output #0, rawvideo, to 'zero-out-gray16le.raw':
Metadata:
encoder : Lavf55.33.100
Stream #0:0, 0, 1/90000: Video: rawvideo (Y1[0][16] / 0x10003159),
gray16le, 16x16, 1/25, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> rawvideo)
Press [q] to stop, [?] for help
[output stream 0:0 @ 00000000004cef20] EOF on sink link output stream
0:0:default.
No more output streams to write to, finishing.
frame= 1 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.04 bitrate=
102.4kbits/s
video:0kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead
0.000000%
1 frames successfully decoded, 0 decoding errors
[AVIOContext @ 000000000061b980] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 000000000061e8c0] Statistics: 768 bytes read, 0 seeks
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/3422>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list