Revision 7eb9b068

View differences:

libavformat/matroskadec.c
461 461
 * The opposite isn't done - that's auto-done using master
462 462
 * element reading.
463 463
 */
464

  
465 464
static int
466 465
ebml_read_element_level_up (MatroskaDemuxContext *matroska)
467 466
{
......
491 490
 * number.
492 491
 * Returns: num. of bytes read. < 0 on error.
493 492
 */
494

  
495 493
static int
496 494
ebml_read_num (MatroskaDemuxContext *matroska,
497 495
               int                   max_size,
......
542 540
 * Read: the element content data ID.
543 541
 * Return: the number of bytes read or < 0 on error.
544 542
 */
545

  
546 543
static int
547 544
ebml_read_element_id (MatroskaDemuxContext *matroska,
548 545
                      uint32_t             *id,
......
575 572
 * Read: element content length.
576 573
 * Return: the number of bytes read or < 0 on error.
577 574
 */
578

  
579 575
static int
580 576
ebml_read_element_length (MatroskaDemuxContext *matroska,
581 577
                          uint64_t             *length)
......
592 588
 * Level_up contains the amount of levels that this
593 589
 * next element lies higher than the previous one.
594 590
 */
595

  
596 591
static uint32_t
597 592
ebml_peek_id (MatroskaDemuxContext *matroska,
598 593
              int                  *level_up)
......
609 604
 * Seek to a given offset.
610 605
 * 0 is success, -1 is failure.
611 606
 */
612

  
613 607
static int
614 608
ebml_read_seek (MatroskaDemuxContext *matroska,
615 609
                offset_t              offset)
......
626 620
 * Skip the next element.
627 621
 * 0 is success, -1 is failure.
628 622
 */
629

  
630 623
static int
631 624
ebml_read_skip (MatroskaDemuxContext *matroska)
632 625
{
......
648 641
 * Read the next element as an unsigned int.
649 642
 * 0 is success, < 0 is failure.
650 643
 */
651

  
652 644
static int
653 645
ebml_read_uint (MatroskaDemuxContext *matroska,
654 646
                uint32_t             *id,
......
682 674
 * Read the next element as a float.
683 675
 * 0 is success, < 0 is failure.
684 676
 */
685

  
686 677
static int
687 678
ebml_read_float (MatroskaDemuxContext *matroska,
688 679
                 uint32_t             *id,
......
716 707
 * Read the next element as an ASCII string.
717 708
 * 0 is success, < 0 is failure.
718 709
 */
719

  
720 710
static int
721 711
ebml_read_ascii (MatroskaDemuxContext *matroska,
722 712
                 uint32_t             *id,
......
754 744
 * are supposed to be sub-elements which can be read separately.
755 745
 * 0 is success, < 0 is failure.
756 746
 */
757

  
758 747
static int
759 748
ebml_read_master (MatroskaDemuxContext *matroska,
760 749
                  uint32_t             *id)
......
785 774
 * Read the next element as binary data.
786 775
 * 0 is success, < 0 is failure.
787 776
 */
788

  
789 777
static int
790 778
ebml_read_binary (MatroskaDemuxContext *matroska,
791 779
                  uint32_t             *id,
......
822 810
 * Return: number of bytes processed, < 0 on error.
823 811
 * XXX: use ebml_read_num().
824 812
 */
825

  
826 813
static int
827 814
matroska_ebmlnum_uint (uint8_t  *data,
828 815
                       uint32_t  size,
......
864 851
/*
865 852
 * Same as above, but signed.
866 853
 */
867

  
868 854
static int
869 855
matroska_ebmlnum_sint (uint8_t  *data,
870 856
                       uint32_t  size,
......
907 893
 * Put one packet in an application-supplied AVPacket struct.
908 894
 * Returns 0 on success or -1 on failure.
909 895
 */
910

  
911 896
static int
912 897
matroska_deliver_packet (MatroskaDemuxContext *matroska,
913 898
                         AVPacket             *pkt)
......
935 920
 * Put a packet into our internal queue. Will be delivered to the
936 921
 * user/application during the next get_packet() call.
937 922
 */
938

  
939 923
static void
940 924
matroska_queue_packet (MatroskaDemuxContext *matroska,
941 925
                       AVPacket             *pkt)
......
969 953
/*
970 954
 * Autodetecting...
971 955
 */
972

  
973 956
static int
974 957
matroska_probe (AVProbeData *p)
975 958
{
......
1008 991
    return 0;
1009 992
}
1010 993

  
1011

  
1012 994
static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
1013 995
                      void *data, uint32_t expected_id, int once);
1014 996

  
......
1103 1085
        if (once)
1104 1086
            break;
1105 1087

  
1106

  
1107 1088
        if (matroska->level_up) {
1108 1089
            matroska->level_up--;
1109 1090
            break;
......
1425 1406
            (track->codec_priv.data != NULL)) {
1426 1407
            track->video.fourcc = AV_RL32(track->codec_priv.data + 16);
1427 1408
            codec_id = codec_get_id(codec_bmp_tags, track->video.fourcc);
1428

  
1429 1409
        }
1430

  
1431 1410
        else if (!strcmp(track->codec_id,
1432 1411
                         MATROSKA_CODEC_ID_AUDIO_ACM) &&
1433 1412
                 (track->codec_priv.size >= 18) &&
1434 1413
                 (track->codec_priv.data != NULL)) {
1435 1414
            uint16_t tag = AV_RL16(track->codec_priv.data);
1436 1415
            codec_id = codec_get_id(codec_wav_tags, tag);
1437

  
1438 1416
        }
1439 1417

  
1440 1418
        else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
......
1461 1439
            } else
1462 1440
                extradata_size = 2;
1463 1441
        }
1464

  
1465 1442
        else if (codec_id == CODEC_ID_TTA) {
1466 1443
            ByteIOContext b;
1467 1444
            extradata_size = 30;
......
1477 1454
            put_le32(&b, track->audio.out_samplerate);
1478 1455
            put_le32(&b, matroska->ctx->duration * track->audio.out_samplerate);
1479 1456
        }
1480

  
1481 1457
        else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
1482 1458
                 codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
1483 1459
            extradata_offset = 26;
1484 1460
            track->codec_priv.size -= extradata_offset;
1485 1461
        }
1486

  
1487 1462
        else if (codec_id == CODEC_ID_RA_144) {
1488 1463
            track->audio.out_samplerate = 8000;
1489 1464
            track->audio.channels = 1;
1490 1465
        }
1491

  
1492 1466
        else if (codec_id == CODEC_ID_RA_288 ||
1493 1467
                 codec_id == CODEC_ID_COOK ||
1494 1468
                 codec_id == CODEC_ID_ATRAC3) {
......
1562 1536
        } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
1563 1537
            st->codec->codec_type = CODEC_TYPE_SUBTITLE;
1564 1538
        }
1565

  
1566 1539
    }
1567 1540

  
1568 1541
    attachements = attachements_list->elem;
......
1856 1829
    MatroskaDemuxContext *matroska = s->priv_data;
1857 1830

  
1858 1831
    while (matroska_deliver_packet(matroska, pkt)) {
1859

  
1860 1832
        if (matroska->done)
1861 1833
            return AVERROR(EIO);
1862

  
1863 1834
        if (matroska_parse_cluster(matroska) < 0)
1864 1835
            matroska->done = 1;
1865 1836
    }

Also available in: Unified diff