EINTERLACEMETHOD CXBMCRenderManager::AutoInterlaceMethod(EINTERLACEMETHOD mInt) { CSharedLock lock(m_sharedSection); return AutoInterlaceMethodInternal(mInt); }
void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/) { if(timestamp - GetPresentTime() > MAXPRESENTDELAY) timestamp = GetPresentTime() + MAXPRESENTDELAY; /* can't flip, untill timestamp */ if(!g_graphicsContext.IsFullScreenVideo()) WaitPresentTime(timestamp); /* make sure any queued frame was fully presented */ double timeout = m_presenttime + 1.0; while(m_presentstep != PRESENT_IDLE && !bStop) { if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop) { CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for previous frame"); return; } }; if(bStop) return; { CRetakeLock<CExclusiveLock> lock(m_sharedSection); if(!m_pRenderer) return; m_presenttime = timestamp; m_presentfield = sync; m_presentstep = PRESENT_FLIP; m_presentsource = source; EDEINTERLACEMODE deinterlacemode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; EINTERLACEMETHOD interlacemethod = AutoInterlaceMethodInternal(g_settings.m_currentVideoSettings.m_InterlaceMethod); bool invert = false; if (deinterlacemode == VS_DEINTERLACEMODE_OFF) m_presentmethod = PRESENT_METHOD_SINGLE; else { if (deinterlacemode == VS_DEINTERLACEMODE_AUTO && m_presentfield == FS_NONE) m_presentmethod = PRESENT_METHOD_SINGLE; else { if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BLEND) m_presentmethod = PRESENT_METHOD_BLEND; else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE) m_presentmethod = PRESENT_METHOD_WEAVE; else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED) { m_presentmethod = PRESENT_METHOD_WEAVE ; invert = true; } else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB) m_presentmethod = PRESENT_METHOD_BOB; else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED) { m_presentmethod = PRESENT_METHOD_BOB; invert = true; } else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BOB) m_presentmethod = PRESENT_METHOD_BOB; else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BEST) m_presentmethod = PRESENT_METHOD_BOB; else m_presentmethod = PRESENT_METHOD_SINGLE; /* default to odd field if we want to deinterlace and don't know better */ if (deinterlacemode == VS_DEINTERLACEMODE_FORCE && m_presentfield == FS_NONE) m_presentfield = FS_TOP; /* invert present field */ if(invert) { if( m_presentfield == FS_BOT ) m_presentfield = FS_TOP; else m_presentfield = FS_BOT; } } } } g_application.NewFrame(); /* wait untill render thread have flipped buffers */ timeout = m_presenttime + 1.0; while(m_presentstep == PRESENT_FLIP && !bStop) { if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop) { CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for flip to complete"); return; } } }
void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, double pts /* = 0 */, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/) { { CSharedLock lock(m_sharedSection); if(bStop) return; if(!m_pRenderer) return; m_firstFlipPage = true; // tempfix EPRESENTMETHOD presentmethod; EDEINTERLACEMODE deinterlacemode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; EINTERLACEMETHOD interlacemethod = AutoInterlaceMethodInternal(CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod); if(g_advancedSettings.m_videoDisableBackgroundDeinterlace && !g_graphicsContext.IsFullScreenVideo()) deinterlacemode = VS_DEINTERLACEMODE_OFF; if (deinterlacemode == VS_DEINTERLACEMODE_OFF) presentmethod = PRESENT_METHOD_SINGLE; else { if (deinterlacemode == VS_DEINTERLACEMODE_AUTO && sync == FS_NONE) presentmethod = PRESENT_METHOD_SINGLE; else { bool invert = false; if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BLEND) presentmethod = PRESENT_METHOD_BLEND; else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE) presentmethod = PRESENT_METHOD_WEAVE; else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED) { presentmethod = PRESENT_METHOD_WEAVE ; invert = true; } else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB) presentmethod = PRESENT_METHOD_BOB; else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED) { presentmethod = PRESENT_METHOD_BOB; invert = true; } else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BOB) presentmethod = PRESENT_METHOD_BOB; else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BEST) presentmethod = PRESENT_METHOD_BOB; else presentmethod = PRESENT_METHOD_SINGLE; /* default to odd field if we want to deinterlace and don't know better */ if (deinterlacemode == VS_DEINTERLACEMODE_FORCE && sync == FS_NONE) sync = FS_TOP; /* invert present field */ if(invert) { if( sync == FS_BOT ) sync = FS_TOP; else sync = FS_BOT; } } } /* failsafe for invalid timestamps, to make sure queue always empties */ if(timestamp > GetPresentTime() + 5.0) timestamp = GetPresentTime() + 5.0; CSingleLock lock2(m_presentlock); if(m_free.empty()) return; if(source < 0) source = m_free.front(); SPresent& m = m_Queue[source]; m.timestamp = timestamp; m.presentfield = sync; m.presentmethod = presentmethod; m.pts = pts; requeue(m_queued, m_free); /* signal to any waiters to check state */ if(m_presentstep == PRESENT_IDLE) { m_presentstep = PRESENT_READY; m_presentevent.notifyAll(); } } }