Skip to content

Commit 4e0152b

Browse files
committed
Add built-in WebM movie player core (rwebm + rvp8/rvp9)
A dependency-free media player for WebM files, built entirely on libretro-common: rwebm demuxes, rvp9 decodes VP9 and, when rvp8 is present (HAVE_RWEBP), VP8. Gated behind HAVE_WEBMPLAYER (default off; requires HAVE_RWEBM and HAVE_RVP9, enforced by qb), it slots into the existing built-in media player plumbing as the fallback when neither FFmpeg nor MPV is compiled in -- consoles and other minimal builds where those dependencies are unavailable. The core handles VP9 superframes (invisible alt-ref frames packed with the shown frame) and skips presentation of invisible VP8 frames via the frame-tag show bit while still feeding them to the decoder for reference updates. Output is XRGB8888 via BT.601 limited-range conversion; frame rate is derived from the shown video packet count over the stream duration. Audio tracks are ignored for now (silence is output for pacing) pending an Opus decoder in libretro-common. Verified end-to-end: a standalone libretro harness drives the core over nine VP8/VP9 streams (odd dimensions, real motion, alt-ref, two-pass superframes) under AddressSanitizer with pixel-exact output against libvpx-converted reference frames, and a full RetroArch build (HAVE_WEBMPLAYER + null drivers) routes .webm content to the core, plays it at the derived frame rate and shuts down cleanly at end of stream. A default build without the flag is unaffected.
1 parent f21273e commit 4e0152b

14 files changed

Lines changed: 664 additions & 6 deletions

Makefile.common

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,11 @@ ifeq ($(HAVE_RVP9), 1)
23202320
OBJ += $(LIBRETRO_COMM_DIR)/formats/vp9/rvp9.o
23212321
endif
23222322

2323+
ifeq ($(HAVE_WEBMPLAYER), 1)
2324+
DEFINES += -DHAVE_WEBMPLAYER
2325+
OBJ += cores/libretro-webm/webm_core.o
2326+
endif
2327+
23232328
OBJ += $(LIBRETRO_COMM_DIR)/formats/bmp/rbmp_encode.o \
23242329
$(LIBRETRO_COMM_DIR)/formats/json/rjson.o \
23252330
$(LIBRETRO_COMM_DIR)/formats/image_transfer.o \

config.def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@
19711971

19721972
#define DEFAULT_AI_SERVICE_URL "http://localhost:4404/"
19731973

1974-
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
1974+
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) || defined(HAVE_WEBMPLAYER)
19751975
#define DEFAULT_BUILTIN_MEDIAPLAYER_ENABLE true
19761976
#else
19771977
#define DEFAULT_BUILTIN_MEDIAPLAYER_ENABLE false

cores/internal_cores.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,62 @@ size_t libretro_ffmpeg_retro_get_memory_size(unsigned id);
136136

137137
#endif
138138

139+
#ifdef HAVE_WEBMPLAYER
140+
/* Internal WebM (rwebm+rvp8/rvp9) player core. */
141+
142+
void libretro_webm_retro_init(void);
143+
144+
void libretro_webm_retro_deinit(void);
145+
146+
unsigned libretro_webm_retro_api_version(void);
147+
148+
void libretro_webm_retro_get_system_info(struct retro_system_info *info);
149+
150+
void libretro_webm_retro_get_system_av_info(struct retro_system_av_info *info);
151+
152+
void libretro_webm_retro_set_environment(retro_environment_t cb);
153+
154+
void libretro_webm_retro_set_video_refresh(retro_video_refresh_t cb);
155+
156+
void libretro_webm_retro_set_audio_sample(retro_audio_sample_t cb);
157+
158+
void libretro_webm_retro_set_audio_sample_batch(retro_audio_sample_batch_t cb);
159+
160+
void libretro_webm_retro_set_input_poll(retro_input_poll_t cb);
161+
162+
void libretro_webm_retro_set_input_state(retro_input_state_t cb);
163+
164+
void libretro_webm_retro_set_controller_port_device(unsigned port, unsigned device);
165+
166+
void libretro_webm_retro_reset(void);
167+
168+
void libretro_webm_retro_run(void);
169+
170+
size_t libretro_webm_retro_serialize_size(void);
171+
172+
bool libretro_webm_retro_serialize(void *s, size_t len);
173+
174+
bool libretro_webm_retro_unserialize(const void *s, size_t len);
175+
176+
void libretro_webm_retro_cheat_reset(void);
177+
178+
void libretro_webm_retro_cheat_set(unsigned index, bool enabled, const char *code);
179+
180+
bool libretro_webm_retro_load_game(const struct retro_game_info *game);
181+
182+
bool libretro_webm_retro_load_game_special(unsigned game_type,
183+
const struct retro_game_info *info, size_t num_info);
184+
185+
void libretro_webm_retro_unload_game(void);
186+
187+
unsigned libretro_webm_retro_get_region(void);
188+
189+
void *libretro_webm_retro_get_memory_data(unsigned id);
190+
191+
size_t libretro_webm_retro_get_memory_size(unsigned id);
192+
193+
#endif
194+
139195
#ifdef HAVE_MPV
140196
/* Internal mpv core. */
141197

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../internal_cores.h"

0 commit comments

Comments
 (0)