Revision 592110c2

View differences:

libavformat/matroskadec.c
456 456
};
457 457

  
458 458
/*
459
 * Return: the amount of levels in the hierarchy that the
460
 * current element lies higher than the previous one.
461
 * The opposite isn't done - that's auto-done using master
462
 * element reading.
459
 * Return: whether we reached the end of a level in the hierarchy or not
463 460
 */
464
static int ebml_read_element_level_up(MatroskaDemuxContext *matroska)
461
static int ebml_level_end(MatroskaDemuxContext *matroska)
465 462
{
466 463
    ByteIOContext *pb = matroska->ctx->pb;
467 464
    offset_t pos = url_ftell(pb);
468
    int num = 0;
469 465

  
470
    while (matroska->num_levels > 0) {
466
    if (matroska->num_levels > 0) {
471 467
        MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1];
472

  
473
        if (pos >= level->start + level->length) {
468
        if (pos - level->start >= level->length) {
474 469
            matroska->num_levels--;
475
            num++;
476
        } else {
477
            break;
470
            return 1;
478 471
        }
479 472
    }
480

  
481
    return num;
473
    return 0;
482 474
}
483 475

  
484 476
/*
......
933 925
            break;
934 926
        }
935 927

  
936
    while (!res) {
928
    while (!res && !ebml_level_end(matroska)) {
937 929
        res2 = ebml_read_element_id(matroska, &id);
938 930
        if (res2 < 0)
939 931
            break;
940
        if (res2 > 0)
941
            matroska->level_up = ebml_read_element_level_up(matroska);
942
        if (matroska->level_up) {
943
            matroska->level_up--;
944
            break;
945
        }
946

  
947 932
        res = ebml_parse_id(matroska, syntax, id, data);
948 933
        if (once)
949 934
            break;

Also available in: Unified diff