Skip to content

Commit

Permalink
fixup: uninitialised dimensions in mmal
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Feb 26, 2016
1 parent d0f75d0 commit 2ba8247
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
16 changes: 12 additions & 4 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALCodec.cpp
Expand Up @@ -63,6 +63,8 @@ CMMALVideoBuffer::CMMALVideoBuffer(CMMALVideo *omv)
mmal_buffer = NULL;
m_width = 0;
m_height = 0;
m_aligned_width = 0;
m_aligned_height = 0;
m_aspect_ratio = 0.0f;
m_refs = 0;
}
Expand Down Expand Up @@ -108,6 +110,8 @@ CMMALVideo::CMMALVideo()

m_decoded_width = 0;
m_decoded_height = 0;
m_decoded_aligned_width = 0;
m_decoded_aligned_height = 0;

m_finished = false;
m_pFormatName = "mmal-xxxx";
Expand Down Expand Up @@ -195,11 +199,13 @@ void CMMALVideo::PortSettingsChanged(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *bu
m_aspect_ratio = (float)(m_es_format->es->video.par.num * m_es_format->es->video.crop.width) / (m_es_format->es->video.par.den * m_es_format->es->video.crop.height);
m_decoded_width = m_es_format->es->video.crop.width;
m_decoded_height = m_es_format->es->video.crop.height;
m_decoded_aligned_width = m_es_format->es->video.width;
m_decoded_aligned_height = m_es_format->es->video.height;
if (g_advancedSettings.CanLogComponent(LOGVIDEO))
CLog::Log(LOGDEBUG, "%s::%s format changed: %dx%d %.2f", CLASSNAME, __func__, m_decoded_width, m_decoded_height, m_aspect_ratio);
CLog::Log(LOGDEBUG, "%s::%s format changed: %dx%d (%dx%d) %.2f", CLASSNAME, __func__, m_decoded_width, m_decoded_height, m_decoded_aligned_width, m_decoded_aligned_height, m_aspect_ratio);
}
else
CLog::Log(LOGERROR, "%s::%s format changed: Unexpected %dx%d", CLASSNAME, __func__, m_es_format->es->video.crop.width, m_es_format->es->video.crop.height);
CLog::Log(LOGERROR, "%s::%s format changed: Unexpected %dx%d (%dx%d)", CLASSNAME, __func__, m_es_format->es->video.crop.width, m_es_format->es->video.crop.height, m_decoded_aligned_width, m_decoded_aligned_height);

