summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Reufer <thomas@reufer.ch>2015-06-22 16:21:50 +0200
committerThomas Reufer <thomas@reufer.ch>2015-06-22 16:21:50 +0200
commitaa5f04260d0d2ecac5070a38122b3446898993e4 (patch)
tree58d2ecffdf363680a12a175096d055b0d819a62c
parentb5421aa946c8bfe9aec220bb48cf79c19e1c11e6 (diff)
downloadvdr-plugin-rpihddevice-aa5f04260d0d2ecac5070a38122b3446898993e4.tar.gz
vdr-plugin-rpihddevice-aa5f04260d0d2ecac5070a38122b3446898993e4.tar.bz2
treat zero as valid PTS value
-rw-r--r--HISTORY1
-rw-r--r--omx.c33
-rw-r--r--omx.h6
-rw-r--r--omxdevice.c60
-rw-r--r--omxdevice.h6
5 files changed, 58 insertions, 48 deletions
diff --git a/HISTORY b/HISTORY
index cc8c4be..e8f6b4d 100644
--- a/HISTORY
+++ b/HISTORY
@@ -2,6 +2,7 @@ VDR Plugin 'rpihddevice' Revision History
-----------------------------------------
- fixed:
+ - treat zero as valid PTS value
- perform save / restore region direct on pixmaps for accelerated OSDs
- wait for the OVG thread to be ready when creating an accelerated OSD
- set field sync when output interlaced material at interlaced display mode
diff --git a/omx.c b/omx.c
index eb04028..02a9142 100644
--- a/omx.c
+++ b/omx.c
@@ -606,7 +606,7 @@ uint64_t cOmx::TicksToPts(OMX_TICKS &ticks)
int64_t cOmx::GetSTC(void)
{
- int64_t stc = -1;
+ int64_t stc = OMX_INVALID_PTS;
OMX_TIME_CONFIG_TIMESTAMPTYPE timestamp;
OMX_INIT_STRUCT(timestamp);
timestamp.nPortIndex = OMX_ALL;
@@ -1217,7 +1217,7 @@ void cOmx::SetDisplayRegion(int x, int y, int width, int height)
ELOG("failed to set display region!");
}
-OMX_BUFFERHEADERTYPE* cOmx::GetAudioBuffer(uint64_t pts)
+OMX_BUFFERHEADERTYPE* cOmx::GetAudioBuffer(int64_t pts)
{
Lock();
OMX_BUFFERHEADERTYPE* buf = 0;
@@ -1241,19 +1241,20 @@ OMX_BUFFERHEADERTYPE* cOmx::GetAudioBuffer(uint64_t pts)
buf->nOffset = 0;
buf->nFlags = 0;
- if (m_setAudioStartTime)
- buf->nFlags |= OMX_BUFFERFLAG_STARTTIME;
- else if (!pts)
+ if (pts == OMX_INVALID_PTS)
buf->nFlags |= OMX_BUFFERFLAG_TIME_UNKNOWN;
-
+ else if (m_setAudioStartTime)
+ {
+ buf->nFlags |= OMX_BUFFERFLAG_STARTTIME;
+ m_setAudioStartTime = false;
+ }
cOmx::PtsToTicks(pts, buf->nTimeStamp);
- m_setAudioStartTime = false;
}
Unlock();
return buf;
}
-OMX_BUFFERHEADERTYPE* cOmx::GetVideoBuffer(uint64_t pts)
+OMX_BUFFERHEADERTYPE* cOmx::GetVideoBuffer(int64_t pts)
{
Lock();
OMX_BUFFERHEADERTYPE* buf = 0;
@@ -1277,17 +1278,19 @@ OMX_BUFFERHEADERTYPE* cOmx::GetVideoBuffer(uint64_t pts)
buf->nOffset = 0;
buf->nFlags = 0;
- if (m_setVideoStartTime)
- buf->nFlags |= OMX_BUFFERFLAG_STARTTIME;
- else if (!pts)
+ if (pts == OMX_INVALID_PTS)
buf->nFlags |= OMX_BUFFERFLAG_TIME_UNKNOWN;
-
+ else if (m_setVideoStartTime)
+ {
+ buf->nFlags |= OMX_BUFFERFLAG_STARTTIME;
+ m_setVideoStartTime = false;
+ }
if (m_setVideoDiscontinuity)
+ {
buf->nFlags |= OMX_BUFFERFLAG_DISCONTINUITY;
-
+ m_setVideoDiscontinuity = false;
+ }
cOmx::PtsToTicks(pts, buf->nTimeStamp);
- m_setVideoStartTime = false;
- m_setVideoDiscontinuity = false;
}
Unlock();
return buf;
diff --git a/omx.h b/omx.h
index 6988ad4..98ece21 100644
--- a/omx.h
+++ b/omx.h
@@ -15,6 +15,8 @@ extern "C"
#include "ilclient.h"
}
+#define OMX_INVALID_PTS -1
+
class cOmxEvents;
class cOmx : public cThread
@@ -84,8 +86,8 @@ public:
void SetDisplayMode(bool letterbox, bool noaspect);
void SetDisplayRegion(int x, int y, int width, int height);
- OMX_BUFFERHEADERTYPE* GetAudioBuffer(uint64_t pts = 0);
- OMX_BUFFERHEADERTYPE* GetVideoBuffer(uint64_t pts = 0);
+ OMX_BUFFERHEADERTYPE* GetAudioBuffer(int64_t pts = OMX_INVALID_PTS);
+ OMX_BUFFERHEADERTYPE* GetVideoBuffer(int64_t pts = OMX_INVALID_PTS);
bool PollVideo(void);
diff --git a/omxdevice.c b/omxdevice.c
index 5ad3672..80fa0f3 100644
--- a/omxdevice.c
+++ b/omxdevice.c
@@ -259,30 +259,31 @@ int cOmxDevice::PlayAudio(const uchar *Data, int Length, uchar Id)
m_mutex->Lock();
int ret = Length;
- int64_t pts = PesHasPts(Data) ? PesGetPts(Data) : 0;
+ int64_t pts = PesHasPts(Data) ? PesGetPts(Data) : OMX_INVALID_PTS;
- if (!m_hasAudio)
+ if (pts != OMX_INVALID_PTS)
{
- m_hasAudio = true;
- m_omx->SetClockReference(cOmx::eClockRefAudio);
-
- if (!m_hasVideo)
- {
- DBG("audio first");
- m_omx->SetClockScale(s_playbackSpeeds[m_direction][m_playbackSpeed]);
- m_omx->StartClock(m_hasVideo, m_hasAudio);
- m_audioPts = PTS_START_OFFSET + pts;
- m_playMode = pmAudioOnly;
- }
- else
+ if (!m_hasAudio)
{
- m_audioPts = m_videoPts + PtsDiff(m_videoPts & MAX33BIT, pts);
- m_playMode = pmAudioVideo;
+ m_hasAudio = true;
+ m_omx->SetClockReference(cOmx::eClockRefAudio);
+
+ if (!m_hasVideo)
+ {
+ DBG("audio first");
+ m_omx->SetClockScale(
+ s_playbackSpeeds[m_direction][m_playbackSpeed]);
+ m_omx->StartClock(m_hasVideo, m_hasAudio);
+ m_audioPts = PTS_START_OFFSET + pts;
+ m_playMode = pmAudioOnly;
+ }
+ else
+ {
+ m_audioPts = m_videoPts + PtsDiff(m_videoPts & MAX33BIT, pts);
+ m_playMode = pmAudioVideo;
+ }
}
- }
- if (pts)
- {
int64_t ptsDiff = PtsDiff(m_audioPts & MAX33BIT, pts);
m_audioPts += ptsDiff;
@@ -306,7 +307,8 @@ int cOmxDevice::PlayAudio(const uchar *Data, int Length, uchar Id)
data += 4;
length -= 4;
}
- if (!m_audio->WriteData(data, length, pts ? m_audioPts : 0))
+ if (!m_audio->WriteData(data, length,
+ pts != OMX_INVALID_PTS ? m_audioPts : OMX_INVALID_PTS))
ret = 0;
}
m_mutex->Unlock();
@@ -328,9 +330,10 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool EndOfFrame)
m_mutex->Lock();
int ret = Length;
- int64_t pts = PesHasPts(Data) ? PesGetPts(Data) : 0;
+ int64_t pts = PesHasPts(Data) ? PesGetPts(Data) : OMX_INVALID_PTS;
- if (!m_hasVideo && pts && m_videoCodec == cVideoCodec::eInvalid)
+ if (!m_hasVideo && pts != OMX_INVALID_PTS &&
+ m_videoCodec == cVideoCodec::eInvalid)
{
m_videoCodec = ParseVideoCodec(Data + PesPayloadOffset(Data),
Length - PesPayloadOffset(Data));
@@ -347,7 +350,8 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool EndOfFrame)
}
}
- if (!m_hasVideo && pts && cRpiSetup::IsVideoCodecSupported(m_videoCodec))
+ if (!m_hasVideo && pts != OMX_INVALID_PTS &&
+ cRpiSetup::IsVideoCodecSupported(m_videoCodec))
{
m_hasVideo = true;
if (!m_hasAudio)
@@ -368,7 +372,7 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool EndOfFrame)
if (m_hasVideo)
{
- if (pts)
+ if (pts != OMX_INVALID_PTS)
{
int64_t ptsDiff = PtsDiff(m_videoPts & MAX33BIT, pts);
m_videoPts += ptsDiff;
@@ -384,8 +388,8 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool EndOfFrame)
while (Length > 0)
{
- if (OMX_BUFFERHEADERTYPE *buf =
- m_omx->GetVideoBuffer(pts ? m_videoPts : 0))
+ if (OMX_BUFFERHEADERTYPE *buf = m_omx->GetVideoBuffer(
+ pts != OMX_INVALID_PTS ? m_videoPts : OMX_INVALID_PTS))
{
buf->nFilledLen = buf->nAllocLen < (unsigned)Length ?
buf->nAllocLen : Length;
@@ -409,7 +413,7 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool EndOfFrame)
ret = 0;
break;
}
- pts = 0;
+ pts = OMX_INVALID_PTS;
}
}
m_mutex->Unlock();
@@ -436,7 +440,7 @@ bool cOmxDevice::SubmitEOS(void)
int64_t cOmxDevice::GetSTC(void)
{
int64_t stc = m_omx->GetSTC();
- if (stc)
+ if (stc != OMX_INVALID_PTS)
m_lastStc = stc;
return m_lastStc & MAX33BIT;
}
diff --git a/omxdevice.h b/omxdevice.h
index e57137c..9343a69 100644
--- a/omxdevice.h
+++ b/omxdevice.h
@@ -177,10 +177,10 @@ private:
int m_playDirection;
int m_trickRequest;
- uint64_t m_audioPts;
- uint64_t m_videoPts;
+ int64_t m_audioPts;
+ int64_t m_videoPts;
- int64_t m_lastStc;
+ int64_t m_lastStc;
};
#endif