From df6b4497ba53851756d57337dccec8332fe1fd6b Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Tue, 16 Apr 2013 13:20:18 +1200 Subject: [PATCH] Bug 846122 - Handle split multi-track Cues in nestegg. r=padenot --- media/libnestegg/README_MOZILLA | 2 +- media/libnestegg/src/nestegg.c | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/media/libnestegg/README_MOZILLA b/media/libnestegg/README_MOZILLA index 49ac6a10434..d770e7f9787 100644 --- a/media/libnestegg/README_MOZILLA +++ b/media/libnestegg/README_MOZILLA @@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system. The nestegg git repository is: git://github.com/kinetiknz/nestegg.git -The git commit ID used was ebdbb688fb13dd315fc9d16e6897adb5ee42b7bb. +The git commit ID used was 443edc8d8cb1037275b055474256a7fa089766dc. diff --git a/media/libnestegg/src/nestegg.c b/media/libnestegg/src/nestegg.c index 59a1a4734c7..b2651f33557 100644 --- a/media/libnestegg/src/nestegg.c +++ b/media/libnestegg/src/nestegg.c @@ -1407,10 +1407,14 @@ ne_find_seek_for_id(struct ebml_list_node * seek_head, uint64_t id) } static struct cue_point * -ne_find_cue_point_for_tstamp(struct ebml_list_node * cue_point, uint64_t scale, uint64_t tstamp) +ne_find_cue_point_for_tstamp(nestegg * ctx, struct ebml_list_node * cue_point, unsigned int track, uint64_t scale, uint64_t tstamp) { uint64_t time; struct cue_point * c, * prev = NULL; + uint64_t track_number; + unsigned int t; + struct ebml_list_node * node; + struct cue_track_positions * pos; while (cue_point) { assert(cue_point->id == ID_CUE_POINT); @@ -1419,14 +1423,27 @@ ne_find_cue_point_for_tstamp(struct ebml_list_node * cue_point, uint64_t scale, if (!prev) prev = c; - if (ne_get_uint(c->time, &time) == 0 && time * scale > tstamp) - break; + node = prev->cue_track_positions.head; + while (node) { + assert(node->id == ID_CUE_TRACK_POSITIONS); + pos = node->data; + if (ne_get_uint(pos->track, &track_number) != 0) + return NULL; + + if (ne_map_track_number_to_index(ctx, track_number, &t) != 0) + return NULL; + + if (ne_get_uint(c->time, &time) == 0 && time * scale > tstamp && t == track) + return prev; + + node = node->next; + } prev = cue_point->data; cue_point = cue_point->next; } - return prev; + return NULL; } static int @@ -1850,7 +1867,7 @@ nestegg_track_seek(nestegg * ctx, unsigned int track, uint64_t tstamp) tc_scale = ne_get_timecode_scale(ctx); - cue_point = ne_find_cue_point_for_tstamp(ctx->segment.cues.cue_point.head, tc_scale, tstamp); + cue_point = ne_find_cue_point_for_tstamp(ctx, ctx->segment.cues.cue_point.head, track, tc_scale, tstamp); if (!cue_point) return -1;