# Rec.709 to RGB24 to Rec.601

1. I think that the following is correct, but I want to make sure. I need to convert from Rec.709 to RGB24 and expand the luma range, so I use this:

Code:
`ConverttoRGB24(matrix="pc.709")`
Then I can work in RGB. As I understand it, Rec.709 and Rec.601 only relate to YUV. Once one has converted to RGB correctly, there is no longer a distinction, so I can work in RGB and then convert to Rec.601 using this:

Code:
`ConverttoYV12()#compresses luma range and assumes Rec.601`
Does anyone know if HCenc converts YV12 to YUY2 internally? If it does, it might be better to use ConverttoYUY2() because HCenc certainly accepts YUY2 as input.

On a related note, given a Rec.709 YUV source, is
Code:
`ConvertToYUY2(matrix="rec709")#keeps the luma in the TV range`
the same as

Code:
```Colormatrix(mode="rec.709->rec.601",clamp=0)
Convertoyuy2()```
and if not, which would people recommend. (I am not really concerned with the clamp parameter: I want to know if the overall conversion produces the same result.) Thanks for any help. I am nearly clear on this sort of thing.
2. Originally Posted by Jeff B
I think that the following is correct, but I want to make sure. I need to convert from Rec.709 to RGB24 and expand the luma range, so I use this:

Code:
`ConverttoRGB24(matrix="pc.709")`
Then I can work in RGB. As I understand it, Rec.709 and Rec.601 only relate to YUV. Once one has converted to RGB correctly, there is no longer a distinction, so I can work in RGB and then convert to Rec.601 using this:

Code:
`ConverttoYV12()#compresses luma range and assumes Rec.601`
Not quite; Rec601/709 refers whenever conversions are done between RGB<=>YUV

If you don't specify a matrix in avisynth, Rec.601 is used

Does anyone know if HCenc converts YV12 to YUY2 internally? If it does, it might be better to use ConverttoYUY2() because HCenc certainly accepts YUY2 as input.
Other way around; It accepts YUY2 or YV12 input and outputs YV12 . (You can export YUY2 also, but this is invalid for DVD)

On a related note, is
Code:
`ConvertToYUY2(matrix="rec709")#keeps the luma in the TV range`
the same as

Code:
```Colormatrix(mode="rec.709->rec.601",clamp=0)
Convertoyuy2()```
and if not, which would people recommend. (I am not really concerned with the clamp parameter: I want to know if the overall conversion produces the same result.) Thanks for any help. I am nearly clear on this sort of thing.
No it doesn't, assuming your source is RGB, the 1st converts RGB to YUY2 using rec709 matrix

The 2nd depends on how you converted RGB to YUV (colormatrix doesn't work on RGB)
3. Thanks for your help, poisonsdeathray. : )

Other way around; It accepts YUY2 or YV12 input and outputs YV12 . (You can export YUY2 also, but this is invalid for DVD)
Sorry, I was unclear. I know that HCenc accepts YUY2 or YV12 input, and that it outputs YV12 (assuming DVD output). I was wondering if HCenc converts YV12 input to YUY2 internally and then downsamples again when it outputs YV12.

Not quite; Rec601/709 refers whenever conversions are done between RGB<=>YUV If you don't specify a matrix in avisynth, Rec.601 is used
Yeah, I'm clear on the above. What I want to know is once you have converted to RGB is all RGB is the same i.e. if you have a Rec.709 source and convert it to RGB would it be qualitatively different from a Rec.601 source converted to RGB (leaving aside luma ranges and alpha channels for a moment)? (There are no vestiges of the video having been rec.709 originally left, so when you have finished working in RGB you can convert to whatever YUV colorspace you like.)

No it doesn't, assuming your source is RGB, the 1st converts RGB to YUY2 using rec709 matrix

