diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-05-22 21:24:59 +0400 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-11-19 13:22:27 +0400 |
commit | afe2726089a9f45d89e81217cd69505c14b94445 (patch) | |
tree | 037739667ab76ab797782ffa12739a5537d4d870 /libavformat/utils.c | |
parent | 23f0d0f16bb2accc661ab8c135362ee75987c549 (diff) |
lavf: add avformat_find_stream_info()
It supports passing options to codecs.
(cherry picked from commit a67c061e0f3b55ffcc96f336fc0998e44b86c8e4)
Conflicts:
libavformat/utils.c
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index e3c7d4aa84..15fed3287a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2074,7 +2074,7 @@ static int has_decode_delay_been_guessed(AVStream *st) st->codec_info_nb_frames >= 6 + st->codec->has_b_frames; } -static int try_decode_frame(AVStream *st, AVPacket *avpkt) +static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options) { int16_t *samples; AVCodec *codec; @@ -2085,7 +2085,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt) codec = avcodec_find_decoder(st->codec->codec_id); if (!codec) return -1; - ret = avcodec_open(st->codec, codec); + ret = avcodec_open2(st->codec, codec, options); if (ret < 0) return ret; } @@ -2204,12 +2204,20 @@ static int tb_unreliable(AVCodecContext *c){ return 0; } +#if FF_API_FORMAT_PARAMETERS int av_find_stream_info(AVFormatContext *ic) { + return avformat_find_stream_info(ic, NULL); +} +#endif + +int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) +{ int i, count, ret, read_size, j; AVStream *st; AVPacket pkt1, *pkt; int64_t old_offset = avio_tell(ic->pb); + int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those for(i=0;i<ic->nb_streams;i++) { AVCodec *codec; @@ -2246,12 +2254,12 @@ int av_find_stream_info(AVFormatContext *ic) /* Ensure that subtitle_header is properly set. */ if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && codec && !st->codec->codec) - avcodec_open(st->codec, codec); + avcodec_open2(st->codec, codec, options ? &options[i] : NULL); //try to just open decoders, in case this is enough to get parameters if(!has_codec_parameters(st->codec)){ if (codec && !st->codec->codec) - avcodec_open(st->codec, codec); + avcodec_open2(st->codec, codec, options ? &options[i] : NULL); } } @@ -2386,7 +2394,7 @@ int av_find_stream_info(AVFormatContext *ic) it takes longer and uses more memory. For MPEG-4, we need to decompress for QuickTime. */ if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)) - try_decode_frame(st, pkt); + try_decode_frame(st, pkt, (options && i <= orig_nb_streams )? &options[i] : NULL); st->codec_info_nb_frames++; count++; |