[FFmpeg-devel] [PATCH] Fix multithreaded MPEG-4 decoding.
Reimar.Doeffinger at gmx.de
Fri Apr 19 01:20:42 CEST 2013
On 18.04.2013, at 20:57, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Thu, Apr 18, 2013 at 07:13:56PM +0200, Reimar Döffinger wrote:
>> Regression since c10d498bfd246a40cc7830838b74e18a79418839.
>> Unfortunately ff_thread_get_format can only be called from
>> a separate decode thread, running it during init will fail.
>> Fixes for that are welcome, for now just revert back to
>> calling avctx->get_format directly, which is correct
>> but having to decide on a case-by-case basis which approach
>> to use is a bit messy.
> not using get_format() for anything but getting the format would
> solve this mess, i mean no sideeffects like initializing some hardware
Except you (might) need to initialize the hardware to figure out what formats are supported.
So if it's not ok to do in get_format, you'd have to do it before.
Of course, in some cases that means creating a window. In some cases, even a visible one.
So it can get very messy if you want to try through everything "just in case" beforehand.
At that point it would be easier to just close the codec and try again, knowing the available formats beforehand.
Though if I had to argue, I'd say solving this via a callback was the stupid idea from the start, leading to not only this hack but also things like initializing but then not using threading with hwaccel.
It could have been solved by making the decoder return an error until a supported pixfmt was selected via the context for example.
More information about the ffmpeg-devel