I think I EVENTUALLY understood that NTSC dot crawl stuff

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

lidnariq
Posts: 9796
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Tue Jun 14, 2011 3:23 pm

tepples wrote:I can draw a diagram of where $00/$16 artifacts come from if you want.
I'm working on this, I'm probably just being a little slow and overdetailed about it.

tepples
Posts: 22093
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Tue Jun 14, 2011 3:27 pm

Here's my attempt at a diagram, which I've added to the wiki article:

Image

lidnariq
Posts: 9796
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Tue Jun 14, 2011 4:45 pm

Here's a complete description of how I've demodulated the NES's video output by hand-

We tell the NES to this
Image

It generates the following signal
Image

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+ Image, I- Image, Q+ Image, Q- Image
and then add them back together:
I Image and Q Image.
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 chroma-into-luma crosstalk, and it looks like this:
Image,
and you end up with
Image 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+ Image Q+ Image I- Image Q- Image)
*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
Image
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
Image
Last edited by lidnariq on Fri Feb 24, 2012 10:56 pm, edited 2 times in total.

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

Post by psycopathicteen » Tue Jun 14, 2011 7:42 pm

you did ALL that by hand? :shock:

Anyway, how do you calculate a lowpass filter?

lidnariq
Posts: 9796
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Wed Jun 15, 2011 12:56 am

psycopathicteen wrote:Anyway, how do you calculate a lowpass filter?
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 high-order 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.

User avatar
Bregalad
Posts: 7966
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Post by Bregalad » Wed Jun 15, 2011 1:53 pm

I really appreciate the diagrams, thanks guys.
Apparently the TVs uses a band-cut 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 half-wits don't scare us.

tepples
Posts: 22093
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Wed Jun 15, 2011 3:37 pm

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 ?
Image
Representation of hue and saturation in a color picker
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 ?
Correct. Too rapid changes in phase will get confused with luma.

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

Post by psycopathicteen » Wed Jun 15, 2011 4:58 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(x-pi/2)*sin(x)
V = chroma(x)*sin(x) - chroma(x-pi/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 H-blank) there are 8-10 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.

lidnariq
Posts: 9796
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Wed Jun 15, 2011 5:24 pm

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 ?
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.)

*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.

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

Post by psycopathicteen » Wed Jun 15, 2011 7:32 pm

I always thought NTSC uses YUV, and YIQ is only used for filtering.

Drag
Posts: 1327
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Post by Drag » Wed Jun 15, 2011 10:55 pm

psycopathicteen wrote:I always thought NTSC uses YUV, and YIQ is only used for filtering.
I'm fairly certain PAL uses YUV and NTSC uses YIQ.
It doesn't really matter, it's the same exact colorspace anyway, except YIQ is rotated a little bit from YUV.

lidnariq
Posts: 9796
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Thu Jun 16, 2011 1:18 am

The only difference is that U and V are allocated the same bandwidth, but I and Q aren't.

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

Post by psycopathicteen » Thu Jun 16, 2011 9:22 am

What is the reference phase? I thought it was green-yellow but lidnariq said it was orange-red.

What color does NES send out for colorburst?

lidnariq
Posts: 9796
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Thu Jun 16, 2011 10:36 am

psycopathicteen wrote:What is the reference phase? I thought it was green-yellow but lidnariq said it was orange-red.

What color does NES send out for colorburst?
I was wrong. I assumed (oops) that clearly the colorburst was the in-phase 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.

tepples
Posts: 22093
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Thu Jun 16, 2011 11:14 am

lidnariq wrote:
psycopathicteen wrote:What color does NES send out for colorburst?
I was wrong. I assumed (oops) that clearly the colorburst was the in-phase component, and so I, but it's not; instead it's some other random angle neither I nor Q.
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.
The NES sends color $x8, which is mostly yellow.
In fact, as I understand it, $x8 is yellow by definition because it's pure -U.

Post Reply