From 8f46d91326764a436907c2895de1d721d9c6e5bb Mon Sep 17 00:00:00 2001 From: kramm Date: Thu, 10 Jan 2002 19:29:14 +0000 Subject: [PATCH] initial revision --- lib/modules/swfsound.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lib/modules/swfsound.c diff --git a/lib/modules/swfsound.c b/lib/modules/swfsound.c new file mode 100644 index 0000000..5ccc756 --- /dev/null +++ b/lib/modules/swfsound.c @@ -0,0 +1,60 @@ +/* swfaction.c + + SWF Sound handling routines + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2001, 2002 Matthias Kramm + + This file is distributed under the GPL, see file COPYING for details + +*/ + +#include "../rfxswf.h" + +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 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 + + swf_SetU8(tag,(playbackrate<<2)|(playbacksize<<1)|playbacktype); + swf_SetU8(tag,(compression<<4)|(rate<<2)|(size<<1)|type); + swf_SetU16(tag,avgnumsamples); +} + +void swf_SetSoundStreamBlock(TAG*tag, U16*samples, int numsamples) +{ + 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 += codecFlush (&buf[len]); + len += codecExit(&buf[len]); + + swf_SetBlock(tag, buf, len); + free(buf); +} + -- 1.7.10.4