Revision 636f1c4c

View differences:

cmdutils.c
46 46

  
47 47
const char **opt_names;
48 48
static int opt_name_count;
49
AVCodecContext *avctx_opts[CODEC_TYPE_NB];
49
AVCodecContext *avcodec_opts[CODEC_TYPE_NB];
50 50
AVFormatContext *avformat_opts;
51 51
struct SwsContext *sws_opts;
52 52

  
......
179 179
    int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
180 180

  
181 181
    for(type=0; type<CODEC_TYPE_NB && ret>= 0; type++){
182
        const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
182
        const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]);
183 183
        if(o2)
184
            ret = av_set_string3(avctx_opts[type], opt, arg, 1, &o);
184
            ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
185 185
    }
186 186
    if(!o)
187 187
        ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
......
189 189
        ret = av_set_string3(sws_opts, opt, arg, 1, &o);
190 190
    if(!o){
191 191
        if(opt[0] == 'a')
192
            ret = av_set_string3(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1, &o);
192
            ret = av_set_string3(avcodec_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1, &o);
193 193
        else if(opt[0] == 'v')
194
            ret = av_set_string3(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1, &o);
194
            ret = av_set_string3(avcodec_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1, &o);
195 195
        else if(opt[0] == 's')
196
            ret = av_set_string3(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1, &o);
196
            ret = av_set_string3(avcodec_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1, &o);
197 197
    }
198 198
    if (o && ret < 0) {
199 199
        fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
......
202 202
    if(!o)
203 203
        return -1;
204 204

  
205
//    av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avctx_opts, opt, NULL), (int)av_get_int(avctx_opts, opt, NULL));
205
//    av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL));
206 206

  
207
    //FIXME we should always use avctx_opts, ... for storing options so there will not be any need to keep track of what i set over this
207
    //FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this
208 208
    opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
209 209
    opt_names[opt_name_count++]= o->name;
210 210

  
211
    if(avctx_opts[0]->debug || avformat_opts->debug)
211
    if(avcodec_opts[0]->debug || avformat_opts->debug)
212 212
        av_log_set_level(AV_LOG_DEBUG);
213 213
    return 0;
214 214
}
cmdutils.h
40 40
extern const int this_year;
41 41

  
42 42
extern const char **opt_names;
43
extern AVCodecContext *avctx_opts[CODEC_TYPE_NB];
43
extern AVCodecContext *avcodec_opts[CODEC_TYPE_NB];
44 44
extern AVFormatContext *avformat_opts;
45 45
extern struct SwsContext *sws_opts;
46 46

  
ffmpeg.c
946 946
            /* better than nothing: use input picture interlaced
947 947
               settings */
948 948
            big_picture.interlaced_frame = in_picture->interlaced_frame;
949
            if(avctx_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
949
            if(avcodec_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
950 950
                if(top_field_first == -1)
951 951
                    big_picture.top_field_first = in_picture->top_field_first;
952 952
                else
......
2328 2328

  
2329 2329
    opt_default(opt, arg);
2330 2330

  
2331
    if (av_get_int(avctx_opts[codec_type], "b", NULL) < 1000)
2331
    if (av_get_int(avcodec_opts[codec_type], "b", NULL) < 1000)
2332 2332
        fprintf(stderr, "WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s\n");
2333 2333

  
2334 2334
    return 0;
......
2854 2854
        enc->thread_count= thread_count;
2855 2855
        switch(enc->codec_type) {
2856 2856
        case CODEC_TYPE_AUDIO:
2857
            set_context_opts(enc, avctx_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
2857
            set_context_opts(enc, avcodec_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
2858 2858
            //fprintf(stderr, "\nInput Audio channels: %d", enc->channels);
2859 2859
            channel_layout = enc->channel_layout;
2860 2860
            audio_channels = enc->channels;
......
2865 2865
                ic->streams[i]->discard= AVDISCARD_ALL;
2866 2866
            break;
2867 2867
        case CODEC_TYPE_VIDEO:
2868
            set_context_opts(enc, avctx_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
2868
            set_context_opts(enc, avcodec_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
2869 2869
            frame_height = enc->height;
2870 2870
            frame_width = enc->width;
2871 2871
            if(ic->streams[i]->sample_aspect_ratio.num)
......
2994 2994
    if(   (video_global_header&1)
2995 2995
       || (video_global_header==0 && (oc->oformat->flags & AVFMT_GLOBALHEADER))){
2996 2996
        video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
2997
        avctx_opts[CODEC_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
2997
        avcodec_opts[CODEC_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
2998 2998
    }
2999 2999
    if(video_global_header&2){
3000 3000
        video_enc->flags2 |= CODEC_FLAG2_LOCAL_HEADER;
3001
        avctx_opts[CODEC_TYPE_VIDEO]->flags2|= CODEC_FLAG2_LOCAL_HEADER;
3001
        avcodec_opts[CODEC_TYPE_VIDEO]->flags2|= CODEC_FLAG2_LOCAL_HEADER;
3002 3002
    }
3003 3003

  
3004 3004
    if (video_stream_copy) {
......
3023 3023

  
3024 3024
        video_enc->codec_id = codec_id;
3025 3025

  
3026
        set_context_opts(video_enc, avctx_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
3026
        set_context_opts(video_enc, avcodec_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
3027 3027

  
3028 3028
        if (codec && codec->supported_framerates && !force_fps)
3029 3029
            fps = codec->supported_framerates[av_find_nearest_q_idx(fps, codec->supported_framerates)];
......
3137 3137

  
3138 3138
    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
3139 3139
        audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
3140
        avctx_opts[CODEC_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
3140
        avcodec_opts[CODEC_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
3141 3141
    }
3142 3142
    if (audio_stream_copy) {
3143 3143
        st->stream_copy = 1;
......
3145 3145
    } else {
3146 3146
        AVCodec *codec;
3147 3147

  
3148
        set_context_opts(audio_enc, avctx_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
3148
        set_context_opts(audio_enc, avcodec_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
3149 3149

  
3150 3150
        if (audio_codec_name) {
3151 3151
            codec_id = find_codec_or_die(audio_codec_name, CODEC_TYPE_AUDIO, 1);
......
3211 3211
    if (subtitle_stream_copy) {
3212 3212
        st->stream_copy = 1;
3213 3213
    } else {
3214
        set_context_opts(avctx_opts[CODEC_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
3214
        set_context_opts(avcodec_opts[CODEC_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
3215 3215
        subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, CODEC_TYPE_SUBTITLE, 1);
3216 3216
        output_codecs[nb_ocodecs] = avcodec_find_encoder_by_name(subtitle_codec_name);
3217 3217
    }
......
3503 3503
                      OPT_GRAB,
3504 3504
                      OPT_GRAB);
3505 3505
    printf("\n");
3506
    av_opt_show(avctx_opts[0], NULL);
3506
    av_opt_show(avcodec_opts[0], NULL);
3507 3507
    printf("\n");
3508 3508
    av_opt_show(avformat_opts, NULL);
3509 3509
    printf("\n");
......
3888 3888
        url_set_interrupt_cb(decode_interrupt_cb);
3889 3889

  
3890 3890
    for(i=0; i<CODEC_TYPE_NB; i++){
3891
        avctx_opts[i]= avcodec_alloc_context2(i);
3891
        avcodec_opts[i]= avcodec_alloc_context2(i);
3892 3892
    }
3893 3893
    avformat_opts = avformat_alloc_context();
3894 3894
    sws_opts = sws_getContext(16,16,0, 16,16,0, sws_flags, NULL,NULL,NULL);
ffplay.c
1752 1752
    enc->error_recognition= error_recognition;
1753 1753
    enc->error_concealment= error_concealment;
1754 1754

  
1755
    set_context_opts(enc, avctx_opts[enc->codec_type], 0);
1755
    set_context_opts(enc, avcodec_opts[enc->codec_type], 0);
1756 1756

  
1757 1757
    if (!codec ||
1758 1758
        avcodec_open(enc, codec) < 0)
......
2558 2558
    av_register_all();
2559 2559

  
2560 2560
    for(i=0; i<CODEC_TYPE_NB; i++){
2561
        avctx_opts[i]= avcodec_alloc_context2(i);
2561
        avcodec_opts[i]= avcodec_alloc_context2(i);
2562 2562
    }
2563 2563
    avformat_opts = avformat_alloc_context();
2564 2564
    sws_opts = sws_getContext(16,16,0, 16,16,0, sws_flags, NULL,NULL,NULL);

Also available in: Unified diff