mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Return a more accurate mpeg ringbuffer decode pos.
This commit is contained in:
parent
94cce219a8
commit
17907b204b
2 changed files with 13 additions and 6 deletions
|
@ -109,8 +109,8 @@ void MediaEngine::closeMedia() {
|
|||
av_free(m_pFrameRGB);
|
||||
if (m_pFrame)
|
||||
av_free(m_pFrame);
|
||||
if (m_pIOContext && ((AVIOContext*)m_pIOContext)->buffer)
|
||||
av_free(((AVIOContext*)m_pIOContext)->buffer);
|
||||
if (m_pIOContext && m_pIOContext->buffer)
|
||||
av_free(m_pIOContext->buffer);
|
||||
if (m_pIOContext)
|
||||
av_free(m_pIOContext);
|
||||
if (m_pCodecCtx)
|
||||
|
@ -183,8 +183,8 @@ bool MediaEngine::openContext() {
|
|||
|
||||
AVFormatContext *pFormatCtx = avformat_alloc_context();
|
||||
m_pFormatCtx = (void*)pFormatCtx;
|
||||
m_pIOContext = (void*)avio_alloc_context(tempbuf, m_bufSize, 0, (void*)this, _MpegReadbuffer, NULL, _MpegSeekbuffer);
|
||||
pFormatCtx->pb = (AVIOContext*)m_pIOContext;
|
||||
m_pIOContext = avio_alloc_context(tempbuf, m_bufSize, 0, (void*)this, _MpegReadbuffer, NULL, _MpegSeekbuffer);
|
||||
pFormatCtx->pb = m_pIOContext;
|
||||
|
||||
// Open video file
|
||||
if(avformat_open_input((AVFormatContext**)&m_pFormatCtx, NULL, NULL, NULL) != 0)
|
||||
|
@ -541,6 +541,12 @@ static int getNextHeaderPosition(u8* audioStream, int curpos, int limit, int fra
|
|||
return -1;
|
||||
}
|
||||
|
||||
int MediaEngine::getBufferedSize() {
|
||||
// m_decodePos is technically "decoderNextReadPos", we want what has actually been decoded.
|
||||
int buffer_left = m_pIOContext->buffer_size - (m_pIOContext->buf_ptr - m_pIOContext->buffer);
|
||||
return m_readSize - m_decodePos + buffer_left;
|
||||
}
|
||||
|
||||
int MediaEngine::getAudioSamples(u8* buffer) {
|
||||
if (!m_demux) {
|
||||
return 0;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
struct SwsContext;
|
||||
struct AVFrame;
|
||||
struct AVIOContext;
|
||||
|
||||
class MediaEngine
|
||||
{
|
||||
|
@ -45,7 +46,7 @@ public:
|
|||
// Returns number of packets actually added.
|
||||
int addStreamData(u8* buffer, int addSize);
|
||||
int getRemainSize() { return m_streamSize - m_readSize;}
|
||||
int getBufferedSize() { return m_readSize - m_decodePos; }
|
||||
int getBufferedSize();
|
||||
|
||||
bool stepVideo(int videoPixelMode);
|
||||
bool writeVideoImage(u8* buffer, int frameWidth = 512, int videoPixelMode = 3);
|
||||
|
@ -76,7 +77,7 @@ public:
|
|||
void *m_pCodecCtx;
|
||||
AVFrame *m_pFrame;
|
||||
AVFrame *m_pFrameRGB;
|
||||
void *m_pIOContext;
|
||||
AVIOContext *m_pIOContext;
|
||||
int m_videoStream;
|
||||
SwsContext *m_sws_ctx;
|
||||
int m_sws_fmt;
|
||||
|
|
Loading…
Add table
Reference in a new issue