Author Topic: YABAV(A)  (Read 7070 times)

0 Members and 1 Guest are viewing this topic.

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
YABAV(A)
« on: December 22, 2013, 01:31:13 pm »
Yet Another "Bad Apple" Video (attempt).

This was a quick attempt to see what I can do with the stuff I've already made. This attempt recycled both sides of the Athena Installer/Packager project to process the video via modified pucrunch. Much of the time spent was trying to get the youtube video into a format I could work with (ffmpeg and irfanview were used).

Since Athena was re-used, the executable is in the form of a main executable followed by loads of files. Here's some numbers:

Total number of frames: 6585
Memory used if not compressed: 4.8 MB (5057280 bytes plus headers for required number of files)
Memory after passing it through Athena: 1.03MB (1088847 bytes including headers for 81 .8xp files)
Executable size: 944 bytes (including .8xp header)
New lines of z80 code: ~100
New lines of Java code: Less than 50
Average framerate at 15MHz: 25FPS

If you've read the last part, you'll know that the decompressor ran a bit too slow for real-time video playback. This *can* be fixed and made better, but the point of this was to see what I could do in a single day. I do plan on working on this a bit more.

Known problems: Playback is too slow, unknown corruption in the encoding (can't find)

Warn: Attachment below is a 3.5MB video of the results so far.
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: YABAV(A)
« Reply #1 on: December 22, 2013, 01:37:49 pm »
Nice to see some competition.  :thumbsup: By the way, I'm currently at 966,656 bytes including executable code and wasted space in the app pages.
« Last Edit: December 22, 2013, 01:46:17 pm by fb39ca4 »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: YABAV(A)
« Reply #2 on: December 22, 2013, 01:43:54 pm »
I kind of want to play with compression a bit, now. That is some really good compression, by the way. I am not good on the computer side, but I would like to see what I could do with a few frames to test on.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: YABAV(A)
« Reply #3 on: December 22, 2013, 01:50:03 pm »
To extract the frames, I losslessly reencoded the video in handbrake, resizing it to 96x72. (I'm sure I could have done the cropping in that step as well, but the settings are confusing.) Then, I ran ffmpeg on the resulting video, using (if I remember correctly) -o badapple%05d.png to output each frame to a numbered .png file. From there, my python encoding script crops, converts to monochrome, encodes, and places into page .bin files each frame.
« Last Edit: December 22, 2013, 01:51:22 pm by fb39ca4 »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: YABAV(A)
« Reply #4 on: December 22, 2013, 04:42:33 pm »
Very good attempt :)

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: YABAV(A)
« Reply #5 on: December 25, 2013, 08:59:56 pm »
Second attempt. This one took a much longer amount of time to accomplish, as there were many problems both with the Java side of things and with SPASM, not to mention the woes of trying to get my 4 channel audio interrupt to work with the renderer and keep the decompressor running in the background at all times.

I still use pucrunch, but this time around, I decompress to ~16KB blocks and have the renderer scan across it.

After some manual tinkering with the data block locations, I've got the app down to 835,584 bytes total. There's still a disgusting amount of space being wasted between pages and I'm sure I could reduce the size by another 16-64KB if I coded the Java side of things to actually sort and try to fill the gaps.

Anyway.

Even tho there is no (real) music, the 4 channel audio interrupt *is* running in this screenshot at a very low frequency hum (as is the setting if not initialized). The video itself is much smoother on-calc, despite the fact that there is frame-skipping logic if the video can't render at ~30FPS.

-------
EDIT: Music *can* play. I just don't have a track to play with the thing yet.

Also, there's still an unidentified encoding problem. I don't know if it's with pucrunch or if it's the Java code unreliably reading in the .png files. Or if it's a problem with the frameskip logic.

EDIT3: Maybe I should try apack next, just for the fun of it?
« Last Edit: December 25, 2013, 09:04:44 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline Hexatron

  • LV3 Member (Next: 100)
  • ***
  • Posts: 76
  • Rating: +2/-1
    • View Profile
Re: YABAV(A)
« Reply #6 on: December 25, 2013, 09:00:47 pm »
keep up the good work!

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: YABAV(A)
« Reply #7 on: December 28, 2013, 04:45:33 pm »
Changes:

* Size reduction (now 737,280 bytes on-calc)
* Video playback perfect
* Aspect ratio preserved. Video cropped on left and right to fit.

What happened:

Implemented a page filling algorithm that actually tries to fill in the gaps between pages with data by sorting through the chunks to see what will still fit, starting from the largest available piece working its way down the list until none of the available blocks will fit any more. Saved 48-64KB.

Changed compression/decompression scheme from puCrunch to APACK. This fixed the video playback corruption issue, which doesn't inspire much confidence in what I had before. APACK also seems to perform better than puCrunch in this application. Saved another ~48-64KB.

In an attempt to fix the playback problem, I performed much of the video/image processing in FFMPEG instead of doing the ridiculously slow batch file conversions in Irfanview. Although I spent more time learning how to actually use FFMPEG than it did if I had actually went through with the batch conversion, I learned how to use it better, which makes me happier. Unfortunately, the destination folder went up dramatically, as I was unable to figure out how to change color depth of the output .png files. But, I was able to perform resizing (while preserving the aspect ratio), cropping the video, and (as was done before) splitting the file into its individual frames as PNG's.

Also, the Java script had to be changed to handle PNG files that had a color depth of more than 1bpp. If it had a color depth of 1bpp and you knew the image was 96x64, you could create an ImageData object (from the SWT library), then do something like "myPictureObject.data" to get a data stream that's binary-compatible with the calc. Just put that data into a source file and LDIR it to a screen buffer. But... since I couldn't do that anymore, I had to change it so that it actually scans through the file and creates the bitmap. Ah well.

When I changed from puCrunch to APACK, the application's performance characteristics didn't change all that much. If anything, APACK is a slight bit faster than puCrunch, but I'll have to test using an actual stopwatch later on instead of counting it out.

The audio interrupt is running at 24KHz. The app has 23-29% free CPU clocks left.

I can no longer continue this project until I have finished (or at least, completed basic functionality) my on-calc music tracker project. So unless there are other suggestions (I've already tried KermM's mt3 converter, with no luck), I'm putting this on hold for a while.

Or... if you happen to have the music for Bad Apple playable via MobileTunes3, this will plug right into the app, albeit at the wrong octave (due to the app running at 24Khz vs the required ~62KHz)

EDIT: Whoops. Forgot to upload the video. I'll do that now.
« Last Edit: December 28, 2013, 04:46:32 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline Lunar Fire

  • LV3 Member (Next: 100)
  • ***
  • Posts: 66
  • Rating: +7/-1
  • I'll be watching you from the shadows
    • View Profile
    • My Tumblr
Re: YABAV(A)
« Reply #8 on: December 28, 2013, 10:56:25 pm »
It is indeed really good. You could do a video to show how well this runs on a real calculator and have it uploaded to Youtube / Dailymotion / whatever video site you want to use. The gif is nice, but nothing shows the completion of the project like showing it running on actual hardware.
« Last Edit: December 28, 2013, 10:56:38 pm by LunarFire »
Your drill is the drill that will pierce the heavens!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: YABAV(A)
« Reply #9 on: December 30, 2013, 02:53:47 pm »
Very nice! I can't wait to hear a version with the sound ON (Video).
It is indeed really good. You could do a video to show how well this runs on a real calculator and have it uploaded to Youtube / Dailymotion / whatever video site you want to use. The gif is nice, but nothing shows the completion of the project like showing it running on actual hardware.
I think it would be best to wait until a download link is available, else people there will think it's fake.
« Last Edit: December 30, 2013, 02:54:32 pm by DJ Omnimaga »

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: YABAV(A)
« Reply #10 on: January 02, 2014, 05:42:59 pm »
It's nice to see these competing renditions. :D Good work!

Offline nikitouzz

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 215
  • Rating: +22/-1
    • View Profile
Re: YABAV(A)
« Reply #11 on: January 02, 2014, 05:59:30 pm »
Someone can make a version for TI-84+ not SE ? as if the version is not long ? please :)
mes records personels :

