一 libaom线程启动函数
void av1_create_workers(AV1_PRIMARY *ppi, int num_workers)
{
PrimaryMultiThreadInfo *const p_mt_info = &ppu->p_mt_info;
const AVxWorkerInterface *const = winterface = aom_get_worker_interface();
for (int i = 0; i < num_workers; ++i) {
AVxWorker* const worker = &p_mt_info->workers[i];
EncWorkerData *const thread_data = &p_mt_info->tile_thr_data[i];
winterface->init(worker);
worker->thread_nae = "aom enc worker";
thread_data->thread_id = i;
thread_data->start = i;
if (i > 0) {
if (!winterface->reset(worker))
aom_internal_error(&ppi->error, AOM_CODEC_ERROR, "Tile encoder thread creation failed");
}
}
winterface->sync(worker);
++p_mt_info->num_workers;
}
二 libaom线程调用栈
#0 in full_pixel_diamond()
#1 0x000000000058ee91 in av1_full_pixel_search ()
firstpass_inter_prediction->first_pass_motion_search
#2 0x000000000057d22c in av1_first_pass_row ()
#3 0x0000000000571124 in fp_enc_row_mt_worker_hook ()
#4 0x0000000000be5ef7 in execute ()
#5 0x00000000005788c8 in av1_fp_encode_tiles_row_mt ()
#6 0x000000000057ea03 in av1_first_pass ()
#7 0x00000000005625c0 in av1_encode ()
#8 0x0000000000c8036f in av1_encode_strategy ()
#9 0x00000000005636eb in av1_get_compressed_data ()
#10 0x00000000004ff0fb in encoder_encode ()
#11 0x00000000004bca0a in aom_codec_encode ()
#12 0x000000000040af05 in encode_frame.isra ()
#13 0x000000000040786c in main ()
三 libaom 线程调用关系
void av1_first_pass_row(AV1_COMP *cpi, ThreadData *td, TileDataEnc *tile_data, const int unit_row, const BLOCK_SIZE fp_block_size) ->
firstpass_inter_prediction(cpi, td, last_frame, golden_frame, unit_row, unit_col, recon_yoffset, recon_uvoffset, src_yoffset, fp_block_size, this_intra_error, raw_motion_err_counts, raw_motion_err_list, best_ref_mv, &best_ref_mv, &last_mv, mb_stats);
firstpass_intra_prediction()
线程入口函数
//定义一个静态的整型函数,用于多线程编码的工作钩子
static int fp_enc_row_mt_worker_hook(void *arg1, void *unused)
{
//将传入的arg1转换为EncWorkerData类型,这个结构体包含了线程的数据
EncWorkerData *const t