|
resonance 1.0.1
|
Reader that plays a chunked movie file into per-track handlers. More...
#include <amovieset.h>

Classes | |
| struct | Track |
| Track description a MOVT chunk supplies, 0x2c bytes. More... | |
| struct | PaletteChunk |
| Payload of a PALL chunk. More... | |
| struct | FrameChunk |
| Payload of a FRAM chunk, followed by the frame's pixels. More... | |
| struct | BlankChunk |
| Payload of a BLAK chunk. More... | |
Public Types | |
| typedef void(* | ChunkHandler) (AMovieChunkHdr *pHeader, void *pPayload, void *pData) |
| Receiver of one track's chunks. | |
Public Member Functions | |
| AMovieSet (const char *pszPath, int bStreaming, int *pnError) | |
| Open a movie file and queue its first read. | |
| ~AMovieSet () | |
| Close the file, cancel an outstanding read, and destroy the ring buffer. | |
| void | Update (int nTick, int nReadSize) |
| Consume every chunk due by nTick and top up a streaming buffer. | |
| int | ParseHeader (char *pBuffer, int nBytes) |
| Parse the MOVS and MOVT chunks at the start of a loaded buffer and set up the ring buffer. | |
| void | AssignHandler (int nTrackId, ChunkHandler pfnHandler, void *pData) |
| Install the handler for one track. | |
| int | RequestRead (int nBytes) |
| Queue the next streaming read of up to nBytes, as Update() does inline. | |
Public Attributes | |
| int | mFile |
| ACircBuff * | mCircBuff |
| char * | mBuffer |
| int | mBufferSize |
| unsigned char | mReserved10 [8] |
| Track | mTracks [kTrackCount] |
| ChunkHandler | mHandlers [kTrackCount] |
| void * | mHandlerData [kTrackCount] |
| int | mLoopTicks |
| Tick offset the LOOP chunks have accumulated. | |
| int | mLastTick |
| int | mDataStart |
| unsigned char | mReserved364 [4] |
| int | mStreaming |
| int | mLoaded |
| int | mFileLength |
| int | mFileOffset |
| int | mAsyncHandle |
| int | mSoundHold |
Static Public Attributes | |
| static constexpr int | kTrackCount = 16 |
| Tracks a file can describe, and so the handler slots. | |
Reader that plays a chunked movie file into per-track handlers.
The class emits no RTTI. Its name comes from the debugging symbols of the North American demo release. The object is 0x380 bytes and is allocated untagged. Rnd::Movie plays its .mmv file through one, and the synth plays its sound bank movie through another (0x00462908).
A file begins with a MOVS chunk and one MOVT chunk per track, which ParseHeader() copies into mTracks. The chunks that follow carry palettes (PALL), frames (FRAM), blank frames (BLAK), loop points (LOOP), and three kinds of sound data (SNDH, SNDB, SNDP). Update() consumes every chunk whose tick has arrived and passes it to the handler AssignHandler() installed for its track. A whole file is read into memory at once. A streaming file is read in 0x8000 byte and smaller requests into an ACircBuff in the zone "movieStreamBuff", which must be at least 512K.
| typedef void(* Rnd::AMovieSet::ChunkHandler) (AMovieChunkHdr *pHeader, void *pPayload, void *pData) |
Receiver of one track's chunks.
| pHeader | The chunk. |
| pPayload | The bytes after the header. |
| pData | The value installed with the handler. |
| Rnd::AMovieSet::AMovieSet | ( | const char * | pszPath, |
| int | bStreaming, | ||
| int * | pnError ) |
Open a movie file and queue its first read.
A whole file is read into a zone block of its uncompressed length through AsyncLoadFileByPath(). A streaming file takes every byte the zone "movieStreamBuff" has left, which a missing zone, a zone under 512K, or a file that will not open reports as fatal, and its first 0x8000 bytes are read through AsyncSubmitRequest(). Either way the stream joins the list MovieAsyncCallback searches, and ParseHeader() runs once the read completes.
| pszPath | The file. |
| bStreaming | Non-zero to stream rather than read the whole file. |
| pnError | Receives 0, -1 when the buffer could not be allocated, or -2 when the file has no length. |
| Rnd::AMovieSet::~AMovieSet | ( | ) |
Close the file, cancel an outstanding read, and destroy the ring buffer.
The data buffer belongs to its zone and is not released, and a stream destroyed before its header arrives stays in the pending list.
| void Rnd::AMovieSet::Update | ( | int | nTick, |
| int | nReadSize ) |
Consume every chunk due by nTick and top up a streaming buffer.
A tick earlier than the last one rewinds to the first data chunk. At most one video chunk and one sound chunk are dispatched per call, and a LOOP chunk advances mLoopTicks by its length. A LOOP chunk in a whole file moves the read pointer back to the start. An unknown chunk type is fatal.
| nTick | The current tick. |
| nReadSize | The largest streaming read to queue. |
| int Rnd::AMovieSet::ParseHeader | ( | char * | pBuffer, |
| int | nBytes ) |
Parse the MOVS and MOVT chunks at the start of a loaded buffer and set up the ring buffer.
MovieAsyncCallback::Done() calls it once the first read completes.
| pBuffer | The buffer the read filled. |
| nBytes | The bytes read. |
| void Rnd::AMovieSet::AssignHandler | ( | int | nTrackId, |
| ChunkHandler | pfnHandler, | ||
| void * | pData ) |
Install the handler for one track.
| nTrackId | The track. |
| pfnHandler | The handler, or null to drop the track's chunks. |
| pData | The value passed to the handler. |
| int Rnd::AMovieSet::RequestRead | ( | int | nBytes | ) |
Queue the next streaming read of up to nBytes, as Update() does inline.
Nothing is queued unless the stream is streaming and loaded, no other streaming read is outstanding, and more than 0x400 bytes are free. A read that would pass the end of the file is shortened, or the file is rewound to the first data chunk when nothing is left. The out-of-line copy has no caller, and its name is inferred.
| nBytes | The largest read to queue. |
|
staticconstexpr |
Tracks a file can describe, and so the handler slots.
| int Rnd::AMovieSet::mFile |
The open file, or -1. +0x00
| ACircBuff* Rnd::AMovieSet::mCircBuff |
Ring buffer over the chunk data. +0x04
| char* Rnd::AMovieSet::mBuffer |
Start of the loaded data, headers included. +0x08
| int Rnd::AMovieSet::mBufferSize |
Size of the data buffer. +0x0c
| unsigned char Rnd::AMovieSet::mReserved10[8] |
| Track Rnd::AMovieSet::mTracks[kTrackCount] |
Track descriptions. +0x18
| ChunkHandler Rnd::AMovieSet::mHandlers[kTrackCount] |
Handler per track. +0x2d8
| void* Rnd::AMovieSet::mHandlerData[kTrackCount] |
Value passed to each handler. +0x318
| int Rnd::AMovieSet::mLoopTicks |
Tick offset the LOOP chunks have accumulated.
Public because the synth's sound bank starter at 0x00462908 sets it to the song tick directly. +0x358
| int Rnd::AMovieSet::mLastTick |
Tick of the previous Update(). +0x35c
| int Rnd::AMovieSet::mDataStart |
File offset of the first data chunk. +0x360
| unsigned char Rnd::AMovieSet::mReserved364[4] |
| int Rnd::AMovieSet::mStreaming |
Non-zero when the file is streamed. +0x368
| int Rnd::AMovieSet::mLoaded |
Non-zero once ParseHeader() has succeeded. +0x36c
| int Rnd::AMovieSet::mFileLength |
Uncompressed length of the file. +0x370
| int Rnd::AMovieSet::mFileOffset |
File offset the next streaming read starts at. +0x374
| int Rnd::AMovieSet::mAsyncHandle |
Identifier of the outstanding read, or 0. +0x378
| int Rnd::AMovieSet::mSoundHold |
Updates left before another sound chunk may play. +0x37c