From 14c28415b96a43923912038ee52995b6f62ab593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 30 Nov 2020 15:01:01 +0100 Subject: [PATCH] va: Remove gst_va_decoder_destroy_buffers() Since GstVaDecodePicture is destroyed completely with its free() function and it's used as destroy notify by codecs picture, there's no need to call gst_va_decoder_destroy_buffers() externally, since the codecs base classes destroy the codec picture when it's required. Part-of: --- sys/va/gstvadecoder.c | 40 ++++++++++------------------------------ sys/va/gstvadecoder.h | 2 -- sys/va/gstvah264dec.c | 24 ++++-------------------- sys/va/gstvah265dec.c | 22 ++++------------------ sys/va/gstvavp8dec.c | 20 ++------------------ sys/va/gstvavp9dec.c | 19 +------------------ 6 files changed, 21 insertions(+), 106 deletions(-) diff --git a/sys/va/gstvadecoder.c b/sys/va/gstvadecoder.c index 7e21e32a17..61d81a6fbd 100644 --- a/sys/va/gstvadecoder.c +++ b/sys/va/gstvadecoder.c @@ -65,6 +65,8 @@ enum static GParamSpec *g_properties[N_PROPERTIES]; +static gboolean _destroy_buffers (GstVaDecodePicture * pic); + static void gst_va_decoder_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -619,15 +621,13 @@ gst_va_decoder_decode (GstVaDecoder * self, GstVaDecodePicture * pic) gst_va_display_lock (self->display); status = vaEndPicture (dpy, self->context); gst_va_display_unlock (self->display); - if (status != VA_STATUS_SUCCESS) { + if (status != VA_STATUS_SUCCESS) GST_WARNING_OBJECT (self, "vaEndPicture: %s", vaErrorStr (status)); - goto bail; - } - - ret = TRUE; + else + ret = TRUE; bail: - gst_va_decoder_destroy_buffers (self, pic); + _destroy_buffers (pic); return ret; @@ -641,7 +641,7 @@ fail_end_pic: } static gboolean -_va_decoder_picture_destroy_buffers (GstVaDecodePicture * pic) +_destroy_buffers (GstVaDecodePicture * pic) { VABufferID buffer; VADisplay dpy; @@ -649,6 +649,8 @@ _va_decoder_picture_destroy_buffers (GstVaDecodePicture * pic) guint i; gboolean ret = TRUE; + g_return_val_if_fail (GST_IS_VA_DISPLAY (pic->display), FALSE); + dpy = gst_va_display_get_va_dpy (pic->display); for (i = 0; i < pic->buffers->len; i++) { @@ -680,28 +682,6 @@ _va_decoder_picture_destroy_buffers (GstVaDecodePicture * pic) return ret; } -gboolean -gst_va_decoder_destroy_buffers (GstVaDecoder * self, GstVaDecodePicture * pic) -{ - VASurfaceID surface; - - g_return_val_if_fail (GST_IS_VA_DECODER (self), FALSE); - g_return_val_if_fail (pic, FALSE); - - surface = gst_va_decode_picture_get_surface (pic); - if (surface == VA_INVALID_ID) { - GST_ERROR_OBJECT (self, "Decode picture without VASurfaceID"); - return FALSE; - } - - g_assert (pic->display == self->display); - - GST_TRACE_OBJECT (self, "Destroy buffers of surface %#x", surface); - - return _va_decoder_picture_destroy_buffers (pic); -} - - GstVaDecodePicture * gst_va_decode_picture_new (GstVaDecoder * self, GstBuffer * buffer) { @@ -735,7 +715,7 @@ gst_va_decode_picture_free (GstVaDecodePicture * pic) if (pic->buffers->len > 0 || pic->slices->len > 0) { GST_WARNING ("VABufferIDs have not been released."); - _va_decoder_picture_destroy_buffers (pic); + _destroy_buffers (pic); } gst_buffer_unref (pic->gstbuffer); diff --git a/sys/va/gstvadecoder.h b/sys/va/gstvadecoder.h index 0c6631ddf5..ec0a912129 100644 --- a/sys/va/gstvadecoder.h +++ b/sys/va/gstvadecoder.h @@ -67,8 +67,6 @@ gboolean gst_va_decoder_add_slice_buffer (GstVaDecoder * self, gsize slice_size); gboolean gst_va_decoder_decode (GstVaDecoder * self, GstVaDecodePicture * pic); -gboolean gst_va_decoder_destroy_buffers (GstVaDecoder * self, - GstVaDecodePicture * pic); GstVaDecodePicture * gst_va_decode_picture_new (GstVaDecoder * self, GstBuffer * buffer); diff --git a/sys/va/gstvah264dec.c b/sys/va/gstvah264dec.c index a355c0037b..77ad697893 100644 --- a/sys/va/gstvah264dec.c +++ b/sys/va/gstvah264dec.c @@ -331,7 +331,6 @@ gst_va_h264_dec_decode_slice (GstH264Decoder * decoder, GstVaBaseDec *base = GST_VA_BASE_DEC (decoder); GstVaDecodePicture *va_pic; VASliceParameterBufferH264 slice_param; - gboolean ret; /* *INDENT-OFF* */ slice_param = (VASliceParameterBufferH264) { @@ -360,15 +359,9 @@ gst_va_h264_dec_decode_slice (GstH264Decoder * decoder, va_pic = gst_h264_picture_get_user_data (picture); - ret = gst_va_decoder_add_slice_buffer (base->decoder, va_pic, &slice_param, + return gst_va_decoder_add_slice_buffer (base->decoder, va_pic, &slice_param, sizeof (slice_param), slice->nalu.data + slice->nalu.offset, slice->nalu.size); - if (!ret) { - gst_va_decoder_destroy_buffers (base->decoder, va_pic); - return FALSE; - } - - return TRUE; } static gboolean @@ -463,7 +456,7 @@ gst_va_h264_dec_start_picture (GstH264Decoder * decoder, if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic, VAPictureParameterBufferType, &pic_param, sizeof (pic_param))) - goto fail; + return FALSE; /* there are always 6 4x4 scaling lists */ for (i = 0; i < 6; i++) { @@ -480,17 +473,8 @@ gst_va_h264_dec_start_picture (GstH264Decoder * decoder, [i], pps->scaling_lists_8x8[i]); } - if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic, - VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix))) - goto fail; - - return TRUE; - -fail: - { - gst_va_decoder_destroy_buffers (base->decoder, va_pic); - return FALSE; - } + return gst_va_decoder_add_param_buffer (base->decoder, va_pic, + VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix)); } static gboolean diff --git a/sys/va/gstvah265dec.c b/sys/va/gstvah265dec.c index 19e5c9f87f..6e1b9319ab 100644 --- a/sys/va/gstvah265dec.c +++ b/sys/va/gstvah265dec.c @@ -361,7 +361,6 @@ gst_va_h265_dec_decode_slice (GstH265Decoder * decoder, GstVaBaseDec *base = GST_VA_BASE_DEC (decoder); GstVaDecodePicture *va_pic; VASliceParameterBufferHEVC slice_param; - gboolean ret; /* *INDENT-OFF* */ slice_param = (VASliceParameterBufferHEVC) { @@ -416,15 +415,9 @@ gst_va_h265_dec_decode_slice (GstH265Decoder * decoder, va_pic = gst_h265_picture_get_user_data (picture); - ret = gst_va_decoder_add_slice_buffer (base->decoder, va_pic, &slice_param, + return gst_va_decoder_add_slice_buffer (base->decoder, va_pic, &slice_param, sizeof (slice_param), slice->nalu.data + slice->nalu.offset, slice->nalu.size); - if (!ret) { - gst_va_decoder_destroy_buffers (base->decoder, va_pic); - return FALSE; - } - - return TRUE; } static gboolean @@ -544,7 +537,7 @@ gst_va_h265_dec_start_picture (GstH265Decoder * decoder, if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic, VAPictureParameterBufferType, pic_param, sizeof (*pic_param))) - goto fail; + return FALSE; if (pps->scaling_list_data_present_flag || (sps->scaling_list_enabled_flag @@ -582,18 +575,11 @@ gst_va_h265_dec_start_picture (GstH265Decoder * decoder, iq_matrix.ScalingListDC32x32[i] = scaling_list->scaling_list_dc_coef_minus8_32x32[i] + 8; - if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic, - VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix))) - goto fail; + return gst_va_decoder_add_param_buffer (base->decoder, va_pic, + VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix)); } return TRUE; - -fail: - { - gst_va_decoder_destroy_buffers (base->decoder, va_pic); - return FALSE; - } } static gboolean diff --git a/sys/va/gstvavp8dec.c b/sys/va/gstvavp8dec.c index bb4fac9339..577dbb59ff 100644 --- a/sys/va/gstvavp8dec.c +++ b/sys/va/gstvavp8dec.c @@ -413,24 +413,8 @@ static gboolean gst_va_vp8_dec_decode_picture (GstVp8Decoder * decoder, GstVp8Picture * picture, GstVp8Parser * parser) { - GstVaBaseDec *base = GST_VA_BASE_DEC (decoder); - GstVaDecodePicture *va_pic; - - if (!_fill_picture (decoder, picture, parser)) - goto error; - - if (!_add_slice (decoder, picture, parser)) - goto error; - - return TRUE; - -error: - { - GST_WARNING_OBJECT (base, "Decode the picture error"); - va_pic = gst_vp8_picture_get_user_data (picture); - gst_va_decoder_destroy_buffers (base->decoder, va_pic); - return FALSE; - } + return _fill_picture (decoder, picture, parser) && + _add_slice (decoder, picture, parser); } static gboolean diff --git a/sys/va/gstvavp9dec.c b/sys/va/gstvavp9dec.c index b1657ea8b9..fccfad041d 100644 --- a/sys/va/gstvavp9dec.c +++ b/sys/va/gstvavp9dec.c @@ -363,24 +363,7 @@ static gboolean gst_va_vp9_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture, GstVp9Dpb * dpb) { - GstVaBaseDec *base = GST_VA_BASE_DEC (decoder); - - if (!_fill_param (decoder, picture, dpb)) - goto fail; - - if (!_fill_slice (decoder, picture)) - goto fail; - - return TRUE; - -fail: - { - GstVaDecodePicture *va_pic; - - va_pic = gst_vp9_picture_get_user_data (picture); - gst_va_decoder_destroy_buffers (base->decoder, va_pic); - return FALSE; - } + return _fill_param (decoder, picture, dpb) && _fill_slice (decoder, picture); } static gboolean