Revision d4d1b5fb libavformat/rmdec.c

View differences:

libavformat/rmdec.c
632 632
    return 0;
633 633
}
634 634

  
635
static void
636
ff_rm_retrieve_cache (AVFormatContext *s, AVStream *st, AVPacket *pkt)
637
{
638
    ByteIOContext *pb = &s->pb;
639
    RMContext *rm = s->priv_data;
640

  
641
    assert (rm->audio_pkt_cnt > 0);
642

  
643
    if (st->codec->codec_id == CODEC_ID_AAC)
644
        av_get_packet(pb, pkt, rm->sub_packet_lengths[rm->sub_packet_cnt - rm->audio_pkt_cnt]);
645
    else {
646
        av_new_packet(pkt, st->codec->block_align);
647
        memcpy(pkt->data, rm->audiobuf + st->codec->block_align *
648
               (rm->sub_packet_h * rm->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
649
               st->codec->block_align);
650
    }
651
    rm->audio_pkt_cnt--;
652
    pkt->flags = 0;
653
    pkt->stream_index = st->index;
654
}
655

  
635 656
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
636 657
{
637 658
    RMContext *rm = s->priv_data;
......
645 666
    if (rm->audio_pkt_cnt) {
646 667
        // If there are queued audio packet return them first
647 668
        st = s->streams[rm->audio_stream_num];
648
        if (st->codec->codec_id == CODEC_ID_AAC)
649
            av_get_packet(pb, pkt, rm->sub_packet_lengths[rm->sub_packet_cnt - rm->audio_pkt_cnt]);
650
        else {
651
        av_new_packet(pkt, st->codec->block_align);
652
        memcpy(pkt->data, rm->audiobuf + st->codec->block_align *
653
               (rm->sub_packet_h * rm->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
654
               st->codec->block_align);
655
        }
656
        rm->audio_pkt_cnt--;
657
        pkt->flags = 0;
658
        pkt->stream_index = st->index;
669
        ff_rm_retrieve_cache(s, st, pkt);
659 670
    } else if (rm->old_format) {
660 671
        st = s->streams[0];
661 672
        if (st->codec->codec_id == CODEC_ID_RA_288) {

Also available in: Unified diff