Author Topic: Four Level Grayscale Video  (Read 32531 times)

0 Members and 3 Guests are viewing this topic.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Four Level Grayscale Video
« Reply #30 on: January 30, 2011, 11:02:12 pm »
What do you mean by dithering in this case? If you are talking about the scan lines, those are only present in wabbitEmu. I tried it on my real calculator and they are hardly noticeable.

You are also definitely correct about the compression artifacts. I traced the steps through and it looks like SUPER caused them when it converted the .flv to .jpg's. But as of now, I don't know any other way to do that step.

For decompression on the calculator, there is definitely enough time. 16,000,000 hz * 50 % (grayscale) /15 = 533,000 clock cycles per frame. That's 347 clocks per byte, clearly enough time to do something amazing. The only thing I'm doing right now is converting strings of 00's and FF's to 00 00 (length) and FF FF (length).
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Four Level Grayscale Video
« Reply #31 on: January 30, 2011, 11:13:14 pm »
Dithering is a way to artificially increase the number of shades availible. A good example is here on wikipedia http://en.wikipedia.org/wiki/File:Dithering_example_red_blue.png you can see how red and blue are combined to make purple. In your converter you could add dithering to better shade some areas

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Four Level Grayscale Video
« Reply #32 on: January 31, 2011, 01:20:24 am »
Perhaps the jpegs themselves are the source of the problem?  Maybe you would be better off with some sort of lossless image file instead of a lossy one.

As for dithering, note that it would also raise the filesize significantly ;)

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Four Level Grayscale Video
« Reply #33 on: January 31, 2011, 01:57:23 am »
Perhaps the jpegs themselves are the source of the problem?  Maybe you would be better off with some sort of lossless image file instead of a lossy one.

As for dithering, note that it would also raise the filesize significantly ;)
In dithering do you mean by breaking up the long chains of FF's and 00's normally found in a frame. I didn't really realize at first that it would prevent the compression from working as efficiently.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Four Level Grayscale Video
« Reply #34 on: January 31, 2011, 02:03:43 am »
Right, by dithering you are adding more complexity, and so RLE will not work as well.  Btw how are you doing your RLE?

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Four Level Grayscale Video
« Reply #35 on: January 31, 2011, 02:14:20 am »
I'm not sure how thepenguin77 is doing it, but for a string of 16 00's I would write $0010. So the 00 would be the identfier and 10 would represent 16 of them. and this is only for 00 and FF.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Four Level Grayscale Video
« Reply #36 on: January 31, 2011, 02:29:19 am »
the thing is though, that this video is not going to be byte based, but pixel based.  you wouldn't have 16 00's, you would have runs of either binary, or runs of 0-3

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Four Level Grayscale Video
« Reply #37 on: January 31, 2011, 08:46:32 am »
OH MY GOD, THIS IS SO AWESOME!

I just checked this topic, and it looks so great! Do you make every video or is it a converter from PC files?

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Four Level Grayscale Video
« Reply #38 on: January 31, 2011, 03:08:53 pm »
Here is my current method of compression. 00's and FF's are the target since black or white sections are all one color.
Code: [Select]
Data: 00 00 00 00 00 00 00 00 00 06 58 00 36 87 ff ff ff ff ff ff ff ff 59 ff ff    86 32
Comp: 00 00 08                   06 58 00 36 87 ff ff 07                59 ff ff 01 86 32
Expl: 00flag#-1                        one ok   FFflag#-1                  only downside

As you can see, any long string gets shortened to three bytes with this. The only downside is that since the flag is a repeated FF or 00, 00 00 and ff ff get expanded one. But those are somewhat rare. The reason that the number of bytes is -1 is just to make life easier in z80.

As for dithering I just figured out that that means artificial grayscale by alternating colors between frames. But I could more easily add 8 level grayscale, it's just the file size that would suffer.

Edit:
    Does anyone have a good idea for compression techniques? I would love to hear them.
« Last Edit: January 31, 2011, 03:09:24 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Four Level Grayscale Video
« Reply #39 on: January 31, 2011, 03:55:21 pm »
Ahhh thats an interesting take on RLE, I was assuming you were doing it pixel by pixel, not byte by byte.  I wonder what the size difference is between the two o.O There is always Huffman coding, although I have a feeling it would be not very well suited for video.  Hmmm there is some sort of expansion on RLE but I don't remember what it's called, something with a 7.  By its nature, it is a RLE but it is also more...

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Four Level Grayscale Video
« Reply #40 on: January 31, 2011, 04:16:28 pm »
I'm thinking of doing a variation of DEFLATE. Here is the specification if anyone is interested. (if you're going to look at it, the important part is the top of page 11) It is essentially LZ77 paired with huffman tables for the distances and lengths. It's what .png uses so I figure it's good for pictures/video. What I think I'll do is just use the uncompressed and Fixed huffman table parts of it because I don't think my file sizes are big enough to be able to use the dynamic huffman table properly.

Since LZ77 using a sliding window, that creates a sort of problem when doing it on the calculator due to memory requirements. I am thinking of using a sliding window of 768*2*2=3,072 because that is two frames. To accomplish this quickly and efficiently, I'm going to move data around by switching pages rapidly. In what might be the most hacked memory configuration yet, I will have the flash page in the $4000 slot. I will have $3A00 bytes of page $81 swapped into the $8000 range through port ($28). Then, I will alternate having pages 0 and 3 swapped into the $8000 range and the $C000 range so that the two frames are always in the same place: $BA00 and $FA00. Hopefully, this will allow me to get the speed and address space required to make this work. (I'm backing up page 0, so don't worry.)
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Four Level Grayscale Video
« Reply #41 on: January 31, 2011, 04:26:18 pm »
wow that sounds complicated O.O I hope you can get it all working :D

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Four Level Grayscale Video
« Reply #42 on: January 31, 2011, 04:57:42 pm »
Sounds epic!  Good luck! ;D

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Four Level Grayscale Video
« Reply #43 on: January 31, 2011, 06:26:14 pm »
That is just... intense. I didn't know you could swap pages that quickly, though.

Offline qazwsx988

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +7/-0
    • View Profile
Re: Four Level Grayscale Video
« Reply #44 on: January 31, 2011, 07:06:30 pm »
It doesn't seem to work on a real calc, what do you have to do with the files?