mp_semaphore_signal( &picture_started, 1);
static void *parencodeworker(void *start_arg){	pict_data_ptr picture;	mjpeg_debug( "Worker thread started" );	for(;;)	{		mp_semaphore_signal( &worker_available, 1);		mp_semaphore_wait( &picture_available );		/* Precisely *one* worker is started after update of		   picture_for_started_worker, so no need for handshake.  */		picture = (Picture *)picture_to_encode;		mp_semaphore_signal( &picture_started, 1);		/* ALWAYS do-able */		mjpeg_info("Frame %d %c %d %d",  				   picture->decode,  pict_type_char[picture->pict_type],				   picture->temp_ref,				   picture->present);		if( picture->pict_struct != FRAME_PICTURE )			mjpeg_info("Field %s (%d)",					   (picture->pict_struct == TOP_FIELD) ? "top" : "bot",					   picture->pict_struct				);		motion_subsampled_lum(picture);				/* DEPEND on completion previous Reference frames (P) or on old		   and new Reference frames B.  However, since new reference frame		   cannot complete until old reference frame completed (see below)		   suffices just to check new reference frame... 		   N.b. completion guard of picture is always reset to false		   before this function is called...		   		   In field picture encoding the P field of an I frame is		   a special case.  We have to wait for completion of the I field		   before starting the P field		*/#ifdef ORIGINAL_PHASE_BASED_PROC		if( ctl->refine_from_rec )		{			sync_guard_test( picture->ref_frame_completion );			motion_estimation(picture);		}		else		{			motion_estimation(picture);			sync_guard_test( picture->ref_frame_completion );		}		predict(picture);		/* No dependency */		transform(picture);#else        sync_guard_test( picture->ref_frame_completion );        encodembs(picture);#endif		/* Depends on previous frame completion for IB and P */		sync_guard_test( picture->prev_frame_completion );		picture->PutHeadersAndEncoding(*bitrate_controller);		reconstruct(picture);		/* Handle second field of a frame that is being field encoded */		if( opt->fieldpic )		{			set_2nd_field_params(picture);			mjpeg_info("Field %s (%d)",					   (picture->pict_struct == TOP_FIELD) ? "top" : "bot",					   picture->pict_struct				);			motion_estimation(picture);			predict(picture);			transform(picture);            picture->PutHeadersAndEncoding(*bitrate_controller);			reconstruct(picture);		}		mjpeg_info("Frame end %d %s %3.2f %.2f %2.1f %.2f",					picture->decode, 					picture->pad ? "PAD" : "   ",					picture->avg_act, picture->sum_avg_act,					picture->AQ, picture->SQ);		/* We're finished - let anyone depending on us know...		 */		sync_guard_update( &picture->completion, 1 );				}	return NULL;}