mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
va: h264enc: Change the set_property to make it atomic
The inside encoder may be set in other threads, so we should make its accessing atomic. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6471>
This commit is contained in:
parent
812e7efb90
commit
045449e190
1 changed files with 19 additions and 6 deletions
|
@ -3294,6 +3294,13 @@ gst_va_h264_enc_set_property (GObject * object, guint prop_id,
|
|||
{
|
||||
GstVaH264Enc *self = GST_VA_H264_ENC (object);
|
||||
GstVaBaseEnc *base = GST_VA_BASE_ENC (self);
|
||||
GstVaEncoder *encoder = NULL;
|
||||
gboolean no_effect;
|
||||
|
||||
gst_object_replace ((GstObject **) (&encoder), (GstObject *) base->encoder);
|
||||
no_effect = (encoder && gst_va_encoder_is_open (encoder));
|
||||
if (encoder)
|
||||
gst_object_unref (encoder);
|
||||
|
||||
GST_OBJECT_LOCK (self);
|
||||
|
||||
|
@ -3324,14 +3331,17 @@ gst_va_h264_enc_set_property (GObject * object, guint prop_id,
|
|||
break;
|
||||
case PROP_QP_I:
|
||||
self->prop.qp_i = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_QP_P:
|
||||
self->prop.qp_p = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_QP_B:
|
||||
self->prop.qp_b = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_DCT8X8:
|
||||
|
@ -3370,22 +3380,27 @@ gst_va_h264_enc_set_property (GObject * object, guint prop_id,
|
|||
}
|
||||
case PROP_BITRATE:
|
||||
self->prop.bitrate = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_TARGET_PERCENTAGE:
|
||||
self->prop.target_percentage = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_TARGET_USAGE:
|
||||
self->prop.target_usage = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_RATE_CONTROL:
|
||||
self->prop.rc_ctrl = g_value_get_enum (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_CPB_SIZE:
|
||||
self->prop.cpb_size = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
default:
|
||||
|
@ -3394,14 +3409,12 @@ gst_va_h264_enc_set_property (GObject * object, guint prop_id,
|
|||
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
if (no_effect) {
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
if (!g_atomic_int_get (&GST_VA_BASE_ENC (self)->reconf)
|
||||
&& base->encoder && gst_va_encoder_is_open (base->encoder)) {
|
||||
GST_WARNING_OBJECT (self, "Property `%s` change ignored while processing.",
|
||||
pspec->name);
|
||||
}
|
||||
GST_WARNING_OBJECT (self, "Property `%s` change may not take effect "
|
||||
"until the next encoder reconfig.", pspec->name);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue