summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Reufer <thomas@reufer.ch>2014-09-02 15:13:38 +0200
committerThomas Reufer <thomas@reufer.ch>2014-09-02 15:13:38 +0200
commitc35a921aa031103e36dd0fb75aefd94178eba681 (patch)
treee4ce37913f61538e647277b8536d425315c4d6eb
parentf5c5c262feec54ffaea1f1525ba274e267637bd3 (diff)
downloadvdr-plugin-rpihddevice-c35a921aa031103e36dd0fb75aefd94178eba681.tar.gz
vdr-plugin-rpihddevice-c35a921aa031103e36dd0fb75aefd94178eba681.tar.bz2
skip packets with invalid payload offset in PlayVideo() and PlayAudio()
-rw-r--r--HISTORY1
-rw-r--r--omxdevice.c47
-rw-r--r--omxdevice.h2
3 files changed, 29 insertions, 21 deletions
diff --git a/HISTORY b/HISTORY
index 805f299..854d19b 100644
--- a/HISTORY
+++ b/HISTORY
@@ -10,6 +10,7 @@ VDR Plugin 'rpihddevice' Revision History
- reworked setup parameter handling
- implemented proper command queue for OVG-OSD
- fixed:
+ - skip packets with invalid payload offset in PlayVideo() and PlayAudio()
- play multiple video PES packets sequentially in StillPicture()
- updated parameter when setting clock latency target according omxplayer
- code clean up based on cppcheck's results (thanks to Rolf Ahrenberg)
diff --git a/omxdevice.c b/omxdevice.c
index c32ea9e..88d6639 100644
--- a/omxdevice.c
+++ b/omxdevice.c
@@ -244,19 +244,20 @@ int cOmxDevice::PlayAudio(const uchar *Data, int Length, uchar Id)
if (Transferring() && pts)
UpdateLatency(pts);
- int ret = m_audio->WriteData(Data + PesPayloadOffset(Data),
+ // ignore packets with invalid payload offset
+ int ret = (Length - PesPayloadOffset(Data) < 0) ||
+ m_audio->WriteData(Data + PesPayloadOffset(Data),
Length - PesPayloadOffset(Data), pts) ? Length : 0;
m_mutex->Unlock();
return ret;
}
-int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool singleFrame)
+int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool EndOfStream)
{
m_mutex->Lock();
int ret = Length;
- int64_t pts = PesHasPts(Data) ? PesGetPts(Data) : 0;
cVideoCodec::eCodec codec = ParseVideoCodec(Data, Length);
// video restart after Clear() with same codec
@@ -292,30 +293,39 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool singleFrame)
m_omx->StartClock(m_hasVideo, m_hasAudio);
}
- // keep track of direction in case of trick speed
- if (m_trickRequest && pts)
+ if (m_hasVideo)
{
- if (m_videoPts)
- PtsTracker(PtsDiff(m_videoPts, pts));
+ int64_t pts = PesHasPts(Data) ? PesGetPts(Data) : 0;
- m_videoPts = pts;
- }
+ // keep track of direction in case of trick speed
+ if (m_trickRequest && pts)
+ {
+ if (m_videoPts)
+ PtsTracker(PtsDiff(m_videoPts, pts));
+
+ m_videoPts = pts;
+ }
- if (m_hasVideo)
- {
if (!m_hasAudio && Transferring() && pts)
UpdateLatency(pts);
- while (Length)
+ // skip PES header, proceed with payload towards OMX
+ Length -= PesPayloadOffset(Data);
+ Data += PesPayloadOffset(Data);
+
+ while (Length > 0)
{
OMX_BUFFERHEADERTYPE *buf = m_omx->GetVideoBuffer(pts);
if (buf)
{
- buf->nFilledLen = PesLength(Data) - PesPayloadOffset(Data);
- memcpy(buf->pBuffer, Data + PesPayloadOffset(Data),
- PesLength(Data) - PesPayloadOffset(Data));
+ buf->nFilledLen = buf->nAllocLen < (unsigned)Length ?
+ buf->nAllocLen : Length;
+
+ memcpy(buf->pBuffer, Data, buf->nFilledLen);
+ Length -= buf->nFilledLen;
+ Data += buf->nFilledLen;
- if (singleFrame && Length == PesLength(Data))
+ if (EndOfStream && !Length)
buf->nFlags |= OMX_BUFFERFLAG_EOS;
if (!m_omx->EmptyVideoBuffer(buf))
@@ -330,10 +340,7 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool singleFrame)
ret = 0;
break;
}
-
- Length -= PesLength(Data);
- Data += PesLength(Data);
- pts = PesHasPts(Data) ? PesGetPts(Data) : 0;
+ pts = 0;
}
}
diff --git a/omxdevice.h b/omxdevice.h
index ea5f68f..62b1971 100644
--- a/omxdevice.h
+++ b/omxdevice.h
@@ -45,7 +45,7 @@ public:
virtual int PlayVideo(const uchar *Data, int Length)
{ return PlayVideo(Data, Length, false); }
- virtual int PlayVideo(const uchar *Data, int Length, bool singleFrame);
+ virtual int PlayVideo(const uchar *Data, int Length, bool EndOfStream);
virtual int64_t GetSTC(void);