I'm working on this, I'm probably just being a little slow and overdetailed about it.tepples wrote:I can draw a diagram of where $00/$16 artifacts come from if you want.
I think I EVENTUALLY understood that NTSC dot crawl stuff
Moderator: Moderators
Here's a complete description of how I've demodulated the NES's video output by hand
We tell the NES to this
It generates the following signal
Off the left hand of the screen, we get a cue of what phase 8 is (red here is phase 6)
We demodulate I and Q from that. GIMP doesn't support negative colors, so I have to demodulate all four quadrants separately:
I+ , I , Q+ , Q
and then add them back together:
I and Q .
Note that I has a bandwidth of 1.5MHz (24 pixels) and Q has a bandwidth of <700kHz (>48 pixels)
We could just lowpass our input at 4.3MHz, which basically won't get rid of much of the chromaintoluma crosstalk, and it looks like this:
,
and you end up with
at the end.
One of the earlier techniques invented to reduce this crosstalk is to subtract I and Q back from the input signal. We remodulate our calculated I and Q
(I+ Q+ I Q )
*EDIT I forgot 4 of the 8 products, they're not shown here, but the two results below now include them
and subtract it from the input. Because the NES produced too sharp an edge on the sides, this color trap isn't particularly effective on verticals and the result only looks like
We then lowpass at 4.3MHz (we still know per the spec that there's nothing valid above) and do the colorspace transform and get
We tell the NES to this
It generates the following signal
Off the left hand of the screen, we get a cue of what phase 8 is (red here is phase 6)
We demodulate I and Q from that. GIMP doesn't support negative colors, so I have to demodulate all four quadrants separately:
I+ , I , Q+ , Q
and then add them back together:
I and Q .
Note that I has a bandwidth of 1.5MHz (24 pixels) and Q has a bandwidth of <700kHz (>48 pixels)
We could just lowpass our input at 4.3MHz, which basically won't get rid of much of the chromaintoluma crosstalk, and it looks like this:
,
and you end up with
at the end.
One of the earlier techniques invented to reduce this crosstalk is to subtract I and Q back from the input signal. We remodulate our calculated I and Q
(I+ Q+ I Q )
*EDIT I forgot 4 of the 8 products, they're not shown here, but the two results below now include them
and subtract it from the input. Because the NES produced too sharp an edge on the sides, this color trap isn't particularly effective on verticals and the result only looks like
We then lowpass at 4.3MHz (we still know per the spec that there's nothing valid above) and do the colorspace transform and get
Last edited by lidnariq on Fri Feb 24, 2012 10:56 pm, edited 2 times in total.

 Posts: 2953
 Joined: Wed May 19, 2010 6:12 pm
I knew the spatial frequency of the images I have there is 1 pixel = 12xNTSC ≈ 43MHz, so when I wanted a 1.5MHz lowpass I I used a 43MHz/1.5MHz = 29 pixel wide gaussian. (Actually, I eyeballed it and used a 24 pixel wide gaussian.) The gaussian isn't quite right  a sinc or highorder chebychev is probably more authentic, but the gaussian has the advantage that it's symmetrically noncausal (unlike the chebychev or boxcar "motion blur") so I don't need to worry about group delay and it's natively supported in GIMP.psycopathicteen wrote:Anyway, how do you calculate a lowpass filter?
I really appreciate the diagrams, thanks guys.
Apparently the TVs uses a bandcut filter (as opposed to lowpass filter) for luma, which mans resolution higher than 3.5 MHz can happen as long as the hue (I and Q) are the same. However luma's harmonics close to 3.5 MHz will be cut off from the filter and be interpreted as color information, which can be indesirable.
One thing I still don't understand is how colors are decded. One can filter a 3.5 MHz signal easily and detect whenever or not there is color information, but how can you tell WHICH color it is ? I'm pretty sure amplitude modultion is done for staturation (unused on NES) and phase modultion for the color, but it should be really hard to know the phase of the signal to be able to tell if there is a blue, red or whatever color ?
If the phase change multiple times during less than a full period (what would happen if you try to get a higher resolution than 3.5 MHz with color, what the NES is doing in fact), then the TV can't detect this properly right ?
Even if it could, it would be filtered of by the bandpass filter, so changes in phase could not be detected. Filters does affect the phase of signals.
Apparently the TVs uses a bandcut filter (as opposed to lowpass filter) for luma, which mans resolution higher than 3.5 MHz can happen as long as the hue (I and Q) are the same. However luma's harmonics close to 3.5 MHz will be cut off from the filter and be interpreted as color information, which can be indesirable.
One thing I still don't understand is how colors are decded. One can filter a 3.5 MHz signal easily and detect whenever or not there is color information, but how can you tell WHICH color it is ? I'm pretty sure amplitude modultion is done for staturation (unused on NES) and phase modultion for the color, but it should be really hard to know the phase of the signal to be able to tell if there is a blue, red or whatever color ?
If the phase change multiple times during less than a full period (what would happen if you try to get a higher resolution than 3.5 MHz with color, what the NES is doing in fact), then the TV can't detect this properly right ?
Even if it could, it would be filtered of by the bandpass filter, so changes in phase could not be detected. Filters does affect the phase of signals.
Useless, lumbering halfwits don't scare us.
Bregalad wrote:One can filter a 3.5 MHz signal easily and detect whenever or not there is color information, but how can you tell WHICH color it is ? I'm pretty sure amplitude modultion is done for staturation (unused on NES) and phase modultion for the color, but it should be really hard to know the phase of the signal to be able to tell if there is a blue, red or whatever color ?
Representation of hue and saturation in a color picker
Correct. Too rapid changes in phase will get confused with luma.If the phase change multiple times during less than a full period (what would happen if you try to get a higher resolution than 3.5 MHz with color, what the NES is doing in fact), then the TV can't detect this properly right ?

 Posts: 2953
 Joined: Wed May 19, 2010 6:12 pm
encoding chroma:
luma = .299*red + .587*green + .114*blue
U = .492*(blue  luma)
V = .877*(red  luma)
chroma(x) = U*cos(x) + V*sin(x)
decoding chroma:
U = chroma(x)*cos(x) + chroma(xpi/2)*sin(x)
V = chroma(x)*sin(x)  chroma(xpi/2)*cos(x)
blue = (U + luma)/.492
red = (V + luma)/.877
green = (luma  .114*blue  .299*red)/.587
At the beginning of every scanline (during Hblank) there are 810 cycles of "colorburst" that analog TVs use to keep in sync with the color generating. U is 180 degrees from colorburst phase. V is 90 degrees from colorburst phase.
luma = .299*red + .587*green + .114*blue
U = .492*(blue  luma)
V = .877*(red  luma)
chroma(x) = U*cos(x) + V*sin(x)
decoding chroma:
U = chroma(x)*cos(x) + chroma(xpi/2)*sin(x)
V = chroma(x)*sin(x)  chroma(xpi/2)*cos(x)
blue = (U + luma)/.492
red = (V + luma)/.877
green = (luma  .114*blue  .299*red)/.587
At the beginning of every scanline (during Hblank) there are 810 cycles of "colorburst" that analog TVs use to keep in sync with the color generating. U is 180 degrees from colorburst phase. V is 90 degrees from colorburst phase.
We are told a reference phase at the beginning of every scanline. Doing this QAM demodulation gets us the I and Q parts of YIQ. (PAL uses YUV where U is blueness and V is redness.)Bregalad wrote:One thing I still don't understand is how colors are decded. One can filter a 3.5 MHz signal easily and detect whenever or not there is color information, but how can you tell WHICH color it is ? I'm pretty sure amplitude modultion is done for staturation (unused on NES) and phase modultion for the color, but it should be really hard to know the phase of the signal to be able to tell if there is a blue, red or whatever color ?
*edit: removed lie  NTSC's reference phase is neither pure I nor Q. (wtf?)
Last edited by lidnariq on Thu Jun 16, 2011 10:33 am, edited 1 time in total.

 Posts: 2953
 Joined: Wed May 19, 2010 6:12 pm

 Posts: 2953
 Joined: Wed May 19, 2010 6:12 pm
I was wrong. I assumed (oops) that clearly the colorburst was the inphase component, and so I, but it's not; instead it's some other random angle neither I nor Q. The NES sends color $x8, which is mostly yellow.psycopathicteen wrote:What is the reference phase? I thought it was greenyellow but lidnariq said it was orangered.
What color does NES send out for colorburst?
But because I and Q are merely U and V rotated by a phase offset, they appear to be two different ways to decode the same thing.lidnariq wrote:I was wrong. I assumed (oops) that clearly the colorburst was the inphase component, and so I, but it's not; instead it's some other random angle neither I nor Q.psycopathicteen wrote:What color does NES send out for colorburst?
In fact, as I understand it, $x8 is yellow by definition because it's pure U.The NES sends color $x8, which is mostly yellow.