2 * Various utilities for command line tools
3 * Copyright (c) 2000-2003 Fabrice Bellard
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 /* Include only the enabled headers since some compilers (namely, Sun
28 Studio) will not omit unused inline functions and create undefined
29 references to libraries that are not being built. */
32 #include "compat/va_copy.h"
33 #include "libavformat/avformat.h"
34 #include "libavfilter/avfilter.h"
35 #include "libavdevice/avdevice.h"
36 #include "libavresample/avresample.h"
37 #include "libswscale/swscale.h"
38 #include "libswresample/swresample.h"
40 #include "libpostproc/postprocess.h"
42 #include "libavutil/avassert.h"
43 #include "libavutil/avstring.h"
44 #include "libavutil/mathematics.h"
45 #include "libavutil/imgutils.h"
46 #include "libavutil/parseutils.h"
47 #include "libavutil/pixdesc.h"
48 #include "libavutil/eval.h"
49 #include "libavutil/dict.h"
50 #include "libavutil/opt.h"
54 #include "libavformat/network.h"
56 #if HAVE_SYS_RESOURCE_H
57 #include <sys/resource.h>
60 struct SwsContext *sws_opts;
62 AVDictionary *format_opts, *codec_opts;
64 const int this_year = 2012;
66 static FILE *report_file;
72 sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
76 swr_opts = swr_alloc();
79 void uninit_opts(void)
82 sws_freeContext(sws_opts);
89 av_dict_free(&format_opts);
90 av_dict_free(&codec_opts);
93 void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
95 vfprintf(stdout, fmt, vl);
98 static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl)
102 static int print_prefix = 1;
105 av_log_default_callback(ptr, level, fmt, vl);
106 av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
108 fputs(line, report_file);
112 double parse_number_or_die(const char *context, const char *numstr, int type,
113 double min, double max)
117 double d = av_strtod(numstr, &tail);
119 error = "Expected number for %s but found: %s\n";
120 else if (d < min || d > max)
121 error = "The value for %s was %s which is not within %f - %f\n";
122 else if (type == OPT_INT64 && (int64_t)d != d)
123 error = "Expected int64 for %s but found %s\n";
124 else if (type == OPT_INT && (int)d != d)
125 error = "Expected int for %s but found %s\n";
128 av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
133 int64_t parse_time_or_die(const char *context, const char *timestr,
137 if (av_parse_time(&us, timestr, is_duration) < 0) {
138 av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
139 is_duration ? "duration" : "date", context, timestr);
145 void show_help_options(const OptionDef *options, const char *msg, int req_flags,
146 int rej_flags, int alt_flags)
152 for (po = options; po->name != NULL; po++) {
155 if (((po->flags & req_flags) != req_flags) ||
156 (alt_flags && !(po->flags & alt_flags)) ||
157 (po->flags & rej_flags))
164 av_strlcpy(buf, po->name, sizeof(buf));
166 av_strlcat(buf, " ", sizeof(buf));
167 av_strlcat(buf, po->argname, sizeof(buf));
169 printf("-%-17s %s\n", buf, po->help);
174 void show_help_children(const AVClass *class, int flags)
176 const AVClass *child = NULL;
178 av_opt_show2(&class, NULL, flags, 0);
182 while (child = av_opt_child_class_next(class, child))
183 show_help_children(child, flags);
186 static const OptionDef *find_option(const OptionDef *po, const char *name)
188 const char *p = strchr(name, ':');
189 int len = p ? p - name : strlen(name);
191 while (po->name != NULL) {
192 if (!strncmp(name, po->name, len) && strlen(po->name) == len)
199 #if defined(_WIN32) && !defined(__MINGW32CE__)
201 #include <shellapi.h>
202 /* Will be leaked on exit */
203 static char** win32_argv_utf8 = NULL;
204 static int win32_argc = 0;
207 * Prepare command line arguments for executable.
208 * For Windows - perform wide-char to UTF-8 conversion.
209 * Input arguments should be main() function arguments.
210 * @param argc_ptr Arguments number (including executable)
211 * @param argv_ptr Arguments list.
213 static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
217 int i, buffsize = 0, offset = 0;
219 if (win32_argv_utf8) {
220 *argc_ptr = win32_argc;
221 *argv_ptr = win32_argv_utf8;
226 argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc);
227 if (win32_argc <= 0 || !argv_w)
230 /* determine the UTF-8 buffer size (including NULL-termination symbols) */
231 for (i = 0; i < win32_argc; i++)
232 buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
233 NULL, 0, NULL, NULL);
235 win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize);
236 argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1);
237 if (win32_argv_utf8 == NULL) {
242 for (i = 0; i < win32_argc; i++) {
243 win32_argv_utf8[i] = &argstr_flat[offset];
244 offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
245 &argstr_flat[offset],
246 buffsize - offset, NULL, NULL);
248 win32_argv_utf8[i] = NULL;
251 *argc_ptr = win32_argc;
252 *argv_ptr = win32_argv_utf8;
255 static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
259 #endif /* WIN32 && !__MINGW32CE__ */
261 int parse_option(void *optctx, const char *opt, const char *arg,
262 const OptionDef *options)
269 po = find_option(options, opt);
270 if (!po->name && opt[0] == 'n' && opt[1] == 'o') {
271 /* handle 'no' bool option */
272 po = find_option(options, opt + 2);
273 if ((po->name && (po->flags & OPT_BOOL)))
277 po = find_option(options, "default");
279 av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
280 return AVERROR(EINVAL);
282 if (po->flags & HAS_ARG && !arg) {
283 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt);
284 return AVERROR(EINVAL);
287 /* new-style options contain an offset into optctx, old-style address of
289 dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? (uint8_t *)optctx + po->u.off
292 if (po->flags & OPT_SPEC) {
293 SpecifierOpt **so = dst;
294 char *p = strchr(opt, ':');
296 dstcount = (int *)(so + 1);
297 *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1);
298 (*so)[*dstcount - 1].specifier = av_strdup(p ? p + 1 : "");
299 dst = &(*so)[*dstcount - 1].u;
302 if (po->flags & OPT_STRING) {
304 str = av_strdup(arg);
307 } else if (po->flags & OPT_BOOL) {
308 *(int *)dst = bool_val;
309 } else if (po->flags & OPT_INT) {
310 *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
311 } else if (po->flags & OPT_INT64) {
312 *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
313 } else if (po->flags & OPT_TIME) {
314 *(int64_t *)dst = parse_time_or_die(opt, arg, 1);
315 } else if (po->flags & OPT_FLOAT) {
316 *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
317 } else if (po->flags & OPT_DOUBLE) {
318 *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY);
319 } else if (po->u.func_arg) {
320 int ret = po->u.func_arg(optctx, opt, arg);
322 av_log(NULL, AV_LOG_ERROR,
323 "Failed to set value '%s' for option '%s'\n", arg, opt);
327 if (po->flags & OPT_EXIT)
329 return !!(po->flags & HAS_ARG);
332 void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
333 void (*parse_arg_function)(void *, const char*))
336 int optindex, handleoptions = 1, ret;
338 /* perform system-dependent conversions for arguments list */
339 prepare_app_arguments(&argc, &argv);
343 while (optindex < argc) {
344 opt = argv[optindex++];
346 if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
347 if (opt[1] == '-' && opt[2] == '\0') {
353 if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
357 if (parse_arg_function)
358 parse_arg_function(optctx, opt);
363 int locate_option(int argc, char **argv, const OptionDef *options,
369 for (i = 1; i < argc; i++) {
370 const char *cur_opt = argv[i];
372 if (*cur_opt++ != '-')
375 po = find_option(options, cur_opt);
376 if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o')
377 po = find_option(options, cur_opt + 2);
379 if ((!po->name && !strcmp(cur_opt, optname)) ||
380 (po->name && !strcmp(optname, po->name)))
383 if (po->flags & HAS_ARG)
389 static void dump_argument(const char *a)
391 const unsigned char *p;
394 if (!((*p >= '+' && *p <= ':') || (*p >= '@' && *p <= 'Z') ||
395 *p == '_' || (*p >= 'a' && *p <= 'z')))
398 fputs(a, report_file);
401 fputc('"', report_file);
402 for (p = a; *p; p++) {
403 if (*p == '\\' || *p == '"' || *p == '$' || *p == '`')
404 fprintf(report_file, "\\%c", *p);
405 else if (*p < ' ' || *p > '~')
406 fprintf(report_file, "\\x%02x", *p);
408 fputc(*p, report_file);
410 fputc('"', report_file);
413 void parse_loglevel(int argc, char **argv, const OptionDef *options)
415 int idx = locate_option(argc, argv, options, "loglevel");
417 idx = locate_option(argc, argv, options, "v");
418 if (idx && argv[idx + 1])
419 opt_loglevel(NULL, "loglevel", argv[idx + 1]);
420 idx = locate_option(argc, argv, options, "report");
421 if (idx || getenv("FFREPORT")) {
422 opt_report("report");
425 fprintf(report_file, "Command line:\n");
426 for (i = 0; i < argc; i++) {
427 dump_argument(argv[i]);
428 fputc(i < argc - 1 ? ' ' : '\n', report_file);
435 #define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
436 int opt_default(void *optctx, const char *opt, const char *arg)
440 char opt_stripped[128];
442 const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(), *sc, *swr_class;
444 if (!(p = strchr(opt, ':')))
445 p = opt + strlen(opt);
446 av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
448 if ((o = av_opt_find(&cc, opt_stripped, NULL, 0,
449 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||
450 ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
451 (o = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) {
452 av_dict_set(&codec_opts, opt, arg, FLAGS);
455 if ((o = av_opt_find(&fc, opt, NULL, 0,
456 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
457 av_dict_set(&format_opts, opt, arg, FLAGS);
459 av_log(NULL, AV_LOG_VERBOSE, "Routing %s to codec and muxer layer\n", opt);
463 sc = sws_get_class();
464 if (!consumed && (o = av_opt_find(&sc, opt, NULL, 0,
465 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
466 // XXX we only support sws_flags, not arbitrary sws options
467 int ret = av_opt_set(sws_opts, opt, arg, 0);
469 av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
475 #if CONFIG_SWRESAMPLE
476 swr_class = swr_get_class();
477 if (!consumed && (o = av_opt_find(&swr_class, opt, NULL, 0,
478 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
479 int ret = av_opt_set(swr_opts, opt, arg, 0);
481 av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
490 av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
491 return AVERROR_OPTION_NOT_FOUND;
494 int opt_loglevel(void *optctx, const char *opt, const char *arg)
496 const struct { const char *name; int level; } log_levels[] = {
497 { "quiet" , AV_LOG_QUIET },
498 { "panic" , AV_LOG_PANIC },
499 { "fatal" , AV_LOG_FATAL },
500 { "error" , AV_LOG_ERROR },
501 { "warning", AV_LOG_WARNING },
502 { "info" , AV_LOG_INFO },
503 { "verbose", AV_LOG_VERBOSE },
504 { "debug" , AV_LOG_DEBUG },
510 for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
511 if (!strcmp(log_levels[i].name, arg)) {
512 av_log_set_level(log_levels[i].level);
517 level = strtol(arg, &tail, 10);
519 av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". "
520 "Possible levels are numbers or:\n", arg);
521 for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
522 av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
525 av_log_set_level(level);
529 int opt_report(const char *opt)
535 if (report_file) /* already opened */
538 tm = localtime(&now);
539 snprintf(filename, sizeof(filename), "%s-%04d%02d%02d-%02d%02d%02d.log",
541 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
542 tm->tm_hour, tm->tm_min, tm->tm_sec);
543 report_file = fopen(filename, "w");
545 av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
546 filename, strerror(errno));
547 return AVERROR(errno);
549 av_log_set_callback(log_callback_report);
550 av_log(NULL, AV_LOG_INFO,
551 "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n"
552 "Report written to \"%s\"\n",
554 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
555 tm->tm_hour, tm->tm_min, tm->tm_sec,
557 av_log_set_level(FFMAX(av_log_get_level(), AV_LOG_VERBOSE));
561 int opt_max_alloc(void *optctx, const char *opt, const char *arg)
566 max = strtol(arg, &tail, 10);
568 av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg);
575 int opt_cpuflags(void *optctx, const char *opt, const char *arg)
578 unsigned flags = av_get_cpu_flags();
580 if ((ret = av_parse_cpu_caps(&flags, arg)) < 0)
583 av_force_cpu_flags(flags);
587 int opt_codec_debug(void *optctx, const char *opt, const char *arg)
589 av_log_set_level(AV_LOG_DEBUG);
590 return opt_default(NULL, opt, arg);
593 int opt_timelimit(void *optctx, const char *opt, const char *arg)
596 int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
597 struct rlimit rl = { lim, lim + 1 };
598 if (setrlimit(RLIMIT_CPU, &rl))
601 av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
606 void print_error(const char *filename, int err)
609 const char *errbuf_ptr = errbuf;
611 if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
612 errbuf_ptr = strerror(AVUNERROR(err));
613 av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr);
616 static int warned_cfg = 0;
619 #define SHOW_VERSION 2
620 #define SHOW_CONFIG 4
621 #define SHOW_COPYRIGHT 8
623 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \
624 if (CONFIG_##LIBNAME) { \
625 const char *indent = flags & INDENT? " " : ""; \
626 if (flags & SHOW_VERSION) { \
627 unsigned int version = libname##_version(); \
628 av_log(NULL, level, \
629 "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \
631 LIB##LIBNAME##_VERSION_MAJOR, \
632 LIB##LIBNAME##_VERSION_MINOR, \
633 LIB##LIBNAME##_VERSION_MICRO, \
634 version >> 16, version >> 8 & 0xff, version & 0xff); \
636 if (flags & SHOW_CONFIG) { \
637 const char *cfg = libname##_configuration(); \
638 if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \
640 av_log(NULL, level, \
641 "%sWARNING: library configuration mismatch\n", \
645 av_log(NULL, level, "%s%-11s configuration: %s\n", \
646 indent, #libname, cfg); \
651 static void print_all_libs_info(int flags, int level)
653 PRINT_LIB_INFO(avutil, AVUTIL, flags, level);
654 PRINT_LIB_INFO(avcodec, AVCODEC, flags, level);
655 PRINT_LIB_INFO(avformat, AVFORMAT, flags, level);
656 PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
657 PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
658 // PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level);
659 PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
660 PRINT_LIB_INFO(swresample,SWRESAMPLE, flags, level);
662 PRINT_LIB_INFO(postproc, POSTPROC, flags, level);
666 static void print_program_info(int flags, int level)
668 const char *indent = flags & INDENT? " " : "";
670 av_log(NULL, level, "%s version " FFMPEG_VERSION, program_name);
671 if (flags & SHOW_COPYRIGHT)
672 av_log(NULL, level, " Copyright (c) %d-%d the FFmpeg developers",
673 program_birth_year, this_year);
674 av_log(NULL, level, "\n");
675 av_log(NULL, level, "%sbuilt on %s %s with %s\n",
676 indent, __DATE__, __TIME__, CC_IDENT);
678 av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent);
681 void show_banner(int argc, char **argv, const OptionDef *options)
683 int idx = locate_option(argc, argv, options, "version");
687 print_program_info (INDENT|SHOW_COPYRIGHT, AV_LOG_INFO);
688 print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_INFO);
689 print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_INFO);
692 int show_version(void *optctx, const char *opt, const char *arg)
694 av_log_set_callback(log_callback_help);
695 print_program_info (0 , AV_LOG_INFO);
696 print_all_libs_info(SHOW_VERSION, AV_LOG_INFO);
701 int show_license(void *optctx, const char *opt, const char *arg)
705 "This version of %s has nonfree parts compiled in.\n"
706 "Therefore it is not legally redistributable.\n",
709 "%s is free software; you can redistribute it and/or modify\n"
710 "it under the terms of the GNU General Public License as published by\n"
711 "the Free Software Foundation; either version 3 of the License, or\n"
712 "(at your option) any later version.\n"
714 "%s is distributed in the hope that it will be useful,\n"
715 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
716 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
717 "GNU General Public License for more details.\n"
719 "You should have received a copy of the GNU General Public License\n"
720 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
721 program_name, program_name, program_name
723 "%s is free software; you can redistribute it and/or modify\n"
724 "it under the terms of the GNU General Public License as published by\n"
725 "the Free Software Foundation; either version 2 of the License, or\n"
726 "(at your option) any later version.\n"
728 "%s is distributed in the hope that it will be useful,\n"
729 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
730 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
731 "GNU General Public License for more details.\n"
733 "You should have received a copy of the GNU General Public License\n"
734 "along with %s; if not, write to the Free Software\n"
735 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
736 program_name, program_name, program_name
738 "%s is free software; you can redistribute it and/or modify\n"
739 "it under the terms of the GNU Lesser General Public License as published by\n"
740 "the Free Software Foundation; either version 3 of the License, or\n"
741 "(at your option) any later version.\n"
743 "%s is distributed in the hope that it will be useful,\n"
744 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
745 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
746 "GNU Lesser General Public License for more details.\n"
748 "You should have received a copy of the GNU Lesser General Public License\n"
749 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
750 program_name, program_name, program_name
752 "%s is free software; you can redistribute it and/or\n"
753 "modify it under the terms of the GNU Lesser General Public\n"
754 "License as published by the Free Software Foundation; either\n"
755 "version 2.1 of the License, or (at your option) any later version.\n"
757 "%s is distributed in the hope that it will be useful,\n"
758 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
759 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
760 "Lesser General Public License for more details.\n"
762 "You should have received a copy of the GNU Lesser General Public\n"
763 "License along with %s; if not, write to the Free Software\n"
764 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
765 program_name, program_name, program_name
772 int show_formats(void *optctx, const char *opt, const char *arg)
774 AVInputFormat *ifmt = NULL;
775 AVOutputFormat *ofmt = NULL;
776 const char *last_name;
778 printf("File formats:\n"
779 " D. = Demuxing supported\n"
780 " .E = Muxing supported\n"
786 const char *name = NULL;
787 const char *long_name = NULL;
789 while ((ofmt = av_oformat_next(ofmt))) {
790 if ((name == NULL || strcmp(ofmt->name, name) < 0) &&
791 strcmp(ofmt->name, last_name) > 0) {
793 long_name = ofmt->long_name;
797 while ((ifmt = av_iformat_next(ifmt))) {
798 if ((name == NULL || strcmp(ifmt->name, name) < 0) &&
799 strcmp(ifmt->name, last_name) > 0) {
801 long_name = ifmt->long_name;
804 if (name && strcmp(ifmt->name, name) == 0)
811 printf(" %s%s %-15s %s\n",
815 long_name ? long_name:" ");
820 #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \
821 if (codec->field) { \
822 const type *p = c->field; \
824 printf(" Supported " list_name ":"); \
825 while (*p != term) { \
827 printf(" %s", name); \
833 static void print_codec(const AVCodec *c)
835 int encoder = av_codec_is_encoder(c);
837 printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name,
838 c->long_name ? c->long_name : "");
840 if (c->type == AVMEDIA_TYPE_VIDEO) {
841 printf(" Threading capabilities: ");
842 switch (c->capabilities & (CODEC_CAP_FRAME_THREADS |
843 CODEC_CAP_SLICE_THREADS)) {
844 case CODEC_CAP_FRAME_THREADS |
845 CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
846 case CODEC_CAP_FRAME_THREADS: printf("frame"); break;
847 case CODEC_CAP_SLICE_THREADS: printf("slice"); break;
848 default: printf("no"); break;
853 if (c->supported_framerates) {
854 const AVRational *fps = c->supported_framerates;
856 printf(" Supported framerates:");
858 printf(" %d/%d", fps->num, fps->den);
863 PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats",
864 AV_PIX_FMT_NONE, GET_PIX_FMT_NAME);
865 PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0,
866 GET_SAMPLE_RATE_NAME);
867 PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats",
868 AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME);
869 PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts",
870 0, GET_CH_LAYOUT_DESC);
873 show_help_children(c->priv_class,
874 AV_OPT_FLAG_ENCODING_PARAM |
875 AV_OPT_FLAG_DECODING_PARAM);
879 static char get_media_type_char(enum AVMediaType type)
882 case AVMEDIA_TYPE_VIDEO: return 'V';
883 case AVMEDIA_TYPE_AUDIO: return 'A';
884 case AVMEDIA_TYPE_DATA: return 'D';
885 case AVMEDIA_TYPE_SUBTITLE: return 'S';
886 case AVMEDIA_TYPE_ATTACHMENT:return 'T';
891 static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
894 while ((prev = av_codec_next(prev))) {
895 if (prev->id == id &&
896 (encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
902 static int compare_codec_desc(const void *a, const void *b)
904 const AVCodecDescriptor * const *da = a;
905 const AVCodecDescriptor * const *db = b;
907 return (*da)->type != (*db)->type ? (*da)->type - (*db)->type :
908 strcmp((*da)->name, (*db)->name);
911 static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs)
913 const AVCodecDescriptor *desc = NULL;
914 const AVCodecDescriptor **codecs;
915 unsigned nb_codecs = 0, i = 0;
917 while ((desc = avcodec_descriptor_next(desc)))
919 if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs)))) {
920 av_log(0, AV_LOG_ERROR, "Out of memory\n");
924 while ((desc = avcodec_descriptor_next(desc)))
926 av_assert0(i == nb_codecs);
927 qsort(codecs, nb_codecs, sizeof(*codecs), compare_codec_desc);
932 static void print_codecs_for_id(enum AVCodecID id, int encoder)
934 const AVCodec *codec = NULL;
936 printf(" (%s: ", encoder ? "encoders" : "decoders");
938 while ((codec = next_codec_for_id(id, codec, encoder)))
939 printf("%s ", codec->name);
944 int show_codecs(void *optctx, const char *opt, const char *arg)
946 const AVCodecDescriptor **codecs;
947 unsigned i, nb_codecs = get_codecs_sorted(&codecs);
950 " D..... = Decoding supported\n"
951 " .E.... = Encoding supported\n"
952 " ..V... = Video codec\n"
953 " ..A... = Audio codec\n"
954 " ..S... = Subtitle codec\n"
955 " ...I.. = Intra frame-only codec\n"
956 " ....L. = Lossy compression\n"
957 " .....S = Lossless compression\n"
959 for (i = 0; i < nb_codecs; i++) {
960 const AVCodecDescriptor *desc = codecs[i];
961 const AVCodec *codec = NULL;
964 printf(avcodec_find_decoder(desc->id) ? "D" : ".");
965 printf(avcodec_find_encoder(desc->id) ? "E" : ".");
967 printf("%c", get_media_type_char(desc->type));
968 printf((desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : ".");
969 printf((desc->props & AV_CODEC_PROP_LOSSY) ? "L" : ".");
970 printf((desc->props & AV_CODEC_PROP_LOSSLESS) ? "S" : ".");
972 printf(" %-20s %s", desc->name, desc->long_name ? desc->long_name : "");
974 /* print decoders/encoders when there's more than one or their
975 * names are different from codec name */
976 while ((codec = next_codec_for_id(desc->id, codec, 0))) {
977 if (strcmp(codec->name, desc->name)) {
978 print_codecs_for_id(desc->id, 0);
983 while ((codec = next_codec_for_id(desc->id, codec, 1))) {
984 if (strcmp(codec->name, desc->name)) {
985 print_codecs_for_id(desc->id, 1);
996 static void print_codecs(int encoder)
998 const AVCodecDescriptor **codecs;
999 unsigned i, nb_codecs = get_codecs_sorted(&codecs);
1004 " S..... = Subtitle\n"
1005 " .F.... = Frame-level multithreading\n"
1006 " ..S... = Slice-level multithreading\n"
1007 " ...X.. = Codec is experimental\n"
1008 " ....B. = Supports draw_horiz_band\n"
1009 " .....D = Supports direct rendering method 1\n"
1011 encoder ? "Encoders" : "Decoders");
1012 for (i = 0; i < nb_codecs; i++) {
1013 const AVCodecDescriptor *desc = codecs[i];
1014 const AVCodec *codec = NULL;
1016 while ((codec = next_codec_for_id(desc->id, codec, encoder))) {
1017 printf(" %c", get_media_type_char(desc->type));
1018 printf((codec->capabilities & CODEC_CAP_FRAME_THREADS) ? "F" : ".");
1019 printf((codec->capabilities & CODEC_CAP_SLICE_THREADS) ? "S" : ".");
1020 printf((codec->capabilities & CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
1021 printf((codec->capabilities & CODEC_CAP_DRAW_HORIZ_BAND)?"B" : ".");
1022 printf((codec->capabilities & CODEC_CAP_DR1) ? "D" : ".");
1024 printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : "");
1025 if (strcmp(codec->name, desc->name))
1026 printf(" (codec %s)", desc->name);
1034 int show_decoders(void *optctx, const char *opt, const char *arg)
1040 int show_encoders(void *optctx, const char *opt, const char *arg)
1046 int show_bsfs(void *optctx, const char *opt, const char *arg)
1048 AVBitStreamFilter *bsf = NULL;
1050 printf("Bitstream filters:\n");
1051 while ((bsf = av_bitstream_filter_next(bsf)))
1052 printf("%s\n", bsf->name);
1057 int show_protocols(void *optctx, const char *opt, const char *arg)
1059 void *opaque = NULL;
1062 printf("Supported file protocols:\n"
1064 while ((name = avio_enum_protocols(&opaque, 0)))
1065 printf("%s\n", name);
1066 printf("Output:\n");
1067 while ((name = avio_enum_protocols(&opaque, 1)))
1068 printf("%s\n", name);
1072 int show_filters(void *optctx, const char *opt, const char *arg)
1074 AVFilter av_unused(**filter) = NULL;
1075 char descr[64], *descr_cur;
1077 const AVFilterPad *pad;
1079 printf("Filters:\n");
1081 while ((filter = av_filter_next(filter)) && *filter) {
1083 for (i = 0; i < 2; i++) {
1085 *(descr_cur++) = '-';
1086 *(descr_cur++) = '>';
1088 pad = i ? (*filter)->outputs : (*filter)->inputs;
1089 for (j = 0; pad && pad[j].name; j++) {
1090 if (descr_cur >= descr + sizeof(descr) - 4)
1092 *(descr_cur++) = get_media_type_char(pad[j].type);
1095 *(descr_cur++) = '|';
1098 printf("%-16s %-10s %s\n", (*filter)->name, descr, (*filter)->description);
1104 int show_pix_fmts(void *optctx, const char *opt, const char *arg)
1106 const AVPixFmtDescriptor *pix_desc = NULL;
1108 printf("Pixel formats:\n"
1109 "I.... = Supported Input format for conversion\n"
1110 ".O... = Supported Output format for conversion\n"
1111 "..H.. = Hardware accelerated format\n"
1112 "...P. = Paletted format\n"
1113 "....B = Bitstream format\n"
1114 "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
1118 # define sws_isSupportedInput(x) 0
1119 # define sws_isSupportedOutput(x) 0
1122 while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
1123 enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
1126 printf("%c%c%c%c%c %-16s %d %2d\n",
1127 sws_isSupportedInput (pix_fmt) ? 'I' : '.',
1128 sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
1129 pix_desc->flags & PIX_FMT_HWACCEL ? 'H' : '.',
1130 pix_desc->flags & PIX_FMT_PAL ? 'P' : '.',
1131 pix_desc->flags & PIX_FMT_BITSTREAM ? 'B' : '.',
1133 pix_desc->nb_components,
1134 av_get_bits_per_pixel(pix_desc));
1139 int show_layouts(void *optctx, const char *opt, const char *arg)
1143 const char *name, *descr;
1145 printf("Individual channels:\n"
1146 "NAME DESCRIPTION\n");
1147 for (i = 0; i < 63; i++) {
1148 name = av_get_channel_name((uint64_t)1 << i);
1151 descr = av_get_channel_description((uint64_t)1 << i);
1152 printf("%-12s%s\n", name, descr);
1154 printf("\nStandard channel layouts:\n"
1155 "NAME DECOMPOSITION\n");
1156 for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) {
1158 printf("%-12s", name);
1159 for (j = 1; j; j <<= 1)
1161 printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
1168 int show_sample_fmts(void *optctx, const char *opt, const char *arg)
1172 for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
1173 printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
1177 static void show_help_codec(const char *name, int encoder)
1179 const AVCodecDescriptor *desc;
1180 const AVCodec *codec;
1183 av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n");
1187 codec = encoder ? avcodec_find_encoder_by_name(name) :
1188 avcodec_find_decoder_by_name(name);
1192 else if ((desc = avcodec_descriptor_get_by_name(name))) {
1195 while ((codec = next_codec_for_id(desc->id, codec, encoder))) {
1201 av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, "
1202 "but no %s for it are available. FFmpeg might need to be "
1203 "recompiled with additional external libraries.\n",
1204 name, encoder ? "encoders" : "decoders");
1207 av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n",
1212 static void show_help_demuxer(const char *name)
1214 const AVInputFormat *fmt = av_find_input_format(name);
1217 av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
1221 printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name);
1223 if (fmt->extensions)
1224 printf(" Common extensions: %s.\n", fmt->extensions);
1226 if (fmt->priv_class)
1227 show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM);
1230 static void show_help_muxer(const char *name)
1232 const AVCodecDescriptor *desc;
1233 const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL);
1236 av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name);
1240 printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name);
1242 if (fmt->extensions)
1243 printf(" Common extensions: %s.\n", fmt->extensions);
1245 printf(" Mime type: %s.\n", fmt->mime_type);
1246 if (fmt->video_codec != AV_CODEC_ID_NONE &&
1247 (desc = avcodec_descriptor_get(fmt->video_codec))) {
1248 printf(" Default video codec: %s.\n", desc->name);
1250 if (fmt->audio_codec != AV_CODEC_ID_NONE &&
1251 (desc = avcodec_descriptor_get(fmt->audio_codec))) {
1252 printf(" Default audio codec: %s.\n", desc->name);
1254 if (fmt->subtitle_codec != AV_CODEC_ID_NONE &&
1255 (desc = avcodec_descriptor_get(fmt->subtitle_codec))) {
1256 printf(" Default subtitle codec: %s.\n", desc->name);
1259 if (fmt->priv_class)
1260 show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM);
1263 int show_help(void *optctx, const char *opt, const char *arg)
1266 av_log_set_callback(log_callback_help);
1268 topic = av_strdup(arg ? arg : "");
1269 par = strchr(topic, '=');
1274 show_help_default(topic, par);
1275 } else if (!strcmp(topic, "decoder")) {
1276 show_help_codec(par, 0);
1277 } else if (!strcmp(topic, "encoder")) {
1278 show_help_codec(par, 1);
1279 } else if (!strcmp(topic, "demuxer")) {
1280 show_help_demuxer(par);
1281 } else if (!strcmp(topic, "muxer")) {
1282 show_help_muxer(par);
1284 show_help_default(topic, par);
1291 int read_yesno(void)
1294 int yesno = (toupper(c) == 'Y');
1296 while (c != '\n' && c != EOF)
1302 int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
1305 FILE *f = fopen(filename, "rb");
1308 av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
1310 return AVERROR(errno);
1312 fseek(f, 0, SEEK_END);
1314 fseek(f, 0, SEEK_SET);
1315 if (*size == (size_t)-1) {
1316 av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", strerror(errno));
1317 return AVERROR(errno);
1319 *bufptr = av_malloc(*size + 1);
1321 av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
1323 return AVERROR(ENOMEM);
1325 ret = fread(*bufptr, 1, *size, f);
1329 av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
1330 filename, strerror(errno));
1331 ret = AVERROR(errno);
1336 (*bufptr)[(*size)++] = '\0';
1343 FILE *get_preset_file(char *filename, size_t filename_size,
1344 const char *preset_name, int is_path,
1345 const char *codec_name)
1349 const char *base[3] = { getenv("FFMPEG_DATADIR"),
1354 av_strlcpy(filename, preset_name, filename_size);
1355 f = fopen(filename, "r");
1358 char datadir[MAX_PATH], *ls;
1361 if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1))
1363 for (ls = datadir; ls < datadir + strlen(datadir); ls++)
1364 if (*ls == '\\') *ls = '/';
1366 if (ls = strrchr(datadir, '/'))
1369 strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir));
1374 for (i = 0; i < 3 && !f; i++) {
1377 snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
1378 i != 1 ? "" : "/.ffmpeg", preset_name);
1379 f = fopen(filename, "r");
1380 if (!f && codec_name) {
1381 snprintf(filename, filename_size,
1382 "%s%s/%s-%s.ffpreset",
1383 base[i], i != 1 ? "" : "/.ffmpeg", codec_name,
1385 f = fopen(filename, "r");
1393 int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
1395 int ret = avformat_match_stream_specifier(s, st, spec);
1397 av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
1401 AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
1402 AVFormatContext *s, AVStream *st, AVCodec *codec)
1404 AVDictionary *ret = NULL;
1405 AVDictionaryEntry *t = NULL;
1406 int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
1407 : AV_OPT_FLAG_DECODING_PARAM;
1409 const AVClass *cc = avcodec_get_class();
1412 codec = s->oformat ? avcodec_find_encoder(codec_id)
1413 : avcodec_find_decoder(codec_id);
1417 switch (codec->type) {
1418 case AVMEDIA_TYPE_VIDEO:
1420 flags |= AV_OPT_FLAG_VIDEO_PARAM;
1422 case AVMEDIA_TYPE_AUDIO:
1424 flags |= AV_OPT_FLAG_AUDIO_PARAM;
1426 case AVMEDIA_TYPE_SUBTITLE:
1428 flags |= AV_OPT_FLAG_SUBTITLE_PARAM;
1432 while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) {
1433 char *p = strchr(t->key, ':');
1435 /* check stream specification in opt name */
1437 switch (check_stream_specifier(s, st, p + 1)) {
1438 case 1: *p = 0; break;
1440 default: return NULL;
1443 if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) ||
1444 (codec && codec->priv_class &&
1445 av_opt_find(&codec->priv_class, t->key, NULL, flags,
1446 AV_OPT_SEARCH_FAKE_OBJ)))
1447 av_dict_set(&ret, t->key, t->value, 0);
1448 else if (t->key[0] == prefix &&
1449 av_opt_find(&cc, t->key + 1, NULL, flags,
1450 AV_OPT_SEARCH_FAKE_OBJ))
1451 av_dict_set(&ret, t->key + 1, t->value, 0);
1459 AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
1460 AVDictionary *codec_opts)
1463 AVDictionary **opts;
1467 opts = av_mallocz(s->nb_streams * sizeof(*opts));
1469 av_log(NULL, AV_LOG_ERROR,
1470 "Could not alloc memory for stream options.\n");
1473 for (i = 0; i < s->nb_streams; i++)
1474 opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id,
1475 s, s->streams[i], NULL);
1479 void *grow_array(void *array, int elem_size, int *size, int new_size)
1481 if (new_size >= INT_MAX / elem_size) {
1482 av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
1485 if (*size < new_size) {
1486 uint8_t *tmp = av_realloc(array, new_size*elem_size);
1488 av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
1491 memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
1498 static int alloc_buffer(FrameBuffer **pool, AVCodecContext *s, FrameBuffer **pbuf)
1500 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
1504 int h_chroma_shift, v_chroma_shift;
1505 int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1
1506 int w = s->width, h = s->height;
1509 return AVERROR(EINVAL);
1510 pixel_size = desc->comp[0].step_minus1 + 1;
1512 buf = av_mallocz(sizeof(*buf));
1514 return AVERROR(ENOMEM);
1516 avcodec_align_dimensions(s, &w, &h);
1518 if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {
1523 if ((ret = av_image_alloc(buf->base, buf->linesize, w, h,
1524 s->pix_fmt, 32)) < 0) {
1526 av_log(s, AV_LOG_ERROR, "alloc_buffer: av_image_alloc() failed\n");
1529 /* XXX this shouldn't be needed, but some tests break without this line
1530 * those decoders are buggy and need to be fixed.
1531 * the following tests fail:
1532 * cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit
1534 memset(buf->base[0], 128, ret);
1536 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
1537 for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
1538 const int h_shift = i==0 ? 0 : h_chroma_shift;
1539 const int v_shift = i==0 ? 0 : v_chroma_shift;
1540 if ((s->flags & CODEC_FLAG_EMU_EDGE) || !buf->linesize[i] || !buf->base[i])
1541 buf->data[i] = buf->base[i];
1543 buf->data[i] = buf->base[i] +
1544 FFALIGN((buf->linesize[i]*edge >> v_shift) +
1545 (pixel_size*edge >> h_shift), 32);
1549 buf->pix_fmt = s->pix_fmt;
1556 int codec_get_buffer(AVCodecContext *s, AVFrame *frame)
1558 FrameBuffer **pool = s->opaque;
1562 if(av_image_check_size(s->width, s->height, 0, s) || s->pix_fmt<0) {
1563 av_log(s, AV_LOG_ERROR, "codec_get_buffer: image parameters invalid\n");
1567 if (!*pool && (ret = alloc_buffer(pool, s, pool)) < 0)
1573 if (buf->w != s->width || buf->h != s->height || buf->pix_fmt != s->pix_fmt) {
1574 av_freep(&buf->base[0]);
1576 if ((ret = alloc_buffer(pool, s, &buf)) < 0)
1579 av_assert0(!buf->refcount);
1582 frame->opaque = buf;
1583 frame->type = FF_BUFFER_TYPE_USER;
1584 frame->extended_data = frame->data;
1585 frame->pkt_pts = s->pkt ? s->pkt->pts : AV_NOPTS_VALUE;
1586 frame->width = buf->w;
1587 frame->height = buf->h;
1588 frame->format = buf->pix_fmt;
1589 frame->sample_aspect_ratio = s->sample_aspect_ratio;
1591 for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
1592 frame->base[i] = buf->base[i]; // XXX h264.c uses base though it shouldn't
1593 frame->data[i] = buf->data[i];
1594 frame->linesize[i] = buf->linesize[i];
1600 static void unref_buffer(FrameBuffer *buf)
1602 FrameBuffer **pool = buf->pool;
1604 av_assert0(buf->refcount > 0);
1606 if (!buf->refcount) {
1608 for(tmp= *pool; tmp; tmp= tmp->next)
1609 av_assert1(tmp != buf);
1616 void codec_release_buffer(AVCodecContext *s, AVFrame *frame)
1618 FrameBuffer *buf = frame->opaque;
1621 if(frame->type!=FF_BUFFER_TYPE_USER) {
1622 avcodec_default_release_buffer(s, frame);
1626 for (i = 0; i < FF_ARRAY_ELEMS(frame->data); i++)
1627 frame->data[i] = NULL;
1632 void filter_release_buffer(AVFilterBuffer *fb)
1634 FrameBuffer *buf = fb->priv;
1639 void free_buffer_pool(FrameBuffer **pool)
1641 FrameBuffer *buf = *pool;
1644 av_freep(&buf->base[0]);