*/
#include <string.h>
+#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <math.h>
#include "libavutil/eval.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
+#include "libavutil/cpu.h"
#include "cmdutils.h"
#include "version.h"
#if CONFIG_NETWORK
vfprintf(stdout, fmt, vl);
}
+static void (*program_exit)(int ret);
+
+void register_exit(void (*cb)(int ret))
+{
+ program_exit = cb;
+}
+
+void exit_program(int ret)
+{
+ if (program_exit)
+ program_exit(ret);
+
+ exit(ret);
+}
+
double parse_number_or_die(const char *context, const char *numstr, int type,
double min, double max)
{
else
return d;
av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
- exit(1);
+ exit_program(1);
return 0;
}
if (av_parse_time(&us, timestr, is_duration) < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
- exit(1);
+ exit_program(1);
}
return us;
}
return po;
}
-#if HAVE_COMMANDLINETOARGVW
+/* _WIN32 means using the windows libc - cygwin doesn't define that
+ * by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while
+ * it doesn't provide the actual command line via GetCommandLineW(). */
+#if HAVE_COMMANDLINETOARGVW && defined(_WIN32)
#include <windows.h>
#include <shellapi.h>
/* Will be leaked on exit */
}
}
if (po->flags & OPT_EXIT)
- exit(0);
+ exit_program(0);
return 0;
}
opt++;
if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
- exit(1);
+ exit_program(1);
optindex += ret;
} else {
if (parse_arg_function)
octx->nb_groups = nb_groups;
octx->groups = av_mallocz(sizeof(*octx->groups) * octx->nb_groups);
if (!octx->groups)
- exit(1);
+ exit_program(1);
for (i = 0; i < octx->nb_groups; i++)
octx->groups[i].group_def = &groups[i];
return 0;
}
+int opt_cpuflags(void *optctx, const char *opt, const char *arg)
+{
+ int flags = av_parse_cpu_flags(arg);
+
+ if (flags < 0)
+ return flags;
+
+ av_set_cpu_flags_mask(flags);
+ return 0;
+}
+
int opt_loglevel(void *optctx, const char *opt, const char *arg)
{
const struct { const char *name; int level; } log_levels[] = {
"Possible levels are numbers or:\n", arg);
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
- exit(1);
+ exit_program(1);
}
av_log_set_level(level);
return 0;
while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
printf("%c%c%c%c%c %-16s %d %2d\n",
- sws_isSupportedInput (pix_fmt) ? 'I' : '.',
- sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
- pix_desc->flags & PIX_FMT_HWACCEL ? 'H' : '.',
- pix_desc->flags & PIX_FMT_PAL ? 'P' : '.',
- pix_desc->flags & PIX_FMT_BITSTREAM ? 'B' : '.',
+ sws_isSupportedInput (pix_fmt) ? 'I' : '.',
+ sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
+ pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL ? 'H' : '.',
+ pix_desc->flags & AV_PIX_FMT_FLAG_PAL ? 'P' : '.',
+ pix_desc->flags & AV_PIX_FMT_FLAG_BITSTREAM ? 'B' : '.',
pix_desc->name,
pix_desc->nb_components,
av_get_bits_per_pixel(pix_desc));
show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM);
}
+#if CONFIG_AVFILTER
static void show_help_filter(const char *name)
{
const AVFilter *f = avfilter_get_by_name(name);
printf("Filter %s [%s]:\n", f->name, f->description);
+ if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
+ printf(" slice threading supported\n");
+
printf(" Inputs:\n");
count = avfilter_pad_count(f->inputs);
for (i = 0; i < count; i++) {
show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM |
AV_OPT_FLAG_AUDIO_PARAM);
}
+#endif
int show_help(void *optctx, const char *opt, const char *arg)
{
show_help_demuxer(par);
} else if (!strcmp(topic, "muxer")) {
show_help_muxer(par);
+#if CONFIG_AVFILTER
} else if (!strcmp(topic, "filter")) {
show_help_filter(par);
+#endif
} else {
show_help_default(topic, par);
}
{
if (new_size >= INT_MAX / elem_size) {
av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
- exit(1);
+ exit_program(1);
}
if (*size < new_size) {
uint8_t *tmp = av_realloc(array, new_size*elem_size);
if (!tmp) {
av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
- exit(1);
+ exit_program(1);
}
memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
*size = new_size;