2012-11-12 19:53:16 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Simulation of the hardware video/audio decoders.
|
|
|
|
// The idea is high level emulation where we simply use FFMPEG.
|
2012-11-13 17:05:26 +00:00
|
|
|
// TODO: Actually hook up to ffmpeg.
|
2012-11-12 19:53:16 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// An approximation of what the interface will look like. Similar to JPCSP's.
|
|
|
|
|
|
|
|
#include "../../Globals.h"
|
2012-11-13 17:05:26 +00:00
|
|
|
#include "../HLE/sceMpeg.h"
|
2013-02-04 04:31:46 +00:00
|
|
|
#include "ChunkFile.h"
|
2013-06-01 17:29:22 +00:00
|
|
|
#include "Core/HW/MpegDemux.h"
|
2012-11-12 19:53:16 +00:00
|
|
|
|
2013-06-02 07:29:45 +00:00
|
|
|
struct SwsContext;
|
2013-06-02 08:37:16 +00:00
|
|
|
struct AVFrame;
|
2013-06-07 06:18:12 +00:00
|
|
|
struct AVIOContext;
|
2013-06-08 07:22:59 +00:00
|
|
|
struct AVFormatContext;
|
|
|
|
struct AVCodecContext;
|
2013-06-02 07:29:45 +00:00
|
|
|
|
2013-06-09 20:21:36 +00:00
|
|
|
inline s64 getMpegTimeStamp(u8* buf) {
|
|
|
|
return (s64)buf[5] | ((s64)buf[4] << 8) | ((s64)buf[3] << 16) | ((s64)buf[2] << 24)
|
|
|
|
| ((s64)buf[1] << 32) | ((s64)buf[0] << 36);
|
|
|
|
}
|
|
|
|
|
2012-11-12 19:53:16 +00:00
|
|
|
class MediaEngine
|
|
|
|
{
|
|
|
|
public:
|
2013-06-01 17:29:22 +00:00
|
|
|
MediaEngine();
|
|
|
|
~MediaEngine();
|
|
|
|
|
|
|
|
void closeMedia();
|
2013-06-15 19:27:14 +00:00
|
|
|
bool loadStream(u8* buffer, int readSize, int RingbufferSize);
|
2013-06-11 11:04:14 +00:00
|
|
|
// open the mpeg context
|
|
|
|
bool openContext();
|
2013-06-01 21:53:07 +00:00
|
|
|
// Returns number of packets actually added.
|
|
|
|
int addStreamData(u8* buffer, int addSize);
|
2013-06-11 11:04:14 +00:00
|
|
|
|
|
|
|
void setVideoStream(int streamNum) { m_videoStream = streamNum; }
|
|
|
|
void setAudioStream(int streamNum) { m_audioStream = streamNum; }
|
|
|
|
|
2013-06-15 19:27:14 +00:00
|
|
|
int getRemainSize();
|
2013-06-01 17:29:22 +00:00
|
|
|
|
2013-06-02 07:29:45 +00:00
|
|
|
bool stepVideo(int videoPixelMode);
|
2013-06-08 11:50:36 +00:00
|
|
|
int writeVideoImage(u8* buffer, int frameWidth = 512, int videoPixelMode = 3);
|
|
|
|
int writeVideoImageWithRange(u8* buffer, int frameWidth, int videoPixelMode,
|
2013-06-01 17:29:22 +00:00
|
|
|
int xpos, int ypos, int width, int height);
|
|
|
|
int getAudioSamples(u8* buffer);
|
|
|
|
|
|
|
|
bool setVideoDim(int width = 0, int height = 0);
|
|
|
|
s64 getVideoTimeStamp();
|
|
|
|
s64 getAudioTimeStamp();
|
|
|
|
s64 getLastTimeStamp();
|
2012-11-13 17:05:26 +00:00
|
|
|
|
2013-06-08 09:45:58 +00:00
|
|
|
bool IsVideoEnd() { return m_isVideoEnd; }
|
2013-07-02 09:20:46 +00:00
|
|
|
bool IsNoAudioData() { return m_noAudioData; }
|
2013-06-04 12:25:03 +00:00
|
|
|
|
2013-06-17 20:08:48 +00:00
|
|
|
void DoState(PointerWrap &p);
|
2012-12-29 11:19:13 +00:00
|
|
|
|
2012-11-12 19:53:16 +00:00
|
|
|
private:
|
2013-06-02 07:29:45 +00:00
|
|
|
void updateSwsFormat(int videoPixelMode);
|
2013-06-01 17:29:22 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-06-08 07:22:59 +00:00
|
|
|
AVFormatContext *m_pFormatCtx;
|
|
|
|
AVCodecContext *m_pCodecCtx;
|
2013-06-02 08:37:16 +00:00
|
|
|
AVFrame *m_pFrame;
|
|
|
|
AVFrame *m_pFrameRGB;
|
2013-06-07 06:18:12 +00:00
|
|
|
AVIOContext *m_pIOContext;
|
2013-06-02 07:29:45 +00:00
|
|
|
SwsContext *m_sws_ctx;
|
2013-06-02 09:45:20 +00:00
|
|
|
int m_sws_fmt;
|
2013-06-02 07:29:45 +00:00
|
|
|
u8 *m_buffer;
|
2013-06-11 11:04:14 +00:00
|
|
|
int m_videoStream;
|
|
|
|
int m_audioStream;
|
2013-06-01 17:29:22 +00:00
|
|
|
|
|
|
|
int m_desWidth;
|
|
|
|
int m_desHeight;
|
2013-06-23 07:36:28 +00:00
|
|
|
int m_decodingsize;
|
2013-06-01 17:29:22 +00:00
|
|
|
int m_bufSize;
|
|
|
|
s64 m_videopts;
|
2013-06-15 19:27:14 +00:00
|
|
|
Atrac3plus_Decoder::BufferQueue *m_pdata;
|
2013-06-01 17:29:22 +00:00
|
|
|
|
|
|
|
MpegDemux *m_demux;
|
|
|
|
void* m_audioContext;
|
|
|
|
s64 m_audiopts;
|
2013-06-04 12:25:03 +00:00
|
|
|
|
2013-06-15 19:27:14 +00:00
|
|
|
s64 m_firstTimeStamp;
|
|
|
|
s64 m_lastTimeStamp;
|
|
|
|
|
2013-06-04 12:25:03 +00:00
|
|
|
bool m_isVideoEnd;
|
2013-07-02 09:20:46 +00:00
|
|
|
bool m_noAudioData;
|
2013-06-17 20:08:48 +00:00
|
|
|
|
|
|
|
int m_ringbuffersize;
|
|
|
|
u8 m_mpegheader[0x10000];
|
|
|
|
int m_mpegheaderReadPos;
|
2012-11-12 19:53:16 +00:00
|
|
|
};
|