Mercurial > libavformat.hg
comparison rmdec.c @ 2724:1f752c3afdc8 libavformat
Isolate caching of audio frames in its own function.
Patch by Ronald S. Bultje: rsbultje gmail com
Original thread: Re: [FFmpeg-devel] [PATCH 3/6] rmdec.c: ff_rm_retrieve_cache()
Date: 11/05/2007 09:25 PM
author | benoit |
---|---|
date | Thu, 08 Nov 2007 15:14:37 +0000 |
parents | 80fc8554cde6 |
children | 0fb209cef761 |
comparison
equal
deleted
inserted
replaced
2723:80fc8554cde6 | 2724:1f752c3afdc8 |
---|---|
630 pkt->flags |= PKT_FLAG_KEY; | 630 pkt->flags |= PKT_FLAG_KEY; |
631 | 631 |
632 return 0; | 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 static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) | 656 static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) |
636 { | 657 { |
637 RMContext *rm = s->priv_data; | 658 RMContext *rm = s->priv_data; |
638 ByteIOContext *pb = &s->pb; | 659 ByteIOContext *pb = &s->pb; |
639 AVStream *st; | 660 AVStream *st; |
643 int flags; | 664 int flags; |
644 | 665 |
645 if (rm->audio_pkt_cnt) { | 666 if (rm->audio_pkt_cnt) { |
646 // If there are queued audio packet return them first | 667 // If there are queued audio packet return them first |
647 st = s->streams[rm->audio_stream_num]; | 668 st = s->streams[rm->audio_stream_num]; |
648 if (st->codec->codec_id == CODEC_ID_AAC) | 669 ff_rm_retrieve_cache(s, st, pkt); |
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; | |
659 } else if (rm->old_format) { | 670 } else if (rm->old_format) { |
660 st = s->streams[0]; | 671 st = s->streams[0]; |
661 if (st->codec->codec_id == CODEC_ID_RA_288) { | 672 if (st->codec->codec_id == CODEC_ID_RA_288) { |
662 int x, y; | 673 int x, y; |
663 | 674 |