51 #if HAVE_SYS_RESOURCE_H
52 #include <sys/resource.h>
80 vfprintf(stdout, fmt, vl);
84 double min,
double max)
90 error =
"Expected number for %s but found: %s\n";
91 else if (d < min || d > max)
92 error =
"The value for %s was %s which is not within %f - %f\n";
93 else if (type ==
OPT_INT64 && (int64_t)d != d)
94 error =
"Expected int64 for %s but found %s\n";
95 else if (type ==
OPT_INT && (
int)d != d)
96 error =
"Expected int for %s but found %s\n";
110 is_duration ?
"duration" :
"date", context, timestr);
123 for (po = options; po->
name !=
NULL; po++) {
125 if ((po->
flags & mask) == value) {
152 const char *p = strchr(name,
':');
153 int len = p ? p - name : strlen(name);
156 if (!strncmp(name, po->
name, len) && strlen(po->
name) == len)
163 #if defined(_WIN32) && !defined(__MINGW32CE__)
166 static char** win32_argv_utf8 =
NULL;
167 static int win32_argc = 0;
180 int i, buffsize = 0, offset = 0;
182 if (win32_argv_utf8) {
183 *argc_ptr = win32_argc;
184 *argv_ptr = win32_argv_utf8;
189 argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc);
190 if (win32_argc <= 0 || !argv_w)
194 for (i = 0; i < win32_argc; i++)
195 buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
198 win32_argv_utf8 =
av_mallocz(
sizeof(
char *) * (win32_argc + 1) + buffsize);
199 argstr_flat = (
char *)win32_argv_utf8 +
sizeof(
char *) * (win32_argc + 1);
200 if (win32_argv_utf8 ==
NULL) {
205 for (i = 0; i < win32_argc; i++) {
206 win32_argv_utf8[i] = &argstr_flat[offset];
207 offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
208 &argstr_flat[offset],
211 win32_argv_utf8[i] =
NULL;
214 *argc_ptr = win32_argc;
215 *argv_ptr = win32_argv_utf8;
233 if (!po->
name && opt[0] ==
'n' && opt[1] ==
'o') {
259 char *p = strchr(opt,
':');
261 dstcount = (
int *)(so + 1);
262 *so =
grow_array(*so,
sizeof(**so), dstcount, *dstcount + 1);
263 (*so)[*dstcount - 1].specifier =
av_strdup(p ? p + 1 :
"");
264 dst = &(*so)[*dstcount - 1].u;
272 *(
int *)dst = bool_val;
288 "Failed to set value '%s' for option '%s'\n", arg, opt);
298 void (*parse_arg_function)(
void *,
const char*))
301 int optindex, handleoptions = 1, ret;
308 while (optindex < argc) {
309 opt = argv[optindex++];
311 if (handleoptions && opt[0] ==
'-' && opt[1] !=
'\0') {
312 if (opt[1] ==
'-' && opt[2] ==
'\0') {
318 if ((ret =
parse_option(optctx, opt, argv[optindex], options)) < 0)
322 if (parse_arg_function)
323 parse_arg_function(optctx, opt);
337 for (i = 1; i < argc; i++) {
338 const char *cur_opt = argv[i];
340 if (*cur_opt++ !=
'-')
344 if (!po->
name && cur_opt[0] ==
'n' && cur_opt[1] ==
'o')
347 if ((!po->
name && !strcmp(cur_opt, optname)) ||
348 (po->
name && !strcmp(optname, po->
name)))
362 if (idx && argv[idx + 1])
366 #define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
370 char opt_stripped[128];
374 if (!(p = strchr(opt,
':')))
375 p = opt + strlen(opt);
376 av_strlcpy(opt_stripped, opt,
FFMIN(
sizeof(opt_stripped), p - opt + 1));
380 ((opt[0] ==
'v' || opt[0] ==
'a' || opt[0] ==
's') &&
404 const struct {
const char *
name;
int level; } log_levels[] = {
419 if (!strcmp(log_levels[i].
name, arg)) {
425 level = strtol(arg, &tail, 10);
428 "Possible levels are numbers or:\n", arg);
441 struct rlimit rl = { lim, lim + 1 };
442 if (setrlimit(RLIMIT_CPU, &rl))
453 const char *errbuf_ptr = errbuf;
465 #define SHOW_VERSION 2
466 #define SHOW_CONFIG 4
468 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \
469 if (CONFIG_##LIBNAME) { \
470 const char *indent = flags & INDENT? " " : ""; \
471 if (flags & SHOW_VERSION) { \
472 unsigned int version = libname##_version(); \
473 av_log(NULL, level, "%slib%-9s %2d.%3d.%2d / %2d.%3d.%2d\n",\
475 LIB##LIBNAME##_VERSION_MAJOR, \
476 LIB##LIBNAME##_VERSION_MINOR, \
477 LIB##LIBNAME##_VERSION_MICRO, \
478 version >> 16, version >> 8 & 0xff, version & 0xff); \
480 if (flags & SHOW_CONFIG) { \
481 const char *cfg = libname##_configuration(); \
482 if (strcmp(LIBAV_CONFIGURATION, cfg)) { \
484 av_log(NULL, level, \
485 "%sWARNING: library configuration mismatch\n", \
489 av_log(NULL, level, "%s%-11s configuration: %s\n", \
490 indent, #libname, cfg); \
511 "%s version " LIBAV_VERSION ", Copyright (c) %d-%d the Libav developers\n",
530 "This version of %s has nonfree parts compiled in.\n"
531 "Therefore it is not legally redistributable.\n",
534 "%s is free software; you can redistribute it and/or modify\n"
535 "it under the terms of the GNU General Public License as published by\n"
536 "the Free Software Foundation; either version 3 of the License, or\n"
537 "(at your option) any later version.\n"
539 "%s is distributed in the hope that it will be useful,\n"
540 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
541 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
542 "GNU General Public License for more details.\n"
544 "You should have received a copy of the GNU General Public License\n"
545 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
548 "%s is free software; you can redistribute it and/or modify\n"
549 "it under the terms of the GNU General Public License as published by\n"
550 "the Free Software Foundation; either version 2 of the License, or\n"
551 "(at your option) any later version.\n"
553 "%s is distributed in the hope that it will be useful,\n"
554 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
555 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
556 "GNU General Public License for more details.\n"
558 "You should have received a copy of the GNU General Public License\n"
559 "along with %s; if not, write to the Free Software\n"
560 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
563 "%s is free software; you can redistribute it and/or modify\n"
564 "it under the terms of the GNU Lesser General Public License as published by\n"
565 "the Free Software Foundation; either version 3 of the License, or\n"
566 "(at your option) any later version.\n"
568 "%s is distributed in the hope that it will be useful,\n"
569 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
570 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
571 "GNU Lesser General Public License for more details.\n"
573 "You should have received a copy of the GNU Lesser General Public License\n"
574 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
577 "%s is free software; you can redistribute it and/or\n"
578 "modify it under the terms of the GNU Lesser General Public\n"
579 "License as published by the Free Software Foundation; either\n"
580 "version 2.1 of the License, or (at your option) any later version.\n"
582 "%s is distributed in the hope that it will be useful,\n"
583 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
584 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
585 "Lesser General Public License for more details.\n"
587 "You should have received a copy of the GNU Lesser General Public\n"
588 "License along with %s; if not, write to the Free Software\n"
589 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
599 const char *last_name;
602 " D. = Demuxing supported\n"
603 " .E = Muxing supported\n"
610 const char *long_name =
NULL;
613 if ((name ==
NULL || strcmp(ofmt->
name, name) < 0) &&
614 strcmp(ofmt->
name, last_name) > 0) {
621 if ((name ==
NULL || strcmp(ifmt->
name, name) < 0) &&
622 strcmp(ifmt->
name, last_name) > 0) {
627 if (name && strcmp(ifmt->
name, name) == 0)
634 printf(
" %s%s %-15s %s\n",
638 long_name ? long_name:
" ");
645 const char *last_name;
647 " D..... = Decoding supported\n"
648 " .E.... = Encoding supported\n"
649 " ..V... = Video codec\n"
650 " ..A... = Audio codec\n"
651 " ..S... = Subtitle codec\n"
652 " ...S.. = Supports draw_horiz_band\n"
653 " ....D. = Supports direct rendering method 1\n"
654 " .....T = Supports weird frame truncation\n"
661 const char *type_str;
665 if ((p2 ==
NULL || strcmp(p->
name, p2->name) < 0) &&
666 strcmp(p->
name, last_name) > 0) {
668 decode = encode = cap = 0;
670 if (p2 && strcmp(p->
name, p2->name) == 0) {
680 last_name = p2->name;
696 printf(
" %s%s%s%s%s%s %-15s %s",
697 decode ?
"D" : (
" "),
704 p2->long_name ? p2->long_name :
"");
706 if (p2->decoder && decode == 0)
707 printf(
" use %s for decoding", p2->decoder->name);
712 printf(
"Note, the names of encoders and decoders do not always match, so there are\n"
713 "several cases where the above table shows encoder only or decoder only entries\n"
714 "even though both encoding and decoding are supported. For example, the h263\n"
715 "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
723 printf(
"Bitstream filters:\n");
734 printf(
"Supported file protocols:\n"
750 printf(
"%-16s %s\n", (*filter)->name, (*filter)->description);
759 "I.... = Supported Input format for conversion\n"
760 ".O... = Supported Output format for conversion\n"
761 "..H.. = Hardware accelerated format\n"
762 "...P. = Paletted format\n"
763 "....B = Bitstream format\n"
764 "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
768 # define sws_isSupportedInput(x) 0
769 # define sws_isSupportedOutput(x) 0
772 for (pix_fmt = 0; pix_fmt <
PIX_FMT_NB; pix_fmt++) {
774 printf(
"%c%c%c%c%c %-16s %d %2d\n",
798 int yesno = (toupper(c) ==
'Y');
800 while (c !=
'\n' && c != EOF)
809 FILE *
f = fopen(filename,
"rb");
816 fseek(f, 0, SEEK_END);
818 fseek(f, 0, SEEK_SET);
825 ret = fread(*bufptr, 1, *size, f);
830 filename, strerror(errno));
836 (*bufptr)[*size++] =
'\0';
872 const char *preset_name,
int is_path,
873 const char *codec_name)
877 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
882 av_strlcpy(filename, preset_name, filename_size);
883 f = fopen(filename,
"r");
885 for (i = 0; i < 3 && !
f; i++) {
888 snprintf(filename, filename_size,
"%s%s/%s.avpreset", base[i],
889 i != 1 ?
"" :
"/.avconv", preset_name);
890 f = fopen(filename,
"r");
891 if (!f && codec_name) {
892 snprintf(filename, filename_size,
893 "%s%s/%s-%s.avpreset",
894 base[i], i != 1 ?
"" :
"/.avconv", codec_name,
896 f = fopen(filename,
"r");
906 if (*spec <= '9' && *spec >=
'0')
907 return strtol(spec,
NULL, 0) == st->
index;
908 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
921 if (*spec++ ==
':') {
925 return i == st->
index;
929 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
933 prog_id = strtol(spec, &endptr, 0);
938 if (*endptr++ ==
':') {
939 int stream_idx = strtol(endptr,
NULL, 0);
940 return stream_idx >= 0 &&
972 switch (codec->
type) {
988 char *p = strchr(t->
key,
':');
993 case 1: *p = 0;
break;
995 default:
return NULL;
1003 else if (t->
key[0] == prefix &&
1025 "Could not alloc memory for stream options.\n");
1036 static int avsink_init(
AVFilterContext *ctx,
const char *args,
void *opaque)
1061 .
init = avsink_init,
1083 *picref_ptr = picref;
1087 memcpy(frame->
data, picref->
data,
sizeof(frame->
data));
1102 if (new_size >= INT_MAX / elem_size) {
1106 if (*size < new_size) {
1107 uint8_t *tmp =
av_realloc(array, new_size*elem_size);
1112 memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);