diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2008-11-17 14:20:00 +0000 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2008-11-17 14:20:00 +0000 |
commit | fcc995a533ddf0d892348c76244bd667949a3223 (patch) | |
tree | cbfa83bcbe937ce30297e522ec047703badb69f5 /libavformat/rmdec.c | |
parent | 074bfa7de756e42523093bbf7ee5bb9772043d55 (diff) | |
download | ffmpeg-fcc995a533ddf0d892348c76244bd667949a3223.tar.gz |
Add ByteIOContext argument to public ff_rm_* functions so that we can
specify the data source as function argument instead of in s->pb before
calling the function. Discussed in ML thread "[PATCH] fix small memleak
in rdt.c".
Originally committed as revision 15849 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rmdec.c')
-rw-r--r-- | libavformat/rmdec.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 9db09e1ed9..d9c508f71d 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -47,11 +47,10 @@ static void get_str8(ByteIOContext *pb, char *buf, int buf_size) get_strl(pb, buf, buf_size, get_byte(pb)); } -static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, - int read_all) +static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb, + AVStream *st, int read_all) { RMContext *rm = s->priv_data; - ByteIOContext *pb = s->pb; char buf[256]; uint32_t version; int i; @@ -196,9 +195,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, } int -ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st, int codec_data_size) +ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb, + AVStream *st, int codec_data_size) { - ByteIOContext *pb = s->pb; unsigned int v; int size; int64_t codec_pos; @@ -208,7 +207,7 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st, int codec_data_size v = get_be32(pb); if (v == MKTAG(0xfd, 'a', 'r', '.')) { /* ra type header */ - if (rm_read_audio_stream_info(s, st, 0)) + if (rm_read_audio_stream_info(s, pb, st, 0)) return -1; } else { int fps, fps2; @@ -275,7 +274,7 @@ static int rm_read_header_old(AVFormatContext *s, AVFormatParameters *ap) st = av_new_stream(s, 0); if (!st) return -1; - return rm_read_audio_stream_info(s, st, 1); + return rm_read_audio_stream_info(s, s->pb, st, 1); } static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) @@ -357,7 +356,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) get_str8(pb, buf, sizeof(buf)); /* desc */ get_str8(pb, buf, sizeof(buf)); /* mimetype */ st->codec->codec_type = CODEC_TYPE_DATA; - if (ff_rm_read_mdpr_codecdata(s, st, get_be32(pb)) < 0) + if (ff_rm_read_mdpr_codecdata(s, s->pb, st, get_be32(pb)) < 0) return -1; break; case MKTAG('D', 'A', 'T', 'A'): @@ -452,9 +451,9 @@ skip: return -1; } -static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket *pkt, int len) +static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb, + RMContext *rm, AVPacket *pkt, int len) { - ByteIOContext *pb = s->pb; int hdr, seq, pic_num, len2, pos; int type; @@ -550,15 +549,15 @@ rm_ac3_swap_bytes (AVStream *st, AVPacket *pkt) } int -ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt, +ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb, + AVStream *st, int len, AVPacket *pkt, int *seq, int *flags, int64_t *timestamp) { - ByteIOContext *pb = s->pb; RMContext *rm = s->priv_data; if (st->codec->codec_type == CODEC_TYPE_VIDEO) { rm->current_stream= st->id; - if(rm_assemble_video_frame(s, rm, pkt, len) == 1) + if(rm_assemble_video_frame(s, pb, rm, pkt, len) == 1) return -1; //got partial frame } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) { if ((st->codec->codec_id == CODEC_ID_RA_288) || @@ -649,9 +648,9 @@ ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt, } void -ff_rm_retrieve_cache (AVFormatContext *s, AVStream *st, AVPacket *pkt) +ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb, + AVStream *st, AVPacket *pkt) { - ByteIOContext *pb = s->pb; RMContext *rm = s->priv_data; assert (rm->audio_pkt_cnt > 0); @@ -681,7 +680,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) if (rm->audio_pkt_cnt) { // If there are queued audio packet return them first st = s->streams[rm->audio_stream_num]; - ff_rm_retrieve_cache(s, st, pkt); + ff_rm_retrieve_cache(s, s->pb, st, pkt); } else if (rm->old_format) { st = s->streams[0]; if (st->codec->codec_id == CODEC_ID_RA_288) { @@ -717,7 +716,7 @@ resync: return AVERROR(EIO); st = s->streams[i]; - if (ff_rm_parse_packet (s, st, len, pkt, &seq, &flags, ×tamp) < 0) + if (ff_rm_parse_packet (s, s->pb, st, len, pkt, &seq, &flags, ×tamp) < 0) goto resync; if((flags&2) && (seq&0x7F) == 1) |