summaryrefslogtreecommitdiff
path: root/apps/codecs/libcook/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libcook/main.c')
-rw-r--r--apps/codecs/libcook/main.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c
index 87f65845e8..fd20f98871 100644
--- a/apps/codecs/libcook/main.c
+++ b/apps/codecs/libcook/main.c
@@ -29,13 +29,6 @@
29#include "cook.h" 29#include "cook.h"
30 30
31//#define DUMP_RAW_FRAMES 31//#define DUMP_RAW_FRAMES
32#ifndef DEBUGF
33# if 0
34# define DEBUGF(message,args ...) printf
35# else
36# define DEBUGF(...)
37# endif
38#endif
39 32
40#define DATA_HEADER_SIZE 18 /* size of DATA chunk header in a rm file */ 33#define DATA_HEADER_SIZE 18 /* size of DATA chunk header in a rm file */
41static unsigned char wav_header[44]={ 34static unsigned char wav_header[44]={
@@ -151,8 +144,8 @@ int main(int argc, char *argv[])
151 144
152 /* copy the input rm file to a memory buffer */ 145 /* copy the input rm file to a memory buffer */
153 uint8_t * filebuf = (uint8_t *)calloc((int)filesize(fd),sizeof(uint8_t)); 146 uint8_t * filebuf = (uint8_t *)calloc((int)filesize(fd),sizeof(uint8_t));
154 read(fd,filebuf,filesize(fd)); 147 res = read(fd,filebuf,filesize(fd));
155 148
156 fd_dec = open_wav("output.wav"); 149 fd_dec = open_wav("output.wav");
157 if (fd_dec < 0) { 150 if (fd_dec < 0) {
158 DEBUGF("Error creating output file\n"); 151 DEBUGF("Error creating output file\n");
@@ -166,27 +159,25 @@ int main(int argc, char *argv[])
166 sps= rmctx.block_align; 159 sps= rmctx.block_align;
167 h = rmctx.sub_packet_h; 160 h = rmctx.sub_packet_h;
168 cook_decode_init(&rmctx,&q); 161 cook_decode_init(&rmctx,&q);
169 DEBUGF("nb_frames = %d\n",nb_frames); 162
170
171 /* change the buffer pointer to point at the first audio frame */ 163 /* change the buffer pointer to point at the first audio frame */
172 advance_buffer(&filebuf, rmctx.data_offset+ DATA_HEADER_SIZE); 164 advance_buffer(&filebuf, rmctx.data_offset+ DATA_HEADER_SIZE);
173 while(packet_count) 165 while(packet_count)
174 { 166 {
175 rm_get_packet_membuf(&filebuf, &rmctx, &pkt); 167 rm_get_packet(&filebuf, &rmctx, &pkt);
176 DEBUGF("total frames = %d packet count = %d output counter = %d \n",rmctx.audio_pkt_cnt*(fs/sps), packet_count,rmctx.audio_pkt_cnt); 168 //DEBUGF("total frames = %d packet count = %d output counter = %d \n",rmctx.audio_pkt_cnt*(fs/sps), packet_count,rmctx.audio_pkt_cnt);
177 for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) 169 for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
178 { 170 {
179 /* output raw audio frames that are sent to the decoder into separate files */ 171 /* output raw audio frames that are sent to the decoder into separate files */
180 #ifdef DUMP_RAW_FRAMES 172#ifdef DUMP_RAW_FRAMES
181 snprintf(filename,sizeof(filename),"dump%d.raw",++x); 173 snprintf(filename,sizeof(filename),"dump%d.raw",++x);
182 fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND); 174 fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND);
183 write(fd_out,pkt.frames[i],sps); 175 write(fd_out,pkt.frames[i],sps);
184 close(fd_out); 176 close(fd_out);
185 #endif 177#endif
186
187 nb_frames = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i] , rmctx.block_align); 178 nb_frames = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i] , rmctx.block_align);
188 rmctx.frame_number++; 179 rmctx.frame_number++;
189 write(fd_dec,outbuf,datasize); 180 res = write(fd_dec,outbuf,datasize);
190 } 181 }
191 packet_count -= rmctx.audio_pkt_cnt; 182 packet_count -= rmctx.audio_pkt_cnt;
192 rmctx.audio_pkt_cnt = 0; 183 rmctx.audio_pkt_cnt = 0;