if (!change_dec_output_format())
CLog::Log(LOGERROR, "%s::%s - change_dec_output_format() failed", CLASSNAME, __func__);
Expand Down Expand Up @@ -285,6 +291,8 @@ void CMMALVideo::dec_output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buf
buffer->user_data = (void *)omvb;
omvb->m_width = m_decoded_width;
omvb->m_height = m_decoded_height;
omvb->m_aligned_width = m_decoded_aligned_width;
omvb->m_aligned_height = m_decoded_aligned_height;
omvb->m_aspect_ratio = m_aspect_ratio;
{
CSingleLock lock(m_output_mutex);
Expand Down Expand Up @@ -549,8 +557,8 @@ bool CMMALVideo::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
m_renderer = (CMMALRenderer *)options.m_opaque_pointer;
MMAL_STATUS_T status;

m_decoded_width = hints.width;
m_decoded_height = hints.height;
m_decoded_width = m_decoded_aligned_width = hints.width;
m_decoded_height = m_decoded_aligned_height = hints.height;

// use aspect in stream if available
if (m_hints.forced_aspect)
Expand Down
6 changes: 4 additions & 2 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALCodec.h
Expand Up @@ -109,8 +109,10 @@ class CMMALVideo : public CDVDVideoCodec
void Prime();

// Video format
int m_decoded_width;
int m_decoded_height;
unsigned int m_decoded_width;
unsigned int m_decoded_height;
unsigned int m_decoded_aligned_width;
unsigned int m_decoded_aligned_height;
unsigned int m_egl_buffer_count;
bool m_finished;
float m_aspect_ratio;
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALFFmpeg.cpp
Expand Up @@ -66,6 +66,7 @@ CMMALYUVBuffer::CMMALYUVBuffer(const CBufferPoolPtr &pool, unsigned int width, u
m_height = height;
m_aligned_width = aligned_width;
m_aligned_height = aligned_height;
m_aspect_ratio = 0.0f;
m_refs = 0;

unsigned int size_pic = (m_aligned_width * m_aligned_height * 3) >> 1;
Expand Down
31 changes: 12 additions & 19 deletions xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp
Expand Up @@ -130,22 +130,12 @@ bool CMMALRenderer::init_vout(ERenderFormat format, bool opaque)
else if (CONF_FLAGS_YUVCOEF_MASK(m_iFlags) == CONF_FLAGS_YUVCOEF_240M)
es_format->es->video.color_space = MMAL_COLOR_SPACE_SMPTE240M;

if (m_opaque)
{
es_format->encoding = MMAL_ENCODING_OPAQUE;
es_format->es->video.crop.width = m_sourceWidth;
es_format->es->video.crop.height = m_sourceHeight;
es_format->es->video.width = m_sourceWidth;
es_format->es->video.height = m_sourceHeight;
}
else
{
es_format->encoding = MMAL_ENCODING_I420;
es_format->es->video.crop.width = 0;
es_format->es->video.crop.height = 0;
es_format->es->video.width = 16;
es_format->es->video.height = 16;
}
es_format->es->video.crop.width = m_sourceWidth;
es_format->es->video.crop.height = m_sourceHeight;
es_format->es->video.width = m_sourceWidth;
es_format->es->video.height = m_sourceHeight;

es_format->encoding = m_opaque ? MMAL_ENCODING_OPAQUE : MMAL_ENCODING_I420;

status = mmal_port_parameter_set_boolean(m_vout_input, MMAL_PARAMETER_ZERO_COPY, MMAL_TRUE);
if (status != MMAL_SUCCESS)
Expand Down Expand Up @@ -184,7 +174,7 @@ bool CMMALRenderer::init_vout(ERenderFormat format, bool opaque)
}

CLog::Log(LOGDEBUG, "%s::%s Created pool of size %d x %d", CLASSNAME, __func__, m_vout_input->buffer_num, m_vout_input->buffer_size);
m_vout_input_pool = mmal_port_pool_create(m_vout_input , m_vout_input->buffer_num, m_vout_input->buffer_size);
m_vout_input_pool = mmal_port_pool_create(m_vout_input , m_vout_input->buffer_num, m_opaque ? m_vout_input->buffer_size:0);
if (!m_vout_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));
Expand Down Expand Up @@ -362,9 +352,12 @@ void CMMALRenderer::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
if (omvb->mmal_buffer->flags & MMAL_BUFFER_HEADER_FLAG_USER1)
return;
// check for changes in aligned sizes
if (omvb->m_aligned_width != m_vout_input->format->es->video.width || omvb->m_aligned_height != m_vout_input->format->es->video.height)
if (omvb->m_width != (uint32_t)m_vout_input->format->es->video.crop.width || omvb->m_height != (uint32_t)m_vout_input->format->es->video.crop.height ||
omvb->m_aligned_width != m_vout_input->format->es->video.width || omvb->m_aligned_height != m_vout_input->format->es->video.height)
{
CLog::Log(LOGDEBUG, "%s::%s Changing dimensions from %dx%d to %dx%d", CLASSNAME, __func__, m_vout_input->format->es->video.width, m_vout_input->format->es->video.height, omvb->m_aligned_width, omvb->m_aligned_height);
CLog::Log(LOGDEBUG, "%s::%s Changing dimensions from %dx%d (%dx%d) to %dx%d (%dx%d)", CLASSNAME, __func__,
m_vout_input->format->es->video.crop.width, m_vout_input->format->es->video.crop.height, omvb->m_width, omvb->m_height,
m_vout_input->format->es->video.width, m_vout_input->format->es->video.height, omvb->m_aligned_width, omvb->m_aligned_height);
m_vout_input->format->es->video.width = omvb->m_aligned_width;
m_vout_input->format->es->video.height = omvb->m_aligned_height;
m_vout_input->format->es->video.crop.width = omvb->m_width;
Expand Down

0 comments on commit 2ba8247

Please sign in to comment.