[FFmpeg-trac] #3345(swscale:open): Bias in planar YUV to YUV bit depth conversion

FFmpeg trac at avcodec.org
Tue Sep 7 19:14:38 EEST 2021


#3345: Bias in planar YUV to YUV bit depth conversion
------------------------------------+-----------------------------------
             Reporter:  abc123      |                    Owner:  (none)
                 Type:  defect      |                   Status:  open
             Priority:  normal      |                Component:  swscale
              Version:  git-master  |               Resolution:
             Keywords:  bounty      |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+-----------------------------------
Comment (by Balling):

 Okay. When you play this, one should use
 {{{
 ffplay -pixel_format yuv420p10le -video_size 1280x720 testGrad_01.yuv -vf
 scale=in_color_matrix=bt709,format=gbrp


 }}}
 Your command line is '''technically''' wrong. BT.709 is not the default:
 it is BT.601. So it does conversion assuming bt601 to bt601, all limited.
 That surprisingly does not affect the pixels. What does affect the pixels
 is no dither (recently fixed):

 ffmpeg -pix_fmt yuv420p10le -video_size 1280x720 -i testGrad_01.yuv -vf
 scale=in_range=limited:in_color_matrix=bt709:out_range=limited:out_color_matrix=bt709:sws_dither=0,format=yuv420p
 -f rawvideo testGrad_03.yuv

 That file is different at least.

 Now, lets test that 03 file with the use of to PNG conversion.

 ffmpeg -pixel_format yuv420p10le -video_size 1280x720 -i testGrad_01.yuv
 -vf scale=flags=bilinear:in_color_matrix=bt709:sws_dither=none
 03testgrad.png

 Not a surprise that this produces 16 bit per component png file, yet we
 know that such 10 bit to 16 bit conversion is broken from #7978.

 So you use ffmpeg -pixel_format yuv420p10le -video_size 1280x720 -i
 testGrad_01.yuv -vf zscale=matrixin=bt709,format=gbrp16le
 031zscaletestgrad.png

 And same for testGrad_03.yuv.

 ffmpeg -pixel_format yuv420p -video_size 1280x720 -i
 C:\Users\ZAQU\testGrad_03.yuv -vf zscale=matrixin=bt709,format=gbrp16le
 031zscaletestgrad.png

 So, yeah... That still looks bad.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/3345#comment:9>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list