Browse Source

avformat/matroskadec: Don't reset cluster position

The new code does not rely on whether the cluster's position is set or
not to infer whether a cluster needs to be closed or not (instead, this
is done in ebml_parse), so there is no need to reset the cluster's
position at all any more. It will be automatically set to the correct
value when a cluster is entered.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
tags/n4.2
Andreas Rheinhardt James Almer 6 years ago
parent
commit
a9f051519e
1 changed files with 3 additions and 11 deletions
  1. +3
    -11
      libavformat/matroskadec.c

+ 3
- 11
libavformat/matroskadec.c View File

@@ -770,7 +770,6 @@ static int matroska_reset_status(MatroskaDemuxContext *matroska,


matroska->current_id = id; matroska->current_id = id;
matroska->num_levels = 1; matroska->num_levels = 1;
matroska->current_cluster.pos = 0;
matroska->resync_pos = avio_tell(matroska->ctx->pb); matroska->resync_pos = avio_tell(matroska->ctx->pb);
if (id) if (id)
matroska->resync_pos -= (av_log2(id) + 7) / 8; matroska->resync_pos -= (av_log2(id) + 7) / 8;
@@ -1750,8 +1749,8 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska,
} }
} }
} }
/* Seek back - notice that in all instances where this is used it is safe
* to set the level to 1 and unset the position of the current cluster. */
/* Seek back - notice that in all instances where this is used
* it is safe to set the level to 1. */
matroska_reset_status(matroska, saved_id, before_pos); matroska_reset_status(matroska, saved_id, before_pos);


return ret; return ret;
@@ -3606,7 +3605,6 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
} }


if (matroska->num_levels == 2) { if (matroska->num_levels == 2) {
int err = 0;
/* We are inside a cluster. */ /* We are inside a cluster. */
res = ebml_parse(matroska, matroska_cluster_parsing, cluster); res = ebml_parse(matroska, matroska_cluster_parsing, cluster);


@@ -3615,7 +3613,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
uint8_t* additional = block->additional.size > 0 ? uint8_t* additional = block->additional.size > 0 ?
block->additional.data : NULL; block->additional.data : NULL;


err = matroska_parse_block(matroska, block->bin.buf, block->bin.data,
res = matroska_parse_block(matroska, block->bin.buf, block->bin.data,
block->bin.size, block->bin.pos, block->bin.size, block->bin.pos,
cluster->timecode, block->duration, cluster->timecode, block->duration,
is_keyframe, additional, block->additional_id, is_keyframe, additional, block->additional_id,
@@ -3623,14 +3621,8 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
block->discard_padding); block->discard_padding);
} }


if (res == LEVEL_ENDED)
cluster->pos = 0;

ebml_free(matroska_blockgroup, block); ebml_free(matroska_blockgroup, block);
memset(block, 0, sizeof(*block)); memset(block, 0, sizeof(*block));

if (err < 0)
return err;
} else if (!matroska->num_levels) { } else if (!matroska->num_levels) {
matroska->done = 1; matroska->done = 1;
return AVERROR_EOF; return AVERROR_EOF;


Loading…
Cancel
Save