Browse code

cmdutils: remove OPT_FUNC2

Make ff* tools only accept opt_* functions taking two arguments.

The distinction between functions with one and two arguments is quite
pointless. Simplify parse_options() code.

Stefano Sabatini authored on 2011/05/25 01:14:42
Showing 6 changed files
... ...
@@ -273,15 +273,13 @@ unknown_opt:
273 273
                 *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
274 274
             } else if (po->flags & OPT_FLOAT) {
275 275
                 *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
276
-            } else if (po->flags & OPT_FUNC2) {
277
-                if (po->u.func2_arg(opt, arg) < 0) {
278
-                    fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
279
-                    exit(1);
280
-                }
281 276
             } else if (po->flags & OPT_DUMMY) {
282 277
                 /* Do nothing for this option */
283 278
             } else {
284
-                po->u.func_arg(arg);
279
+                if (po->u.func_arg(opt, arg) < 0) {
280
+                    fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
281
+                    exit(1);
282
+                }
285 283
             }
286 284
             if(po->flags & OPT_EXIT)
287 285
                 exit(0);
... ...
@@ -121,17 +121,15 @@ typedef struct {
121 121
 #define OPT_INT    0x0080
122 122
 #define OPT_FLOAT  0x0100
123 123
 #define OPT_SUBTITLE 0x0200
124
-#define OPT_FUNC2  0x0400
125
-#define OPT_INT64  0x0800
126
-#define OPT_EXIT   0x1000
127
-#define OPT_DATA   0x2000
128
-#define OPT_DUMMY  0x4000
124
+#define OPT_INT64  0x0400
125
+#define OPT_EXIT   0x0800
126
+#define OPT_DATA   0x1000
127
+#define OPT_DUMMY  0x2000
129 128
      union {
130
-        void (*func_arg)(const char *); //FIXME passing error code as int return would be nicer then exit() in the func
131 129
         int *int_arg;
132 130
         char **str_arg;
133 131
         float *float_arg;
134
-        int (*func2_arg)(const char *, const char *);
132
+        int (*func_arg)(const char *, const char *);
135 133
         int64_t *int64_arg;
136 134
     } u;
137 135
     const char *help;
... ...
@@ -10,4 +10,4 @@
10 10
     { "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" },
11 11
     { "filters",   OPT_EXIT, {(void*)show_filters  }, "show available filters" },
12 12
     { "pix_fmts" , OPT_EXIT, {(void*)show_pix_fmts }, "show available pixel formats" },
13
-    { "loglevel", HAS_ARG | OPT_FUNC2, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
13
+    { "loglevel", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
... ...
@@ -2810,14 +2810,16 @@ static int transcode(AVFormatContext **output_files,
2810 2810
     return ret;
2811 2811
 }
2812 2812
 
2813
-static void opt_format(const char *arg)
2813
+static int opt_format(const char *opt, const char *arg)
2814 2814
 {
2815 2815
     last_asked_format = arg;
2816
+    return 0;
2816 2817
 }
2817 2818
 
2818
-static void opt_video_rc_override_string(const char *arg)
2819
+static int opt_video_rc_override_string(const char *opt, const char *arg)
2819 2820
 {
2820 2821
     video_rc_override_string = arg;
2822
+    return 0;
2821 2823
 }
2822 2824
 
2823 2825
 static int opt_me_threshold(const char *opt, const char *arg)
... ...
@@ -2859,12 +2861,13 @@ static int opt_frame_crop(const char *opt, const char *arg)
2859 2859
     return AVERROR(EINVAL);
2860 2860
 }
2861 2861
 
2862
-static void opt_frame_size(const char *arg)
2862
+static int opt_frame_size(const char *opt, const char *arg)
2863 2863
 {
2864 2864
     if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
2865 2865
         fprintf(stderr, "Incorrect frame size\n");
2866
-        ffmpeg_exit(1);
2866
+        return AVERROR(EINVAL);
2867 2867
     }
2868
+    return 0;
2868 2869
 }
2869 2870
 
2870 2871
 static int opt_pad(const char *opt, const char *arg) {
... ...
@@ -2872,21 +2875,22 @@ static int opt_pad(const char *opt, const char *arg) {
2872 2872
     return -1;
2873 2873
 }
2874 2874
 
2875
-static void opt_frame_pix_fmt(const char *arg)
2875
+static int opt_frame_pix_fmt(const char *opt, const char *arg)
2876 2876
 {
2877 2877
     if (strcmp(arg, "list")) {
2878 2878
         frame_pix_fmt = av_get_pix_fmt(arg);
2879 2879
         if (frame_pix_fmt == PIX_FMT_NONE) {
2880 2880
             fprintf(stderr, "Unknown pixel format requested: %s\n", arg);
2881
-            ffmpeg_exit(1);
2881
+            return AVERROR(EINVAL);
2882 2882
         }
2883 2883
     } else {
2884 2884
         show_pix_fmts();
2885 2885
         ffmpeg_exit(0);
2886 2886
     }
2887
+    return 0;
2887 2888
 }
2888 2889
 
2889
-static void opt_frame_aspect_ratio(const char *arg)
2890
+static int opt_frame_aspect_ratio(const char *opt, const char *arg)
2890 2891
 {
2891 2892
     int x = 0, y = 0;
2892 2893
     double ar = 0;
... ...
@@ -2905,9 +2909,10 @@ static void opt_frame_aspect_ratio(const char *arg)
2905 2905
 
2906 2906
     if (!ar) {
2907 2907
         fprintf(stderr, "Incorrect aspect ratio specification.\n");
2908
-        ffmpeg_exit(1);
2908
+        return AVERROR(EINVAL);
2909 2909
     }
2910 2910
     frame_aspect_ratio = ar;
2911
+    return 0;
2911 2912
 }
2912 2913
 
2913 2914
 static int opt_metadata(const char *opt, const char *arg)
... ...
@@ -2952,13 +2957,13 @@ static int opt_thread_count(const char *opt, const char *arg)
2952 2952
     return 0;
2953 2953
 }
2954 2954
 
2955
-static void opt_audio_sample_fmt(const char *arg)
2955
+static int opt_audio_sample_fmt(const char *opt, const char *arg)
2956 2956
 {
2957 2957
     if (strcmp(arg, "list")) {
2958 2958
         audio_sample_fmt = av_get_sample_fmt(arg);
2959 2959
         if (audio_sample_fmt == AV_SAMPLE_FMT_NONE) {
2960 2960
             av_log(NULL, AV_LOG_ERROR, "Invalid sample format '%s'\n", arg);
2961
-            ffmpeg_exit(1);
2961
+            return AVERROR(EINVAL);
2962 2962
         }
2963 2963
     } else {
2964 2964
         int i;
... ...
@@ -2967,6 +2972,7 @@ static void opt_audio_sample_fmt(const char *arg)
2967 2967
             printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
2968 2968
         ffmpeg_exit(0);
2969 2969
     }
2970
+    return 0;
2970 2971
 }
2971 2972
 
2972 2973
 static int opt_audio_rate(const char *opt, const char *arg)
... ...
@@ -2987,12 +2993,13 @@ static int opt_video_channel(const char *opt, const char *arg)
2987 2987
     return 0;
2988 2988
 }
