[FFmpeg-cvslog] r23587 - trunk/libavformat/matroskadec.c

aurel subversion
Fri Jun 11 18:34:01 CEST 2010


Author: aurel
Date: Fri Jun 11 18:34:01 2010
New Revision: 23587

Log:
matroskadec: store the ID of the currently parsed ebml element
This allows to interrupt parsing after reading an ID, and then properly
recover parsing.

Modified:
   trunk/libavformat/matroskadec.c

Modified: trunk/libavformat/matroskadec.c
==============================================================================
--- trunk/libavformat/matroskadec.c	Fri Jun 11 18:27:30 2010	(r23586)
+++ trunk/libavformat/matroskadec.c	Fri Jun 11 18:34:01 2010	(r23587)
@@ -214,6 +214,7 @@ typedef struct {
     int num_levels;
     MatroskaLevel levels[EBML_MAX_DEPTH];
     int level_up;
+    uint32_t current_id;
 
     uint64_t time_scale;
     double   duration;
@@ -724,12 +725,14 @@ static int ebml_parse_id(MatroskaDemuxCo
 static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
                       void *data)
 {
+    if (!matroska->current_id) {
     uint64_t id;
     int res = ebml_read_num(matroska, matroska->ctx->pb, 4, &id);
     if (res < 0)
         return res;
-    id |= 1 << 7*res;
-    return ebml_parse_id(matroska, syntax, id, data);
+    matroska->current_id = id | 1 << 7*res;
+    }
+    return ebml_parse_id(matroska, syntax, matroska->current_id, data);
 }
 
 static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
@@ -774,9 +777,11 @@ static int ebml_parse_elem(MatroskaDemux
         list->nb_elem++;
     }
 
-    if (syntax->type != EBML_PASS && syntax->type != EBML_STOP)
+    if (syntax->type != EBML_PASS && syntax->type != EBML_STOP) {
+        matroska->current_id = 0;
         if ((res = ebml_read_num(matroska, pb, 8, &length)) < 0)
             return res;
+    }
 
     switch (syntax->type) {
     case EBML_UINT:  res = ebml_read_uint  (pb, length, data);  break;
@@ -1063,6 +1068,7 @@ static void matroska_execute_seekhead(Ma
     MatroskaSeekhead *seekhead = seekhead_list->elem;
     uint32_t level_up = matroska->level_up;
     int64_t before_pos = url_ftell(matroska->ctx->pb);
+    uint32_t saved_id = matroska->current_id;
     MatroskaLevel level;
     int i;
 
@@ -1096,6 +1102,7 @@ static void matroska_execute_seekhead(Ma
         level.length = (uint64_t)-1;
         matroska->levels[matroska->num_levels] = level;
         matroska->num_levels++;
+        matroska->current_id = 0;
 
         ebml_parse(matroska, matroska_segment, matroska);
 
@@ -1110,6 +1117,7 @@ static void matroska_execute_seekhead(Ma
     /* seek back */
     url_fseek(matroska->ctx->pb, before_pos, SEEK_SET);
     matroska->level_up = level_up;
+    matroska->current_id = saved_id;
 }
 
 static int matroska_aac_profile(char *codec_id)



More information about the ffmpeg-cvslog mailing list