History

libavformat: Account for negative position differences in ff_configure_buffers_for_index

When scanning through the index, account for the fact that the compared samples may be located in an unexpected order in the file; this function is mainly interested in the absolute difference between file locations.

Martin Storsjö committed 3 years ago

Commit 33d06de1 parent 182663a1 file · +3 −1Browse files

Unified · Split

libavformat/seek.c+3−1
@@ -208,9 +208,11 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) · 207 unmodified lines
208208 for (; i2 < sti2->nb_index_entries; i2++) {
209209 const AVIndexEntry *const e2 = &sti2->index_entries[i2];
210210 int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);
211+ int64_t cur_delta;
211212 if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
212213 continue;
213− pos_delta = FFMAX(pos_delta, e1->pos - e2->pos);
214+ cur_delta = FFABS(e1->pos - e2->pos);
215+ pos_delta = FFMAX(pos_delta, cur_delta);
214216 break;
215217 }
216218 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t