[gst-devel] Dynamic thread creation in Gstreamer

Mattias Barthel mb at novanotio.es
Sun Jun 29 10:03:22 CEST 2008


Thomas Vander Stichele wrote:
> On Fri, 2008-06-27 at 09:53 +0200, mattias wrote:
>   
>> Ok, good to know that, thanks.
>>
>> What I was seeing through gdb was the bezerk thread creation of x264enc.
>> x264enc creates a new thread for each frame it encodes.
>>     
>
> Are you sure about this ? That sounds very wrong.  Can you see where
> this happens in the code ?
>
> Thomas
>
>
>   
Yes,
If you specify to g_object_set on the property threads of the x264enc 
element of just threads=2 in a gst-launch involving x264enc, then in the 
library libx264.a the thread creation goes in that manner.

Have a look at encoder/encoder.c in the funcion 
x264_encoder_encode(...), there x264_pthread_create is called with 
x264_slices_write as thread function. Then in the function 
x264_encoder_frame_end(...) the function x264_pthread_join is called to 
join the finished thread after each frame. Now, what is not totally 
clear to me is if the code really creates more than one extra thread.

So for each frame, at least one thread is created and killed!

Of course this behaviour creates a lot of overhead and it is quite bad 
if you want to create a realtime application.

Mattias




More information about the gstreamer-devel mailing list