From: kramm Date: Sat, 4 Jan 2003 17:01:54 +0000 (+0000) Subject: implemented --framerate. X-Git-Tag: old_makefiles2~4 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=0e8807d9a620e8932bc67653321eaae1436fdd43;p=swftools.git implemented --framerate. --- diff --git a/src/wav2swf.1 b/src/wav2swf.1 index ed7333e..58ef992 100644 --- a/src/wav2swf.1 +++ b/src/wav2swf.1 @@ -18,6 +18,17 @@ Print version info and exit .TP \fB\-o\fR, \fB\-\-output\fR \fIfilename\fR Explicitly specify output file. (Otherwise, output will go to output.swf) +.TP +\fB\-f\fR, \fB\-\-framerate\fR \fIfps\fR +Set file framerate to \fIfps\fR frames per second. +.TP +\fB\-l\fR, \fB\-\-loop\fR \fIn\fR +(Only used with -d) +Loop the sound n times. +.TP +\fB\-d\fR, \fB\-\-definesound\fR +Store the sound as DEFINESOUND tag, not as streaming sound. Allows for +looping. .SH AUTHORS diff --git a/src/wav2swf.c b/src/wav2swf.c index 0b233c7..70315b2 100644 --- a/src/wav2swf.c +++ b/src/wav2swf.c @@ -24,12 +24,14 @@ struct options_t options[] = {"v","verbose"}, {"d","definesound"}, {"l","loop"}, + {"f","framerate"}, {"V","version"}, {0,0} }; static int loop = 0; static int definesound = 0; +static int framerate = 0; int args_callback_option(char*name,char*val) { @@ -53,6 +55,12 @@ int args_callback_option(char*name,char*val) verbose ++; return 0; } + else if(!strcmp(name, "f")) { + float f; + sscanf(val, "%f", &f); + framerate = f*256; + return 1; + } else { printf("Unknown option: -%s\n", name); exit(1); @@ -69,6 +77,7 @@ void args_callback_usage(char*name) printf("\t-v , --verbose\t\t\t Be more verbose\n"); printf("\t-d , --definesound\t\t\t Generate a DefineSound tag instead of streaming sound\n"); printf("\t-l , --loop n\t\t\t Loop sound n times (implies -d)\n"); + printf("\t-f , --framerate fps\t\t\t Set framerate to fps frames per seond\n"); printf("\t-o , --output filename\t\t set output filename (default: output.swf)\n"); printf("\t-V , --version\t\t\t Print program version and exit\n"); } @@ -94,11 +103,23 @@ int main (int argc,char ** argv) int count; int t; struct WAV wav,wav2; - int blocksize = 1152; + int blocksize; + float blockspersecond; + float framespersecond; + float framesperblock; + float framepos = 0; U16* samples; int numsamples; processargs(argc, argv); + + blocksize = 1152; + blockspersecond = 11025.0/blocksize; + framespersecond = blockspersecond; + if(framerate) + framespersecond = framerate/256.0; + framesperblock = framespersecond/blockspersecond; + initLog(0,-1,0,0,-1,verbose); if(!readWAV(filename, &wav)) @@ -115,7 +136,7 @@ int main (int argc,char ** argv) memset(&swf,0x00,sizeof(SWF)); swf.fileVersion = 5; - swf.frameRate = 11025*256/(blocksize); + swf.frameRate = (int)(framespersecond*256); swf.movieSize.xmax = 20*width; swf.movieSize.ymax = 20*height; @@ -135,12 +156,17 @@ int main (int argc,char ** argv) logf(" %d blocks", numsamples/(blocksize*2)); for(t=0;t Writing block %d", t); block1 = &samples[t*2*blocksize]; swf_SetSoundStreamBlock(tag, block1, 1); - tag = swf_InsertTag(tag, ST_SHOWFRAME); + oldframe = (int)framepos; + framepos += framesperblock; + newframe = (int)framepos; + for(s=oldframe;s