[FFmpeg-cvslog] cmdutils: Pass the actual chosen encoder to filter_codec_opts
Martin Storsjö
git at videolan.org
Sat Jun 30 22:47:42 CEST 2012
ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Sat Jun 30 01:28:02 2012 +0300| [d3ed1c9571c24d33fc485fba01bc2d6ed4de18b1] | committer: Martin Storsjö
cmdutils: Pass the actual chosen encoder to filter_codec_opts
This allows passing the right options to encoders when there's more
than one encoder for a certain codec id.
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d3ed1c9571c24d33fc485fba01bc2d6ed4de18b1
---
avconv.c | 4 ++--
avplay.c | 2 +-
cmdutils.c | 9 +++++----
cmdutils.h | 4 +++-
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/avconv.c b/avconv.c
index 3eb249d..3a7cebf 100644
--- a/avconv.c
+++ b/avconv.c
@@ -3441,7 +3441,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
ist->file_index = nb_input_files;
ist->discard = 1;
st->discard = AVDISCARD_ALL;
- ist->opts = filter_codec_opts(codec_opts, ist->st->codec->codec_id, ic, st);
+ ist->opts = filter_codec_opts(codec_opts, ist->st->codec->codec_id, ic, st, NULL);
ist->ts_scale = 1.0;
MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
@@ -3768,7 +3768,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
st->codec->codec_type = type;
choose_encoder(o, oc, ost);
if (ost->enc) {
- ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st);
+ ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st, ost->enc);
}
avcodec_get_context_defaults3(st->codec, ost->enc);
diff --git a/avplay.c b/avplay.c
index 6acb6c1..71844c2 100644
--- a/avplay.c
+++ b/avplay.c
@@ -2081,7 +2081,7 @@ static int stream_component_open(VideoState *is, int stream_index)
return -1;
avctx = ic->streams[stream_index]->codec;
- opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index]);
+ opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index], NULL);
codec = avcodec_find_decoder(avctx->codec_id);
avctx->debug_mv = debug_mv;
diff --git a/cmdutils.c b/cmdutils.c
index abf89a3..6d13bd6 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -948,18 +948,19 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
}
AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id,
- AVFormatContext *s, AVStream *st)
+ AVFormatContext *s, AVStream *st, AVCodec *codec)
{
AVDictionary *ret = NULL;
AVDictionaryEntry *t = NULL;
- AVCodec *codec = s->oformat ? avcodec_find_encoder(codec_id)
- : avcodec_find_decoder(codec_id);
int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
: AV_OPT_FLAG_DECODING_PARAM;
char prefix = 0;
const AVClass *cc = avcodec_get_class();
if (!codec)
+ codec = s->oformat ? avcodec_find_encoder(codec_id)
+ : avcodec_find_decoder(codec_id);
+ if (!codec)
return NULL;
switch (codec->type) {
@@ -1020,7 +1021,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
}
for (i = 0; i < s->nb_streams; i++)
opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id,
- s, s->streams[i]);
+ s, s->streams[i], NULL);
return opts;
}
diff --git a/cmdutils.h b/cmdutils.h
index 5dac130..793a1e8 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -214,10 +214,12 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
*
* @param s Corresponding format context.
* @param st A stream from s for which the options should be filtered.
+ * @param codec The particular codec for which the options should be filtered.
+ * If null, the default one is looked up according to the codec id.
* @return a pointer to the created dictionary
*/
AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id,
- AVFormatContext *s, AVStream *st);
+ AVFormatContext *s, AVStream *st, AVCodec *codec);
/**
* Setup AVCodecContext options for avformat_find_stream_info().
More information about the ffmpeg-cvslog
mailing list