Log in

View Full Version : How do ConvertToRGB* handle out-of-range YUV combinations?


fvisagie
25th March 2013, 12:41
When the input clip to ConvertToRGB*() contains pixels with out-of-range YUV combinations no error is thrown, so presumably they are processed somehow. However, I can't find any explanation in the Convert description (http://avisynth.org/mediawiki/ConvertToRGB) of how this done. What exactly happens in such cases?

Thanks,
Francois

2Bdecided
25th March 2013, 13:34
The resulting RGB values are clipped to be within the range 0-255.

Cheers,
David.

fvisagie
25th March 2013, 18:57
Thanks, appreciated.

Gavino
25th March 2013, 20:47
See the thread U and V ranges for valid RGB for a demonstration, and post #14 of the thread (and the later post #25) for a function that will identify the out-of-range pixels in a frame.

fvisagie
26th March 2013, 09:15
Thanks, Gavino, that's a very useful function and thread.

fvisagie
26th March 2013, 09:47
In the case where

Input is in out-of-RGB-gamut YUV
Intermediate conversion to and from RGB32 is needed, and
Output is in YUV


a useful approach seems to be

# Reduce number of pixels that will be clipped by RGB conversion
Levels(...)
ConvertToRGB(...)
# RGB32 work
ConvertToYV12(...)
# Back in YUV complete rest of colour treatment to what's desired for aesthetics and what output can handle:
# restore colour range and/or correct gamma and/or adjust dynamic range etc.


This will require balancing reduced clipping against loss of colour resolution, but in principle this may be worth trying out, correct? I'm asking because I don't always know enough yet to understand what I'm looking at ;).