Revision 6a63ff19

View differences:

libavformat/mov.c
244 244

  
245 245
static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
246 246
{
247
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
248
    MOVStreamContext *sc = st->priv_data;
247
    AVStream *st;
248
    MOVStreamContext *sc;
249 249
    int entries, i, j;
250 250

  
251
    if (c->fc->nb_streams < 1)
252
        return 0;
253
    st = c->fc->streams[c->fc->nb_streams-1];
254
    sc = st->priv_data;
255

  
251 256
    get_be32(pb); // version + flags
252 257
    entries = get_be32(pb);
253 258
    if (entries >= UINT_MAX / sizeof(*sc->drefs))
......
390 395

  
391 396
static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
392 397
{
393
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
398
    AVStream *st;
394 399
    int tag, len;
395 400

  
401
    if (c->fc->nb_streams < 1)
402
        return 0;
403
    st = c->fc->streams[c->fc->nb_streams-1];
404

  
396 405
    get_be32(pb); /* version + flags */
397 406
    len = mp4_read_descr(c, pb, &tag);
398 407
    if (tag == MP4ESDescrTag) {
......
449 458
{
450 459
    const int num = get_be32(pb);
451 460
    const int den = get_be32(pb);
452
    AVStream * const st = c->fc->streams[c->fc->nb_streams-1];
461
    AVStream *st;
462

  
463
    if (c->fc->nb_streams < 1)
464
        return 0;
465
    st = c->fc->streams[c->fc->nb_streams-1];
466

  
453 467
    if (den != 0) {
454 468
        if ((st->sample_aspect_ratio.den != 1 || st->sample_aspect_ratio.num) && // default
455 469
            (den != st->sample_aspect_ratio.den || num != st->sample_aspect_ratio.num))
......
503 517

  
504 518
static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
505 519
{
506
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
507
    MOVStreamContext *sc = st->priv_data;
508
    int version = get_byte(pb);
520
    AVStream *st;
521
    MOVStreamContext *sc;
522
    int version;
509 523
    char language[4] = {0};
510 524
    unsigned lang;
511 525

  
526
    if (c->fc->nb_streams < 1)
527
        return 0;
528
    st = c->fc->streams[c->fc->nb_streams-1];
529
    sc = st->priv_data;
530

  
531
    version = get_byte(pb);
512 532
    if (version > 1)
513 533
        return -1; /* unsupported */
514 534

  
......
570 590

  
571 591
static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
572 592
{
573
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
593
    AVStream *st;
594

  
595
    if (c->fc->nb_streams < 1)
596
        return 0;
597
    st = c->fc->streams[c->fc->nb_streams-1];
574 598

  
575 599
    if((uint64_t)atom.size > (1<<30))
576 600
        return -1;
......
590 614

  
591 615
static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
592 616
{
593
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
594
    int little_endian = get_be16(pb);
617
    AVStream *st;
618
    int little_endian;
619

  
620
    if (c->fc->nb_streams < 1)
621
        return 0;
622
    st = c->fc->streams[c->fc->nb_streams-1];
595 623

  
624
    little_endian = get_be16(pb);
596 625
    dprintf(c->fc, "enda %d\n", little_endian);
597 626
    if (little_endian == 1) {
598 627
        switch (st->codec->codec_id) {
......
642 671

  
643 672
static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
644 673
{
645
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
674
    AVStream *st;
675

  
676
    if (c->fc->nb_streams < 1)
677
        return 0;
678
    st = c->fc->streams[c->fc->nb_streams-1];
646 679

  
647 680
    if((uint64_t)atom.size > (1<<30))
648 681
        return -1;
......
669 702
 */
670 703
static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
671 704
{
672
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
705
    AVStream *st;
706

  
707
    if (c->fc->nb_streams < 1)
708
        return 0;
709
    st = c->fc->streams[c->fc->nb_streams-1];
673 710

  
674 711
    if((uint64_t)atom.size > (1<<30))
675 712
        return -1;
......
685 722

  
686 723
static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
687 724
{
688
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
689
    MOVStreamContext *sc = st->priv_data;
725
    AVStream *st;
726
    MOVStreamContext *sc;
690 727
    unsigned int i, entries;
691 728

  
729
    if (c->fc->nb_streams < 1)
730
        return 0;
731
    st = c->fc->streams[c->fc->nb_streams-1];
732
    sc = st->priv_data;
733

  
692 734
    get_byte(pb); /* version */
693 735
    get_be24(pb); /* flags */
694 736

  
......
751 793

  
752 794
static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
753 795
{
754
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
755
    MOVStreamContext *sc = st->priv_data;
796
    AVStream *st;
797
    MOVStreamContext *sc;
756 798
    int j, entries, pseudo_stream_id;
757 799

  
800
    if (c->fc->nb_streams < 1)
801
        return 0;
802
    st = c->fc->streams[c->fc->nb_streams-1];
803
    sc = st->priv_data;
804

  
758 805
    get_byte(pb); /* version */
759 806
    get_be24(pb); /* flags */
760 807

  
......
1078 1125

  
1079 1126
static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1080 1127
{
1081
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
1082
    MOVStreamContext *sc = st->priv_data;
1128
    AVStream *st;
1129
    MOVStreamContext *sc;
1083 1130
    unsigned int i, entries;
1084 1131

  
1132
    if (c->fc->nb_streams < 1)
1133
        return 0;
1134
    st = c->fc->streams[c->fc->nb_streams-1];
1135
    sc = st->priv_data;
1136

  
1085 1137
    get_byte(pb); /* version */
1086 1138
    get_be24(pb); /* flags */
1087 1139

  
......
1135 1187

  
1136 1188
static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1137 1189
{
1138
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
1139
    MOVStreamContext *sc = st->priv_data;
1190
    AVStream *st;
1191
    MOVStreamContext *sc;
1140 1192
    unsigned int i, entries;
1141 1193

  
1194
    if (c->fc->nb_streams < 1)
1195
        return 0;
1196
    st = c->fc->streams[c->fc->nb_streams-1];
1197
    sc = st->priv_data;
1198

  
1142 1199
    get_byte(pb); /* version */
1143 1200
    get_be24(pb); /* flags */
1144 1201

  
......
1162 1219

  
1163 1220
static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1164 1221
{
1165
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
1166
    MOVStreamContext *sc = st->priv_data;
1222
    AVStream *st;
1223
    MOVStreamContext *sc;
1167 1224
    unsigned int i, entries, sample_size, field_size, num_bytes;
1168 1225
    GetBitContext gb;
1169 1226
    unsigned char* buf;
1170 1227

  
1228
    if (c->fc->nb_streams < 1)
1229
        return 0;
1230
    st = c->fc->streams[c->fc->nb_streams-1];
1231
    sc = st->priv_data;
1232

  
1171 1233
    get_byte(pb); /* version */
1172 1234
    get_be24(pb); /* flags */
1173 1235

  
......
1225 1287

  
1226 1288
static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1227 1289
{
1228
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
1229
    MOVStreamContext *sc = st->priv_data;
1290
    AVStream *st;
1291
    MOVStreamContext *sc;
1230 1292
    unsigned int i, entries;
1231 1293
    int64_t duration=0;
1232 1294
    int64_t total_sample_count=0;
1233 1295

  
1296
    if (c->fc->nb_streams < 1)
1297
        return 0;
1298
    st = c->fc->streams[c->fc->nb_streams-1];
1299
    sc = st->priv_data;
1300

  
1234 1301
    get_byte(pb); /* version */
1235 1302
    get_be24(pb); /* flags */
1236 1303
    entries = get_be32(pb);
......
1290 1357

  
1291 1358
static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1292 1359
{
1293
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
1294
    MOVStreamContext *sc = st->priv_data;
1360
    AVStream *st;
1361
    MOVStreamContext *sc;
1295 1362
    unsigned int i, entries;
1296 1363

  
1364
    if (c->fc->nb_streams < 1)
1365
        return 0;
1366
    st = c->fc->streams[c->fc->nb_streams-1];
1367
    sc = st->priv_data;
1368

  
1297 1369
    get_byte(pb); /* version */
1298 1370
    get_be24(pb); /* flags */
1299 1371
    entries = get_be32(pb);
......
1547 1619
    int height;
1548 1620
    int64_t disp_transform[2];
1549 1621
    int display_matrix[3][2];
1550
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
1551
    MOVStreamContext *sc = st->priv_data;
1552
    int version = get_byte(pb);
1622
    AVStream *st;
1623
    MOVStreamContext *sc;
1624
    int version;
1625

  
1626
    if (c->fc->nb_streams < 1)
1627
        return 0;
1628
    st = c->fc->streams[c->fc->nb_streams-1];
1629
    sc = st->priv_data;
1553 1630

  
1631
    version = get_byte(pb);
1554 1632
    get_be24(pb); /* flags */
1555 1633
    /*
1556 1634
    MOV_TRACK_ENABLED 0x0001

Also available in: Unified diff