summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-03-29 08:19:47 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-03-29 08:19:47 +0000
commitb109c1e910bb51f06fba96a9eebcc6963cd51de7 (patch)
tree0928028450e672c976a9f9ef2a23788c16a43a30 /apps
parent39c07cdcfba8aa17f9f323ac363702a0879e43cf (diff)
downloadrockbox-b109c1e910bb51f06fba96a9eebcc6963cd51de7.tar.gz
rockbox-b109c1e910bb51f06fba96a9eebcc6963cd51de7.zip
insert a dummy frame before changing clips (still no major improvement), back to the previous frame search algorithm because the talkbox clips can be quite different
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4449 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/talk.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 6dd0076f06..f65b594b92 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -167,14 +167,11 @@ static int shutup(void)
unsigned char* pos;
unsigned char* search;
unsigned char* end;
- unsigned char frame1, frame3;
- unsigned char *firstclip = mp3buf + p_voicefont->index[0].offset;
-
- /* We use the first frame in the thumbnail buffer as a template
- for finding headers, assuming that all thumbnails are encoded
- with the same parameters */
- frame1 = firstclip[1]; /* second byte of the first mp3 header */
- frame3 = firstclip[3]; /* last byte of the first mp3 header */
+ /* one silent bitswapped mp3 frame (22kHz), without bit reservoir */
+ static const unsigned char silent_frame[] = {
+ 0xFF,0xCF,0x08,0x23,0x00,0x00,0x00,0xC0,0x12,0x80,0x01,0x00,0x00,
+ 0x32,0x82,0xB2,0xA2,0xCC,0x74,0x9C,0xCC,0xAA,0xAA,0xAA,0xAA,0xAA,
+ };
mp3_play_pause(false); /* pause */
@@ -188,11 +185,21 @@ static int shutup(void)
/* Find the next frame boundary */
while (search < end) /* search the remaining data */
{
- if(search[0] == 0xff && search[1] == frame1 && search[3] == frame3)
+ if (*search++ != 0xFF) /* search for frame sync byte */
+ {
+ continue;
+ }
+
+ /* look at the (bitswapped) 2nd byte of header candidate */
+ if ((*search & 0x07) == 0x07 /* rest of frame sync */
+ && (*search & 0x18) != 0x10 /* version != reserved */
+ && (*search & 0x60) != 0x00) /* layer != reserved */
{
- break;
+ search--; /* back to the sync byte */
+ break; /* From looking at the first 2 bytes, this is a header. */
+ /* this is not a sufficient condition to find header,
+ may give "false alert" (end too early), but a start */
}
- search++;
}
queue_write = queue_read; /* reset the queue */
@@ -204,6 +211,7 @@ static int shutup(void)
/* If the voice clips contain dependent frames (currently they don't),
it may be a good idea to insert an independent dummy frame here. */
+ queue_clip((unsigned char*)silent_frame, sizeof(silent_frame), true);
return 0;
}