Commit e046ba72 authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Fix clobbering of mutex/cvs

Regression in r2183.
Bizarrely seemed to work on many platforms, but crashed on win64 and may have been slower.
Only affected sliced threads during encoding, but could cause crashes on x264 encoder close even without sliced threads.
parent a155572e
......@@ -1271,18 +1271,8 @@ x264_t *x264_encoder_open( x264_param_t *param )
goto fail;
h->thread[0] = h;
for( int i = 0; i < h->param.i_threads + !!h->param.i_sync_lookahead; i++ )
{
if( i )
CHECKED_MALLOC( h->thread[i], sizeof(x264_t) );
if( i < h->param.i_threads )
{
if( x264_pthread_mutex_init( &h->thread[i]->mutex, NULL ) )
goto fail;
if( x264_pthread_cond_init( &h->thread[i]->cv, NULL ) )
goto fail;
}
}
for( int i = 1; i < h->param.i_threads + !!h->param.i_sync_lookahead; i++ )
CHECKED_MALLOC( h->thread[i], sizeof(x264_t) );
for( int i = 0; i < h->param.i_threads; i++ )
{
......@@ -1291,6 +1281,11 @@ x264_t *x264_encoder_open( x264_param_t *param )
if( i > 0 )
*h->thread[i] = *h;
if( x264_pthread_mutex_init( &h->thread[i]->mutex, NULL ) )
goto fail;
if( x264_pthread_cond_init( &h->thread[i]->cv, NULL ) )
goto fail;
if( allocate_threadlocal_data )
{
h->thread[i]->fdec = x264_frame_pop_unused( h, 1 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment