summaryrefslogtreecommitdiff
path: root/libavcodec/h264_sei.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2013-02-20 16:34:58 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2013-12-09 16:02:43 +0100
commit5b10ef729f610fcbc9c485e7b643ce53268144cb (patch)
tree4b147db6c5e36bbf1021797ebd2b14c427bee0e4 /libavcodec/h264_sei.c
parent7e244c68600f479270e979258e389ed5240885fb (diff)
h264: parse frame packing arrangement SEI messages and save relevant stereo3d information
Diffstat (limited to 'libavcodec/h264_sei.c')
-rw-r--r--libavcodec/h264_sei.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 27a2c7689c..746c2132c1 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -42,6 +42,7 @@ void ff_h264_reset_sei(H264Context *h)
h->sei_dpb_output_delay = 0;
h->sei_cpb_removal_delay = -1;
h->sei_buffering_period_present = 0;
+ h->sei_frame_packing_present = 0;
}
static int decode_picture_timing(H264Context *h)
@@ -175,6 +176,40 @@ static int decode_buffering_period(H264Context *h)
return 0;
}
+static int decode_frame_packing_arrangement(H264Context *h)
+{
+ int cancel;
+ int quincunx = 0;
+ int content = -1;
+ int type = -1;
+
+ get_ue_golomb(&h->gb); // frame_packing_arrangement_id
+ cancel = get_bits1(&h->gb); // frame_packing_arrangement_cancel_flag
+ if (cancel == 0) {
+ type = get_bits(&h->gb, 7); // frame_packing_arrangement_type
+ quincunx = get_bits1(&h->gb); // quincunx_sampling_flag
+ content = get_bits(&h->gb, 6); // content_interpretation_type
+
+ // the following skips: spatial_flipping_flag, frame0_flipped_flag,
+ // field_views_flag, current_frame_is_frame0_flag,
+ // frame0_self_contained_flag, frame1_self_contained_flag
+ skip_bits(&h->gb, 6);
+
+ if (quincunx == 0 && type != 5)
+ skip_bits(&h->gb, 16); // frame[01]_grid_position_[xy]
+ skip_bits(&h->gb, 8); // frame_packing_arrangement_reserved_byte
+ get_ue_golomb(&h->gb); // frame_packing_arrangement_repetition_period
+ }
+ skip_bits1(&h->gb); // frame_packing_arrangement_extension_flag
+
+ h->sei_frame_packing_present = (cancel == 0);
+ h->frame_packing_arrangement_type = type;
+ h->content_interpretation_type = content;
+ h->quincunx_subsampling = quincunx;
+
+ return 0;
+}
+
int ff_h264_decode_sei(H264Context *h)
{
while (get_bits_left(&h->gb) > 16) {
@@ -217,6 +252,11 @@ int ff_h264_decode_sei(H264Context *h)
if (ret < 0)
return ret;
break;
+ case SEI_TYPE_FRAME_PACKING:
+ ret = decode_frame_packing_arrangement(h);
+ if (ret < 0)
+ return ret;
+ break;
default:
av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
skip_bits(&h->gb, 8 * size);