Example #1
0
static int read_frame( x264_picture_t *p_pic, hnd_t handle, int i_frame )
{
    thread_hnd_t *h = handle;
    int ret = 0;

    if( h->next_frame >= 0 )
    {
        x264_pthread_join( h->tid, NULL );
        ret |= h->next_args->status;
        h->in_progress = 0;
    }

    if( h->next_frame == i_frame )
        XCHG( x264_picture_t, *p_pic, h->pic );
    else
        ret |= h->input.read_frame( p_pic, h->p_handle, i_frame );

    if( !h->frame_total || i_frame+1 < h->frame_total )
    {
        h->next_frame =
        h->next_args->i_frame = i_frame+1;
        h->next_args->pic = &h->pic;
        if( x264_pthread_create( &h->tid, NULL, (void*)read_frame_thread_int, h->next_args ) )
            return -1;
        h->in_progress = 1;
    }
    else
        h->next_frame = -1;

    return ret;
}
Example #2
0
static int close_file( hnd_t handle )
{
    thread_hnd_t *h = handle;
    if( h->in_progress )
        x264_pthread_join( h->tid, NULL );
    h->input.close_file( h->p_handle );
    h->input.picture_clean( &h->pic );
    free( h->next_args );
    free( h );
    return 0;
}
Example #3
0
void x264_threadpool_delete( x264_threadpool_t *pool )
{
    x264_pthread_mutex_lock( &pool->run.mutex );
    pool->exit = 1;
    x264_pthread_cond_broadcast( &pool->run.cv_fill );
    x264_pthread_mutex_unlock( &pool->run.mutex );
    for( int i = 0; i < pool->threads; i++ )
        x264_pthread_join( pool->thread_handle[i], NULL );

    x264_threadpool_list_delete( &pool->uninit );
    x264_threadpool_list_delete( &pool->run );
    x264_threadpool_list_delete( &pool->done );
    x264_free( pool->thread_handle );
    x264_free( pool );
}
Example #4
0
void x264_lookahead_delete( x264_t *h )
{
    if( h->param.i_sync_lookahead )
    {
        h->lookahead->b_exit_thread = 1;
        x264_pthread_cond_broadcast( &h->lookahead->ifbuf.cv_fill );
        x264_pthread_join( h->thread[h->param.i_threads]->thread_handle, NULL );
        x264_macroblock_cache_end( h->thread[h->param.i_threads] );
        x264_free( h->thread[h->param.i_threads] );
    }
    x264_synch_frame_list_delete( &h->lookahead->ifbuf );
    x264_synch_frame_list_delete( &h->lookahead->next );
    if( h->lookahead->last_nonb )
        x264_frame_push_unused( h, h->lookahead->last_nonb );
    x264_synch_frame_list_delete( &h->lookahead->ofbuf );
    x264_free( h->lookahead );
}