Emulating NTSC video
Moderator: Moderators
Emulating NTSC video
For the C++ on the Wiki, what is that 9-bit pixel color? Is there a way to convert the 6-bit PPU palette index into that?
Re: Emulating NTSC video
It's the 6-bit raw color number (i.e. the output of the palette) appended to the preemphasis bits.
Re: Emulating NTSC video
Thanks. I plugged in that code without any optimizations to see what it looks like. He's a screenshot (3x magnification):
That looks pretty horrible to me. And, I'm pretty sure that effect can be simulated by applying a filter that emphasizes R, then G, then B cyclically over every 3 pixels.
Anyway, the NTSC filters in other emulators don't look that bad. What is missing here?
That looks pretty horrible to me. And, I'm pretty sure that effect can be simulated by applying a filter that emphasizes R, then G, then B cyclically over every 3 pixels.
Anyway, the NTSC filters in other emulators don't look that bad. What is missing here?
- rainwarrior
- Posts: 8758
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Emulating NTSC video
I think that looks more or less correct, but you've rendered to low resolution and then upscaled.zeroone wrote:Anyway, the NTSC filters in other emulators don't look that bad. What is missing here?
If you want better looking quality, you should render the NTSC output directly to a higher resolution output. Vertical can just double or triple lines (darkening some if you like "scanline" simulation), but horizontal should be accounting for the NTSC signal across the whole line (possibly while stretching to a different aspect ratio).
e.g. Blargg's NTSC filter demo upscales 256 x 240 to 602 x 480.
- rainwarrior
- Posts: 8758
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Emulating NTSC video
For a quick comparison, Blargg's filter demo output compared to decimating it to half the resolution:
Note the better quality in the first image because it is able to subsample the analog NTSC signal during horizontal upscaling.Re: Emulating NTSC video
It looks like every other line is slightly darker. I'll try to figure out how that code works.
Re: Emulating NTSC video
You're seeing a combination of three differences:
- As rainwarrior mentioned, TVs and emulators run the NTSC decoder at full output resolution, as opposed to one sample per NES pixel.
- The PPU alternates the color subcarrier's phase by one-third of a cycle between one frame and the next. When played at 60 fps, frames with different phases blend together in a way that a single-field still screenshot doesn't capture.
- The last thing you noticed is "scanlines", an interpolation technique that makes every other line darker to simulate the beam shape on a CRT that's focused for 480i but displaying 240p. But this is independent of the NTSC encoding and decoding; PlayChoice-style emulation with scanlines but without an NTSC filter is still valid.
- rainwarrior
- Posts: 8758
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Emulating NTSC video
That part isn't important, simulating scanlines is merely a stylistic choice / personal preference. It's a vague approximation of the gaps between lines in 240p on a CRT.zeroone wrote:It looks like every other line is slightly darker. I'll try to figure out how that code works.
The vertical stretching of the image is simply done by doubling every line (no interpolation or oversampling, etc.). The scanline effect is literally just darkening every second line. I would have removed it for clarity if the filter demo had an option to do so, since I was only trying to demonstrate how the horizontal scaling is different.
- rainwarrior
- Posts: 8758
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Emulating NTSC video
For a better comparison, here's the Blarrg filter example with the scanlines removed. (Compare this against the second "decimated" example above.)
Comparing the two you can see the decimated version has the same problem as your example, though maybe slightly milder (the problem is a little bit obscured by the aspect ratio change). The point is that quality improves with better sampling. You should see that the decimated version has more spurious colour fringes, etc. than the normal version, similar to your example.Re: Emulating NTSC video
Does following along with my manual demodulation explain things at all?
Re: Emulating NTSC video
One of the functions on the wiki takes a Width parameter. Here's the result with a Width of 512:
@rainwarrior It's a lot closer to the last Blarrg image that you posted, but Blarrg's still doesn't not contain that much color fringing.
@rainwarrior It's a lot closer to the last Blarrg image that you posted, but Blarrg's still doesn't not contain that much color fringing.
That looks like a really interesting post. I'll study it. I'm clueless about how NTSC does it's thing. I just copied-and-pasted wiki codelidnariq wrote:Does following along with my manual demodulation explain things at all?
Re: Emulating NTSC video
Below is another with Width set to 768. It also smoothly stretches it to the TV pixel aspect ratio.
I don't recall any CRT looking quite like these images.
I don't recall any CRT looking quite like these images.
Re: Emulating NTSC video
The red-green-blue artifacts are way too pronounced, but the image looks fairly accurate otherwise, IMO.
Re: Emulating NTSC video
I agree. But, this was generated with the code straight off the wiki. Any tuning suggestions?tokumaru wrote:The red-green-blue artifacts are way too pronounced, but the image looks fairly accurate otherwise, IMO.
Re: Emulating NTSC video
The C++ on the wiki "should" generate a 2048x240 image.
Oh, I see, the "width" parameter imposes a simple decimation of the output image. At a width of 768, it ought to be ... moderately representative to the actual bandwidth of the system, I'd think...?
Oh, I see, the "width" parameter imposes a simple decimation of the output image. At a width of 768, it ought to be ... moderately representative to the actual bandwidth of the system, I'd think...?