2x2x2 : 2.18 secondes / 2x2x2 une main : 21.15 secondes / 2x2x2 yeux bandés : 47.59
3x3x3 : 5.97 secondes / 3x3x3 une main : 49.86 secondes
4x4x4 : 1.49 minutes / 4x4x4 une main : 6.50 minutes
5x5x5 : 4.10 minutes / 5x5x5 une main : 18.02 minutes
6x6x6 : 8.10 minutes
7x7x7 : 16.03 minutes
9x9x9 : 58.26 minutes

megaminx : 5.59 minutes / pyraminx : 7.91 secondes / square-one : 1.07 minutes

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: YABAV(A)
« Reply #12 on: January 02, 2014, 06:58:10 pm »
Shouldn't be too hard. Heck, I could even make a 6 or 7 part one for the 83+ without sound.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: YABAV(A)
« Reply #13 on: January 06, 2014, 05:30:41 pm »
Iambian, what are you using to calculate CPU usage?

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: YABAV(A)
« Reply #14 on: January 07, 2014, 04:22:26 pm »
A loop of known clock cycle length during the wait period between interrupts. Cycles used in this loop is compared against the total number of cycles during program execution. I would have this loop update a 32 bit counter, which is then later read out after the end of the program execution via debugger. Your math would then be:

To determine CPU percentage idle:

(NumberOfTimesLooped*ClockCycleCountOfLoop)/(15,000,000*NumberOfSeconds)

This will give you a good enough estimation, since any inaccuracies, if done right, are negligible (less than 0.1%). This is also assuming you're running the calc at 15MHz.
« Last Edit: January 07, 2014, 04:26:32 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...