ArturAlekseev / AVS_SoftLight

AviSynth Softlight plugin
5 stars 0 forks source link

Feature request: high bit depth support #1

Closed Selur closed 4 months ago

Selur commented 7 months ago

Would be nice if (at least for Vapoursynth) RGBS, RGBH, RGB48, RGB30, YUV44P16, YUV44P10 could be supported. This way one could use it on high bit depth sources without having to lose the precision (for example by converting 32bit RGBS to 8Bit RGB24 or YUV44P8).

ArturAlekseev commented 7 months ago

Yes, I will add support. Just need to find sources to test on. Think I need one P10 and just convert it to other formats for test.

Selur commented 7 months ago

https://www.arri.com/en/learn-help/learn-help-camera-system/camera-sample-footage-reference-image has some nice samples.

ArturAlekseev commented 4 months ago

Added 10 bit support (YUV420, YUV444, Planar RGB). Planar RGB 10 bit in VapourSynth is RGB30.

Selur commented 4 months ago

Using:

clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, range_s="limited")
# color adjustment using SoftLight
clip = core.Argaricolm.Softlight(clip, mode=4, formula=1)

with latest v.1.14 only half of the image is processed grafik same with RGB30 and YUV420P10

Selur commented 4 months ago

=> 10bit support does not work properly in Vapoursynth

ArturAlekseev commented 4 months ago

Looks like VapourSynth passes frame info differently. Will check/fix now. Btw you better use softlight(8) + softlight(3) for content like on picture. If you want to see real colors + blacks. And don't forget to set full color range flag for your output (like in VUI nvencc in staxrip). Also if you want to watch full color range in mpc-hc - you need to select EVR decoder in settings (default decoder will cut range to limited again).

Selur commented 4 months ago

I'll remember to use full color range for the filter and convert back to "limited" after the filter when needed.

ArturAlekseev commented 4 months ago

No, its not necessary to convert to full or limited before using filter. YUV<->RGB formula works fine for both. Just convert if you want specific result. As for the bug: VapourSynth gives width in pixels while AviSynth gives in bytes (*2 for 10 bit). I'll publish update now.

Selur commented 4 months ago

okay, to be sure. If I feed it limited YUV content and it internally converts to RGB and back the luma scaling afterwards will still be limited, or will it be full?

ArturAlekseev commented 4 months ago

From what I'v understood YUV<->RGB conversion formula used will not change color range. So if you pass limited input you will get limited RGB inside and limited output after. It may (maybe) go a little out of range. Formula is here. For example: YUV (Y=16,U=128,V=128) => RGB (16,16,16) => YUV (15,128,128) But this is on page. He uses math.floor rounding. I use "round" in my code. So maybe it will give 16 128 128 back. But softlight function itself does not care about color range. So it may decrease level 16 resulting in values that are not allowed in limited color range. So easily speaking you can just give limited color range input and you will get limited output. You do not need to rerange it to limited. Just tell encoder that it is limited (if encoder cares). NVENCC for example does not care about color range at all. It will just set color range flag you specify that may be used by decoder (TV/box). Technically colors that went out of range will be some sort of technical noise. Because when limited range is converted to full range (for viewing) - all values out of range will be just dropped (become 0 or 255).

Selur commented 4 months ago

Okay, nice, just wanted to make. Sure the playback part and vui setting is no problem. :) => looking forward for the fixed version with 10bit support in Vapoursynth :)

ArturAlekseev commented 4 months ago

Check it out.

Selur commented 4 months ago

Works fine. Thanks for fixing it so swiftly! 👍