From 434d496a8a16e016950cd16bc759efb5cf856e32 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Tue, 5 Aug 2008 00:40:18 +0000 Subject: [PATCH] matroskadec: use generic parser to parse tags Originally committed as revision 14558 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/matroskadec.c | 41 ++++++--------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b3f8b6d77a..0c42b1fc0f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -250,6 +250,11 @@ static EbmlSyntax matroska_index[] = { { 0 } }; +static EbmlSyntax matroska_tags[] = { + { EBML_ID_VOID, EBML_NONE }, + { 0 } +}; + /* * The first few functions handle EBML file parsing. The rest * is the document interpretation. Matroska really just is a @@ -1758,37 +1763,7 @@ matroska_parse_index (MatroskaDemuxContext *matroska) static int matroska_parse_metadata (MatroskaDemuxContext *matroska) { - int res = 0; - uint32_t id; - - while (res == 0) { - if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { - res = AVERROR(EIO); - break; - } else if (matroska->level_up) { - matroska->level_up--; - break; - } - - switch (id) { - /* Hm, this is unsupported... */ - default: - av_log(matroska->ctx, AV_LOG_INFO, - "Unknown entry 0x%x in metadata header\n", id); - /* fall-through */ - - case EBML_ID_VOID: - res = ebml_read_skip(matroska); - break; - } - - if (matroska->level_up) { - matroska->level_up--; - break; - } - } - - return res; + return ebml_parse(matroska, matroska_tags, matroska, MATROSKA_ID_TAGS, 0); } static int @@ -1914,8 +1889,6 @@ matroska_parse_seekhead (MatroskaDemuxContext *matroska) } break; case MATROSKA_ID_TAGS: - if ((res = ebml_read_master(matroska, &id)) < 0) - goto finish; if (!(res = matroska_parse_metadata(matroska)) || url_feof(matroska->ctx->pb)) { matroska->metadata_parsed = 1; @@ -2355,8 +2328,6 @@ matroska_read_header (AVFormatContext *s, /* metadata */ case MATROSKA_ID_TAGS: { if (!matroska->metadata_parsed) { - if ((res = ebml_read_master(matroska, &id)) < 0) - break; res = matroska_parse_metadata(matroska); } else res = ebml_read_skip(matroska);