Blargg's NTSC Libraries

Home | News | Info | Code | Misc | Contact

These libraries perform NTSC video signal processing on an image, giving a result similar to that of the game console connected to a TV and unlike that of a simple palette-based image. Standard controls like color tint and contrast can be adjusted, as well as many low-level parameters like gamma, sharpness, and color bleed. Presets are included for composite, S-video, RGB, and monochrome video quality. Image sharpness can be cranked up to match a usual pixellated image, while still having use of all the other image controls (lower-right image in examples below). See the examples pages for many images. Libraries are available for the following systems listed below (e-mail me if you want a new system added):

SystemLibrary
Nintendo NESnes_ntsc
Nintendo Super NESsnes_ntsc
Sega Master System/Game Gearsms_ntsc
TI 99/4Ae-mail me
Commodore 64e-mail me
Sega Genesise-mail me

The libraries are written in portable C and licensed under the GNU Lesser General Public License (LGPL). They should work well even with older compilers and have been compiled on the following platforms: Windows, Linux, and Mac OS. An archive of previous releases is available in case the latest version doesn't work. Post to the discussion forum for help or to give feedback.

All filters use an optimized algorithm that does all math-intensive calculation during initialization, leaving just a minimal integer-only 14-point RGB convolution and clamping to be performed for each input pixel during filtering. Running the filter at 60 frames per second uses 8% CPU on a 2.0 GHz Athlon PC and 40% CPU on a 400 MHz PowerMac G3, making it suitable for use on almost any system. The pixel output format can be set to 15/16/24/32-bit RGB. For cases where the standard blitter function is insufficient, an interface is included for writing a custom blitter, allowing an optimized implementation for a particular platform, customized pixel format, scanline effects like interpolated line doubling, etc. Each library includes an SDL-based demo that loads a BMP image and displays it with interactive control of filter parameters.


nes_ntsc

Screenshot

NES NTSC video filter. Pixel artifacts (left images) and color mixing (upper right) play an important role in NES graphics. Contrast with RGB (lower right). Accepts pixels in native 6-bit NES palette format, or a 9-bit format that includes the three color emphasis bits from PPU register $2001. Can also output an RGB palette for use in a regular blitter, and accept a custom input RGB palette that bypasses some of the NTSC color circuitry. If your emulator can only output RGB pixels and not native NES palette colors, use snes_ntsc.

nes_ntsc-0.2.2.zip (C or C++)

  • Added ability to use a custom RGB palette in place of the NES color circuitry (with the option of being before color emphasis)
  • Moved configuration options to nes_ntsc_config.h, making it easier to manage
  • Greatly clarified and improved demo to read any uncompressed BMP image and write filtered image when done
  • Improved gamma to be properly applied to each RGB channel, and changed default to compensate for difference between PC monitor and TV gamma
  • Improved contrast to be properly applied to each RGB channel rather than just luma
  • Improved floating point calculations in library to be more stable and not need double precision, which was causing problems with the sharpness control on Windows when the DirectX libraries carelessly changed the FPU to single precision mode
  • Eliminated slight artifacts still visible when using the RGB preset with field merging off

This library is used in: Nestopia, FakeNES, Mednafen, Sega Li (Windows), QuickNES (Mac OS)


snes_ntsc

Screenshot

Super NES NTSC video filter. The main benefit is color mixing (upper right), as composite video artifacts (left images) are less noticeable than on the NES. Contrast with RGB (lower right). Accepts pixels in 16-bit RGB or 15-bit BGR (native SNES format).

snes_ntsc-0.2.2.zip (C or C++)

  • Moved configuration options to snes_ntsc_config.h, making it easier to manage
  • Greatly clarified and improved demo to read any uncompressed BMP image and write filtered image when done
  • Improved gamma to be properly applied to each RGB channel, and changed default to compensate for difference between PC monitor and TV gamma
  • Improved contrast to be properly applied to each RGB channel rather than just luma
  • Removed hue_warping for now, due to its obscurity
  • Improved floating point calculations in library to be more stable and not need double precision, which was causing problems with the sharpness control on Windows when the DirectX libraries changed the FPU to single precision mode

This library is used in: ZSNES, bsnes


sms_ntsc

Screenshot

Sega Master System NTSC video filter. Reproduces the significant artifacts on the vertical edges of some colors (upper left), and the general color mixing (upper right). Contrast with RGB (lower right). Accepts pixels in 16-bit RGB or 12-bit BGR (native Game Gear palette format). Can also output an RGB palette for use in a regular blitter.

sms_ntsc-0.2.3.zip (C or C++)

  • Moved configuration options to sms_ntsc_config.h, making it easier to manage
  • Greatly clarified and improved demo to read any uncompressed BMP image and write filtered image when done
  • Improved gamma to be properly applied to each RGB channel, and changed default to compensate for difference between PC monitor and TV gamma
  • Improved contrast to be properly applied to each RGB channel rather than just luma
  • Improved floating point calculations in library to be more stable and not need double precision, which was causing problems with the sharpness control on Windows when the DirectX libraries changed the FPU to single precision mode

This library is used in: Classic99 (Windows), SMS Plus