Skip to content

Commit

Permalink
[mmal] Enable zero copy
Browse files Browse the repository at this point in the history
This is a bit subtle, but the reference counting of pictures is only shared
between arm side and gpu side when in zero copy mode.
  • Loading branch information
popcornmix committed May 9, 2015
1 parent 1616025 commit 29cd277
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions xbmc/cores/VideoRenderers/MMALRenderer.cpp
Expand Up @@ -147,6 +147,12 @@ bool CMMALRenderer::init_vout(ERenderFormat format)
es_format->es->video.color_space = MMAL_COLOR_SPACE_SMPTE240M;
}

if (m_format == RENDER_FMT_MMAL)
{
status = mmal_port_parameter_set_boolean(m_vout_input, MMAL_PARAMETER_ZERO_COPY, MMAL_TRUE);
if (status != MMAL_SUCCESS)
CLog::Log(LOGERROR, "%s::%s Failed to enable zero copy mode on %s (status=%x %s)", CLASSNAME, __func__, m_vout_input->name, status, mmal_status_to_string(status));
}
status = mmal_port_format_commit(m_vout_input);
if (status != MMAL_SUCCESS)
{
Expand Down
18 changes: 16 additions & 2 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.cpp
Expand Up @@ -307,6 +307,11 @@ bool CMMALVideo::change_dec_output_format()
CLog::Log(LOGERROR, "%s::%s Failed to query interlace type on %s (status=%x %s)", CLASSNAME, __func__, m_dec_output->name, status, mmal_status_to_string(status));

mmal_format_copy(m_dec_output->format, m_es_format);

status = mmal_port_parameter_set_boolean(m_dec_output, MMAL_PARAMETER_ZERO_COPY, MMAL_TRUE);
if (status != MMAL_SUCCESS)
CLog::Log(LOGERROR, "%s::%s Failed to enable zero copy mode on %s (status=%x %s)", CLASSNAME, __func__, m_dec_output->name, status, mmal_status_to_string(status));

status = mmal_port_format_commit(m_dec_output);
if (status != MMAL_SUCCESS)
{
Expand Down Expand Up @@ -378,6 +383,11 @@ bool CMMALVideo::CreateDeinterlace(EINTERLACEMETHOD interlace_method)
}

mmal_format_copy(m_deint->output[0]->format, m_es_format);

status = mmal_port_parameter_set_boolean(m_deint->output[0], MMAL_PARAMETER_ZERO_COPY, MMAL_TRUE);
if (status != MMAL_SUCCESS)
CLog::Log(LOGERROR, "%s::%s Failed to enable zero copy mode on %s (status=%x %s)", CLASSNAME, __func__, m_deint->output[0]->name, status, mmal_status_to_string(status));

status = mmal_port_format_commit(m_deint->output[0]);
if (status != MMAL_SUCCESS)
{
Expand Down Expand Up @@ -648,6 +658,10 @@ bool CMMALVideo::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options, MMALVide
m_dec_output->format->encoding = MMAL_ENCODING_OPAQUE;
mmal_format_copy(m_es_format, m_dec_output->format);

status = mmal_port_parameter_set_boolean(m_dec_output, MMAL_PARAMETER_ZERO_COPY, MMAL_TRUE);
if (status != MMAL_SUCCESS)
CLog::Log(LOGERROR, "%s::%s Failed to enable zero copy mode on %s (status=%x %s)", CLASSNAME, __func__, m_dec_output->name, status, mmal_status_to_string(status));

status = mmal_port_format_commit(m_dec_output);
if (status != MMAL_SUCCESS)
{
Expand All @@ -672,14 +686,14 @@ bool CMMALVideo::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options, MMALVide
return false;
}

m_dec_input_pool = mmal_pool_create(m_dec_input->buffer_num, m_dec_input->buffer_size);
m_dec_input_pool = mmal_port_pool_create(m_dec_input, m_dec_input->buffer_num, m_dec_input->buffer_size);
if (!m_dec_input_pool)
{
CLog::Log(LOGERROR, "%s::%s Failed to create pool for decoder input port (status=%x %s)", CLASSNAME, __func__, status, mmal_status_to_string(status));
return false;
}

m_dec_output_pool = mmal_pool_create(m_dec_output->buffer_num, m_dec_output->buffer_size);
m_dec_output_pool = mmal_port_pool_create(m_dec_output, m_dec_output->buffer_num, m_dec_output->buffer_size);
if(!m_dec_output_pool)
{
CLog::Log(LOGERROR, "%s::%s Failed to create pool for decode output port (status=%x %s)", CLASSNAME, __func__, status, mmal_status_to_string(status));
Expand Down

0 comments on commit 29cd277

Please sign in to comment.