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);
|
GstVaAV1Enc *const self = GST_VA_AV1_ENC (object);
|
||||||
GstVaBaseEnc *base = GST_VA_BASE_ENC (self);
|
GstVaBaseEnc *base = GST_VA_BASE_ENC (self);
|
||||||
|
GstVaEncoder *encoder = NULL;
|
||||||
|
gboolean no_effect;
|
||||||
|
|
||||||
if (base->encoder && gst_va_encoder_is_open (base->encoder)) {
|
gst_object_replace ((GstObject **) (&encoder), (GstObject *) base->encoder);
|
||||||
GST_ERROR_OBJECT (object,
|
no_effect = (encoder && gst_va_encoder_is_open (encoder));
|
||||||
"failed to set any property after encoding started");
|
if (encoder)
|
||||||
return;
|
gst_object_unref (encoder);
|
||||||
}
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
|
|
||||||
|
@ -4038,6 +4039,7 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
||||||
break;
|
break;
|
||||||
case PROP_QP:
|
case PROP_QP:
|
||||||
self->prop.qp = g_value_get_uint (value);
|
self->prop.qp = g_value_get_uint (value);
|
||||||
|
no_effect = FALSE;
|
||||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_QP:
|
case PROP_MAX_QP:
|
||||||
|
@ -4048,6 +4050,7 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
||||||
break;
|
break;
|
||||||
case PROP_BITRATE:
|
case PROP_BITRATE:
|
||||||
self->prop.bitrate = g_value_get_uint (value);
|
self->prop.bitrate = g_value_get_uint (value);
|
||||||
|
no_effect = FALSE;
|
||||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||||
break;
|
break;
|
||||||
case PROP_NUM_TILE_COLS:
|
case PROP_NUM_TILE_COLS:
|
||||||
|
@ -4061,18 +4064,22 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
||||||
break;
|
break;
|
||||||
case PROP_TARGET_USAGE:
|
case PROP_TARGET_USAGE:
|
||||||
self->prop.target_usage = g_value_get_uint (value);
|
self->prop.target_usage = g_value_get_uint (value);
|
||||||
|
no_effect = FALSE;
|
||||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||||
break;
|
break;
|
||||||
case PROP_TARGET_PERCENTAGE:
|
case PROP_TARGET_PERCENTAGE:
|
||||||
self->prop.target_percentage = g_value_get_uint (value);
|
self->prop.target_percentage = g_value_get_uint (value);
|
||||||
|
no_effect = FALSE;
|
||||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||||
break;
|
break;
|
||||||
case PROP_CPB_SIZE:
|
case PROP_CPB_SIZE:
|
||||||
self->prop.cpb_size = g_value_get_uint (value);
|
self->prop.cpb_size = g_value_get_uint (value);
|
||||||
|
no_effect = FALSE;
|
||||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||||
break;
|
break;
|
||||||
case PROP_RATE_CONTROL:
|
case PROP_RATE_CONTROL:
|
||||||
self->prop.rc_ctrl = g_value_get_enum (value);
|
self->prop.rc_ctrl = g_value_get_enum (value);
|
||||||
|
no_effect = FALSE;
|
||||||
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
g_atomic_int_set (&GST_VA_BASE_ENC (self)->reconf, TRUE);
|
||||||
break;
|
break;
|
||||||
case PROP_MBBRC:{
|
case PROP_MBBRC:{
|
||||||
|
@ -4099,6 +4106,13 @@ gst_va_av1_enc_set_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (self);
|
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
|
static void
|
||||||
|
|
Loading…
Reference in a new issue