X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=cmdutils.c;h=ed6951f6b7bc9726e0c2ec314539710587062911;hb=7ac5c38ec5baeea6ad647ccc9bb7e97564c50ec2;hp=5a18cd56531cf71fdf43ce7ecbb9df080fa8fd95;hpb=78f50e7eb69437fd108c82f963e7add5e9faa36e;p=ffmpeg diff --git a/cmdutils.c b/cmdutils.c index 5a18cd56531..ed6951f6b7b 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -41,8 +41,10 @@ #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" @@ -2073,6 +2075,30 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) 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_ask_for_sample(NULL, "Odd rotation angle\n"); + + return theta; +} + #if CONFIG_AVDEVICE static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) { @@ -2229,4 +2255,5 @@ int show_sinks(void *optctx, const char *opt, const char *arg) av_log_set_level(error_level); return ret; } + #endif