Revision d8470737

View differences:

libavformat/asf.c
145 145
    int size, i;
146 146
    int64_t gsize;
147 147
    AVRational dar[128];
148
    uint32_t bitrate[128];
148 149

  
149 150
    memset(dar, 0, sizeof(dar));
151
    memset(bitrate, 0, sizeof(bitrate));
150 152

  
151 153
    get_guid(pb, &g);
152 154
    if (memcmp(&g, &asf_header, sizeof(GUID)))
......
421 423
            }
422 424
        } else if (!memcmp(&g, &ext_stream_header, sizeof(GUID))) {
423 425
            int ext_len, payload_ext_ct, stream_ct;
424
            uint32_t ext_d;
426
            uint32_t ext_d, leak_rate, stream_num;
425 427
            int64_t pos_ex_st;
426 428
            pos_ex_st = url_ftell(pb);
427 429

  
428 430
            get_le64(pb); // starttime
429 431
            get_le64(pb); // endtime
430
            get_le32(pb); // leak-datarate
432
            leak_rate = get_le32(pb); // leak-datarate
431 433
            get_le32(pb); // bucket-datasize
432 434
            get_le32(pb); // init-bucket-fullness
433 435
            get_le32(pb); // alt-leak-datarate
......
435 437
            get_le32(pb); // alt-init-bucket-fullness
436 438
            get_le32(pb); // max-object-size
437 439
            get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
438
            get_le16(pb); // stream-num
440
            stream_num = get_le16(pb); // stream-num
439 441
            get_le16(pb); // stream-language-id-index
440 442
            get_le64(pb); // avg frametime in 100ns units
441 443
            stream_ct = get_le16(pb); //stream-name-count
442 444
            payload_ext_ct = get_le16(pb); //payload-extension-system-count
443 445

  
446
            if (stream_num < 128)
447
                bitrate[stream_num] = leak_rate;
448

  
444 449
            for (i=0; i<stream_ct; i++){
445 450
                get_le16(pb);
446 451
                ext_len = get_le16(pb);
......
504 509

  
505 510
    for(i=0; i<128; i++){
506 511
        int stream_num= asf->asfid2avid[i];
507
        if(stream_num>=0 && dar[i].num>0 && dar[i].den>0){
512
        if(stream_num>=0){
508 513
            AVCodecContext *codec= s->streams[stream_num]->codec;
514
            if (!codec->bit_rate)
515
                codec->bit_rate = bitrate[i];
516
            if (dar[i].num > 0 && dar[i].den > 0)
509 517
            av_reduce(&codec->sample_aspect_ratio.num,
510 518
                    &codec->sample_aspect_ratio.den,
511 519
                    dar[i].num, dar[i].den, INT_MAX);

Also available in: Unified diff