Files
itgmania212121/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.h
T

122 lines
3.6 KiB
C++
Raw Normal View History

2003-09-02 04:19:02 +00:00
#ifndef RAGEMOVIETEXTURE_FFMPEG_H
#define RAGEMOVIETEXTURE_FFMPEG_H
2003-08-29 04:34:10 +00:00
#include "MovieTexture.h"
#include "RageDisplay.h"
#include "RageTexture.h"
#include "RageThreads.h"
2004-04-02 23:00:29 +00:00
#include "RageTimer.h"
2003-08-29 04:34:10 +00:00
2003-09-02 19:30:20 +00:00
/* Fix a compile problem in gcc 3.2: */
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
#endif
class FFMpeg_Helper;
2003-08-29 04:34:10 +00:00
2003-09-02 04:01:01 +00:00
class MovieTexture_FFMpeg: public RageMovieTexture
2003-08-29 04:34:10 +00:00
{
public:
2003-09-02 04:01:01 +00:00
MovieTexture_FFMpeg( RageTextureID ID );
virtual ~MovieTexture_FFMpeg();
2004-11-30 21:17:13 +00:00
CString Init();
2003-08-29 04:34:10 +00:00
/* only called by RageTextureManager::InvalidateTextures */
void Invalidate() { m_uTexHandle = 0; }
void Update(float fDeltaTime);
virtual void Reload();
virtual void SetPosition( float fSeconds );
virtual void DecodeSeconds( float fSeconds );
2003-08-29 04:34:10 +00:00
virtual void SetPlaybackRate( float fRate ) { m_Rate=fRate; }
void SetLooping(bool looping=true) { m_bLoop = looping; }
2003-09-02 07:47:37 +00:00
unsigned GetTexHandle() const { return m_uTexHandle; }
2003-08-29 04:34:10 +00:00
static void RegisterProtocols();
2003-08-29 04:34:10 +00:00
private:
FFMpeg_Helper *decoder;
2003-08-29 04:34:10 +00:00
/* The time the movie is actually at: */
float m_Rate;
2004-04-04 00:39:23 +00:00
enum {
FRAME_NONE, /* no frame available; call GetFrame to get one */
FRAME_DECODED, /* frame decoded; call ConvertFrame */
FRAME_WAITING /* frame converted and waiting to be uploaded */
} m_ImageWaiting;
2003-08-29 04:34:10 +00:00
bool m_bLoop;
bool m_bWantRewind;
2004-04-02 23:15:29 +00:00
bool m_bThreaded;
2003-08-29 04:34:10 +00:00
/*
2003-09-02 07:47:37 +00:00
* Only the main thread can change m_State.
2003-08-29 04:34:10 +00:00
*
2003-09-02 07:47:37 +00:00
* DECODER_QUIT: The decoder thread is not running. We should only
2003-08-29 04:34:10 +00:00
* be in this state internally; when we return after a call, we should
* never be in this state. Start the thread before returning.
*
* PAUSE_DECODER: The decoder thread is idle.
*
* PLAYING: The decoder thread is running.
*/
enum State { DECODER_QUIT, DECODER_RUNNING } m_State;
2003-08-29 04:34:10 +00:00
unsigned m_uTexHandle;
2004-06-14 01:09:11 +00:00
RageSurface *m_img;
2003-09-02 07:47:37 +00:00
int m_AVTexfmt; /* AVPixelFormat_t of m_img */
2003-08-29 04:34:10 +00:00
2004-06-14 05:36:42 +00:00
RageSemaphore m_BufferFinished;
2003-08-29 04:34:10 +00:00
2004-04-02 23:00:29 +00:00
RageTimer m_Timer;
float m_Clock;
bool m_FrameSkipMode;
2003-09-02 04:01:01 +00:00
static int DecoderThread_start(void *p) { ((MovieTexture_FFMpeg *)(p))->DecoderThread(); return 0; }
2003-08-29 04:34:10 +00:00
void DecoderThread();
RageThread m_DecoderThread;
void ConvertFrame();
void UpdateFrame();
2004-11-30 21:17:13 +00:00
CString CreateDecoder();
2003-08-29 04:34:10 +00:00
void CreateTexture();
2003-09-02 06:08:02 +00:00
void DestroyDecoder();
void DestroyTexture();
2003-08-29 04:34:10 +00:00
void StartThread();
void StopThread();
2004-04-04 00:39:23 +00:00
bool DecodeFrame();
float CheckFrameTime();
void DiscardFrame();
2003-08-29 04:34:10 +00:00
};
#endif
2004-05-15 22:07:41 +00:00
/*
* (c) 2003-2004 Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/