aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-07-11 02:17:55 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-07-16 19:02:12 +0200
commit48479937c3e92cf0056ab99e215e29e29b61f929 (patch)
treefc4c0d986d45d7e294f8cfb37bc2d73570cb7951
parentfd53179f4a71e0acd807bdfff112a55e204fa4ba (diff)
downloadffmpeg-48479937c3e92cf0056ab99e215e29e29b61f929.tar.gz
avformat/mov: remove modulo operations from mov_estimate_video_delay()
0.324 <-0.491 sec Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Reviewed-by: Sasi Inguva <isasi@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit c995e01b1e01ac11cf2545b3ce86569a482ff434) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/mov.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index a44a90ca71..1df6b3781f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3308,13 +3308,16 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st) {
for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) {
if (buf_size == (MAX_REORDER_DELAY + 1)) {
// If circular buffer is full, then move the first element forward.
- buf_start = (buf_start + 1) % buf_size;
+ buf_start = (buf_start + 1);
+ if (buf_start == MAX_REORDER_DELAY + 1)
+ buf_start = 0;
} else {
++buf_size;
}
// Point j to the last elem of the buffer and insert the current pts there.
- j = (buf_start + buf_size - 1) % buf_size;
+ j = buf_start - 1;
+ if (j < 0) j = buf_size - 1;
pts_buf[j] = st->index_entries[ind].timestamp + msc->ctts_data[ctts_ind].duration;
// The timestamps that are already in the sorted buffer, and are greater than the
@@ -3325,7 +3328,8 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st) {
// go through, to keep this buffer in sorted order.
num_swaps = 0;
while (j != buf_start) {
- r = (j - 1 + buf_size) % buf_size;
+ r = j - 1;
+ if (r < 0) r = buf_size - 1;
if (pts_buf[j] < pts_buf[r]) {
FFSWAP(int64_t, pts_buf[j], pts_buf[r]);
++num_swaps;