* commit 'e2d50fc2f5f3600e13055acf1a10fec35e941f37':
avplay: Add support for rotated video
Conflicts:
configure
doc/ffplay.texi
ffplay.c
See: 08c51e12b1c3f3e3e68e33eb46be7131df5b3682
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -161,7 +161,7 @@ Force a specific video decoder. |
161 | 161 |
Force a specific subtitle decoder. |
162 | 162 |
|
163 | 163 |
@item -autorotate |
164 |
-Automatically rotate the video according to presentation metadata. Enabled by |
|
164 |
+Automatically rotate the video according to file metadata. Enabled by |
|
165 | 165 |
default, use @option{-noautorotate} to disable it. |
166 | 166 |
|
167 | 167 |
@item -framedrop |
... | ... |
@@ -32,6 +32,7 @@ |
32 | 32 |
|
33 | 33 |
#include "libavutil/avstring.h" |
34 | 34 |
#include "libavutil/colorspace.h" |
35 |
+#include "libavutil/display.h" |
|
35 | 36 |
#include "libavutil/mathematics.h" |
36 | 37 |
#include "libavutil/pixdesc.h" |
37 | 38 |
#include "libavutil/imgutils.h" |
... | ... |
@@ -2017,6 +2018,9 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c |
2017 | 2017 |
|
2018 | 2018 |
if (autorotate) { |
2019 | 2019 |
AVDictionaryEntry *rotate_tag = av_dict_get(is->video_st->metadata, "rotate", NULL, 0); |
2020 |
+ uint8_t* displaymatrix = av_stream_get_side_data(is->video_st, |
|
2021 |
+ AV_PKT_DATA_DISPLAYMATRIX, NULL); |
|
2022 |
+ |
|
2020 | 2023 |
if (rotate_tag && *rotate_tag->value && strcmp(rotate_tag->value, "0")) { |
2021 | 2024 |
if (!strcmp(rotate_tag->value, "90")) { |
2022 | 2025 |
INSERT_FILT("transpose", "clock"); |
... | ... |
@@ -2030,6 +2034,16 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c |
2030 | 2030 |
snprintf(rotate_buf, sizeof(rotate_buf), "%s*PI/180", rotate_tag->value); |
2031 | 2031 |
INSERT_FILT("rotate", rotate_buf); |
2032 | 2032 |
} |
2033 |
+ } else if (displaymatrix) { |
|
2034 |
+ double rot = av_display_rotation_get((int32_t*) displaymatrix); |
|
2035 |
+ if (rot < -135 || rot > 135) { |
|
2036 |
+ INSERT_FILT("vflip", NULL); |
|
2037 |
+ INSERT_FILT("hflip", NULL); |
|
2038 |
+ } else if (rot < -45) { |
|
2039 |
+ INSERT_FILT("transpose", "dir=clock"); |
|
2040 |
+ } else if (rot > 45) { |
|
2041 |
+ INSERT_FILT("transpose", "dir=cclock"); |
|
2042 |
+ } |
|
2033 | 2043 |
} |
2034 | 2044 |
} |
2035 | 2045 |
|