Skip to content

Commit

Permalink
Read only the mpeg header when reading packets.
Browse files Browse the repository at this point in the history
When trying to convince FFmpeg to read only the header, this was allowed
to get longer.  But we only really need the actual header here, and that
can prevent FFmpeg mis-parsing later packets.
  • Loading branch information
unknownbrackets committed Sep 25, 2016
1 parent 246f3aa commit 209500a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Core/HW/MediaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,12 @@ int MediaEngine::addStreamData(const u8 *buffer, int addSize) {
#ifdef USE_FFMPEG
if (!m_pFormatCtx && m_pdata->getQueueSize() >= 2048) {
m_mpegheaderSize = m_pdata->get_front(m_mpegheader, sizeof(m_mpegheader));
m_pdata->pop_front(0, m_mpegheaderSize);
openContext();
int streamOffset = (int)(*(s32_be *)(m_mpegheader + 8));
if (streamOffset <= m_mpegheaderSize) {
m_mpegheaderSize = streamOffset;
m_pdata->pop_front(0, m_mpegheaderSize);
openContext();
}
}
#endif // USE_FFMPEG

Expand Down

0 comments on commit 209500a

Please sign in to comment.