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. |
8th January 2015, 13:03 | #1 | Link |
Registered User
Join Date: Mar 2007
Posts: 192
|
10-bit safe colors
I've posted this in the AutoAdjust forum with no replies so it might be more of a general AVIsynth topic:
Is it possible to use AVIsynth to limit the chroma and black levels of 10-bit video? According to bt.709 specs we need to keep the Y within 64-940 and UV at 64-960, and black has to be limited at 64. |
8th January 2015, 13:24 | #2 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
here's the math
(1023-a)/(a-0)=(940-x)/(x-64) #simplified version: (1023-0)/(a-0)=(940-64)/(x-64) a is the value in full range (0-1023) x is the target limited range value (64-940) now all you have to do is convert the expression above to "x = ???? a" form and wrap it in Dither_lut16 () I don't wanna do it, cuz I might be the laziest guy on this planet :P EDIT: fine, here Dither_lut16 ("x 876 * 1023 / 64 +", y=3, u=2, v=2) Dither_lut16 ("x 896 * 1023 / 64 +", y=2, u=3, v=3) Last edited by feisty2; 8th January 2015 at 13:37. |
8th January 2015, 17:27 | #3 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
What feisty2 posted is correct if your source is full-range 10-bit and is zero-padded in the MSB instead of LSB.
If all you want is to clip the Y/Cb/Cr values for a source that is already nominally limited-range 10-bit (with peaks/troughs that might exceed the 16/235/240 limits because of compression artifacts or whatever), that's easily done with Dither_lut16 too. Code:
Dither_lut16(expr="x 4 / 16 max 240 min 4 *", yexpr="x 4 / 16 max 235 min 4 *", u=3, v=3) # zero padding in LSB # OR (don't use both) Dither_lut16(expr="x 256 / 16 max 240 min 256 *", yexpr="x 256 / 16 max 235 min 256 *", u=3, v=3) # zero padding in MSB
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! |
8th January 2015, 20:01 | #4 | Link |
Registered User
Join Date: Mar 2007
Posts: 192
|
Thanks.
How can I tell if my source is full-range 10-bit and is zero padded in the MSB instead of LSB? All I know about it is that its a ProRes high profile. So far I was using FFvideoSource with the 10-bit hack to decode it, followed by f3kdb_dither, but I'm not sure I'm doing it right. |
9th January 2015, 08:22 | #5 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
The builds of FFMS that have the enable10bithack option return the result with zero padding in the least significant bits. Not every source filter does the same thing, which is why confirming this is pretty important.
If you want to confirm whether your source is limited-range or full-range, put a Histogram() after the f3kdb_dither and look out for particularly dark or bright scenes. If you see white spots extending well into the brown regions, that means your source is full-range. If you don't, it could be either full-range or limited-range, and you should check other dark/bright scenes. (This is not an exact science and necessarily involves some guesswork.) If it turns out that the source is limited-range (which I'm guessing it is, because full-range >8-bit is kind of rare), you can use either the Dither_lut16 line I posted before or the keep_tv_range option in f3kdb_dither.
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! |
9th January 2015, 10:43 | #6 | Link |
Registered User
Join Date: Feb 2002
Location: Germany
Posts: 540
|
To get legal and valid colors it's not enough to bring Y'CbCr values into the needed boundaries. You also have to limit in R'G'B' color space.
Some very interesting documents about this topic: http://www.tek.com/document/applicat...illegal-colors http://www.poynton.com/notes/video/Confusion.html regards hanfrunz |
|
|