projects/RPi/patches/xbmc: add FM support patch from 4.0.7 back

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2014-09-30 16:41:38 +02:00
parent 97aabe2946
commit fe224ebecb
4 changed files with 11211 additions and 675 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
From 4f6188bc2bcee52ab3a150fff336b58c11f8928a Mon Sep 17 00:00:00 2001
From: Stefan Saraev <stefan@saraev.ca>
Date: Sat, 22 Mar 2014 22:18:28 +0200
Subject: [PATCH] dont set _NET_WM_STATE_FULLSCREEN
---
xbmc/windowing/X11/WinSystemX11.cpp | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp
index c95f4ec..d12e050 100644
--- a/xbmc/windowing/X11/WinSystemX11.cpp
+++ b/xbmc/windowing/X11/WinSystemX11.cpp
@@ -903,12 +903,6 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const std:
InputOutput, vi->visual,
mask, &swa);
- if (fullscreen && hasWM)
- {
- Atom fs = XInternAtom(m_dpy, "_NET_WM_STATE_FULLSCREEN", True);
- XChangeProperty(m_dpy, m_mainWindow, XInternAtom(m_dpy, "_NET_WM_STATE", True), XA_ATOM, 32, PropModeReplace, (unsigned char *) &fs, 1);
- }
-
// define invisible cursor
Pixmap bitmapNoData;
XColor black;
--
1.7.2.5

View File

@ -0,0 +1,13 @@
diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp
index a5b4ba2..3586a6a 100644
--- a/xbmc/windowing/WinEventsX11.cpp
+++ b/xbmc/windowing/WinEventsX11.cpp
@@ -731,7 +731,7 @@ XBMCKey CWinEventsX11Imp::LookupXbmcKeySym(KeySym keysym)
// try ascii mappings
if (keysym>>8 == 0x00)
- return (XBMCKey)(keysym & 0xFF);
+ return (XBMCKey)tolower(keysym & 0xFF);
return (XBMCKey)keysym;
}

View File

