Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: apcalc on January 31, 2011, 04:30:16 pm

Title: TI-Nspire Video Player Help
Post by: apcalc on January 31, 2011, 04:30:16 pm
I am in the process of coding a video player for the Nspire using almost the same method as described by thepenguin77 in his 84+ video player.  Unfortunately, I am having difficulty getting the .tns file to run.  I find that when I display one and only one frame of the video, everything works fine, but the instant I try to show more than one frame, whether it be 200 frames of 2 frames, the Nspire crashes.

For example, the code:

Code: [Select]
#include <os.h>

int main (void) {

char * buffer=malloc(SCREEN_BYTES_SIZE);
memcpy(buffer,0xFF,SCREEN_BYTES_SIZE);
char image1[SCREEN_BYTES_SIZE]={image data, too long to post here};
memcpy(buffer,image1,SCREEN_BYTES_SIZE);
memcpy(SCREEN_BASE_ADDRESS,buffer,SCREEN_BYTES_SIZE);
free(buffer);
return 0;

}

But, when I add a second image, like so:


Code: [Select]
#include <os.h>

int main (void) {

char * buffer=malloc(SCREEN_BYTES_SIZE);
memcpy(buffer,0xFF,SCREEN_BYTES_SIZE);
char image1[SCREEN_BYTES_SIZE]={image data, too long to post here};
memcpy(buffer,image1,SCREEN_BYTES_SIZE);
memcpy(SCREEN_BASE_ADDRESS,buffer,SCREEN_BYTES_SIZE);
char image2[SCREEN_BYTES_SIZE]={image data, too long to post here};
memcpy(buffer,image2,SCREEN_BYTES_SIZE);
memcpy(SCREEN_BASE_ADDRESS,buffer,SCREEN_BYTES_SIZE);
free(buffer);
return 0;

}

The Nspire crashes when I run the program.  Does anyone know what could be causing this?  Obviously, this program is still in very early stages, and the conversion process is difficult at this point, but, I can't make any more progress until I can at least see something play.  Is there something preventing me from calling memcpy( so many times?  The data files for each frame are HUGE, could having more than one be causing me to crash?   Any help would be much appreciated, I would love to finish this program, as I think it would add new dimensions to Nspire programming.

Also, for the curious, here is a screenshot of it successfully running one single frame:

(http://img.removedfromgame.com/imgs/train_pic.GIF)
(note, the dithering is done by my screenshot program, not the actual calculator)
Title: Re: TI-Nspire Video Player Help
Post by: calc84maniac on January 31, 2011, 06:08:59 pm
It could be because it's allocating these char buffers on the stack. Try making them global variables instead.
Title: Re: TI-Nspire Video Player Help
Post by: apcalc on January 31, 2011, 06:24:56 pm
YAY! :D

That works beautifully, calc84, thank you!  Now I can actually rickroll everyone in school tomorrow!!!! :)
Title: Re: TI-Nspire Video Player Help
Post by: jnesselr on January 31, 2011, 06:27:10 pm
Oh, I was expecting critor. He usually does some of the interesting NSpire hacks.  It looks nice apcalc!
Title: Re: TI-Nspire Video Player Help
Post by: critor on January 31, 2011, 06:40:46 pm
Sorry, I was quite busy today.

I'm glad the problem is solved :)
Title: Re: TI-Nspire Video Player Help
Post by: calcdude84se on February 01, 2011, 08:51:02 pm
Nice, apcalc :D
And I see that it has already been put to rickroll use elsewhere... :P
Title: Re: TI-Nspire Video Player Help
Post by: Jonius7 on February 01, 2011, 09:50:33 pm
wow so how does it convert the frames (like there are different video resolutions)