summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-12-09 22:25:38 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-12-09 22:25:38 +0100
commit31a52a60c9778e3e39631a9722d4b7db931dc377 (patch)
tree20b9bcdd19d1bc3570937308744aca43c24b2e3d /libavcodec
parent33dfddf65324dcb28114ea6907071605c2c3857b (diff)
parentacb77dff6af036192f6064c84f9cccc48582989e (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: hevc: parse frame packing arrangement SEI messages and save relevant stereo3d information Conflicts: libavcodec/hevc.h libavcodec/hevc_sei.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/hevc.c40
-rw-r--r--libavcodec/hevc.h6
-rw-r--r--libavcodec/hevc_sei.c9
3 files changed, 53 insertions, 2 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 4294760bb7..06f4b1654b 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -30,6 +30,7 @@
#include "libavutil/md5.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/stereo3d.h"
#include "bytestream.h"
#include "cabac_functions.h"
@@ -2072,6 +2073,41 @@ static void restore_tqb_pixels(HEVCContext *s)
}
}
+static int set_side_data(HEVCContext *s)
+{
+ AVFrame *out = s->ref->frame;
+
+ if (s->sei_frame_packing_present &&
+ s->frame_packing_arrangement_type >= 3 &&
+ s->frame_packing_arrangement_type <= 5 &&
+ s->content_interpretation_type > 0 &&
+ s->content_interpretation_type < 3) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(out);
+ if (!stereo)
+ return AVERROR(ENOMEM);
+
+ switch (s->frame_packing_arrangement_type) {
+ case 3:
+ if (s->quincunx_subsampling)
+ stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+ else
+ stereo->type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case 4:
+ stereo->type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ case 5:
+ stereo->type = AV_STEREO3D_FRAMESEQUENCE;
+ break;
+ }
+
+ if (s->content_interpretation_type == 2)
+ stereo->flags = AV_STEREO3D_FLAG_INVERT;
+ }
+
+ return 0;
+}
+
static int hevc_frame_start(HEVCContext *s)
{
HEVCLocalContext *lc = s->HEVClc;
@@ -2106,6 +2142,10 @@ static int hevc_frame_start(HEVCContext *s)
goto fail;
}
+ ret = set_side_data(s);
+ if (ret < 0)
+ goto fail;
+
av_frame_unref(s->output_frame);
ret = ff_hevc_output_frame(s, s->output_frame, 0);
if (ret < 0)
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 74673a9f1a..bbb18973bd 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -886,6 +886,12 @@ typedef struct HEVCContext {
int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
int nuh_layer_id;
+ /** frame packing arrangement variables */
+ int sei_frame_packing_present;
+ int frame_packing_arrangement_type;
+ int content_interpretation_type;
+ int quincunx_subsampling;
+
int picture_struct;
} HEVCContext;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index af8cb7d60e..2804ef1a9c 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -52,14 +52,14 @@ static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
- int cancel, type, quincunx;
+ int cancel, type, quincunx, content;
get_ue_golomb(gb); // frame_packing_arrangement_id
cancel = get_bits1(gb); // frame_packing_cancel_flag
if (cancel == 0) {
type = get_bits(gb, 7); // frame_packing_arrangement_type
quincunx = get_bits1(gb); // quincunx_sampling_flag
- skip_bits(gb, 6); // content_interpretation_type
+ content = get_bits(gb, 6); // content_interpretation_type
// the following skips spatial_flipping_flag frame0_flipped_flag
// field_views_flag current_frame_is_frame0_flag
@@ -72,6 +72,11 @@ static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
skip_bits1(gb); // frame_packing_arrangement_persistance_flag
}
skip_bits1(gb); // upsampled_aspect_ratio_flag
+
+ s->sei_frame_packing_present = (cancel == 0);
+ s->frame_packing_arrangement_type = type;
+ s->content_interpretation_type = content;
+ s->quincunx_subsampling = quincunx;
}
static int decode_pic_timing(HEVCContext *s)