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
This commit is contained in:
Björn Axelsson
2007-11-21 07:41:00 +00:00
committed by Andreas Öman
parent 79815f622d
commit 899681cd1d
89 changed files with 873 additions and 824 deletions

View File

@@ -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;