[FFmpeg-devel] [PATCH] Make RM demuxer behave better with -an option
Ronald S. Bultje
rsbultje
Sun Mar 8 15:44:27 CET 2009
Hi,
On Mon, Mar 2, 2009 at 8:35 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> On Mon, Mar 2, 2009 at 2:02 AM, Kostya <kostya.shishkov at gmail.com> wrote:
>> The only obvious simplification I see for now is merging old and new format
>> demuxing - the only difference is that old format does not contain packet
>> headers and audio only (exactly like .wav and .avi).
>
> that's funny, I just noticed that yesterday and was planning some
> testing today to see if it's really that simple as replacing that
> whole block by a single ff_rm_parse_packet(s, s->priv_data,
> s->streams[0], s->streams[0]->priv_data, pkt);. That be the most
> beautiful simplification of all.
Attached patch does it, tested with "old_format" .ra files and works
same as before. It's a few more lines of code than I would've liked,
but still a good simplification and removal of duplicate code.
Ronald
-------------- next part --------------
Index: ffmpeg-svn/libavformat/rmdec.c
===================================================================
--- ffmpeg-svn.orig/libavformat/rmdec.c 2009-03-02 08:58:41.000000000 -0500
+++ ffmpeg-svn/libavformat/rmdec.c 2009-03-03 08:22:09.000000000 -0500
@@ -693,7 +693,7 @@
RMDemuxContext *rm = s->priv_data;
ByteIOContext *pb = s->pb;
AVStream *st;
- int i, len;
+ int i, len, seq = 1;
int64_t timestamp, pos;
int flags;
@@ -702,37 +702,19 @@
st = s->streams[rm->audio_stream_num];
ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
} else if (rm->old_format) {
- RMStream *ast;
+ RMStream *ast = s->streams[0]->priv_data;
+ int res, y, h = ast->audio_framesize ? ast->sub_packet_h : 1;
- st = s->streams[0];
- ast = st->priv_data;
- if (st->codec->codec_id == CODEC_ID_RA_288) {
- int x, y;
-
- for (y = 0; y < ast->sub_packet_h; y++)
- for (x = 0; x < ast->sub_packet_h/2; x++)
- if (get_buffer(pb, ast->pkt.data+x*2*ast->audio_framesize+y*ast->coded_framesize, ast->coded_framesize) <= 0)
- return AVERROR(EIO);
- rm->audio_stream_num = 0;
- rm->audio_pkt_cnt = ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - 1;
- // Release first audio packet
- av_new_packet(pkt, st->codec->block_align);
- memcpy(pkt->data, ast->pkt.data, st->codec->block_align); //FIXME avoid this
- 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(EIO);
- }
- pkt->size = len;
+ timestamp = AV_NOPTS_VALUE;
+ len = ast->audio_framesize ? ast->coded_framesize * h / 2 : RAW_PACKET_SIZE;
+ for (y = 0; y < h; y++) {
+ flags = !y ? 2 : 0;
+ res = ff_rm_parse_packet(s, s->pb, s->streams[0], ast, len, pkt,
+ &seq, &flags, ×tamp);
}
- rm_ac3_swap_bytes(st, pkt);
+ if (res < 0)
+ return res;
} else {
- int seq=1;
resync:
len=sync(s, ×tamp, &flags, &i, &pos);
if(len<0)
More information about the ffmpeg-devel
mailing list