View Single Post
Old 19th August 2019, 00:10   #93  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by hello_hello View Post

First we have this table showing the difference between NTSC and PAL color primaries (from Wikipedia).
A quick glance and it appears those values are different than the official specs, not sure what's up with that . I think the ones in wikipedia are older, I think it was revised again later. I'd probably trust the official ITU document - that's what zimg/zlib uses and I'm pretty sure jpsdr goes by it too. Anyways, the point is they have different primaries.

Quote:
Color Matrix is the formula for converting YUV back to RGB (or more correctly converting YCbCr to RGB).
From what I understand now, there's only one formula for each, but there's constant(s) in each formula that are different for 525 line, 625 line (and rec.709) to account for the different primaries. If the wrong "constants" are used you don't convert back to exactly the same RGB you started with. Is that a correct assumption?

So the formula for converting between the rec.601 and rec.709 matrices is a standard formula used by most programs, that should take into account the different "constants" for red, blue and green, but doesn't because that makes stuff-all difference compared to using the wrong matrix, and I assume in many cases the original RGB primaries might be unknown anyway. I think I finally understand what "ignoring the primaries" means....
Yes, if you use the wrong assumption or value you get different colors than expected. Remember - 6 values total - for matrix, transfer, primaries. Input and output . Transfer cancels out for both 601(525 and 625) and 709 . Primaries are usually ignored for the 709/601 case (input and output are calculated as "unspecified" so there is no net effect of primaries) . So the only thing that affects the conversion is matrix in most software for the 709/601 case



Quote:
I assume HDRTools does account for those primaries... hence the two flavours of rec.601.... so to be technically accurate, assuming I'm encoding with x264 for example, if I converted HD to SD using the rec.601_625 formula, I should specify bt470bg for the color primaries and for the color matrix (rather than rec.709 for primaries and bt470bg for matrix), and if I'm upscaling from PAL to HD it'd be bt709 for the primaries and matrix (rather than bt470bg and rec.709)? Not that I've bothered setting the color primaries for a long time, just the matrix.
I'm not sure what it does; I haven't really used it much. But if it accounts for the primaries difference (ie. primaries_input was 709, primaries_output is 601_625) - you'll usually get shifted colors in typical programs, because when they convert back to RGB for display, they usually only use the matrix the way most people have programs configured.

Note that in x264, those --colorprim xxx --transfer xxx --colormatrix xxx switches are just VUI metadata. They don't actually do anything. It's up to the other recieving software how it's handled . Some pay attention to that metadata. e.g vapoursynth. So if you do that actual primaries adjustment, and flag it accordingly, you end up getting the expected colors.
poisondeathray is offline   Reply With Quote