Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(821)

Side by Side Diff: patched-ffmpeg-mt/cmdutils.c

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Various utilities for command line tools 2 * Various utilities for command line tools
3 * Copyright (c) 2000-2003 Fabrice Bellard 3 * Copyright (c) 2000-2003 Fabrice Bellard
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 17 matching lines...) Expand all
28 Studio) will not omit unused inline functions and create undefined 28 Studio) will not omit unused inline functions and create undefined
29 references to libraries that are not being built. */ 29 references to libraries that are not being built. */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "libavformat/avformat.h" 32 #include "libavformat/avformat.h"
33 #include "libavfilter/avfilter.h" 33 #include "libavfilter/avfilter.h"
34 #include "libavdevice/avdevice.h" 34 #include "libavdevice/avdevice.h"
35 #include "libswscale/swscale.h" 35 #include "libswscale/swscale.h"
36 #include "libpostproc/postprocess.h" 36 #include "libpostproc/postprocess.h"
37 #include "libavutil/avstring.h" 37 #include "libavutil/avstring.h"
38 #include "libavutil/pixdesc.h"
38 #include "libavcodec/opt.h" 39 #include "libavcodec/opt.h"
39 #include "cmdutils.h" 40 #include "cmdutils.h"
40 #include "version.h" 41 #include "version.h"
41 #if CONFIG_NETWORK 42 #if CONFIG_NETWORK
42 #include "libavformat/network.h" 43 #include "libavformat/network.h"
43 #endif 44 #endif
44 #if HAVE_SYS_RESOURCE_H 45 #if HAVE_SYS_RESOURCE_H
45 #include <sys/resource.h> 46 #include <sys/resource.h>
46 #endif 47 #endif
47 48
48 #undef exit
49
50 const char **opt_names; 49 const char **opt_names;
51 static int opt_name_count; 50 static int opt_name_count;
52 AVCodecContext *avcodec_opts[CODEC_TYPE_NB]; 51 AVCodecContext *avcodec_opts[CODEC_TYPE_NB];
53 AVFormatContext *avformat_opts; 52 AVFormatContext *avformat_opts;
54 struct SwsContext *sws_opts; 53 struct SwsContext *sws_opts;
55 54
56 const int this_year = 2010; 55 const int this_year = 2010;
57 56
58 double parse_number_or_die(const char *context, const char *numstr, int type, do uble min, double max) 57 double parse_number_or_die(const char *context, const char *numstr, int type, do uble min, double max)
59 { 58 {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 *po->u.str_arg = str; 162 *po->u.str_arg = str;
164 } else if (po->flags & OPT_BOOL) { 163 } else if (po->flags & OPT_BOOL) {
165 *po->u.int_arg = bool_val; 164 *po->u.int_arg = bool_val;
166 } else if (po->flags & OPT_INT) { 165 } else if (po->flags & OPT_INT) {
167 *po->u.int_arg = parse_number_or_die(opt, arg, OPT_INT64, INT_MI N, INT_MAX); 166 *po->u.int_arg = parse_number_or_die(opt, arg, OPT_INT64, INT_MI N, INT_MAX);
168 } else if (po->flags & OPT_INT64) { 167 } else if (po->flags & OPT_INT64) {
169 *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT6 4_MIN, INT64_MAX); 168 *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT6 4_MIN, INT64_MAX);
170 } else if (po->flags & OPT_FLOAT) { 169 } else if (po->flags & OPT_FLOAT) {
171 *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -1.0 /0.0, 1.0/0.0); 170 *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -1.0 /0.0, 1.0/0.0);
172 } else if (po->flags & OPT_FUNC2) { 171 } else if (po->flags & OPT_FUNC2) {
173 if(po->u.func2_arg(opt, arg)<0) 172 if (po->u.func2_arg(opt, arg) < 0) {
174 goto unknown_opt; 173 fprintf(stderr, "%s: invalid value '%s' for option '%s'\n", argv[0], arg, opt);
174 exit(1);
175 }
175 } else { 176 } else {
176 po->u.func_arg(arg); 177 po->u.func_arg(arg);
177 } 178 }
178 if(po->flags & OPT_EXIT) 179 if(po->flags & OPT_EXIT)
179 exit(0); 180 exit(0);
180 } else { 181 } else {
181 if (parse_arg_function) 182 if (parse_arg_function)
182 parse_arg_function(opt); 183 parse_arg_function(opt);
183 } 184 }
184 } 185 }
185 } 186 }
186 187
187 int opt_default(const char *opt, const char *arg){ 188 int opt_default(const char *opt, const char *arg){
188 int type; 189 int type;
189 int ret= 0; 190 int ret= 0;
190 const AVOption *o= NULL; 191 const AVOption *o= NULL;
191 int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT _FLAG_SUBTITLE_PARAM, 0}; 192 int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT _FLAG_SUBTITLE_PARAM, 0};
192 193
193 for(type=0; type<CODEC_TYPE_NB && ret>= 0; type++){ 194 for(type=0; type<CODEC_TYPE_NB && ret>= 0; type++){
194 const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[t ype], opt_types[type]); 195 const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[t ype], opt_types[type]);
195 if(o2) 196 if(o2)
196 ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); 197 ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
197 } 198 }
198 if(!o) 199 if(!o)
199 ret = av_set_string3(avformat_opts, opt, arg, 1, &o); 200 ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
200 if(!o) 201 if(!o && sws_opts)
201 ret = av_set_string3(sws_opts, opt, arg, 1, &o); 202 ret = av_set_string3(sws_opts, opt, arg, 1, &o);
202 if(!o){ 203 if(!o){
203 if(opt[0] == 'a') 204 if(opt[0] == 'a')
204 ret = av_set_string3(avcodec_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1, &o); 205 ret = av_set_string3(avcodec_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1, &o);
205 else if(opt[0] == 'v') 206 else if(opt[0] == 'v')
206 ret = av_set_string3(avcodec_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1, &o); 207 ret = av_set_string3(avcodec_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1, &o);
207 else if(opt[0] == 's') 208 else if(opt[0] == 's')
208 ret = av_set_string3(avcodec_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1, &o); 209 ret = av_set_string3(avcodec_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1, &o);
209 } 210 }
210 if (o && ret < 0) { 211 if (o && ret < 0) {
211 fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); 212 fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
212 exit(1); 213 exit(1);
213 } 214 }
214 if(!o) 215 if (!o) {
215 return -1; 216 fprintf(stderr, "Unrecognized option '%s'\n", opt);
217 exit(1);
218 }
216 219
217 // av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(av codec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL)); 220 // av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(av codec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL));
218 221
219 //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 222 //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
220 opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); 223 opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
221 opt_names[opt_name_count++]= o->name; 224 opt_names[opt_name_count++]= o->name;
222 225
223 if(avcodec_opts[0]->debug || avformat_opts->debug) 226 if(avcodec_opts[0]->debug || avformat_opts->debug)
224 av_log_set_level(AV_LOG_DEBUG); 227 av_log_set_level(AV_LOG_DEBUG);
225 return 0; 228 return 0;
(...skipping 29 matching lines...) Expand all
255 for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) 258 for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
256 fprintf(stderr, "\"%s\"\n", log_levels[i].name); 259 fprintf(stderr, "\"%s\"\n", log_levels[i].name);
257 exit(1); 260 exit(1);
258 } 261 }
259 av_log_set_level(level); 262 av_log_set_level(level);
260 return 0; 263 return 0;
261 } 264 }
262 265
263 int opt_timelimit(const char *opt, const char *arg) 266 int opt_timelimit(const char *opt, const char *arg)
264 { 267 {
265 #if HAVE_SYS_RESOURCE_H 268 #if HAVE_SETRLIMIT
266 int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); 269 int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
267 struct rlimit rl = { lim, lim + 1 }; 270 struct rlimit rl = { lim, lim + 1 };
268 if (setrlimit(RLIMIT_CPU, &rl)) 271 if (setrlimit(RLIMIT_CPU, &rl))
269 perror("setrlimit"); 272 perror("setrlimit");
270 #else 273 #else
271 fprintf(stderr, "Warning: -%s not implemented on this OS\n", opt); 274 fprintf(stderr, "Warning: -%s not implemented on this OS\n", opt);
272 #endif 275 #endif
273 return 0; 276 return 0;
274 } 277 }
275 278
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 362 }
360 } 363 }
361 364
362 #define PRINT_LIB_CONFIG(lib, tag, cfg) do { \ 365 #define PRINT_LIB_CONFIG(lib, tag, cfg) do { \
363 if (CONFIG_##lib) \ 366 if (CONFIG_##lib) \
364 maybe_print_config(tag, cfg); \ 367 maybe_print_config(tag, cfg); \
365 } while (0) 368 } while (0)
366 369
367 void show_banner(void) 370 void show_banner(void)
368 { 371 {
369 fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d Fabrice Bellard, et al.\n", 372 fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmp eg developers\n",
370 program_name, program_birth_year, this_year); 373 program_name, program_birth_year, this_year);
371 fprintf(stderr, " built on %s %s with %s %s\n", 374 fprintf(stderr, " built on %s %s with %s %s\n",
372 __DATE__, __TIME__, CC_TYPE, CC_VERSION); 375 __DATE__, __TIME__, CC_TYPE, CC_VERSION);
373 fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n"); 376 fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n");
374 PRINT_LIB_CONFIG(AVUTIL, "libavutil", avutil_configuration()); 377 PRINT_LIB_CONFIG(AVUTIL, "libavutil", avutil_configuration());
375 PRINT_LIB_CONFIG(AVCODEC, "libavcodec", avcodec_configuration()); 378 PRINT_LIB_CONFIG(AVCODEC, "libavcodec", avcodec_configuration());
376 PRINT_LIB_CONFIG(AVFORMAT, "libavformat", avformat_configuration()); 379 PRINT_LIB_CONFIG(AVFORMAT, "libavformat", avformat_configuration());
377 PRINT_LIB_CONFIG(AVDEVICE, "libavdevice", avdevice_configuration()); 380 PRINT_LIB_CONFIG(AVDEVICE, "libavdevice", avdevice_configuration());
378 PRINT_LIB_CONFIG(AVFILTER, "libavfilter", avfilter_configuration()); 381 PRINT_LIB_CONFIG(AVFILTER, "libavfilter", avfilter_configuration());
379 PRINT_LIB_CONFIG(SWSCALE, "libswscale", swscale_configuration()); 382 PRINT_LIB_CONFIG(SWSCALE, "libswscale", swscale_configuration());
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 621
619 printf("Filters:\n"); 622 printf("Filters:\n");
620 #if CONFIG_AVFILTER 623 #if CONFIG_AVFILTER
621 while ((filter = av_filter_next(filter)) && *filter) 624 while ((filter = av_filter_next(filter)) && *filter)
622 printf("%-16s %s\n", (*filter)->name, (*filter)->description); 625 printf("%-16s %s\n", (*filter)->name, (*filter)->description);
623 #endif 626 #endif
624 } 627 }
625 628
626 void show_pix_fmts(void) 629 void show_pix_fmts(void)
627 { 630 {
628 list_fmts(avcodec_pix_fmt_string, PIX_FMT_NB); 631 enum PixelFormat pix_fmt;
632
633 printf(
634 "Pixel formats:\n"
635 "I.... = Supported Input format for conversion\n"
636 ".O... = Supported Output format for conversion\n"
637 "..H.. = Hardware accelerated format\n"
638 "...P. = Paletted format\n"
639 "....B = Bitstream format\n"
640 "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
641 "-----\n");
642
643 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) {
644 const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt];
645 printf("%c%c%c%c%c %-16s %d %2d\n",
646 sws_isSupportedInput (pix_fmt) ? 'I' : '.',
647 sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
648 pix_desc->flags & PIX_FMT_HWACCEL ? 'H' : '.',
649 pix_desc->flags & PIX_FMT_PAL ? 'P' : '.',
650 pix_desc->flags & PIX_FMT_BITSTREAM ? 'B' : '.',
651 pix_desc->name,
652 pix_desc->nb_components,
653 av_get_bits_per_pixel(pix_desc));
654 }
629 } 655 }
630 656
631 int read_yesno(void) 657 int read_yesno(void)
632 { 658 {
633 int c = getchar(); 659 int c = getchar();
634 int yesno = (toupper(c) == 'Y'); 660 int yesno = (toupper(c) == 'Y');
635 661
636 while (c != '\n' && c != EOF) 662 while (c != '\n' && c != EOF)
637 c = getchar(); 663 c = getchar();
638 664
639 return yesno; 665 return yesno;
640 } 666 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698