~ubuntu-branches/ubuntu/precise/ffmpeg-debian/precise

« back to all changes in this revision

Viewing changes to cmdutils.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include "config.h"
32
32
#include "libavformat/avformat.h"
33
 
#ifdef CONFIG_AVFILTER
34
33
#include "libavfilter/avfilter.h"
35
 
#endif
36
34
#include "libavdevice/avdevice.h"
37
35
#include "libswscale/swscale.h"
38
 
#ifdef CONFIG_POSTPROC
39
36
#include "libpostproc/postprocess.h"
40
 
#endif
41
37
#include "libavutil/avstring.h"
42
38
#include "libavcodec/opt.h"
43
39
#include "cmdutils.h"
44
40
#include "version.h"
45
 
#ifdef CONFIG_NETWORK
46
41
#include "libavformat/network.h"
47
 
#endif
48
42
 
49
43
#undef exit
50
44
 
54
48
AVFormatContext *avformat_opts;
55
49
struct SwsContext *sws_opts;
56
50
 
 
51
const int this_year = 2009;
 
52
 
57
53
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
58
54
{
59
55
    char *tail;
127
123
        opt = argv[optindex++];
128
124
 
129
125
        if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
130
 
          if (opt[1] == '-' && opt[2] == '\0') {
131
 
            handleoptions = 0;
132
 
            continue;
133
 
          }
 
126
            if (opt[1] == '-' && opt[2] == '\0') {
 
127
                handleoptions = 0;
 
128
                continue;
 
129
            }
134
130
            po= find_option(options, opt + 1);
135
131
            if (!po->name)
136
132
                po= find_option(options, "default");
176
172
 
177
173
int opt_default(const char *opt, const char *arg){
178
174
    int type;
 
175
    int ret= 0;
179
176
    const AVOption *o= NULL;
180
177
    int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
181
178
 
182
 
    for(type=0; type<CODEC_TYPE_NB; type++){
 
179
    for(type=0; type<CODEC_TYPE_NB && ret>= 0; type++){
183
180
        const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
184
181
        if(o2)
185
 
            o = av_set_string2(avctx_opts[type], opt, arg, 1);
 
182
            ret = av_set_string3(avctx_opts[type], opt, arg, 1, &o);
186
183
    }
187
184
    if(!o)
188
 
        o = av_set_string2(avformat_opts, opt, arg, 1);
 
185
        ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
189
186
    if(!o)
190
 
        o = av_set_string2(sws_opts, opt, arg, 1);
 
187
        ret = av_set_string3(sws_opts, opt, arg, 1, &o);
191
188
    if(!o){
192
189
        if(opt[0] == 'a')
193
 
            o = av_set_string2(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1);
 
190
            ret = av_set_string3(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1, &o);
194
191
        else if(opt[0] == 'v')
195
 
            o = av_set_string2(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1);
 
192
            ret = av_set_string3(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1, &o);
196
193
        else if(opt[0] == 's')
197
 
            o = av_set_string2(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1);
 
194
            ret = av_set_string3(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1, &o);
 
195
    }
 
196
    if (o && ret < 0) {
 
197
        fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
 
198
        exit(1);
198
199
    }
199
200
    if(!o)
200
201
        return -1;
219
220
        const char *str= av_get_string(opts_ctx, opt_names[i], &opt, buf, sizeof(buf));
220
221
        /* if an option with name opt_names[i] is present in opts_ctx then str is non-NULL */
221
222
        if(str && ((opt->flags & flags) == flags))
222
 
            av_set_string2(ctx, opt_names[i], str, 1);
 
223
            av_set_string3(ctx, opt_names[i], str, 1, NULL);
223
224
    }
224
225
}
225
226
 
250
251
    case AVERROR(ENOENT):
251
252
        fprintf(stderr, "%s: no such file or directory\n", filename);
252
253
        break;
253
 
#ifdef CONFIG_NETWORK
 
254
#if CONFIG_NETWORK
254
255
    case AVERROR(FF_NETERROR(EPROTONOSUPPORT)):
255
256
        fprintf(stderr, "%s: Unsupported network protocol\n", filename);
256
257
        break;
274
275
    PRINT_LIB_VERSION(outstream, avcodec,  AVCODEC,  indent);
275
276
    PRINT_LIB_VERSION(outstream, avformat, AVFORMAT, indent);
276
277
    PRINT_LIB_VERSION(outstream, avdevice, AVDEVICE, indent);
277
 
#ifdef CONFIG_AVFILTER
 
278
#if CONFIG_AVFILTER
278
279
    PRINT_LIB_VERSION(outstream, avfilter, AVFILTER, indent);
279
280
#endif
280
 
#ifdef CONFIG_SWSCALE
 
281
#if CONFIG_SWSCALE
281
282
    PRINT_LIB_VERSION(outstream, swscale,  SWSCALE,  indent);
282
283
#endif
283
 
#ifdef CONFIG_POSTPROC
 
284
#if CONFIG_POSTPROC
284
285
    PRINT_LIB_VERSION(outstream, postproc, POSTPROC, indent);
285
286
#endif
286
287
}
287
288
 
288
289
void show_banner(void)
289
290
{
290
 
    fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-2008 Fabrice Bellard, et al.\n",
291
 
            program_name, program_birth_year);
 
291
    fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d Fabrice Bellard, et al.\n",
 
292
            program_name, program_birth_year, this_year);
292
293
    fprintf(stderr, "  configuration: " FFMPEG_CONFIGURATION "\n");
293
294
    print_all_lib_versions(stderr, 1);
294
295
    fprintf(stderr, "  built on " __DATE__ " " __TIME__);
306
307
 
307
308
void show_license(void)
308
309
{
309
 
#ifdef CONFIG_NONFREE
 
310
#if CONFIG_NONFREE
310
311
    printf(
311
312
    "This version of %s has nonfree parts compiled in.\n"
312
313
    "Therefore it is not legally redistributable.\n",