From 0af3e36068a93a68ec6c3c039f28c441bf0af26a Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 10 May 2019 18:29:10 +0800 Subject: [PATCH] libs: encoder: not call ensure_num_slices inside g_assert g_assert will take no effect when glib's G_DISABLE_ASSERT macro is defined. The function inside the g_assert will take no effect and we will fail to set the correct slice number. --- gst-libs/gst/vaapi/gstvaapiencoder_h264.c | 6 ++++-- gst-libs/gst/vaapi/gstvaapiencoder_h265.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c index f20e00e387..e3c391db15 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c @@ -2748,6 +2748,7 @@ reset_properties (GstVaapiEncoderH264 * encoder) { GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder); guint mb_size, i; + gboolean ret; if (encoder->idr_period < base_encoder->keyframe_period) encoder->idr_period = base_encoder->keyframe_period; @@ -2757,8 +2758,9 @@ reset_properties (GstVaapiEncoderH264 * encoder) encoder->qp_i = encoder->init_qp; mb_size = encoder->mb_width * encoder->mb_height; - g_assert (gst_vaapi_encoder_ensure_num_slices (base_encoder, encoder->profile, - encoder->entrypoint, (mb_size + 1) / 2, &encoder->num_slices)); + ret = gst_vaapi_encoder_ensure_num_slices (base_encoder, encoder->profile, + encoder->entrypoint, (mb_size + 1) / 2, &encoder->num_slices); + g_assert (ret); if (encoder->num_bframes > (base_encoder->keyframe_period + 1) / 2) encoder->num_bframes = (base_encoder->keyframe_period + 1) / 2; diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c index 01425523f8..53c22121ca 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c @@ -2058,6 +2058,7 @@ reset_properties (GstVaapiEncoderH265 * encoder) GstVaapiH265ReorderPool *reorder_pool; GstVaapiH265RefPool *ref_pool; guint ctu_size; + gboolean ret; if (encoder->idr_period < base_encoder->keyframe_period) encoder->idr_period = base_encoder->keyframe_period; @@ -2067,8 +2068,9 @@ reset_properties (GstVaapiEncoderH265 * encoder) encoder->qp_i = encoder->init_qp; ctu_size = encoder->ctu_width * encoder->ctu_height; - g_assert (gst_vaapi_encoder_ensure_num_slices (base_encoder, encoder->profile, - encoder->entrypoint, (ctu_size + 1) / 2, &encoder->num_slices)); + ret = gst_vaapi_encoder_ensure_num_slices (base_encoder, encoder->profile, + encoder->entrypoint, (ctu_size + 1) / 2, &encoder->num_slices); + g_assert (ret); gst_vaapi_encoder_ensure_max_num_ref_frames (base_encoder, encoder->profile, encoder->entrypoint);