Unified · Split
| @@ -308,147 +308,7 @@ int opt_default(const char *opt, const char *arg) · 307 unmodified lines | |||
| 308 | fprintf(stderr, "Unrecognized option '%s'\n", opt); | 308 | fprintf(stderr, "Unrecognized option '%s'\n", opt); |
| 309 | return AVERROR_OPTION_NOT_FOUND; | 309 | return AVERROR_OPTION_NOT_FOUND; |
| 310 | } | 310 | } |
| 311 | #if 0 | ||
| 312 | <<<<<<< HEAD | ||
| 313 | int opt_default(const char *opt, const char *arg){ | ||
| 314 | int type; | ||
| 315 | int ret= 0; | ||
| 316 | const AVOption *o= NULL; | ||
| 317 | int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0}; | ||
| 318 | AVCodec *p = NULL; | ||
| 319 | AVOutputFormat *oformat = NULL; | ||
| 320 | AVInputFormat *iformat = NULL; | ||
| 321 | |||
| 322 | while ((p = av_codec_next(p))) { | ||
| 323 | const AVClass *c = p->priv_class; | ||
| 324 | if (c && av_find_opt(&c, opt, NULL, 0, 0)) | ||
| 325 | break; | ||
| 326 | } | ||
| 327 | if (p) | ||
| 328 | goto out; | ||
| 329 | while ((oformat = av_oformat_next(oformat))) { | ||
| 330 | const AVClass *c = oformat->priv_class; | ||
| 331 | if (c && av_find_opt(&c, opt, NULL, 0, 0)) | ||
| 332 | break; | ||
| 333 | } | ||
| 334 | if (oformat) | ||
| 335 | goto out; | ||
| 336 | while ((iformat = av_iformat_next(iformat))) { | ||
| 337 | const AVClass *c = iformat->priv_class; | ||
| 338 | if (c && av_find_opt(&c, opt, NULL, 0, 0)) | ||
| 339 | break; | ||
| 340 | } | ||
| 341 | if (iformat) | ||
| 342 | goto out; | ||
| 343 | |||
| 344 | for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){ | ||
| 345 | const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0); | ||
| 346 | if(o2) | ||
| 347 | ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); | ||
| 348 | } | ||
| 349 | if(!o && avformat_opts) | ||
| 350 | ret = av_set_string3(avformat_opts, opt, arg, 1, &o); | ||
| 351 | if(!o && sws_opts) | ||
| 352 | ret = av_set_string3(sws_opts, opt, arg, 1, &o); | ||
| 353 | if(!o){ | ||
| 354 | if (opt[0] == 'a' && avcodec_opts[AVMEDIA_TYPE_AUDIO]) | ||
| 355 | ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o); | ||
| 356 | else if(opt[0] == 'v' && avcodec_opts[AVMEDIA_TYPE_VIDEO]) | ||
| 357 | ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o); | ||
| 358 | else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE]) | ||
| 359 | ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o); | ||
| 360 | if (ret >= 0) | ||
| 361 | opt += 1; | ||
| 362 | } | ||
| 363 | if (o && ret < 0) { | ||
| 364 | fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); | ||
| 365 | exit(1); | ||
| 366 | } | ||
| 367 | if (!o) { | ||
| 368 | fprintf(stderr, "Unrecognized option '%s'\n", opt); | ||
| 369 | exit(1); | ||
| 370 | } | ||
| 371 | |||
| 372 | out: | ||
| 373 | if ((ret = opt_default2(opt, arg)) < 0) | ||
| 374 | return ret; | ||
| 375 | 311 | ||
| 376 | // 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)); | ||
| 377 | |||
| 378 | opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1)); | ||
| 379 | opt_values[opt_name_count] = av_strdup(arg); | ||
| 380 | opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); | ||
| 381 | opt_names[opt_name_count++] = av_strdup(opt); | ||
| 382 | |||
| 383 | if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug)) | ||
| 384 | av_log_set_level(AV_LOG_DEBUG); | ||
| 385 | return 0; | ||
| 386 | } | ||
| 387 | |||
| 388 | ||||||| merged common ancestors | ||
| 389 | int opt_default(const char *opt, const char *arg){ | ||
| 390 | int type; | ||
| 391 | int ret= 0; | ||
| 392 | const AVOption *o= NULL; | ||
| 393 | int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0}; | ||
| 394 | |||
| 395 | for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){ | ||
| 396 | const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0); | ||
| 397 | if(o2) | ||
| 398 | ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); | ||
| 399 | } | ||
| 400 | if(!o && avformat_opts) | ||
| 401 | ret = av_set_string3(avformat_opts, opt, arg, 1, &o); | ||
| 402 | if(!o && sws_opts) | ||
| 403 | ret = av_set_string3(sws_opts, opt, arg, 1, &o); | ||
| 404 | if(!o){ | ||
| 405 | if (opt[0] == 'a' && avcodec_opts[AVMEDIA_TYPE_AUDIO]) | ||
| 406 | ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o); | ||
| 407 | else if(opt[0] == 'v' && avcodec_opts[AVMEDIA_TYPE_VIDEO]) | ||
| 408 | ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o); | ||
| 409 | else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE]) | ||
| 410 | ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o); | ||
| 411 | } | ||
| 412 | if (o && ret < 0) { | ||
| 413 | fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); | ||
| 414 | exit(1); | ||
| 415 | } | ||
| 416 | if (!o) { | ||
| 417 | AVCodec *p = NULL; | ||
| 418 | AVOutputFormat *oformat = NULL; | ||
| 419 | while ((p=av_codec_next(p))){ | ||
| 420 | const AVClass *c = p->priv_class; | ||
| 421 | if(c && av_opt_find(&c, opt, NULL, 0, 0)) | ||
| 422 | break; | ||
| 423 | } | ||
| 424 | if (!p) { | ||
| 425 | while ((oformat = av_oformat_next(oformat))) { | ||
| 426 | const AVClass *c = oformat->priv_class; | ||
| 427 | if (c && av_opt_find(&c, opt, NULL, 0, 0)) | ||
| 428 | break; | ||
| 429 | } | ||
| 430 | } | ||
| 431 | } | ||
| 432 | |||
| 433 | if ((ret = opt_default2(opt, arg)) < 0) | ||
| 434 | return ret; | ||
| 435 | |||
| 436 | // 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)); | ||
| 437 | |||
| 438 | //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 | ||
| 439 | opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1)); | ||
| 440 | opt_values[opt_name_count]= o ? NULL : av_strdup(arg); | ||
| 441 | opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); | ||
| 442 | opt_names[opt_name_count++]= o ? o->name : av_strdup(opt); | ||
| 443 | |||
| 444 | if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug)) | ||
| 445 | av_log_set_level(AV_LOG_DEBUG); | ||
| 446 | return 0; | ||
| 447 | } | ||
| 448 | |||
| 449 | ======= | ||
| 450 | >>>>>>> qatar/master | ||
| 451 | #endif | ||
| 452 | int opt_loglevel(const char *opt, const char *arg) | 312 | int opt_loglevel(const char *opt, const char *arg) |
| 453 | { | 313 | { |
| 454 | const struct { const char *name; int level; } log_levels[] = { | 314 | const struct { const char *name; int level; } log_levels[] = { |