diff options
author | Nevcairiel <Nevcairiel@users.sourceforge.net> | 2011-06-04 02:08:10 +0400 |
---|---|---|
committer | Nevcairiel <Nevcairiel@users.sourceforge.net> | 2011-06-04 02:08:10 +0400 |
commit | 86ef35b2b6e984d87376c2d38affa7706c290d52 (patch) | |
tree | 77089619965f8a208dcdebdfce580a2c65ea5304 /src/DSUtil/H264Nalu.cpp | |
parent | 0637b772bff4eaa532de975b5f58fbf667e5dce5 (diff) |
Fix H264Nalu parser class
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3177 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/DSUtil/H264Nalu.cpp')
-rw-r--r-- | src/DSUtil/H264Nalu.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/DSUtil/H264Nalu.cpp b/src/DSUtil/H264Nalu.cpp index 0d54c59fc..927795da7 100644 --- a/src/DSUtil/H264Nalu.cpp +++ b/src/DSUtil/H264Nalu.cpp @@ -35,9 +35,9 @@ void CH264Nalu::SetBuffer(BYTE* pBuffer, int nSize, int nNALSize) m_nNALDataPos = 0;
}
-bool CH264Nalu::MoveToNextStartcode()
+bool CH264Nalu::MoveToNextAnnexBStartcode()
{
- int nBuffEnd = (m_nNextRTP > 0) ? min (m_nNextRTP, m_nSize-4) : m_nSize-4;
+ int nBuffEnd = m_nSize - 4;
for (int i=m_nCurPos; i<nBuffEnd; i++) {
if ((*((DWORD*)(m_pBuffer+i)) & 0x00FFFFFF) == 0x00010000) {
@@ -47,10 +47,16 @@ bool CH264Nalu::MoveToNextStartcode() }
}
- if ((m_nNALSize != 0) && (m_nNextRTP < m_nSize)) {
- m_nCurPos = m_nNextRTP;
- return true;
- }
+ m_nCurPos = m_nSize;
+ return false;
+}
+
+bool CH264Nalu::MoveToNextRTPStartcode()
+{
+ if (m_nNextRTP < m_nSize) {
+ m_nCurPos = m_nNextRTP;
+ return true;
+ }
m_nCurPos = m_nSize;
return false;
@@ -71,7 +77,7 @@ bool CH264Nalu::ReadNext() nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
}
m_nNextRTP += nTemp + m_nNALSize;
- MoveToNextStartcode();
+ MoveToNextRTPStartcode();
} else {
// Remove trailing bits
while (m_pBuffer[m_nCurPos]==0x00 && ((*((DWORD*)(m_pBuffer+m_nCurPos)) & 0x00FFFFFF) != 0x00010000)) {
@@ -82,7 +88,7 @@ bool CH264Nalu::ReadNext() m_nNALStartPos = m_nCurPos;
m_nCurPos += 3;
m_nNALDataPos = m_nCurPos;
- MoveToNextStartcode();
+ MoveToNextAnnexBStartcode();
}
forbidden_bit = (m_pBuffer[m_nNALDataPos]>>7) & 1;
|