Commit 730ac1ae authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by James Almer

avformat/matroskadec: Use file offsets for level 1 elements

This commit converts the MatroskaLevel1Element struct to use file-based
offsets, as opposed to the current practice of using offsets relative to
the beginning of the segment in it. This also includes a change from
uint64_t to int64_t.

This is in preparation to another patch that improves the check for
duplicate level 1 elements.
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent 6854127a
...@@ -330,7 +330,7 @@ typedef struct MatroskaCluster { ...@@ -330,7 +330,7 @@ typedef struct MatroskaCluster {
} MatroskaCluster; } MatroskaCluster;
typedef struct MatroskaLevel1Element { typedef struct MatroskaLevel1Element {
uint64_t pos; int64_t pos;
uint32_t id; uint32_t id;
int parsed; int parsed;
} MatroskaLevel1Element; } MatroskaLevel1Element;
...@@ -1795,16 +1795,14 @@ static void matroska_convert_tags(AVFormatContext *s) ...@@ -1795,16 +1795,14 @@ static void matroska_convert_tags(AVFormatContext *s)
} }
static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska,
uint64_t pos) int64_t pos)
{ {
uint32_t saved_id = matroska->current_id; uint32_t saved_id = matroska->current_id;
int64_t before_pos = avio_tell(matroska->ctx->pb); int64_t before_pos = avio_tell(matroska->ctx->pb);
int64_t offset;
int ret = 0; int ret = 0;
/* seek */ /* seek */
offset = pos + matroska->segment_start; if (avio_seek(matroska->ctx->pb, pos, SEEK_SET) == pos) {
if (avio_seek(matroska->ctx->pb, offset, SEEK_SET) == offset) {
/* We don't want to lose our seekhead level, so we add /* We don't want to lose our seekhead level, so we add
* a dummy. This is a crude hack. */ * a dummy. This is a crude hack. */
if (matroska->num_levels == EBML_MAX_DEPTH) { if (matroska->num_levels == EBML_MAX_DEPTH) {
...@@ -1842,8 +1840,8 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) ...@@ -1842,8 +1840,8 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
for (i = 0; i < seekhead_list->nb_elem; i++) { for (i = 0; i < seekhead_list->nb_elem; i++) {
MatroskaSeekhead *seekheads = seekhead_list->elem; MatroskaSeekhead *seekheads = seekhead_list->elem;
uint32_t id = seekheads[i].id; uint32_t id = seekheads[i].id;
uint64_t pos = seekheads[i].pos; int64_t pos = seekheads[i].pos + matroska->segment_start;
MatroskaLevel1Element *elem = matroska_find_level1_elem(matroska, id); MatroskaLevel1Element *elem = matroska_find_level1_elem(matroska, id);
if (!elem || elem->parsed) if (!elem || elem->parsed)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment