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];
377 if (!(p = strchr(opt,
':')))
378 p = opt + strlen(opt);
379 av_strlcpy(opt_stripped, opt,
FFMIN(
sizeof(opt_stripped), p - opt + 1));
383 ((opt[0] ==
'v' || opt[0] ==
'a' || opt[0] ==
's') &&
409 const struct {
const char *
name;
int level; } log_levels[] = {
424 if (!strcmp(log_levels[i].
name, arg)) {
430 level = strtol(arg, &tail, 10);
433 "Possible levels are numbers or:\n", arg);
446 struct rlimit rl = { lim, lim + 1 };
447 if (setrlimit(RLIMIT_CPU, &rl))
458 const char *errbuf_ptr = errbuf;
470 #define SHOW_VERSION 2
471 #define SHOW_CONFIG 4
473 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \
474 if (CONFIG_##LIBNAME) { \
475 const char *indent = flags & INDENT? " " : ""; \
476 if (flags & SHOW_VERSION) { \
477 unsigned int version = libname##_version(); \
478 av_log(NULL, level, "%slib%-9s %2d.%3d.%2d / %2d.%3d.%2d\n",\
480 LIB##LIBNAME##_VERSION_MAJOR, \
481 LIB##LIBNAME##_VERSION_MINOR, \
482 LIB##LIBNAME##_VERSION_MICRO, \
483 version >> 16, version >> 8 & 0xff, version & 0xff); \
485 if (flags & SHOW_CONFIG) { \
486 const char *cfg = libname##_configuration(); \
487 if (strcmp(LIBAV_CONFIGURATION, cfg)) { \
489 av_log(NULL, level, \
490 "%sWARNING: library configuration mismatch\n", \
494 av_log(NULL, level, "%s%-11s configuration: %s\n", \
495 indent, #libname, cfg); \
516 "%s version " LIBAV_VERSION ", Copyright (c) %d-%d the Libav developers\n",
535 "This version of %s has nonfree parts compiled in.\n"
536 "Therefore it is not legally redistributable.\n",
539 "%s is free software; you can redistribute it and/or modify\n"
540 "it under the terms of the GNU General Public License as published by\n"
541 "the Free Software Foundation; either version 3 of the License, or\n"
542 "(at your option) any later version.\n"
544 "%s is distributed in the hope that it will be useful,\n"
545 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
546 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
547 "GNU General Public License for more details.\n"
549 "You should have received a copy of the GNU General Public License\n"
550 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
553 "%s is free software; you can redistribute it and/or modify\n"
554 "it under the terms of the GNU General Public License as published by\n"
555 "the Free Software Foundation; either version 2 of the License, or\n"
556 "(at your option) any later version.\n"
558 "%s is distributed in the hope that it will be useful,\n"
559 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
560 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
561 "GNU General Public License for more details.\n"
563 "You should have received a copy of the GNU General Public License\n"
564 "along with %s; if not, write to the Free Software\n"
565 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
568 "%s is free software; you can redistribute it and/or modify\n"
569 "it under the terms of the GNU Lesser General Public License as published by\n"
570 "the Free Software Foundation; either version 3 of the License, or\n"
571 "(at your option) any later version.\n"
573 "%s is distributed in the hope that it will be useful,\n"
574 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
575 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
576 "GNU Lesser General Public License for more details.\n"
578 "You should have received a copy of the GNU Lesser General Public License\n"
579 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
582 "%s is free software; you can redistribute it and/or\n"
583 "modify it under the terms of the GNU Lesser General Public\n"
584 "License as published by the Free Software Foundation; either\n"
585 "version 2.1 of the License, or (at your option) any later version.\n"
587 "%s is distributed in the hope that it will be useful,\n"
588 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
589 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
590 "Lesser General Public License for more details.\n"
592 "You should have received a copy of the GNU Lesser General Public\n"
593 "License along with %s; if not, write to the Free Software\n"
594 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
604 const char *last_name;
607 " D. = Demuxing supported\n"
608 " .E = Muxing supported\n"
615 const char *long_name =
NULL;
618 if ((name ==
NULL || strcmp(ofmt->
name, name) < 0) &&
619 strcmp(ofmt->
name, last_name) > 0) {
626 if ((name ==
NULL || strcmp(ifmt->
name, name) < 0) &&
627 strcmp(ifmt->
name, last_name) > 0) {
632 if (name && strcmp(ifmt->
name, name) == 0)
639 printf(
" %s%s %-15s %s\n",
643 long_name ? long_name:
" ");
650 const char *last_name;
652 " D..... = Decoding supported\n"
653 " .E.... = Encoding supported\n"
654 " ..V... = Video codec\n"
655 " ..A... = Audio codec\n"
656 " ..S... = Subtitle codec\n"
657 " ...S.. = Supports draw_horiz_band\n"
658 " ....D. = Supports direct rendering method 1\n"
659 " .....T = Supports weird frame truncation\n"
666 const char *type_str;
670 if ((p2 ==
NULL || strcmp(p->
name, p2->name) < 0) &&
671 strcmp(p->
name, last_name) > 0) {
673 decode = encode = cap = 0;
675 if (p2 && strcmp(p->
name, p2->name) == 0) {
685 last_name = p2->name;
701 printf(
" %s%s%s%s%s%s %-15s %s",
702 decode ?
"D" : (
" "),
709 p2->long_name ? p2->long_name :
"");
711 if (p2->decoder && decode == 0)
712 printf(
" use %s for decoding", p2->decoder->name);
717 printf(
"Note, the names of encoders and decoders do not always match, so there are\n"
718 "several cases where the above table shows encoder only or decoder only entries\n"
719 "even though both encoding and decoding are supported. For example, the h263\n"
720 "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
728 printf(
"Bitstream filters:\n");
739 printf(
"Supported file protocols:\n"
755 printf(
"%-16s %s\n", (*filter)->name, (*filter)->description);
764 "I.... = Supported Input format for conversion\n"
765 ".O... = Supported Output format for conversion\n"
766 "..H.. = Hardware accelerated format\n"
767 "...P. = Paletted format\n"
768 "....B = Bitstream format\n"
769 "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
773 # define sws_isSupportedInput(x) 0
774 # define sws_isSupportedOutput(x) 0
777 for (pix_fmt = 0; pix_fmt <
PIX_FMT_NB; pix_fmt++) {
779 printf(
"%c%c%c%c%c %-16s %d %2d\n",
803 int yesno = (toupper(c) ==
'Y');
805 while (c !=
'\n' && c != EOF)
814 FILE *
f = fopen(filename,
"rb");
821 fseek(f, 0, SEEK_END);
823 fseek(f, 0, SEEK_SET);
830 ret = fread(*bufptr, 1, *size, f);
835 filename, strerror(errno));
841 (*bufptr)[*size++] =
'\0';
877 const char *preset_name,
int is_path,
878 const char *codec_name)
882 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
887 av_strlcpy(filename, preset_name, filename_size);
888 f = fopen(filename,
"r");
890 for (i = 0; i < 3 && !
f; i++) {
893 snprintf(filename, filename_size,
"%s%s/%s.avpreset", base[i],
894 i != 1 ?
"" :
"/.avconv", preset_name);
895 f = fopen(filename,
"r");
896 if (!f && codec_name) {
897 snprintf(filename, filename_size,
898 "%s%s/%s-%s.avpreset",
899 base[i], i != 1 ?
"" :
"/.avconv", codec_name,
901 f = fopen(filename,
"r");
911 if (*spec <= '9' && *spec >=
'0')
912 return strtol(spec,
NULL, 0) == st->
index;
913 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
926 if (*spec++ ==
':') {
930 return i == st->
index;
934 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
938 prog_id = strtol(spec, &endptr, 0);
943 if (*endptr++ ==
':') {
944 int stream_idx = strtol(endptr,
NULL, 0);
945 return stream_idx >= 0 &&
977 switch (codec->
type) {
993 char *p = strchr(t->
key,
':');
998 case 1: *p = 0;
break;
1000 default:
return NULL;
1008 else if (t->
key[0] == prefix &&
1030 "Could not alloc memory for stream options.\n");
1041 static int avsink_init(
AVFilterContext *ctx,
const char *args,
void *opaque)
1066 .
init = avsink_init,
1088 *picref_ptr = picref;
1092 memcpy(frame->
data, picref->
data,
sizeof(frame->
data));
1107 if (new_size >= INT_MAX / elem_size) {
1111 if (*size < new_size) {
1112 uint8_t *tmp =
av_realloc(array, new_size*elem_size);
1117 memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);