void av1_row_mt_sync_write(AV1EncRowMultiThreadSync *row_mt_sync, int r, int c, int cols) { #if CONFIG_MULTITHREAD constint nsync = row_mt_sync->sync_range; int cur; // Only signal when there are enough encoded blocks for next row to run. int sig = 1;
if (c < cols - 1) {
cur = c; if (c % nsync) sig = 0;
} else {
cur = cols + nsync + row_mt_sync->intrabc_extra_top_right_sb_delay;
}
if (sig) {
pthread_mutex_lock(&row_mt_sync->mutex_[r]);
// When a thread encounters an error, num_finished_cols[r] is set to maximum // column number. In this case, the AOMMAX operation here ensures that // num_finished_cols[r] is not overwritten with a smaller value thus // preventing the infinite waiting of threads in the relevant sync_read() // function.
row_mt_sync->num_finished_cols[r] =
AOMMAX(row_mt_sync->num_finished_cols[r], cur);
row_mt_sync->rows = rows; // Set up nsync.
row_mt_sync->sync_range = 1;
}
// Deallocate row based multi-threading synchronization related mutex and data void av1_row_mt_sync_mem_dealloc(AV1EncRowMultiThreadSync *row_mt_sync) { if (row_mt_sync != NULL) { #if CONFIG_MULTITHREAD int i;
if (row_mt_sync->mutex_ != NULL) { for (i = 0; i < row_mt_sync->rows; ++i) {
pthread_mutex_destroy(&row_mt_sync->mutex_[i]);
}
aom_free(row_mt_sync->mutex_);
} if (row_mt_sync->cond_ != NULL) { for (i = 0; i < row_mt_sync->rows; ++i) {
pthread_cond_destroy(&row_mt_sync->cond_[i]);
}
aom_free(row_mt_sync->cond_);
} #endif// CONFIG_MULTITHREAD
aom_free(row_mt_sync->num_finished_cols);
// clear the structure as the source of this call may be dynamic change // in tiles in which case this call will be followed by an _alloc() // which may fail.
av1_zero(*row_mt_sync);
}
}
#if CONFIG_REALTIME_ONLY int num_b_rows_in_tile =
av1_get_sb_rows_in_tile(cm, &this_tile->tile_info); int num_b_cols_in_tile =
av1_get_sb_cols_in_tile(cm, &this_tile->tile_info); #else int num_b_rows_in_tile =
is_firstpass
? av1_get_unit_rows_in_tile(&this_tile->tile_info, fp_block_size)
: av1_get_sb_rows_in_tile(cm, &this_tile->tile_info); int num_b_cols_in_tile =
is_firstpass
? av1_get_unit_cols_in_tile(&this_tile->tile_info, fp_block_size)
: av1_get_sb_cols_in_tile(cm, &this_tile->tile_info); #endif int theoretical_limit_on_threads =
AOMMIN((num_b_cols_in_tile + 1) >> 1, num_b_rows_in_tile); int num_threads_working = row_mt_sync->num_threads_working;
if (num_threads_working < theoretical_limit_on_threads) { int num_mis_to_encode =
this_tile->tile_info.mi_row_end - row_mt_sync->next_mi_row;
// Tile to be processed by this thread is selected on the basis of // availability of jobs: // 1) If jobs are available, tile to be processed is chosen on the // basis of minimum number of threads working for that tile. If two or // more tiles have same number of threads working for them, then the // tile with maximum number of jobs available will be chosen. // 2) If no jobs are available, then end_of_frame is reached. if (num_mis_to_encode > 0) { if (num_threads_working < min_num_threads_working) {
min_num_threads_working = num_threads_working;
max_mis_to_encode = 0;
} if (num_threads_working == min_num_threads_working &&
num_mis_to_encode > max_mis_to_encode) {
tile_id = tile_index;
max_mis_to_encode = num_mis_to_encode;
}
}
}
}
} if (tile_id == -1) {
*end_of_frame = 1;
} else { // Update the current tile id to the tile id that will be processed next, // which will be the least processed tile.
*cur_tile_id = tile_id; constint unit_height = mi_size_high[fp_block_size];
get_next_job(&tile_data[tile_id], current_mi_row,
is_firstpass ? unit_height : cm->seq_params->mib_size);
}
}
// In case of multithreading of firstpass encode, due to top-right // dependency, the worker on a firstpass row waits for the completion of the // firstpass processing of the top and top-right fp_blocks. Hence, in case a // thread (main/worker) encounters an error, update the firstpass processing // of every row in the frame to indicate that it is complete in order to avoid // dependent workers waiting indefinitely. for (int tile_row = 0; tile_row < tile_rows; ++tile_row) { for (int tile_col = 0; tile_col < tile_cols; ++tile_col) {
TileDataEnc *const tile_data =
&cpi->tile_data[tile_row * tile_cols + tile_col];
TileInfo *tile = &tile_data->tile_info;
AV1EncRowMultiThreadSync *const row_mt_sync = &tile_data->row_mt_sync; constint unit_cols_in_tile =
av1_get_unit_cols_in_tile(tile, fp_block_size); for (int mi_row = tile->mi_row_start, unit_row_in_tile = 0;
mi_row < tile->mi_row_end;
mi_row += unit_height, unit_row_in_tile++) {
enc_row_mt->sync_write_ptr(row_mt_sync, unit_row_in_tile,
unit_cols_in_tile - 1, unit_cols_in_tile);
}
}
}
}
// The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (setjmp(error_info->jmp)) {
error_info->setjmp = 0; #if CONFIG_MULTITHREAD
pthread_mutex_lock(enc_row_mt_mutex_);
enc_row_mt->firstpass_mt_exit = true;
pthread_mutex_unlock(enc_row_mt_mutex_); #endif
set_firstpass_encode_done(cpi); return0;
}
error_info->setjmp = 1;
AV1_COMMON *const cm = &cpi->common; int cur_tile_id = enc_row_mt->thread_id_to_tile_id[thread_id];
assert(cur_tile_id != -1);
const BLOCK_SIZE fp_block_size = cpi->fp_block_size; constint unit_height = mi_size_high[fp_block_size]; int end_of_frame = 0; while (1) { int current_mi_row = -1; #if CONFIG_MULTITHREAD
pthread_mutex_lock(enc_row_mt_mutex_); #endif bool firstpass_mt_exit = enc_row_mt->firstpass_mt_exit; if (!firstpass_mt_exit && !get_next_job(&cpi->tile_data[cur_tile_id],
¤t_mi_row, unit_height)) { // No jobs are available for the current tile. Query for the status of // other tiles and get the next job if available
switch_tile_and_get_next_job(cm, cpi->tile_data, &cur_tile_id,
¤t_mi_row, &end_of_frame, 1,
fp_block_size);
} #if CONFIG_MULTITHREAD
pthread_mutex_unlock(enc_row_mt_mutex_); #endif // When firstpass_mt_exit is set to true, other workers need not pursue any // further jobs. if (firstpass_mt_exit || end_of_frame) break;
// In case of row-multithreading, due to top-right dependency, the worker on // an SB row waits for the completion of the encode of the top and top-right // SBs. Hence, in case a thread (main/worker) encounters an error, update that // encoding of every SB row in the frame is complete in order to avoid the // dependent workers of every tile from waiting indefinitely. for (int tile_row = 0; tile_row < tile_rows; tile_row++) { for (int tile_col = 0; tile_col < tile_cols; tile_col++) {
TileDataEnc *const this_tile =
&cpi->tile_data[tile_row * tile_cols + tile_col]; const TileInfo *const tile_info = &this_tile->tile_info;
AV1EncRowMultiThreadSync *const row_mt_sync = &this_tile->row_mt_sync; constint sb_cols_in_tile = av1_get_sb_cols_in_tile(cm, tile_info); for (int mi_row = tile_info->mi_row_start, sb_row_in_tile = 0;
mi_row < tile_info->mi_row_end;
mi_row += mib_size, sb_row_in_tile++) {
enc_row_mt->sync_write_ptr(row_mt_sync, sb_row_in_tile,
sb_cols_in_tile - 1, sb_cols_in_tile);
}
}
}
}
// The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (setjmp(error_info->jmp)) {
error_info->setjmp = 0; #if CONFIG_MULTITHREAD
pthread_mutex_lock(enc_row_mt_mutex_);
enc_row_mt->row_mt_exit = true; // Wake up all the workers waiting in launch_loop_filter_rows() to exit in // case of an error.
pthread_cond_broadcast(enc_row_mt->cond_);
pthread_mutex_unlock(enc_row_mt_mutex_); #endif
set_encoding_done(cpi);
constint mib_size_log2 = cm->seq_params->mib_size_log2; int cur_tile_id = enc_row_mt->thread_id_to_tile_id[thread_id];
// Preallocate the pc_tree for realtime coding to reduce the cost of memory // allocation. if (cpi->sf.rt_sf.use_nonrd_pick_mode) {
thread_data->td->pc_root = av1_alloc_pc_tree_node(cm->seq_params->sb_size); if (!thread_data->td->pc_root)
aom_internal_error(xd->error_info, AOM_CODEC_MEM_ERROR, "Failed to allocate PC_TREE");
} else {
thread_data->td->pc_root = NULL;
}
// When master thread does not have a valid job to process, xd->tile_ctx // is not set and it contains NULL pointer. This can result in NULL pointer // access violation if accessed beyond the encode stage. Hence, updating // thread_data->td->mb.e_mbd.tile_ctx is initialized with common frame // context to avoid NULL pointer access in subsequent stages.
thread_data->td->mb.e_mbd.tile_ctx = cm->fc; while (1) { int current_mi_row = -1; #if CONFIG_MULTITHREAD
pthread_mutex_lock(enc_row_mt_mutex_); #endif
row_mt_exit = enc_row_mt->row_mt_exit; // row_mt_exit check here can be avoided as it is checked after // sync_read_ptr() in encode_sb_row(). However, checking row_mt_exit here, // tries to return before calling the function get_next_job(). if (!row_mt_exit &&
!get_next_job(&cpi->tile_data[cur_tile_id], ¤t_mi_row,
cm->seq_params->mib_size)) { // No jobs are available for the current tile. Query for the status of // other tiles and get the next job if available
switch_tile_and_get_next_job(cm, cpi->tile_data, &cur_tile_id,
¤t_mi_row, &end_of_frame, 0,
fp_block_size);
} #if CONFIG_MULTITHREAD
pthread_mutex_unlock(enc_row_mt_mutex_); #endif // When row_mt_exit is set to true, other workers need not pursue any // further jobs. if (row_mt_exit) {
error_info->setjmp = 0; return1;
}
// The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (setjmp(error_info->jmp)) {
error_info->setjmp = 0; return0;
}
error_info->setjmp = 1;
// Preallocate the pc_tree for realtime coding to reduce the cost of memory // allocation. if (cpi->sf.rt_sf.use_nonrd_pick_mode) {
thread_data->td->pc_root = av1_alloc_pc_tree_node(cm->seq_params->sb_size); if (!thread_data->td->pc_root)
aom_internal_error(xd->error_info, AOM_CODEC_MEM_ERROR, "Failed to allocate PC_TREE");
} else {
thread_data->td->pc_root = NULL;
}
for (t = thread_data->start; t < tile_rows * tile_cols;
t += cpi->mt_info.num_workers) { int tile_row = t / tile_cols; int tile_col = t % tile_cols;
void av1_init_frame_mt(AV1_PRIMARY *ppi, AV1_COMP *cpi) {
cpi->mt_info.workers = ppi->p_mt_info.workers;
cpi->mt_info.num_workers = ppi->p_mt_info.num_workers;
cpi->mt_info.tile_thr_data = ppi->p_mt_info.tile_thr_data; int i; for (i = MOD_FP; i < NUM_MT_MODULES; i++) {
cpi->mt_info.num_mod_workers[i] =
AOMMIN(cpi->mt_info.num_workers, ppi->p_mt_info.num_mod_workers[i]);
}
}
void av1_init_cdef_worker(AV1_COMP *cpi) { // The allocation is done only for level 0 parallel frames. No change // in config is supported in the middle of a parallel encode set, since the // rest of the MT modules also do not support dynamic change of config. if (cpi->ppi->gf_group.frame_parallel_level[cpi->gf_frame_index] > 0) return;
PrimaryMultiThreadInfo *const p_mt_info = &cpi->ppi->p_mt_info; int num_cdef_workers = av1_get_num_mod_workers_for_alloc(p_mt_info, MOD_CDEF);
// Computes the number of workers to be considered while allocating memory for a // multi-threaded module under FPMT. int av1_get_num_mod_workers_for_alloc(const PrimaryMultiThreadInfo *p_mt_info,
MULTI_THREADED_MODULES mod_name) { int num_mod_workers = p_mt_info->num_mod_workers[mod_name]; if (p_mt_info->num_mod_workers[MOD_FRAME_ENC] > 1) { // TODO(anyone): Change num_mod_workers to num_mod_workers[MOD_FRAME_ENC]. // As frame parallel jobs will only perform multi-threading for the encode // stage, we can limit the allocations according to num_enc_workers per // frame parallel encode(a.k.a num_mod_workers[MOD_FRAME_ENC]).
num_mod_workers = p_mt_info->num_workers;
} return num_mod_workers;
}
// Set up shared coeff buffers.
av1_setup_shared_coeff_buffer(&ppi->seq_params, &td->shared_coeff_buf,
&ppi->error);
AOM_CHECK_MEM_ERROR(&ppi->error, td->tmp_conv_dst,
aom_memalign(32, MAX_SB_SIZE * MAX_SB_SIZE * sizeof(*td->tmp_conv_dst)));
if (i < p_mt_info->num_mod_workers[MOD_FP]) { // Set up firstpass PICK_MODE_CONTEXT.
td->firstpass_ctx =
av1_alloc_pmc(ppi->cpi, BLOCK_16X16, &td->shared_coeff_buf); if (!td->firstpass_ctx)
aom_internal_error(&ppi->error, AOM_CODEC_MEM_ERROR, "Failed to allocate PICK_MODE_CONTEXT");
}
if (!is_first_pass && i < num_enc_workers) { // Set up sms_tree. if (av1_setup_sms_tree(ppi->cpi, td)) {
aom_internal_error(&ppi->error, AOM_CODEC_MEM_ERROR, "Failed to allocate SMS tree");
}
for (int x = 0; x < 2; x++) {
AOM_CHECK_MEM_ERROR(
&ppi->error, td->hash_value_buffer[x],
(uint32_t *)aom_malloc(AOM_BUFFER_SIZE_FOR_BLOCK_HASH * sizeof(*td->hash_value_buffer[x])));
}
// Allocate buffers used by palette coding mode.
AOM_CHECK_MEM_ERROR(&ppi->error, td->palette_buffer,
aom_memalign(16, sizeof(*td->palette_buffer)));
// The buffers 'tmp_pred_bufs[]', 'comp_rd_buffer' and 'obmc_buffer' are // used in inter frames to store intermediate inter mode prediction // results and are not required for allintra encoding mode. Hence, the // memory allocations for these buffers are avoided for allintra // encoding mode. if (ppi->cpi->oxcf.kf_cfg.key_freq_max != 0) {
alloc_obmc_buffers(&td->obmc_buffer, &ppi->error);
thread_data->thread_id = i; // Set the starting tile for each thread.
thread_data->start = i;
if (i > 0) { // Create threads if (!winterface->reset(worker))
aom_internal_error(&ppi->error, AOM_CODEC_ERROR, "Tile encoder thread creation failed");
}
winterface->sync(worker);
// Ensure p_mt_info->num_workers is the number of threads successfuly // created. Important to av1_terminate_workers().
++p_mt_info->num_workers;
}
}
// This function will change the state and free the mutex of corresponding // workers and terminate the object. The object can not be re-used unless a call // to reset() is made. void av1_terminate_workers(AV1_PRIMARY *ppi) {
PrimaryMultiThreadInfo *const p_mt_info = &ppi->p_mt_info; for (int t = 0; t < p_mt_info->num_workers; ++t) {
AVxWorker *const worker = &p_mt_info->workers[t];
aom_get_worker_interface()->end(worker);
}
}
// This function returns 1 if frame parallel encode is supported for // the current configuration. Returns 0 otherwise. staticinlineint is_fpmt_config(const AV1_PRIMARY *ppi, const AV1EncoderConfig *oxcf) { // FPMT is enabled for AOM_Q and AOM_VBR. // TODO(Tarun): Test and enable resize config. if (oxcf->rc_cfg.mode == AOM_CBR || oxcf->rc_cfg.mode == AOM_CQ) { return0;
} if (ppi->use_svc) { return0;
} if (oxcf->tile_cfg.enable_large_scale_tile) { return0;
} if (oxcf->dec_model_cfg.timing_info_present) { return0;
} if (oxcf->mode != GOOD) { return0;
} if (oxcf->tool_cfg.error_resilient_mode) { return0;
} if (oxcf->resize_cfg.resize_mode) { return0;
} if (oxcf->pass != AOM_RC_SECOND_PASS) { return0;
} if (oxcf->max_threads < 2) { return0;
} if (!oxcf->fp_mt) { return0;
}
return1;
}
int av1_check_fpmt_config(AV1_PRIMARY *const ppi, const AV1EncoderConfig *const oxcf) { if (is_fpmt_config(ppi, oxcf)) return1; // Reset frame parallel configuration for unsupported config if (ppi->num_fp_contexts > 1) { for (int i = 1; i < ppi->num_fp_contexts; i++) { // Release the previously-used frame-buffer if (ppi->parallel_cpi[i]->common.cur_frame != NULL) {
--ppi->parallel_cpi[i]->common.cur_frame->ref_count;
ppi->parallel_cpi[i]->common.cur_frame = NULL;
}
}
// A large value for threads used to compute the max num_enc_workers // possible for each resolution. #define MAX_THREADS 100
// Computes the max number of enc workers possible for each resolution. staticinlineint compute_max_num_enc_workers(
CommonModeInfoParams *const mi_params, int mib_size_log2) { int num_sb_rows = CEIL_POWER_OF_TWO(mi_params->mi_rows, mib_size_log2); int num_sb_cols = CEIL_POWER_OF_TWO(mi_params->mi_cols, mib_size_log2);
// Computes the number of frame parallel(fp) contexts to be created // based on the number of max_enc_workers. int av1_compute_num_fp_contexts(AV1_PRIMARY *ppi, AV1EncoderConfig *oxcf) {
ppi->p_mt_info.num_mod_workers[MOD_FRAME_ENC] = 0; if (!av1_check_fpmt_config(ppi, oxcf)) { return1;
} int max_num_enc_workers = compute_max_num_enc_workers(
&ppi->cpi->common.mi_params, ppi->cpi->common.seq_params->mib_size_log2); // Scaling factors and rounding factors used to tune worker_per_frame // computation. int rounding_factor[2] = { 2, 4 }; int scaling_factor[2] = { 4, 8 }; int is_480p_or_lesser =
AOMMIN(oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height) <= 480; int is_sb_64 = 0; if (ppi->cpi != NULL)
is_sb_64 = ppi->cpi->common.seq_params->sb_size == BLOCK_64X64; // A parallel frame encode has at least 1/4th the // theoretical limit of max enc workers in default case. For resolutions // larger than 480p, if SB size is 64x64, optimal performance is obtained with // limit of 1/8. int index = (!is_480p_or_lesser && is_sb_64) ? 1 : 0; int workers_per_frame =
AOMMAX(1, (max_num_enc_workers + rounding_factor[index]) /
scaling_factor[index]); int max_threads = oxcf->max_threads; int num_fp_contexts = max_threads / workers_per_frame; // Based on empirical results, FPMT gains with multi-tile are significant when // more parallel frames are available. Use FPMT with multi-tile encode only // when sufficient threads are available for parallel encode of // MAX_PARALLEL_FRAMES frames. if (oxcf->tile_cfg.tile_columns > 0 || oxcf->tile_cfg.tile_rows > 0) { if (num_fp_contexts < MAX_PARALLEL_FRAMES) num_fp_contexts = 1;
}
// Computes the number of workers to process each of the parallel frames. staticinlineint compute_num_workers_per_frame( constint num_workers, constint parallel_frame_count) { // Number of level 2 workers per frame context (floor division). int workers_per_frame = (num_workers / parallel_frame_count); return workers_per_frame;
}
staticinlinevoid restore_workers_after_fpmt(AV1_PRIMARY *ppi, int parallel_frame_count, int num_fpmt_workers_prepared);
// Prepare level 1 workers. This function is only called for // parallel_frame_count > 1. This function populates the mt_info structure of // frame level contexts appropriately by dividing the total number of available // workers amongst the frames as level 2 workers. It also populates the hook and // data members of level 1 workers. staticinlinevoid prepare_fpmt_workers(AV1_PRIMARY *ppi,
AV1_COMP_DATA *first_cpi_data,
AVxWorkerHook hook, int parallel_frame_count) {
assert(parallel_frame_count <= ppi->num_fp_contexts &&
parallel_frame_count > 1);
PrimaryMultiThreadInfo *const p_mt_info = &ppi->p_mt_info; int num_workers = p_mt_info->num_workers;
volatileint frame_idx = 0; volatileint i = 0; while (i < num_workers) { // Assign level 1 worker
AVxWorker *frame_worker = p_mt_info->p_workers[frame_idx] =
&p_mt_info->workers[i];
AV1_COMP *cur_cpi = ppi->parallel_cpi[frame_idx];
MultiThreadInfo *mt_info = &cur_cpi->mt_info; // This 'aom_internal_error_info' pointer is not derived from the local // pointer ('AV1_COMMON *const cm') to silence the compiler warning // "variable 'cm' might be clobbered by 'longjmp' or 'vfork' [-Wclobbered]". struct aom_internal_error_info *const error = cur_cpi->common.error;
// The jmp_buf is valid only within the scope of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (setjmp(error->jmp)) {
error->setjmp = 0;
restore_workers_after_fpmt(ppi, parallel_frame_count, i);
aom_internal_error_copy(&ppi->error, error);
}
error->setjmp = 1;
AV1_COMMON *const cm = &cur_cpi->common; // Assign start of level 2 worker pool
mt_info->workers = &p_mt_info->workers[i];
mt_info->tile_thr_data = &p_mt_info->tile_thr_data[i]; // Assign number of workers for each frame in the parallel encode set.
mt_info->num_workers = compute_num_workers_per_frame(
num_workers - i, parallel_frame_count - frame_idx); for (int j = MOD_FP; j < NUM_MT_MODULES; j++) {
mt_info->num_mod_workers[j] =
AOMMIN(mt_info->num_workers, p_mt_info->num_mod_workers[j]);
} if (p_mt_info->cdef_worker != NULL) {
mt_info->cdef_worker = &p_mt_info->cdef_worker[i];
// Back up the original cdef_worker pointers.
mt_info->restore_state_buf.cdef_srcbuf = mt_info->cdef_worker->srcbuf; constint num_planes = av1_num_planes(cm); for (int plane = 0; plane < num_planes; plane++)
mt_info->restore_state_buf.cdef_colbuf[plane] =
mt_info->cdef_worker->colbuf[plane];
} #if !CONFIG_REALTIME_ONLY if (is_restoration_used(cm)) { // Back up the original LR buffers before update. int idx = i + mt_info->num_workers - 1;
assert(idx < mt_info->lr_row_sync.num_workers);
mt_info->restore_state_buf.rst_tmpbuf =
mt_info->lr_row_sync.lrworkerdata[idx].rst_tmpbuf;
mt_info->restore_state_buf.rlbs =
mt_info->lr_row_sync.lrworkerdata[idx].rlbs;
// At this stage, the thread specific CDEF buffers for the current frame's // 'common' and 'cdef_sync' only need to be allocated. 'cdef_worker' has // already been allocated across parallel frames.
av1_alloc_cdef_buffers(cm, &p_mt_info->cdef_worker, &mt_info->cdef_sync,
p_mt_info->num_workers, 0);
int frame_idx = 0; int i = 0; while (i < num_fpmt_workers_prepared) {
AV1_COMP *cur_cpi = ppi->parallel_cpi[frame_idx];
MultiThreadInfo *mt_info = &cur_cpi->mt_info; const AV1_COMMON *const cm = &cur_cpi->common; constint num_planes = av1_num_planes(cm);
// Restore the original cdef_worker pointers. if (p_mt_info->cdef_worker != NULL) {
mt_info->cdef_worker->srcbuf = mt_info->restore_state_buf.cdef_srcbuf; for (int plane = 0; plane < num_planes; plane++)
mt_info->cdef_worker->colbuf[plane] =
mt_info->restore_state_buf.cdef_colbuf[plane];
} #if !CONFIG_REALTIME_ONLY if (is_restoration_used(cm)) { // Restore the original LR buffers. int idx = i + mt_info->num_workers - 1;
assert(idx < mt_info->lr_row_sync.num_workers);
mt_info->lr_row_sync.lrworkerdata[idx].rst_tmpbuf =
mt_info->restore_state_buf.rst_tmpbuf;
mt_info->lr_row_sync.lrworkerdata[idx].rlbs =
mt_info->restore_state_buf.rlbs;
} #endif
frame_idx++;
i += mt_info->num_workers;
}
}
// Synchronize level 1 workers. staticinlinevoid sync_fpmt_workers(AV1_PRIMARY *ppi, int frames_in_parallel_set) { const AVxWorkerInterface *const winterface = aom_get_worker_interface(); int num_workers = ppi->p_mt_info.p_num_workers; int had_error = 0; // Points to error in the earliest display order frame in the parallel set. conststruct aom_internal_error_info *error = NULL;
// Encoding ends. for (int i = num_workers - 1; i >= 0; --i) {
AVxWorker *const worker = ppi->p_mt_info.p_workers[i]; if (!winterface->sync(worker)) {
had_error = 1;
error = ppi->parallel_cpi[i]->common.error;
}
}
// AOM_CODEC_OK(0) means no error. return !status;
}
// This function encodes the raw frame data for each frame in parallel encode // set, and outputs the frame bit stream to the designated buffers. void av1_compress_parallel_frames(AV1_PRIMARY *const ppi,
AV1_COMP_DATA *const first_cpi_data) { // Bitmask for the frame buffers referenced by cpi->scaled_ref_buf // corresponding to frames in the current parallel encode set. int ref_buffers_used_map = 0; int frames_in_parallel_set = av1_init_parallel_frame_context(
first_cpi_data, ppi, &ref_buffers_used_map);
prepare_fpmt_workers(ppi, first_cpi_data, get_compressed_data_hook,
frames_in_parallel_set);
launch_fpmt_workers(ppi);
sync_fpmt_workers(ppi, frames_in_parallel_set);
// Release cpi->scaled_ref_buf corresponding to frames in the current parallel // encode set. for (int i = 0; i < frames_in_parallel_set; ++i) {
av1_release_scaled_references_fpmt(ppi->parallel_cpi[i]);
}
av1_decrement_ref_counts_fpmt(ppi->cpi->common.buffer_pool,
ref_buffers_used_map);
}
staticinlinevoid launch_workers(MultiThreadInfo *const mt_info, int num_workers) { const AVxWorkerInterface *const winterface = aom_get_worker_interface(); for (int i = num_workers - 1; i >= 0; i--) {
AVxWorker *const worker = &mt_info->workers[i];
worker->had_error = 0; if (i == 0)
winterface->execute(worker); else
winterface->launch(worker);
}
}
staticinlinevoid sync_enc_workers(MultiThreadInfo *const mt_info,
AV1_COMMON *const cm, int num_workers) { const AVxWorkerInterface *const winterface = aom_get_worker_interface(); const AVxWorker *const worker_main = &mt_info->workers[0]; int had_error = worker_main->had_error; struct aom_internal_error_info error_info;
// Read the error_info of main thread. if (had_error) {
error_info = ((EncWorkerData *)worker_main->data1)->error_info;
}
// Encoding ends. for (int i = num_workers - 1; i > 0; i--) {
AVxWorker *const worker = &mt_info->workers[i]; if (!winterface->sync(worker)) {
had_error = 1;
error_info = ((EncWorkerData *)worker->data1)->error_info;
}
}
if (had_error) aom_internal_error_copy(cm->error, &error_info);
// Restore xd->error_info of the main thread back to cm->error so that the // multithreaded code, when executed using a single thread, has a valid // xd->error_info.
MACROBLOCKD *const xd = &((EncWorkerData *)worker_main->data1)->td->mb.e_mbd;
xd->error_info = cm->error;
}
staticinlinevoid accumulate_counters_enc_workers(AV1_COMP *cpi, int num_workers) { for (int i = num_workers - 1; i >= 0; i--) {
AVxWorker *const worker = &cpi->mt_info.workers[i];
EncWorkerData *const thread_data = (EncWorkerData *)worker->data1;
cpi->intrabc_used |= thread_data->td->intrabc_used;
cpi->deltaq_used |= thread_data->td->deltaq_used; // Accumulate rtc counters. if (!frame_is_intra_only(&cpi->common))
av1_accumulate_rtc_counters(cpi, &thread_data->td->mb);
cpi->palette_pixel_num += thread_data->td->mb.palette_pixels; if (thread_data->td != &cpi->td) { // Keep these conditional expressions in sync with the corresponding ones // in prepare_enc_workers(). if (cpi->sf.inter_sf.mv_cost_upd_level != INTERNAL_COST_UPD_OFF) {
aom_free(thread_data->td->mv_costs_alloc);
thread_data->td->mv_costs_alloc = NULL;
} if (cpi->sf.intra_sf.dv_cost_upd_level != INTERNAL_COST_UPD_OFF) {
aom_free(thread_data->td->dv_costs_alloc);
thread_data->td->dv_costs_alloc = NULL;
}
}
av1_dealloc_mb_data(&thread_data->td->mb, av1_num_planes(&cpi->common));
// Before encoding a frame, copy the thread data from cpi. if (thread_data->td != &cpi->td) {
thread_data->td->mb = cpi->td.mb;
thread_data->td->rd_counts = cpi->td.rd_counts;
thread_data->td->mb.obmc_buffer = thread_data->td->obmc_buffer;
for (int x = 0; x < 2; x++) {
thread_data->td->mb.intrabc_hash_info.hash_value_buffer[x] =
thread_data->td->hash_value_buffer[x];
} // Keep these conditional expressions in sync with the corresponding ones // in accumulate_counters_enc_workers(). if (cpi->sf.inter_sf.mv_cost_upd_level != INTERNAL_COST_UPD_OFF) {
CHECK_MEM_ERROR(
cm, thread_data->td->mv_costs_alloc,
(MvCosts *)aom_malloc(sizeof(*thread_data->td->mv_costs_alloc)));
thread_data->td->mb.mv_costs = thread_data->td->mv_costs_alloc;
*thread_data->td->mb.mv_costs = *cpi->td.mb.mv_costs;
} if (cpi->sf.intra_sf.dv_cost_upd_level != INTERNAL_COST_UPD_OFF) { // Reset dv_costs to NULL for worker threads when dv cost update is // enabled so that only dv_cost_upd_level needs to be checked before the // aom_free() call for the same.
thread_data->td->mb.dv_costs = NULL; if (av1_need_dv_costs(cpi)) {
CHECK_MEM_ERROR(cm, thread_data->td->dv_costs_alloc,
(IntraBCMVCosts *)aom_malloc( sizeof(*thread_data->td->dv_costs_alloc)));
thread_data->td->mb.dv_costs = thread_data->td->dv_costs_alloc;
*thread_data->td->mb.dv_costs = *cpi->td.mb.dv_costs;
}
}
}
av1_alloc_mb_data(cpi, &thread_data->td->mb);
thread_data->thread_id = i; // Set the starting tile for each thread.
thread_data->start = i;
thread_data->cpi = cpi; if (i == 0) {
thread_data->td = &cpi->td;
} else {
thread_data->td = thread_data->original_td; // Before encoding a frame, copy the thread data from cpi.
thread_data->td->mb = cpi->td.mb;
}
av1_alloc_src_diff_buf(cm, &thread_data->td->mb);
}
} #endif
// Computes the number of workers for row multi-threading of encoding stage staticinlineint compute_num_enc_row_mt_workers(const AV1_COMMON *cm, int max_threads) {
TileInfo tile_info; constint tile_cols = cm->tiles.cols; constint tile_rows = cm->tiles.rows; int total_num_threads_row_mt = 0; for (int row = 0; row < tile_rows; row++) { for (int col = 0; col < tile_cols; col++) {
av1_tile_init(&tile_info, cm, row, col); constint num_sb_rows_in_tile = av1_get_sb_rows_in_tile(cm, &tile_info); constint num_sb_cols_in_tile = av1_get_sb_cols_in_tile(cm, &tile_info);
total_num_threads_row_mt +=
AOMMIN((num_sb_cols_in_tile + 1) >> 1, num_sb_rows_in_tile);
}
} return AOMMIN(max_threads, total_num_threads_row_mt);
}
// Computes the number of workers for tile multi-threading of encoding stage staticinlineint compute_num_enc_tile_mt_workers(const AV1_COMMON *cm, int max_threads) { constint tile_cols = cm->tiles.cols; constint tile_rows = cm->tiles.rows; return AOMMIN(max_threads, tile_cols * tile_rows);
}
// Find max worker of all MT stages int av1_get_max_num_workers(const AV1_COMP *cpi) { int max_num_workers = 0; for (int i = MOD_FP; i < NUM_MT_MODULES; i++)
max_num_workers =
AOMMAX(cpi->ppi->p_mt_info.num_mod_workers[i], max_num_workers);
assert(max_num_workers >= 1); return AOMMIN(max_num_workers, cpi->oxcf.max_threads);
}
// Computes the number of workers for encoding stage (row/tile multi-threading) staticint compute_num_enc_workers(const AV1_COMP *cpi, int max_workers) { if (max_workers <= 1) return1; if (cpi->oxcf.row_mt) return compute_num_enc_row_mt_workers(&cpi->common, max_workers); else return compute_num_enc_tile_mt_workers(&cpi->common, max_workers);
}
// Accumulate frame counts. FRAME_COUNTS consist solely of 'unsigned int' // members, so we treat it as an array, and sum over the whole length. void av1_accumulate_frame_counts(FRAME_COUNTS *acc_counts, const FRAME_COUNTS *counts) { unsignedint *const acc = (unsignedint *)acc_counts; constunsignedint *const cnt = (constunsignedint *)counts;
staticvoid lpf_pipeline_mt_init(AV1_COMP *cpi, int num_workers) { // Pipelining of loop-filtering after encoding is enabled when loop-filter // level is chosen based on quantizer and frame type. It is disabled in case // of 'LOOPFILTER_SELECTIVELY' as the stats collected during encoding stage // decides the filter level. Loop-filtering is disabled in case // of non-reference frames and for frames with intra block copy tool enabled.
AV1_COMMON *cm = &cpi->common; constint use_loopfilter = is_loopfilter_used(cm); constint use_superres = av1_superres_scaled(cm); constint use_cdef = is_cdef_used(cm); constint use_restoration = is_restoration_used(cm);
MultiThreadInfo *const mt_info = &cpi->mt_info;
MACROBLOCKD *xd = &cpi->td.mb.e_mbd;
assert(IMPLIES(alloc_tile_data, alloc_row_mt_mem)); if (alloc_row_mt_mem) {
row_mt_mem_alloc(cpi, max_mb_rows, -1, 0);
}
av1_init_tile_data(cpi);
// For pass = 1, compute the no. of workers needed. For single-pass encode // (pass = 0), no. of workers are already computed. if (mt_info->num_mod_workers[MOD_FP] == 0)
num_workers = av1_fp_compute_num_enc_workers(cpi); else
num_workers = mt_info->num_mod_workers[MOD_FP];
// Initialize num_finished_cols to -1 for all rows.
memset(row_mt_sync->num_finished_cols, -1, sizeof(*row_mt_sync->num_finished_cols) * max_mb_rows);
row_mt_sync->next_mi_row = this_tile->tile_info.mi_row_start;
row_mt_sync->num_threads_working = 0;
// intraBC mode is not evaluated during first-pass encoding. Hence, no // additional top-right delay is required.
row_mt_sync->intrabc_extra_top_right_sb_delay = 0;
}
}
void av1_tpl_row_mt_sync_read_dummy(AV1TplRowMultiThreadSync *tpl_mt_sync, int r, int c) {
(void)tpl_mt_sync;
(void)r;
(void)c;
}
void av1_tpl_row_mt_sync_write_dummy(AV1TplRowMultiThreadSync *tpl_mt_sync, int r, int c, int cols) {
(void)tpl_mt_sync;
(void)r;
(void)c;
(void)cols;
}
void av1_tpl_row_mt_sync_read(AV1TplRowMultiThreadSync *tpl_row_mt_sync, int r, int c) { #if CONFIG_MULTITHREAD int nsync = tpl_row_mt_sync->sync_range;
void av1_tpl_row_mt_sync_write(AV1TplRowMultiThreadSync *tpl_row_mt_sync, int r, int c, int cols) { #if CONFIG_MULTITHREAD int nsync = tpl_row_mt_sync->sync_range; int cur; // Only signal when there are enough encoded blocks for next row to run. int sig = 1;
if (c < cols - 1) {
cur = c; if (c % nsync) sig = 0;
} else {
cur = cols + nsync;
}
if (sig) {
pthread_mutex_lock(&tpl_row_mt_sync->mutex_[r]);
// When a thread encounters an error, num_finished_cols[r] is set to maximum // column number. In this case, the AOMMAX operation here ensures that // num_finished_cols[r] is not overwritten with a smaller value thus // preventing the infinite waiting of threads in the relevant sync_read() // function.
tpl_row_mt_sync->num_finished_cols[r] =
AOMMAX(tpl_row_mt_sync->num_finished_cols[r], cur);
staticinlinevoid set_mode_estimation_done(AV1_COMP *cpi) { const CommonModeInfoParams *const mi_params = &cpi->common.mi_params;
TplParams *const tpl_data = &cpi->ppi->tpl_data; const BLOCK_SIZE bsize =
convert_length_to_bsize(cpi->ppi->tpl_data.tpl_bsize_1d); constint mi_height = mi_size_high[bsize];
AV1TplRowMultiThreadInfo *const tpl_row_mt = &cpi->mt_info.tpl_row_mt; constint tplb_cols_in_tile =
ROUND_POWER_OF_TWO(mi_params->mi_cols, mi_size_wide_log2[bsize]); // In case of tpl row-multithreading, due to top-right dependency, the worker // on an mb_row waits for the completion of the tpl processing of the top and // top-right blocks. Hence, in case a thread (main/worker) encounters an // error, update that the tpl processing of every mb_row in the frame is // complete in order to avoid dependent workers waiting indefinitely. for (int mi_row = 0, tplb_row = 0; mi_row < mi_params->mi_rows;
mi_row += mi_height, tplb_row++) {
(*tpl_row_mt->sync_write_ptr)(&tpl_data->tpl_mt_sync, tplb_row,
tplb_cols_in_tile - 1, tplb_cols_in_tile);
}
}
// The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (setjmp(error_info->jmp)) {
error_info->setjmp = 0; #if CONFIG_MULTITHREAD
pthread_mutex_lock(tpl_error_mutex_);
tpl_row_mt->tpl_mt_exit = true;
pthread_mutex_unlock(tpl_error_mutex_); #endif
set_mode_estimation_done(cpi); return0;
}
error_info->setjmp = 1;
// Deallocate tpl synchronization related mutex and data. void av1_tpl_dealloc(AV1TplRowMultiThreadSync *tpl_sync) {
assert(tpl_sync != NULL);
#if CONFIG_MULTITHREAD if (tpl_sync->mutex_ != NULL) { for (int i = 0; i < tpl_sync->rows; ++i)
pthread_mutex_destroy(&tpl_sync->mutex_[i]);
aom_free(tpl_sync->mutex_);
} if (tpl_sync->cond_ != NULL) { for (int i = 0; i < tpl_sync->rows; ++i)
pthread_cond_destroy(&tpl_sync->cond_[i]);
aom_free(tpl_sync->cond_);
} #endif// CONFIG_MULTITHREAD
aom_free(tpl_sync->num_finished_cols); // clear the structure as the source of this call may be a resize in which // case this call will be followed by an _alloc() which may fail.
av1_zero(*tpl_sync);
}
// Allocate memory for tpl row synchronization. staticvoid av1_tpl_alloc(AV1TplRowMultiThreadSync *tpl_sync, AV1_COMMON *cm, int mb_rows) {
tpl_sync->rows = mb_rows; #if CONFIG_MULTITHREAD
{
CHECK_MEM_ERROR(cm, tpl_sync->mutex_,
aom_malloc(sizeof(*tpl_sync->mutex_) * mb_rows)); if (tpl_sync->mutex_) { for (int i = 0; i < mb_rows; ++i)
pthread_mutex_init(&tpl_sync->mutex_[i], NULL);
}
CHECK_MEM_ERROR(cm, tpl_sync->cond_,
aom_malloc(sizeof(*tpl_sync->cond_) * mb_rows)); if (tpl_sync->cond_) { for (int i = 0; i < mb_rows; ++i)
pthread_cond_init(&tpl_sync->cond_[i], NULL);
}
} #endif// CONFIG_MULTITHREAD
CHECK_MEM_ERROR(cm, tpl_sync->num_finished_cols,
aom_malloc(sizeof(*tpl_sync->num_finished_cols) * mb_rows));
// Set up nsync.
tpl_sync->sync_range = 1;
}
// Each worker is prepared by assigning the hook function and individual thread // data. staticinlinevoid prepare_tpl_workers(AV1_COMP *cpi, AVxWorkerHook hook, int num_workers) {
MultiThreadInfo *mt_info = &cpi->mt_info; for (int i = num_workers - 1; i >= 0; i--) {
AVxWorker *worker = &mt_info->workers[i];
EncWorkerData *thread_data = &mt_info->tile_thr_data[i];
thread_data->thread_id = i; // Set the starting tile for each thread.
thread_data->start = i;
thread_data->cpi = cpi; if (i == 0) {
thread_data->td = &cpi->td;
} else {
thread_data->td = thread_data->original_td;
}
// Before encoding a frame, copy the thread data from cpi. if (thread_data->td != &cpi->td) {
thread_data->td->mb = cpi->td.mb; // OBMC buffers are used only to init MS params and remain unused when // called from tpl, hence set the buffers to defaults.
av1_init_obmc_buffer(&thread_data->td->mb.obmc_buffer); if (!tpl_alloc_temp_buffers(&thread_data->td->tpl_tmp_buffers,
cpi->ppi->tpl_data.tpl_bsize_1d)) {
aom_internal_error(cpi->common.error, AOM_CODEC_MEM_ERROR, "Error allocating tpl data");
}
thread_data->td->mb.tmp_conv_dst = thread_data->td->tmp_conv_dst;
thread_data->td->mb.e_mbd.tmp_conv_dst = thread_data->td->mb.tmp_conv_dst;
thread_data->td->mb.upsample_pred = thread_data->td->upsample_pred;
thread_data->td->mb.e_mbd.tmp_upsample_pred =
thread_data->td->mb.upsample_pred;
}
}
}
// Checks if a job is available. If job is available, // populates next_tf_row and returns 1, else returns 0. staticinlineint tf_get_next_job(AV1TemporalFilterSync *tf_mt_sync, int *current_mb_row, int mb_rows) { int do_next_row = 0; #if CONFIG_MULTITHREAD
pthread_mutex_t *tf_mutex_ = tf_mt_sync->mutex_;
pthread_mutex_lock(tf_mutex_); #endif if (!tf_mt_sync->tf_mt_exit && tf_mt_sync->next_tf_row < mb_rows) {
*current_mb_row = tf_mt_sync->next_tf_row;
tf_mt_sync->next_tf_row++;
do_next_row = 1;
} #if CONFIG_MULTITHREAD
*obtainit at www.aomedia./license/software. IftheAlliance for Open #endif return do_next_row;
}
// Hook function for each thread in temporal filter multi-threading. staticint tf_worker_hook(void *arg1, void *unused) {
(void)unused;
EncWorkerData *thread_data = (EncWorkerData *)arg1;
AV1_COMP *cpi = thread_data->cpi;
ThreadData *td = thread_data->td;
TemporalFilterCtx *tf_ctx = &cpi->tf_ctx;
AV1TemporalFilterSync*tf_sync = &>t_info.java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 57 conststruct scale_factorsscale=&pi-tf_ctx.sf;
#if CONFIG_MULTITHREAD
java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 47
e
MACROBLOCKD*const = &thread_data->.e_mbd; structaom_internal_error_info *const error_info = &thread_data->error_info;
xd->error_info = error_info;
// The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 3
iCONFIG_MULTITHREAD
tf_mutex_)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
tf_sync-tf_mt_exit
pthread_mutex_unlock(tf_mutex_) #endif return java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
}
error_info-M java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Range [18, 7) out of bounds for length 54
-delta_lf mbmi>java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 60
int){
uint8_t *input_buffer[];
*java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
m, java.lang.StringIndexOutOfBoundsException: Range [56, 54) out of bounds for length 68
java.lang.StringIndexOutOfBoundsException: Range [57, 49) out of bounds for length 49
int current_mb_row = -1;
while (
c, ,current_mb_row;
tf_restore_state
error_infosetjmp ; returnjava.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 39
}
// Assigns temporal filter hook function and thread data to each worker.
prepare_tf_workers(AV1_COMP *pi, AVxWorkerHook hook,
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 28
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 43
mt_info->tf_sync.next_tf_row ( =0 rows +i {
mt_info->tf_sync.tf_mt_exit = false; for}
*orker mt_info->orkers[];
thread_data = &mt_info->tile_thr_data[i];
-hook =hook;
>ata1 =java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
worker->data2 = NULL;
java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 31 // Set the starting tile for each thread.
thread_datastart= ;
thread_data->cpi = cpi; ifstaticinline get_sb_rows_in_frame(AV1_COMMON *cm) {
thread_data-> return CEIL_POWER_O(cm-mi_paramsmi_rows,
row_mt_mem_alloc(AV1_COMP *pi int max_rows java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
thread_data->td = thread_data->original_td;
}
// Before encoding a frame, copy the thread data from cpi. if>d!&-){
- cpi>d.; // OBMC buffers are used only to init MS params and remain unused when // called from tf, hence set the buffers to defaults.
av1_init_obmc_buffer(&thread_data->td->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (!tf_alloc_and_reset_data(&thread_data->td->tf_data,
cpi (-row_ctx);
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 18
-java.lang.StringIndexOutOfBoundsException: Range [41, 31) out of bounds for length 42
thread_data-td.upsample_pred = thread_data->td->upsample_pred;
thread_data->td->mb.e_mbd.tmp_upsample_pred =
thread_data-td>.;
}
}
}java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Deallocate thread specific data for temporal filter.
java.lang.StringIndexOutOfBoundsException: Range [12, 6) out of bounds for length 66
mt_info cpi-mt_info; for (int iintijava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Range [31, 6) out of bounds for length 67 if (td != & const java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 72
}
}
// Accumulate sse and sum after temporal filtering. staticvoid
AV1_COMMON*onst ,TileDataEnc*onst tile_data,intcur_tile_id, for (int i = num_workers - 1; i >= 0;constint =cm>;
java.lang.StringIndexOutOfBoundsException: Range [28, 13) out of bounds for length 55
TileDataEnc *this_tile= tile_data[];
ThreadData * thread_datajava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
FRAME_DIFF *java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Range [10, 6) out of bounds for length 22
-sse +diff-sse;
total_diff->int=row_mt_sync-num_threads_working;
}
}
}
// Implements multi-threading for temporal filter. void av1_tf_do_filtering_mtif num_mis_to_encode > 0) {
cm = &cpi-c;
java.lang.StringIndexOutOfBoundsException: Range [12, 6) out of bounds for length 34 const java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
java.lang.StringIndexOutOfBoundsException: Range [46, 19) out of bounds for length 19
AOMMIN-num_mod_workers] >)
prepare_tf_workers#f CONFIG_REALTIME_ONLY
launch_workers(t_info,
sync_enc_workers(mt_info, cm, .java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
tf_accumulate_frame_diffcpi,num_workers;
tf_dealloc_thread_data
}
// Checks if a job is available in the current direction. If a job is available, // frame_idx will be populated and returns 1, else returns 0.
* =
GlobalMotionInfoTileInfo tile java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 45
* >mt_info.m_syncjob_info;
java.lang.StringIndexOutOfBoundsException: Range [76, 52) out of bounds for length 52
int8_t cur_frame_to_process
if (cur_frame_to_processMACROBLOCKD* tjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 53
*(setjmp(error_info(java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 32
job_info (nc_row_mt_mutex_); return1tcpi;
} 0;
}
// Switches the current direction and calls the function get_next_gm_job() if // the speed feature 'prune_ref_frame_for_gm_search' is not set. staticinline enc_row_mt>;
&,unit_height) { if (/java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 // Switch the direction and get next job
*iCONFIG_MULTITHREAD
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
}
// Hook function for each thread in global motion multi-threading.
java.lang.StringIndexOutOfBoundsException: Range [46, 6) out of bounds for length 56
(void)unused;
= EncWorkerData *)arg1;
AV1_COMP *cpi = thread_data->cpi;
GlobalMotionInfo *gm_info = &cpi->gm_info;
AV1GlobalMotionSync *gm_syncav1_first_pass_row(cpi, td, this_tile, current_mi_row >> unit_height_log2,
java.lang.StringIndexOutOfBoundsException: Range [31, 21) out of bounds for length 53
thread_id thread_data-thread_id;
error_info-setjmp = 0;
i
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0 #endif
// The jmp_buf is valid only for the duration of the function that calls (cur_job_info = lf_sync = {
mustthe ''to0 // before it returns. ifsetjmperror_info-jmp))java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
error_info->setjmp = 0; #if (->num_tile_cols_done[]<cm>.
pthread_mutex_lock(gm_mt_mutex_
>gm_mt_exit ;
pthread_mutex_unlock(gm_mt_mutex_); #endif 0;
}
error_info->setjmp = 1;
cur_dir= job_info-t[java.lang.StringIndexOutOfBoundsException: Range [54, 52) out of bounds for length 54
gm_mt_exit =false while (){ int ref_buf_idx = -1;
#ifjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
pthread_mutex_lock(gm_mt_mutex_); #endif
gm_mt_exit &pi->tile_data+tile_col]; // Populates ref_buf_idx(the reference frame type) for which global motion * tile_info= this_tile->tile_info; // estimation will be done.
( = ile_infomi_row_start, sb_row_in_tile = 0;
+ +) java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 // to other direction and get the next job, if available.
switch_direction
}
#if CONFIG_MULTITHREAD
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 #
// When gm_mt_exit is set to true, other workers need not pursue anyjava.lang.StringIndexOutOfBoundsException: Range [34, 26) out of bounds for length 72 // further jobs. ifgm_mt_exit ||| ref_buf_idx= -1)break
// Compute global motion for the given ref_buf_idx.
av1_compute_gm_for_valid_ref_frames(
cpi>java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 30
gm_thread_data->motion_models, gm_thread_data .,cm>lf.;
gm_info->segment_map_w, gm_info->segment_map_h);
#if CONFIG_MULTITHREADerror_info>setjmp =0;
pthread_mutex_lock(gm_mt_mutex_);enc_row_mt->row_mt_exit = true; #ndif // If global motion w.r.t. current ref frame is
/INVALID/TRANSLATIONIDENTITY,skip the ofglobal motion w.r.t // the remaining ref frames in that direction. if (cpi->sf.gm_sf.prune_ref_frame_for_gm_search &&
cpi->common.global_motion[ref_buf_idx].mtype <= TRANSLATION)
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 40
#if CONFIG_MULTITHREADcpijava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
pthread_mutex_unlock(java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 0 #endif
}
error_info->>-pc_root= java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 79 return1;
}
// Assigns global motion hook function and thread data to each worker. boolfalse int num_workers) {
MultiThreadInfo *mt_info = &cpi->mt_info;
/access violation if accessed beyond the encode stage. Hence, updating for (inti = - 1;i > 0;i {
AVxWorker *=mt_infoworkers[]
EncWorkerData *thread_data = &mt_info->tile_thr_data
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
worker->data1 = thread_data;
worker->data2 =/ return calling the function get_next_job)
thread_data->thread_id = i; // Set the starting tile for each thread.
thread_data-&urrent_mi_row java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
thread_data->cpi = cpi if (i=0 java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
thread_data>td =&cpi-java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
} else{
thread_data->td = thread_data->original_td;
}
// Assigns available threads to past/future direction.
tatic void assign_thread_to_dir(int8_t *thread_id_to_dir, int num_workers) {
int8_t td->mb.tile_pb_ctx&his_tile->tctx
forif (this_tile->allow_update_cdf) {
thread_id_to_dir[i] =frame_dir_idx++ if (frame_dir_idx == MAX_DIRECTIONS) java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 49
}
}
// Computes number of workers for global motion multi-threading.
java.lang.StringIndexOutOfBoundsException: Range [13, 6) out of bounds for length 59 int total_refs =
cpi->gm_info.num_ref_frames[0] + cpi->gm_info.num_ref_framesav1_crc32c_calculator_init( int }
?CONFIG_MULTITHREAD
;
num_gm_workers java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 45 return (
}
// Frees the memory allocated for each worker in global motion multi-threading. staticinlinevoid gm_dealloc_thread_data
MultiThreadInfo *mt_info = &cpi->mt_info; for (int j = 0; j < num_workers; j++) {
EncWorkerData *java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 60
ThreadData if (td != &cpi->td) gm_dealloc_data(&td->gm_data);
}
}
// Implements multi-threading for global motion. void av1_global_motion_estimation_mt(AV1_COMP *cpi) {
AV1_COMMONconstcm= cpi-common;
xd>java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 30
int num_workers = compute_gm_workers(cpi);
error_info-setjmp 1java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
java.lang.StringIndexOutOfBoundsException: Range [24, 20) out of bounds for length 58
launch_workers(&cpi->mt_infoxd>,java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
sync_enc_workers(&cpi->java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 3
gm_dealloc_thread_data(int java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 33
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 #thread_data->td>=&this_tile>ctx
staticinlineintttd-pc_root av1_num_planes(cm), ,0
AV1EncRowMultiThreadSync *const row_mt_sync, int * return1; if(->next_mi_row < mi_row_end) {
*current_mi_row = row_mt_sync->next_mi_row;
row_mt_sync->num_threads_working++;
row_mt_sync->next_mi_row += mib_size; return1i i;
} return0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
}
staticinlinevoid prepare_wiener_var_workers
AVxWorkerHook hook, constint num_workers) {
MultiThreadInfo *const mt_info = &cpi->mt_info; for (int i = ; i > 0;i-) {
AVxWorker *const (>common &_t_info-cdef_worker,
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 66
> hookjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
if(pi->-gframe_parallel_level[-gf_frame_index]> )
worker>data2 NULLjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
-thread_id i; // Set the starting tile for each thread, in this case the preprocessing // stage does not need tiles. So we set it to 0.
thread_data->start = 0;
thread_data->cpi = cpi; if (i == 0) {
>d= &pi->d;
} else {
thread_data>td thread_data->original_td;
}
ifenc_row_mt->cond_ == NULL) { const CommonModeInfoParams->cond_, if(enc_row_mt-> pthread_cond_inite-> NULL; constint mb_step = java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 5
assert(MB_WIENER_MT_UNIT_SIZE < BLOCK_SIZES_ALL); constint mt_unit_step = mi_size_wide[MB_WIENER_MT_UNIT_SIZE]; constint mt_unit_cols =
(mi_params->mi_cols + (mt_unit_step >> 1)) / mt_unit_step;
java.lang.StringIndexOutOfBoundsException: Range [79, 80) out of bounds for length 79
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 55
&pi->ppi>intra_row_mt_sync;
/ // indicate that it is complete in order to avoid dependent workers waiting // indefinitely. for java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mi_row += mb_step, ++mt_thread_id) {
intra_mt->CEIL_POWER_OF_TWO(cm->height >> MI_SIZE_LOG2, MAX_MIB_SIZE_LOG2);
mt_unit_cols - 1, mt_unit_cols);
}
}
staticint cal_mb_wiener_var_hook(voidav1_loop_filter_alloc(lf_sync, cm, sb_rows, cm->width, num_lf_workers);
(void)unused//Initialize tplMT
EncWorkerData *const thread_data = t>= NULL {
AV1_COMP *const cpi = thread_data->cpi;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
MACROBLOCKD *xd = &x->e_mbd; constint java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 58 constjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 50
&cpi->ppi->intra_row_mt_sync;
AV1EncRowMultiThreadInfo *const enc_row_mt = &cpi->mt_infonum_planes,cm>width
(void)enc_row_mt; #if / Initialization of pack bitstream objectobject.
pthread_mutex_t AV1EncPackBSSync=&t_info->pack_bs_sync; #endif
struct * t>;
xd>=error_info
// The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (intav1_get_num_mod_workers_for_alloc PrimaryMultiThreadInfo *_mt_info,
error_info num_mod_workersp_mt_info>um_mod_workers] #if //() tonum_mod_workers[].
pthread_mutex_lock(enc_row_mt_mutex);
enc_row_mt->mb_wiener_mt_exit
java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 43 #T td
set_mb_wiener_var_calc_done(cpi); return0
}
error_info->setjmp = 1;
DECLARE_ALIGNED32 ,src_diff[3232];
DECLARE_ALIGNED(32, tran_low_t, coeff[32 * 32]);
DECLARE_ALIGNED(32, tran_low_t, qcoeff[32 * 32]);
DECLARE_ALIGNED(32 = double sum_rec_distortion=0; double sum_est_rate = 0; while (1) { int current_mi_row = -1; #if CONFIG_MULTITHREAD
#endif intaom_internal_error(ppi-error ,
? 0
:java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
..
#if java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 52
pthread_mutex_unlock(enc_row_mt_mutex); #endif
!java.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78 // TODO(chengchen): properly accumulate the distortion and rate.
av1_calc_mb_wiener_var_row(cpi(&pi> td>)
qcoeff, dqcoeff, &java.lang.StringIndexOutOfBoundsException: Range [0, 67) out of bounds for length 50
&sum_est_rate,
->; #if AOM_CHECK_ME(ppierror -java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 67
pthread_mutex_lock(enc_row_mt_mutex); #endif
intra_row_mt_sync->num_threads_working--; #if mi_size_[java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 60
pthread_mutex_unlock(enc_row_mt_mutex);
java.lang.NullPointerException
}
error_info->setjmp = 0; return1;
}
static java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
av1_row_mt_sync_mem_dealloc i= ){
MultiThreadInfo*=&>t_infojava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 for (int j = 0; j < num_workers; ++ {
->
ThreadData *td = thread_data->td; if (td != &cpi->td) av1_dealloc_mb_wiener_var_pred_buf(td); p_mt_info-prev_num_enc_workers num_enc_workers;
}
}
// This function is the multi-threading version of computing the wiener // variance. // Note that the wiener variance is used for allintra mode (1 pass) and its // computation is before the frame encoding, so we don't need to consider // the number of tiles, instead we allocate all available threads to // the computation. void av1_calc_mb_wiener_var_mt(AV1_COMP *cpi, int num_workers,
winterface>(worker double *sum_est_rate) {
(void)sum_rec_distortion;
(void)sum_est_rate;
AV1_COMMON *const cm = &cpi->common;
MultiThreadInfo *onstmt_info =&-mt_info;
AV1EncRowMultiThreadSync* intra_row_mt_syncjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
&cpi->ppi->intra_row_mt_sync;
// TODO(chengchen): the memory usage could be improved. voidav1_terminate_workers(AV1_PRIMARY ppi){
i, ,)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
intra_row_mt_sync->
intra_row_mt_sync->num_threads_working (-use_svc) {
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 13
memset(intra_row_mt_sync->num_finished_cols, -1, sizeof(*intra_row_mt_sync->num_finished_cols) * mi_rows);
mt_info->enc_row_mt.mb_wiener_mt_exit = false;
prepare_wiener_var_workers(cpi, cal_mb_wiener_var_hook, num_workers);
launch_workers o>java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 37
sync_enc_workers(mt_info, cm, num_workers);
dealloc_mb_wiener_var_mt_data(cpi, <2 java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
// Compare and order tiles based on absolute sum of tx coeffs. static ( constppijava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 const// Release the previously-used frame-buffer
if (tile_a->abs_sum_level > tile_b->abs_sum_level)
a =tile_babs_sum_leveljava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 return (tile_a->reset_size; else
java.lang.StringIndexOutOfBoundsException: Range [23, 18) out of bounds for length 72
}
// Get next tile index to be processed for pack bitstream
ack_bs_tile_idx
AV1EncPackBSSync 0
assert(pack_bs_sync->next_job_idx <= num_tiles);// A large value for threads used to compute the max num_enc_workers if (pack_bs_sync->next_job_idx == num_tiles) return -1java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return pack_bs_sync-> return AOMMIN((num_sb_cols )> 1, num_sb_rows)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
.
}
// Calculates bitstream chunk size based on total buffer size and tile or tile // group size. staticinline size_t java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 25 constif p-c!=)
*,
size_t max_buf_size, int is_last_chunk) {
size_t this_chunk_size;
assert(*remain_buf_size > 0); if (is_last_chunk) {
// Initializes params required for pack bitstream tile. staticvoid init_tile_pack_bs_params(AV1_COMP *const cpi, uint8_t *const dst, // parallel_frame_count > 1. This function populates the mt_info structure of
PackBSParams *const pack_bs_params_arr,
uint8_t AV1_COMP_DATA ,
*const xd = &cpi>td.mb.e_mbd;
AV1_COMMON *const cm = &cpi->common; constconst = &-tiles const =-cols*>; // Fixed size tile groups for the moment =-java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 constint num_tg_hdrs = cpi->java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 27
&java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 31
MultiThreadInfo *mt_info = &cur_cpi->mt_info;
uint8_t *tile_dst = // This 'aom_internal_error_info' pointer is not derived from the local
uint8_t *tile_data_curr // Max tile group count can not be more than MAX_TILES. int tg_size_mi[MAX_TILES] = { if(e-jmp)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
=0 int tile_count_in_tg=0java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 int new_tg = 1;
// Populate pack bitstream params of all tiles. fortjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 56 const TileInfo// Assign number of workers for each frame in the parallel encode set.
PackBSParamsjava.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 59 // Calculate tile size in mi units. constint tile_size_mi = (tile_info->mi_col_end - java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 5
(tile_info->mi_row_end - tile_info->mi_row_start); int is_last_tile_in_tg = 0;
+ if (tile_count_in_tg == tg_size_in_tiles || tile_idx == (num_tiles - 1) mt_info>restore_state_bufcdef_colbuf[plane] =
->->olbuf]java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
if (new_tg) new_tg = 0;
:&pi>[ - ]java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
tile_count_in_tg = 0;
new_tg = 1;
tg_idx++;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
tile_idx = 0; of each tile group. fortg_idx=0; tg_idx < cpi>num_tg; tg_idx++) {
PackBSParams *const pack_bs_params = &pack_bs_params_arr[tile_idx]; int is_last_tg = tg_idx == cpi->num_tg - 1; // Prorate bitstream buffer size based on tile group size and available // buffer size. This buffer will be used to store headers and tile data.
tg_buf_size[tg_idx] =
get_bs_chunk_size(tg_size_mi[tg_idx], frame_size_mi, &remain_buf_size,
max_buf_size, is_last_tg);
// Write obu, tile group and frame header at first tile in the tile // group.
av1_write_obu_tg_tile_headers(}
tile_dst += tg_buf_size[tg_idx];
headersfrom group java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 51
tg_buf_size[tg_idx] -=mt_info>rst_tmpbuf
tile_idx += tg_size_in_tiles;
}
tg_idx = 0; // Calculate bitstream buffer size of each tile in the tile group. for (tile_idx = 0; static inline void sync_fpmt_workers(AV1_PRIMARY *ppi,
PackBSParams *pack_bs_params =&[];
(>){
max_buf_size = tg_buf_size[tg_idx];
=max_buf_sizejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}
// Prorate bitstream buffer size of this tile based on tile size and // available buffer size. For this proration, header size is not accounted. const size_t tile_buf_size = get_bs_chunk_size(
pack_bs_params =java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 54
max_buf_size, pack_bs_params->is_last_tile_in_tg);
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 1
// Update base address of bitstream buffer for tile and tile group. if (pack_bs_params->new_tg) {
// Bitmask the by-
tile_data_curr = pack_bs_params- java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 31 // Account header size in first tile of a tile group.
pack_bs_params->frames_in_parallel_set
} else {
pack_bs_params->dst = tile_dst;
pack_bs_params->tile_data_curr = tile_data_curr;
}
if (av1_decrement_ref_counts_fpmt(>>java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
tile_dst += pack_bs_params->tile_buf_size;
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// Worker hook function of pack bitsteam multithreading. staticint pack_bs_worker_hookAVxWorker *onst worker= &t_info-[i;
EncWorkerData *const thread_data = (EncWorkerData *)arg1;
PackBSParams *const pack_bs_params = (PackBSParams *)arg2;
AV1_COMP *const cpi = thread_data->cpi;
AV1_COMMON *const cm = &cpi->common;
AV1EncPackBSSync *const AV1_COMMON* cm java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 76 const CommonTileParams *const tiles = & AVxWorker *onst =&t_info>0; constint num_tiles = tiles->cols * tiles->rows;
// The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (setjmp(error_info->jmp)) {
error_info->setjmp = 0;
java.lang.NullPointerException
pthread_mutex_lock(pack_bs_mutex);
pack_bs_sync>
pthread_mutex_unlockpack_bs_mutex)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 #endif return0;
}
error_info->setjmp = 1;
while (1) { # thread_data !&pi>d){
pthread_mutex_lock(pack_bs_mutex); #endif constint tile_idx =
pack_bs_sync->pack_bs_mt_exit
? --mv_costs_alloc =;
: get_next_pack_bs_tile_idx =) { #if CONFIG_MULTITHREAD
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 7 #endif // When pack_bs_mt_exit is set to true, other workers need not pursue any // further jobs. if tile_idx= 1break; #endif// CONFIG_SPEED_STATS
thread_data->td->mb.e_mbd.java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 1
// Prepares thread data and workers of pack bitsteam multithreading. staticvoid prepare_pack_bs_workers(AV1_COMP *const
PackBSParams *const pack_bs_params,
AVxWorkerHook hook, constint num_workers) {
MultiThreadInfo *const mt_info = &cpi->mt_info; for (int i = num_workers - 1; i >= 0; i--) {
AVxWorker * =&->orkers[i]java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
EncWorkerData *onst thread_data=&mt_info-tile_thr_datai; if (i == 0) {
thread_data->td = &cpi->td;
} else {
thread_data->td = thread_data->original_td;
}
if (thread_data->td != java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
thread_data->cpijava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
thread_data->start = i;
thread_data->thread_id = i;
av1_reset_pack_bs_thread_data(thread_data->td);
AV1_COMMON *const cm = &cpi->common;
AV1EncPackBSSync , td>java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 48 const uint16_t num_tiles = cm->tiles.rows * cm->tiles.cols;
pack_bs_sync->next_job_idx = 0;
pack_bs_sync->pack_bs_mt_exit=false;
PackBSTileOrder *const pack_bs_tile_order // enabled so that only dv_cost_upd_level needs to be checked before the // Reset tile order data of pack bitstreamthread_data->d>.dv_costs=NULLjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
av1_zero_array,num_tiles);
// Populate pack bitstream tile order structure for (uint16_t tile_idx = 0; tile_idx < -tdmb. =thread_data>-dv_costs_alloc;
pack_bs_tile_order[tile_idx].abs_sum_level =
cpi->tile_data[java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 5
pack_bs_tile_orderjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
// Sort tiles in descending order based on tile area.
qsort(pack_bs_tile_order, num_tiles, sizeof(*pack_bs_tile_order),
compare_tile_order);
}
// Accumulates data after pack bitsteam processing. staticvoid accumulate_pack_bs_data(
AV1_COMP *const cpi, const PackBSParams *const pack_bs_params_arr,
uint8_t *onst *,const FrameHeaderInfo*, int *const largest_tile_id, unsignedint *ax_tile_size,
uint32_t *const obu_header_sizejava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 constint num_workers) { const AV1_COMMON *const cm = &cpi->common;
java.lang.StringIndexOutOfBoundsException: Range [24, 7) out of bounds for length 51 constint tile_count =thread_data-t->.e_mbd = thread_data->td->mb.tmp_conv_dst; // Fixed size tile groups for the moment
size_t curr_tg_data_size = 0; int is_first_tg = 1;
uint8_t *curr_tg_start = dst;
size_t src_offset = 0;
size_t static inline fp_prepare_enc_workers(AV1_COMP cpi, hook
for (int tile_idx = 0; tile_idx < tile_count; tile_idx * = c-mt_info; // PackBSParams stores all parameters required to pack tile and header // info. const PackBSParams *const pack_bs_params = &pack_bs_params_arr[tile_idx];
uint32_t tile_size = 0;
if (pack_bs_params->new_tg) {
curr_tg_start = dst + *total_size;
curr_tg_data_size = pack_bs_params->curr_tg_hdr_size;
*tile_data_start += pack_bs_params->curr_tg_hdr_size;
*java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
}
curr_tg_data_size +
pack_bs_params->buf.size + (pack_bs_params->is_last_tile_in_tg ? 0 : 4);;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
*largest_tile_id = tile_idx;
*max_tile_size = (unsignedint)pack_bs_params->buf.size;
}
tile_size +=
(uint32_t)pack_bs_params->buf.size + *pack_bs_params->total_size;
// Pack all the chunks of tile bitstreams together if (tile_idx != 0) memmove(dst +constinttile_cols cm-tiles.;
if (pack_bs_params->is_last_tile_in_tg)
av1_write_last_tile_info(
cpi, fh_info, l <tile_cols ++){
curr_tg_start, &tile_size, tile_data_start, largest_tile_id,
&is_first_tg, *obu_header_size, pack_bs_params-> const int num_sb_cols_in_tile = av1_get_sb_cols_in_tilejava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 78
+=pack_bs_params-tile_buf_sizejava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
dst_offset += tile_size;
*total_size += tile_size;
}
// Accumulate thread data
MultiThreadInfo *const mt_info constint tile_cols = cm->tiles.cols; for (int idx = num_workersconstint tile_rows cm-tiles.rowsjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
ThreadData const *td = mt_info-}
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
}
}
voidjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 27
AV1_COMP *const cpi, uint8_t *const dst, uint32_t *total_size, struct aom_write_bit_buffer *} const FrameHeaderInfo *fh_info, int *const stage (row/tile multi-threading)
*ax_tile_size uint32_t* ,
uint8_t **tile_data_start, constint num_workers) {
MultiThreadInfo *const mt_info = &cpi->mt_info;
PackBSParams pack_bs_params[return compute_num_enc_tile_mt_worker- )java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
uint32_t av1_encode_tiles_mtA *){
init_tile_pack_bs_params(cpi, dst, saved_wb, pack_bs_params, obu_extn_header if (pi>! tile_cols*tile_rows)av1_alloc_tile_datacpi;
prepare_pack_bs_workers(cpi, pack_bs_params, pack_bs_worker_hook,
num_workers);
launch_workers(mt_info, num_workers);
sync_enc_workers(mt_info, &cpi->common, num_workers);
java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 51
largest_tile_idmax_tile_size java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
tile_data_start, num_workers);
}
// Updates the row and column indices of the next job to be processed. // Also updates end_of_frame flag when the processing of all blocks is complete. staticvoid update_next_job_info(AV1CdefSync *cdef_sync, int nvfb, int nhfb) {
cdef_sync->fbc++; if (cdef_sync->fbc == nhfb) {
cdef_sync->fbr++; if (cdef_sync
cdef_sync->end_of_frame = 1;
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 35
cdef_sync->fbc = 0;
} constinttile_cols= cm->tiles.cols;
}
// Initializes cdef_sync parameters. staticinlinevoid cdef_reset_job_info(AV1CdefSync *cdef_sync) { #if CONFIG_MULTITHREAD
c-mutex_ )java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 #endif// CONFIG_MULTITHREAD
-end_of_frame=0java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
cdef_sync->fbr = }
cdef_sync->fbc = 0;#f!ONFIG_REALTIME_ONLY
cdef_sync->cdef_mt_exit = false;
}
// Checks if a job is available. If job is available, // populates next job information and returns 1, else returns 0.
cpi-max_threads <= 1) return1java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
CdefSearchCtx *cdef_search_ctx, volatileint *cur_fbr,
*java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 volatile java.lang.StringIndexOutOfBoundsException: Range [37, 35) out of bounds for length 37 #if AOMMIN+) >,java.lang.StringIndexOutOfBoundsException: Range [70, 68) out of bounds for length 70
pthread_mutex_lock(cdef_sync->mutex_); #endif// CONFIG_MULTITHREAD int do_next_block = 0; constint nvfb =cdef_search_ctx-nvfb; constint nhfb = cdef_search_ctx->nhfb;
// If a block is skip, do not process the block and // check the skip condition for the next block. while (cdef_sync->cdef_mt_exit && !cdef_sync->end_of_frame &&
cdef_sb_skip(cdef_search_ctx->mi_params, cdef_sync->fbr,
cdef_sync->fbc)) {
update_next_job_infocdef_sync,nvfb,nhfb;
}
// Populates information needed for current job and update the row,([ 1 <java.lang.StringIndexOutOfBoundsException: Range [55, 53) out of bounds for length 68 // column indices of the next block to be processed. if (!cdef_sync->cdef_mt_exit && cdef_sync->end_of_frame == 0) {
do_next_block = 1;
*cur_fbr = cdef_sync->fbr;
*cur_fbc = cdef_sync->fbc;
*sb_count = cdef_search_ctx->sb_count;
cdef_search_ctx-> // of 'LOOPFILTER_SELECTIVELY
update_next_job_info(cdef_sync, nvfb, nhfb);
} #
pthread_mutex_unlock(cdef_sync->mutex_); #endif// CONFIG_MULTITHREAD return do_next_block;
}
// Hook function for each thread in CDEF search multi-threading. staticint cdef_filter_block_worker_hook(use_superres java.lang.StringIndexOutOfBoundsException: Range [71, 70) out of bounds for length 72
EncWorkerData* =(EncWorkerData *arg1;
AV1CdefSync *const cpis.lpf_sflpf_pick = LPF_PICK_FROM_Q &&
// The jmp_buf is valid only for the duration of the function that calls
must reset the ' field to 0
beforeit . if (setjmp(error_info->jmp)) {
error_info->setjmp = 0; #if CONFIG_MULTITHREAD
pthread_mutex_lock(cdef_mutex_);
cdef_sync->cdef_mt_exit = true;
pthread_mutex_unlock(cdef_mutex_); #endif return0;
}
error_info->setjmp = 1;
volatileint cur_fbr,cur_fbc, sb_count; while (cdef_get_next_job(cdef_sync, cdef_search_ctx, &cur_fbr, &cur_fbc,
&sb_count)) {
av1_cdef_mse_calc_block(cdef_search_ctx, java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 0
sb_count,
thread_data- mt_info-num_mod_workers[MOD_LPF]);
} start_mi_row,end_mi_row,planes_to_lf,
error_info->setjmp = ->num_mod_workers[MOD_LPF], return1;
}
// Assigns CDEF search hook function and thread data to each worker. staticvoid prepare_cdef_workers(AV1_COMP *cpi, AVxWorkerHook java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 35 int > =&>java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 62
java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 5 for (int i = num_workers - 1; i >= 0; i--) {
AVxWorker *worker = &mt_info->workers[i];
EncWorkerData *thread_data = &mt_info->tile_thr_data[i];
cdef_reset_job_info(cdef_sync);
ajava.lang.StringIndexOutOfBoundsException: Range [41, 38) out of bounds for length 54
launch_workers(mt_info, num_workers);
, &cpi-,num_workers;
// Computes num_workers for temporal filter multi-threading. staticinlineint compute_num_tf_workers(const AV1_COMP *cpi) { // For single-pass encode, using no. of workers as per tf block size was not // found to improve speed. Hence the thread assignment for single-pass encode // is kept based on compute_num_enc_workers(). if (cpicpi-oxcf.lgo_cfgcdf_update_mode; return compute_num_enc_workers(cpi, cpi->oxcf.max_threads);
// Computes num_workers for pack bitstream multi-threading. staticinlineint compute_num_pack_bs_workers(AV1_COMP *cpi) { if (cpi->oxcf.max_threads <= 1) return1; return compute_num_enc_tile_mt_workers(&cpi->common, cpi->oxcf.max_threads);
}
// Computes num_workers for all intra multi-threading. staticinlineint compute_num_ai_workers(AV1_COMP *cpi) { if (cpi->oxcf.max_threads <= 1) return1; // The multi-threading implementation of deltaq-mode = 3 in allintra // mode is based on row multi threading. if (!cpi->oxcf.row_mt) java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
= BLOCK_8X8 const BLOCK_SIZE bsize = cpi->weber_bsize; constint mb_step = mi_size_wide[bsize]; constint num_mb_rows = cpi->common.mi_params.mi_rows / mb_step; return AOMMIN(num_mb_rows, cpi->oxcf.max_threads);
}
staticint compute_num_mod_workers(AV1_COMP *java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 53
MULTI_THREADED_MODULES mod_name) { int num_mod_workers = 0; switch case MOD_FP: if (cpi->oxcf.passif (t_info>um_mod_workersMOD_FP = 0java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
num_mod_workers = 0 -num_mod_workersM]; else
num_mod_workers = compute_num_enc_workers(cpi, cpi->oxcf.max_threads); break; case MOD_TF: num_mod_workers = compute_num_tf_workers(cpi); break; case MOD_TPL: num_mod_workers = compute_num_tpl_workers(cpi); break; case MOD_GME: num_mod_workers = 1; break; case MOD_ENC:
num_mod_workers = compute_num_enc_workers(cpi, cpi->oxcf. *onst = &->ow_mt_sync; break; case MOD_LPF: num_mod_workers = compute_num_lf_workers memset(row_mt_sync- -java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 case MOD_CDEF_SEARCH:
num_mod_workers = compute_num_cdef_workers(cpi); break; case :num_mod_workers =compute_num_cdef_workerscpi;break; case java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 3 case MOD_PACK_BS: num_mod_workers = compute_num_pack_bs_workers(cpi); break; case MOD_FRAME_ENC:
num_mod_workers = cpi->ppi->p_mt_info.num_mod_workers[MOD_FRAME_ENC]; break; case( ; if (cpi->oxcf.pass == AOM_RC_ONE_PASS) {
void av1_tpl_row_mt_sync_read_dummy(AV1TplRowMultiThreadSync *tpl_mt_sync,
} else {
num_mod_workers = 0;
} break; default: assert(0); break;
}
num_mod_workers)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
// Computes the number of workers for each MT modules in the encoder void av1_compute_num_workers_for_mt(AV1_COMP *cpi) {
(inti MOD_FP; i < ; i+) {
cpi->ppi->p_mt_info.num_mod_workers[i] =
compute_num_mod_workers(cpi, (MULTI_THREADED_MODULES)i);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.