@ -19375,681 +19375,6 @@ index 6f19395..8eff32f 100644
2.0.4
From 09c1715be013bc927d975761513a358f010cec52 Mon Sep 17 00:00:00 2001
From: xbmc <fernetmenta@online.de>
Date: Mon, 28 May 2012 10:34:39 +0200
Subject: [PATCH 084/106] videoplayer: adapt lateness detection and dropping to
buffering
---
xbmc/cores/VideoRenderers/RenderManager.cpp | 16 +-
xbmc/cores/VideoRenderers/RenderManager.h | 12 +-
.../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h | 38 +++-
.../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 41 +++++
.../DVDCodecs/Video/DVDVideoCodecFFmpeg.h | 7 +
xbmc/cores/dvdplayer/DVDPlayerVideo.cpp | 197 +++++++++++++++++----
xbmc/cores/dvdplayer/DVDPlayerVideo.h | 23 +++
7 files changed, 296 insertions(+), 38 deletions(-)
diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp
index a7b4721..d31c6c7 100644
--- a/xbmc/cores/VideoRenderers/RenderManager.cpp
+++ b/xbmc/cores/VideoRenderers/RenderManager.cpp
@@ -286,6 +286,8 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
m_bIsStarted = true;
m_bReconfigured = true;
m_presentstep = PRESENT_IDLE;
+ m_presentpts = DVD_NOPTS_VALUE;
+ m_sleeptime = 1.0;
m_presentevent.notifyAll();
m_firstFlipPage = false; // tempfix
@@ -631,7 +633,7 @@ void CXBMCRenderManager::SetViewMode(int iViewMode)
m_pRenderer->SetViewMode(iViewMode);
}
-void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/)
+void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, double pts /* = 0 */, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/)
{
{ CSharedLock lock(m_sharedSection);
@@ -699,6 +701,7 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L
m.timestamp = timestamp;
m.presentfield = sync;
m.presentmethod = presentmethod;
+ m.pts = pts;
requeue(m_queued, m_free);
/* signal to any waiters to check state */
@@ -1073,6 +1076,8 @@ void CXBMCRenderManager::PrepareNextRender()
m_discard.push_back(m_presentsource);
m_presentsource = idx;
m_queued.pop_front();
+ m_sleeptime = m_Queue[idx].timestamp - clocktime;
+ m_presentpts = m_Queue[idx].pts;
m_presentevent.notifyAll();
}
}
@@ -1089,3 +1094,12 @@ void CXBMCRenderManager::DiscardBuffer()
m_presentstep = PRESENT_IDLE;
m_presentevent.notifyAll();
}
+
+bool CXBMCRenderManager::GetStats(double &sleeptime, double &pts, int &bufferLevel)
+{
+ CSingleLock lock(m_presentlock);
+ sleeptime = m_sleeptime;
+ pts = m_presentpts;
+ bufferLevel = m_queued.size() + m_discard.size();
+ return true;
+}
diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h
index c3f5517..d84ff6c 100644
--- a/xbmc/cores/VideoRenderers/RenderManager.h
+++ b/xbmc/cores/VideoRenderers/RenderManager.h
@@ -98,10 +98,11 @@ class CXBMCRenderManager
*
* @param bStop reference to stop flag of calling thread
* @param timestamp of frame delivered with AddVideoPicture
+ * @param pts used for lateness detection
* @param source depreciated
* @param sync signals frame, top, or bottom field
*/
- void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
+ void FlipPage(volatile bool& bStop, double timestamp = 0.0, double pts = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
unsigned int PreInit();
void UnInit();
bool Flush();
@@ -176,6 +177,12 @@ class CXBMCRenderManager
int WaitForBuffer(volatile bool& bStop, int timeout = 100);
/**
+ * Can be called by player for lateness detection. This is done best by
+ * looking at the end of the queue.
+ */
+ bool GetStats(double &sleeptime, double &pts, int &bufferLevel);
+
+ /**
* Video player call this on flush in oder to discard any queued frames
*/
void DiscardBuffer();
@@ -222,6 +229,7 @@ class CXBMCRenderManager
struct SPresent
{
+ double pts;
double timestamp;
EFIELDSYNC presentfield;
EPRESENTMETHOD presentmethod;
@@ -233,6 +241,8 @@ class CXBMCRenderManager
ERenderFormat m_format;
+ double m_sleeptime;
+ double m_presentpts;
double m_presentcorr;
double m_presenterr;
double m_errorbuff[ERRORBUFFSIZE];
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
index dc047d7..c09939c 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
@@ -129,6 +129,10 @@ struct DVDVideoUserData
#define DVP_FLAG_NOSKIP 0x00000010 // indicate this picture should never be dropped
#define DVP_FLAG_DROPPED 0x00000020 // indicate that this picture has been dropped in decoder stage, will have no data
+#define DVP_FLAG_DROPDEINT 0x00000040 // indicate that this picture was requested to have been dropped in deint stage
+#define DVP_FLAG_NO_POSTPROC 0x00000100 // see GetCodecStats
+#define DVP_FLAG_DRAIN 0x00000200 // see GetCodecStats
+
// DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2!
#define DVP_QSCALE_UNKNOWN 0
@@ -146,6 +150,8 @@ class CDVDCodecOptions;
#define VC_PICTURE 0x00000004 // the decoder got a picture, call Decode(NULL, 0) again to parse the rest of the data
#define VC_USERDATA 0x00000008 // the decoder found some userdata, call Decode(NULL, 0) again to parse the rest of the data
#define VC_FLUSHED 0x00000010 // the decoder lost it's state, we need to restart decoding again
+#define VC_DROPPED 0x00000020 // needed to identify if a picture was dropped
+
class CDVDVideoCodec
{
public:
@@ -263,7 +269,6 @@ class CDVDVideoCodec
return 0;
}
-
/**
* Number of references to old pictures that are allowed to
* be retained when calling decode on the next demux packet
@@ -280,4 +285,35 @@ class CDVDVideoCodec
* Interact with user settings so that user disabled codecs are disabled
*/
static bool IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id);
+
+ /* For calculation of dropping requirements player asks for some information.
+ *
+ * - pts : right after decoder, used to detect gaps (dropped frames in decoder)
+ * - droppedPics : indicates if decoder has dropped a picture
+ * -1 means that decoder has no info on this.
+ *
+ * If codec does not implement this method, pts of decoded frame at input
+ * video player is used. In case decoder does post-proc and de-interlacing there
+ * may be quite some frames queued up between exit decoder and entry player.
+ */
+ virtual bool GetCodecStats(double &pts, int &droppedPics)
+ {
+ droppedPics= -1;
+ return false;
+ }
+
+ /**
+ * Codec can be informed by player with the following flags:
+ *
+ * DVP_FLAG_NO_POSTPROC : if speed is not normal the codec can switch off
+ * postprocessing and de-interlacing
+ *
+ * DVP_FLAG_DRAIN : codecs may do postprocessing and de-interlacing.
+ * If video buffers in RenderManager are about to run dry,
+ * this is signaled to codec. Codec can wait for post-proc
+ * to be finished instead of returning empty and getting another
+ * packet.
+ *
+ */
+ virtual void SetCodecControl(int flags) {}
};
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
index 9b6a34d..81fe0cf 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
@@ -164,6 +164,7 @@ CDVDVideoCodecFFmpeg::CDVDVideoCodecFFmpeg() : CDVDVideoCodec()
m_iLastKeyframe = 0;
m_dts = DVD_NOPTS_VALUE;
m_started = false;
+ m_decoderPts = DVD_NOPTS_VALUE;
}
CDVDVideoCodecFFmpeg::~CDVDVideoCodecFFmpeg()
@@ -355,6 +356,14 @@ void CDVDVideoCodecFFmpeg::SetDropState(bool bDrop)
{
if( m_pCodecContext )
{
+ if (bDrop && m_pHardware && m_pHardware->CanSkipDeint())
+ {
+ m_requestSkipDeint = true;
+ bDrop = false;
+ }
+ else
+ m_requestSkipDeint = false;
+
// i don't know exactly how high this should be set
// couldn't find any good docs on it. think it varies
// from codec to codec on what it does
@@ -556,6 +565,7 @@ int CDVDVideoCodecFFmpeg::Decode(uint8_t* pData, int iSize, double dts, double p
void CDVDVideoCodecFFmpeg::Reset()
{
m_started = false;
+ m_decoderPts = DVD_NOPTS_VALUE;
m_iLastKeyframe = m_pCodecContext->has_b_frames;
m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext);
@@ -665,6 +675,22 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture)
else
pDvdVideoPicture->pts = DVD_NOPTS_VALUE;
+ if (pDvdVideoPicture->pts != DVD_NOPTS_VALUE)
+ m_decoderPts = pDvdVideoPicture->pts;
+ else
+ m_decoderPts = m_dts;
+
+ if (m_requestSkipDeint)
+ {
+ pDvdVideoPicture->iFlags |= DVP_FLAG_DROPDEINT;
+ m_skippedDeint = 1;
+ }
+ else
+ m_skippedDeint = 0;
+
+ m_requestSkipDeint = false;
+ pDvdVideoPicture->iFlags |= m_codecControlFlags;
+
if(!m_started)
pDvdVideoPicture->iFlags |= DVP_FLAG_DROPPED;
@@ -924,3 +950,18 @@ unsigned CDVDVideoCodecFFmpeg::GetAllowedReferences()
else
return 0;
}
+
+bool CDVDVideoCodecFFmpeg::GetCodecStats(double &pts, int &droppedPics)
+{
+ pts = m_decoderPts;
+ if (m_skippedDeint)
+ droppedPics = m_skippedDeint;
+ else
+ droppedPics = -1;
+ return true;
+}
+
+void CDVDVideoCodecFFmpeg::SetCodecControl(int flags)
+{
+ m_codecControlFlags = flags;
+}
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
index 2287031..827c9507 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
@@ -45,6 +45,7 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
virtual int Check (AVCodecContext* avctx) = 0;
virtual void Reset () {}
virtual unsigned GetAllowedReferences() { return 0; }
+ virtual bool CanSkipDeint() {return false; }
virtual const std::string Name() = 0;
virtual CCriticalSection* Section() { return NULL; }
};
@@ -62,6 +63,8 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
virtual const char* GetName() { return m_name.c_str(); }; // m_name is never changed after open
virtual unsigned GetConvergeCount();
virtual unsigned GetAllowedReferences();
+ virtual bool GetCodecStats(double &pts, int &droppedPics);
+ virtual void SetCodecControl(int flags);
bool IsHardwareAllowed() { return !m_bSoftware; }
IHardwareDecoder * GetHardware() { return m_pHardware; };
@@ -127,4 +130,8 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
double m_dts;
bool m_started;
std::vector<PixelFormat> m_formats;
+ double m_decoderPts, m_decoderInterval;
+ int m_skippedDeint;
+ bool m_requestSkipDeint;
+ int m_codecControlFlags;
};
diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
index fddb7f7..181ff74 100644
--- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
@@ -38,6 +38,7 @@
#include "DVDCodecs/DVDCodecs.h"
#include "DVDCodecs/Overlay/DVDOverlayCodecCC.h"
#include "DVDCodecs/Overlay/DVDOverlaySSA.h"
+#include "guilib/GraphicContext.h"
#include <sstream>
#include <iomanip>
#include <numeric>
@@ -320,8 +321,10 @@ void CDVDPlayerVideo::Process()
int iDropped = 0; //frames dropped in a row
bool bRequestDrop = false;
+ int iDropDirective;
m_videoStats.Start();
+ m_droppingStats.Reset();
while (!m_bStop)
{
@@ -436,6 +439,7 @@ void CDVDPlayerVideo::Process()
picture.iFlags &= ~DVP_FLAG_ALLOCATED;
m_packets.clear();
m_started = false;
+ m_droppingStats.Reset();
}
else if (pMsg->IsType(CDVDMsg::GENERAL_FLUSH)) // private message sent by (CDVDPlayerVideo::Flush())
{
@@ -448,6 +452,7 @@ void CDVDPlayerVideo::Process()
//we need to recalculate the framerate
//TODO: this needs to be set on a streamchange instead
ResetFrameRateCalc();
+ m_droppingStats.Reset();
m_stalled = true;
m_started = false;
@@ -467,6 +472,7 @@ void CDVDPlayerVideo::Process()
m_iNrOfPicturesNotToSkip = 0;
if (m_pVideoCodec)
m_pVideoCodec->SetSpeed(m_speed);
+ m_droppingStats.Reset();
}
else if (pMsg->IsType(CDVDMsg::PLAYER_STARTED))
{
@@ -515,6 +521,28 @@ void CDVDPlayerVideo::Process()
m_iNrOfPicturesNotToSkip = 1;
}
+ bRequestDrop = false;
+ iDropDirective = CalcDropRequirement(pts);
+ if (iDropDirective & EOS_VERYLATE)
+ {
+ if (m_bAllowDrop)
+ {
+ m_pullupCorrection.Flush();
+ bRequestDrop = true;
+ }
+ }
+ int codecControl = 0;
+ if (iDropDirective & EOS_BUFFER_LEVEL)
+ codecControl |= DVP_FLAG_DRAIN;
+ if (m_speed > DVD_PLAYSPEED_NORMAL)
+ codecControl |= DVP_FLAG_NO_POSTPROC;
+ m_pVideoCodec->SetCodecControl(codecControl);
+ if (iDropDirective & EOS_DROPPED)
+ {
+ m_iDroppedFrames++;
+ iDropped++;
+ }
+
if (m_messageQueue.GetDataSize() == 0
|| m_speed < 0)
{
@@ -567,15 +595,7 @@ void CDVDPlayerVideo::Process()
}
m_videoStats.AddSampleBytes(pPacket->iSize);
- // assume decoder dropped a picture if it didn't give us any
- // picture from a demux packet, this should be reasonable
- // for libavformat as a demuxer as it normally packetizes
- // pictures when they come from demuxer
- if(bRequestDrop && !bPacketDrop && (iDecoderState & VC_BUFFER) && !(iDecoderState & VC_PICTURE))
- {
- m_iDroppedFrames++;
- iDropped++;
- }
+
// reset the request, the following while loop may break before
// setting the flag to a new value
bRequestDrop = false;
@@ -1185,33 +1205,12 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
m_FlipTimeStamp += max(0.0, iSleepTime);
m_FlipTimeStamp += iFrameDuration;
- if (iSleepTime <= 0 && m_speed)
- m_iLateFrames++;
- else
- m_iLateFrames = 0;
-
- // ask decoder to drop frames next round, as we are very late
- if(m_iLateFrames > 10)
+ if ((pPicture->iFlags & DVP_FLAG_DROPPED))
{
- if (!(pPicture->iFlags & DVP_FLAG_NOSKIP))
- {
- //if we're calculating the framerate,
- //don't drop frames until we've calculated a stable framerate
- if (m_bAllowDrop || m_speed != DVD_PLAYSPEED_NORMAL)
- {
- result |= EOS_VERYLATE;
- m_pullupCorrection.Flush(); //dropped frames mess up the pattern, so just flush it
- }
- m_iDroppedRequest++;
- }
- }
- else
- {
- m_iDroppedRequest = 0;
- }
-
- if( (pPicture->iFlags & DVP_FLAG_DROPPED) )
+ m_droppingStats.AddOutputDropGain(pts, 1/m_fFrameRate);
+ CLog::Log(LOGDEBUG,"%s - dropped in output", __FUNCTION__);
return result | EOS_DROPPED;
+ }
// set fieldsync if picture is interlaced
EFIELDSYNC mDisplayField = FS_NONE;
@@ -1244,7 +1243,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
if (index < 0)
return EOS_DROPPED;
- g_renderManager.FlipPage(CThread::m_bStop, (iCurrentClock + iSleepTime) / DVD_TIME_BASE, -1, mDisplayField);
+ g_renderManager.FlipPage(CThread::m_bStop, (iCurrentClock + iSleepTime) / DVD_TIME_BASE, pts, -1, mDisplayField);
return result;
#else
@@ -1544,3 +1543,131 @@ void CDVDPlayerVideo::CalcFrameRate()
m_iFrameRateCount = 0;
}
}
+
+int CDVDPlayerVideo::CalcDropRequirement(double pts)
+{
+ int result = 0;
+ double iSleepTime;
+ double iDecoderPts, iRenderPts;
+ double iInterval;
+ double iGain;
+ double iLateness;
+ bool bNewFrame;
+ int iDroppedPics = -1;
+ int iBufferLevel;
+
+ // get decoder stats
+ if (!m_pVideoCodec->GetCodecStats(iDecoderPts, iDroppedPics))
+ iDecoderPts = pts;
+ if (iDecoderPts == DVD_NOPTS_VALUE)
+ iDecoderPts = pts;
+
+ // get render stats
+ g_renderManager.GetStats(iSleepTime, iRenderPts, iBufferLevel);
+
+ if (iBufferLevel < 0)
+ result |= EOS_BUFFER_LEVEL;
+ else if (iBufferLevel < 2)
+ {
+ result |= EOS_BUFFER_LEVEL;
+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - hurry: %d", iBufferLevel);
+ }
+
+ bNewFrame = iDecoderPts != m_droppingStats.m_lastDecoderPts;
+
+ iInterval = 1/m_fFrameRate*(double)DVD_TIME_BASE;
+
+ m_FlipTimeStamp = m_pClock->GetAbsoluteClock() + max(0.0, iSleepTime) + iInterval;
+
+ if (m_stalled)
+ m_iCurrentPts = DVD_NOPTS_VALUE;
+ else
+ m_iCurrentPts = iRenderPts - max(0.0, iSleepTime);
+
+ if (m_droppingStats.m_lastDecoderPts > 0
+ && bNewFrame
+ && m_bAllowDrop)
+ {
+ iGain = (iDecoderPts - m_droppingStats.m_lastDecoderPts - iInterval)/(double)DVD_TIME_BASE;
+ if (iDroppedPics > 0)
+ {
+ CDroppingStats::CGain gain;
+ gain.gain = iDroppedPics * 1/m_fFrameRate;
+ gain.pts = iDecoderPts;
+ m_droppingStats.m_gain.push_back(gain);
+ m_droppingStats.m_totalGain += gain.gain;
+ result |= EOS_DROPPED;
+ m_droppingStats.m_dropRequests = 0;
+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - dropped pictures, Sleeptime: %f, Bufferlevel: %d, Gain: %f", iSleepTime, iBufferLevel, iGain);
+ }
+ else if (iDroppedPics < 0 && iGain > 1/m_fFrameRate)
+ {
+ CDroppingStats::CGain gain;
+ gain.gain = iGain;
+ gain.pts = iDecoderPts;
+ m_droppingStats.m_gain.push_back(gain);
+ m_droppingStats.m_totalGain += iGain;
+ result |= EOS_DROPPED;
+ m_droppingStats.m_dropRequests = 0;
+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - dropped in decoder, Sleeptime: %f, Bufferlevel: %d, Gain: %f", iSleepTime, iBufferLevel, iGain);
+ }
+ }
+ m_droppingStats.m_lastDecoderPts = iDecoderPts;
+
+ // subtract gains
+ while (!m_droppingStats.m_gain.empty() &&
+ iRenderPts >= m_droppingStats.m_gain.front().pts)
+ {
+ m_droppingStats.m_totalGain -= m_droppingStats.m_gain.front().gain;
+ m_droppingStats.m_gain.pop_front();
+ }
+
+ // calculate lateness
+ iLateness = iSleepTime + m_droppingStats.m_totalGain;
+ if (iLateness < 0 && m_speed)
+ {
+ if (bNewFrame)
+ m_droppingStats.m_lateFrames++;
+
+ // if lateness is smaller than frametime, we observe this state
+ // for 10 cycles
+ if (m_droppingStats.m_lateFrames > 10 || iLateness < -2/m_fFrameRate)
+ {
+ // is frame allowed to skip
+ if (m_iNrOfPicturesNotToSkip <= 0)
+ {
+ if (bNewFrame || m_droppingStats.m_dropRequests < 5)
+ {
+ result |= EOS_VERYLATE;
+ }
+ m_droppingStats.m_dropRequests++;
+ }
+ }
+ }
+ else
+ {
+ m_droppingStats.m_dropRequests = 0;
+ m_droppingStats.m_lateFrames = 0;
+ }
+ m_droppingStats.m_lastRenderPts = iRenderPts;
+ return result;
+}
+
+void CDroppingStats::Reset()
+{
+ m_gain.clear();
+ m_totalGain = 0;
+ m_lastDecoderPts = 0;
+ m_lastRenderPts = 0;
+ m_lateFrames = 0;
+ m_dropRequests = 0;
+}
+
+void CDroppingStats::AddOutputDropGain(double pts, double frametime)
+{
+ CDroppingStats::CGain gain;
+ gain.gain = frametime;
+ gain.pts = pts;
+ m_gain.push_back(gain);
+ m_totalGain += frametime;
+}
diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.h b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
index f8ad541..186e271 100644
--- a/xbmc/cores/dvdplayer/DVDPlayerVideo.h
+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
@@ -36,6 +36,25 @@ class CDVDOverlayCodecCC;
#define VIDEO_PICTURE_QUEUE_SIZE 1
+class CDroppingStats
+{
+public:
+ void Reset();
+ void AddOutputDropGain(double pts, double frametime);
+ struct CGain
+ {
+ double gain;
+ double pts;
+ };
+ std::deque<CGain> m_gain;
+ double m_totalGain;
+ double m_lastDecoderPts;
+ double m_lastRenderPts;
+ unsigned int m_lateFrames;
+ unsigned int m_dropRequests;
+};
+
+
class CDVDPlayerVideo : public CThread
{
public:
@@ -104,6 +123,7 @@ class CDVDPlayerVideo : public CThread
#define EOS_ABORT 1
#define EOS_DROPPED 2
#define EOS_VERYLATE 4
+#define EOS_BUFFER_LEVEL 8
void AutoCrop(DVDVideoPicture* pPicture);
void AutoCrop(DVDVideoPicture *pPicture, RECT &crop);
@@ -129,6 +149,7 @@ class CDVDPlayerVideo : public CThread
void ResetFrameRateCalc();
void CalcFrameRate();
+ int CalcDropRequirement(double pts);
double m_fFrameRate; //framerate of the video currently playing
bool m_bCalcFrameRate; //if we should calculate the framerate from the timestamps
@@ -182,5 +203,7 @@ class CDVDPlayerVideo : public CThread
CPullupCorrection m_pullupCorrection;
std::list<DVDMessageListItem> m_packets;
+
+ CDroppingStats m_droppingStats;
};
--
2.0.4
From 5d8f78e836ee606751959e2704a1eec93a84717f Mon Sep 17 00:00:00 2001
From: xbmc <fernetmenta@online.de>
Date: Sun, 2 Sep 2012 16:05:21 +0200
Subject: [PATCH 085/106] video player: present correct pts to user for a/v
sync (after buffering in renderer)
---
xbmc/cores/dvdplayer/DVDPlayerVideo.cpp | 16 ++++++++++++++++
xbmc/cores/dvdplayer/DVDPlayerVideo.h | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
index 181ff74..01757cc 100644
--- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
@@ -1463,6 +1463,22 @@ void CDVDPlayerVideo::ResetFrameRateCalc()
g_advancedSettings.m_videoFpsDetect == 0;
}
+double CDVDPlayerVideo::GetCurrentPts()
+{
+ double iSleepTime, iRenderPts;
+ int iBufferLevel;
+
+ // get render stats
+ g_renderManager.GetStats(iSleepTime, iRenderPts, iBufferLevel);
+
+ if( m_stalled )
+ iRenderPts = DVD_NOPTS_VALUE;
+ else
+ iRenderPts = iRenderPts - max(0.0, iSleepTime);
+
+ return iRenderPts;
+}
+
#define MAXFRAMERATEDIFF 0.01
#define MAXFRAMESERR 1000
diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.h b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
index 186e271..59c7f09 100644
--- a/xbmc/cores/dvdplayer/DVDPlayerVideo.h
+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
@@ -100,7 +100,7 @@ class CDVDPlayerVideo : public CThread
bool InitializedOutputDevice();
- double GetCurrentPts() { return m_iCurrentPts; }
+ double GetCurrentPts();
int GetPullupCorrection() { return m_pullupCorrection.GetPatternLength(); }
double GetOutputDelay(); /* returns the expected delay, from that a packet is put in queue */
--
2.0.4
From 499e5f43bb88de9d5f343e43cfb1e1fbb3c868d6 Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com>
Date: Mon, 12 May 2014 23:06:43 +0100