# IRE to Studio Swing

1. I'm having trouble working out an equation to convert IRE units to digital values within studio swing. Such an equation would give the following results:

0 IRE -> digital 0

7.5 IRE -> digital 16

100 IRE -> digital 235

I've tried but am having trouble getting the above results. Any help is appreciated.

Thank you.
2. For Japanese NTSC (IRE 0-100):
Code:
`Y = IRE * 2.19 + 16`
For North American NTSC (IRE 7.5-100):
Code:
`Y = (IRE-7.5) * 2.37 + 16`
Keep in mind that the IRE 7.5 setup is only for North American analog video. Once it's converted to digital IRE 7.5 becomes Y=16. For Japanese NTSC there is no setup so IRE 0 becomes Y=16.

If you're wondering where 2.19 and 2.37 come from:

For Japanese NTSC video IRE 0 to 100 is 100 units. That accounts for Y=16-235, 219 units. 219/100 = 2.19.

For North American NTSC video IRE 7.5 to 100 is 92.5 units. That accounts for Y=16-235, 219 units. 219/92.5 ~= 2.37
3. Thanks, jagabo.

Your code was returning -2 for 0 IRE so I modified it (yes, this is for North America)

This code is for Libre Office/Excel with IRE in cell A16:

Code:
`=IF(A16>=0.75, (A16-7.5) * 2.37 + 16,0)`
4. MAX also works and is more self-documenting:

Code:
`=MAX((A16 - 7.5) * 2.37 + 16, 0)`
5. Note you can get a little better precision with more digits to the right of the decimal point: 2.3675675... Or do the multiply and divide explicitly:

Code:
`Y = (IRE-7.5) * 219 / 92.5 + 16`
6. The (219/92.5) must be enclosed in parentheses.

This works:

Code:
`=IF((A4-7.5) * (219/92.5) + 16<0,0,(A4-7.5) * (219/92.5) + 16)`
Or if you're coding it:

Code:
```n = (IRE-7.5) * (219/92.5) + 16

if n < 0
n = 0
endif```
7. Going back to our discusion of SMPTE RP 219 bars of several months ago, here are the digital values you would use for the percentages given in the spec, confined to studio swing 16 - 235.

Do they look good to you?

Code:
```Percent	Digital

100	        235
75	        180
40	        104
15	         49
0	         16
4	         25
2	         20
-2	         12```
8. Originally Posted by chris319
I'm having trouble working out an equation to convert IRE units to digital values within studio swing. Such an equation would give the following results:

0 IRE -> digital 0

7.5 IRE -> digital 16

100 IRE -> digital 235

I've tried but am having trouble getting the above results. Any help is appreciated.

Thank you.
Please describe your goal - pedestal is added by hardware not encoded in video data (so 16 means always black i.e. 0 and this apply for USA, Japan, Europe etc) - normally IRE is unit used in analog video not digital.
9. Mainly a matter of curiosity. There are a few IRE values of interest in NTSC: 7.5 IRE, 100 IRE, various values found in NTSC color bars.
10. Color bars explained here:
http://avisynth.nl/index.php/ColorBars#TV_range

https://www.itu.int/rec/R-REC-BT.601-7-201103-I/en

Recommendation ITU-R BT.601-7
Studio encoding parameters of digital television
(Annex 1, Table 3)

luminance signal
220 (8-bit) or 877 (10-bit) quantization levels with the black level corresponding to
level 16.00d and the peak white level corresponding to level 235.00d. The signal level
may occasionally excurse beyond level 235.00d or below level 16.00d.

each colour-difference signal
225 (8-bit) or 897 (10-bit) quantization levels in the centre part of the quantization
scale with zero signal corresponding to level 128.00d. The signal level may
occasionally excurse beyond level 240.00d or below level 16.00d.
No mention of IRE or setup levels, just that "black" should be at digital 16.
11. Originally Posted by chris319
The (219/92.5) must be enclosed in parentheses.
Not by algebraic rules.

Code:
`Y = (IRE-7.5) * 219 / 92.5 + 16`
is the same as:

