Animation player

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.
kp64
Posts: 31
Joined: Fri Aug 01, 2014 3:13 pm

Animation player

Post by kp64 »

http://www.youtube.com/watch?v=rnKlTN8aFJU
kp64.my3gb.com/aimForTheTop.zip
Last edited by kp64 on Wed May 06, 2015 10:18 am, edited 1 time in total.
User avatar
Khaz
Posts: 314
Joined: Thu Dec 25, 2014 10:26 pm
Location: Canada

Re: Animation player

Post by Khaz »

Feel like sharing any details about what exactly I'm looking at and how it was done? It seems interesting.
kp64
Posts: 31
Joined: Fri Aug 01, 2014 3:13 pm

Re: Animation player

Post by kp64 »

Khaz wrote:Feel like sharing any details about what exactly I'm looking at and how it was done? It seems interesting.
The results are pretty cool but the program is simple and uninteresting.
I will try to explain it the better I can, but writing explanations in english
is not my speciality, so excuse me if I write something that does not make any sense.

The program transfers a 160x144 4bpp image to the VRAM using DMA each VBLANK period .... and thats it.
I wrote a BMP to SNES batch converter and also a script to auto generate the includes of all the pictures in the code.
With ffmpeg (I should start using avconv) and Imagemagick, I can extract frames from videos , resize , indexing , crop , etc...
I have scripts that do the mayority of the process.
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Animation player

Post by koitsu »

We do have people here who speak fluent Spanish, so if you want to provide an explanation in native Spanish, please do so! :-)
Stef
Posts: 259
Joined: Mon Jul 01, 2013 11:25 am

Re: Animation player

Post by Stef »

Is there any compression involved ? Still looks nice, the 4bpp conversion is really well done (we can hardly tell there is only 15 used colors in the video).
kp64
Posts: 31
Joined: Fri Aug 01, 2014 3:13 pm

Re: Animation player

Post by kp64 »

Stef wrote:Is there any compression involved ?
No , there is not compression.
Stef wrote:Still looks nice, the 4bpp conversion is really well done (we can hardly tell there is only 15 used colors in the video)
Imagemagick applies Riemersma's dithering to the images by default.
Each frame has his own 16 colors palette.
Also, the video itself looks pretty good at 16 colors.

I made this before, using just one shared palette for all the frames:
http://www.mediafire.com/download/vk1jp ... 282%29.sfc
As you can see , the results are uglier
Stef
Posts: 259
Joined: Mon Jul 01, 2013 11:25 am

Re: Animation player

Post by Stef »

Well the ImageMagick result is quite impressive, i used to use it a long time ago...
I don't remember if it support both color space reduction and color reduction *at same time*.
For instance from a 24 RGB image, can you convert easily to 16 colors in RGB555 ? and also control the dithering (checkboard or diffusion) ?
kp64
Posts: 31
Joined: Fri Aug 01, 2014 3:13 pm

Re: Animation player

Post by kp64 »

For instance from a 24 RGB image, can you convert easily to 16 colors in RGB555 ? and also control the dithering (checkboard or diffusion) ?
ImageMagick let you control the dithering and reduce colors at the same time.
http://www.imagemagick.org/Usage/quantize/

My program converts images that are already indexed (16 or 256 colors).
SDL converts the images to 8 RGB , then my program converts the 8 RGB palette to 5 BGR.
I wrote the conversion program like 2 or 3 years ago.
This is a part of the function that converts the palette( pls dont bully):

Code: Select all

#define SDL_FULLCOLOR 255 //<- MAX COLOR VALUE
#define SNES_FULLCOLOR 31 //<- MAX COLOR VALUE
float color_average = (float)SNES_FULLCOLOR/(float)SDL_FULLCOLOR ;

    for(i= 0; i < img->format->palette->ncolors ; i++)
    {

#ifdef DEBUG
        printf("Translating color number %d \n",i);
#endif

        SNES_color_buffer= 0;
        SNES_color_component= 0;

        //get red
        SNES_color_component= ((double)(img->format->palette->colors+i)->r*color_average);
        SNES_color_buffer= SNES_color_buffer | SNES_color_component;
        
        //get green
        SNES_color_component= ((double)(img->format->palette->colors+i)->g*color_average);
        SNES_color_buffer= SNES_color_buffer | (SNES_color_component << 5);

        //get blue
        SNES_color_component= ((double)(img->format->palette->colors+i)->b*color_average);
        SNES_color_buffer= SNES_color_buffer | (SNES_color_component << 10);

#ifdef DEBUG
        printf("SNES BGR color: %x \n",SNES_color_buffer);
#endif
	/*MORE STUFF HERE*/
}
The program uses SDL and SDL_Surfaces.
With SDL, you don't need to write code to support diferent image formats, because SDL itself does all the work for you.
Also, SDL_Surface structures are pretty simple and easy to work with.
Near
Founder of higan project
Posts: 1553
Joined: Mon Mar 27, 2006 5:23 pm

