diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2008-08-05 00:42:08 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2008-08-05 00:42:08 +0000 |
commit | 592110c26c7ec76a6ab9c350b0ca1e861c33605c (patch) | |
tree | c51f44e38c74cd4054c5953406099ea2d0fb0ed8 /libavformat/matroskadec.c | |
parent | f7b9687cbbf2149b56aede2dfdea9895e605dea7 (diff) | |
download | ffmpeg-592110c26c7ec76a6ab9c350b0ca1e861c33605c.tar.gz |
matroskadec: simplify check for hierarchy level
Originally committed as revision 14594 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r-- | libavformat/matroskadec.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 6a7ab6526a..f62cc53f7f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -456,29 +456,21 @@ static EbmlSyntax matroska_clusters[] = { }; /* - * Return: the amount of levels in the hierarchy that the - * current element lies higher than the previous one. - * The opposite isn't done - that's auto-done using master - * element reading. + * Return: whether we reached the end of a level in the hierarchy or not */ -static int ebml_read_element_level_up(MatroskaDemuxContext *matroska) +static int ebml_level_end(MatroskaDemuxContext *matroska) { ByteIOContext *pb = matroska->ctx->pb; offset_t pos = url_ftell(pb); - int num = 0; - while (matroska->num_levels > 0) { + if (matroska->num_levels > 0) { MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1]; - - if (pos >= level->start + level->length) { + if (pos - level->start >= level->length) { matroska->num_levels--; - num++; - } else { - break; + return 1; } } - - return num; + return 0; } /* @@ -933,17 +925,10 @@ static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, break; } - while (!res) { + while (!res && !ebml_level_end(matroska)) { res2 = ebml_read_element_id(matroska, &id); if (res2 < 0) break; - if (res2 > 0) - matroska->level_up = ebml_read_element_level_up(matroska); - if (matroska->level_up) { - matroska->level_up--; - break; - } - res = ebml_parse_id(matroska, syntax, id, data); if (once) break; |