Originally committed as revision 10963 to svn://svn.ffmpeg.org/ffmpeg/trunk
Ronald S. Bultje authored on 2007/11/09 00:14:37... | ... |
@@ -632,6 +632,27 @@ ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt, |
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,17 +666,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) |
645 | 645 |
if (rm->audio_pkt_cnt) { |
646 | 646 |
// If there are queued audio packet return them first |
647 | 647 |
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; |
|
648 |
+ ff_rm_retrieve_cache(s, st, pkt); |
|
659 | 649 |
} else if (rm->old_format) { |
660 | 650 |
st = s->streams[0]; |
661 | 651 |
if (st->codec->codec_id == CODEC_ID_RA_288) { |