summaryrefslogtreecommitdiffstats
path: root/apps/codecs/mpa.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-08-28 07:45:35 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-08-28 07:45:35 +0000
commit7ad2cad173ffa094bb285112582afee1c9aea4e5 (patch)
treece23e816cfdffb1767ebe44f4f960c304d8a5fb9 /apps/codecs/mpa.c
parent463b3ed8b2630d1b9d656dd2a52bbcbd429b4c08 (diff)
downloadrockbox-7ad2cad173ffa094bb285112582afee1c9aea4e5.tar.gz
rockbox-7ad2cad173ffa094bb285112582afee1c9aea4e5.zip
Commit work started in FS#12153 to put timing/position information in PCM
buffer chunks. * Samples and position indication is closely associated with audio data instead of compensating by a latency constant. Alleviates problems with using the elapsed as a track indicator where it could be off by several steps. * Timing is accurate throughout track even if resampling for pitch shift, whereas before it updated during transition latency at the normal 1:1 rate. * Simpler PCM buffer with a constant chunk size, no linked lists. In converting crossfade, a minor change was made to not change the WPS until the fade-in of the incoming track, whereas before it would change upon the start of the fade-out of the outgoing track possibly having the WPS change with far too much lead time. Codec changes are to set elapsed times *before* writing next PCM frame because time and position data last set are saved in the next committed PCM chunk. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30366 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/mpa.c')
-rw-r--r--apps/codecs/mpa.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index c9e2131450..ac81f06cab 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -144,6 +144,7 @@ static void set_elapsed(struct mp3entry* id3)
{
unsigned long offset = id3->offset > id3->first_frame_offset ?
id3->offset - id3->first_frame_offset : 0;
+ unsigned long elapsed = id3->elapsed;
if ( id3->vbr ) {
if ( id3->has_toc ) {
@@ -172,27 +173,28 @@ static void set_elapsed(struct mp3entry* id3)
/* set time for this percent (divide before multiply to prevent
overflow on long files. loss of precision is negligible on
short files) */
- id3->elapsed = i * (id3->length / 100);
+ elapsed = i * (id3->length / 100);
/* calculate remainder time */
plen = (nextpos - relpos) * (id3->filesize / 256);
- id3->elapsed += (((remainder * 100) / plen) *
- (id3->length / 10000));
+ elapsed += (((remainder * 100) / plen) * (id3->length / 10000));
}
else {
/* no TOC exists. set a rough estimate using average bitrate */
int tpk = id3->length /
((id3->filesize - id3->first_frame_offset - id3->id3v1len) /
1024);
- id3->elapsed = offset / 1024 * tpk;
+ elapsed = offset / 1024 * tpk;
}
}
else
{
/* constant bitrate, use exact calculation */
if (id3->bitrate != 0)
- id3->elapsed = offset / (id3->bitrate / 8);
+ elapsed = offset / (id3->bitrate / 8);
}
+
+ ci->set_elapsed(elapsed);
}
#ifdef MPA_SYNTH_ON_COP