Revision 21b37529 libavformat/rmdec.c

View differences:

libavformat/rmdec.c
691 691
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
692 692
{
693 693
    RMDemuxContext *rm = s->priv_data;
694
    ByteIOContext *pb = s->pb;
695 694
    AVStream *st;
696
    int i, len;
695
    int i, len, seq = 1;
697 696
    int64_t timestamp, pos;
698 697
    int flags;
699 698

  
......
702 701
        st = s->streams[rm->audio_stream_num];
703 702
        ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
704 703
    } else if (rm->old_format) {
705
        RMStream *ast;
706

  
707
        st = s->streams[0];
708
        ast = st->priv_data;
709
        if (st->codec->codec_id == CODEC_ID_RA_288) {
710
            int x, y;
711

  
712
            for (y = 0; y < ast->sub_packet_h; y++)
713
                for (x = 0; x < ast->sub_packet_h/2; x++)
714
                    if (get_buffer(pb, ast->pkt.data+x*2*ast->audio_framesize+y*ast->coded_framesize, ast->coded_framesize) <= 0)
715
                        return AVERROR(EIO);
716
            rm->audio_stream_num = 0;
717
            rm->audio_pkt_cnt = ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - 1;
718
            // Release first audio packet
719
            av_new_packet(pkt, st->codec->block_align);
720
            memcpy(pkt->data, ast->pkt.data, st->codec->block_align); //FIXME avoid this
721
            pkt->flags |= PKT_FLAG_KEY; // Mark first packet as keyframe
722
            pkt->stream_index = 0;
723
        } else {
724
            /* just read raw bytes */
725
            len = RAW_PACKET_SIZE;
726
            len= av_get_packet(pb, pkt, len);
727
            pkt->stream_index = 0;
728
            if (len <= 0) {
729
                return AVERROR(EIO);
730
            }
731
            pkt->size = len;
704
        RMStream *ast = s->streams[0]->priv_data;
705
        int res, y, h = ast->audio_framesize ? ast->sub_packet_h : 1;
706

  
707
        timestamp = AV_NOPTS_VALUE;
708
        len = ast->audio_framesize ? ast->coded_framesize * h / 2 : RAW_PACKET_SIZE;
709
        for (y = 0; y < h; y++) {
710
            flags = !y ? 2 : 0;
711
            res = ff_rm_parse_packet(s, s->pb, s->streams[0], ast, len, pkt,
712
                                     &seq, &flags, &timestamp);
732 713
        }
733
        rm_ac3_swap_bytes(st, pkt);
714
        if (res < 0)
715
            return res;
734 716
    } else {
735
        int seq=1;
736 717
resync:
737 718
        len=sync(s, &timestamp, &flags, &i, &pos);
738 719
        if(len<0)

Also available in: Unified diff