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

The MPEG-1 decoder's entry points, declared once for both platforms. More...

#include <cstdint>
Include dependency graph for VideoBindings.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int es_video_open (uintptr_t dataPtr, uint32_t size)
void es_video_close (int handle)
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)

Detailed Description

The MPEG-1 decoder's entry points, declared once for both platforms.

The engine owns its video decode (pl_mpeg) rather than depending on a platform's media stack, which is what makes a cooked .esv play the same way everywhere. On the web it links as a wasm side module; a native app compiles the same TU into the host binary and reaches it through the QuickJS wrappers EHT generates from these declarations.

Bulk data crosses as an offset into the caller's heap (wasm linear memory on the web, the host arena on a device): the source bytes in, the decoded RGBA frame out. Nothing owns anything across the boundary — see es_video_open.

Author
ESEngine Team
Date
2026

Definition in file VideoBindings.hpp.

Function Documentation

◆ es_video_advance()

int es_video_advance ( int handle,
double dt )

Decode forward by dt seconds; returns 1 when a new frame became available.

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 and everything it decoded. Safe on a stale 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 )

Write the pending frame as RGBA into outPtr (>= width*height*4 bytes).

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 a stream from size bytes at dataPtr; the bytes are copied, so the caller keeps its buffer. Returns a handle >= 1, or 0.

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, leaving the target frame pending.

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)

Presentation time of the last decoded frame, in seconds.

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.