Code:
`Y = (IRE-7.5) * (219 / 92.5) + 16`
is the same as:

Code:
`Y = (((IRE-7.5) * 219) / 92.5) + 16`
is the same as:

Code:
`Y = (IRE-7.5) / 92.5 * 219 + 16`
12. Originally Posted by chris319
Mainly a matter of curiosity. There are a few IRE values of interest in NTSC: 7.5 IRE, 100 IRE, various values found in NTSC color bars.
If this for your own hardware then you may not follow BT.601 rules on digital codes but once again - in market HW pedestal is created by NTSC encoder not coded with signal samples. Usually there is special bit to enable/disable pedestal as such there is always same 220 quantization levels they are squeezed in analog domain between 7.5IRE and 100IRE.
13. Originally Posted by pandy
Originally Posted by chris319
Mainly a matter of curiosity. There are a few IRE values of interest in NTSC: 7.5 IRE, 100 IRE, various values found in NTSC color bars.
If this for your own hardware then you may not follow BT.601 rules on digital codes but once again - in market HW pedestal is created by NTSC encoder not coded with signal samples. Usually there is special bit to enable/disable pedestal as such there is always same 220 quantization levels they are squeezed in analog domain between 7.5IRE and 100IRE.
Why are you banging on about this? The OP is interested in the correspondence between IRE and digital values that is the result of sampling, not according to some normative standard. No one has suggested that the dreaded NTSC pedestal exists in the digital domain.
14. There is an error in the values in avisynth's pluge table. It shows one of the pluge stripes at -4 IRE. This is not allowed in analog NTSC as anything below blanking (0 IRE) interferes with the sync pulses.

See figure 17.5 here:

http://www.xilinx.com/support/documentation/application_notes/xapp514.pdf
15. No one has suggested that the dreaded NTSC pedestal exists in the digital domain.
The studio swing value of 16 can be thought of as a pedestal of sorts.

In broadcast work (ATSC) digital 0 and 255 are reserved for sync.
16. Originally Posted by chris319
There is an error in the values in avisynth's pluge table...
I noticed that earlier today and have made some clarifications:
...a series of black and near-black bars: 0, -4, 0, +4 and 0 IRE relative to black.

Note 'IRE' is used here to mean 'percent luminance', on a scale from 0 (black) to 100 (white), ignoring the varying broadcast standards where black might be 0 IRE or 7.5 IRE depending on the country.
If further corrections are needed, please let me know -- remembering that frameserving is not broadcasting; there is no sync pulse.
17. I don't know how to read the digital value of the black stripe level in BT.814-2, do you?

It says (12)48.
18. Originally Posted by chris319
I don't know how to read the digital value of the black stripe level in BT.814-2, do you?

It says (12)48.
Sample value 12 for 8 bit and 48 for 8.2 (10 bit where 16 = 64 and 235 = 940 - i.e. normal studio mode).
19. This takes into account the fact that 0 is reserved for sync:

Code:
`=IF((A4-7.5) * (219/92.5) + 16<1,1,(A4-7.5) * (219/92.5) + 16)`
Code:
```n = (IRE-7.5) * (219/92.5) + 16

if n < 1
n = 1
endif```
20. While we're on the subject of Avisynth, in their table giving the 8-bit RGB values for "TV range" color bars, yellow is shown as R = 180, G = 180, B = 16. http://avisynth.nl/index.php/ColorBars#TV_range

Would it not be proper for, say, yellow to be R = 180, G = 180, B = 1?

I'll have to get out my copy of Ennes but IIRC in analog color bars B equals 0 in the yellow bar. No setup (7.5 IRE) is added, thus making all colors fully saturated. In "TV range", 0 is reserved for sync so the next avaliable value would be digital 1. By making B = 16 in the yellow bar it is not fully saturated.

It's true that 16 is the blackest black in "TV range" video but the values from 1 to 15 are also legal values and can be thought of as super black, just as anything between 0 and just below 7.5 IRE is super black. I consider digital 16 to be comparable to a digital setup or pedestal.
21. >It's true that 16 is the blackest black in "TV range" video but the values from 1 to 15 are also legal values and can be thought of as super black...
Right, and the same applies to R, G and B in RGB space. "Yellow" has no blueness, and "zero blue" is digitized as 16 on a 0-to-255 scale.

