Skip to content

Commit 1fd9577

Browse files
committed
Improve get_next_track_with_minimum_timestamp()
Move tmp var into block
1 parent 78225ce commit 1fd9577

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

libavformat/imf_cpl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem,
313313
FFIMFCPL *cpl)
314314
{
315315
xmlNodePtr element = NULL;
316-
void *tmp;
317316
int ret = 0;
318317

319318
if (ret = fill_base_resource(marker_resource_elem, (FFIMFBaseResource *)marker_resource, cpl))
@@ -323,6 +322,8 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem,
323322
element = xmlFirstElementChild(marker_resource_elem);
324323
while (element) {
325324
if (xmlStrcmp(element->name, "Marker") == 0) {
325+
void *tmp;
326+
326327
tmp = av_realloc_array(marker_resource->markers,
327328
marker_resource->marker_count + 1,
328329
sizeof(FFIMFMarker));

libavformat/imfdec.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static IMFVirtualTrackPlaybackCtx *get_next_track_with_minimum_timestamp(AVForma
642642
IMFVirtualTrackPlaybackCtx *track;
643643

644644
AVRational minimum_timestamp = av_make_q(INT32_MAX, 1);
645-
for (uint32_t i = 0; i < c->track_count; ++i) {
645+
for (uint32_t i = c->track_count; i > 0; i--) {
646646
av_log(
647647
s,
648648
AV_LOG_DEBUG,
@@ -651,11 +651,12 @@ static IMFVirtualTrackPlaybackCtx *get_next_track_with_minimum_timestamp(AVForma
651651
" (over duration: " AVRATIONAL_FORMAT
652652
")\n",
653653
i,
654-
AVRATIONAL_ARG(c->tracks[i]->current_timestamp),
654+
AVRATIONAL_ARG(c->tracks[i - 1]->current_timestamp),
655655
AVRATIONAL_ARG(minimum_timestamp),
656-
AVRATIONAL_ARG(c->tracks[i]->duration));
657-
if (av_cmp_q(c->tracks[i]->current_timestamp, minimum_timestamp) < 0) {
658-
track = c->tracks[i];
656+
AVRATIONAL_ARG(c->tracks[i - 1]->duration));
657+
658+
if (av_cmp_q(c->tracks[i - 1]->current_timestamp, minimum_timestamp) <= 0) {
659+
track = c->tracks[i - 1];
659660
minimum_timestamp = track->current_timestamp;
660661
}
661662
}

0 commit comments

Comments
 (0)