diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2007-10-31 21:35:50 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2007-10-31 21:35:50 +0000 |
commit | 6f910bcf395c072f943d55535071989b0c53f332 (patch) | |
tree | 6f01675fd0330e9c5ca4c1d15256649498bccfd8 /libavformat/flvdec.c | |
parent | ff21c1b0560f8133bc46cbe9b5840a8a80a31689 (diff) | |
download | ffmpeg-6f910bcf395c072f943d55535071989b0c53f332.tar.gz |
factorize stream creation
Originally committed as revision 10886 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r-- | libavformat/flvdec.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 001239b732..1de656ba7d 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -224,11 +224,19 @@ static int flv_read_metabody(AVFormatContext *s, unsigned int next_pos) { return 0; } +static AVStream *create_stream(AVFormatContext *s, int is_audio){ + AVStream *st = av_new_stream(s, is_audio); + if (!st) + return NULL; + st->codec->codec_type = is_audio ? CODEC_TYPE_AUDIO : CODEC_TYPE_VIDEO; + av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ + return st; +} + static int flv_read_header(AVFormatContext *s, AVFormatParameters *ap) { int offset, flags; - AVStream *st; url_fskip(&s->pb, 4); flags = get_byte(&s->pb); @@ -240,18 +248,12 @@ static int flv_read_header(AVFormatContext *s, } if(flags & FLV_HEADER_FLAG_HASVIDEO){ - st = av_new_stream(s, 0); - if (!st) + if(!create_stream(s, 0)) return AVERROR(ENOMEM); - st->codec->codec_type = CODEC_TYPE_VIDEO; - av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ } if(flags & FLV_HEADER_FLAG_HASAUDIO){ - st = av_new_stream(s, 1); - if (!st) + if(!create_stream(s, 1)) return AVERROR(ENOMEM); - st->codec->codec_type = CODEC_TYPE_AUDIO; - av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ } offset = get_be32(&s->pb); |