Zophar's Message Domain

Go Back   Zophar's Message Domain > Emulation Talk > General Emulation

Reply
 
Thread Tools Display Modes
Old 02-20-2006, 09:45 PM   #1
blargg
Regular Member
 
Join Date: Jul 2004
Posts: 45
Default SNES NTSC Video Filter

Today I had an idea of how the SNES NTSC composite video output might work. After a couple of hours I've got output very close to what my video capture gets from a SNES. Apparently it's very similar to the NES. Since I recently optimized my NES NTSC filter code to run many times faster than before, I'm hoping to come up with an optimized version of this SNES NTSC filter code offering similar speed. Here are the screenshots, one from video capture and one from the emulator, but I won't say which is which (the attachment has the full captures side-by-side). <img src=smilies/magbiggrin.gif>


<P ID="signature"></P>

C:Serverxampphtdocszopharoldwwwthrea...nes_or_emu.png
blargg is offline   Reply With Quote
Old 02-20-2006, 11:55 PM   #2
D--
Senior Member
 
D--'s Avatar
 
Join Date: Oct 2001
Location: Chaoyang, Beijing, China
Posts: 826
Default Re: SNES NTSC Video Filter

> but I won't say which is which (the attachment has
> the full captures side-by-side).

Is the left the composite? I'm guessing based on its harder vertical grain. My old wintv card tended to have that.
<P ID="signature"><hr>
Cinnamon Pirate.com</P>
__________________
portfolio :: deviantArt :: 微博 :: Twitter
D-- is offline   Reply With Quote
Old 02-21-2006, 12:34 AM   #3
maq112k2
Senior Member
 
Join Date: Jan 2002
Posts: 1,971
Default Re: SNES NTSC Video Filter

> Is the left the composite? I'm guessing based on its harder
> vertical grain. My old wintv card tended to have that.

After looking at the picture zoomed in (yay paintbrush), I believe the left is the composite, too.

Still, awesome job. Looks amazing.

<P ID="signature"></P>
maq112k2 is offline   Reply With Quote
Old 02-21-2006, 06:07 AM   #4
blargg
Regular Member
 
Join Date: Jul 2004
Posts: 45
Default Re: SNES NTSC Video Filter