2989 2989
 
2990
-static void opt_video_standard(const char *arg)
2990
+static int opt_video_standard(const char *opt, const char *arg)
2991 2991
 {
2992 2992
     video_standard = av_strdup(arg);
2993
+    return 0;
2993 2994
 }
2994 2995
 
2995
-static void opt_codec(int *pstream_copy, char **pcodec_name,
2996
+static int opt_codec(int *pstream_copy, char **pcodec_name,
2996 2997
                       int codec_type, const char *arg)
2997 2998
 {
2998 2999
     av_freep(pcodec_name);
... ...
@@ -3001,26 +3008,27 @@ static void opt_codec(int *pstream_copy, char **pcodec_name,
3001 3001
     } else {
3002 3002
         *pcodec_name = av_strdup(arg);
3003 3003
     }
3004
+    return 0;
3004 3005
 }
3005 3006
 
3006
-static void opt_audio_codec(const char *arg)
3007
+static int opt_audio_codec(const char *opt, const char *arg)
3007 3008
 {
3008
-    opt_codec(&audio_stream_copy, &audio_codec_name, AVMEDIA_TYPE_AUDIO, arg);
3009
+    return opt_codec(&audio_stream_copy, &audio_codec_name, AVMEDIA_TYPE_AUDIO, arg);
3009 3010
 }
3010 3011
 
3011
-static void opt_video_codec(const char *arg)
3012
+static int opt_video_codec(const char *opt, const char *arg)
3012 3013
 {
3013
-    opt_codec(&video_stream_copy, &video_codec_name, AVMEDIA_TYPE_VIDEO, arg);
3014
+    return opt_codec(&video_stream_copy, &video_codec_name, AVMEDIA_TYPE_VIDEO, arg);
3014 3015
 }
3015 3016
 
3016
-static void opt_subtitle_codec(const char *arg)
3017
+static int opt_subtitle_codec(const char *opt, const char *arg)
3017 3018
 {
3018
-    opt_codec(&subtitle_stream_copy, &subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, arg);
3019
+    return opt_codec(&subtitle_stream_copy, &subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, arg);
3019 3020
 }
3020 3021
 
3021
-static void opt_data_codec(const char *arg)
3022
+static int opt_data_codec(const char *opt, const char *arg)
3022 3023
 {
3023
-    opt_codec(&data_stream_copy, &data_codec_name, AVMEDIA_TYPE_DATA, arg);
3024
+    return opt_codec(&data_stream_copy, &data_codec_name, AVMEDIA_TYPE_DATA, arg);
3024 3025
 }
3025 3026
 
3026 3027
 static int opt_codec_tag(const char *opt, const char *arg)
... ...
@@ -3041,7 +3049,7 @@ static int opt_codec_tag(const char *opt, const char *arg)
3041 3041
     return 0;
3042 3042
 }
