MovieTexture_FFmpeg: move class defs to header file
No-op. Should make it a little easier to find things in the FFmpeg driver.
This commit is contained in:
@@ -9,129 +9,6 @@
|
|||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
namespace avcodec
|
|
||||||
{
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libswscale/swscale.h>
|
|
||||||
#include <libavutil/pixdesc.h>
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/avcodec.lib")
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/avformat.lib")
|
|
||||||
#if defined(USE_MODERN_FFMPEG)
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/swscale.lib")
|
|
||||||
#endif
|
|
||||||
#endif // _MSC_VER
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const int sws_flags = SWS_BICUBIC; // XXX: Reasonable default?
|
|
||||||
|
|
||||||
static struct AVPixelFormat_t
|
|
||||||
{
|
|
||||||
int bpp;
|
|
||||||
uint32_t masks[4];
|
|
||||||
avcodec::PixelFormat pf;
|
|
||||||
bool bHighColor;
|
|
||||||
bool bByteSwapOnLittleEndian;
|
|
||||||
MovieDecoderPixelFormatYCbCr YUV;
|
|
||||||
} AVPixelFormats[] = {
|
|
||||||
{
|
|
||||||
32,
|
|
||||||
{ 0xFF000000,
|
|
||||||
0x00FF0000,
|
|
||||||
0x0000FF00,
|
|
||||||
0x000000FF },
|
|
||||||
avcodec::PIX_FMT_YUYV422,
|
|
||||||
false, /* N/A */
|
|
||||||
true,
|
|
||||||
PixelFormatYCbCr_YUYV422,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
32,
|
|
||||||
{ 0x0000FF00,
|
|
||||||
0x00FF0000,
|
|
||||||
0xFF000000,
|
|
||||||
0x000000FF },
|
|
||||||
avcodec::PIX_FMT_BGRA,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
PixelFormatYCbCr_Invalid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
32,
|
|
||||||
{ 0x00FF0000,
|
|
||||||
0x0000FF00,
|
|
||||||
0x000000FF,
|
|
||||||
0xFF000000 },
|
|
||||||
avcodec::PIX_FMT_ARGB,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
PixelFormatYCbCr_Invalid,
|
|
||||||
},
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
32,
|
|
||||||
{ 0x000000FF,
|
|
||||||
0x0000FF00,
|
|
||||||
0x00FF0000,
|
|
||||||
0xFF000000 },
|
|
||||||
avcodec::PIX_FMT_ABGR,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
PixelFormatYCbCr_Invalid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
32,
|
|
||||||
{ 0xFF000000,
|
|
||||||
0x00FF0000,
|
|
||||||
0x0000FF00,
|
|
||||||
0x000000FF },
|
|
||||||
avcodec::PIX_FMT_RGBA,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
PixelFormatYCbCr_Invalid,
|
|
||||||
}, */
|
|
||||||
{
|
|
||||||
24,
|
|
||||||
{ 0xFF0000,
|
|
||||||
0x00FF00,
|
|
||||||
0x0000FF,
|
|
||||||
0x000000 },
|
|
||||||
avcodec::PIX_FMT_RGB24,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
PixelFormatYCbCr_Invalid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
24,
|
|
||||||
{ 0x0000FF,
|
|
||||||
0x00FF00,
|
|
||||||
0xFF0000,
|
|
||||||
0x000000 },
|
|
||||||
avcodec::PIX_FMT_BGR24,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
PixelFormatYCbCr_Invalid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
16,
|
|
||||||
{ 0x7C00,
|
|
||||||
0x03E0,
|
|
||||||
0x001F,
|
|
||||||
0x0000 },
|
|
||||||
avcodec::PIX_FMT_RGB555,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
PixelFormatYCbCr_Invalid,
|
|
||||||
},
|
|
||||||
{ 0, { 0,0,0,0 }, avcodec::PIX_FMT_NB, true, false, PixelFormatYCbCr_Invalid }
|
|
||||||
};
|
|
||||||
|
|
||||||
static void FixLilEndian()
|
static void FixLilEndian()
|
||||||
{
|
{
|
||||||
#if defined(ENDIAN_LITTLE)
|
#if defined(ENDIAN_LITTLE)
|
||||||
@@ -196,15 +73,6 @@ static int FindCompatibleAVFormat( bool bHighColor )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MovieTexture_FFMpeg: public MovieTexture_Generic
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MovieTexture_FFMpeg( RageTextureID ID );
|
|
||||||
|
|
||||||
static void RegisterProtocols();
|
|
||||||
static RageSurface *AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt, MovieDecoderPixelFormatYCbCr &fmtout );
|
|
||||||
};
|
|
||||||
|
|
||||||
RageSurface *RageMovieTextureDriver_FFMpeg::AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt, MovieDecoderPixelFormatYCbCr &fmtout )
|
RageSurface *RageMovieTextureDriver_FFMpeg::AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt, MovieDecoderPixelFormatYCbCr &fmtout )
|
||||||
{
|
{
|
||||||
FixLilEndian();
|
FixLilEndian();
|
||||||
@@ -237,59 +105,6 @@ RageSurface *RageMovieTextureDriver_FFMpeg::AVCodecCreateCompatibleSurface( int
|
|||||||
pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
|
pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
|
||||||
}
|
}
|
||||||
|
|
||||||
class MovieDecoder_FFMpeg: public MovieDecoder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MovieDecoder_FFMpeg();
|
|
||||||
~MovieDecoder_FFMpeg();
|
|
||||||
|
|
||||||
RString Open( RString sFile );
|
|
||||||
void Close();
|
|
||||||
void Rewind();
|
|
||||||
|
|
||||||
void GetFrame( RageSurface *pOut );
|
|
||||||
int DecodeFrame( float fTargetTime );
|
|
||||||
|
|
||||||
int GetWidth() const { return m_pStream->codec->width; }
|
|
||||||
int GetHeight() const { return m_pStream->codec->height; }
|
|
||||||
|
|
||||||
RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, MovieDecoderPixelFormatYCbCr &fmtout );
|
|
||||||
|
|
||||||
float GetTimestamp() const;
|
|
||||||
float GetFrameDuration() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Init();
|
|
||||||
RString OpenCodec();
|
|
||||||
int ReadPacket();
|
|
||||||
int DecodePacket( float fTargetTime );
|
|
||||||
|
|
||||||
avcodec::AVStream *m_pStream;
|
|
||||||
avcodec::AVFrame m_Frame;
|
|
||||||
avcodec::PixelFormat m_AVTexfmt; /* PixelFormat of output surface */
|
|
||||||
avcodec::SwsContext *m_swsctx;
|
|
||||||
|
|
||||||
float m_fPTS;
|
|
||||||
avcodec::AVFormatContext *m_fctx;
|
|
||||||
bool m_bGetNextTimestamp;
|
|
||||||
float m_fTimestamp;
|
|
||||||
float m_fTimestampOffset;
|
|
||||||
float m_fLastFrameDelay;
|
|
||||||
int m_iFrameNumber;
|
|
||||||
|
|
||||||
unsigned char *m_buffer;
|
|
||||||
avcodec::AVIOContext *m_avioContext;
|
|
||||||
|
|
||||||
avcodec::AVPacket m_Packet;
|
|
||||||
int m_iCurrentPacketOffset;
|
|
||||||
float m_fLastFrame;
|
|
||||||
|
|
||||||
/* 0 = no EOF
|
|
||||||
* 1 = EOF from ReadPacket
|
|
||||||
* 2 = EOF from ReadPacket and DecodePacket */
|
|
||||||
int m_iEOF;
|
|
||||||
};
|
|
||||||
|
|
||||||
MovieDecoder_FFMpeg::MovieDecoder_FFMpeg()
|
MovieDecoder_FFMpeg::MovieDecoder_FFMpeg()
|
||||||
{
|
{
|
||||||
FixLilEndian();
|
FixLilEndian();
|
||||||
@@ -589,8 +404,6 @@ void MovieTexture_FFMpeg::RegisterProtocols()
|
|||||||
avcodec::av_register_all();
|
avcodec::av_register_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STEPMANIA_FFMPEG_BUFFER_SIZE 4096
|
|
||||||
|
|
||||||
static int AVIORageFile_ReadPacket( void *opaque, uint8_t *buf, int buf_size )
|
static int AVIORageFile_ReadPacket( void *opaque, uint8_t *buf, int buf_size )
|
||||||
{
|
{
|
||||||
RageFile *f = (RageFile *)opaque;
|
RageFile *f = (RageFile *)opaque;
|
||||||
|
|||||||
@@ -6,6 +6,28 @@
|
|||||||
#include "MovieTexture_Generic.h"
|
#include "MovieTexture_Generic.h"
|
||||||
struct RageSurface;
|
struct RageSurface;
|
||||||
|
|
||||||
|
namespace avcodec
|
||||||
|
{
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
#include <libswscale/swscale.h>
|
||||||
|
#include <libavutil/pixdesc.h>
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define STEPMANIA_FFMPEG_BUFFER_SIZE 4096
|
||||||
|
static const int sws_flags = SWS_BICUBIC; // XXX: Reasonable default?
|
||||||
|
|
||||||
|
class MovieTexture_FFMpeg: public MovieTexture_Generic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MovieTexture_FFMpeg( RageTextureID ID );
|
||||||
|
|
||||||
|
static void RegisterProtocols();
|
||||||
|
static RageSurface *AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt, MovieDecoderPixelFormatYCbCr &fmtout );
|
||||||
|
};
|
||||||
|
|
||||||
class RageMovieTextureDriver_FFMpeg: public RageMovieTextureDriver
|
class RageMovieTextureDriver_FFMpeg: public RageMovieTextureDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -13,6 +35,160 @@ public:
|
|||||||
static RageSurface *AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt, MovieDecoderPixelFormatYCbCr &fmtout );
|
static RageSurface *AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt, MovieDecoderPixelFormatYCbCr &fmtout );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MovieDecoder_FFMpeg: public MovieDecoder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MovieDecoder_FFMpeg();
|
||||||
|
~MovieDecoder_FFMpeg();
|
||||||
|
|
||||||
|
RString Open( RString sFile );
|
||||||
|
void Close();
|
||||||
|
void Rewind();
|
||||||
|
|
||||||
|
void GetFrame( RageSurface *pOut );
|
||||||
|
int DecodeFrame( float fTargetTime );
|
||||||
|
|
||||||
|
int GetWidth() const { return m_pStream->codec->width; }
|
||||||
|
int GetHeight() const { return m_pStream->codec->height; }
|
||||||
|
|
||||||
|
RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, MovieDecoderPixelFormatYCbCr &fmtout );
|
||||||
|
|
||||||
|
float GetTimestamp() const;
|
||||||
|
float GetFrameDuration() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Init();
|
||||||
|
RString OpenCodec();
|
||||||
|
int ReadPacket();
|
||||||
|
int DecodePacket( float fTargetTime );
|
||||||
|
|
||||||
|
avcodec::AVStream *m_pStream;
|
||||||
|
avcodec::AVFrame m_Frame;
|
||||||
|
avcodec::PixelFormat m_AVTexfmt; /* PixelFormat of output surface */
|
||||||
|
avcodec::SwsContext *m_swsctx;
|
||||||
|
|
||||||
|
float m_fPTS;
|
||||||
|
avcodec::AVFormatContext *m_fctx;
|
||||||
|
bool m_bGetNextTimestamp;
|
||||||
|
float m_fTimestamp;
|
||||||
|
float m_fTimestampOffset;
|
||||||
|
float m_fLastFrameDelay;
|
||||||
|
int m_iFrameNumber;
|
||||||
|
|
||||||
|
unsigned char *m_buffer;
|
||||||
|
avcodec::AVIOContext *m_avioContext;
|
||||||
|
|
||||||
|
avcodec::AVPacket m_Packet;
|
||||||
|
int m_iCurrentPacketOffset;
|
||||||
|
float m_fLastFrame;
|
||||||
|
|
||||||
|
/* 0 = no EOF
|
||||||
|
* 1 = EOF from ReadPacket
|
||||||
|
* 2 = EOF from ReadPacket and DecodePacket */
|
||||||
|
int m_iEOF;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct AVPixelFormat_t
|
||||||
|
{
|
||||||
|
int bpp;
|
||||||
|
uint32_t masks[4];
|
||||||
|
avcodec::PixelFormat pf;
|
||||||
|
bool bHighColor;
|
||||||
|
bool bByteSwapOnLittleEndian;
|
||||||
|
MovieDecoderPixelFormatYCbCr YUV;
|
||||||
|
} AVPixelFormats[] = {
|
||||||
|
{
|
||||||
|
32,
|
||||||
|
{ 0xFF000000,
|
||||||
|
0x00FF0000,
|
||||||
|
0x0000FF00,
|
||||||
|
0x000000FF },
|
||||||
|
avcodec::PIX_FMT_YUYV422,
|
||||||
|
false, /* N/A */
|
||||||
|
true,
|
||||||
|
PixelFormatYCbCr_YUYV422,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
32,
|
||||||
|
{ 0x0000FF00,
|
||||||
|
0x00FF0000,
|
||||||
|
0xFF000000,
|
||||||
|
0x000000FF },
|
||||||
|
avcodec::PIX_FMT_BGRA,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
PixelFormatYCbCr_Invalid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
32,
|
||||||
|
{ 0x00FF0000,
|
||||||
|
0x0000FF00,
|
||||||
|
0x000000FF,
|
||||||
|
0xFF000000 },
|
||||||
|
avcodec::PIX_FMT_ARGB,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
PixelFormatYCbCr_Invalid,
|
||||||
|
},
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
32,
|
||||||
|
{ 0x000000FF,
|
||||||
|
0x0000FF00,
|
||||||
|
0x00FF0000,
|
||||||
|
0xFF000000 },
|
||||||
|
avcodec::PIX_FMT_ABGR,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
PixelFormatYCbCr_Invalid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
32,
|
||||||
|
{ 0xFF000000,
|
||||||
|
0x00FF0000,
|
||||||
|
0x0000FF00,
|
||||||
|
0x000000FF },
|
||||||
|
avcodec::PIX_FMT_RGBA,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
PixelFormatYCbCr_Invalid,
|
||||||
|
}, */
|
||||||
|
{
|
||||||
|
24,
|
||||||
|
{ 0xFF0000,
|
||||||
|
0x00FF00,
|
||||||
|
0x0000FF,
|
||||||
|
0x000000 },
|
||||||
|
avcodec::PIX_FMT_RGB24,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
PixelFormatYCbCr_Invalid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
24,
|
||||||
|
{ 0x0000FF,
|
||||||
|
0x00FF00,
|
||||||
|
0xFF0000,
|
||||||
|
0x000000 },
|
||||||
|
avcodec::PIX_FMT_BGR24,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
PixelFormatYCbCr_Invalid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
16,
|
||||||
|
{ 0x7C00,
|
||||||
|
0x03E0,
|
||||||
|
0x001F,
|
||||||
|
0x0000 },
|
||||||
|
avcodec::PIX_FMT_RGB555,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
PixelFormatYCbCr_Invalid,
|
||||||
|
},
|
||||||
|
{ 0, { 0,0,0,0 }, avcodec::PIX_FMT_NB, true, false, PixelFormatYCbCr_Invalid }
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user