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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1841>
This commit is contained in:
Víctor Manuel Jáquez Leal 2020-11-30 15:01:01 +01:00
parent f5c7ada98e
commit 14c28415b9
6 changed files with 21 additions and 106 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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