3043 3043
 
3044
-static void opt_map(const char *arg)
3044
+static int opt_map(const char *opt, const char *arg)
3045 3045
 {
3046 3046
     AVStreamMap *m;
3047 3047
     char *p;
... ...
@@ -3064,6 +3072,7 @@ static void opt_map(const char *arg)
3064 3064
         m->sync_file_index = m->file_index;
3065 3065
         m->sync_stream_index = m->stream_index;
3066 3066
     }
3067
+    return 0;
3067 3068
 }
3068 3069
 
3069 3070
 static void parse_meta_type(char *arg, char *type, int *index, char **endptr)
... ...
@@ -3087,7 +3096,7 @@ static void parse_meta_type(char *arg, char *type, int *index, char **endptr)
3087 3087
         *type = 'g';
3088 3088
 }
3089 3089
 
3090
-static void opt_map_metadata(const char *arg)
3090
+static int opt_map_metadata(const char *opt, const char *arg)
3091 3091
 {
3092 3092
     AVMetaDataMap *m, *m1;
3093 3093
     char *p;
... ...
@@ -3111,16 +3120,18 @@ static void opt_map_metadata(const char *arg)
3111 3111
         metadata_streams_autocopy = 0;
3112 3112
     if (m->type == 'c' || m1->type == 'c')
3113 3113
         metadata_chapters_autocopy = 0;
3114
+
3115
+    return 0;
3114 3116
 }
3115 3117
 
3116
-static void opt_map_meta_data(const char *arg)
3118
+static int opt_map_meta_data(const char *opt, const char *arg)
3117 3119
 {
3118 3120
     fprintf(stderr, "-map_meta_data is deprecated and will be removed soon. "
3119 3121
                     "Use -map_metadata instead.\n");
3120
-    opt_map_metadata(arg);
3122
+    return opt_map_metadata(opt, arg);
3121 3123
 }
3122 3124
 
3123
-static void opt_map_chapters(const char *arg)
3125
+static int opt_map_chapters(const char *opt, const char *arg)
3124 3126
 {
3125 3127
     AVChapterMap *c;
3126 3128
     char *p;
... ...
@@ -3133,9 +3144,10 @@ static void opt_map_chapters(const char *arg)
3133 3133
         p++;
3134 3134
 
3135 3135
     c->in_file = strtol(p, &p, 0);
3136
+    return 0;
3136 3137
 }
3137 3138
 
3138
-static void opt_input_ts_scale(const char *arg)
3139
+static int opt_input_ts_scale(const char *opt, const char *arg)
3139 3140
 {
3140 3141
     unsigned int stream;
3141 3142
     double scale;
... ...
@@ -3151,6 +3163,7 @@ static void opt_input_ts_scale(const char *arg)
3151 3151
 
3152 3152
     input_files_ts_scale[nb_input_files] = grow_array(input_files_ts_scale[nb_input_files], sizeof(*input_files_ts_scale[nb_input_files]), &nb_input_files_ts_scale[nb_input_files], stream + 1);
3153 3153
     input_files_ts_scale[nb_input_files][stream]= scale;
3154
+    return 0;
3154 3155
 }
3155 3156
 
3156 3157
 static int opt_recording_time(const char *opt, const char *arg)
... ...
@@ -3211,7 +3224,7 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder, i
3211 3211
     return codec->id;
3212 3212
 }
3213 3213
 
3214
-static void opt_input_file(const char *filename)
3214
+static int opt_input_file(const char *opt, const char *filename)
3215 3215
 {
3216 3216
     AVFormatContext *ic;
3217 3217
     AVFormatParameters params, *ap = &params;
... ...
@@ -3433,6 +3446,7 @@ static void opt_input_file(const char *filename)
3433 3433
     av_freep(&subtitle_codec_name);
3434 3434
     uninit_opts();
3435 3435
     init_opts();
3436
+    return 0;
3436 3437
 }
3437 3438
 
3438 3439
 static void check_inputs(int *has_video_ptr,
... ...
@@ -4101,7 +4115,7 @@ static void show_help(void)
4101 4101
     av_opt_show2(sws_opts, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0);
4102 4102
 }
4103 4103
 
4104
-static void opt_target(const char *arg)
4104
+static int opt_target(const char *opt, const char *arg)
4105 4105
 {
4106 4106
     enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
4107 4107
     static const char *const frame_rates[] = {"25", "30000/1001", "24000/1001"};
... ...
@@ -4158,13 +4172,12 @@ static void opt_target(const char *arg)
4158 4158
     }
4159 4159
 
4160 4160
     if(!strcmp(arg, "vcd")) {
4161
+        opt_video_codec("vcodec", "mpeg1video");
4162
+        opt_audio_codec("vcodec", "mp2");
4163
+        opt_format("f", "vcd");
4161 4164
 
4162
-        opt_video_codec("mpeg1video");
4163
-        opt_audio_codec("mp2");
4164
-        opt_format("vcd");
4165
-
4166
-        opt_frame_size(norm == PAL ? "352x288" : "352x240");
4167
-        opt_frame_rate(NULL, frame_rates[norm]);
4165
+        opt_frame_size("s", norm == PAL ? "352x288" : "352x240");
4166
+        opt_frame_rate("r", frame_rates[norm]);
4168 4167
         opt_default("g", norm == PAL ? "15" : "18");
4169 4168
 
4170 4169
         opt_default("b", "1150000");
... ...
@@ -4187,12 +4200,12 @@ static void opt_target(const char *arg)
4187 4187
         mux_preload= (36000+3*1200) / 90000.0; //0.44
4188 4188
     } else if(!strcmp(arg, "svcd")) {
4189 4189
 
4190
-        opt_video_codec("mpeg2video");
4191
-        opt_audio_codec("mp2");
4192
-        opt_format("svcd");
4190
+        opt_video_codec("vcodec", "mpeg2video");
4191
+        opt_audio_codec("acodec", "mp2");
4192
+        opt_format("f", "svcd");
4193 4193
 
4194
-        opt_frame_size(norm == PAL ? "480x576" : "480x480");
4195
-        opt_frame_rate(NULL, frame_rates[norm]);
4194
+        opt_frame_size("s", norm == PAL ? "480x576" : "480x480");
4195
+        opt_frame_rate("r", frame_rates[norm]);
4196 4196
         opt_default("g", norm == PAL ? "15" : "18");
4197 4197
 
4198 4198
         opt_default("b", "2040000");
... ...
@@ -4209,12 +4222,12 @@ static void opt_target(const char *arg)
4209 4209
 
4210 4210
     } else if(!strcmp(arg, "dvd")) {
4211 4211
 
4212
-        opt_video_codec("mpeg2video");
4213
-        opt_audio_codec("ac3");
4214
-        opt_format("dvd");
4212
+        opt_video_codec("vcodec", "mpeg2video");
4213
+        opt_audio_codec("vcodec", "ac3");
4214
+        opt_format("f", "dvd");
4215 4215
 
4216
-        opt_frame_size(norm == PAL ? "720x576" : "720x480");
4217
-        opt_frame_rate(NULL, frame_rates[norm]);
4216
+        opt_frame_size("vcodec", norm == PAL ? "720x576" : "720x480");
4217
+        opt_frame_rate("r", frame_rates[norm]);
4218 4218
         opt_default("g", norm == PAL ? "15" : "18");
4219 4219
 
4220 4220
         opt_default("b", "6000000");
... ...
@@ -4230,29 +4243,31 @@ static void opt_target(const char *arg)
4230 4230
 
4231 4231
     } else if(!strncmp(arg, "dv", 2)) {
4232 4232
 
4233
-        opt_format("dv");
4233
+        opt_format("f", "dv");
4234 4234
 
4235
-        opt_frame_size(norm == PAL ? "720x576" : "720x480");
4236
-        opt_frame_pix_fmt(!strncmp(arg, "dv50", 4) ? "yuv422p" :
4237
-                          (norm == PAL ? "yuv420p" : "yuv411p"));
4238
-        opt_frame_rate(NULL, frame_rates[norm]);
4235
+        opt_frame_size("s", norm == PAL ? "720x576" : "720x480");
4236
+        opt_frame_pix_fmt("pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
4237
+                          norm == PAL ? "yuv420p" : "yuv411p");
4238
+        opt_frame_rate("r", frame_rates[norm]);
4239 4239
 
4240 4240
         audio_sample_rate = 48000;
4241 4241
         audio_channels = 2;
4242 4242
 
4243 4243
     } else {
4244 4244
         fprintf(stderr, "Unknown target: %s\n", arg);
4245
-        ffmpeg_exit(1);
4245
+        return AVERROR(EINVAL);
4246 4246
     }
4247
+    return 0;
4247 4248
 }
4248 4249
 
4249
-static void opt_vstats_file (const char *arg)
4250
+static int opt_vstats_file(const char *opt, const char *arg)
4250 4251
 {
4251 4252
     av_free (vstats_filename);
4252 4253
     vstats_filename=av_strdup (arg);
4254
+    return 0;
4253 4255
 }
4254 4256
 
4255
-static void opt_vstats (void)
4257
+static int opt_vstats(const char *opt, const char *arg)
4256 4258
 {
4257 4259
     char filename[40];
4258 4260
     time_t today2 = time(NULL);
... ...
@@ -4260,7 +4275,7 @@ static void opt_vstats (void)
4260 4260
 
4261 4261
     snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
4262 4262
              today->tm_sec);
4263
-    opt_vstats_file(filename);
4263
+    return opt_vstats_file(opt, filename);
4264 4264
 }
