From 20831a08e8a661b1e0a1fba4112b6717234ad6e8 Mon Sep 17 00:00:00 2001 From: zhongcong Date: Tue, 12 Mar 2013 20:01:56 +0800 Subject: [PATCH] mpeg2: fix quant-matrix update early --- gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c index de750fa..9844ecd 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c @@ -192,6 +192,7 @@ struct _GstVaapiDecoderMpeg2Private { guint progressive_sequence : 1; guint closed_gop : 1; guint broken_link : 1; + guint update_qm : 1; }; /* VLC decoder from gst-plugins-bad */ @@ -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; @@ -992,6 +987,9 @@ decode_packet(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size) if (!priv->width || !priv->height) goto unknown_picture_size; status = decode_picture(decoder, buf, buf_size); + if (GST_VAAPI_DECODER_STATUS_SUCCESS == status){ + priv->update_qm = TRUE; + } break; case GST_MPEG_VIDEO_PACKET_SEQUENCE: status = decode_sequence(decoder, buf, buf_size); @@ -1038,6 +1036,13 @@ decode_packet(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size) type - GST_MPEG_VIDEO_PACKET_SLICE_MIN, buf, buf_size ); + if (priv->update_qm){ + status = ensure_quant_matrix(decoder, priv->current_picture); + if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) { + GST_ERROR("failed to reset quantizer matrix"); + } + priv->update_qm = FALSE; + } break; } else if (type >= 0xb9 && type <= 0xff) { @@ -1210,6 +1215,7 @@ gst_vaapi_decoder_mpeg2_init(GstVaapiDecoderMpeg2 *decoder) priv->progressive_sequence = FALSE; priv->closed_gop = FALSE; priv->broken_link = FALSE; + priv->update_qm = FALSE; } /** -- 1.7.9.5