summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2009-05-22 19:36:32 +0000
committerMohamed Tarek <mt@rockbox.org>2009-05-22 19:36:32 +0000
commitfde78ddcc0f28f8f43b026db5a59e0a653e33c42 (patch)
tree85e7cf2e774d39555093b2e8698b98c23d549ace /apps
parentfe263f72608c634b3eda0bba1b6451820bfedd9b (diff)
downloadrockbox-fde78ddcc0f28f8f43b026db5a59e0a653e33c42.tar.gz
rockbox-fde78ddcc0f28f8f43b026db5a59e0a653e33c42.zip
Move wav related code to main.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21039 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/libcook/main.c80
-rw-r--r--apps/codecs/libcook/rm2wav.c80
2 files changed, 80 insertions, 80 deletions
diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c
index 3c671e0c3f..c13e74a201 100644
--- a/apps/codecs/libcook/main.c
+++ b/apps/codecs/libcook/main.c
@@ -37,6 +37,86 @@
# endif
#endif
+static unsigned char wav_header[44]={
+ 'R','I','F','F',// 0 - ChunkID
+ 0,0,0,0, // 4 - ChunkSize (filesize-8)
+ 'W','A','V','E',// 8 - Format
+ 'f','m','t',' ',// 12 - SubChunkID
+ 16,0,0,0, // 16 - SubChunk1ID // 16 for PCM
+ 1,0, // 20 - AudioFormat (1=Uncompressed)
+ 2,0, // 22 - NumChannels
+ 0,0,0,0, // 24 - SampleRate in Hz
+ 0,0,0,0, // 28 - Byte Rate (SampleRate*NumChannels*(BitsPerSample/8)
+ 4,0, // 32 - BlockAlign (== NumChannels * BitsPerSample/8)
+ 16,0, // 34 - BitsPerSample
+ 'd','a','t','a',// 36 - Subchunk2ID
+ 0,0,0,0 // 40 - Subchunk2Size
+};
+
+int open_wav(char* filename) {
+ int fd,res;
+
+ fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR);
+ if (fd >= 0) {
+ res = write(fd,wav_header,sizeof(wav_header));
+ }
+
+ return(fd);
+}
+
+void close_wav(int fd, RMContext *rmctx) {
+ int x,res;
+ int filesize;
+ int bytes_per_sample = 2;
+ int samples_per_frame = rmctx->samples_pf_pc;
+ int nb_channels = rmctx->nb_channels;
+ int sample_rate = rmctx->sample_rate;
+ int nb_frames = rmctx->audio_framesize/rmctx->block_align * rmctx->nb_packets - 2; // first 2 frames have no valid audio; skipped in output
+
+ filesize= samples_per_frame*bytes_per_sample*nb_frames +44;
+ printf("Filesize = %d\n",filesize);
+
+ // ChunkSize
+ x=filesize-8;
+ wav_header[4]=(x&0xff);
+ wav_header[5]=(x&0xff00)>>8;
+ wav_header[6]=(x&0xff0000)>>16;
+ wav_header[7]=(x&0xff000000)>>24;
+
+ // Number of channels
+ wav_header[22]=nb_channels;
+
+ // Samplerate
+ wav_header[24]=sample_rate&0xff;
+ wav_header[25]=(sample_rate&0xff00)>>8;
+ wav_header[26]=(sample_rate&0xff0000)>>16;
+ wav_header[27]=(sample_rate&0xff000000)>>24;
+
+ // ByteRate
+ x=sample_rate*bytes_per_sample*nb_channels;
+ wav_header[28]=(x&0xff);
+ wav_header[29]=(x&0xff00)>>8;
+ wav_header[30]=(x&0xff0000)>>16;
+ wav_header[31]=(x&0xff000000)>>24;
+
+ // BlockAlign
+ wav_header[32]=rmctx->block_align;//2*rmctx->nb_channels;
+
+ // Bits per sample
+ wav_header[34]=16;
+
+ // Subchunk2Size
+ x=filesize-44;
+ wav_header[40]=(x&0xff);
+ wav_header[41]=(x&0xff00)>>8;
+ wav_header[42]=(x&0xff0000)>>16;
+ wav_header[43]=(x&0xff000000)>>24;
+
+ lseek(fd,0,SEEK_SET);
+ res = write(fd,wav_header,sizeof(wav_header));
+ close(fd);
+}
+
int main(int argc, char *argv[])
{
int fd, fd_dec;
diff --git a/apps/codecs/libcook/rm2wav.c b/apps/codecs/libcook/rm2wav.c
index 4ef1ec4f66..f2e9635bfc 100644
--- a/apps/codecs/libcook/rm2wav.c
+++ b/apps/codecs/libcook/rm2wav.c
@@ -44,86 +44,6 @@
/* ASF codec IDs */
#define CODEC_ID_WMAV1 0x160
#define CODEC_ID_WMAV2 0x161
-
-static unsigned char wav_header[44]={
- 'R','I','F','F',// 0 - ChunkID
- 0,0,0,0, // 4 - ChunkSize (filesize-8)
- 'W','A','V','E',// 8 - Format
- 'f','m','t',' ',// 12 - SubChunkID
- 16,0,0,0, // 16 - SubChunk1ID // 16 for PCM
- 1,0, // 20 - AudioFormat (1=Uncompressed)
- 2,0, // 22 - NumChannels
- 0,0,0,0, // 24 - SampleRate in Hz
- 0,0,0,0, // 28 - Byte Rate (SampleRate*NumChannels*(BitsPerSample/8)
- 4,0, // 32 - BlockAlign (== NumChannels * BitsPerSample/8)
- 16,0, // 34 - BitsPerSample
- 'd','a','t','a',// 36 - Subchunk2ID
- 0,0,0,0 // 40 - Subchunk2Size
-};
-
-int open_wav(char* filename) {
- int fd,res;
-
- fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR);
- if (fd >= 0) {
- res = write(fd,wav_header,sizeof(wav_header));
- }
-
- return(fd);
-}
-
-void close_wav(int fd, RMContext *rmctx) {
- int x,res;
- int filesize;
- int bytes_per_sample = 2;
- int samples_per_frame = rmctx->samples_pf_pc;
- int nb_channels = rmctx->nb_channels;
- int sample_rate = rmctx->sample_rate;
- int nb_frames = rmctx->audio_framesize/rmctx->block_align * rmctx->nb_packets - 2; // first 2 frames have no valid audio; skipped in output
-
- filesize= samples_per_frame*bytes_per_sample*nb_frames +44;
- printf("Filesize = %d\n",filesize);
-
- // ChunkSize
- x=filesize-8;
- wav_header[4]=(x&0xff);
- wav_header[5]=(x&0xff00)>>8;
- wav_header[6]=(x&0xff0000)>>16;
- wav_header[7]=(x&0xff000000)>>24;
-
- // Number of channels
- wav_header[22]=nb_channels;
-
- // Samplerate
- wav_header[24]=sample_rate&0xff;
- wav_header[25]=(sample_rate&0xff00)>>8;
- wav_header[26]=(sample_rate&0xff0000)>>16;
- wav_header[27]=(sample_rate&0xff000000)>>24;
-
- // ByteRate
- x=sample_rate*bytes_per_sample*nb_channels;
- wav_header[28]=(x&0xff);
- wav_header[29]=(x&0xff00)>>8;
- wav_header[30]=(x&0xff0000)>>16;
- wav_header[31]=(x&0xff000000)>>24;
-
- // BlockAlign
- wav_header[32]=rmctx->block_align;//2*rmctx->nb_channels;
-
- // Bits per sample
- wav_header[34]=16;
-
- // Subchunk2Size
- x=filesize-44;
- wav_header[40]=(x&0xff);
- wav_header[41]=(x&0xff00)>>8;
- wav_header[42]=(x&0xff0000)>>16;
- wav_header[43]=(x&0xff000000)>>24;
-
- lseek(fd,0,SEEK_SET);
- res = write(fd,wav_header,sizeof(wav_header));
- close(fd);
-}
/* Some Rockbox-like functions (these should be implemented in metadata_common.[ch] */
struct cook_extradata {