|
persona-3-dual
A DS demake of Persona 3
|
Streams video frames and multiplexed QOA audio from a single .vid file. More...
#include <VideoController.hpp>

Public Member Functions | |
| void | init (std::string iFileName, ae::q20_12_t iFps, ViewState iNextState) |
| Opens and prepares a video stream. | |
| ViewState | update () |
| Advances playback: pumps audio, displays the next due frame and reads ahead. | |
| void | cleanup () |
| Stops playback and releases the file, audio stream and frame buffer. | |
| void | stopInternalAudio () |
| Shuts down and frees the internal audio player. | |
Static Public Member Functions | |
| static void | create () |
| Creates the singleton instance if it does not exist. | |
| static void | destroy () |
| Destroys the singleton instance and releases all video resources. | |
| static VideoController * | getInstance () |
Private Member Functions | |
| VideoController ()=default | |
| ~VideoController () | |
| bool | refillBuffer () |
| Reads one audio chunk (into the audio ring) and one video frame. | |
| void | pumpAudio () |
| Feeds the maxmod stream; a no-op when no audio is active. | |
| void | setEOF () |
| Marks end of file and tells the audio player no more data will arrive. | |
| int | clockFrame () const |
| Computes the frame that should be on screen now. | |
Private Attributes | |
| ViewState | nextState = ViewState::DEFAULT |
| State returned when playback ends. | |
| uint8_t | fpsInt = 24 |
| Frame rate in whole fps (from the header or fallback). | |
| FILE * | videoFile = nullptr |
| Open .vid file handle. | |
| bool | fileEOF = false |
| True once the file (or a read) is exhausted. | |
| int64_t | currentFrame = 0 |
| Index of the next frame to display. | |
| int8_t | bg = -1 |
| Background id returned by bgInit(). | |
| uint8_t * | ramBuffer = nullptr |
| Ring buffer holding FRAMES_TO_BUFFER decoded frames. | |
| uint16_t | readIndex = 0 |
| Ring slot of the next frame to display. | |
| uint16_t | writeIndex = 0 |
| Ring slot the next frame is read into. | |
| uint16_t | framesAvailable = 0 |
| Number of frames currently buffered. | |
| uint16_t | frameW = 0 |
| Frame width in pixels. | |
| uint16_t | frameH = 0 |
| Frame height in pixels. | |
| uint8_t | bpp = 0 |
| Bytes per pixel (1 = 8-bit paletted, 2 = 16-bit). | |
| uint32_t | frameSize = 0 |
| Size of one frame in bytes. | |
| uint32_t | bufferSize = 0 |
| Total size of the frame ring buffer in bytes. | |
| VideoAudio * | aud = nullptr |
| Internal audio player; non-null while audio is active. | |
| bool | haveChunkHeader = false |
| True if the current chunk's audio size has been read. | |
| uint32_t | pendingAudioSize = 0 |
| Audio bytes still to be read for the current chunk. | |
| uint32_t | silentVblanks = 0 |
| Pacing clock (vblanks) used when there is no audio. | |
Static Private Attributes | |
| static VideoController * | instance = nullptr |
| Singleton instance. | |
Streams video frames and multiplexed QOA audio from a single .vid file.
Audio is decoded and streamed by a private QOA/maxmod player inside this class (AudioManager is not used for playback). The audio clock drives frame pacing; files without audio use a vblank clock instead.
The controller is a singleton and owns its file handle, frame buffer and audio player.
Definition at line 51 of file VideoController.hpp.
|
privatedefault |

|
inlineprivate |
| void VideoController::cleanup | ( | ) |
Stops playback and releases the file, audio stream and frame buffer.
Definition at line 609 of file VideoController.cpp.


|
private |
Computes the frame that should be on screen now.
Definition at line 322 of file VideoController.cpp.

|
static |
Creates the singleton instance if it does not exist.
Definition at line 269 of file VideoController.cpp.


|
static |
Destroys the singleton instance and releases all video resources.
Definition at line 277 of file VideoController.cpp.
|
static |
Definition at line 286 of file VideoController.cpp.

| void VideoController::init | ( | std::string | iFileName, |
| ae::q20_12_t | iFps, | ||
| ViewState | iNextState ) |
Opens and prepares a video stream.
Reads the .vid header, configures the display background, allocates the frame buffer, starts the internal audio player (if the file has audio) and prefills the buffers. Any previous playback is released first.
| iFileName | Video filename relative to the data video directory. |
| iFps | Fallback frame rate when the file has no header. |
| iNextState | View state returned by update() after playback completes. |
Definition at line 331 of file VideoController.cpp.

|
private |
Feeds the maxmod stream; a no-op when no audio is active.
Definition at line 295 of file VideoController.cpp.

|
private |
Reads one audio chunk (into the audio ring) and one video frame.
Stops without reading if the frame buffer or audio ring is full.
Definition at line 475 of file VideoController.cpp.


|
private |
Marks end of file and tells the audio player no more data will arrive.
Definition at line 313 of file VideoController.cpp.

| void VideoController::stopInternalAudio | ( | ) |
Shuts down and frees the internal audio player.
Definition at line 303 of file VideoController.cpp.

| ViewState VideoController::update | ( | ) |
Advances playback: pumps audio, displays the next due frame and reads ahead.
Definition at line 550 of file VideoController.cpp.

|
private |
Internal audio player; non-null while audio is active.
Definition at line 117 of file VideoController.hpp.
|
private |
Background id returned by bgInit().
Definition at line 102 of file VideoController.hpp.
|
private |
Bytes per pixel (1 = 8-bit paletted, 2 = 16-bit).
Definition at line 112 of file VideoController.hpp.
|
private |
Total size of the frame ring buffer in bytes.
Definition at line 114 of file VideoController.hpp.
|
private |
Index of the next frame to display.
Definition at line 101 of file VideoController.hpp.
|
private |
True once the file (or a read) is exhausted.
Definition at line 100 of file VideoController.hpp.
|
private |
Frame rate in whole fps (from the header or fallback).
Definition at line 97 of file VideoController.hpp.
|
private |
Frame height in pixels.
Definition at line 111 of file VideoController.hpp.
|
private |
Number of frames currently buffered.
Definition at line 107 of file VideoController.hpp.
|
private |
Size of one frame in bytes.
Definition at line 113 of file VideoController.hpp.
|
private |
Frame width in pixels.
Definition at line 110 of file VideoController.hpp.
|
private |
True if the current chunk's audio size has been read.
Definition at line 118 of file VideoController.hpp.
|
staticprivate |
Singleton instance.
Definition at line 94 of file VideoController.hpp.
|
private |
State returned when playback ends.
Definition at line 96 of file VideoController.hpp.
|
private |
Audio bytes still to be read for the current chunk.
Definition at line 119 of file VideoController.hpp.
|
private |
Ring buffer holding FRAMES_TO_BUFFER decoded frames.
Definition at line 104 of file VideoController.hpp.
|
private |
Ring slot of the next frame to display.
Definition at line 105 of file VideoController.hpp.
|
private |
Pacing clock (vblanks) used when there is no audio.
Definition at line 120 of file VideoController.hpp.
|
private |
Open .vid file handle.
Definition at line 99 of file VideoController.hpp.
|
private |
Ring slot the next frame is read into.
Definition at line 106 of file VideoController.hpp.