Revision 01f4895c libavformat/rm.c

View differences:

libavformat/rm.c
298 298

  
299 299
    for(n=0;n<s->nb_streams;n++) {
300 300
        s->streams[n]->id = n;
301
        codec = &s->streams[n]->codec;
301
        codec = s->streams[n]->codec;
302 302
        stream = &rm->streams[n];
303 303
        memset(stream, 0, sizeof(StreamInfo));
304 304
        stream->num = n;
......
399 399

  
400 400
static int rm_write_packet(AVFormatContext *s, AVPacket *pkt)
401 401
{
402
    if (s->streams[pkt->stream_index]->codec.codec_type == 
402
    if (s->streams[pkt->stream_index]->codec->codec_type == 
403 403
        CODEC_TYPE_AUDIO)
404 404
        return rm_write_audio(s, pkt->data, pkt->size, pkt->flags);
405 405
    else
......
495 495
        get_str8(pb, s->comment, sizeof(s->comment));
496 496
        get_byte(pb);
497 497
        get_str8(pb, buf, sizeof(buf));
498
        st->codec.sample_rate = 8000;
499
        st->codec.channels = 1;
500
        st->codec.codec_type = CODEC_TYPE_AUDIO;
501
        st->codec.codec_id = CODEC_ID_RA_144;
498
        st->codec->sample_rate = 8000;
499
        st->codec->channels = 1;
500
        st->codec->codec_type = CODEC_TYPE_AUDIO;
501
        st->codec->codec_id = CODEC_ID_RA_144;
502 502
    } else {
503 503
        int flavor, sub_packet_h, coded_framesize;
504 504
        /* old version (4) */
......
512 512
        get_be32(pb); /* ??? */
513 513
        get_be32(pb); /* ??? */
514 514
        sub_packet_h= get_be16(pb); /* 1 */ 
515
        st->codec.block_align= get_be16(pb); /* frame size */
515
        st->codec->block_align= get_be16(pb); /* frame size */
516 516
        get_be16(pb); /* sub packet size */
517 517
        get_be16(pb); /* ??? */
518
        st->codec.sample_rate = get_be16(pb);
518
        st->codec->sample_rate = get_be16(pb);
519 519
        get_be32(pb);
520
        st->codec.channels = get_be16(pb);
520
        st->codec->channels = get_be16(pb);
521 521
        get_str8(pb, buf, sizeof(buf)); /* desc */
522 522
        get_str8(pb, buf, sizeof(buf)); /* desc */
523
        st->codec.codec_type = CODEC_TYPE_AUDIO;
523
        st->codec->codec_type = CODEC_TYPE_AUDIO;
524 524
        if (!strcmp(buf, "dnet")) {
525
            st->codec.codec_id = CODEC_ID_AC3;
525
            st->codec->codec_id = CODEC_ID_AC3;
526 526
        } else if (!strcmp(buf, "28_8")) {
527
            st->codec.codec_id = CODEC_ID_RA_288;
528
            st->codec.extradata_size= 10;
529
            st->codec.extradata= av_mallocz(st->codec.extradata_size);
527
            st->codec->codec_id = CODEC_ID_RA_288;
528
            st->codec->extradata_size= 10;
529
            st->codec->extradata= av_mallocz(st->codec->extradata_size);
530 530
            /* this is completly braindead and broken, the idiot who added this codec and endianness
531 531
               specific reordering to mplayer and libavcodec/ra288.c should be drowned in a see of cola */
532 532
            //FIXME pass the unpermutated extradata
533
            ((uint16_t*)st->codec.extradata)[1]= sub_packet_h;
534
            ((uint16_t*)st->codec.extradata)[2]= flavor;
535
            ((uint16_t*)st->codec.extradata)[3]= coded_framesize;
533
            ((uint16_t*)st->codec->extradata)[1]= sub_packet_h;
534
            ((uint16_t*)st->codec->extradata)[2]= flavor;
535
            ((uint16_t*)st->codec->extradata)[3]= coded_framesize;
536 536
        } else {
537
            st->codec.codec_id = CODEC_ID_NONE;
538
            pstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name),
537
            st->codec->codec_id = CODEC_ID_NONE;
538
            pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name),
539 539
                    buf);
540 540
        }
541 541
        if (read_all) {
......
635 635
                goto fail;
636 636
            st->id = get_be16(pb);
637 637
            get_be32(pb); /* max bit rate */
638
            st->codec.bit_rate = get_be32(pb); /* bit rate */
638
            st->codec->bit_rate = get_be32(pb); /* bit rate */
639 639
            get_be32(pb); /* max packet size */
640 640
            get_be32(pb); /* avg packet size */
641 641
            start_time = get_be32(pb); /* start time */
......
647 647
            get_str8(pb, buf, sizeof(buf)); /* mimetype */
648 648
            codec_data_size = get_be32(pb);
649 649
            codec_pos = url_ftell(pb);
650
            st->codec.codec_type = CODEC_TYPE_DATA;
650
            st->codec->codec_type = CODEC_TYPE_DATA;
651 651
            av_set_pts_info(st, 64, 1, 1000);
652 652

  
653 653
            v = get_be32(pb);
......
658 658
                int fps, fps2;
659 659
                if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
660 660
                fail1:
661
                    av_log(&st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
661
                    av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
662 662
                    goto skip;
663 663
                }
664
                st->codec.codec_tag = get_le32(pb);
665
//                av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec.codec_tag, MKTAG('R', 'V', '2', '0'));
666
                if (   st->codec.codec_tag != MKTAG('R', 'V', '1', '0')
667
                    && st->codec.codec_tag != MKTAG('R', 'V', '2', '0')
668
                    && st->codec.codec_tag != MKTAG('R', 'V', '3', '0')
669
                    && st->codec.codec_tag != MKTAG('R', 'V', '4', '0'))
664
                st->codec->codec_tag = get_le32(pb);
665
//                av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
666
                if (   st->codec->codec_tag != MKTAG('R', 'V', '1', '0')
667
                    && st->codec->codec_tag != MKTAG('R', 'V', '2', '0')
668
                    && st->codec->codec_tag != MKTAG('R', 'V', '3', '0')
669
                    && st->codec->codec_tag != MKTAG('R', 'V', '4', '0'))
670 670
                    goto fail1;
671
                st->codec.width = get_be16(pb);
672
                st->codec.height = get_be16(pb);
673
                st->codec.time_base.num= 1;
671
                st->codec->width = get_be16(pb);
672
                st->codec->height = get_be16(pb);
673
                st->codec->time_base.num= 1;
674 674
                fps= get_be16(pb);
675
                st->codec.codec_type = CODEC_TYPE_VIDEO;
675
                st->codec->codec_type = CODEC_TYPE_VIDEO;
676 676
                get_be32(pb);
677 677
                fps2= get_be16(pb);
678 678
                get_be16(pb);
679 679
                
680
                st->codec.extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
681
                st->codec.extradata= av_malloc(st->codec.extradata_size);
682
                get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
680
                st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
681
                st->codec->extradata= av_malloc(st->codec->extradata_size);
682
                get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
683 683
                
684 684
//                av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
685
                st->codec.time_base.den = fps * st->codec.time_base.num;
685
                st->codec->time_base.den = fps * st->codec->time_base.num;
686 686
                /* modification of h263 codec version (!) */
687 687
#ifdef WORDS_BIGENDIAN
688
                h263_hack_version = ((uint32_t*)st->codec.extradata)[1];
688
                h263_hack_version = ((uint32_t*)st->codec->extradata)[1];
689 689
#else
690
                h263_hack_version = bswap_32(((uint32_t*)st->codec.extradata)[1]);
690
                h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]);
691 691
#endif
692
                st->codec.sub_id = h263_hack_version;
692
                st->codec->sub_id = h263_hack_version;
693 693
                switch((h263_hack_version>>28)){
694
                case 1: st->codec.codec_id = CODEC_ID_RV10; break;
695
                case 2: st->codec.codec_id = CODEC_ID_RV20; break;
696
                case 3: st->codec.codec_id = CODEC_ID_RV30; break;
697
                case 4: st->codec.codec_id = CODEC_ID_RV40; break;
694
                case 1: st->codec->codec_id = CODEC_ID_RV10; break;
695
                case 2: st->codec->codec_id = CODEC_ID_RV20; break;
696
                case 3: st->codec->codec_id = CODEC_ID_RV30; break;
697
                case 4: st->codec->codec_id = CODEC_ID_RV40; break;
698 698
                default: goto fail1;
699 699
                }
700 700
            }
......
827 827
            return AVERROR_IO;
828 828
        st = s->streams[i];
829 829

  
830
        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
830
        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
831 831
            int h, pic_num, len2, pos;
832 832

  
833 833
            h= get_byte(pb); len--;
......
862 862
        pkt->stream_index = i;
863 863

  
864 864
#if 0
865
        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
866
            if(st->codec.codec_id == CODEC_ID_RV20){
865
        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
866
            if(st->codec->codec_id == CODEC_ID_RV20){
867 867
                int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
868 868
                av_log(NULL, AV_LOG_DEBUG, "%d %Ld %d\n", timestamp, timestamp*512LL/25, seq);
869 869

  
......
882 882
    }
883 883

  
884 884
    /* for AC3, needs to swap bytes */
885
    if (st->codec.codec_id == CODEC_ID_AC3) {
885
    if (st->codec->codec_id == CODEC_ID_AC3) {
886 886
        ptr = pkt->data;
887 887
        for(j=0;j<len;j+=2) {
888 888
            tmp = ptr[0];
......
937 937
            return AV_NOPTS_VALUE;
938 938

  
939 939
        st = s->streams[stream_index2];
940
        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
940
        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
941 941
            h= get_byte(&s->pb); len--;
942 942
            if(!(h & 0x40)){
943 943
                seq = get_byte(&s->pb); len--;

Also available in: Unified diff