#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
+#include "libavutil/display.h"
#include "libavutil/mathematics.h"
#include "libavutil/imgutils.h"
+#include "libavutil/libm.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/cpu.h"
#include "libavutil/ffversion.h"
+#include "libavutil/version.h"
#include "cmdutils.h"
#if CONFIG_NETWORK
#include "libavformat/network.h"
static int init_report(const char *env);
-struct SwsContext *sws_opts;
+AVDictionary *sws_dict;
AVDictionary *swr_opts;
AVDictionary *format_opts, *codec_opts, *resample_opts;
void init_opts(void)
{
-
- if(CONFIG_SWSCALE)
- sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
- NULL, NULL, NULL);
+ av_dict_set(&sws_dict, "flags", "bicubic", 0);
}
void uninit_opts(void)
{
-#if CONFIG_SWSCALE
- sws_freeContext(sws_opts);
- sws_opts = NULL;
-#endif
-
av_dict_free(&swr_opts);
+ av_dict_free(&sws_dict);
av_dict_free(&format_opts);
av_dict_free(&codec_opts);
av_dict_free(&resample_opts);
fputc('"', report_file);
}
+static void check_options(const OptionDef *po)
+{
+ while (po->name) {
+ if (po->flags & OPT_PERFILE)
+ av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT));
+ po++;
+ }
+}
+
void parse_loglevel(int argc, char **argv, const OptionDef *options)
{
int idx = locate_option(argc, argv, options, "loglevel");
const char *env;
+
+ check_options(options);
+
if (!idx)
idx = locate_option(argc, argv, options, "v");
if (idx && argv[idx + 1])
return o;
}
-#define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
+#define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0
int opt_default(void *optctx, const char *opt, const char *arg)
{
const AVOption *o;
#if CONFIG_AVRESAMPLE
const AVClass *rc = avresample_get_class();
#endif
- const AVClass *sc, *swr_class;
+#if CONFIG_SWSCALE
+ const AVClass *sc = sws_get_class();
+#endif
+#if CONFIG_SWRESAMPLE
+ const AVClass *swr_class = swr_get_class();
+#endif
if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
av_log_set_level(AV_LOG_DEBUG);
consumed = 1;
}
#if CONFIG_SWSCALE
- sc = sws_get_class();
- if (!consumed && 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 (!consumed && (o = opt_find(&sc, opt, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
+ struct SwsContext *sws = sws_alloc_context();
+ int ret = av_opt_set(sws, opt, arg, 0);
+ sws_freeContext(sws);
+ if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") ||
+ !strcmp(opt, "dstw") || !strcmp(opt, "dsth") ||
+ !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) {
+ av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n");
+ return AVERROR(EINVAL);
+ }
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
return ret;
}
+
+ av_dict_set(&sws_dict, opt, arg, FLAGS);
+
consumed = 1;
}
#else
}
#endif
#if CONFIG_SWRESAMPLE
- swr_class = swr_get_class();
if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
struct SwrContext *swr = swr_alloc();
*g = octx->cur_group;
g->arg = arg;
g->group_def = l->group_def;
-#if CONFIG_SWSCALE
- g->sws_opts = sws_opts;
-#endif
+ g->sws_dict = sws_dict;
g->swr_opts = swr_opts;
g->codec_opts = codec_opts;
g->format_opts = format_opts;
codec_opts = NULL;
format_opts = NULL;
resample_opts = NULL;
-#if CONFIG_SWSCALE
- sws_opts = NULL;
-#endif
+ sws_dict = NULL;
swr_opts = NULL;
init_opts();
av_dict_free(&l->groups[j].codec_opts);
av_dict_free(&l->groups[j].format_opts);
av_dict_free(&l->groups[j].resample_opts);
-#if CONFIG_SWSCALE
- sws_freeContext(l->groups[j].sws_opts);
-#endif
+
+ av_dict_free(&l->groups[j].sws_dict);
av_dict_free(&l->groups[j].swr_opts);
}
av_freep(&l->groups);
LIB##LIBNAME##_VERSION_MAJOR, \
LIB##LIBNAME##_VERSION_MINOR, \
LIB##LIBNAME##_VERSION_MICRO, \
- version >> 16, version >> 8 & 0xff, version & 0xff); \
+ AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\
+ AV_VERSION_MICRO(version)); \
} \
if (flags & SHOW_CONFIG) { \
const char *cfg = libname##_configuration(); \
static void print_all_libs_info(int flags, int level)
{
- PRINT_LIB_INFO(avutil, AVUTIL, flags, level);
- PRINT_LIB_INFO(avcodec, AVCODEC, flags, level);
- PRINT_LIB_INFO(avformat, AVFORMAT, flags, level);
- PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
- PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
+ PRINT_LIB_INFO(avutil, AVUTIL, flags, level);
+ PRINT_LIB_INFO(avcodec, AVCODEC, flags, level);
+ PRINT_LIB_INFO(avformat, AVFORMAT, flags, level);
+ PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
+ PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level);
- PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
- PRINT_LIB_INFO(swresample,SWRESAMPLE, flags, level);
- PRINT_LIB_INFO(postproc, POSTPROC, flags, level);
+ PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
+ PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level);
+ PRINT_LIB_INFO(postproc, POSTPROC, flags, level);
}
static void print_program_info(int flags, int level)
printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name,
c->long_name ? c->long_name : "");
+ printf(" General capabilities: ");
+ if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)
+ printf("horizband ");
+ if (c->capabilities & AV_CODEC_CAP_DR1)
+ printf("dr1 ");
+ if (c->capabilities & AV_CODEC_CAP_TRUNCATED)
+ printf("trunc ");
+ if (c->capabilities & AV_CODEC_CAP_DELAY)
+ printf("delay ");
+ if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)
+ printf("small ");
+ if (c->capabilities & AV_CODEC_CAP_SUBFRAMES)
+ printf("subframes ");
+ if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL)
+ printf("exp ");
+ if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF)
+ printf("chconf ");
+ if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE)
+ printf("paramchange ");
+ if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
+ printf("variable ");
+ if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
+ AV_CODEC_CAP_SLICE_THREADS |
+ AV_CODEC_CAP_AUTO_THREADS))
+ printf("threads ");
+ if (!c->capabilities)
+ printf("none");
+ printf("\n");
+
if (c->type == AVMEDIA_TYPE_VIDEO ||
c->type == AVMEDIA_TYPE_AUDIO) {
printf(" Threading capabilities: ");
- switch (c->capabilities & (CODEC_CAP_FRAME_THREADS |
- CODEC_CAP_SLICE_THREADS)) {
- case CODEC_CAP_FRAME_THREADS |
- CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
- case CODEC_CAP_FRAME_THREADS: printf("frame"); break;
- case CODEC_CAP_SLICE_THREADS: printf("slice"); break;
- default: printf("no"); break;
+ switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
+ AV_CODEC_CAP_SLICE_THREADS |
+ AV_CODEC_CAP_AUTO_THREADS)) {
+ case AV_CODEC_CAP_FRAME_THREADS |
+ AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
+ case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break;
+ case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break;
+ case AV_CODEC_CAP_AUTO_THREADS : printf("auto"); break;
+ default: printf("none"); break;
}
printf("\n");
}
const AVCodecDescriptor * const *da = a;
const AVCodecDescriptor * const *db = b;
- return (*da)->type != (*db)->type ? (*da)->type - (*db)->type :
+ return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) :
strcmp((*da)->name, (*db)->name);
}
while ((codec = next_codec_for_id(desc->id, codec, encoder))) {
printf(" %c", get_media_type_char(desc->type));
- printf((codec->capabilities & CODEC_CAP_FRAME_THREADS) ? "F" : ".");
- printf((codec->capabilities & CODEC_CAP_SLICE_THREADS) ? "S" : ".");
- printf((codec->capabilities & CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
- printf((codec->capabilities & CODEC_CAP_DRAW_HORIZ_BAND)?"B" : ".");
- printf((codec->capabilities & CODEC_CAP_DR1) ? "D" : ".");
+ printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : ".");
+ printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : ".");
+ printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
+ printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : ".");
+ printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : ".");
printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : "");
if (strcmp(codec->name, desc->name))
*(descr_cur++) = '>';
}
pad = i ? filter->outputs : filter->inputs;
- for (j = 0; pad && pad[j].name; j++) {
+ for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) {
if (descr_cur >= descr + sizeof(descr) - 4)
break;
- *(descr_cur++) = get_media_type_char(pad[j].type);
+ *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j));
}
if (!j)
*(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) ||
( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|';
}
*descr_cur = 0;
- printf(" %c%c%c %-16s %-10s %s\n",
+ printf(" %c%c%c %-17s %-10s %s\n",
filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.',
filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.',
filter->process_command ? 'C' : '.',
return yesno;
}
-int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
-{
- int64_t ret;
- FILE *f = av_fopen_utf8(filename, "rb");
-
- if (!f) {
- ret = AVERROR(errno);
- av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
- strerror(errno));
- return ret;
- }
-
- 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");
- ret = AVERROR(ENOMEM);
- goto out;
- }
- ret = fread(*bufptr, 1, *size, f);
- if (ret < *size) {
- av_free(*bufptr);
- if (ferror(f)) {
- ret = AVERROR(errno);
- av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
- filename, strerror(errno));
- } else
- ret = AVERROR_EOF;
- } else {
- ret = 0;
- (*bufptr)[(*size)++] = '\0';
- }
-
-out:
- if (ret < 0)
- av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", av_err2str(ret));
- fclose(f);
- return ret;
-}
-
FILE *get_preset_file(char *filename, size_t filename_size,
const char *preset_name, int is_path,
const char *codec_name)
return array;
}
+double get_rotation(AVStream *st)
+{
+ AVDictionaryEntry *rotate_tag = av_dict_get(st->metadata, "rotate", NULL, 0);
+ uint8_t* displaymatrix = av_stream_get_side_data(st,
+ AV_PKT_DATA_DISPLAYMATRIX, NULL);
+ double theta = 0;
+
+ if (rotate_tag && *rotate_tag->value && strcmp(rotate_tag->value, "0")) {
+ char *tail;
+ theta = av_strtod(rotate_tag->value, &tail);
+ if (*tail)
+ theta = 0;
+ }
+ if (displaymatrix && !theta)
+ theta = -av_display_rotation_get((int32_t*) displaymatrix);
+
+ theta -= 360*floor(theta/360 + 0.9/360);
+
+ if (fabs(theta - 90*round(theta/90)) > 2)
+ av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n"
+ "If you want to help, upload a sample "
+ "of this file to ftp://upload.ffmpeg.org/incoming/ "
+ "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)");
+
+ return theta;
+}
+
#if CONFIG_AVDEVICE
static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
{
av_log_set_level(error_level);
return ret;
}
+
#endif