It is currently Mon Dec 10, 2018 4:02 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Tue Jun 14, 2011 3:23 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7804
Location: Seattle
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2011 3:27 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20851
Location: NE Indiana, USA (NTSC)
Here's my attempt at a diagram, which I've added to the wiki article:

Image


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2011 4:45 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7804
Location: Seattle
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.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2011 7:42 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2777
you did ALL that by hand? :shock:

Anyway, how do you calculate a lowpass filter?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2011 12:56 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7804
Location: Seattle
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2011 1:53 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7599
Location: Chexbres, VD, Switzerland
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.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2011 3:37 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20851
Location: NE Indiana, USA (NTSC)
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

Quote:
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2011 4:58 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2777
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2011 5:24 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7804
Location: Seattle
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.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2011 7:32 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2777
I always thought NTSC uses YUV, and YIQ is only used for filtering.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2011 10:55 pm 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1258
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2011 1:18 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7804
Location: Seattle
The only difference is that U and V are allocated the same bandwidth, but I and Q aren't.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2011 9:22 am 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2777
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?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2011 10:36 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7804
Location: Seattle
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2011 11:14 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20851
Location: NE Indiana, USA (NTSC)
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.

Quote:
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group