Commit 146fcb56 authored by Julian Scheel's avatar Julian Scheel Committed by Jean-Baptiste Kempf

mmal: Use zerocopy ports for opaque mode

When running in opaque mode the mmal codec, deinterlace and vout must be used
together, so it is known that all pictures in use are allocated by the mmal
vout and contain an associated mmal_buffer_header. This allows us to enable
the zerocopy feature of mmal, which allocates shared memory between GPU and
CPU for holding the buffer payloads. Albeit the payloads are just small opaque
handles that reference the GPU side pictures it saves a little bit of
performance, because less VCHIQ transfers are required.
Signed-off-by: default avatarJulian Scheel <julian@jusst.de>
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 190ebeb4
...@@ -190,6 +190,19 @@ static int OpenDecoder(decoder_t *dec) ...@@ -190,6 +190,19 @@ static int OpenDecoder(decoder_t *dec)
ret = VLC_EGENERIC; ret = VLC_EGENERIC;
goto out; goto out;
} }
msg_Dbg(dec, "Activate zero-copy for output port");
MMAL_PARAMETER_BOOLEAN_T zero_copy = {
{ MMAL_PARAMETER_ZERO_COPY, sizeof(MMAL_PARAMETER_BOOLEAN_T) },
1
};
status = mmal_port_parameter_set(sys->output, &zero_copy.hdr);
if (status != MMAL_SUCCESS) {
msg_Err(dec, "Failed to set zero copy on port %s (status=%"PRIx32" %s)",
sys->output->name, status, mmal_status_to_string(status));
goto out;
}
} }
status = mmal_port_enable(sys->output, output_port_cb); status = mmal_port_enable(sys->output, output_port_cb);
......
...@@ -160,8 +160,22 @@ static int Open(filter_t *filter) ...@@ -160,8 +160,22 @@ static int Open(filter_t *filter)
goto out; goto out;
} }
sys->input->buffer_size = sys->input->buffer_size_recommended; sys->input->buffer_size = sys->input->buffer_size_recommended;
sys->input->buffer_num = sys->input->buffer_num_recommended; sys->input->buffer_num = sys->input->buffer_num_recommended;
if (filter->fmt_in.i_codec == VLC_CODEC_MMAL_OPAQUE) {
MMAL_PARAMETER_BOOLEAN_T zero_copy = {
{ MMAL_PARAMETER_ZERO_COPY, sizeof(MMAL_PARAMETER_BOOLEAN_T) },
1
};
status = mmal_port_parameter_set(sys->input, &zero_copy.hdr);
if (status != MMAL_SUCCESS) {
msg_Err(filter, "Failed to set zero copy on port %s (status=%"PRIx32" %s)",
sys->input->name, status, mmal_status_to_string(status));
goto out;
}
}
status = mmal_port_enable(sys->input, input_port_cb); status = mmal_port_enable(sys->input, input_port_cb);
if (status != MMAL_SUCCESS) { if (status != MMAL_SUCCESS) {
msg_Err(filter, "Failed to enable input port %s (status=%"PRIx32" %s)", msg_Err(filter, "Failed to enable input port %s (status=%"PRIx32" %s)",
...@@ -183,6 +197,21 @@ static int Open(filter_t *filter) ...@@ -183,6 +197,21 @@ static int Open(filter_t *filter)
} }
sys->output->buffer_num = 3; sys->output->buffer_num = 3;
if (filter->fmt_in.i_codec == VLC_CODEC_MMAL_OPAQUE) {
MMAL_PARAMETER_BOOLEAN_T zero_copy = {
{ MMAL_PARAMETER_ZERO_COPY, sizeof(MMAL_PARAMETER_BOOLEAN_T) },
1
};
status = mmal_port_parameter_set(sys->output, &zero_copy.hdr);
if (status != MMAL_SUCCESS) {
msg_Err(filter, "Failed to set zero copy on port %s (status=%"PRIx32" %s)",
sys->output->name, status, mmal_status_to_string(status));
goto out;
}
}
status = mmal_port_enable(sys->output, output_port_cb); status = mmal_port_enable(sys->output, output_port_cb);
if (status != MMAL_SUCCESS) { if (status != MMAL_SUCCESS) {
msg_Err(filter, "Failed to enable output port %s (status=%"PRIx32" %s)", msg_Err(filter, "Failed to enable output port %s (status=%"PRIx32" %s)",
......
...@@ -462,6 +462,18 @@ static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count) ...@@ -462,6 +462,18 @@ static picture_pool_t *vd_pool(vout_display_t *vd, unsigned count)
if (sys->opaque) { if (sys->opaque) {
if (count <= NUM_ACTUAL_OPAQUE_BUFFERS) if (count <= NUM_ACTUAL_OPAQUE_BUFFERS)
count = NUM_ACTUAL_OPAQUE_BUFFERS; count = NUM_ACTUAL_OPAQUE_BUFFERS;
MMAL_PARAMETER_BOOLEAN_T zero_copy = {
{ MMAL_PARAMETER_ZERO_COPY, sizeof(MMAL_PARAMETER_BOOLEAN_T) },
1
};
status = mmal_port_parameter_set(sys->input, &zero_copy.hdr);
if (status != MMAL_SUCCESS) {
msg_Err(vd, "Failed to set zero copy on port %s (status=%"PRIx32" %s)",
sys->input->name, status, mmal_status_to_string(status));
goto out;
}
} }
if (count < sys->input->buffer_num_recommended) if (count < sys->input->buffer_num_recommended)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment