Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,666
|
SafeColorLimiter
Hi there folks,
the idea is to automatize clipping to get a broadcast safe output in Limited TV Range (0.0-0.7mV). 8bit sources will be limited to 16 - 235 luma and 16 - 240 chroma 10bit sources will be limited to 64 - 940 luma and 64 - 960 chroma 12bit sources will be limited to 256 - 3760 luma and 256 - 3840 chroma 14bit sources will be limited to 1024 - 15040 luma and 1024 - 15360 chroma 16bit sources will be limited to 4096 - 60160 luma and 4096 - 61440 chroma 32bit sources will be limited to 16/255.0 - 235/255.0 luma and -112/255.0 - -112/255.0 - 112/255.0 chroma It supports y8, y10, y12, y14, y16, y32, yv12, YUY2, yv16, yv24 and YUV 4:2:0 planar, YUV 4:1:1 planar, YUV 4:2:2 planar, YUV 4:4:4 planar 10-12-14-16-32bit, including those with alpha channel. If the input is in RGB, it will just return the input untouched. Script: https://github.com/FranceBB/SafeColorLimiter Last edited by FranceBB; 12th October 2020 at 14:46. |
![]() |
![]() |
![]() |
#2 | Link |
Registered User
Join Date: Oct 2018
Posts: 313
|
Code:
passthrough ? out=my_catched_out : out=my_out
__________________
AviSynth AiUpscale |
![]() |
![]() |
![]() |
#3 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,666
|
Ok, so "?" already evaluates if it's true, but there's still the problem with the line above and the 32bit float individuation.
Besides, I was trying something like: Code:
ColorBars(848, 480, pixel_type="YV24") ConvertBits(32) Limiter(min_luma=0.0625, max_luma=0.91796875, min_chroma=0.0625, max_chroma=0.91796875) ![]() which is weird, considering that in 32bit float min_luma is supposed to be 16/256 which is 0.0625 and max_luma is supposed to be 235/256 which is 0.91796875 |
![]() |
![]() |
![]() |
#4 | Link |
Registered User
Join Date: Oct 2018
Posts: 313
|
Actually it is "value/255.0 for Y (luma) channel and (value-128)/255.0 for U/V chroma channels" according to this when using autoscale = true
__________________
AviSynth AiUpscale Last edited by Alexkral; 25th September 2020 at 10:07. |
![]() |
![]() |
![]() |
#5 | Link | |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,666
|
Quote:
Code:
Limiter(min_luma=0.0627450980392157, max_luma=0.9215686274509804, min_chroma=-0.4392156862745098, max_chroma=0.4196078431372549) ![]() however that's an approximation; when I try to use the right float values through mathematical operations in Avisynth I get a completely black output: Code:
ColorBars(848, 480, pixel_type="YV12") ConvertBits(32) min_luma_float=16/255 max_luma_float=235/255 min_chroma_float=-112/255 max_chroma_float=107/255 Limiter(min_luma=min_luma_float, max_luma=max_luma_float, min_chroma=min_chroma_float, max_chroma=max_chroma_float) Last edited by FranceBB; 25th September 2020 at 10:03. |
|
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Jul 2018
Posts: 370
|
Code:
ColorBars(848, 480, pixel_type="yuv420ps") min_luma_float=16/255.0 max_luma_float=235/255.0 min_chroma_float=-112/255.0 max_chroma_float=112/255.0 Limiter(min_luma=min_luma_float, max_luma=max_luma_float, min_chroma=min_chroma_float, max_chroma=max_chroma_float) Code:
ColorBars(848, 480, pixel_type="yuv420ps") Limiter(paramscale=true) |
![]() |
![]() |
![]() |
#7 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,666
|
Ah! Ok, thanks, I edited it.
I'll edit the wiki later as well, thanks. So that's why the autoscale wasn't working, it's actually called paramscale. EDIT: Fixed error in the wiki by swapping "autoscale" with "paramscale" Thanks! Last edited by FranceBB; 25th September 2020 at 13:16. |
![]() |
![]() |
![]() |
#11 | Link |
Cary Knoop
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
|
Almost all software treats the visible range for floats between 0.0 and 1.0. Both limited and full range gets mapped onto this interval.
WTW and BTB are not clipped but exist outside those values. Last edited by Cary Knoop; 25th September 2020 at 15:56. |
![]() |
![]() |
![]() |
#13 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
there's no such thing as fp32 safe color, same as there's no limited range RGB.
YCbCr is always defined on [0.0, 1.0] for Y and [-1.0, 1.0] for CbCr for fp32 it is conceptually incorrect to assume there's a "hard" range for floating point samples Last edited by feisty2; 27th September 2020 at 08:57. |
![]() |
![]() |
![]() |
#14 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
Quote:
https://forum.doom9.org/showthread.p...58#post1843058 By Pinterf - release of AviSynthPlus-MT-r2693.exe, (Quoting from Locked thread dont work any more [if it ever did]) Code:
- Changed (finally): 32bit float YUV colorspaces: zero centered chroma channels. U and V channels are now -0.5..+0.5 (if converted to full scale before) instead of 0..1 Note: filters that relied on having the U and V channel center as 0.5 will fail. Why: the old UV 0..1 range was a very-very early decision in the high-bitdepth transition project. Also it is now compatible with z_XXXXX resizers (zimg image library, external plugin at the moment). - New function: bool IsFloatUvZeroBased() For plugin or script writers who want to be compatible with pre r2672 Avisynth+ float YUV format: Check function availablity with FunctionExists("IsFloatUvZeroBased"). When the function does not exists, the center value of 32 bit float U and V channel is 0.5 When IsFloatUvZeroBased function exists, it will return true (always for official releases) if U and V is 0 based (+/-0.5) - Fix: RGB64 Turnleft/Turnright (which are also used in RGB64 Resizers) - Fix: Rare crash in FrameRegistry - Enhanced: Allow ConvertToRGB24-32-48-64 functions for any source bit depths - Enhanced: ConvertBits: allow fulls-fulld combinations when either clip is 32bits E.g. after a 8->32 bit fulls=false fulld=true: Y: 16..235 -> 0..1 U/V: 16..240 -> -0.5..+0.5
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 27th September 2020 at 11:17. |
|
![]() |
![]() |
![]() |
#15 | Link | ||
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
Quote:
for this particular formula listed on avisynth.nl Quote:
|
||
![]() |
![]() |
![]() |
#16 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
OK, thanks, F2.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#17 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,666
|
New version, see first post or: https://github.com/FranceBB/SafeColorLimiter
Update: - Code cleanup. - Moved project to Github. - Introduced support to Y8, Y10, Y12, Y14, Y16, Y32 and YUV411 - Fixed a bug that would prevent the script from returning a clip when the input had an Alpha Channel |
![]() |
![]() |
![]() |
#20 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,258
|
There is such a thing as "limited range RGB" . It's also known as "studio range RGB" . In 8bit RGB , 16-235 is black to white (sRGB or "computer RGB" is 0-255 black to white in 8bit, it's far more common) . Limited range RGB is used in r103 compliance checks for broadcast, and some NLE's like vegas use studio range RGB .
But it usually makes more sense to limit at the end , not intermediate float processing; and you usually don't deliver a float format in the first place. (common exception would be intermediate stages for production, such as EXR for VFX ). I don't see a usage case where it would be used in float, so it probably is a good idea to remove it For this filter - limiting the min/max limits does not make something necessarily "broadcast safe" . Many YUV values "map" to illegal broadcast values that lie in the middle of the Y,U,V ranges . So the name for the filter is a bit of a misnomer. But typically you're allowed <1% illegal values in scenarios like r103 Last edited by poisondeathray; 12th October 2020 at 17:45. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|