X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=src%2Fwav2swf.c;h=0b1cf36ff86bdb7260ee22dc51aefd3a453d276f;hp=89add267044b0325643b9e8bd3152b4553d19a01;hb=26af26a251a58f33b295a0ae36ebd27ec167dc88;hpb=a5f50be98c64a4f4cd25758a43386528a6998aad diff --git a/src/wav2swf.c b/src/wav2swf.c index 89add26..0b1cf36 100644 --- a/src/wav2swf.c +++ b/src/wav2swf.c @@ -4,8 +4,20 @@ Part of the swftools package. Copyright (c) 2001 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This file is distributed under the GPL, see file COPYING for details */ + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include @@ -89,7 +101,7 @@ int args_callback_option(char*name,char*val) samplerate = 44100; else { fprintf(stderr, "Invalid samplerate: %d\n", samplerate); - fprintf(stderr, "Allowed values: 11025, 22050\n", samplerate); + fprintf(stderr, "Allowed values: 11025, 22050, 44100\n", samplerate); exit(1); } return 1; @@ -178,7 +190,8 @@ int main (int argc,char ** argv) processargs(argc, argv); - blocksize = 576; + blocksize = (samplerate > 22050) ? 1152 : 576; + blockspersecond = (float)samplerate/blocksize; framespersecond = blockspersecond; @@ -207,6 +220,20 @@ int main (int argc,char ** argv) samples = (U16*)wav2.data; numsamples = wav2.size/2; + if(numsamples%blocksize != 0) + { + // apply padding, so that block is a multiple of blocksize + int numblocks = (numsamples+blocksize-1)/blocksize; + int numsamples2; + U16* samples2; + numsamples2 = numblocks * blocksize; + samples2 = malloc(sizeof(U16)*numsamples2); + memcpy(samples2, samples, numsamples*sizeof(U16)); + memset(&samples2[numsamples], 0, sizeof(U16)*(numsamples2 - numsamples)); + numsamples = numsamples2; + samples = samples2; + } + memset(&swf,0x00,sizeof(SWF)); swf.fileVersion = 5; @@ -276,7 +303,7 @@ int main (int argc,char ** argv) #else swf_SetU8(tag,(/*compression*/0<<4)|(/*rate*/3<<2)|(/*size*/1<<1)|/*mono*/0); swf_SetU32(tag, numsamples); // 44100 -> 11025 - swf_SetBlock(tag, wav2.data, numsamples*2); + swf_SetBlock(tag, samples, numsamples*2); #endif