[FFmpeg-trac] #9407(ffmpeg:new): Broken Conversion: yuv444p10le to yuv444p

FFmpeg trac at avcodec.org
Sat Sep 4 22:42:58 EEST 2021


#9407: Broken Conversion: yuv444p10le to yuv444p
-------------------------------------+-------------------------------------
             Reporter:  Michael      |                     Type:  defect
  Witten                             |
               Status:  new          |                 Priority:  normal
            Component:  ffmpeg       |                  Version:
             Keywords:  pix_fmt yuv  |  unspecified
  yuv444p10le yuv444p 10-bit format  |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Conversion from '''yuv444p10le''' to '''yuv444p''' produces erroneous
 results (and not just from expected losses).

 I've attached a script that produces results for examination; save the
 script to `"$dir"` and then run it like so:

 {{{
 $ cd "$dir"
 $ bash 00-commands.sh
 }}}

 In short, the following produces erroneous results:

 {{{
 #!/bin/bash

 bad_output=04-rbg24-to-yuv444p10le-to-yuv444p-to-rgb24.png

 args=(
   -hide_banner
   -loglevel quiet

   -f lavfi -i '
     color=0x7FFFD4:size=480x270, format=rgb24,
       setparams=prog:pc:bt709:iec61966-2-1:bt709
   '

   -vf '
     scale=out_range=pc, format=yuv444p10le,
       scale=out_range=pc, format=yuv444p,
         scale=out_range=pc, format=rgb24
   '

   -frames 1

   "$bad_output"
 )

 ffmpeg "${args[@]}"
 }}}

 The '''workaround''' is to convert to some non-''yuv'' pixel format
 (''e.g.,'' '''rgb24''') before converting to the desired ''yuv'' format:

 {{{
 #!/bin/bash

 good_output=05-rbg24-to-yuv444p10le-to-rgb24-to-yuv444p-to-rgb24.png

 args=(
   -hide_banner
   -loglevel quiet

   -f lavfi -i '
     color=0x7FFFD4:size=480x270, format=rgb24,
       setparams=prog:pc:bt709:iec61966-2-1:bt709
   '

   -vf '
     scale=out_range=pc, format=yuv444p10le,
       scale=out_range=pc, format=rgb24,
         scale=out_range=pc, format=yuv444p,
           scale=out_range=pc, format=rgb24
   '

   -frames 1

   "$good_output"
 )

 ffmpeg "${args[@]}"
 }}}

 Here is the output I got from running my script:

 {{{
 Versions:
 ========

   bash:

     GNU bash, version 5.1.8(1)-release (aarch64-unknown-linux-gnu)

   tee:

     tee (GNU coreutils) 8.32

   sed:

     sed (GNU sed) 4.8

   ffmpeg:

     ffmpeg version n4.4 Copyright (c) 2000-2021 the FFmpeg developers
     built with gcc 10.2.0 (GCC)
     configuration: --prefix=/usr --disable-debug --disable-static
     --disable-stripping --enable-amf --enable-avisynth
     --enable-cuda-llvm --enable-fontconfig --enable-gmp
     --enable-gnutls --enable-gpl --enable-ladspa --enable-libass
     --enable-libbluray --enable-libdav1d --enable-libdrm
     --enable-libfreetype --enable-libfribidi --enable-libgsm
     --enable-libiec61883 --enable-libjack --enable-libmodplug
     --enable-libmp3lame --enable-libopencore_amrnb
     --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus
     --enable-libpulse --enable-librsvg --enable-libsoxr
     --enable-libspeex --enable-libsrt --enable-libssh
     --enable-libtheora --enable-libv4l2 --enable-libvidstab
     --enable-libvorbis --enable-libvpx --enable-libwebp
     --enable-libx264 --enable-libx265 --enable-libxcb
     --enable-libxml2 --enable-libxvid --enable-libzimg
     --enable-shared --enable-version3 --host-cflags='"-fPIC"'
     libavutil      56. 70.100 / 56. 70.100
     libavcodec     58.134.100 / 58.134.100
     libavformat    58. 76.100 / 58. 76.100
     libavdevice    58. 13.100 / 58. 13.100
     libavfilter     7.110.100 /  7.110.100
     libswscale      5.  9.100 /  5.  9.100
     libswresample   3.  9.100 /  3.  9.100
     libpostproc    55.  9.100 / 55.  9.100

   identify:

     Version: ImageMagick 7.1.0-4 Q16 aarch64 2021-07-18
     https://imagemagick.org

   md5sum:

     md5sum (GNU coreutils) 8.32

   diff:

     diff (GNU diffutils) 3.8

 Making files:
 ============

   01-rgb24.png
   02-rbg24-to-yuv444p-to-rgb24.png
   03-rbg24-to-yuv444p10le-to-rgb24.png
   04-rbg24-to-yuv444p10le-to-yuv444p-to-rgb24.png
   05-rbg24-to-yuv444p10le-to-rgb24-to-yuv444p-to-rgb24.png

 Analyzing:
 =========

   md5sums:

     1bb5e65fe0865e210333e46416893d8e:

       02-rbg24-to-yuv444p-to-rgb24.png
       05-rbg24-to-yuv444p10le-to-rgb24-to-yuv444p-to-rgb24.png

     f10bf43eae733b375657074b31c72407:

       01-rgb24.png
       03-rbg24-to-yuv444p10le-to-rgb24.png

     3c8326c3640cf4b6ce10ae70c562730d:

       04-rbg24-to-yuv444p10le-to-yuv444p-to-rgb24.png

   rgb24 -> yuv444p is imperceptibly lossy:

     @@ -1,5 +1,5 @@
      Image:
     -  Filename: 01-rgb24.png
     +  Filename: 02-rbg24-to-yuv444p-to-rgb24.png
        Format: PNG (Portable Network Graphics)
        Mime type: image/png
        Class: DirectClass
     @@ -19,13 +19,13 @@
        Channel statistics:
          Pixels: 129600
          Red:
     -      min: 127  (0.498039)
     -      max: 127 (0.498039)
     -      mean: 127 (0.498039)
     -      median: 127 (0.498039)
     +      min: 126  (0.494118)
     +      max: 126 (0.494118)
     +      mean: 126 (0.494118)
     +      median: 126 (0.494118)
            standard deviation: 0 (0)
     -      kurtosis: 8.25856e+54
     -      skewness: -9.425e+37
     +      kurtosis: -2.67166e+54
     +      skewness: 7.86719e+36
            entropy: 0
          Green:
            min: 255  (1)
     @@ -47,17 +47,17 @@
            entropy: 0
        Image statistics:
          Overall:
     -      min: 127  (0.498039)
     +      min: 126  (0.494118)
            max: 255 (1)
     -      mean: 198 (0.776471)
     -      median: 198 (0.776471)
     +      mean: 197.667 (0.775163)
     +      median: 197.667 (0.775163)
            standard deviation: 0 (0)
            kurtosis: -1.50001
     -      skewness: -0.376606
     +      skewness: -0.3818
            entropy: 0
        Colors: 1
        Histogram:
     -    129600: (127,255,212) #7FFFD4 aquamarine
     +    129600: (126,255,212) #7EFFD4 srgb(126,255,212)
        Rendering intent: Perceptual
        Gamma: 0.454545
        Chromaticity:
     @@ -88,13 +88,13 @@
          png:IHDR.width,height: 480, 270
          png:pHYs: x_res=1, y_res=1, units=0
          png:sRGB: intent=0 (Perceptual Intent)
     -    signature:
 9c96d87924efacd9cd67c296a85efd4dc1aaa4b7053b7ed4410f2944911752f9
     +    signature:
 d8f3dc9f8e5d5fdfe8db73baf881f8660f38afc0617dc3130c3fbc484b87cd74
        Artifacts:
          verbose: true
        Tainted: False
        Filesize: 1054B
        Number pixels: 129600
     -  Pixels per second: 12.2981MP
     -  User time: 0.010u
     -  Elapsed time: 0:01.010
     +  Pixels per second: 22.1496MP
     +  User time: 0.000u
     +  Elapsed time: 0:01.005
        Version: ImageMagick 7.1.0-4 Q16 aarch64 2021-07-18
 https://imagemagick.org

   yuv444p10le -> yuv444p is bonkers:
   (it SHOULD be the same as rgb24 -> yuv444p)

     @@ -1,5 +1,5 @@
      Image:
     -  Filename: 02-rbg24-to-yuv444p-to-rgb24.png
     +  Filename: 04-rbg24-to-yuv444p10le-to-yuv444p-to-rgb24.png
        Format: PNG (Portable Network Graphics)
        Mime type: image/png
        Class: DirectClass
     @@ -19,14 +19,14 @@
        Channel statistics:
          Pixels: 129600
          Red:
     -      min: 126  (0.494118)
     -      max: 126 (0.494118)
     -      mean: 126 (0.494118)
     -      median: 126 (0.494118)
     -      standard deviation: 0 (0)
     -      kurtosis: -2.67166e+54
     -      skewness: 7.86719e+36
     -      entropy: 0
     +      min: 130  (0.509804)
     +      max: 133 (0.521569)
     +      mean: 131.141 (0.514279)
     +      median: 131 (0.513725)
     +      standard deviation: 0.705121 (0.00276518)
     +      kurtosis: 2.83967
     +      skewness: 1.6718
     +      entropy: 0.556059
          Green:
            min: 255  (1)
            max: 255 (1)
     @@ -37,27 +37,30 @@
            skewness: 1e+36
            entropy: 0
          Blue:
     -      min: 212  (0.831373)
     -      max: 212 (0.831373)
     -      mean: 212 (0.831373)
     -      median: 212 (0.831373)
     -      standard deviation: 0 (0)
     -      kurtosis: 1.00773e+56
     -      skewness: -4.0775e+38
     -      entropy: 0
     +      min: 225  (0.882353)
     +      max: 228 (0.894118)
     +      mean: 227.89 (0.893687)
     +      median: 228 (0.894118)
     +      standard deviation: 0.438325 (0.00171892)
     +      kurtosis: 27.3528
     +      skewness: -5.0219
     +      entropy: 0.285571
        Image statistics:
          Overall:
     -      min: 126  (0.494118)
     +      min: 130  (0.509804)
            max: 255 (1)
     -      mean: 197.667 (0.775163)
     -      median: 197.667 (0.775163)
     -      standard deviation: 0 (0)
     -      kurtosis: -1.50001
     -      skewness: -0.3818
     -      entropy: 0
     -  Colors: 1
     +      mean: 204.677 (0.802656)
     +      median: 204.667 (0.802614)
     +      standard deviation: 0.381149 (0.0014947)
     +      kurtosis: -1.49956
     +      skewness: -0.571858
     +      entropy: 0.280543
     +  Colors: 4
        Histogram:
     -    129600: (126,255,212) #7EFFD4 srgb(126,255,212)
     +    2040: (130,255,225) #82FFE1 srgb(130,255,225)
     +    8100: (130,255,227) #82FFE3 srgb(130,255,227)
     +    105240: (131,255,228) #83FFE4 srgb(131,255,228)
     +    14220: (133,255,228) #85FFE4 srgb(133,255,228)
        Rendering intent: Perceptual
        Gamma: 0.454545
        Chromaticity:
     @@ -88,13 +91,13 @@
          png:IHDR.width,height: 480, 270
          png:pHYs: x_res=1, y_res=1, units=0
          png:sRGB: intent=0 (Perceptual Intent)
     -    signature:
 d8f3dc9f8e5d5fdfe8db73baf881f8660f38afc0617dc3130c3fbc484b87cd74
     +    signature:
 0dd1f909b586d9a254b25a7d4f8d9e742fe189c35c1a65e63c9dffde72614506
        Artifacts:
          verbose: true
        Tainted: False
     -  Filesize: 1054B
     +  Filesize: 1577B
        Number pixels: 129600
     -  Pixels per second: 21.2168MP
     +  Pixels per second: 12.2899MP
        User time: 0.010u
     -  Elapsed time: 0:01.006
     +  Elapsed time: 0:01.010
        Version: ImageMagick 7.1.0-4 Q16 aarch64 2021-07-18
 https://imagemagick.org

 Conclusion:
 ==========

   As indicated by the hashes, the *workaround* is to convert
   "yuv444p10le" to some other class of pixel format (like "rgb24")
   before converting to another "yuv*" pixel format:

     scale=out_range=pc, format=yuv444p10le,
       scale=out_range=pc, format=rgb24,     <--------- workaround
         scale=out_range=pc, format=yuv444p

   Nevertheless, a workaround should not even be necessary. There
   is a bug that should be investigated and fixed.

   (As an aside, look at all that "out_range" gibberish; it should
   not be necessary to do that little dance.)
 }}}
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9407>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list