const int mi_alloc_size_1d = mi_size_wide[mi_params->mi_alloc_bsize]; const int mi_alloc_rows =
(mi_params->mi_rows + mi_alloc_size_1d - 1) / mi_alloc_size_1d; const int mi_alloc_cols =
(mi_params->mi_cols + mi_alloc_size_1d - 1) / mi_alloc_size_1d; const int new_ext_mi_size = mi_alloc_rows * mi_alloc_cols;
if (new_ext_mi_size > mbmi_ext_info->alloc_size) {
dealloc_context_buffers_ext(mbmi_ext_info);
CHECK_MEM_ERROR(
cm, mbmi_ext_info->frame_base,
aom_malloc(new_ext_mi_size * sizeof(*mbmi_ext_info->frame_base)));
mbmi_ext_info->alloc_size = new_ext_mi_size;
} // The stride needs to be updated regardless of whether new allocation // happened or not.
mbmi_ext_info->stride = mi_alloc_cols;
}
if (!is_stat_generation_stage(cpi)) av1_alloc_txb_buf(cpi);
aom_free(cpi->td.mv_costs_alloc);
cpi->td.mv_costs_alloc = NULL; // Avoid the memory allocation of 'mv_costs_alloc' for allintra encoding // mode.
if (cpi->oxcf.kf_cfg.key_freq_max != 0) {
CHECK_MEM_ERROR(cm, cpi->td.mv_costs_alloc,
(MvCosts *)aom_calloc(1, sizeof(*cpi->td.mv_costs_alloc)));
cpi->td.mb.mv_costs = cpi->td.mv_costs_alloc;
}
av1_setup_shared_coeff_buffer(cm->seq_params, &cpi->td.shared_coeff_buf,
cm->error);
if (av1_setup_sms_tree(cpi, &cpi->td)) {
aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR, "Failed to allocate SMS tree");
}
cpi->td.firstpass_ctx =
av1_alloc_pmc(cpi, BLOCK_16X16, &cpi->td.shared_coeff_buf);
if (!cpi->td.firstpass_ctx)
aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR, "Failed to allocate PICK_MODE_CONTEXT");
}
// Allocate mbmi buffers which are used to store mode information at block // level. static inline void alloc_mb_mode_info_buffers(AV1_COMP *const cpi) {
AV1_COMMON *const cm = &cpi->common;
if (av1_alloc_context_buffers(cm, cm->width, cm->height,
cpi->sf.part_sf.default_min_partition_size)) {
aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR, "Failed to allocate context buffers");
}
if (!is_stat_generation_stage(cpi))
alloc_context_buffers_ext(cm, &cpi->mbmi_ext_info);
}
// Create the encoder segmentation map and set all entries to 0
aom_free(cpi->enc_seg.map);
CHECK_MEM_ERROR(cm, cpi->enc_seg.map,
aom_calloc(mi_params->mi_rows * mi_params->mi_cols, 1));
// Create a map used for cyclic background refresh.
if (cpi->cyclic_refresh) av1_cyclic_refresh_free(cpi->cyclic_refresh);
CHECK_MEM_ERROR(
cm, cpi->cyclic_refresh,
av1_cyclic_refresh_alloc(mi_params->mi_rows, mi_params->mi_cols));
// Create a map used to mark inactive areas.
aom_free(cpi->active_map.map);
CHECK_MEM_ERROR(cm, cpi->active_map.map,
aom_calloc(mi_params->mi_rows * mi_params->mi_cols, 1));
}
const int is_highbitdepth = cpi->tf_ctx.is_highbitdepth; // This call ensures that the buffers allocated by tf_alloc_and_reset_data() // in av1_temporal_filter() for single-threaded encode are freed in case an // error is encountered during temporal filtering (due to early termination // tf_dealloc_data() in av1_temporal_filter() would not be invoked).
tf_dealloc_data(&cpi->td.tf_data, is_highbitdepth);
// This call ensures that tpl_tmp_buffers for single-threaded encode are freed // in case of an error during tpl.
tpl_dealloc_temp_buffers(&cpi->td.tpl_tmp_buffers);
// This call ensures that the global motion (gm) data buffers for // single-threaded encode are freed in case of an error during gm.
gm_dealloc_data(&cpi->td.gm_data);
// This call ensures that CDEF search context buffers are deallocated in case // of an error during cdef search.
av1_cdef_dealloc_data(cpi->cdef_search_ctx);
aom_free(cpi->cdef_search_ctx);
cpi->cdef_search_ctx = NULL;
if (aom_realloc_frame_buffer(
&cpi->scaled_source, scaled_width, scaled_height,
cm->seq_params->subsampling_x, cm->seq_params->subsampling_y,
cm->seq_params->use_highbitdepth, AOM_BORDER_IN_PIXELS,
cm->features.byte_alignment, NULL, NULL, NULL, cpi->alloc_pyramid, 0))
aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR, "Failed to reallocate scaled source buffer");
assert(cpi->scaled_source.y_crop_width == scaled_width);
assert(cpi->scaled_source.y_crop_height == scaled_height);
if (!av1_resize_and_extend_frame_nonnormative(
cpi->unscaled_source, &cpi->scaled_source,
(int)cm->seq_params->bit_depth, num_planes))
aom_internal_error(cm->error, AOM_CODEC_MEM_ERROR, "Failed to reallocate buffers during resize"); return &cpi->scaled_source;
}
// Deallocate allocated thread_data. static inline void free_thread_data(AV1_PRIMARY *ppi) {
PrimaryMultiThreadInfo *const p_mt_info = &ppi->p_mt_info; const int num_tf_workers =
AOMMIN(p_mt_info->num_mod_workers[MOD_TF], p_mt_info->num_workers); const int num_tpl_workers =
AOMMIN(p_mt_info->num_mod_workers[MOD_TPL], p_mt_info->num_workers); const int is_highbitdepth = ppi->seq_params.use_highbitdepth; const int num_planes = ppi->seq_params.monochrome ? 1 : MAX_MB_PLANE;
for (int t = 1; t < p_mt_info->num_workers; ++t) {
EncWorkerData *const thread_data = &p_mt_info->tile_thr_data[t];
thread_data->td = thread_data->original_td;
ThreadData *const td = thread_data->td;
if (!td) continue;
aom_free(td->tctx);
aom_free(td->palette_buffer);
aom_free(td->tmp_conv_dst);
aom_free(td->upsample_pred);
release_compound_type_rd_buffers(&td->comp_rd_buffer);
for (int j = 0; j < 2; ++j) {
aom_free(td->tmp_pred_bufs[j]);
}
aom_free(td->pixel_gradient_info);
aom_free(td->src_var_info_of_4x4_sub_blocks);
release_obmc_buffers(&td->obmc_buffer);
aom_free(td->vt64x64);
for (int x = 0; x < 2; x++) {
aom_free(td->hash_value_buffer[x]);
td->hash_value_buffer[x] = NULL;
}
aom_free(td->mv_costs_alloc);
td->mv_costs_alloc = NULL;
aom_free(td->dv_costs_alloc);
td->dv_costs_alloc = NULL;
aom_free(td->counts);
av1_free_pmc(td->firstpass_ctx, num_planes);
td->firstpass_ctx = NULL;
av1_free_shared_coeff_buffer(&td->shared_coeff_buf);
av1_free_sms_tree(td); // This call ensures that the buffers allocated by tf_alloc_and_reset_data() // in prepare_tf_workers() for MT encode are freed in case an error is // encountered during temporal filtering (due to early termination // tf_dealloc_thread_data() in av1_tf_do_filtering_mt() would not be // invoked).
if (t < num_tf_workers) tf_dealloc_data(&td->tf_data, is_highbitdepth); // This call ensures that tpl_tmp_buffers for MT encode are freed in case of // an error during tpl.
if (t < num_tpl_workers) tpl_dealloc_temp_buffers(&td->tpl_tmp_buffers); // This call ensures that the buffers in gm_data for MT encode are freed in // case of an error during gm.
gm_dealloc_data(&td->gm_data);
av1_dealloc_mb_data(&td->mb, num_planes);
aom_free(td->mb.sb_stats_cache);
td->mb.sb_stats_cache = NULL;
aom_free(td->mb.sb_fp_stats);
td->mb.sb_fp_stats = NULL; #if CONFIG_PARTITION_SEARCH_ORDER
aom_free(td->mb.rdcost);
td->mb.rdcost = NULL; #endif
av1_free_pc_tree_recursive(td->pc_root, num_planes, 0, 0, SEARCH_PARTITION);
td->pc_root = NULL;
av1_dealloc_mb_wiener_var_pred_buf(td);
aom_free(td);
thread_data->td = NULL;
thread_data->original_td = NULL;
}
}
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.