Decompressing a JPEG in a plugin

majenko

New Member
I'm writing a plugin at the moment which receives a stream of JPEG images over the network from another device (a camera as it happens). At the moment I'm using libjpeg in Linux to do the JPEG decoding, which is fine I suppose, but I'd much prefer to use the internal OBS graphics handling routines to do the job.

However I can't see how I can. All the documentation seems to revolve around loading image data from a file into a texture, rather than from a memory buffer into a texture. How can I decompress a JPEG into a texture from memory instead of from a file?
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
We have an API for image files. libobs/util/graphics/image-file.h if you want to get a OBS texture from an image file. Note that it's designed to be used with animated gifs as well, so it'll have things like tick functions for animation.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
Oh gosh I'm sorry, I apparently didn't even read what you said. Unfortunately we don't have an API for an image buffer to a texture. Just a file to texture at the moment. You could probably make something out of that though or submit a pull request for that though if you really need it. It probably wouldn't be that big of a deal to write.
 

majenko

New Member
I have ported "ffjpeg" - a small, light weight, JPEG library - as code directly in the plugin. That itself is also only for compressing/decompressing files, so took a bit of creative wrapping of code. Fortunately all the file access is within just one function, and I wrote a set of "md_f*" replacements for the normal f* functions that emulate disk access using a block of data instead. Cludgy, but it works well enough for now. Maybe one day I may look at enhancing the graphics API with memory "loading" of the data.

Now, my next chore is how the $&%^ can I get this plugin to compile in Windows?! I hate Windows. How anyone can actively develop in I have no clue...
 
Top