From 5bb773e10a99dea6e224030bda4b58aba1679869 Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 13 Jan 2002 18:24:44 +0000 Subject: [PATCH] only write the init header once per SWF. --- lib/modules/swfsound.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/modules/swfsound.c b/lib/modules/swfsound.c index 5804921..ba5e935 100644 --- a/lib/modules/swfsound.c +++ b/lib/modules/swfsound.c @@ -13,49 +13,51 @@ #include "../rfxswf.h" +CodecInitOut * init = 0; void swf_SetSoundStreamHead(TAG*tag, U16 avgnumsamples) { U8 playbackrate = 3; // 0 = 5.5 Khz, 1 = 11 Khz, 2 = 22 Khz, 3 = 44 Khz - U8 playbacksize = 0; // 0 = 8 bit, 1 = 16 bit - U8 playbacktype = 1; // 0 = mono, 1 = stereo + U8 playbacksize = 1; // 0 = 8 bit, 1 = 16 bit + U8 playbacktype = 0; // 0 = mono, 1 = stereo U8 compression = 2; // 0 = raw, 1 = ADPCM, 2 = mp3 U8 rate = 3; // 0 = 5.5 Khz, 1 = 11 Khz, 2 = 22 Khz, 3 = 44 Khz - U8 size = 0; // 0 = 8 bit, 1 = 16 bit - U8 type = 1; // 0 = mono, 1 = stereo + U8 size = 1; // 0 = 8 bit, 1 = 16 bit + U8 type = 0; // 0 = mono, 1 = stereo + + CodecInitIn params; + memset(¶ms, 0, sizeof(params)); + params.frequency = 44100; //48000, 44100 or 32000 + params.mode = 3; //0 = Stereo, 2 = Dual Channel, 3 = Mono + params.emphasis = 0; //0 = None, 1 = 50/15 microsec, 3 = CCITT J.17 + params.bitrate = 128; //default is 128 (64 for mono) + init = codecInit(¶ms); swf_SetU8(tag,(playbackrate<<2)|(playbacksize<<1)|playbacktype); swf_SetU8(tag,(compression<<4)|(rate<<2)|(size<<1)|type); swf_SetU16(tag,avgnumsamples); + + printf("numSamples:%d\n",init->nSamples); + printf("bufferSize:%d\n",init->bufferSize); } -void swf_SetSoundStreamBlock(TAG*tag, U16*samples, int numsamples) +void swf_SetSoundStreamBlock(TAG*tag, S16*samples, int numsamples, char first) { - CodecInitOut * init; - CodecInitIn params; char*buf; int len = 0; if(!buf) return; - - memset(¶ms, 0, sizeof(params)); - params.frequency = 44100; //48000, 44100 or 32000 - params.mode = 0; //0 = Stereo, 2 = Dual Channel, 3 = Mono - params.emphasis = 0; //0 = None, 1 = 50/15 microsec, 3 = CCITT J.17 - params.bitrate = 128; //default is 128 (64 for mono) - - init = codecInit(¶ms); - printf("nSamples:%d\n", init->nSamples); - printf("bufferSize:%d\n", init->bufferSize); buf = malloc(init->bufferSize); - len = codecEncodeChunk(numsamples, samples, buf); + len = codecEncodeChunk (numsamples, samples, buf); len += codecFlush (&buf[len]); - len += codecExit(&buf[len]); + len += codecExit (&buf[len]); - swf_SetU16(tag, numsamples); // number of samples - swf_SetU16(tag, 0); // seek + if(first) { + swf_SetU16(tag, numsamples); // number of samples + swf_SetU16(tag, 0); // seek + } swf_SetBlock(tag, buf, len); free(buf); } -- 1.7.10.4