summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorBjörn Axelsson <gecko@acc.umu.se>2007-11-21 07:41:00 +0000
committerAndreas Öman <andreas@lonelycoder.com>2007-11-21 07:41:00 +0000
commit899681cd1dbf4cd7c3b86af23bca25e20a54f4d0 (patch)
tree6f4556497efab1d703d1289b170c936154c6bbd5 /libavformat/movenc.c
parent79815f622d90499f882ad968a1351134535cbbab (diff)
Use dynamically allocated ByteIOContext in AVFormatContext
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
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c25
1 files changed, 14 insertions, 11 deletions
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;