Re: Animation player

Post by Near »

If you're sharing your own version, that's cool. Always nice to see others' code.

But if you're demonstrating the technique, we've already done this before. We've done it at 2bpp, 4bpp, 8bpp at 15fps, 20fps, 30fps; in lores/progressive and in hires/interlace.

The problem is that it eats ROM like crazy. 160x144x4bpp@15fps will eat 168.5KB/s, giving you 24 seconds of video for a full ROM. And said ROM won't have a game to go with it. So the technique is nearly worthless for stock hardware.

You can double this by using the S-DD1 or SPC7110 for real-time decompression (and also expand your ROM to 8MB/hardware, or 256MB/theoretical). smkdan was able to run the 2-minute Lunar: SSS opening video in a 64MB S-DD1 ROM. But even that's not really practical.

Hence why MSU1 was made: to give you tons of ROM storage space for video.

> Is there any compression involved ?

Even with the SuperFX or SA-1, the SNES doesn't have the horsepower for real-time decompression of video. Not even simple RLE stuff.
User avatar
Ramsis
Posts: 341
Joined: Sun Jul 01, 2012 6:44 am
Location: Lion's den :3
Contact:

Re: Animation player

Post by Ramsis »

byuu wrote:Hence why MSU1 was made: to give you tons of ROM storage space for video.
Hey byuu, I thought you might appreciate this. :D
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
User avatar
mikejmoffitt
Posts: 1352
Joined: Sun May 27, 2012 8:43 pm

Re: Animation player

Post by mikejmoffitt »

This looks really good, would there be a chance of overlapping BG layers to get 31 colors, or is that too much data to DMA each frame?
Stef
Posts: 259
Joined: Mon Jul 01, 2013 11:25 am

Re: Animation player

Post by Stef »

byuu wrote: Even with the SuperFX or SA-1, the SNES doesn't have the horsepower for real-time decompression of video. Not even simple RLE stuff.
I guess it depends from resolution and codec, the Mega CD which use a 12 Mhz 68000 is able to decode cinepak video with almost fullscreen and decent frame rate (15 FPS). The Megadrive even had the Sonic 3D blast intro video which is also compressed.
Maybe with a very simple and adapted codec (and resolution) you can get something working on a stock SNES.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Animation player

Post by Drew Sebastino »

mikejmoffitt wrote:This looks really good, would there be a chance of overlapping BG layers to get 31 colors, or is that too much data to DMA each frame?
Why not just use 8bpp graphics at that point?

You know, one thing I thought would be really cool is if you had a 4bpp layer, and a transparent 2bpp layer on top of it so you are only using 6bpp. I'm really not sure how you'd write a code to translate a video to use that, and I'm sure it would take years on end to process...
Last edited by Drew Sebastino on Tue Apr 21, 2015 2:35 pm, edited 1 time in total.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: Animation player

Post by Sik »

If 4bpp and 8bpp are feasible, 6bpp should too, provided you have existing code to adapt. The biggest problem would be to adapt the code that comes up with an optimized palette then (since I assume you'd use this with blending or something?).

Wouldn't it be more feasible to just use all the palettes and assign the best one for each tile?
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Animation player

Post by Drew Sebastino »

Sik wrote:Wouldn't it be more feasible to just use all the palettes and assign the best one for each tile?
You mean like what is already being done, where there are 8 palettes? When I meant 6bpp, I mean you would do that exact same thing, except you would save 1 or 2 palettes for a transparent 2bpp layer over the 4bpp layer for a greater number of colors. (It would probably take a year to process one frame, but yeah...)
Post Reply