mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
cmdutils: K&R reformatting cosmetics
Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
parent
e49d21306a
commit
cbaef7d16e
136
cmdutils.c
136
cmdutils.c
@ -58,7 +58,8 @@ static const int this_year = 2011;
|
||||
void init_opts(void)
|
||||
{
|
||||
#if CONFIG_SWSCALE
|
||||
sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NULL);
|
||||
sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
|
||||
NULL, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -77,7 +78,8 @@ void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
|
||||
vfprintf(stdout, fmt, vl);
|
||||
}
|
||||
|
||||
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
|
||||
double parse_number_or_die(const char *context, const char *numstr, int type,
|
||||
double min, double max)
|
||||
{
|
||||
char *tail;
|
||||
const char *error;
|
||||
@ -97,7 +99,8 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
|
||||
int64_t parse_time_or_die(const char *context, const char *timestr,
|
||||
int is_duration)
|
||||
{
|
||||
int64_t us;
|
||||
if (av_parse_time(&us, timestr, is_duration) < 0) {
|
||||
@ -108,7 +111,8 @@ int64_t parse_time_or_die(const char *context, const char *timestr, int is_durat
|
||||
return us;
|
||||
}
|
||||
|
||||
void show_help_options(const OptionDef *options, const char *msg, int mask, int value)
|
||||
void show_help_options(const OptionDef *options, const char *msg, int mask,
|
||||
int value)
|
||||
{
|
||||
const OptionDef *po;
|
||||
int first;
|
||||
@ -141,7 +145,8 @@ void show_help_children(const AVClass *class, int flags)
|
||||
show_help_children(child, flags);
|
||||
}
|
||||
|
||||
static const OptionDef* find_option(const OptionDef *po, const char *name){
|
||||
static const OptionDef *find_option(const OptionDef *po, const char *name)
|
||||
{
|
||||
const char *p = strchr(name, ':');
|
||||
int len = p ? p - name : strlen(name);
|
||||
|
||||
@ -214,7 +219,8 @@ static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
|
||||
}
|
||||
#endif /* WIN32 && !__MINGW32CE__ */
|
||||
|
||||
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
|
||||
int parse_option(void *optctx, const char *opt, const char *arg,
|
||||
const OptionDef *options)
|
||||
{
|
||||
const OptionDef *po;
|
||||
int bool_val = 1;
|
||||
@ -243,7 +249,8 @@ unknown_opt:
|
||||
|
||||
/* new-style options contain an offset into optctx, old-style address of
|
||||
* a global var*/
|
||||
dst = po->flags & (OPT_OFFSET|OPT_SPEC) ? (uint8_t*)optctx + po->u.off : po->u.dst_ptr;
|
||||
dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? (uint8_t *)optctx + po->u.off
|
||||
: po->u.dst_ptr;
|
||||
|
||||
if (po->flags & OPT_SPEC) {
|
||||
SpecifierOpt **so = dst;
|
||||
@ -272,10 +279,11 @@ unknown_opt:
|
||||
} else if (po->flags & OPT_DOUBLE) {
|
||||
*(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY);
|
||||
} else if (po->u.func_arg) {
|
||||
int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg) :
|
||||
po->u.func_arg(opt, arg);
|
||||
int ret = po->flags & OPT_FUNC2 ? po->u.func2_arg(optctx, opt, arg)
|
||||
: po->u.func_arg(opt, arg);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", arg, opt);
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Failed to set value '%s' for option '%s'\n", arg, opt);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -318,7 +326,8 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options
|
||||
/*
|
||||
* Return index of option opt in argv or 0 if not found.
|
||||
*/
|
||||
static int locate_option(int argc, char **argv, const OptionDef *options, const char *optname)
|
||||
static int locate_option(int argc, char **argv, const OptionDef *options,
|
||||
const char *optname)
|
||||
{
|
||||
const OptionDef *po;
|
||||
int i;
|
||||
@ -364,13 +373,16 @@ int opt_default(const char *opt, const char *arg)
|
||||
p = opt + strlen(opt);
|
||||
av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
|
||||
|
||||
if ((o = av_opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN|AV_OPT_SEARCH_FAKE_OBJ)) ||
|
||||
if ((o = av_opt_find(&cc, opt_stripped, NULL, 0,
|
||||
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||
|
||||
((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&
|
||||
(o = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ))))
|
||||
av_dict_set(&codec_opts, opt, arg, FLAGS);
|
||||
else if ((o = av_opt_find(&fc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)))
|
||||
else if ((o = av_opt_find(&fc, opt, NULL, 0,
|
||||
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)))
|
||||
av_dict_set(&format_opts, opt, arg, FLAGS);
|
||||
else if ((o = av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
|
||||
else if ((o = av_opt_find(&sc, opt, NULL, 0,
|
||||
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
|
||||
// XXX we only support sws_flags, not arbitrary sws options
|
||||
int ret = av_opt_set(sws_opts, opt, arg, 0);
|
||||
if (ret < 0) {
|
||||
@ -489,7 +501,8 @@ static void print_all_libs_info(int flags, int level)
|
||||
|
||||
void show_banner(void)
|
||||
{
|
||||
av_log(NULL, AV_LOG_INFO, "%s version " LIBAV_VERSION ", Copyright (c) %d-%d the Libav developers\n",
|
||||
av_log(NULL, AV_LOG_INFO,
|
||||
"%s version " LIBAV_VERSION ", Copyright (c) %d-%d the Libav developers\n",
|
||||
program_name, program_birth_year, this_year);
|
||||
av_log(NULL, AV_LOG_INFO, " built on %s %s with %s %s\n",
|
||||
__DATE__, __TIME__, CC_TYPE, CC_VERSION);
|
||||
@ -579,8 +592,7 @@ void show_formats(void)
|
||||
AVOutputFormat *ofmt = NULL;
|
||||
const char *last_name;
|
||||
|
||||
printf(
|
||||
"File formats:\n"
|
||||
printf("File formats:\n"
|
||||
" D. = Demuxing supported\n"
|
||||
" .E = Muxing supported\n"
|
||||
" --\n");
|
||||
@ -613,8 +625,7 @@ void show_formats(void)
|
||||
break;
|
||||
last_name = name;
|
||||
|
||||
printf(
|
||||
" %s%s %-15s %s\n",
|
||||
printf(" %s%s %-15s %s\n",
|
||||
decode ? "D" : " ",
|
||||
encode ? "E" : " ",
|
||||
name,
|
||||
@ -626,8 +637,7 @@ void show_codecs(void)
|
||||
{
|
||||
AVCodec *p = NULL, *p2;
|
||||
const char *last_name;
|
||||
printf(
|
||||
"Codecs:\n"
|
||||
printf("Codecs:\n"
|
||||
" D..... = Decoding supported\n"
|
||||
" .E.... = Encoding supported\n"
|
||||
" ..V... = Video codec\n"
|
||||
@ -652,8 +662,10 @@ void show_codecs(void)
|
||||
decode = encode = cap = 0;
|
||||
}
|
||||
if (p2 && strcmp(p->name, p2->name) == 0) {
|
||||
if(p->decode) decode=1;
|
||||
if(p->encode) encode=1;
|
||||
if (p->decode)
|
||||
decode = 1;
|
||||
if (p->encode)
|
||||
encode = 1;
|
||||
cap |= p->capabilities;
|
||||
}
|
||||
}
|
||||
@ -675,8 +687,7 @@ void show_codecs(void)
|
||||
type_str = "?";
|
||||
break;
|
||||
}
|
||||
printf(
|
||||
" %s%s%s%s%s%s %-15s %s",
|
||||
printf(" %s%s%s%s%s%s %-15s %s",
|
||||
decode ? "D" : (/* p2->decoder ? "d" : */ " "),
|
||||
encode ? "E" : " ",
|
||||
type_str,
|
||||
@ -685,13 +696,14 @@ void show_codecs(void)
|
||||
cap & CODEC_CAP_TRUNCATED ? "T" : " ",
|
||||
p2->name,
|
||||
p2->long_name ? p2->long_name : "");
|
||||
/* if(p2->decoder && decode==0)
|
||||
printf(" use %s for decoding", p2->decoder->name);*/
|
||||
#if 0
|
||||
if (p2->decoder && decode == 0)
|
||||
printf(" use %s for decoding", p2->decoder->name);
|
||||
#endif
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
printf(
|
||||
"Note, the names of encoders and decoders do not always match, so there are\n"
|
||||
printf("Note, the names of encoders and decoders do not always match, so there are\n"
|
||||
"several cases where the above table shows encoder only or decoder only entries\n"
|
||||
"even though both encoding and decoding are supported. For example, the h263\n"
|
||||
"decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
|
||||
@ -737,8 +749,7 @@ void show_pix_fmts(void)
|
||||
{
|
||||
enum PixelFormat pix_fmt;
|
||||
|
||||
printf(
|
||||
"Pixel formats:\n"
|
||||
printf("Pixel formats:\n"
|
||||
"I.... = Supported Input format for conversion\n"
|
||||
".O... = Supported Output format for conversion\n"
|
||||
"..H.. = Hardware accelerated format\n"
|
||||
@ -792,7 +803,8 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
|
||||
FILE *f = fopen(filename, "rb");
|
||||
|
||||
if (!f) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, strerror(errno));
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
|
||||
strerror(errno));
|
||||
return AVERROR(errno);
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
@ -828,7 +840,8 @@ void init_pts_correction(PtsCorrectionContext *ctx)
|
||||
ctx->last_pts = ctx->last_dts = INT64_MIN;
|
||||
}
|
||||
|
||||
int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int64_t dts)
|
||||
int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts,
|
||||
int64_t dts)
|
||||
{
|
||||
int64_t pts = AV_NOPTS_VALUE;
|
||||
|
||||
@ -850,14 +863,14 @@ int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int6
|
||||
}
|
||||
|
||||
FILE *get_preset_file(char *filename, size_t filename_size,
|
||||
const char *preset_name, int is_path, const char *codec_name)
|
||||
const char *preset_name, int is_path,
|
||||
const char *codec_name)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
int i;
|
||||
const char *base[3] = { getenv("AVCONV_DATADIR"),
|
||||
getenv("HOME"),
|
||||
AVCONV_DATADIR,
|
||||
};
|
||||
AVCONV_DATADIR, };
|
||||
|
||||
if (is_path) {
|
||||
av_strlcpy(filename, preset_name, filename_size);
|
||||
@ -866,11 +879,14 @@ FILE *get_preset_file(char *filename, size_t filename_size,
|
||||
for (i = 0; i < 3 && !f; i++) {
|
||||
if (!base[i])
|
||||
continue;
|
||||
snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.avconv", preset_name);
|
||||
snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
|
||||
i != 1 ? "" : "/.avconv", preset_name);
|
||||
f = fopen(filename, "r");
|
||||
if (!f && codec_name) {
|
||||
snprintf(filename, filename_size,
|
||||
"%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.avconv", codec_name, preset_name);
|
||||
"%s%s/%s-%s.ffpreset",
|
||||
base[i], i != 1 ? "" : "/.avconv", codec_name,
|
||||
preset_name);
|
||||
f = fopen(filename, "r");
|
||||
}
|
||||
}
|
||||
@ -883,7 +899,8 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
|
||||
{
|
||||
if (*spec <= '9' && *spec >= '0') /* opt:index */
|
||||
return strtol(spec, NULL, 0) == st->index;
|
||||
else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || *spec == 't') { /* opt:[vasdt] */
|
||||
else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
|
||||
*spec == 't') { /* opt:[vasdt] */
|
||||
enum AVMediaType type;
|
||||
|
||||
switch (*spec++) {
|
||||
@ -931,12 +948,15 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFormatContext *s, AVStream *st)
|
||||
AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id,
|
||||
AVFormatContext *s, AVStream *st)
|
||||
{
|
||||
AVDictionary *ret = NULL;
|
||||
AVDictionaryEntry *t = NULL;
|
||||
AVCodec *codec = s->oformat ? avcodec_find_encoder(codec_id) : avcodec_find_decoder(codec_id);
|
||||
int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM;
|
||||
AVCodec *codec = s->oformat ? avcodec_find_encoder(codec_id)
|
||||
: avcodec_find_decoder(codec_id);
|
||||
int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
|
||||
: AV_OPT_FLAG_DECODING_PARAM;
|
||||
char prefix = 0;
|
||||
const AVClass *cc = avcodec_get_class();
|
||||
|
||||
@ -944,9 +964,18 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFor
|
||||
return NULL;
|
||||
|
||||
switch (codec->type) {
|
||||
case AVMEDIA_TYPE_VIDEO: prefix = 'v'; flags |= AV_OPT_FLAG_VIDEO_PARAM; break;
|
||||
case AVMEDIA_TYPE_AUDIO: prefix = 'a'; flags |= AV_OPT_FLAG_AUDIO_PARAM; break;
|
||||
case AVMEDIA_TYPE_SUBTITLE: prefix = 's'; flags |= AV_OPT_FLAG_SUBTITLE_PARAM; break;
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
prefix = 'v';
|
||||
flags |= AV_OPT_FLAG_VIDEO_PARAM;
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
prefix = 'a';
|
||||
flags |= AV_OPT_FLAG_AUDIO_PARAM;
|
||||
break;
|
||||
case AVMEDIA_TYPE_SUBTITLE:
|
||||
prefix = 's';
|
||||
flags |= AV_OPT_FLAG_SUBTITLE_PARAM;
|
||||
break;
|
||||
}
|
||||
|
||||
while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) {
|
||||
@ -961,9 +990,13 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFor
|
||||
}
|
||||
|
||||
if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) ||
|
||||
(codec && codec->priv_class && av_opt_find(&codec->priv_class, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ)))
|
||||
(codec && codec->priv_class &&
|
||||
av_opt_find(&codec->priv_class, t->key, NULL, flags,
|
||||
AV_OPT_SEARCH_FAKE_OBJ)))
|
||||
av_dict_set(&ret, t->key, t->value, 0);
|
||||
else if (t->key[0] == prefix && av_opt_find(&cc, t->key+1, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ))
|
||||
else if (t->key[0] == prefix &&
|
||||
av_opt_find(&cc, t->key + 1, NULL, flags,
|
||||
AV_OPT_SEARCH_FAKE_OBJ))
|
||||
av_dict_set(&ret, t->key + 1, t->value, 0);
|
||||
|
||||
if (p)
|
||||
@ -972,7 +1005,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFor
|
||||
return ret;
|
||||
}
|
||||
|
||||
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
|
||||
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
|
||||
AVDictionary *codec_opts)
|
||||
{
|
||||
int i;
|
||||
AVDictionary **opts;
|
||||
@ -981,11 +1015,13 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *cod
|
||||
return NULL;
|
||||
opts = av_mallocz(s->nb_streams * sizeof(*opts));
|
||||
if (!opts) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Could not alloc memory for stream options.\n");
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Could not alloc memory for stream options.\n");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < s->nb_streams; i++)
|
||||
opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id, s, s->streams[i]);
|
||||
opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id,
|
||||
s, s->streams[i]);
|
||||
return opts;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user