Browse code

cmdutils: pass AVCodec to filter_codec_opts()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/11/28 05:17:56
Showing 5 changed files
... ...
@@ -2963,7 +2963,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
2963 2963
         ist->st = st;
2964 2964
         ist->file_index = nb_input_files;
2965 2965
         ist->discard = 1;
2966
-        ist->opts = filter_codec_opts(codec_opts, ist->st->codec->codec_id, ic, st);
2966
+        ist->opts = filter_codec_opts(codec_opts, choose_decoder(o, ic, st), ic, st);
2967 2967
 
2968 2968
         ist->ts_scale = 1.0;
2969 2969
         MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
... ...
@@ -3302,7 +3302,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
3302 3302
     st->codec->codec_type = type;
3303 3303
     choose_encoder(o, oc, ost);
3304 3304
     if (ost->enc) {
3305
-        ost->opts  = filter_codec_opts(codec_opts, ost->enc->id, oc, st);
3305
+        ost->opts  = filter_codec_opts(codec_opts, ost->enc, oc, st);
3306 3306
     }
3307 3307
 
3308 3308
     avcodec_get_context_defaults3(st->codec, ost->enc);
... ...
@@ -945,11 +945,10 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
945 945
     return AVERROR(EINVAL);
946 946
 }
947 947
 
948
-AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFormatContext *s, AVStream *st)
948
+AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatContext *s, AVStream *st)
949 949
 {
950 950
     AVDictionary    *ret = NULL;
951 951
     AVDictionaryEntry *t = NULL;
952
-    AVCodec       *codec = s->oformat ? avcodec_find_encoder(codec_id) : avcodec_find_decoder(codec_id);
953 952
     int            flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM;
954 953
     char          prefix = 0;
955 954
     const AVClass    *cc = avcodec_get_class();
... ...
@@ -999,7 +998,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *cod
999 999
         return NULL;
1000 1000
     }
1001 1001
     for (i = 0; i < s->nb_streams; i++)
1002
-        opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id, s, s->streams[i]);
1002
+        opts[i] = filter_codec_opts(codec_opts, avcodec_find_decoder(s->streams[i]->codec->codec_id), s, s->streams[i]);
1003 1003
     return opts;
1004 1004
 }
1005 1005
 
... ...
@@ -212,7 +212,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
212 212
  * @param st A stream from s for which the options should be filtered.
213 213
  * @return a pointer to the created dictionary
214 214
  */
215
-AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFormatContext *s, AVStream *st);
215
+AVDictionary *filter_codec_opts(AVDictionary *opts, AVCodec *codec, AVFormatContext *s, AVStream *st);
216 216
 
217 217
 /**
218 218
  * Setup AVCodecContext options for avformat_find_stream_info().
... ...
@@ -3189,7 +3189,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
3189 3189
         ist->st = st;
3190 3190
         ist->file_index = nb_input_files;
3191 3191
         ist->discard = 1;
3192
-        ist->opts = filter_codec_opts(codec_opts, ist->st->codec->codec_id, ic, st);
3192
+        ist->opts = filter_codec_opts(codec_opts, choose_decoder(o, ic, st), ic, st);
3193 3193
 
3194 3194
         ist->ts_scale = 1.0;
3195 3195
         MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
... ...
@@ -3546,7 +3546,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
3546 3546
     st->codec->codec_type = type;
3547 3547
     choose_encoder(o, oc, ost);
3548 3548
     if (ost->enc) {
3549
-        ost->opts  = filter_codec_opts(codec_opts, ost->enc->id, oc, st);
3549
+        ost->opts  = filter_codec_opts(codec_opts, ost->enc, oc, st);
3550 3550
     }
3551 3551
 
3552 3552
     avcodec_get_context_defaults3(st->codec, ost->enc);
... ...
@@ -2217,9 +2217,9 @@ static int stream_component_open(VideoState *is, int stream_index)
2217 2217
         return -1;
2218 2218
     avctx = ic->streams[stream_index]->codec;
2219 2219
 
2220
-    opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index]);
2221
-
2222 2220
     codec = avcodec_find_decoder(avctx->codec_id);
2221
+    opts = filter_codec_opts(codec_opts, codec, ic, ic->streams[stream_index]);
2222
+
2223 2223
     switch(avctx->codec_type){
2224 2224
         case AVMEDIA_TYPE_AUDIO   : if(audio_codec_name   ) codec= avcodec_find_decoder_by_name(   audio_codec_name); break;
2225 2225
         case AVMEDIA_TYPE_SUBTITLE: if(subtitle_codec_name) codec= avcodec_find_decoder_by_name(subtitle_codec_name); break;