From c69e7914be63cca5b08713dcdacb1baf801b0d02 Mon Sep 17 00:00:00 2001 From: Roberto Togni Date: Sun, 25 Dec 2005 00:48:12 +0000 Subject: [PATCH] Support for 28_8 in old ar. files Originally committed as revision 4772 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/rm.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/libavformat/rm.c b/libavformat/rm.c index d771a3fd13..fc292e9806 100644 --- a/libavformat/rm.c +++ b/libavformat/rm.c @@ -846,17 +846,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) uint8_t *ptr; int flags; - if (rm->old_format) { - /* just read raw bytes */ - len = RAW_PACKET_SIZE; - len= av_get_packet(pb, pkt, len); - pkt->stream_index = 0; - if (len <= 0) { - return AVERROR_IO; - } - pkt->size = len; - st = s->streams[0]; - } else if (rm->audio_pkt_cnt) { + if (rm->audio_pkt_cnt) { // If there are queued audio packet return them first st = s->streams[rm->audio_stream_num]; av_new_packet(pkt, st->codec->block_align); @@ -866,6 +856,32 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) rm->audio_pkt_cnt--; pkt->flags = 0; pkt->stream_index = rm->audio_stream_num; + } else if (rm->old_format) { + st = s->streams[0]; + if (st->codec->codec_id == CODEC_ID_RA_288) { + int x, y; + + for (y = 0; y < rm->sub_packet_h; y++) + for (x = 0; x < rm->sub_packet_h/2; x++) + if (get_buffer(pb, rm->audiobuf+x*2*rm->audio_framesize+y*rm->coded_framesize, rm->coded_framesize) <= 0) + return AVERROR_IO; + rm->audio_stream_num = 0; + rm->audio_pkt_cnt = rm->sub_packet_h * rm->audio_framesize / st->codec->block_align - 1; + // Release first audio packet + av_new_packet(pkt, st->codec->block_align); + memcpy(pkt->data, rm->audiobuf, st->codec->block_align); + pkt->flags |= PKT_FLAG_KEY; // Mark first packet as keyframe + pkt->stream_index = 0; + } else { + /* just read raw bytes */ + len = RAW_PACKET_SIZE; + len= av_get_packet(pb, pkt, len); + pkt->stream_index = 0; + if (len <= 0) { + return AVERROR_IO; + } + pkt->size = len; + } } else { int seq=1; resync: