happycube / ld-decode

Software defined LaserDisc decoder
GNU General Public License v3.0
307 stars 80 forks source link

Add YCbCr input support to ld-chroma-encoder #813

Closed ifb closed 1 year ago

ifb commented 1 year ago

Adds the -p/--input-format options. Below-black (pluge) patterns are possible now.

There's about a 6 dB bump in PSNR for YUV which makes me distrust the test a bit. The difference is visible, though.

NTSC bars line 420 https://imgsli.com/MTM0NjYx NTSC bars vectorscope https://imgsli.com/MTM0NjYy mobcal frame 3 https://imgsli.com/MTM0NjU2

../scripts/test-chroma --build ./ --system ntsc  ../mobcal.y4m --input-format yuv
Phase-Comp (Dec)   Decoder         Format   PSNR (dB)
False              ntsc1d          rgb         24.54
False              ntsc1d          yuv         24.19
False              ntsc1d          y4m         24.19
False              ntsc2d          rgb         29.20
False              ntsc2d          yuv         29.00
False              ntsc2d          y4m         29.00
False              ntsc3d          rgb         29.99
False              ntsc3d          yuv         29.78
False              ntsc3d          y4m         29.78
True               ntsc1d          rgb         24.36
True               ntsc1d          yuv         23.97
True               ntsc1d          y4m         23.97
True               ntsc2d          rgb         28.87
True               ntsc2d          yuv         28.64
True               ntsc2d          y4m         28.64
True               ntsc3d          rgb         29.61
True               ntsc3d          yuv         29.39
True               ntsc3d          y4m         29.39

../scripts/test-chroma --build ./ --system ntsc  ../mobcal.y4m --input-format rgb
Phase-Comp (Dec)   Decoder         Format   PSNR (dB)
False              ntsc1d          rgb         18.73
False              ntsc1d          yuv         18.73
False              ntsc1d          y4m         18.73
False              ntsc2d          rgb         23.38
False              ntsc2d          yuv         23.37
False              ntsc2d          y4m         23.37
False              ntsc3d          rgb         23.99
False              ntsc3d          yuv         23.99
False              ntsc3d          y4m         23.99
True               ntsc1d          rgb         18.56
True               ntsc1d          yuv         18.56
True               ntsc1d          y4m         18.56
True               ntsc2d          rgb         23.09
True               ntsc2d          yuv         23.08
True               ntsc2d          y4m         23.08
True               ntsc3d          rgb         23.68
True               ntsc3d          yuv         23.67
True               ntsc3d          y4m         23.67
atsampson commented 1 year ago

The code looks good. The comparison is interesting - in the mobcal comparison it looks like the RGB version has half the vertical chroma resolution, maybe? Is ffmpeg somehow going via a subsampled YCbCr format when we're generating the input?

ifb commented 1 year ago

I believe the swscale defaults are notoriously bad. accurate_rnd and full_chroma_int are off by default? I personally always use zscale, but it doesn't ship with Ubuntu.

https://ffmpeg.org/ffmpeg-scaler.html https://ffmpeg.org/ffmpeg-filters.html#zscale-1

atsampson commented 1 year ago

In case anyone else is wondering about this, I tried adding -sws_flags accurate_rnd+bitexact+full_chroma_inp+full_chroma_int to the ffmpeg command in test-chroma, but it made no difference to the PSNRs...