[FFmpeg-devel] [PATCH] pthread detection on mingw + static pthread
Ramiro Polla
ramiro
Fri Apr 25 02:32:55 CEST 2008
Hello,
Gianluigi Tiesi wrote:
> On Thu, Apr 24, 2008 at 10:52:55PM +0100, Ramiro Polla wrote:
>> Hello,
>>
>> Gianluigi Tiesi wrote:
>>> On Thu, Apr 24, 2008 at 04:53:21AM +0100, Ramiro Polla wrote:
>>>> libx264.diff uses require2 in configure
>>>> pthreadsGC2_static.diff adds static pthreads-win32 support, given that a
>>>> certain patch be applied to x264 (which I'll send to the x264
>>>> mailinglist right away).
>>>>
>>> libx264.a does not need any patches
>> Did you even read the link I passed? That patch makes x264 not
>> initialize any mutexes if no threads are specified since it's not going
>> to use them anyways.
>>
>> When I moved the initialization code from ffmpeg.c to phtreads.c, that
>> code would only be called if -threads x was given. If only 1 thread was
>> used, it would crash x264 attempting to create mutexes (without running
>> the init code). This is a bug in x264.
>
> libx264 does not have any of win32 pthread attach code,
> it's the executable that should take care of this
> x264.c already does it
>
> since the pthread code is only called in pthread.c
> it should be ok to call it from there
Ok, let me describe what led me to these patches:
Current FFmpeg does not support static pthreads-win32.
Current FFmpeg + your patches makes everything work but leaves some
unwanted #ifdefs in ffmpeg.c
Current FFmpeg + my patches moves the #ifdef closer to where it's
actually used. All lavc codecs work with it.
If libx264 is used with multiple threads, it works too, since the init
code is called from within FFmpeg.
If libx264 is used with no threads, FFmpeg does not init pthreads-win32.
But x264 expects to have an initialized pthreads-win32 so that it can
create a mutex. That mutex will never be used because no threads were
asked for. This is the bug in x264.
> are you sure that no other part of code of x264
> (with pthread calls)
> is called before pthread init?
Yes. I've worked on these patches for quite some time last night.
Ramiro Polla
More information about the ffmpeg-devel
mailing list