mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
omx: Add hack for RPi for the minimum number of buffers required for a port
The value in the port definition is invalid and the initial actual buffer count should be used.
This commit is contained in:
parent
5132a89331
commit
1dd6214f44
3 changed files with 33 additions and 26 deletions
|
@ -5,7 +5,7 @@ component-name=OMX.broadcom.video_decode
|
|||
rank=256
|
||||
in-port-index=130
|
||||
out-port-index=131
|
||||
hacks=no-empty-eos-buffer;no-component-role
|
||||
hacks=no-empty-eos-buffer;no-component-role;port-actual-count-is-minimum
|
||||
|
||||
[omxh264dec]
|
||||
type-name=GstOMXH264Dec
|
||||
|
@ -14,7 +14,7 @@ component-name=OMX.broadcom.video_decode
|
|||
rank=256
|
||||
in-port-index=130
|
||||
out-port-index=131
|
||||
hacks=no-empty-eos-buffer;no-component-role
|
||||
hacks=no-empty-eos-buffer;no-component-role;port-actual-count-is-minimum
|
||||
|
||||
[omxmpeg2dec]
|
||||
type-name=GstOMXMPEG2Dec
|
||||
|
@ -23,7 +23,7 @@ component-name=OMX.broadcom.video_decode
|
|||
rank=256
|
||||
in-port-index=130
|
||||
out-port-index=131
|
||||
hacks=no-empty-eos-buffer;no-component-role
|
||||
hacks=no-empty-eos-buffer;no-component-role;port-actual-count-is-minimum
|
||||
|
||||
[omxmpeg4videoenc]
|
||||
type-name=GstOMXMPEG4VideoEnc
|
||||
|
@ -32,7 +32,7 @@ component-name=OMX.broadcom.video_encode
|
|||
rank=256
|
||||
in-port-index=200
|
||||
out-port-index=201
|
||||
hacks=no-empty-eos-buffer;no-component-role
|
||||
hacks=no-empty-eos-buffer;no-component-role;port-actual-count-is-minimum
|
||||
|
||||
[omxh264enc]
|
||||
type-name=GstOMXH264Enc
|
||||
|
@ -41,5 +41,5 @@ component-name=OMX.broadcom.video_encode
|
|||
rank=256
|
||||
in-port-index=200
|
||||
out-port-index=201
|
||||
hacks=no-empty-eos-buffer;no-component-role
|
||||
hacks=no-empty-eos-buffer;no-component-role;port-actual-count-is-minimum
|
||||
|
||||
|
|
41
omx/gstomx.c
41
omx/gstomx.c
|
@ -879,6 +879,11 @@ gst_omx_component_add_port (GstOMXComponent * comp, guint32 index)
|
|||
port->enabled_pending = FALSE;
|
||||
port->disabled_pending = FALSE;
|
||||
|
||||
if (comp->hacks & GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM) {
|
||||
port->min_buffer_count = port->port_def.nBufferCountActual;
|
||||
port->port_def.nBufferCountMin = port->min_buffer_count;
|
||||
}
|
||||
|
||||
if (port->port_def.eDir == OMX_DirInput)
|
||||
comp->n_in_ports++;
|
||||
else
|
||||
|
@ -1140,6 +1145,8 @@ gst_omx_port_get_port_definition (GstOMXPort * port,
|
|||
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
port_def);
|
||||
if (comp->hacks & GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM)
|
||||
port_def->nBufferCountMin = port->min_buffer_count;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -1160,6 +1167,9 @@ gst_omx_port_update_port_definition (GstOMXPort * port,
|
|||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
|
||||
if (comp->hacks & GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM)
|
||||
port->port_def.nBufferCountMin = port->min_buffer_count;
|
||||
|
||||
GST_DEBUG_OBJECT (comp->parent, "Updated port %u definition: %s (0x%08x)",
|
||||
port->index, gst_omx_error_to_string (err), err);
|
||||
|
||||
|
@ -1585,24 +1595,16 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port,
|
|||
* buffers after the port configuration was done and to
|
||||
* update the buffer size
|
||||
*/
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_port_update_port_definition (port, NULL);
|
||||
|
||||
g_return_val_if_fail (n == -1 || n >= port->port_def.nBufferCountMin,
|
||||
OMX_ErrorBadParameter);
|
||||
if (n == -1)
|
||||
n = port->port_def.nBufferCountMin;
|
||||
|
||||
/* If the configured, actual number of buffers is less than
|
||||
* the minimal number of buffers required, use the minimal
|
||||
* number of buffers
|
||||
*/
|
||||
if (port->port_def.nBufferCountActual != n) {
|
||||
port->port_def.nBufferCountActual = n;
|
||||
err = gst_omx_component_set_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_port_update_port_definition (port, &port->port_def);
|
||||
}
|
||||
|
||||
if (err != OMX_ErrorNone) {
|
||||
|
@ -1852,8 +1854,7 @@ gst_omx_port_set_enabled_unlocked (GstOMXPort * port, gboolean enabled)
|
|||
(enabled ? "enabled" : "disabled"));
|
||||
|
||||
/* Check if the port is already enabled/disabled first */
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_port_update_port_definition (port, NULL);
|
||||
if (! !port->port_def.bEnabled == ! !enabled)
|
||||
goto done;
|
||||
|
||||
|
@ -2053,8 +2054,7 @@ gst_omx_port_wait_enabled_unlocked (GstOMXPort * port, GstClockTime timeout)
|
|||
comp = port->comp;
|
||||
|
||||
/* Check the current port status */
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_port_update_port_definition (port, NULL);
|
||||
|
||||
if (port->enabled_pending)
|
||||
enabled = TRUE;
|
||||
|
@ -2092,8 +2092,7 @@ gst_omx_port_wait_enabled_unlocked (GstOMXPort * port, GstClockTime timeout)
|
|||
/* And now wait until the enable/disable command is finished */
|
||||
signalled = TRUE;
|
||||
last_error = OMX_ErrorNone;
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_port_update_port_definition (port, NULL);
|
||||
gst_omx_component_handle_messages (comp);
|
||||
while (signalled && last_error == OMX_ErrorNone &&
|
||||
(! !port->port_def.bEnabled != ! !enabled || port->enabled_pending
|
||||
|
@ -2115,8 +2114,7 @@ gst_omx_port_wait_enabled_unlocked (GstOMXPort * port, GstClockTime timeout)
|
|||
if (signalled)
|
||||
gst_omx_component_handle_messages (comp);
|
||||
last_error = comp->last_error;
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_port_update_port_definition (port, NULL);
|
||||
}
|
||||
port->enabled_pending = FALSE;
|
||||
port->disabled_pending = FALSE;
|
||||
|
@ -2216,8 +2214,7 @@ gst_omx_port_is_enabled (GstOMXPort * port)
|
|||
|
||||
comp = port->comp;
|
||||
|
||||
gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition,
|
||||
&port->port_def);
|
||||
gst_omx_port_update_port_definition (port, NULL);
|
||||
enabled = ! !port->port_def.bEnabled;
|
||||
|
||||
GST_DEBUG_OBJECT (comp->parent, "Port %u is enabled: %d", port->index,
|
||||
|
@ -2396,7 +2393,7 @@ gst_omx_error_to_string (OMX_ERRORTYPE err)
|
|||
}
|
||||
|
||||
#if defined(USE_OMX_TARGET_RPI)
|
||||
#define DEFAULT_HACKS (GST_OMX_HACK_NO_EMPTY_EOS_BUFFER | GST_OMX_HACK_NO_COMPONENT_ROLE)
|
||||
#define DEFAULT_HACKS (GST_OMX_HACK_NO_EMPTY_EOS_BUFFER | GST_OMX_HACK_NO_COMPONENT_ROLE | GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM)
|
||||
#else
|
||||
#define DEFAULT_HACKS (0)
|
||||
#endif
|
||||
|
@ -2428,6 +2425,8 @@ gst_omx_parse_hacks (gchar ** hacks)
|
|||
hacks_flags |= GST_OMX_HACK_DRAIN_MAY_NOT_RETURN;
|
||||
else if (g_str_equal (*hacks, "no-component-role"))
|
||||
hacks_flags |= GST_OMX_HACK_NO_COMPONENT_ROLE;
|
||||
else if (g_str_equal (*hacks, "port-actual-count-is-minimum"))
|
||||
hacks_flags |= GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM;
|
||||
else
|
||||
GST_WARNING ("Unknown hack: %s", *hacks);
|
||||
hacks++;
|
||||
|
|
|
@ -103,6 +103,11 @@ G_BEGIN_DECLS
|
|||
*/
|
||||
#define GST_OMX_HACK_NO_COMPONENT_ROLE G_GUINT64_CONSTANT (0x0000000000000080)
|
||||
|
||||
/* If the component reports the minimum number of required
|
||||
* buffers via nBufferCountActual instead of nBufferCountMin.
|
||||
* Happens with Broadcom's OpenMAX implementation.
|
||||
*/
|
||||
#define GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM G_GUINT64_CONSTANT (0x0000000000000100)
|
||||
|
||||
typedef struct _GstOMXCore GstOMXCore;
|
||||
typedef struct _GstOMXPort GstOMXPort;
|
||||
|
@ -199,6 +204,9 @@ struct _GstOMXPort {
|
|||
*/
|
||||
gint settings_cookie;
|
||||
gint configured_settings_cookie;
|
||||
|
||||
/* Only valid if GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM */
|
||||
gint min_buffer_count;
|
||||
};
|
||||
|
||||
struct _GstOMXComponent {
|
||||
|
|
Loading…
Reference in a new issue