From 65ede48b7bfd84aaf7f2cbd3908e915a08525172 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 2 Jan 2013 14:02:29 +0100 Subject: [PATCH] mpeg2: handle sequence_display_extension(). --- gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c index 6fe9a3a7cb..16b4f7510b 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c @@ -190,6 +190,7 @@ struct _GstVaapiDecoderUnitMpeg2 { union { GstMpegVideoSequenceHdr seq_hdr; GstMpegVideoSequenceExt seq_ext; + GstMpegVideoSequenceDisplayExt seq_display_ext; GstMpegVideoGop gop; GstMpegVideoQuantMatrixExt quant_matrix; GstMpegVideoPictureHdr pic_hdr; @@ -230,6 +231,7 @@ struct _GstVaapiDecoderMpeg2Private { guint fps_d; GstVaapiDecoderUnitMpeg2 *seq_hdr_unit; GstVaapiDecoderUnitMpeg2 *seq_ext_unit; + GstVaapiDecoderUnitMpeg2 *seq_display_ext_unit; GstVaapiDecoderUnitMpeg2 *seq_scalable_ext_unit; GstVaapiDecoderUnitMpeg2 *pic_hdr_unit; GstVaapiDecoderUnitMpeg2 *pic_ext_unit; @@ -335,6 +337,7 @@ gst_vaapi_decoder_mpeg2_close(GstVaapiDecoderMpeg2 *decoder) gst_vaapi_decoder_unit_replace(&priv->seq_hdr_unit, NULL); gst_vaapi_decoder_unit_replace(&priv->seq_ext_unit, NULL); + gst_vaapi_decoder_unit_replace(&priv->seq_display_ext_unit, NULL); gst_vaapi_decoder_unit_replace(&priv->seq_scalable_ext_unit, NULL); gst_vaapi_decoder_unit_replace(&priv->pic_hdr_unit, NULL); gst_vaapi_decoder_unit_replace(&priv->pic_ext_unit, NULL); @@ -586,6 +589,7 @@ decode_sequence(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnitMpeg2 *unit) gst_vaapi_decoder_unit_replace(&priv->seq_hdr_unit, unit); seq_hdr = &priv->seq_hdr_unit->data.seq_hdr; gst_vaapi_decoder_unit_replace(&priv->seq_ext_unit, NULL); + gst_vaapi_decoder_unit_replace(&priv->seq_display_ext_unit, NULL); priv->fps_n = seq_hdr->fps_n; priv->fps_d = seq_hdr->fps_d; @@ -681,6 +685,32 @@ decode_sequence_ext(GstVaapiDecoderMpeg2 *decoder, return GST_VAAPI_DECODER_STATUS_SUCCESS; } +static GstVaapiDecoderStatus +parse_sequence_display_ext(GstVaapiDecoderUnitMpeg2 *unit) +{ + GstMpegVideoPacket * const packet = &unit->packet; + + if (!gst_mpeg_video_parse_sequence_display_extension( + &unit->data.seq_display_ext, + packet->data, packet->size, packet->offset)) { + GST_ERROR("failed to parse sequence-display-extension"); + return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER; + } + return GST_VAAPI_DECODER_STATUS_SUCCESS; +} + +static GstVaapiDecoderStatus +decode_sequence_display_ext(GstVaapiDecoderMpeg2 *decoder, + GstVaapiDecoderUnitMpeg2 *unit) +{ + GstVaapiDecoderMpeg2Private * const priv = decoder->priv; + + gst_vaapi_decoder_unit_replace(&priv->seq_display_ext_unit, unit); + + /* XXX: handle color primaries and cropping */ + return GST_VAAPI_DECODER_STATUS_SUCCESS; +} + static GstVaapiDecoderStatus decode_sequence_end(GstVaapiDecoderMpeg2 *decoder) { @@ -1074,6 +1104,9 @@ decode_unit(GstVaapiDecoderMpeg2 *decoder, GstVaapiDecoderUnitMpeg2 *unit) case GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE: status = decode_sequence_ext(decoder, unit); break; + case GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE_DISPLAY: + status = decode_sequence_display_ext(decoder, unit); + break; case GST_MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX: status = decode_quant_matrix_ext(decoder, unit); break; @@ -1204,6 +1237,9 @@ gst_vaapi_decoder_mpeg2_parse(GstVaapiDecoder *base_decoder, case GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE: status = parse_sequence_ext(unit); break; + case GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE_DISPLAY: + status = parse_sequence_display_ext(unit); + break; case GST_MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX: status = parse_quant_matrix_ext(unit); break; -- 2.34.1