From 6ae97634cf8d8c5f0978a52202e29a5cbdd5c062 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 7 Oct 2011 11:50:20 +0200 Subject: [PATCH] vc1: fix codec-data decoding for WMV3 format. --- gst-libs/gst/vaapi/gstvaapidecoder_vc1.c | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c b/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c index 35fc75b4ed..55d0f0b853 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c @@ -1163,17 +1163,55 @@ decode_buffer(GstVaapiDecoderVC1 *decoder, GstBuffer *buffer) static GstVaapiDecoderStatus decode_codec_data(GstVaapiDecoderVC1 *decoder, GstBuffer *buffer) { + GstVaapiDecoderVC1Private * const priv = decoder->priv; + GstVC1SeqHdr * const seq_hdr = &priv->seq_hdr; GstVaapiDecoderStatus status; GstVC1ParserResult result; GstVC1BDU ebdu; + GstCaps *caps; + GstStructure *structure; guchar *buf; guint buf_size, ofs; + gint width, height; + guint32 format; buf = GST_BUFFER_DATA(buffer); buf_size = GST_BUFFER_SIZE(buffer); if (!buf || buf_size == 0) return GST_VAAPI_DECODER_STATUS_SUCCESS; + caps = GST_VAAPI_DECODER_CAST(decoder)->priv->caps; + structure = gst_caps_get_structure(caps, 0); + + if (!gst_structure_get_int(structure, "width", &width) || + !gst_structure_get_int(structure, "height", &height)) { + GST_DEBUG("failed to parse size from codec-data"); + return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN; + } + + if (!gst_structure_get_fourcc(structure, "format", &format)) { + GST_DEBUG("failed to parse profile from codec-data"); + return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC; + } + + /* WMV3 -- expecting sequence header */ + if (format == GST_MAKE_FOURCC('W','M','V','3')) { + seq_hdr->struct_c.coded_width = width; + seq_hdr->struct_c.coded_height = height; + ebdu.type = GST_VC1_SEQUENCE; + ebdu.size = buf_size; + ebdu.sc_offset = 0; + ebdu.offset = 0; + ebdu.data = buf; + return decode_ebdu(decoder, &ebdu); + } + + /* WVC1 -- expecting bitstream data units */ + if (format != GST_MAKE_FOURCC('W','V','C','1')) + return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE; + seq_hdr->advanced.max_coded_width = width; + seq_hdr->advanced.max_coded_height = height; + ofs = 0; do { result = gst_vc1_identify_next_bdu(