diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-05-03 23:49:16 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-05-03 23:49:16 +0200 |
commit | 4351c288b9841d02a55e7b836796d7da6d19cac8 (patch) | |
tree | 0e2f5ae6b1d0a8a476d1bd16c001d9927074a544 /cmdutils.c | |
parent | a6b630e9b6d873d97c91322608ce4ac5fb9bed78 (diff) | |
download | ffmpeg-4351c288b9841d02a55e7b836796d7da6d19cac8.tar.gz |
ffplay&cmdutils:Factor get_rotation() code out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'cmdutils.c')
-rw-r--r-- | cmdutils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cmdutils.c b/cmdutils.c index 5a18cd5653..d5a2cbea6b 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -41,6 +41,7 @@ #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/parseutils.h" @@ -2229,4 +2230,26 @@ int show_sinks(void *optctx, const char *opt, const char *arg) av_log_set_level(error_level); return ret; } + +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); + + return theta; +} + #endif |