Commit 8deaf4c0 authored by Andrew de Quincey's avatar Andrew de Quincey

Fixed file looping on certain files (e.g. Dolby Canyon)

parent ab50a4b1
......@@ -2,7 +2,7 @@
* ps2ts.cpp: MPEG1 and MPEG2 PS to MPEG2 TS converter
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: ps2ts.cpp,v 1.11 2003/08/20 13:49:49 adq Exp $
* $Id: ps2ts.cpp,v 1.12 2003/08/20 21:06:06 adq Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -165,13 +165,12 @@ template <class Reader, class TsProvider>
C_TsPacket* C_Ps2Ts<Reader, TsProvider>::GetPacket(bool bPreparsing)
{
int iRc = NO_ERR;
bool bStreamLooped = false;
// if there's nothing left in the buffer. we need to fill it
if (m_cPendingTS.Size() == 0) {
// keep looping until the buffer is full
while((m_cPendingTS.Size() < m_iMaxBufferedTs) && (!bStreamLooped)) {
while(m_cPendingTS.Size() < m_iMaxBufferedTs) {
// If we're not already sending PSI, check if we need to send it again
if ((!m_bSendPSI) && (!bPreparsing)) {
......@@ -234,7 +233,7 @@ template <class Reader, class TsProvider>
} else {
// we've finished sending PSI for this time
m_bSendPSI = false;
}
}
}
// not sending PSI => grab some REAL data packets
......@@ -262,12 +261,11 @@ template <class Reader, class TsProvider>
break;
}
// OK, synch with the stream again
// OK, synch with the stream again. Loop will continue sending packets
iRc = Synch();
m_bSendPSI = true;
m_bGenPat = true;
m_bGenPmt = true;
bStreamLooped = true;
}
break;
}
......@@ -275,18 +273,18 @@ template <class Reader, class TsProvider>
// OK, was there really a problem?
if (iRc) {
m_iStatus = iRc;
break;
break;
}
}
// if we're preparsing, exit as soon as we have one packet
if (bPreparsing && m_cPendingTS.Size()) {
break;
break;
}
}
}
}
// Return the first packet
if(m_cPendingTS.Size() > 0)
return m_cPendingTS.Remove(0);
......@@ -538,7 +536,7 @@ template <class Reader, class TsProvider>
// calculate how much data we can send
int readSize = TS_PACKET_LEN - iPos;
// If there is not enough data to completely fill the TS packet,
// add stuffing bytes
if((m_iDataLen+iPesPos) < readSize) {
......@@ -612,7 +610,7 @@ template <class Reader, class TsProvider>
if (!m_iDataLen) {
m_bInMiddleOfPES = false;
}
// OK, return the status. This will be either NO_ERR or END_OF_STREAM
return iRc;
}
......@@ -643,9 +641,8 @@ template <class Reader, class TsProvider>
// try to read the data
iRc = m_pReader->Read(buf, length);
if (iRc == FILE_EOF) return END_OF_STREAM;
if (iRc < 0) return iRc;
// check for lack of data
if (m_pReader->EndOfStream()) return END_OF_STREAM;
// success
......@@ -667,12 +664,11 @@ template <class Reader, class TsProvider>
// read a bit
iRc = m_pReader->Read(buf, skipSize);
if (iRc == FILE_EOF) return END_OF_STREAM;
if (iRc < 0) return iRc;
if (m_pReader->EndOfStream()) return END_OF_STREAM;
}
// check for lack of data
if (m_pReader->EndOfStream()) return END_OF_STREAM;
// success
return 0;
}
......@@ -685,11 +681,12 @@ template <class Reader, class TsProvider>
// try to read it
iRc = m_pReader->Read(buf, 2);
if (iRc == FILE_EOF) return END_OF_STREAM;
if (iRc < 0) return iRc;
*lengthDest = U16_AT(buf);
// check for lack of data
if (m_pReader->EndOfStream()) return END_OF_STREAM;
// OK, extract it
*lengthDest = U16_AT(buf);
// success
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment