X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswfsound.c;h=a7ca0e1539068015180e5b20b8cc5bb1460fe5bb;hb=714b122c75a757dcd1ef9a631aa209a298e650d7;hp=dec1fe9fe0a90fb23eca0d29e8ca87e3e2a86661;hpb=d6156a349c63b5fb77a6bd0160aef54cb3b13cdb;p=swftools.git diff --git a/lib/modules/swfsound.c b/lib/modules/swfsound.c index dec1fe9..a7ca0e1 100644 --- a/lib/modules/swfsound.c +++ b/lib/modules/swfsound.c @@ -7,16 +7,27 @@ Copyright (c) 2001, 2002 Matthias Kramm - This file is distributed under the GPL, see file COPYING for details + 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 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. -#ifndef RFXSWF_DISABLESOUND + 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 */ + +#ifndef NO_MP3 #include "../rfxswf.h" #ifdef BLADEENC -fjokjklj +#define HAVE_SOUND + CodecInitOut * init = 0; void swf_SetSoundStreamHead(TAG*tag, U16 avgnumsamples) { @@ -66,17 +77,18 @@ void swf_SetSoundStreamBlock(TAG*tag, S16*samples, int numsamples, char first) } #endif +/* TODO: find a better way to set these from the outside */ -#ifdef LAME - -#include "../lame/lame.h" - -/* TODO: find a way to set these from the outside */ int swf_mp3_in_samplerate = 44100; int swf_mp3_out_samplerate = 11025; int swf_mp3_channels = 1; int swf_mp3_bitrate = 32; +#ifdef HAVE_LAME +#define HAVE_SOUND + +#include "../lame/lame.h" + static lame_global_flags*lame_flags; static void initlame() @@ -142,8 +154,8 @@ void swf_SetSoundStreamBlock(TAG*tag, S16*samples, int seek, char first) char*buf; int len = 0; int bufsize = 16384; - int numsamples = 576*(swf_mp3_in_samplerate/swf_mp3_out_samplerate); - int fs; + int numsamples = (int)(((swf_mp3_out_samplerate > 22050) ? 1152 : 576) * ((double)swf_mp3_in_samplerate/swf_mp3_out_samplerate)); + int fs = 0; buf = malloc(bufsize); if(!buf) @@ -184,7 +196,7 @@ void swf_SetSoundDefine(TAG*tag, S16*samples, int num) char*buf; int oldlen=0,len = 0; int bufsize = 16384; - int blocksize = 576*(swf_mp3_in_samplerate/swf_mp3_out_samplerate); + int blocksize = (int)(((swf_mp3_out_samplerate > 22050) ? 1152 : 576) * ((double)swf_mp3_in_samplerate/swf_mp3_out_samplerate)); int t; int blocks; @@ -203,8 +215,8 @@ void swf_SetSoundDefine(TAG*tag, S16*samples, int num) swf_SetU8(tag,(compression<<4)|(rate<<2)|(size<<1)|type); - swf_SetU32(tag,blocks*blocksize / - (swf_mp3_in_samplerate/swf_mp3_out_samplerate) // account for resampling + swf_SetU32(tag, (int)(tag,blocks*blocksize / + ((double)swf_mp3_in_samplerate/swf_mp3_out_samplerate)) // account for resampling ); buf = malloc(bufsize); @@ -227,6 +239,37 @@ void swf_SetSoundDefine(TAG*tag, S16*samples, int num) free(buf); } +#endif + +#endif + +#ifndef HAVE_SOUND + +// supply stubs + +void swf_SetSoundStreamHead(TAG*tag, int avgnumsamples) +{ + fprintf(stderr, "Error: no sound support compiled in.\n");exit(1); +} +void swf_SetSoundStreamBlock(TAG*tag, S16*samples, int seek, char first) +{ + fprintf(stderr, "Error: no sound support compiled in.\n");exit(1); +} +void swf_SetSoundStreamEnd(TAG*tag) +{ + fprintf(stderr, "Error: no sound support compiled in.\n");exit(1); +} +void swf_SetSoundDefineRaw(TAG*tag, S16*samples, int num, int samplerate) +{ + fprintf(stderr, "Error: no sound support compiled in.\n");exit(1); +} +void swf_SetSoundDefine(TAG*tag, S16*samples, int num) +{ + fprintf(stderr, "Error: no sound support compiled in.\n");exit(1); +} + +#endif + #define SOUNDINFO_STOP 32 #define SOUNDINFO_NOMULTIPLE 16 #define SOUNDINFO_HASENVELOPE 8 @@ -234,6 +277,7 @@ void swf_SetSoundDefine(TAG*tag, S16*samples, int num) #define SOUNDINFO_HASOUTPOINT 2 #define SOUNDINFO_HASINPOINT 1 + void swf_SetSoundInfo(TAG*tag, SOUNDINFO*info) { U8 flags = (info->stop?SOUNDINFO_STOP:0) @@ -260,6 +304,4 @@ void swf_SetSoundInfo(TAG*tag, SOUNDINFO*info) } } -#endif -#endif // RFXSWF_DISABLESOUND