summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2018-10-15 17:59:13 -0400
committerSolomon Peachy <pizza@shaftnet.org>2018-10-29 19:50:34 +0100
commit20b91a83d3078eeabc02a4d214f6d44c64282f89 (patch)
tree00a182ef2240e6edc5a88ae4cf037479f5fa042c /lib
parent0120ecd651a2ff3f8e202a704d6e73b705cf81d0 (diff)
downloadrockbox-20b91a83d3078eeabc02a4d214f6d44c64282f89.tar.gz
rockbox-20b91a83d3078eeabc02a4d214f6d44c64282f89.tar.bz2
rockbox-20b91a83d3078eeabc02a4d214f6d44c64282f89.zip
codecs: Fix elapsed time calculation for large files
In particular, this solves seeking glitches seen in ~6 hr mp3 files. (Patch taken from Igor Poretsky's tree) Change-Id: Id65b6726146b6d2d1a223e90b88e401d1b2d597a
Diffstat (limited to 'lib')
-rw-r--r--lib/rbcodec/codecs/aac.c5
-rw-r--r--lib/rbcodec/codecs/alac.c6
-rw-r--r--lib/rbcodec/codecs/ape.c7
-rw-r--r--lib/rbcodec/codecs/mpa.c4
-rw-r--r--lib/rbcodec/codecs/mpc.c6
-rw-r--r--lib/rbcodec/codecs/shorten.c2
-rw-r--r--lib/rbcodec/codecs/speex.c2
7 files changed, 15 insertions, 17 deletions
diff --git a/lib/rbcodec/codecs/aac.c b/lib/rbcodec/codecs/aac.c
index 5e289f0306..c00946f227 100644
--- a/lib/rbcodec/codecs/aac.c
+++ b/lib/rbcodec/codecs/aac.c
@@ -141,8 +141,7 @@ enum codec_status codec_run(void)
sound_samples_done = 0;
}
NeAACDecPostSeekReset(decoder, i);
- elapsed_time = (sound_samples_done * 10) /
- (ci->id3->frequency / 100);
+ elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency;
} else if (param) {
elapsed_time = param;
action = CODEC_ACTION_SEEK_TIME;
@@ -176,7 +175,7 @@ enum codec_status codec_run(void)
(param/10/sbr_fac)*(ci->id3->frequency/100),
&sound_samples_done, (int*) &i)) {
sound_samples_done *= sbr_fac;
- elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100);
+ elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency;
ci->set_elapsed(elapsed_time);
seek_idx = 0;
diff --git a/lib/rbcodec/codecs/alac.c b/lib/rbcodec/codecs/alac.c
index 35c3645657..903ea2850e 100644
--- a/lib/rbcodec/codecs/alac.c
+++ b/lib/rbcodec/codecs/alac.c
@@ -104,7 +104,7 @@ enum codec_status codec_run(void)
}
}
- elapsedtime = (samplesdone*10)/(ci->id3->frequency/100);
+ elapsedtime = samplesdone * 1000LL / ci->id3->frequency;
ci->set_elapsed(elapsedtime);
/* The main decoding loop */
@@ -119,7 +119,7 @@ enum codec_status codec_run(void)
if (m4a_seek(&demux_res, &input_stream,
(param/10) * (ci->id3->frequency/100),
&samplesdone, (int *)&i)) {
- elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
+ elapsedtime=samplesdone*1000LL/ci->id3->frequency;
}
ci->set_elapsed(elapsedtime);
ci->seek_complete();
@@ -140,7 +140,7 @@ enum codec_status codec_run(void)
/* Update the elapsed-time indicator */
samplesdone+=samplesdecoded;
- elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
+ elapsedtime=samplesdone*1000LL/ci->id3->frequency;
ci->set_elapsed(elapsedtime);
i++;
diff --git a/lib/rbcodec/codecs/ape.c b/lib/rbcodec/codecs/ape.c
index 0adc793ade..937af1945f 100644
--- a/lib/rbcodec/codecs/ape.c
+++ b/lib/rbcodec/codecs/ape.c
@@ -218,7 +218,7 @@ enum codec_status codec_run(void)
ape_resume(&ape_ctx, resume_offset,
&currentframe, &samplesdone, &samplestoskip, &firstbyte);
- elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100);
+ elapsedtime = samplesdone*1000LL/ape_ctx.samplerate;
}
else {
currentframe = 0;
@@ -285,8 +285,7 @@ frame_start:
inbuffer = ci->request_buffer(&bytesleft,
INPUT_CHUNKSIZE);
- elapsedtime = (samplesdone*10)/
- (ape_ctx.samplerate/100);
+ elapsedtime = samplesdone*1000LL/ape_ctx.samplerate;
ci->set_elapsed(elapsedtime);
ci->seek_complete();
action = CODEC_ACTION_NULL;
@@ -330,7 +329,7 @@ frame_start:
if (!samplestoskip) {
/* Update the elapsed-time indicator */
- elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100);
+ elapsedtime = samplesdone*1000LL/ape_ctx.samplerate;
ci->set_elapsed(elapsedtime);
}
diff --git a/lib/rbcodec/codecs/mpa.c b/lib/rbcodec/codecs/mpa.c
index 0e7b4faf4f..e6662ddcbe 100644
--- a/lib/rbcodec/codecs/mpa.c
+++ b/lib/rbcodec/codecs/mpa.c
@@ -420,7 +420,7 @@ enum codec_status codec_run(void)
break;
}
- ci->set_elapsed((samplesdone * 1000) / current_frequency);
+ ci->set_elapsed((samplesdone * 1000LL) / current_frequency);
ci->seek_complete();
init_mad();
framelength = 0;
@@ -508,7 +508,7 @@ enum codec_status codec_run(void)
}
samplesdone += framelength;
- ci->set_elapsed((samplesdone * 1000) / current_frequency);
+ ci->set_elapsed((samplesdone * 1000LL) / current_frequency);
}
/* wait for synth idle - MT only*/
diff --git a/lib/rbcodec/codecs/mpc.c b/lib/rbcodec/codecs/mpc.c
index a856f6f3d1..44c286ba0a 100644
--- a/lib/rbcodec/codecs/mpc.c
+++ b/lib/rbcodec/codecs/mpc.c
@@ -140,7 +140,7 @@ enum codec_status codec_run(void)
samplesdone = 0;
}
- elapsed_time = (samplesdone*10)/frequency;
+ elapsed_time = (samplesdone*10LL)/frequency;
}
ci->set_elapsed(elapsed_time);
@@ -162,7 +162,7 @@ enum codec_status codec_run(void)
samplesdone = new_offset;
}
- elapsed_time = (samplesdone*10)/frequency;
+ elapsed_time = (samplesdone*10LL)/frequency;
ci->set_elapsed(elapsed_time);
ci->seek_complete();
}
@@ -182,7 +182,7 @@ enum codec_status codec_run(void)
frame.buffer + MPC_FRAME_LENGTH,
frame.samples);
samplesdone += frame.samples;
- elapsed_time = (samplesdone*10)/frequency;
+ elapsed_time = (samplesdone*10LL)/frequency;
ci->set_elapsed(elapsed_time);
/* Remark: rockbox offset is the file offset in bytes. So estimate
* this offset from the samples, sampling frequency and bitrate */
diff --git a/lib/rbcodec/codecs/shorten.c b/lib/rbcodec/codecs/shorten.c
index f171b69a64..e8d845c18b 100644
--- a/lib/rbcodec/codecs/shorten.c
+++ b/lib/rbcodec/codecs/shorten.c
@@ -145,7 +145,7 @@ seek_start:
/* Update the elapsed-time indicator */
samplesdone += nsamples;
- elapsedtime = (samplesdone*10) / (sc.sample_rate/100);
+ elapsedtime = samplesdone*1000LL/sc.sample_rate;
ci->set_elapsed(elapsedtime);
}
diff --git a/lib/rbcodec/codecs/speex.c b/lib/rbcodec/codecs/speex.c
index e1be971096..659694fa2a 100644
--- a/lib/rbcodec/codecs/speex.c
+++ b/lib/rbcodec/codecs/speex.c
@@ -570,7 +570,7 @@ next_page:
ci->set_offset((long) ci->curpos);
ci->set_elapsed((samplerate == 0) ? 0 :
- cur_granule * 1000 / samplerate);
+ cur_granule * 1000LL / samplerate);
}
}
}