YUView icon indicating copy to clipboard operation
YUView copied to clipboard

Lanczos 2 upsampling algorithm, recommended in ITU-T H series Supplement 18

Open ValZapod opened this issue 3 years ago • 5 comments

As you may know SDR BT.2020 spec. and HDR (PQ and HLG transfer) stuff introduced in BT.2100 all require top-left chroma sitting (type 2, where possible types are 0, 1, 2, 3, 4, 5) if subsampled to 4:2:0. Yet not only I do not see it, but I also cannot see the use of normal 444 chroma upsampler a.k.a. FIR. ITU-T H series Supplement 18 recommends at least Lanczos 2.

Describe the solution you'd like Better use ffmpeg? Zimg uses Lanczos 2 by default and supports all chroma locations, but so does swscaler. I recently wrote how to do this stuff in swscale. Last paragraph https://trac.ffmpeg.org/wiki/Scaling

Some obvious logic, R'G'B' does not have chroma siting, since no chroma, 4:4:4 does not have it either. 4:2:2 has only one siting.

ValZapod avatar Jan 24 '22 07:01 ValZapod

It may be good to do Lanczos 4 (that means with 4 taps). https://forum.doom9.org/archive/index.php/t-161263.html and

https://github.com/FFmpeg/FFmpeg/commit/58e59396f5fe93f0606dc458d84c609b5d23ea1c#diff-1664bc2b6de9114b685897e0152a71de38d58acdfb642639bd8c2210ef4cc68fR904

zscale already uses 3 taps by default (in mpv in particular).

ValZapod avatar Jan 29 '22 11:01 ValZapod

@ChristianFeldmann So do you default for left chroma siting?

ValZapod avatar May 24 '22 09:05 ValZapod

Hi! The default if you open a 4:2:0 YUV file is ChromaLocType=0 as in left. You can actually set this position in the YUV format selection: image So if you set both offsets to 0 you get type 2 (top left). For the chroma interpolation algorithm, however, we only have the ones available under Chroma Interpolation. So no Lanczos yet.

ChristianFeldmann avatar May 25 '22 10:05 ChristianFeldmann

So if you set both offsets to 0 you get type 2 (top left).

Oh! Thank you!

For the chroma interpolation algorithm, however, we only have the ones available under Chroma Interpolation. So no Lanczos yet.

Understood! Will rename the issue!

ValZapod avatar May 25 '22 11:05 ValZapod

I just looked through the code of zimg a bit on the weekend and that may be very interesing to integrate here. They support basically all relevant conversions and on top also SIMDI accelerated code.

ChristianFeldmann avatar May 30 '22 07:05 ChristianFeldmann