Converting video file to planar format.

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
psycopathicteen
Posts: 3001
Joined: Wed May 19, 2010 6:12 pm

Converting video file to planar format.

Post by psycopathicteen »

I looked for a program that could convert video files to planar format that can be used in SNES games, but I couldn't find any, and I'm only starting to learn C++ and I don't want to reinvent the wheel.

This has to do with the "bad apple" demo I've been wanting to make. I'm pretty much finished with the compression algorithm in asm. I just need a compressor for the following format:

The data stream alternates between compressed tile maps and compressed 2bpp tile patterns, with the compressed tile map always first.

Tile maps are compressed with 1 byte for each group of tiles.

00xxxxxx = x many white tiles in a row
01xxxxxx = x many black tiles in a row
10xxxxxx = x many 2bpp patterned tiles in a row
11xxxxxx = same as above

After the compressed tile map data is the compressed tile patterns.

The first 16-bit word, has each bit corresponding with a row of 8 pixels for the first 2 8x8 tiles, followed by the rows of 8 pixels themselves.

0 = repeat last row of pixels
1 = fetch new row of pixels

...and the pattern repeats.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Converting video file to planar format.

Post by tepples »

psycopathicteen wrote:I looked for a program that could convert video files to planar format that can be used in SNES games, but I couldn't find any, and I'm only starting to learn C++ and I don't want to reinvent the wheel.
TIP: Start by using FFmpeg to decode the video, convert it to grayscale, scale it to 256x224, and output a stream of raw grayscale pixels. It'll give you a stream of pixels, and you can quantize them to 4 grays and do the compression in your own program.
Tile maps are compressed with 1 byte for each group of tiles.

00xxxxxx = x many white tiles in a row
01xxxxxx = x many black tiles in a row
10xxxxxx = x many 2bpp patterned tiles in a row
11xxxxxx = same as above
I'd recommend using 10xxxxxx for 1bpp patterned tiles, with a tunable parameter "lossiness" in the compressor that adjusts under what conditions 1bpp will be used.
0 = repeat last row of pixels
1 = fetch new row of pixels
That is almost exactly the same RLE scheme that I used for CHR data in the Action 53 multicart and my entry to the second compo, except I compressed each bitplane separately, and the sense of the bit was inverted (1=repeat, 0=fetch).
psycopathicteen
Posts: 3001
Joined: Wed May 19, 2010 6:12 pm

Re: Converting video file to planar format.

Post by psycopathicteen »

Where can I get an avi file (or whatever format) for bad apple?
Joe
Posts: 469
Joined: Mon Apr 01, 2013 11:17 pm

Re: Converting video file to planar format.

Post by Joe »

I downloaded a copy of the video from Niconico on October 14th, 2010. I can send it to you in a PM if you'd like.
lidnariq
Posts: 10677
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Converting video file to planar format.

Post by lidnariq »

You might also find “youtube-dl” useful.
Stef
Posts: 259
Joined: Mon Jul 01, 2013 11:25 am

Re: Converting video file to planar format.

Post by Stef »

I have the original bad apple video exported frame per frame in BMP image as i needed it to do the megadrive version of the demo.
I made some specific versions which suit more to your needs :
256x192 resolution in 8bpp: keep pixel ratio and you have some extra blank lines if needed.
256x224 resolution in 8bpp: full screen

You have a sharpen version (default one) and a smooth filtered version (_smooth) so you can make some tests and keep the one you prefer. Just for information on megadrive i used sharpen version to get better compression (i also used only 4 levels of gray).
Here is the link to download them :
https://www.dropbox.com/sh/kyvjzvnj1q4f ... pple/video
psycopathicteen
Posts: 3001
Joined: Wed May 19, 2010 6:12 pm

Re: Converting video file to planar format.

Post by psycopathicteen »

Thanks a lot!
Post Reply