mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
va: av1enc: 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
db74da3f6f
commit
cbdc22d697
1 changed files with 19 additions and 5 deletions
|
@ -4011,12 +4011,13 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
|||
{
|
||||
GstVaAV1Enc *const self = GST_VA_AV1_ENC (object);
|
||||
GstVaBaseEnc *base = GST_VA_BASE_ENC (self);
|
||||
GstVaEncoder *encoder = NULL;
|
||||
gboolean no_effect;
|
||||
|
||||
if (base->encoder && gst_va_encoder_is_open (base->encoder)) {
|
||||
GST_ERROR_OBJECT (object,
|
||||
"failed to set any property after encoding started");
|
||||
return;
|
||||
}
|
||||
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);
|
||||
|
||||
|
@ -4038,6 +4039,7 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
|||
break;
|
||||
case PROP_QP:
|
||||
self->prop.qp = g_value_get_uint (value);
|
||||
no_effect = FALSE;
|
||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||
break;
|
||||
case PROP_MAX_QP:
|
||||
|
@ -4048,6 +4050,7 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
|||
break;
|
||||
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_NUM_TILE_COLS:
|
||||
|
@ -4061,18 +4064,22 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
|||
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_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_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;
|
||||
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_MBBRC:{
|
||||
|
@ -4099,6 +4106,13 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
|||
}
|
||||
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
if (no_effect) {
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
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