mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
omxvideoenc: restore OMX default target-bitrate if requested by user
0xffffffff is the magic number in gst-omx meaning 'the default value defined in OMX'. This works fine with OMX parameters which are only set once when starting the component but not with configs which can be changed while PLAYING. Save the actual OMX default bitrate so we can restore it later if user sets back 0xffffffff on the property. Added GST_OMX_PROP_OMX_DEFAULT so we stop hardcoding magic numbers everywhere. https://bugzilla.gnome.org/show_bug.cgi?id=794998
This commit is contained in:
parent
542faf0f36
commit
72cb1943da
3 changed files with 17 additions and 4 deletions
|
@ -118,6 +118,11 @@ G_BEGIN_DECLS
|
|||
} G_STMT_END
|
||||
#endif
|
||||
|
||||
/* If set on an element property means "use the OMX default value".
|
||||
* If set on a default_* variable means that the default values hasn't been
|
||||
* retrieved from OMX yet. */
|
||||
#define GST_OMX_PROP_OMX_DEFAULT G_MAXUINT32
|
||||
|
||||
/* OMX_StateInvalid does not exist in 1.2.0 spec. The initial state is now
|
||||
* StateLoaded. Problem is that gst-omx still needs an initial state different
|
||||
* than StateLoaded. Otherwise gst_omx_component_set_state(StateLoaded) will
|
||||
|
|
|
@ -518,6 +518,8 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self)
|
|||
self->default_roi_quality = GST_OMX_VIDEO_ENC_DEFAULT_ROI_QUALITY;
|
||||
#endif
|
||||
|
||||
self->default_target_bitrate = GST_OMX_PROP_OMX_DEFAULT;
|
||||
|
||||
g_mutex_init (&self->drain_lock);
|
||||
g_cond_init (&self->drain_cond);
|
||||
|
||||
|
@ -746,9 +748,6 @@ gst_omx_video_enc_set_bitrate (GstOMXVideoEnc * self)
|
|||
gboolean result = TRUE;
|
||||
|
||||
GST_OBJECT_LOCK (self);
|
||||
if (self->control_rate == 0xffffffff && self->target_bitrate == 0xffffffff)
|
||||
/* Keep defaults, nothing to do */
|
||||
goto out;
|
||||
|
||||
GST_OMX_INIT_STRUCT (&bitrate_param);
|
||||
bitrate_param.nPortIndex = self->enc_out_port->index;
|
||||
|
@ -764,10 +763,16 @@ gst_omx_video_enc_set_bitrate (GstOMXVideoEnc * self)
|
|||
bitrate_param.nPortIndex = self->enc_out_port->index;
|
||||
}
|
||||
#endif
|
||||
if (self->default_target_bitrate == GST_OMX_PROP_OMX_DEFAULT)
|
||||
/* Save the actual OMX default so we can restore it if needed */
|
||||
self->default_target_bitrate = bitrate_param.nTargetBitrate;
|
||||
|
||||
if (self->control_rate != 0xffffffff)
|
||||
bitrate_param.eControlRate = self->control_rate;
|
||||
if (self->target_bitrate != 0xffffffff)
|
||||
bitrate_param.nTargetBitrate = self->target_bitrate;
|
||||
else
|
||||
bitrate_param.nTargetBitrate = self->default_target_bitrate;
|
||||
|
||||
err =
|
||||
gst_omx_component_set_parameter (self->enc,
|
||||
|
@ -790,7 +795,6 @@ gst_omx_video_enc_set_bitrate (GstOMXVideoEnc * self)
|
|||
gst_omx_error_to_string (err), err);
|
||||
}
|
||||
|
||||
out:
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
return result;
|
||||
}
|
||||
|
@ -1667,6 +1671,8 @@ gst_omx_video_enc_stop (GstVideoEncoder * encoder)
|
|||
g_cond_broadcast (&self->drain_cond);
|
||||
g_mutex_unlock (&self->drain_lock);
|
||||
|
||||
self->default_target_bitrate = GST_OMX_PROP_OMX_DEFAULT;
|
||||
|
||||
gst_omx_component_get_state (self->enc, 5 * GST_SECOND);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -94,6 +94,8 @@ struct _GstOMXVideoEnc
|
|||
gint default_roi_quality;
|
||||
#endif
|
||||
|
||||
guint32 default_target_bitrate;
|
||||
|
||||
GstFlowReturn downstream_flow_ret;
|
||||
|
||||
GstOMXBufferAllocation input_allocation;
|
||||
|
|
Loading…
Reference in a new issue