From 899681cd1dbf4cd7c3b86af23bca25e20a54f4d0 Mon Sep 17 00:00:00 2001 From: Björn Axelsson Date: Wed, 21 Nov 2007 07:41:00 +0000 Subject: Use dynamically allocated ByteIOContext in AVFormatContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit patch by: Björn Axelsson, bjorn d axelsson a intinor d se thread: [PATCH] Remove static ByteIOContexts, 06 nov 2007 Originally committed as revision 11071 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/movenc.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'libavformat/movenc.c') diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c8d32f3c67..8dd00cdd09 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -442,24 +442,27 @@ static uint8_t *avc_find_startcode( uint8_t *p, uint8_t *end ) return end + 3; } -static void avc_parse_nal_units(uint8_t **buf, int *size) +static int avc_parse_nal_units(uint8_t **buf, int *size) { - ByteIOContext pb; + ByteIOContext *pb; uint8_t *p = *buf; uint8_t *end = p + *size; uint8_t *nal_start, *nal_end; + int ret = url_open_dyn_buf(&pb); + if(ret < 0) + return ret; - url_open_dyn_buf(&pb); nal_start = avc_find_startcode(p, end); while (nal_start < end) { while(!*(nal_start++)); nal_end = avc_find_startcode(nal_start, end); - put_be32(&pb, nal_end - nal_start); - put_buffer(&pb, nal_start, nal_end - nal_start); + put_be32(pb, nal_end - nal_start); + put_buffer(pb, nal_start, nal_end - nal_start); nal_start = nal_end; } av_freep(buf); - *size = url_close_dyn_buf(&pb, buf); + *size = url_close_dyn_buf(pb, buf); + return 0; } static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) @@ -1508,11 +1511,11 @@ static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) static int mov_write_header(AVFormatContext *s) { - ByteIOContext *pb = &s->pb; + ByteIOContext *pb = s->pb; MOVContext *mov = s->priv_data; int i; - if (url_is_streamed(&s->pb)) { + if (url_is_streamed(s->pb)) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return -1; } @@ -1579,13 +1582,13 @@ static int mov_write_header(AVFormatContext *s) static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVContext *mov = s->priv_data; - ByteIOContext *pb = &s->pb; + ByteIOContext *pb = s->pb; MOVTrack *trk = &mov->tracks[pkt->stream_index]; AVCodecContext *enc = trk->enc; unsigned int samplesInChunk = 0; int size= pkt->size; - if (url_is_streamed(&s->pb)) return 0; /* Can't handle that */ + if (url_is_streamed(s->pb)) return 0; /* Can't handle that */ if (!size) return 0; /* Discard 0 sized packets */ if (enc->codec_id == CODEC_ID_AMR_NB) { @@ -1663,7 +1666,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) static int mov_write_trailer(AVFormatContext *s) { MOVContext *mov = s->priv_data; - ByteIOContext *pb = &s->pb; + ByteIOContext *pb = s->pb; int res = 0; int i; -- cgit v1.2.3