Revision 8862fb41

View differences:

libavformat/mp3.c
426 426
}
427 427

  
428 428
/**
429
 * Try to extract a xing tag from the stream and if found, decode it
429
 * Try to find Xing/Info/VBRI tags and compute duration from info therein
430 430
 */
431
static void mp3_parse_xing(AVFormatContext *s, AVStream *st)
431
static void mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, offset_t base)
432 432
{
433 433
    uint32_t v, spf;
434 434
    int frames = -1; /* Total number of frames in file */
......
448 448
            frames = get_be32(&s->pb);
449 449
    }
450 450

  
451
    /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
452
    url_fseek(&s->pb, base + 4 + 32, SEEK_SET);
453
    v = get_be32(&s->pb);
454
    if(v == MKBETAG('V', 'B', 'R', 'I')) {
455
        /* Check tag version */
456
        if(get_be16(&s->pb) == 1) {
457
            /* skip delay, quality and total bytes */
458
            url_fseek(&s->pb, 8, SEEK_CUR);
459
            frames = get_be32(&s->pb);
460
        }
461
    }
462

  
451 463
    if(frames < 0)
452 464
        return;
453 465

  
......
503 515
    }
504 516

  
505 517
    off = url_ftell(&s->pb);
506
    mp3_parse_xing(s, st);
518
    mp3_parse_vbr_tags(s, st, off);
507 519
    url_fseek(&s->pb, off, SEEK_SET);
508 520

  
509 521
    /* the parameters will be extracted from the compressed bitstream */

Also available in: Unified diff