Commit 5f8eeaae authored by aurel's avatar aurel

matroskadec: simplify check for hierarchy level

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14594 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent d715e985
...@@ -456,29 +456,21 @@ static EbmlSyntax matroska_clusters[] = { ...@@ -456,29 +456,21 @@ static EbmlSyntax matroska_clusters[] = {
}; };
/* /*
* Return: the amount of levels in the hierarchy that the * Return: whether we reached the end of a level in the hierarchy or not
* current element lies higher than the previous one.
* The opposite isn't done - that's auto-done using master
* element reading.
*/ */
static int ebml_read_element_level_up(MatroskaDemuxContext *matroska) static int ebml_level_end(MatroskaDemuxContext *matroska)
{ {
ByteIOContext *pb = matroska->ctx->pb; ByteIOContext *pb = matroska->ctx->pb;
offset_t pos = url_ftell(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]; MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1];
if (pos - level->start >= level->length) {
if (pos >= level->start + level->length) {
matroska->num_levels--; matroska->num_levels--;
num++; return 1;
} else {
break;
} }
} }
return 0;
return num;
} }
/* /*
...@@ -933,17 +925,10 @@ static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, ...@@ -933,17 +925,10 @@ static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
break; break;
} }
while (!res) { while (!res && !ebml_level_end(matroska)) {
res2 = ebml_read_element_id(matroska, &id); res2 = ebml_read_element_id(matroska, &id);
if (res2 < 0) if (res2 < 0)
break; 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); res = ebml_parse_id(matroska, syntax, id, data);
if (once) if (once)
break; break;
......
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