From fbab40bd5e58cdda6b718d3062cd52a38c33b60d Mon Sep 17 00:00:00 2001 From: Mengkejiergeli Ba Date: Thu, 9 Feb 2023 16:54:16 +0800 Subject: [PATCH] va: Fix some code defects Part-of: --- subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c | 6 +++++- subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c | 11 ++++++++--- subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c | 5 ++++- subprojects/gst-plugins-bad/sys/va/gstvaencoder.c | 6 +++++- subprojects/gst-plugins-bad/sys/va/gstvah264enc.c | 2 ++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c index 5b6cbe6..9404f2b 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c @@ -300,7 +300,11 @@ _create_internal_pool (GstVaAV1Dec * self, gint width, gint height) return NULL; } - gst_buffer_pool_set_active (pool, TRUE); + if (!gst_buffer_pool_set_active (pool, TRUE)) { + GST_WARNING_OBJECT (self, "Failed to activate internal pool"); + gst_object_unref (pool); + return NULL; + } return pool; } diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c b/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c index 2cadb5d..56f73db 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c @@ -229,7 +229,10 @@ _get_sinkpad_pool (GstVaBaseEnc * base) gst_object_unref (allocator); - gst_buffer_pool_set_active (base->priv->raw_pool, TRUE); + if (!gst_buffer_pool_set_active (base->priv->raw_pool, TRUE)) { + GST_WARNING_OBJECT (base, "Failed to activate sinkpad pool"); + return NULL; + } return base->priv->raw_pool; } @@ -690,8 +693,10 @@ error_reorder: { GST_ELEMENT_ERROR (venc, STREAM, ENCODE, ("Failed to reorder the input frame."), (NULL)); - gst_clear_buffer (&frame->output_buffer); - gst_video_encoder_finish_frame (venc, frame); + if (frame) { + gst_clear_buffer (&frame->output_buffer); + gst_video_encoder_finish_frame (venc, frame); + } return GST_FLOW_ERROR; } error_encode: diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c index 5ced2fa..fbc7230 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c @@ -768,7 +768,10 @@ _get_sinkpad_pool (GstVaBaseTransform * self) if (self->priv->sinkpad_caps) { caps = self->priv->sinkpad_caps; - gst_video_info_from_caps (&in_info, caps); + if (!gst_video_info_from_caps (&in_info, caps)) { + GST_ERROR_OBJECT (self, "Cannot parse caps %" GST_PTR_FORMAT, caps); + return NULL; + } } else { caps = self->in_caps; in_info = self->in_info; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c index 9e08df7..fa8d64e 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c @@ -397,7 +397,11 @@ gst_va_encoder_open (GstVaEncoder * self, VAProfile profile, GST_ERROR_OBJECT (self, "Failed to create reconstruct pool"); goto error; } - gst_buffer_pool_set_active (recon_pool, TRUE); + + if (!gst_buffer_pool_set_active (recon_pool, TRUE)) { + GST_ERROR_OBJECT (self, "Failed to activate reconstruct pool"); + goto error; + } status = vaCreateContext (dpy, config, coded_width, coded_height, VA_PROGRESSIVE, NULL, 0, &context); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c index 5e57d44..1072e25 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c @@ -1200,11 +1200,13 @@ _calculate_coded_size (GstVaH264Enc * self) BitDepthC = 10; MbWidthC = 8; MbHeightC = 8; + break; case VA_RT_FORMAT_YUV422_10: BitDepthY = 10; BitDepthC = 10; MbWidthC = 8; MbHeightC = 16; + break; case VA_RT_FORMAT_YUV444_10: BitDepthY = 10; BitDepthC = 10; -- 2.7.4