bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation) { CSingleLock lock(m_sharedSection); ReleaseBuffers(); m_sourceWidth = width; m_sourceHeight = height; m_renderOrientation = orientation; m_fps = fps; m_iFlags = flags; CLog::Log(LOGDEBUG, "%s::%s - %dx%d->%dx%d@%.2f flags:%x format:%d ext:%x orient:%d", CLASSNAME, __func__, width, height, d_width, d_height, fps, flags, format, extended_format, orientation); m_RenderUpdateCallBackFn = NULL; m_RenderUpdateCallBackCtx = NULL; // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); SetViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); m_bMMALConfigured = init_vout(format); m_bConfigured = m_bMMALConfigured; assert(m_bConfigured); return m_bConfigured; }
bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation) { CSingleLock lock(m_sharedSection); ReleaseBuffers(); m_sourceWidth = width; m_sourceHeight = height; m_renderOrientation = orientation; m_fps = fps; m_iFlags = flags; // cause SetVideoRect to trigger - needed after a hdmi mode change m_src_rect.SetRect(0, 0, 0, 0); m_dst_rect.SetRect(0, 0, 0, 0); CLog::Log(LOGDEBUG, "%s::%s - %dx%d->%dx%d@%.2f flags:%x format:%d ext:%x orient:%d", CLASSNAME, __func__, width, height, d_width, d_height, fps, flags, format, extended_format, orientation); if (format != RENDER_FMT_BYPASS && format != RENDER_FMT_MMAL) { CLog::Log(LOGERROR, "%s::%s - format:%d not supported", CLASSNAME, __func__, format); return false; } // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); SetViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode); ManageRenderArea(); m_bMMALConfigured = init_vout(format, m_opaque); m_bConfigured = m_bMMALConfigured; assert(m_bConfigured); return m_bConfigured; }
MMAL_POOL_T *CMMALRenderer::GetPool(ERenderFormat format, bool opaque) { CSingleLock lock(m_sharedSection); if (!m_bMMALConfigured) m_bMMALConfigured = init_vout(format, opaque); return m_vout_input_pool; }
CRenderInfo CMMALRenderer::GetRenderInfo() { CSingleLock lock(m_sharedSection); CRenderInfo info; // we'll assume that video is accelerated (RENDER_FMT_MMAL) for now // we will reconfigure renderer later if necessary if (!m_bMMALConfigured) m_bMMALConfigured = init_vout(RENDER_FMT_MMAL); #if defined(MMAL_DEBUG_VERBOSE) CLog::Log(LOGDEBUG, "%s::%s cookie:%p", CLASSNAME, __func__, (void *)m_vout_input_pool); #endif info.max_buffer_size = NUM_BUFFERS; info.optimal_buffer_size = NUM_BUFFERS; info.opaque_pointer = (void *)m_vout_input_pool; info.formats = m_formats; return info; }
bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation) { ReleaseBuffers(); m_sourceWidth = width; m_sourceHeight = height; m_renderOrientation = orientation; m_fps = fps; m_iFlags = flags; m_format = format; CLog::Log(LOGDEBUG, "%s::%s - %dx%d->%dx%d@%.2f flags:%x format:%d ext:%x orient:%d", CLASSNAME, __func__, width, height, d_width, d_height, fps, flags, format, extended_format, orientation); m_RenderUpdateCallBackFn = NULL; m_RenderUpdateCallBackCtx = NULL; // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); ChooseBestResolution(fps); m_destWidth = g_graphicsContext.GetResInfo(m_resolution).iWidth; m_destHeight = g_graphicsContext.GetResInfo(m_resolution).iHeight; SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); if (m_format == RENDER_FMT_MMAL|| m_format == RENDER_FMT_YUV420P) { MMAL_ES_FORMAT_T *es_format = mmal_format_alloc(); es_format->type = MMAL_ES_TYPE_VIDEO; es_format->es->video.crop.width = m_sourceWidth; es_format->es->video.crop.height = m_sourceHeight; if (m_format == RENDER_FMT_MMAL) { es_format->encoding = MMAL_ENCODING_OPAQUE; es_format->es->video.width = m_sourceWidth; es_format->es->video.height = m_sourceHeight; } else if (m_format == RENDER_FMT_YUV420P) { const int pitch = ALIGN_UP(m_sourceWidth, 32); const int aligned_height = ALIGN_UP(m_sourceHeight, 16); es_format->encoding = MMAL_ENCODING_I420; es_format->es->video.width = pitch; es_format->es->video.height = aligned_height; if (CONF_FLAGS_YUVCOEF_MASK(m_iFlags) == CONF_FLAGS_YUVCOEF_BT709) es_format->es->video.color_space = MMAL_COLOR_SPACE_ITUR_BT709; else if (CONF_FLAGS_YUVCOEF_MASK(m_iFlags) == CONF_FLAGS_YUVCOEF_BT601) es_format->es->video.color_space = MMAL_COLOR_SPACE_ITUR_BT601; else if (CONF_FLAGS_YUVCOEF_MASK(m_iFlags) == CONF_FLAGS_YUVCOEF_240M) es_format->es->video.color_space = MMAL_COLOR_SPACE_SMPTE240M; } if (m_bConfigured) UnInitMMAL(); m_bConfigured = init_vout(es_format); mmal_format_free(es_format); } else m_bConfigured = true; return m_bConfigured; }