4265 4265
 
4266 4266
 static int opt_bsf(const char *opt, const char *arg)
... ...
@@ -4307,13 +4322,13 @@ static int opt_preset(const char *opt, const char *arg)
4307 4307
             ffmpeg_exit(1);
4308 4308
         }
4309 4309
         if(!strcmp(tmp, "acodec")){
4310
-            opt_audio_codec(tmp2);
4310
+            opt_audio_codec(tmp, tmp2);
4311 4311
         }else if(!strcmp(tmp, "vcodec")){
4312
-            opt_video_codec(tmp2);
4312
+            opt_video_codec(tmp, tmp2);
4313 4313
         }else if(!strcmp(tmp, "scodec")){
4314
-            opt_subtitle_codec(tmp2);
4314
+            opt_subtitle_codec(tmp, tmp2);
4315 4315
         }else if(!strcmp(tmp, "dcodec")){
4316
-            opt_data_codec(tmp2);
4316
+            opt_data_codec(tmp, tmp2);
4317 4317
         }else if(opt_default(tmp, tmp2) < 0){
4318 4318
             fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2);
4319 4319
             ffmpeg_exit(1);
... ...
@@ -4347,17 +4362,17 @@ static const OptionDef options[] = {
4347 4347
     { "map_metadata", HAS_ARG | OPT_EXPERT, {(void*)opt_map_metadata}, "set metadata information of outfile from infile",
4348 4348
       "outfile[,metadata]:infile[,metadata]" },
4349 4349
     { "map_chapters",  HAS_ARG | OPT_EXPERT, {(void*)opt_map_chapters},  "set chapters mapping", "outfile:infile" },
4350
-    { "t", OPT_FUNC2 | HAS_ARG, {(void*)opt_recording_time}, "record or transcode \"duration\" seconds of audio/video", "duration" },
4350
+    { "t", HAS_ARG, {(void*)opt_recording_time}, "record or transcode \"duration\" seconds of audio/video", "duration" },
4351 4351
     { "fs", HAS_ARG | OPT_INT64, {(void*)&limit_filesize}, "set the limit file size in bytes", "limit_size" }, //
4352
-    { "ss", OPT_FUNC2 | HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" },
4353
-    { "itsoffset", OPT_FUNC2 | HAS_ARG, {(void*)opt_input_ts_offset}, "set the input ts offset", "time_off" },
4352
+    { "ss", HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" },
4353
+    { "itsoffset", HAS_ARG, {(void*)opt_input_ts_offset}, "set the input ts offset", "time_off" },
4354 4354
     { "itsscale", HAS_ARG, {(void*)opt_input_ts_scale}, "set the input ts scale", "stream:scale" },
4355
-    { "timestamp", OPT_FUNC2 | HAS_ARG, {(void*)opt_recording_timestamp}, "set the recording timestamp ('now' to set the current time)", "time" },
4356
-    { "metadata", OPT_FUNC2 | HAS_ARG, {(void*)opt_metadata}, "add metadata", "string=string" },
4355
+    { "timestamp", HAS_ARG, {(void*)opt_recording_timestamp}, "set the recording timestamp ('now' to set the current time)", "time" },
4356
+    { "metadata", HAS_ARG, {(void*)opt_metadata}, "add metadata", "string=string" },
4357 4357
     { "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[AVMEDIA_TYPE_DATA]}, "set the number of data frames to record", "number" },
4358 4358
     { "benchmark", OPT_BOOL | OPT_EXPERT, {(void*)&do_benchmark},
4359 4359
       "add timings for benchmarking" },
4360
-    { "timelimit", OPT_FUNC2 | HAS_ARG, {(void*)opt_timelimit}, "set max runtime in seconds", "limit" },
4360
+    { "timelimit", HAS_ARG, {(void*)opt_timelimit}, "set max runtime in seconds", "limit" },
4361 4361
     { "dump", OPT_BOOL | OPT_EXPERT, {(void*)&do_pkt_dump},
4362 4362
       "dump each input packet" },
4363 4363
     { "hex", OPT_BOOL | OPT_EXPERT, {(void*)&do_hex_dump},
... ...
@@ -4365,9 +4380,9 @@ static const OptionDef options[] = {
4365 4365
     { "re", OPT_BOOL | OPT_EXPERT, {(void*)&rate_emu}, "read input at native frame rate", "" },
4366 4366
     { "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "loop (current only works with images)" },
4367 4367
     { "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "number of times to loop output in formats that support looping (0 loops forever)", "" },
4368
-    { "v", HAS_ARG | OPT_FUNC2, {(void*)opt_verbose}, "set ffmpeg verbosity level", "number" },
4368
+    { "v", HAS_ARG, {(void*)opt_verbose}, "set ffmpeg verbosity level", "number" },
4369 4369
     { "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
4370
-    { "threads", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
4370
+    { "threads",  HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
4371 4371
     { "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },
4372 4372
     { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" },
4373 4373
     { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" },
... ...
@@ -4380,33 +4395,33 @@ static const OptionDef options[] = {
4380 4380
     { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)&copy_initial_nonkeyframes}, "copy initial non-keyframes" },
4381 4381
 
4382 4382
     /* video options */
4383
-    { "b", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4384
-    { "vb", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4383
+    { "b",  HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4384
+    { "vb",  HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4385 4385
     { "vframes", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&max_frames[AVMEDIA_TYPE_VIDEO]}, "set the number of video frames to record", "number" },
4386
-    { "r", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz value, fraction or abbreviation)", "rate" },
4386
+    { "r",  HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz value, fraction or abbreviation)", "rate" },
4387 4387
     { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
4388 4388
     { "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
4389 4389
     { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format, 'list' as argument shows all the pixel formats supported", "format" },
4390 4390
     { "bits_per_raw_sample", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&frame_bits_per_raw_sample}, "set the number of bits per raw sample", "number" },
4391
-    { "croptop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4392
-    { "cropbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4393
-    { "cropleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4394
-    { "cropright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4395
-    { "padtop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4396
-    { "padbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4397
-    { "padleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4398
-    { "padright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4399
-    { "padcolor", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "color" },
4391
+    { "croptop",  HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4392
+    { "cropbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4393
+    { "cropleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4394
+    { "cropright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4395
+    { "padtop", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4396
+    { "padbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4397
+    { "padleft", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4398
+    { "padright", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4399
+    { "padcolor", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "color" },
4400 4400
     { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use only intra frames"},
4401 4401
     { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable video" },
4402 4402
     { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold", "n" },
4403
-    { "qscale", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use fixed video quantizer scale (VBR)", "q" },
4403
+    { "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use fixed video quantizer scale (VBR)", "q" },
4404 4404
     { "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_rc_override_string}, "rate control override for specific intervals", "override" },
4405 4405
     { "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_video_codec}, "force video codec ('copy' to copy stream)", "codec" },
4406
-    { "me_threshold", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold",  "threshold" },
4406
+    { "me_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold",  "threshold" },
4407 4407
     { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality},
4408 4408
       "use same quantizer as source (implies VBR)" },
4409
-    { "pass", HAS_ARG | OPT_FUNC2 | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" },
4409
+    { "pass", HAS_ARG | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" },
4410 4410
     { "passlogfile", HAS_ARG | OPT_VIDEO, {(void*)&opt_passlogfile}, "select two pass log file name prefix", "prefix" },
4411 4411
     { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace},
4412 4412
       "deinterlace pictures" },
... ...
@@ -4418,39 +4433,39 @@ static const OptionDef options[] = {
4418 4418
 #endif
4419 4419
     { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix}, "specify intra matrix coeffs", "matrix" },
4420 4420
     { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix}, "specify inter matrix coeffs", "matrix" },
4421
-    { "top", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "top=1/bottom=0/auto=-1 field first", "" },
4421
+    { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "top=1/bottom=0/auto=-1 field first", "" },
4422 4422
     { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precision}, "intra_dc_precision", "precision" },
4423
-    { "vtag", OPT_FUNC2 | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_codec_tag}, "force video tag/fourcc", "fourcc/tag" },
4424
-    { "newvideo", OPT_VIDEO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new video stream to the current output stream" },
4423
+    { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_codec_tag}, "force video tag/fourcc", "fourcc/tag" },
4424
+    { "newvideo", OPT_VIDEO, {(void*)opt_new_stream}, "add a new video stream to the current output stream" },
4425 4425
     { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" },
4426 4426
     { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
4427 4427
     { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "force the selected framerate, disable the best supported framerate selection" },
4428
-    { "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
4428
+    { "streamid", HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
4429 4429
     { "force_key_frames", OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void *)&forced_key_frames}, "force key frames at specified timestamps", "timestamps" },
4430 4430
 
4431 4431
     /* audio options */
4432
-    { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4432
+    { "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4433 4433
     { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[AVMEDIA_TYPE_AUDIO]}, "set the number of audio frames to record", "number" },
4434 4434
     { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", },
4435
-    { "ar", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" },
4436
-    { "ac", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_channels}, "set number of audio channels", "channels" },
4435
+    { "ar", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" },
4436
+    { "ac", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_channels}, "set number of audio channels", "channels" },
4437 4437
     { "an", OPT_BOOL | OPT_AUDIO, {(void*)&audio_disable}, "disable audio" },
4438 4438
     { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_codec}, "force audio codec ('copy' to copy stream)", "codec" },
4439
-    { "atag", OPT_FUNC2 | HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_codec_tag}, "force audio tag/fourcc", "fourcc/tag" },
4439
+    { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_codec_tag}, "force audio tag/fourcc", "fourcc/tag" },
4440 4440
     { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audio volume (256=normal)" , "volume" }, //
4441
-    { "newaudio", OPT_AUDIO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new audio stream to the current output stream" },
4441
+    { "newaudio", OPT_AUDIO, {(void*)opt_new_stream}, "add a new audio stream to the current output stream" },
4442 4442
     { "alang", HAS_ARG | OPT_STRING | OPT_AUDIO, {(void *)&audio_language}, "set the ISO 639 language code (3 letters) of the current audio stream" , "code" },
4443 4443
     { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_sample_fmt}, "set sample format, 'list' as argument shows all the sample formats supported", "format" },
4444 4444
 
4445 4445
     /* subtitle options */
4446 4446
     { "sn", OPT_BOOL | OPT_SUBTITLE, {(void*)&subtitle_disable}, "disable subtitle" },
4447 4447
     { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" },
4448
-    { "newsubtitle", OPT_SUBTITLE | OPT_FUNC2, {(void*)opt_new_stream}, "add a new subtitle stream to the current output stream" },
4448
+    { "newsubtitle", OPT_SUBTITLE, {(void*)opt_new_stream}, "add a new subtitle stream to the current output stream" },
4449 4449
     { "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language}, "set the ISO 639 language code (3 letters) of the current subtitle stream" , "code" },
4450
-    { "stag", OPT_FUNC2 | HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_codec_tag}, "force subtitle tag/fourcc", "fourcc/tag" },
4450
+    { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_codec_tag}, "force subtitle tag/fourcc", "fourcc/tag" },
4451 4451
 
4452 4452
     /* grab options */
4453
-    { "vc", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "set video grab channel (DV1394 only)", "channel" },
4453
+    { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "set video grab channel (DV1394 only)", "channel" },
4454 4454
     { "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_standard}, "set television standard (NTSC, PAL (SECAM))", "standard" },
4455 4455
     { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {(void*)&input_sync}, "sync read on input", "" },
4456 4456
 
... ...
@@ -4458,18 +4473,18 @@ static const OptionDef options[] = {
4458 4458
     { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_max_delay}, "set the maximum demux-decode delay", "seconds" },
4459 4459
     { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_preload}, "set the initial demux-decode delay", "seconds" },
4460 4460
 
4461
-    { "absf", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
4462
-    { "vbsf", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
4463
-    { "sbsf", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
4461
+    { "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
4462
+    { "vbsf", HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
4463
+    { "sbsf", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
4464 4464
 
4465
-    { "apre", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_preset}, "set the audio options to the indicated preset", "preset" },
4466
-    { "vpre", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "set the video options to the indicated preset", "preset" },
4467
-    { "spre", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "set the subtitle options to the indicated preset", "preset" },
4468
-    { "fpre", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_preset}, "set options from indicated preset file", "filename" },
4465
+    { "apre", HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_preset}, "set the audio options to the indicated preset", "preset" },
4466
+    { "vpre", HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "set the video options to the indicated preset", "preset" },
4467
+    { "spre", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "set the subtitle options to the indicated preset", "preset" },
4468
+    { "fpre", HAS_ARG | OPT_EXPERT, {(void*)opt_preset}, "set options from indicated preset file", "filename" },
4469 4469
     /* data codec support */
4470 4470
     { "dcodec", HAS_ARG | OPT_DATA, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },
4471 4471
 
4472
-    { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
4472
+    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
4473 4473
     { NULL, },
4474 4474
 };
4475 4475
 
... ...
@@ -2817,16 +2817,17 @@ static void event_loop(void)
2817 2817
     }
2818 2818
 }
2819 2819
 
2820
-static void opt_frame_size(const char *arg)
2820
+static int opt_frame_size(const char *opt, const char *arg)
2821 2821
 {
2822 2822
     if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
2823 2823
         fprintf(stderr, "Incorrect frame size\n");
2824
-        exit(1);
2824
+        return AVERROR(EINVAL);
2825 2825
     }
2826 2826
     if ((frame_width % 2) != 0 || (frame_height % 2) != 0) {
2827 2827
         fprintf(stderr, "Frame size must be a multiple of 2\n");
2828
-        exit(1);
2828
+        return AVERROR(EINVAL);
2829 2829
     }
2830
+    return 0;
2830 2831
 }
2831 2832
 
2832 2833
 static int opt_width(const char *opt, const char *arg)
... ...
@@ -2841,18 +2842,20 @@ static int opt_height(const char *opt, const char *arg)
2841 2841
     return 0;
2842 2842
 }
2843 2843
 
2844
-static void opt_format(const char *arg)
2844
+static int opt_format(const char *opt, const char *arg)
2845 2845
 {
2846 2846
     file_iformat = av_find_input_format(arg);
2847 2847
     if (!file_iformat) {
2848 2848
         fprintf(stderr, "Unknown input format: %s\n", arg);
2849
-        exit(1);
2849
+        return AVERROR(EINVAL);
2850 2850
     }
2851
+    return 0;
2851 2852
 }
2852 2853
 
2853
-static void opt_frame_pix_fmt(const char *arg)
2854
+static int opt_frame_pix_fmt(const char *opt, const char *arg)
2854 2855
 {
2855 2856
     frame_pix_fmt = av_get_pix_fmt(arg);
2857
+    return 0;
2856 2858
 }
2857 2859
 
2858 2860
 static int opt_sync(const char *opt, const char *arg)
... ...
@@ -2915,8 +2918,8 @@ static int opt_show_mode(const char *opt, const char *arg)
2915 2915
 
2916 2916
 static const OptionDef options[] = {
2917 2917
 #include "cmdutils_common_opts.h"
2918
-    { "x", HAS_ARG | OPT_FUNC2, {(void*)opt_width}, "force displayed width", "width" },
2919
-    { "y", HAS_ARG | OPT_FUNC2, {(void*)opt_height}, "force displayed height", "height" },
2918
+    { "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
2919
+    { "y", HAS_ARG, {(void*)opt_height}, "force displayed height", "height" },
2920 2920
     { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
2921 2921
     { "fs", OPT_BOOL, {(void*)&is_full_screen}, "force full screen" },
2922 2922
     { "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
... ...
@@ -2924,16 +2927,16 @@ static const OptionDef options[] = {
2924 2924
     { "ast", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_AUDIO]}, "select desired audio stream", "stream_number" },
2925 2925
     { "vst", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_VIDEO]}, "select desired video stream", "stream_number" },
2926 2926
     { "sst", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_stream[AVMEDIA_TYPE_SUBTITLE]}, "select desired subtitle stream", "stream_number" },
2927
-    { "ss", HAS_ARG | OPT_FUNC2, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
2928
-    { "t", HAS_ARG | OPT_FUNC2, {(void*)&opt_duration}, "play  \"duration\" seconds of audio/video", "duration" },
2927
+    { "ss", HAS_ARG, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
2928
+    { "t", HAS_ARG, {(void*)&opt_duration}, "play  \"duration\" seconds of audio/video", "duration" },
2929 2929
     { "bytes", OPT_INT | HAS_ARG, {(void*)&seek_by_bytes}, "seek by bytes 0=off 1=on -1=auto", "val" },
2930 2930
     { "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
2931 2931
     { "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
2932 2932
     { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format", "format" },
2933 2933
     { "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
2934
-    { "debug", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
2934
+    { "debug", HAS_ARG | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
2935 2935
     { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" },
2936
-    { "vismv", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
2936
+    { "vismv", HAS_ARG | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
2937 2937
     { "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" },
2938 2938
     { "genpts", OPT_BOOL | OPT_EXPERT, {(void*)&genpts}, "generate pts", "" },
2939 2939
     { "drp", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&decoder_reorder_pts}, "let decoder reorder pts 0=off 1=on -1=auto", ""},
... ...
@@ -2944,8 +2947,8 @@ static const OptionDef options[] = {
2944 2944
     { "idct", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&idct}, "set idct algo",  "algo" },
2945 2945
     { "er", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_recognition}, "set error detection threshold (0-4)",  "threshold" },
2946 2946
     { "ec", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_concealment}, "set error concealment options",  "bit_mask" },
2947
-    { "sync", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
2948
-    { "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
2947
+    { "sync", HAS_ARG | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
2948
+    { "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
2949 2949
     { "autoexit", OPT_BOOL | OPT_EXPERT, {(void*)&autoexit}, "exit at the end", "" },
2950 2950
     { "exitonkeydown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_keydown}, "exit on key down", "" },
2951 2951
     { "exitonmousedown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_mousedown}, "exit on mouse down", "" },
... ...
@@ -2956,8 +2959,8 @@ static const OptionDef options[] = {
2956 2956
     { "vf", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter list" },
2957 2957
 #endif
2958 2958
     { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, {(void*)&rdftspeed}, "rdft speed", "msecs" },
2959
-    { "showmode", HAS_ARG | OPT_FUNC2, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
2960
-    { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
2959
+    { "showmode", HAS_ARG, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
2960
+    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
2961 2961
     { "i", OPT_DUMMY, {NULL}, "ffmpeg compatibility dummy option", ""},
2962 2962
     { NULL, },
2963 2963
 };
... ...
@@ -329,13 +329,14 @@ static void show_usage(void)
329 329
     printf("\n");
330 330
 }
331 331
 
332
-static void opt_format(const char *arg)
332
+static int opt_format(const char *opt, const char *arg)
333 333
 {
334 334
     iformat = av_find_input_format(arg);
335 335
     if (!iformat) {
336 336
         fprintf(stderr, "Unknown input format: %s\n", arg);
337
-        exit(1);
337
+        return AVERROR(EINVAL);
338 338
     }
339
+    return 0;
339 340
 }
340 341
 
341 342
 static void opt_input_file(const char *arg)
... ...
@@ -382,7 +383,7 @@ static const OptionDef options[] = {
382 382
     { "show_format",  OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
383 383
     { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
384 384
     { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },
385
-    { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
385
+    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
386 386
     { NULL, },
387 387
 };
388 388