Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
VideoModuleEntry.cpp File Reference

Emscripten module: MPEG-1 video decoder (pl_mpeg). More...

#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include "./VideoBindings.hpp"
#include "pl_mpeg.h"
Include dependency graph for VideoModuleEntry.cpp:

Go to the source code of this file.

Macros

#define PL_MPEG_IMPLEMENTATION

Functions

int es_video_open (uintptr_t dataPtr, uint32_t size)
uint32_t es_video_width (int handle)
uint32_t es_video_height (int handle)
double es_video_duration (int handle)
double es_video_framerate (int handle)
double es_video_time (int handle)
void es_video_set_loop (int handle, int loop)
int es_video_has_ended (int handle)
int es_video_advance (int handle, double dt)
int es_video_frame_rgba (int handle, uintptr_t outPtr, uint32_t outSize)
int es_video_seek (int handle, double time)
void es_video_close (int handle)

Detailed Description

Emscripten module: MPEG-1 video decoder (pl_mpeg).

The engine-owned software video decode path — a standalone wasm module (built like basis/spine) exposing a small C API over pl_mpeg. Every platform that runs the engine's wasm can run this, which is what makes it the guaranteed video backend on runtimes without a reliable native decoder (WeChat MiniGame, headless). Multi-instance: several videos may decode concurrently, each addressed by an integer handle.

Audio is decoded out-of-band (the cook demuxes the audio track for the engine's audio pipeline), so audio decoding is disabled per instance.

Definition in file VideoModuleEntry.cpp.

Macro Definition Documentation

◆ PL_MPEG_IMPLEMENTATION

#define PL_MPEG_IMPLEMENTATION

Definition at line 25 of file VideoModuleEntry.cpp.

Function Documentation

◆ es_video_advance()

int es_video_advance ( int handle,
double dt )

Advance the decode clock by dt seconds, decoding everything now due (MPEG-1 P/B frames need every frame decoded, so there is no skip). Returns 1 if a new video frame is pending conversion.

Definition at line 166 of file VideoModuleEntry.cpp.

◆ es_video_close()

void es_video_close ( int handle)

Release the instance (frees the source bytes). Safe on a stale handle.

Definition at line 223 of file VideoModuleEntry.cpp.

◆ es_video_duration()

double es_video_duration ( int handle)

Definition at line 133 of file VideoModuleEntry.cpp.

◆ es_video_frame_rgba()

int es_video_frame_rgba ( int handle,
uintptr_t outPtr,
uint32_t outSize )

Convert the latest decoded frame into out as bottom-first RGBA rows — the orientation the engine's flipY-off texture upload samples upright. outSize must be at least width*height*4. outPtr is an offset the caller wrote — wasm linear memory on the web, the host arena on a device — so the pixels land where the caller reads them. Returns 1 and clears the new-frame flag on success.

Definition at line 183 of file VideoModuleEntry.cpp.

◆ es_video_framerate()

double es_video_framerate ( int handle)

Definition at line 138 of file VideoModuleEntry.cpp.

◆ es_video_has_ended()

int es_video_has_ended ( int handle)

Definition at line 156 of file VideoModuleEntry.cpp.

◆ es_video_height()

uint32_t es_video_height ( int handle)

Definition at line 128 of file VideoModuleEntry.cpp.

◆ es_video_open()

int es_video_open ( uintptr_t dataPtr,
uint32_t size )

Open an MPEG-PS / MPEG-1 stream from dataPtr (size bytes in the caller's heap). The bytes are COPIED into memory this module owns, so the caller keeps and frees its own buffer: ownership must not cross the boundary, because the two sides do not necessarily share an allocator. They do in the wasm build — one emscripten heap — and they do not in a native app, where the caller writes into the host's arena (host/heap.hpp) and this module's free is libc's. Returns a handle >= 1, or 0.

Definition at line 85 of file VideoModuleEntry.cpp.

◆ es_video_seek()

int es_video_seek ( int handle,
double time )

Exact-seek to time seconds. Decodes forward from the previous intra frame, leaving the target frame pending as a new frame. Returns 1 on success.

Definition at line 206 of file VideoModuleEntry.cpp.

◆ es_video_set_loop()

void es_video_set_loop ( int handle,
int loop )

With looping on, the stream rewinds seamlessly and never reports ended.

Definition at line 151 of file VideoModuleEntry.cpp.

◆ es_video_time()

double es_video_time ( int handle)

Playhead in seconds (wraps on loop).

Definition at line 144 of file VideoModuleEntry.cpp.

◆ es_video_width()

uint32_t es_video_width ( int handle)

Definition at line 123 of file VideoModuleEntry.cpp.