Bug fix for mpeg.

This commit is contained in:
oioitff 2013-06-18 13:10:24 +08:00
parent 7bde93d534
commit b1cc94b9bf
4 changed files with 12 additions and 9 deletions

View File

@ -307,6 +307,8 @@ int MediaEngine::addStreamData(u8* buffer, int addSize) {
#ifdef USE_FFMPEG
if (!m_pFormatCtx) {
m_pdata->get_front(m_mpegheader, sizeof(m_mpegheader));
int mpegoffset = bswap32(*(int*)(m_mpegheader + 8));
m_pdata->pop_front(0, mpegoffset);
openContext();
}
#endif // USE_FFMPEG

View File

@ -238,7 +238,7 @@ int MpegDemux::getNextaudioFrame(u8** buf, int *headerCode1, int *headerCode2)
audioPos = nextHeader;
} else
audioPos = gotsize;
m_audioStream.pop_front(m_audioFrame, audioPos);
m_audioStream.pop_front(0, audioPos);
*buf = m_audioFrame + 8;
if (headerCode1) *headerCode1 = Code1;
if (headerCode2) *headerCode2 = Code2;

View File

@ -18,7 +18,6 @@ public:
// return its framesize
int getNextaudioFrame(u8** buf, int *headerCode1, int *headerCode2);
int getFilePosition() { return m_index; }
private:
struct PesHeader {
long pts;
@ -53,7 +52,7 @@ private:
}
int readPesHeader(PesHeader &pesHeader, int length, int startCode);
int demuxStream(bool bdemux, int startCode, int channel);
public:
void DoState(PointerWrap &p) {
p.Do(m_index);
p.Do(m_len);

View File

@ -77,12 +77,14 @@ namespace Atrac3plus_Decoder {
int bytesgot = getQueueSize();
if (wantedsize < bytesgot)
bytesgot = wantedsize;
if (start + bytesgot <= bufQueueSize) {
memcpy(buf, bufQueue + start, bytesgot);
} else {
int size = bufQueueSize - start;
memcpy(buf, bufQueue + start, size);
memcpy(buf + size, bufQueue, bytesgot - size);
if (buf) {
if (start + bytesgot <= bufQueueSize) {
memcpy(buf, bufQueue + start, bytesgot);
} else {
int size = bufQueueSize - start;
memcpy(buf, bufQueue + start, size);
memcpy(buf + size, bufQueue, bytesgot - size);
}
}
start = (start + bytesgot) % bufQueueSize;
return bytesgot;