mpeg2: fix set quant_table to driver error
authorzhongcong <congx.zhong@intel.com>
Thu, 14 Mar 2013 09:31:00 +0000 (17:31 +0800)
committerZhong Cong <congx.zhong@intel.com>
Fri, 15 Mar 2013 06:20:13 +0000 (14:20 +0800)
gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c

index de750fa..ee0f2c0 100644 (file)
@@ -549,6 +549,7 @@ decode_sequence(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
     priv->width                 = seq_hdr->width;
     priv->height                = seq_hdr->height;
     priv->has_seq_ext           = FALSE;
+    priv->has_quant_matrix_ext  = FALSE;
     priv->size_changed          = TRUE;
     priv->quant_matrix_changed  = TRUE;
     priv->progressive_sequence  = TRUE;
@@ -708,12 +709,6 @@ decode_picture(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
     gst_vaapi_picture_replace(&priv->current_picture, picture);
     gst_vaapi_picture_unref(picture);
 
-    status = ensure_quant_matrix(decoder, picture);
-    if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
-        GST_ERROR("failed to reset quantizer matrix");
-        return status;
-    }
-
     if (!gst_mpeg_video_parse_picture_header(pic_hdr, buf, buf_size, 4)) {
         GST_ERROR("failed to parse picture header");
         return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
@@ -910,9 +905,18 @@ decode_slice(
     guint8 quantiser_scale_code;
     guint8 intra_slice = 0;
     guint8 extra_bit_slice, junk8;
+    GstVaapiDecoderStatus status;
 
     GST_DEBUG("slice %d @ %p, %u bytes)", slice_no, buf, buf_size);
 
+    if (slice_no == 0){
+        status = ensure_quant_matrix(decoder, picture);
+        if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
+            GST_ERROR("failed to reset quantizer matrix");
+            return status;
+        }
+    }
+
     if (picture->slices->len == 0 && !fill_picture(decoder, picture))
         return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;