Menu: WebM previews in the file browser (Ozone/XMB)

1316b60 made .webm decodable by the thumbnail pipeline, but only wired
it up for playlist thumbnails. Highlighting a .webm in the file browser
still showed nothing, because the 'file is its own thumbnail' preview
path that images use is gated four times on image-ness, in series:

- ozone_selection_changed / xmb selection handling only trigger the
  imageviewer preview for FILE_TYPE_IMAGEVIEWER/FILE_TYPE_IMAGE, and
  .webm entries are typed FILE_TYPE_WEBM / FILE_TYPE_MOVIE (with a
  media player compiled in) or FILE_TYPE_PLAIN (without)
- xmb_set_thumbnail_content's imageviewer branch re-checks
  FILE_TYPE_IMAGEVIEWER
- gfx_thumbnail_set_content_image rejects anything whose
  path_is_media_type is not RARCH_CONTENT_IMAGE
- gfx_thumbnail_update_path's imageviewer special case requires
  RARCH_CONTENT_IMAGE before using the file itself as the thumbnail

Open all four for WebM. The menu-driver checks use
image_texture_get_type(entry.path) == IMAGE_TYPE_WEBM rather than the
entry type, so they work regardless of how the file was typed (and
compile away to a false constant without HAVE_RWEBM, since the type
can then never be returned). File typing itself is untouched: OK on a
.webm still launches the media player as before, and the movie icon
is kept.

Unlike an image, the whole WebM must be read to decode a frame, and
file-browser content is arbitrarily large, so gfx_thumbnail_update_path
additionally refuses files past GFX_THUMB_ANIM_MAX_FILE (64 MiB), the
same cap the animation decoder enforces.

MaterialUI has no filebrowser preview mechanism for images either, so
there is nothing to extend there; its playlist thumbnails already
animate via 1316b60.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-07-14 15:41:10 +02:00
1 parent 1316b60f05
commit 7b2b7116a1
3 files changed
+25 -4

No files matched your search

+13 -1
View File
@@ -1845,7 +1845,10 @@ bool gfx_thumbnail_set_content_image(
if ((!img_dir || !*img_dir) || (!img_name || !*img_name))
return false;
if (path_is_media_type(img_name) != RARCH_CONTENT_IMAGE)
/* Images, and WebM files (whose video track the thumbnail pipeline
* decodes like an animated WebP), can serve as their own thumbnail */
if ( (path_is_media_type(img_name) != RARCH_CONTENT_IMAGE)
&& (image_texture_get_type(img_name) != IMAGE_TYPE_WEBM))
return false;
/* Cache content image name */
@@ -2134,6 +2137,15 @@ bool gfx_thumbnail_update_path(
if (path_is_media_type(path_data->content_path) == RARCH_CONTENT_IMAGE)
strlcpy(thumbnail_path,
path_data->content_path, PATH_MAX_LENGTH * sizeof(char));
/* A WebM file is likewise its own (animated) thumbnail, but unlike
* an image the entire file must be read to decode it, so refuse
* anything past the animation decoder's file-size cap */
else if ( (image_texture_get_type(path_data->content_path)
== IMAGE_TYPE_WEBM)
&& (path_get_size(path_data->content_path)
<= GFX_THUMB_ANIM_MAX_FILE))
strlcpy(thumbnail_path,
path_data->content_path, PATH_MAX_LENGTH * sizeof(char));
}
else
{
+5 -1
View File
@@ -12073,10 +12073,14 @@ static void ozone_selection_changed(ozone_handle_t *ozone, bool allow_animation)
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_PATH_ENABLED;
menu_entry_get(&entry, 0, selection, NULL, true);
if ( (entry.type == FILE_TYPE_IMAGEVIEWER)
|| (entry.type == FILE_TYPE_IMAGE))
|| (entry.type == FILE_TYPE_IMAGE)
/* WebM files preview like images: the thumbnail
* pipeline decodes their video track */
|| (image_texture_get_type(entry.path) == IMAGE_TYPE_WEBM))
{
ozone_set_thumbnail_content(ozone, "imageviewer");
update_thumbnails = true;
+7 -2
View File
@@ -1902,7 +1902,8 @@ static void xmb_set_thumbnail_content(void *data, const char *s)
if ( *entry.path
&& (node->fullpath && *node->fullpath)
&& entry.type == FILE_TYPE_IMAGEVIEWER)
&& ( (entry.type == FILE_TYPE_IMAGEVIEWER)
|| (image_texture_get_type(entry.path) == IMAGE_TYPE_WEBM)))
{
gfx_thumbnail_set_content_image(menu_st->thumbnail_path_data,
node->fullpath, entry.path);
@@ -2237,10 +2238,14 @@ static void xmb_selection_pointer_changed(
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_PATH_ENABLED;
menu_entry_get(&entry, 0, selection, NULL, true);
if ( (entry.type == FILE_TYPE_IMAGEVIEWER)
|| (entry.type == FILE_TYPE_IMAGE))
|| (entry.type == FILE_TYPE_IMAGE)
/* WebM files preview like images: the thumbnail
* pipeline decodes their video track */
|| (image_texture_get_type(entry.path) == IMAGE_TYPE_WEBM))
{
xmb_set_thumbnail_content(xmb, "imageviewer");
update_thumbnails = true;