mpeg2: handle sequence_display_extension().

This commit is contained in:
Gwenole Beauchesne 2013-01-02 14:02:29 +01:00
parent 748a8dbdc6
commit 65ede48b7b

View file

@ -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;