aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-10 00:15:34 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-10 00:19:43 +0200
commitefc66d69bfb622e874d883e0b304cf18b12e41bd (patch)
tree01adc68c2448e4f1950c37348db09790b092f875
parentcd0dc88751db969964e7b40c4d4b5fd446ac1589 (diff)
parent0569a7e0bd2006d9a5248d17a1f4bf3ca654ae50 (diff)
downloadffmpeg-efc66d69bfb622e874d883e0b304cf18b12e41bd.tar.gz
Merge commit '0569a7e0bd2006d9a5248d17a1f4bf3ca654ae50'
* commit '0569a7e0bd2006d9a5248d17a1f4bf3ca654ae50': hevc: parse display orientation SEI message Conflicts: libavcodec/hevc.h libavcodec/hevc_sei.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/hevc.c15
-rw-r--r--libavcodec/hevc.h5
-rw-r--r--libavcodec/hevc_sei.c18
3 files changed, 38 insertions, 0 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 8d951b0e67..99298a8573 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -26,6 +26,7 @@
#include "libavutil/atomic.h"
#include "libavutil/attributes.h"
#include "libavutil/common.h"
+#include "libavutil/display.h"
#include "libavutil/internal.h"
#include "libavutil/md5.h"
#include "libavutil/opt.h"
@@ -2339,6 +2340,20 @@ static int set_side_data(HEVCContext *s)
stereo->flags = AV_STEREO3D_FLAG_INVERT;
}
+ if (s->sei_display_orientation_present &&
+ (s->sei_anticlockwise_rotation || s->sei_hflip || s->sei_vflip)) {
+ double angle = s->sei_anticlockwise_rotation * 360 / (double) (1 << 16);
+ AVFrameSideData *rotation = av_frame_new_side_data(out,
+ AV_FRAME_DATA_DISPLAYMATRIX,
+ sizeof(int32_t) * 9);
+ if (!rotation)
+ return AVERROR(ENOMEM);
+
+ av_display_rotation_set((int32_t *)rotation->data, angle);
+ av_display_matrix_flip((int32_t *)rotation->data,
+ s->sei_vflip, s->sei_hflip);
+ }
+
return 0;
}
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 7c7a459999..5f964c3436 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -885,6 +885,11 @@ typedef struct HEVCContext {
int content_interpretation_type;
int quincunx_subsampling;
+ /** display orientation */
+ int sei_display_orientation_present;
+ int sei_anticlockwise_rotation;
+ int sei_hflip, sei_vflip;
+
int picture_struct;
} HEVCContext;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 29e76ab972..6dfe69d57e 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -74,6 +74,21 @@ static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
skip_bits1(gb); // upsampled_aspect_ratio_flag
}
+static void decode_nal_sei_display_orientation(HEVCContext *s)
+{
+ GetBitContext *gb = &s->HEVClc->gb;
+
+ s->sei_display_orientation_present = !get_bits1(gb);
+
+ if (s->sei_display_orientation_present) {
+ s->sei_hflip = get_bits1(gb); // hor_flip
+ s->sei_vflip = get_bits1(gb); // ver_flip
+
+ s->sei_anticlockwise_rotation = get_bits(gb, 16);
+ skip_bits1(gb); // display_orientation_persistence_flag
+ }
+}
+
static int decode_pic_timing(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
@@ -149,6 +164,9 @@ static int decode_nal_sei_message(HEVCContext *s)
} else if (payload_type == 45) {
decode_nal_sei_frame_packing_arrangement(s);
return 1;
+ } else if (payload_type == 47) {
+ decode_nal_sei_display_orientation(s);
+ return 1;
} else if (payload_type == 1){
int ret = decode_pic_timing(s);
av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", payload_type);