h264 並行編碼

聲明:轉帖時請註明出處

結構體x264_param_t

h264.h結構體x264_param_tapp

/* CPU flags */
    unsigned int cpu;
    int         i_threads;           /* encode multiple frames in parallel */
    int         i_lookahead_threads; /* multiple threads for lookahead analysis */
    int         b_sliced_threads;  /* Whether to use slice-based threading. */
    int         b_deterministic; /* whether to allow non-deterministic optimizations when threaded */
    int         b_cpu_independent; /* force canonical behavior rather than cpu-dependent optimal algorithms */
    int         i_sync_lookahead; /* threaded lookahead buffer */

 

 

encoder.c  x264_validate_parameters

if( h->param.i_threads == X264_THREADS_AUTO )
        h->param.i_threads = x264_cpu_num_processors() * (h->param.b_sliced_threads?2:3)/2;
    int max_sliced_threads = X264_MAX( 1, (h->param.i_height+15)/16 / 4 );
    if( h->param.i_threads > 1 )
    {
#if !HAVE_THREAD
        x264_log( h, X264_LOG_WARNING, "not compiled with thread support!\n");
        h->param.i_threads = 1;
#endif
        /* Avoid absurdly small thread slices as they can reduce performance
         * and VBV compliance.  Capped at an arbitrary 4 rows per thread. */
        if( h->param.b_sliced_threads )
            h->param.i_threads = X264_MIN( h->param.i_threads, max_sliced_threads );
    }
    h->param.i_threads = x264_clip3( h->param.i_threads, 1, X264_THREAD_MAX );
    if( h->param.i_threads == 1 )
    {
        h->param.b_sliced_threads = 0;
        h->param.i_lookahead_threads = 1;
    }
    h->i_thread_frames = h->param.b_sliced_threads ? 1 : h->param.i_threads;
    if( h->i_thread_frames > 1 )
        h->param.nalu_process = NULL;

 

結論:

i_threads和b_sliced_threads沒有配置時,編碼的線程數是CPU的1.5倍。編碼

相關文章
相關標籤/搜索