Etterna 0.74.4
Loading...
Searching...
No Matches
MovieTexture_Generic.h
1#ifndef RAGE_MOVIE_TEXTURE_GENERIC_H
2#define RAGE_MOVIE_TEXTURE_GENERIC_H
3
4#include "MovieTexture.h"
5
6class FFMpeg_Helper;
7struct RageSurface;
8struct RageTextureLock;
10class Sprite;
11
12enum MovieDecoderPixelFormatYCbCr
13{
14 PixelFormatYCbCr_YUYV422,
15 NUM_PixelFormatYCbCr,
16 PixelFormatYCbCr_Invalid
17};
18
20{
21 public:
22 virtual ~MovieDecoder() {}
23
24 virtual std::string Open(const std::string& sFile) = 0;
25 virtual void Close() = 0;
26 virtual void Rewind() = 0;
27
28 /*
29 * Decode a frame. Return 1 on success, 0 on EOF, -1 on fatal error.
30 *
31 * If we're lagging behind the video, fTargetTime will be the target
32 * timestamp. The decoder may skip frames to catch up. On return,
33 * the current timestamp must be <= fTargetTime.
34 *
35 * Otherwise, fTargetTime will be -1, and the next frame should be
36 * decoded; skip frames only if necessary to recover from errors.
37 */
38 virtual int DecodeFrame(float fTargetTime) = 0;
39
40 /*
41 * Get the currently-decoded frame.
42 */
43 virtual void GetFrame(RageSurface* pOut) = 0;
44
45 /* Return the dimensions of the image, in pixels (before aspect ratio
46 * adjustments). */
47 virtual int GetWidth() const = 0;
48 virtual int GetHeight() const = 0;
49
50 /* Return the aspect ratio of a pixel in the image. Usually 1. */
51 virtual float GetSourceAspectRatio() const { return 1.0f; }
52
53 /*
54 * Create a surface acceptable to pass to GetFrame. This should be
55 * a surface which is realtime-compatible with DISPLAY, and should
56 * attempt to obey bPreferHighColor. The given size will usually be
57 * the next power of two higher than GetWidth/GetHeight, but on systems
58 * with limited texture resolution, may be smaller.
59 *
60 * If DISPLAY supports the EffectMode_YUYV422 blend mode, this may be
61 * a packed-pixel YUV surface. UYVY maps to RGBA, respectively. If
62 * used, set fmtout.
63 */
64 virtual RageSurface* CreateCompatibleSurface(
65 int iTextureWidth,
66 int iTextureHeight,
67 bool bPreferHighColor,
68 MovieDecoderPixelFormatYCbCr& fmtout) = 0;
69
70 /* The following functions return information about the current frame,
71 * decoded by the last successful call to GetFrame, and will never be
72 * called before that. */
73
74 /* Get the timestamp, in seconds, when the current frame should be
75 * displayed. The first frame will always be 0. */
76 virtual float GetTimestamp() const = 0;
77
78 /* Get the duration, in seconds, to display the current frame. */
79 virtual float GetFrameDuration() const = 0;
80};
81
83{
84 public:
86 virtual ~MovieTexture_Generic();
87 std::string Init();
88
89 /* only called by RageTextureManager::InvalidateTextures */
90 void Invalidate();
91
92 virtual void Reload();
93
94 virtual void SetPosition(float fSeconds);
95 virtual void DecodeSeconds(float fSeconds);
96 virtual void SetPlaybackRate(float fRate) { m_fRate = fRate; }
97 void SetLooping(bool bLooping = true) { m_bLoop = bLooping; }
98 intptr_t GetTexHandle() const;
99
100 static EffectMode GetEffectMode(MovieDecoderPixelFormatYCbCr fmt);
101
102 private:
103 MovieDecoder* m_pDecoder;
104
105 float m_fRate;
106 enum
107 {
108 FRAME_NONE, /* no frame available; call GetFrame to get one */
109 FRAME_DECODED /* frame decoded; waiting until it's time to display it */
110 } m_ImageWaiting;
111 bool m_bLoop;
112 bool m_bWantRewind;
113
114 intptr_t m_uTexHandle;
115 RageTextureRenderTarget* m_pRenderTarget;
116 RageTexture* m_pTextureIntermediate;
117 Sprite* m_pSprite;
118
119 RageTextureLock* m_pTextureLock;
120
121 /* The time the movie is actually at: */
122 float m_fClock;
123 bool m_bFrameSkipMode;
124
125 void UpdateFrame();
126
127 void CreateTexture();
128 void DestroyTexture();
129
130 bool DecodeFrame();
131 float CheckFrameTime();
132};
133
134#endif
Definition MovieTexture_Generic.h:20
Definition MovieTexture_Generic.h:83
Definition MovieTexture.h:12
Definition RageTextureRenderTarget.h:12
Definition RageTexture.h:14
A bitmap Actor that animates and moves around.
Definition Sprite.h:13
Definition RageSurface.h:90
Definition RageTextureID.h:12
Definition RageDisplay.h:256