mickelson / attract

A graphical front-end for command line emulators that hides the underlying operating system and is intended to be controlled with a joystick or gamepad.
http://attractmode.org
GNU General Public License v3.0
393 stars 115 forks source link

mmal hw video decoding error detection and reverting to software if error occured #627

Closed joyrider3774 closed 4 years ago

joyrider3774 commented 4 years ago

fixes #625 by specifying PLATFORM_RPI4=1 when making and not using mmal for mpeg4 / 2 & vc1 as it's not supported on the pi4 .

I explictly did not use a detection for RPI4 as i don't know how and it might break crosscompiling. If people also omit PLATFORM_RPI4=1 on the make line it will just compile as before but breaks mpeg4 / 2 & vc1 videoplay back as it's not supported on pi4.

Also don't know if you would have had me rather changing the USE_MMAL define instead of creating the PLATFORM_RPI4 one but i guess if there are other specifics to RPI4 it could be reused

sorry did not know how to fix my repo / branch without doing new PR, now it's not showing a merge commit

joyrider3774 commented 4 years ago

should i print a warning when video is reverted to software decoding when playing these vids when mmal decoder is enabled, at least user then knows some of his vids are not supported through mmal on rpi4

oomek commented 4 years ago

I think yes, it could be useful to see that. Btw, have you thought about implementing a runtime fallback decoder based on the error returned by ffmpeg instead of compile time fixed assignment?

joyrider3774 commented 4 years ago

a runtime fallback decoder based on the error returned by ffmpeg would be nice, but not sure i'm up to that task. The mmal codecs used are definatly not supported on RPI4 so might as well disable them also when first trying to play the videos through hw decoder and waiting on an error it could induce a delay before actually seeing the videos. Now software is immediatly used as we know the codecs are not supported in rpi4

joyrider3774 commented 4 years ago

Added the runtime fallback, it does not need PLATFORM_RPI specified anymore and work for any system where USE_MMAL might be defined. For all decoder types it checks if libavcodec gives error or not if not it uses it. If it does, it retries the original software decoder. Tested on my raspberry pi 4 with mpeg4 videos and this worked fast, there is no delay at all. libavcodec also immediatly returns those errors. No video playback is done to test this.

it should work for the other mmal decoder types as well but i did not have such video's to test with but the code used is the same.

Please verify the code as i'm no c/c++ dev and don't really know all the semantics about memory mangement in c++

mickelson commented 4 years ago

Thanks!