#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "libavutil/cpu.h"
+#include "avversion.h"
#include "cmdutils.h"
-#include "version.h"
#if CONFIG_NETWORK
#include "libavformat/network.h"
#endif
struct SwsContext *sws_opts;
AVDictionary *format_opts, *codec_opts, *resample_opts;
-static const int this_year = 2013;
+static const int this_year = 2015;
void init_opts(void)
{
const char *p = strchr(name, ':');
int len = p ? p - name : strlen(name);
- while (po->name != NULL) {
+ while (po->name) {
if (!strncmp(name, po->name, len) && strlen(po->name) == len)
break;
po++;
win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize);
argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1);
- if (win32_argv_utf8 == NULL) {
+ if (!win32_argv_utf8) {
LocalFree(argv_w);
return;
}
if (po->flags & OPT_SPEC) {
SpecifierOpt **so = dst;
char *p = strchr(opt, ':');
+ char *str;
dstcount = (int *)(so + 1);
*so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1);
- (*so)[*dstcount - 1].specifier = av_strdup(p ? p + 1 : "");
+ str = av_strdup(p ? p + 1 : "");
+ if (!str)
+ return AVERROR(ENOMEM);
+ (*so)[*dstcount - 1].specifier = str;
dst = &(*so)[*dstcount - 1].u;
}
char *str;
str = av_strdup(arg);
av_freep(dst);
+ if (!str)
+ return AVERROR(ENOMEM);
*(char **)dst = str;
} else if (po->flags & OPT_BOOL || po->flags & OPT_INT) {
*(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
(po->name && !strcmp(optname, po->name)))
return i;
- if (!po || po->flags & HAS_ARG)
+ if (!po->name || po->flags & HAS_ARG)
i++;
}
return 0;
{ "info" , AV_LOG_INFO },
{ "verbose", AV_LOG_VERBOSE },
{ "debug" , AV_LOG_DEBUG },
+ { "trace" , AV_LOG_TRACE },
};
char *tail;
int level;
const char *long_name = NULL;
while ((ofmt = av_oformat_next(ofmt))) {
- if ((name == NULL || strcmp(ofmt->name, name) < 0) &&
+ if ((!name || strcmp(ofmt->name, name) < 0) &&
strcmp(ofmt->name, last_name) > 0) {
name = ofmt->name;
long_name = ofmt->long_name;
}
}
while ((ifmt = av_iformat_next(ifmt))) {
- if ((name == NULL || strcmp(ifmt->name, name) < 0) &&
+ if ((!name || strcmp(ifmt->name, name) < 0) &&
strcmp(ifmt->name, last_name) > 0) {
name = ifmt->name;
long_name = ifmt->long_name;
if (name && strcmp(ifmt->name, name) == 0)
decode = 1;
}
- if (name == NULL)
+ if (!name)
break;
last_name = name;
int show_filters(void *optctx, const char *opt, const char *arg)
{
- const AVFilter av_unused(*filter) = NULL;
+#if CONFIG_AVFILTER
+ const AVFilter *filter = NULL;
printf("Filters:\n");
-#if CONFIG_AVFILTER
while ((filter = avfilter_next(filter)))
printf("%-16s %s\n", filter->name, filter->description);
+#else
+ printf("No filters available: libavfilter disabled\n");
#endif
return 0;
}
av_log_set_callback(log_callback_help);
topic = av_strdup(arg ? arg : "");
+ if (!topic)
+ return AVERROR(ENOMEM);
par = strchr(topic, '=');
if (par)
*par++ = 0;
strerror(errno));
return AVERROR(errno);
}
- fseek(f, 0, SEEK_END);
- *size = ftell(f);
- fseek(f, 0, SEEK_SET);
+
+ ret = fseek(f, 0, SEEK_END);
+ if (ret == -1) {
+ ret = AVERROR(errno);
+ goto out;
+ }
+
+ ret = ftell(f);
+ if (ret < 0) {
+ ret = AVERROR(errno);
+ goto out;
+ }
+ *size = ret;
+
+ ret = fseek(f, 0, SEEK_SET);
+ if (ret == -1) {
+ ret = AVERROR(errno);
+ goto out;
+ }
+
*bufptr = av_malloc(*size + 1);
if (!*bufptr) {
av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
- fclose(f);
- return AVERROR(ENOMEM);
+ ret = AVERROR(ENOMEM);
+ goto out;
}
ret = fread(*bufptr, 1, *size, f);
if (ret < *size) {
(*bufptr)[(*size)++] = '\0';
}
+out:
fclose(f);
return ret;
}
return 1;
}
return 0;
+ } else if (*spec == 'i' && *(spec + 1) == ':') {
+ int stream_id;
+ char *endptr;
+ spec += 2;
+ stream_id = strtol(spec, &endptr, 0);
+ return stream_id == st->id;
+ } else if (*spec == 'm' && *(spec + 1) == ':') {
+ AVDictionaryEntry *tag;
+ char *key, *val;
+ int ret;
+
+ spec += 2;
+ val = strchr(spec, ':');
+
+ key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
+ if (!key)
+ return AVERROR(ENOMEM);
+
+ tag = av_dict_get(st->metadata, key, NULL, 0);
+ if (tag) {
+ if (!val || !strcmp(tag->value, val + 1))
+ ret = 1;
+ else
+ ret = 0;
+ } else
+ ret = 0;
+
+ av_freep(&key);
+ return ret;
+ } else if (*spec == 'u') {
+ AVCodecContext *avctx = st->codec;
+ int val;
+ switch (avctx->codec_type) {
+ case AVMEDIA_TYPE_AUDIO:
+ val = avctx->sample_rate && avctx->channels;
+ if (avctx->sample_fmt == AV_SAMPLE_FMT_NONE)
+ return 0;
+ break;
+ case AVMEDIA_TYPE_VIDEO:
+ val = avctx->width && avctx->height;
+ if (avctx->pix_fmt == AV_PIX_FMT_NONE)
+ return 0;
+ break;
+ case AVMEDIA_TYPE_UNKNOWN:
+ val = 0;
+ break;
+ default:
+ val = 1;
+ break;
+ }
+ return avctx->codec_id != AV_CODEC_ID_NONE && val != 0;
} else if (!*spec) /* empty specifier, matches everything */
return 1;