summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2009-05-22 20:35:20 +0000
committerMohamed Tarek <mt@rockbox.org>2009-05-22 20:35:20 +0000
commit95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36 (patch)
tree9f708c255835ca590eedd10226ee4731abfb064f
parentb63028d80ae665688a2202a2eaeb2e01e10ab520 (diff)
downloadrockbox-95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36.tar.gz
rockbox-95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36.zip
Move the code segment that corrects the value of (number of packets) to
the parser. This is strictly parser-related and main.c shouldn't have to deal with it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21043 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libcook/main.c8
-rw-r--r--apps/codecs/libcook/rm.c11
2 files changed, 12 insertions, 7 deletions
diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c
index 3557b15524..f12e586352 100644
--- a/apps/codecs/libcook/main.c
+++ b/apps/codecs/libcook/main.c
@@ -121,7 +121,7 @@ void close_wav(int fd, RMContext *rmctx) {
121int main(int argc, char *argv[]) 121int main(int argc, char *argv[])
122{ 122{
123 int fd, fd_dec; 123 int fd, fd_dec;
124 int res, datasize,x,i; 124 int res, datasize,i;
125 int nb_frames = 0; 125 int nb_frames = 0;
126#ifdef DUMP_RAW_FRAMES 126#ifdef DUMP_RAW_FRAMES
127 char filename[15]; 127 char filename[15];
@@ -167,12 +167,6 @@ int main(int argc, char *argv[])
167 h = rmctx.sub_packet_h; 167 h = rmctx.sub_packet_h;
168 cook_decode_init(&rmctx,&q); 168 cook_decode_init(&rmctx,&q);
169 DEBUGF("nb_frames = %d\n",nb_frames); 169 DEBUGF("nb_frames = %d\n",nb_frames);
170 x = 0;
171 if(packet_count % h)
172 {
173 packet_count += h - (packet_count % h);
174 rmctx.nb_packets = packet_count;
175 }
176 170
177 /* change the buffer pointer to point at the first audio frame */ 171 /* change the buffer pointer to point at the first audio frame */
178 advance_buffer(&filebuf, rmctx.data_offset+ DATA_HEADER_SIZE); 172 advance_buffer(&filebuf, rmctx.data_offset+ DATA_HEADER_SIZE);
diff --git a/apps/codecs/libcook/rm.c b/apps/codecs/libcook/rm.c
index b2ccfc2480..86c4378d56 100644
--- a/apps/codecs/libcook/rm.c
+++ b/apps/codecs/libcook/rm.c
@@ -434,6 +434,17 @@ int real_parse_header(int fd, RMContext *rmctx)
434 skipped += 4; 434 skipped += 4;
435 if (!rmctx->nb_packets && (rmctx->flags & 4)) 435 if (!rmctx->nb_packets && (rmctx->flags & 4))
436 rmctx->nb_packets = 3600 * 25; 436 rmctx->nb_packets = 3600 * 25;
437
438 /***
439 * nb_packets correction :
440 * in some samples, number of packets may not exactly form
441 * an integer number of scrambling units. This is corrected
442 * by constructing a partially filled unit out of the few
443 * remaining samples at the end of decoding.
444 ***/
445 if(rmctx->nb_packets % rmctx->sub_packet_h)
446 rmctx->nb_packets += rmctx->sub_packet_h - (rmctx->nb_packets % rmctx->sub_packet_h);
447
437 printf(" data_nb_packets = %d\n",rmctx->nb_packets); 448 printf(" data_nb_packets = %d\n",rmctx->nb_packets);
438 printf(" next DATA offset = %d\n",next_data_off); 449 printf(" next DATA offset = %d\n",next_data_off);
439 header_end = 1; 450 header_end = 1;