Well, I've got the first optimized version working. On my 400 MHz machine it runs around 180 frames per second (just running the filter on a screenshot), and I think the bottleneck is my video memory rather than the calculation. Unfortunately the tables are huge (16MB!), and take about 9 seconds to initialize at present. I haven't thought of any way to reduce the size yet (and I think it'll have to be double that size to handle high-res mode). The working set will be small in actual use, so it won't stress the cache, but it's still inelegant. I'm working now on making table initialization faster; I should be able to get it to a second at most. Once I've got that done, I'll be handing the code off to byuu to try in bsnes (sadly I don't even have any SNES emulators on my machine to try it with).

I'm surprised it turned out to be so simple, something that could be worked out in an afternoon. I think I'll be porting this for many different systems in the future.

Oh, and here's how it handles areas where they use that grid pattern for the water in Super Mario World (sorry, JPEG this time, as the PNGs are way too large for this):

blargg is offline   Reply With Quote
Old 02-21-2006, 08:55 PM   #5
byuu
Junior Member
 
Join Date: Jan 2006
Posts: 19
Default Re: SNES NTSC Video Filter

This looks awesome. I'd be honored to add it to bsnes as soon as its ready, though I can't guarantee I'll be successful. If you could, please make it something simple like passing the routine a source+dest uint16 pointer, and input width + height, then returning the new width + height. bsnes only outputs in 16-bit mode and uses hardware to convert to 32bpp when needed.
Also, I can't use any code that's GPL'd, it will have to be LGPL, BSD, your own license, or an exemption from your normal license, as my license does not allow derivative works ("forks") and is thus incompatible with the GPL.

Also, just to throw these your way, there are technically eight possible modes for the SNES. I cut the bottom line off as its usually garbled data / black.
256x223 (w/overscan = 256x238)
256x446 interlaced (w/overscan = 256x476)
512x223 hires or pseudo-hires (w/overscan = 512x238)
512x446 hires or pseudo-hires + interlaced (w/overscan = 512x476)
Overscan on NTSC TVs is still rendered the same, the image is just shifted upwards on the screen, and you still can only view the same amount of screen. I know absolutely nothing about PAL TVs, but assume they have a black bar at the bottom when overscan is off.

Pseudo-hires and hires are absolutely identical for the purposes of your filter, as is the current SNES video mode. The differences are processed internally. But you will probably need some special handling for 512-width pseudo-hires mode, and I hope you can output the filtered result at the same resolution for all modes. Some games switch between the two modes constantly, e.g. when a hires textbox is opened in a lores game :/
Jurassic Park is a good example game for pseudo-hires. If you start a new game and then don't touch the controls, in about a minute a message will pop up with some info:
<img src=http://byuu.cinnamonpirate.com/images/bs_195.png>
I may have these backwards, but basically every even vertical field is from BG1+BG2+OAM, which is the world map and character sprites. Every odd vertical field is from BG3, which is the "did you know" box. On a real system, I guess the composite video gets blurred together, and the result seems to be that both layers are blended 50% together. It may be the SNES itself, too. d4s used pseudo-hires on an RGB SCART monitor and noticed the effect still worked. If shown on a monitor at full 512-width without blending the pixels together, the result is absolutely hideous, as you might imagine.
I can get you TV capture card images and emulator images with and without the blending applied if you like.
This affect also applies to hires modes which are usually used for text e.g. in Secret of Mana 2, Romancing SaGa 3, Rudra's Secret Treasure, etc.
The problem is that using the same 50% blur on these screens results in significantly lower quality text than a real SNES displays. So obviously reality is somewhere between each pixel being rendered clearly and being averaged as in that JP screenshot above.

Feel free to PM me on the ZSNES boards with your contact info if you want to discuss things in more detail. I'll be happy to help you in any way I can.

<P ID="signature"></P>
byuu is offline   Reply With Quote
Old 02-22-2006, 12:21 AM   #6
Kitsune Sniper
Senior Member
 
Join Date: Feb 2000
Posts: 1,661
Default Re: SNES NTSC Video Filter

> Today I had an idea of how the SNES NTSC composite video
> output might work. After a couple of hours I've got output
> very close to what my video capture gets from a SNES.

Thank you for reminding me why I stopped playing games on my television. Yech.

Good job on it... here's hoping some emulator authors other than byuu add it to their programs.
<P ID="signature"></P>
Kitsune Sniper is offline   Reply With Quote
Old 02-22-2006, 01:50 AM   #7
Reaper man
Member
 
Reaper man's Avatar
 
Join Date: Apr 2002
Location: Austin, TX
Posts: 5,386
Default Re: SNES NTSC Video Filter

> Feel free to PM me on the ZSNES boards with your contact
> info if you want to discuss things in more detail. I'll be
> happy to help you in any way I can.


Actually, he should make a post about it in the ZSNES discussion forum if he hasn't already.
<P ID="signature"></P>
__________________
Reaper man is offline   Reply With Quote
Old 02-22-2006, 07:42 AM   #8
icenine0
Senior Member
 
Join Date: Mar 2001
Posts: 3,958
Default Re: SNES NTSC Video Filter

This looks totally rockin and very nostalgic. If it was in an emu, I could see using it a lot.
<P ID="signature"></P>
icenine0 is offline   Reply With Quote
Old 02-22-2006, 08:55 AM   #9
blargg
Regular Member
 
Join Date: Jul 2004
Posts: 45
Default Re: SNES NTSC Video Filter

> Thank you for reminding me why I stopped playing games on my television. Yech.

The first screenshots I posted look like crap because they are interlaced images, which is wrong for the SNES. It's what my video capture takes, and I didn't want to doctor the capture at all. It looks substantially better than that in use, because the SNES isn't (normally) interlaced. Some colors on the SNES flicker, which isn't that noticeable because they blend together on screen. A screenshot of just one frame (instead of a pair) looks bad because it freezes the pattern that usually blends. Below are the even and odd fields of the same scene, and what they look like when viewed normally (merged together). All three are generated by my code. Note how the color speckles, ragged edge on the grass, and the diagonal color stripes on the left go away when the fields are merged.



If you're using an emulator and your monitor refresh is set to 60 Hz, you'll see what's on the right (assuming the emulator is running at full-speed). If your refresh is different than 60 Hz, it'll flicker wrong and look bad. I've added an optional feature to internally mix even and odd fields together, so the image looks like the right image above (this feature doesn't run any slower since it modifies the tables at startup). This is close to what you'd get from an S-Video cable. When scrolling with field merging enabled, you won't get as much flicker as you would on a SNES; to get this, you have to run at 60 Hz without field merging.

I've got the startup time down to less than a second, so I'll be handing off a version to byuu in a day or so. It now offers full image control, including hue, saturation, contrast, brightness, sharpness, and field merging. Once this is working well, I'll tackle high-resolution (I think it'll be simple, except that it'll double or triple memory usage, ugh).

<P ID="signature"></P>
blargg is offline   Reply With Quote
Old 02-22-2006, 09:12 AM   #10
Dark Knight Kain
Senior Member
 
Join Date: Jan 2002
Posts: 1,278
Default Re: SNES NTSC Video Filter

It looks great, I've fallen in love with the NES NTSC filter, looks like the same will happen for this one <img src=smilies/thumb.gif>
<P ID="signature"><center>
http://dragonsbrethren.elazulspad.net/</a>
</center></P>
Dark Knight Kain is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:37 PM.

Contact Us - Zophar's Domain - Archive - Top

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.