diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2007-08-09 21:10:11 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2007-08-09 21:10:11 +0000 |
commit | 7e506494b104966c4a45072b70f0574363a2f155 (patch) | |
tree | 034cd696293047340427737ce36816e4e0586c6a /libavformat | |
parent | 7a26da44b0f24ca33be642dd9af8fdf7f89656c4 (diff) | |
download | ffmpeg-7e506494b104966c4a45072b70f0574363a2f155.tar.gz |
move header writing into its own function
Originally committed as revision 10034 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/nutenc.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 5f65eda8e4..510020ea1e 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -311,10 +311,28 @@ static int write_streamheader(NUTContext *nut, ByteIOContext *bc, AVCodecContext return 0; } +static void write_headers(NUTContext *nut, ByteIOContext *bc){ + ByteIOContext dyn_bc; + int i; + + put_be64(bc, MAIN_STARTCODE); + url_open_dyn_buf(&dyn_bc); + write_mainheader(nut, &dyn_bc); + put_packet(nut, bc, &dyn_bc, 1); + + for (i=0; i < nut->avf->nb_streams; i++){ + AVCodecContext *codec = nut->avf->streams[i]->codec; + + put_be64(bc, STREAM_STARTCODE); + url_open_dyn_buf(&dyn_bc); + write_streamheader(nut, &dyn_bc, codec, i); + put_packet(nut, bc, &dyn_bc, 1); + } +} + static int write_header(AVFormatContext *s){ NUTContext *nut = s->priv_data; - ByteIOContext *bc = &s->pb, dyn_bc; - AVCodecContext *codec; + ByteIOContext *bc = &s->pb; int i, j; nut->avf= s; @@ -353,20 +371,7 @@ static int write_header(AVFormatContext *s){ put_buffer(bc, ID_STRING, strlen(ID_STRING)); put_byte(bc, 0); - /* main header */ - put_be64(bc, MAIN_STARTCODE); - url_open_dyn_buf(&dyn_bc); - write_mainheader(nut, &dyn_bc); - put_packet(nut, bc, &dyn_bc, 1); - - for (i=0; i < s->nb_streams; i++){ - codec = s->streams[i]->codec; - - put_be64(bc, STREAM_STARTCODE); - url_open_dyn_buf(&dyn_bc); - write_streamheader(nut, &dyn_bc, codec, i); - put_packet(nut, bc, &dyn_bc, 1); - } + write_headers(nut, bc); put_flush_packet(bc); |