mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-23 09:04:15 +00:00
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:
parent
f5c7ada98e
commit
14c28415b9
6 changed files with 21 additions and 106 deletions
|
@ -65,6 +65,8 @@ enum
|
||||||
|
|
||||||
static GParamSpec *g_properties[N_PROPERTIES];
|
static GParamSpec *g_properties[N_PROPERTIES];
|
||||||
|
|
||||||
|
static gboolean _destroy_buffers (GstVaDecodePicture * pic);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_va_decoder_set_property (GObject * object, guint prop_id,
|
gst_va_decoder_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
@ -619,15 +621,13 @@ gst_va_decoder_decode (GstVaDecoder * self, GstVaDecodePicture * pic)
|
||||||
gst_va_display_lock (self->display);
|
gst_va_display_lock (self->display);
|
||||||
status = vaEndPicture (dpy, self->context);
|
status = vaEndPicture (dpy, self->context);
|
||||||
gst_va_display_unlock (self->display);
|
gst_va_display_unlock (self->display);
|
||||||
if (status != VA_STATUS_SUCCESS) {
|
if (status != VA_STATUS_SUCCESS)
|
||||||
GST_WARNING_OBJECT (self, "vaEndPicture: %s", vaErrorStr (status));
|
GST_WARNING_OBJECT (self, "vaEndPicture: %s", vaErrorStr (status));
|
||||||
goto bail;
|
else
|
||||||
}
|
ret = TRUE;
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
gst_va_decoder_destroy_buffers (self, pic);
|
_destroy_buffers (pic);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ fail_end_pic:
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_va_decoder_picture_destroy_buffers (GstVaDecodePicture * pic)
|
_destroy_buffers (GstVaDecodePicture * pic)
|
||||||
{
|
{
|
||||||
VABufferID buffer;
|
VABufferID buffer;
|
||||||
VADisplay dpy;
|
VADisplay dpy;
|
||||||
|
@ -649,6 +649,8 @@ _va_decoder_picture_destroy_buffers (GstVaDecodePicture * pic)
|
||||||
guint i;
|
guint i;
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_VA_DISPLAY (pic->display), FALSE);
|
||||||
|
|
||||||
dpy = gst_va_display_get_va_dpy (pic->display);
|
dpy = gst_va_display_get_va_dpy (pic->display);
|
||||||
|
|
||||||
for (i = 0; i < pic->buffers->len; i++) {
|
for (i = 0; i < pic->buffers->len; i++) {
|
||||||
|
@ -680,28 +682,6 @@ _va_decoder_picture_destroy_buffers (GstVaDecodePicture * pic)
|
||||||
return ret;
|
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 *
|
GstVaDecodePicture *
|
||||||
gst_va_decode_picture_new (GstVaDecoder * self, GstBuffer * buffer)
|
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) {
|
if (pic->buffers->len > 0 || pic->slices->len > 0) {
|
||||||
GST_WARNING ("VABufferIDs have not been released.");
|
GST_WARNING ("VABufferIDs have not been released.");
|
||||||
_va_decoder_picture_destroy_buffers (pic);
|
_destroy_buffers (pic);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unref (pic->gstbuffer);
|
gst_buffer_unref (pic->gstbuffer);
|
||||||
|
|
|
@ -67,8 +67,6 @@ gboolean gst_va_decoder_add_slice_buffer (GstVaDecoder * self,
|
||||||
gsize slice_size);
|
gsize slice_size);
|
||||||
gboolean gst_va_decoder_decode (GstVaDecoder * self,
|
gboolean gst_va_decoder_decode (GstVaDecoder * self,
|
||||||
GstVaDecodePicture * pic);
|
GstVaDecodePicture * pic);
|
||||||
gboolean gst_va_decoder_destroy_buffers (GstVaDecoder * self,
|
|
||||||
GstVaDecodePicture * pic);
|
|
||||||
|
|
||||||
GstVaDecodePicture * gst_va_decode_picture_new (GstVaDecoder * self,
|
GstVaDecodePicture * gst_va_decode_picture_new (GstVaDecoder * self,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
|
|
|
@ -331,7 +331,6 @@ gst_va_h264_dec_decode_slice (GstH264Decoder * decoder,
|
||||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||||
GstVaDecodePicture *va_pic;
|
GstVaDecodePicture *va_pic;
|
||||||
VASliceParameterBufferH264 slice_param;
|
VASliceParameterBufferH264 slice_param;
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
slice_param = (VASliceParameterBufferH264) {
|
slice_param = (VASliceParameterBufferH264) {
|
||||||
|
@ -360,15 +359,9 @@ gst_va_h264_dec_decode_slice (GstH264Decoder * decoder,
|
||||||
|
|
||||||
va_pic = gst_h264_picture_get_user_data (picture);
|
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,
|
sizeof (slice_param), slice->nalu.data + slice->nalu.offset,
|
||||||
slice->nalu.size);
|
slice->nalu.size);
|
||||||
if (!ret) {
|
|
||||||
gst_va_decoder_destroy_buffers (base->decoder, va_pic);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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,
|
if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic,
|
||||||
VAPictureParameterBufferType, &pic_param, sizeof (pic_param)))
|
VAPictureParameterBufferType, &pic_param, sizeof (pic_param)))
|
||||||
goto fail;
|
return FALSE;
|
||||||
|
|
||||||
/* there are always 6 4x4 scaling lists */
|
/* there are always 6 4x4 scaling lists */
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
|
@ -480,17 +473,8 @@ gst_va_h264_dec_start_picture (GstH264Decoder * decoder,
|
||||||
[i], pps->scaling_lists_8x8[i]);
|
[i], pps->scaling_lists_8x8[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic,
|
return gst_va_decoder_add_param_buffer (base->decoder, va_pic,
|
||||||
VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix)))
|
VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix));
|
||||||
goto fail;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
{
|
|
||||||
gst_va_decoder_destroy_buffers (base->decoder, va_pic);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -361,7 +361,6 @@ gst_va_h265_dec_decode_slice (GstH265Decoder * decoder,
|
||||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||||
GstVaDecodePicture *va_pic;
|
GstVaDecodePicture *va_pic;
|
||||||
VASliceParameterBufferHEVC slice_param;
|
VASliceParameterBufferHEVC slice_param;
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
slice_param = (VASliceParameterBufferHEVC) {
|
slice_param = (VASliceParameterBufferHEVC) {
|
||||||
|
@ -416,15 +415,9 @@ gst_va_h265_dec_decode_slice (GstH265Decoder * decoder,
|
||||||
|
|
||||||
va_pic = gst_h265_picture_get_user_data (picture);
|
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,
|
sizeof (slice_param), slice->nalu.data + slice->nalu.offset,
|
||||||
slice->nalu.size);
|
slice->nalu.size);
|
||||||
if (!ret) {
|
|
||||||
gst_va_decoder_destroy_buffers (base->decoder, va_pic);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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,
|
if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic,
|
||||||
VAPictureParameterBufferType, pic_param, sizeof (*pic_param)))
|
VAPictureParameterBufferType, pic_param, sizeof (*pic_param)))
|
||||||
goto fail;
|
return FALSE;
|
||||||
|
|
||||||
if (pps->scaling_list_data_present_flag ||
|
if (pps->scaling_list_data_present_flag ||
|
||||||
(sps->scaling_list_enabled_flag
|
(sps->scaling_list_enabled_flag
|
||||||
|
@ -582,18 +575,11 @@ gst_va_h265_dec_start_picture (GstH265Decoder * decoder,
|
||||||
iq_matrix.ScalingListDC32x32[i] =
|
iq_matrix.ScalingListDC32x32[i] =
|
||||||
scaling_list->scaling_list_dc_coef_minus8_32x32[i] + 8;
|
scaling_list->scaling_list_dc_coef_minus8_32x32[i] + 8;
|
||||||
|
|
||||||
if (!gst_va_decoder_add_param_buffer (base->decoder, va_pic,
|
return gst_va_decoder_add_param_buffer (base->decoder, va_pic,
|
||||||
VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix)))
|
VAIQMatrixBufferType, &iq_matrix, sizeof (iq_matrix));
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
fail:
|
|
||||||
{
|
|
||||||
gst_va_decoder_destroy_buffers (base->decoder, va_pic);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -413,24 +413,8 @@ static gboolean
|
||||||
gst_va_vp8_dec_decode_picture (GstVp8Decoder * decoder, GstVp8Picture * picture,
|
gst_va_vp8_dec_decode_picture (GstVp8Decoder * decoder, GstVp8Picture * picture,
|
||||||
GstVp8Parser * parser)
|
GstVp8Parser * parser)
|
||||||
{
|
{
|
||||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
return _fill_picture (decoder, picture, parser) &&
|
||||||
GstVaDecodePicture *va_pic;
|
_add_slice (decoder, picture, parser);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -363,24 +363,7 @@ static gboolean
|
||||||
gst_va_vp9_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture,
|
gst_va_vp9_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture,
|
||||||
GstVp9Dpb * dpb)
|
GstVp9Dpb * dpb)
|
||||||
{
|
{
|
||||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
return _fill_param (decoder, picture, dpb) && _fill_slice (decoder, picture);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue