mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-03 05:10:03 +02:00
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>
This commit is contained in:
parent
2bdb6b6496
commit
c995e01b1e
@ -3310,13 +3310,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) {
|
for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) {
|
||||||
if (buf_size == (MAX_REORDER_DELAY + 1)) {
|
if (buf_size == (MAX_REORDER_DELAY + 1)) {
|
||||||
// If circular buffer is full, then move the first element forward.
|
// 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 {
|
} else {
|
||||||
++buf_size;
|
++buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Point j to the last elem of the buffer and insert the current pts there.
|
// 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;
|
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
|
// The timestamps that are already in the sorted buffer, and are greater than the
|
||||||
@ -3327,7 +3330,8 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st) {
|
|||||||
// go through, to keep this buffer in sorted order.
|
// go through, to keep this buffer in sorted order.
|
||||||
num_swaps = 0;
|
num_swaps = 0;
|
||||||
while (j != buf_start) {
|
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]) {
|
if (pts_buf[j] < pts_buf[r]) {
|
||||||
FFSWAP(int64_t, pts_buf[j], pts_buf[r]);
|
FFSWAP(int64_t, pts_buf[j], pts_buf[r]);
|
||||||
++num_swaps;
|
++num_swaps;
|
||||||
|
Loading…
Reference in New Issue
Block a user