It's possible to have negative blue, even if if can't be displayed - that's the whole purpose of studio swing.
(EDIT true, studio RGB is unusual, but that's the way ColorBars does it, and its behavior is correctly documented if I do say so myself)

EDIT for full range RGB, use code like
ColorBars(pixel_type="YV24").ConvertToRGB32(matrix ="Rec601")
or
ColorBarsHD.ConvertToRGB32(matrix="Rec709")

>I consider digital 16 to be comparable to a digital setup or pedestal.
Not really. PAL (and NTSC-J) functions perfectly well with no pedestal, and both PAL and NTSC can have occasional signal excursions below zero IRE without causing sync problems.

Besides, computer video has no setup and no sync. The color values 0 and 255 are perfectly legitimate.
22. I got out my copy of Ennes and it clearly states in figure 2-18(c), page 77 that yellow, for example:

R = 1
G = 1
B = 0

In ATSC, 0 is reserved for sync so multiplying by 235 we get:

R = 235
G = 235
B = 1

Again, by making B equal to 16 we do not have a 100% saturated yellow. If a video application implements the yellow color bar with B = 16 then I would suggest that the program's implementation of color bars is flawed.
23. Yes,
R = 1
G = 1
B = 0
...on a scale from 0.0 to 1.0.

Transforming to a 16..235 scale, we get
R = 1.0*219+16 = 235
G = 1.0*219+16 = 235
B = 0.0*219+16 = 16
24. The equation for transforming from what I will call normal (black=0.0, white=1.0) to studio (black=16, white=235) is, I believe:

Xstudio := Xnormal*219 + 16

for example,
Code:
```  1.055normal*219+16 = 247studio // "superwhite"
1.000normal*219+16 = 235studio // "white" / 100 IRE
0.000normal*219+16 =  16studio // "black" / 0 or 7.5 IRE
-0.055normal*219+16 =   4studio // "superblack"```
so the equation for transforming in the opposite direction would be:

Xnormal := (Xstudio-16)/219

for example,
Code:
``` (254studio-16)/219 =  1.087normal // "superwhite"
(235studio-16)/219 =  1.000normal // "white" / 100 IRE
(16studio-16)/219 =  0.000normal // "black" / 0 or 7.5 IRE
(1studio-16)/219 = -0.068normal // "superblack"```
25. The board software is having a bad day today.

The equation for transforming from what I will call normal (black=0.0, white=1.0) to studio (black=16, white=235) is, I believe:

Xstudio := Xnormal*219 + 16
Yes, and there is language in §3.5.3 of BT.601 which confirms this. I needed to see the letter of the law rather than go by what one guy on the Internet thinks, no offense. Turns out you are correct.

What you call "normal" is actually the analog voltage normalized to 1 volt. Upon quantization 1 volt is digitized to 255 or 235 depending on whether it's full-scale or studio swing.

As I said in a message which mysteriously disappeared, in an historical context BT.601 did away with the NTSC concept of "setup".
26. (16studio-16)/219 = 0.000normal // "black" / 0 or 7.5 IRE
(1studio-16)/219 = -0.068normal // "superblack"
These are not legal ATSC values. They're OK if you're putting your home movies of junior on YouTube but they are not broadcastable and do not comply with BT.xxx.

You would need a floating-point variable to represent -0.068.
27. >These are not legal ATSC values.
1 and 16 are certainly legal. Those are the values that would be encoded, not -0.068 or 0.000.

>You would need a floating-point variable to represent -0.068.
Yes, my "point" exactly. "R=1, G=1, B=0" implies floating point, and -0.068 is valid in any floating-point representation.

Normalizing values to the zero-to-one range is done when discussing the mathematics of image processing, as was done in your reference.
Actual encoding and transmission are almost always done in some integer format, such as the common eight-bit "studio swing".

Statistics