Revision 4dc9e183 libavformat/matroskadec.c

View differences:

libavformat/matroskadec.c
577 577
}
578 578

  
579 579
/*
580
 * Return: the ID of the next element, or 0 on error.
581
 * Level_up contains the amount of levels that this
582
 * next element lies higher than the previous one.
583
 */
584
static uint32_t
585
ebml_peek_id (MatroskaDemuxContext *matroska,
586
              int                  *level_up)
587
{
588
    uint32_t id;
589
    int res;
590

  
591
    res = ebml_read_element_id(matroska, &id);
592
    if (res < 0)
593
        return 0;
594

  
595
    if (res > 0 && level_up)
596
        *level_up = ebml_read_element_level_up(matroska);
597

  
598
    return id;
599
}
600

  
601
/*
602 580
 * Seek to a given offset.
603 581
 * 0 is success, -1 is failure.
604 582
 */
......
1045 1023
static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
1046 1024
                      void *data, uint32_t expected_id, int once)
1047 1025
{
1048
    int i, res = 0;
1026
    int i, res = 0, res2;
1049 1027
    uint32_t id = 0;
1050 1028

  
1051 1029
    for (i=0; syntax[i].id; i++)
......
1071 1049
    }
1072 1050

  
1073 1051
    while (!res) {
1074
        if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
1075
            res = AVERROR(EIO);
1052
        res2 = ebml_read_element_id(matroska, &id);
1053
        if (res2 < 0)
1076 1054
            break;
1077
        } else if (matroska->level_up) {
1055
        if (res2 > 0)
1056
            matroska->level_up = ebml_read_element_level_up(matroska);
1057
        if (matroska->level_up) {
1078 1058
            matroska->level_up--;
1079 1059
            break;
1080 1060
        }

Also available in: Unified diff