The 2nd depends on how you converted RGB to YUV (colormatrix doesn't work on RGB)
Sorry, I didn't envisage an RGB source. I envisaged a Rec.709 one being converted to YUY2. When I said on a related note, I was trying to distance this part from the first half of the post. I was just trying to avoid starting a thread for every question I have.
4. Sorry, I was unclear. I know that HCenc accepts YUY2 or YV12 input, and that it outputs YV12 (assuming DVD output). I was wondering if HCenc converts YV12 input to YUY2 internally and then downsamples again when it outputs YV12.
I doubt it, but if you want to be sure ask Hank at Doom9 forum

What I want to know is once you have converted to RGB is all RGB is the same i.e. if you have a Rec.709 source and convert it to RGB would it be qualitatively different from a Rec.601 source converted to RGB (leaving aside luma ranges and alpha channels for a moment)? (There are no vestiges of the video having been rec.709 originally left, so when you have finished working in RGB you can convert to whatever YUV colorspace you like.)
RGB is RGB (brilliant logic there on my part ); that is - what you see on the monitor/TV is RGB

How you convert to RGB determines whether or not you get the same thing. If you converted with proper matrix you get the same thing (nearly; there are rounding differences)

Sorry, I didn't envisage an RGB source. I envisaged a Rec.709 one being converted to YUY2. When I said on a related note, I was trying to distance this part from the first half of the post. I was just trying to avoid starting a thread for every question I have.
If you start with Rec.709 YV12 source, and use ConvertToYUY2() , it's still Rec.709 because you are still in YUV (and again by "Rec.709 YV12 Source " I mean originally RGB but converted to YUV using Rec709)

Remember this and you won't go wrong:
The matrix only takes effect when you do RGB<=>YUV conversions

Colormatrix() filter is unique because it can do changes in YUV (staying in YUV)
5. If you start with Rec.709 YV12 source, and use ConvertToYUY2() , it's still Rec.709 because you are still in YUV
Ah, so YUY2 can be either Rec.709 or Rec.601! I wasn't sure that it could be. I thought perhaps that these distinctions only applied to YV12.

Remember this and you won't go wrong:
The matrix only takes effect when you do RGB<=>YUV conversions
Thanks! So when used on a Rec.709 source, ConverttoYUY2() doesn't assume Rec.601 coefficients, as it does with an RGB source. That helps greatly. In that case, hypothetically, if I had a Rec.709 source and Rec.601 source and wanted to work in YUY2 and splice them together I would have to use colormatrix(mode="rec.709->rec.601") on the former, then ConverttoYUY2() and then splice them. Got it! Thanks again.
6. Originally Posted by Jeff B
If you start with Rec.709 YV12 source, and use ConvertToYUY2() , it's still Rec.709 because you are still in YUV
Ah, so YUY2 can be either Rec.709 or Rec.601! I wasn't sure that it could be. I thought perhaps that these distinctions only applied to YV12.
To be more precise, Rec601/709 only refers to how that YUV video was derived. ie. what matrix was used to convert from the original RGB source to YUV to make that video. The RGB might be a master format. As an end user, you usually only have access to YUV video (e.g. DVD, blu-ray, HDTV caps)

Remember this and you won't go wrong:
The matrix only takes effect when you do RGB<=>YUV conversions
So when used on a Rec.709 source, ConverttoYUY2() doesn't assume Rec.601 coefficients, as it does with an RGB source. That helps greatly.
Correct, it does nothing in terms of colorimetry, because YUV=>YUV

In that case, hypothetically, if I had a Rec.709 source and Rec.601 source and wanted to work in YUY2 and splice them together I would have to use colormatrix(mode="rec.709->rec.601") on the former, then ConverttoYUY2() and then splice them. Got it!
Yes that would work, assuming everything was done correctly prior to that
7. To be more precise, Rec601/709 only refers to how that YUV video was derived. ie. what matrix was used to convert from the original RGB source to YUV to make that video. The RGB might be a master format. As an end user, you usually only have access to YUV video (e.g. DVD, blu-ray, HDTV caps)
I see. These would be the 4:4:4 RGB files that are used to edit movies. Thanks for your help. I think I understand now.
8. Originally Posted by Jeff B
I think that the following is correct, but I want to make sure. I need to convert from Rec.709 to RGB24 and expand the luma range, so I use this:
Code:
`ConverttoRGB24(matrix="pc.709")`
If by expand the luma range, you mean go from luma 16-235 to RGB 0-255, then you would use matrix="Rec709".
If you use matrix="pc.709", it will map luma 0-255 to RGB 0-255.

On a related note, given a Rec.709 YUV source, is
Code:
`ConvertToYUY2(matrix="rec709")#keeps the luma in the TV range`
the same as
Code:
```Colormatrix(mode="rec.709->rec.601",clamp=0)
Convertoyuy2()```
The 'matrix' parameter to the Convert functions is only valid when converting to and from RGB, so you would get an error from the first code.
9. Originally Posted by Gavino
If by expand the luma range, you mean go from luma 16-235 to RGB 0-255, then you would use matrix="Rec709".
That is indeed what I meant. Thanks for the correction. I'm not sure why you italicised the word "expand" though. Is that not the usual term for converting 16-235 to 0-255?

Statistics