phoboslab / pl_mpeg

Single file C library for decoding MPEG1 Video and MP2 Audio
799 stars 58 forks source link

Fix warnings about typedef redefinitions only being available on C11 #32

Closed crudelios closed 2 years ago

crudelios commented 2 years ago

These warnings were annoying me a little bit when compiling with C99 support.

Since the fix was simple, I decided to share it.

In my tests it works on every single compiler (MSVC, mingw, gcc, clang, emscripten, Android, Switch and Vita).

phoboslab commented 2 years ago

Thanks!

In my tests it works on [...] Switch and Vita

I'm curious! Can you share what you are up to? :)

crudelios commented 2 years ago

I'm curious! Can you share what you are up to? :)

Sure! 👍

I'm one of the main developers of Augustus, a fork of Julius, which itself is an open-source reimplementation of the game Caesar III.

Check it out - https://github.com/Keriew/augustus

Your library is used for improved video playback. Sadly it hardly runs on Vita due to poor performance though.

phoboslab commented 2 years ago

Very cool! Thanks for sharing :)

Some remarks regarding performance (though I assume that Vita is not exactly a priority for this project?): I see you are already using accelerated YUV->RGB conversion where available. That's probably the biggest bottleneck, if the platform can't do it in hardware. Copying (and interpolating) blocks in PLM_BLOCK_SET is also quite expensive. I have no idea about Vita's capabilities, but this could probably be improved with some SIMD.

crudelios commented 2 years ago

Yes, the colour space conversion is being done in hardware.

Actually your lib's integration prompted me to ask for yuv texture support for vita, which was then added. As a bonus, an audio issue with vita's SDL driver was found and fixed. Unfortunately that wasn't enough to get good performance.

SIMD would definitely help, but I don't know enough to implement it.

Another possible optimization for vita would be to write to texture memory directly, avoiding the memcpys used in SDL_UpdateTextureYUV, but that would require providing the texture memory pointer for pl_mpeg to use instead of its own internal buffers, which I don't know if it's even possible/feasible.