love-webp - WebP library [archived]

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Imagic
Prole
Posts: 44
Joined: Mon Sep 30, 2019 8:20 am
Contact:

love-webp - WebP library [archived]

Post by Imagic »

Following this topic where adding WebP support to LÖVE was discussed, I created this library as a proof of concept and utility before a potential native support.

It features the loading of WebP images and animations (as a sequence or streamed from memory). The library is kind of experimental due to factors like the WebP ABI or the integration with LÖVE, but it should work fine. Note that the FFI overhead when not JIT compiled is negligible compared to the decoding cost.

Project and documentation: https://github.com/ImagicTheCat/love-webp

Some animation uses cases comparisons:
Atlas loadImage
pros
- good compression for batches
- full control over the animation
- can be used to animate a lot of elements with different states
cons
- for small animations

Animation -> Array texture loadImages
pros
- big animations
- full control over the animation
- can be used to animate a lot of elements with different states
- animated atlas ?
cons
- memory usage/GPU limitations for long animations

Animation -> Streamed (video-like) loadAnimation
pros
- low memory usage for big and long animations (compressed frames + decoded frame)
cons
- CPU usage

WebP animations will probably cost more CPU/memory/space than equivalent Theora videos, they are not a replacement for video codecs; they have more features like alpha, duration per frame, blend/disposable method per frame, lossy/lossless per frame, etc. For example, WebP may be far more suited for a pixel art animation.
Last edited by Imagic on Mon Jul 17, 2023 4:00 pm, edited 1 time in total.
desttiny
Prole
Posts: 10
Joined: Thu Feb 20, 2020 6:02 pm

Re: love-webp - WebP library

Post by desttiny »

hey thanks a lot for doing this! I haven't been able to make this work, can you please provide the shared libraries or at least point from where to get them and what files exactly do we need? Hopefully I don't have to build them myself?
User avatar
Imagic
Prole
Posts: 44
Joined: Mon Sep 30, 2019 8:20 am
Contact:

Re: love-webp - WebP library

Post by Imagic »

Under a GNU/Linux distribution, you probably just need to install the WebP library on the system.

It seems that only static libraries for Windows are given on the WebP website, so you need to compile the shared libraries. I could add the DLLs into the project, but I think it would be better to let people compile those themselves (well, it still may be better than having people replacing DLLs by randomly downloaded ones).
desttiny
Prole
Posts: 10
Joined: Thu Feb 20, 2020 6:02 pm

Re: love-webp - WebP library

Post by desttiny »

Imagic wrote: Wed Mar 18, 2020 1:33 am Under a GNU/Linux distribution, you probably just need to install the WebP library on the system.

It seems that only static libraries for Windows are given on the WebP website, so you need to compile the shared libraries. I could add the DLLs into the project, but I think it would be better to let people compile those themselves (well, it still may be better than having people replacing DLLs by randomly downloaded ones).
So this is not meant to be used in a project? slime already said unless someone makes a single file decoder then he is not adding webp, which means he is not adding webp natively since nobody will make a single file decoder and just praying to god that someone will is quite pointless. We need something that works out of box, not proof of concept.

Could you please provide all the necessary files for all the different platforms so we can make this work on windows, linux and other?
User avatar
Imagic
Prole
Posts: 44
Joined: Mon Sep 30, 2019 8:20 am
Contact:

Re: love-webp - WebP library

Post by Imagic »

This is the drawback of an external library with the FFI and why native support is important for LÖVE where users probably expect everything bundled with the engine.

This is meant to be used in a project, but you need to compile/get the WebP shared libraries for each target, as you would compile/get any external Lua C modules. On Windows, since everything is kind of duplicated everywhere with little diversity, I could provide DLLs and it might work fine; but that's not so easy in general.

See this as an experimental feature, harder to use, but at least we have something to work with.
desttiny
Prole
Posts: 10
Joined: Thu Feb 20, 2020 6:02 pm

Re: love-webp - WebP library

Post by desttiny »

Imagic wrote: Wed Mar 18, 2020 12:27 pm This is the drawback of an external library with the FFI and why native support is important for LÖVE where users probably expect everything bundled with the engine.

This is meant to be used in a project, but you need to compile/get the WebP shared libraries for each target, as you would compile/get any external Lua C modules. On Windows, since everything is kind of duplicated everywhere with little diversity, I could provide DLLs and it might work fine; but that's not so easy in general.

See this as an experimental feature, harder to use, but at least we have something to work with.
I understand. But I still confused what exactly I need to do to make this work. Could you make an indepth guide or give some pointers as how the process of getting this to work looks like? I've only compiled a couple of dll's in my life so I am not well versed in anything other then straightforward scripting but if you could give some pointers I am sure I could manage. Like, I don't expect you to create a course on this topic but if you could break down the process (for this specific love2d-webp purpose) into steps so that it is more digestible by someone like me - I would be very grateful.
User avatar
Imagic
Prole
Posts: 44
Joined: Mon Sep 30, 2019 8:20 am
Contact:

Re: love-webp - WebP library

Post by Imagic »

It depends on each target, there is no (unfortunately) consistent cross-platform automated process to build binaries. There are more build systems than Lua OOP libraries and it's still a nightmare.

What are your OS/arch targets ?
desttiny
Prole
Posts: 10
Joined: Thu Feb 20, 2020 6:02 pm

Re: love-webp - WebP library

Post by desttiny »

windows>linux>mac. So if nothing else, it would be really nice to be able to get this working on windows at least for now.
User avatar
Imagic
Prole
Posts: 44
Joined: Mon Sep 30, 2019 8:20 am
Contact:

Re: love-webp - WebP library

Post by Imagic »

I added compiled libraries for Windows: https://github.com/ImagicTheCat/love-we ... aster/dist

For other platforms, compiling WebP would probably be a part of the app building process.
desttiny
Prole
Posts: 10
Joined: Thu Feb 20, 2020 6:02 pm

Re: love-webp - WebP library

Post by desttiny »

Imagic wrote: Thu Mar 19, 2020 5:32 pm I added compiled libraries for Windows: https://github.com/ImagicTheCat/love-we ... aster/dist

For other platforms, compiling WebP would probably be a part of the app building process.
It works! You sir are a legend! Thank you.
Post Reply

Who is online

Users browsing this forum: slime and 131 guests