forked from len0rd/rockbox
Reworked handling of MPEG audio frame & file info: * Fixed frame size calculation for layer 1 (all versions) and layer 2 (V2/V2.5). * Exact frame time (expressed as a fraction) for way more precise playtime calculation at 44100/22050/11025Hz sample frequency. * Exact playtime<->position conversion for CBR also used for resume position. * More compact code, long policy.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7505 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1996dca15a
commit
ec9b202a92
10 changed files with 138 additions and 159 deletions
|
@ -348,7 +348,7 @@ static void set_elapsed(struct mp3entry* id3)
|
|||
/* find wich percent we're at */
|
||||
for (i=0; i<100; i++ )
|
||||
{
|
||||
if ( id3->offset < (int)(id3->toc[i] * (id3->filesize / 256)) )
|
||||
if ( id3->offset < id3->toc[i] * (id3->filesize / 256) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -388,8 +388,8 @@ static void set_elapsed(struct mp3entry* id3)
|
|||
}
|
||||
}
|
||||
else
|
||||
/* constant bitrate == simple frame calculation */
|
||||
id3->elapsed = id3->offset / id3->bpf * id3->tpf;
|
||||
/* constant bitrate, use exact calculation */
|
||||
id3->elapsed = id3->offset / (id3->bitrate / 8);
|
||||
}
|
||||
|
||||
int audio_get_file_pos(void)
|
||||
|
@ -405,7 +405,7 @@ int audio_get_file_pos(void)
|
|||
unsigned int percent, remainder;
|
||||
int curtoc, nexttoc, plen;
|
||||
|
||||
percent = (id3->elapsed*100)/id3->length;
|
||||
percent = (id3->elapsed*100)/id3->length;
|
||||
if (percent > 99)
|
||||
percent = 99;
|
||||
|
||||
|
@ -431,8 +431,8 @@ int audio_get_file_pos(void)
|
|||
(id3->elapsed / 1000);
|
||||
}
|
||||
}
|
||||
else if (id3->bpf && id3->tpf)
|
||||
pos = (id3->elapsed/id3->tpf)*id3->bpf;
|
||||
else if (id3->bitrate)
|
||||
pos = id3->elapsed * (id3->bitrate / 8);
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue