From 5b10ef729f610fcbc9c485e7b643ce53268144cb Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Wed, 20 Feb 2013 16:34:58 +0100 Subject: h264: parse frame packing arrangement SEI messages and save relevant stereo3d information --- libavcodec/h264_sei.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'libavcodec/h264_sei.c') 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); -- cgit v1.2.3