Optimizes updates of encoder block ptrs

Precalculated block ptrs do not need updates during encoding.
Set these at init stage.

Moved the allocation of 'mt_current_mb_col' (last encoded MB on each
row) to vp8_alloc_compressor_data(), so that it is correctly
reallocated when frame size is changing.

Change-Id: Idcdaa2d0cf3a7f782b7d888626b7cf22a4ffb5c1
This commit is contained in:
Attila Nagy 2012-04-24 15:17:28 +03:00
parent 0cdc046ff2
commit e66e9ddfb4
4 changed files with 26 additions and 18 deletions

View File

@ -641,10 +641,6 @@ static void init_encode_frame_mb_context(VP8_COMP *cpi)
vp8_build_block_offsets(x);
vp8_setup_block_dptrs(&x->e_mbd);
vp8_setup_block_ptrs(x);
xd->mode_info_context->mbmi.mode = DC_PRED;
xd->mode_info_context->mbmi.uv_mode = DC_PRED;

View File

@ -474,10 +474,6 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
vp8_build_block_offsets(mb);
vp8_setup_block_dptrs(mbd);
vp8_setup_block_ptrs(mb);
mbd->left_context = &cm->left_context;
mb->mvc = cm->fc.mvc;
@ -522,8 +518,6 @@ void vp8cx_create_encoder_threads(VP8_COMP *cpi)
vpx_memset(cpi->mb_row_ei, 0, sizeof(MB_ROW_COMP) * th_count);
CHECK_MEM_ERROR(cpi->en_thread_data,
vpx_malloc(sizeof(ENCODETHREAD_DATA) * th_count));
CHECK_MEM_ERROR(cpi->mt_current_mb_col,
vpx_malloc(sizeof(*cpi->mt_current_mb_col) * cm->mb_rows));
sem_init(&cpi->h_event_end_encoding, 0, 0);
@ -537,9 +531,14 @@ void vp8cx_create_encoder_threads(VP8_COMP *cpi)
for (ithread = 0; ithread < th_count; ithread++)
{
ENCODETHREAD_DATA * ethd = &cpi->en_thread_data[ithread];
ENCODETHREAD_DATA *ethd = &cpi->en_thread_data[ithread];
/* Setup block ptrs and offsets */
vp8_setup_block_ptrs(&cpi->mb_row_ei[ithread].mb);
vp8_setup_block_dptrs(&cpi->mb_row_ei[ithread].mb.e_mbd);
sem_init(&cpi->h_event_start_encoding[ithread], 0, 0);
ethd->ithread = ithread;
ethd->ptr1 = (void *)cpi;
ethd->ptr2 = (void *)&cpi->mb_row_ei[ithread];
@ -590,7 +589,6 @@ void vp8cx_remove_encoder_threads(VP8_COMP *cpi)
vpx_free(cpi->h_encoding_thread);
vpx_free(cpi->mb_row_ei);
vpx_free(cpi->en_thread_data);
vpx_free(cpi->mt_current_mb_col);
}
}
#endif

View File

@ -562,10 +562,6 @@ void vp8_first_pass(VP8_COMP *cpi)
vp8_build_block_offsets(x);
vp8_setup_block_dptrs(&x->e_mbd);
vp8_setup_block_ptrs(x);
/* set up frame new frame for intra coded blocks */
vp8_setup_intra_recon(new_yv12);
vp8cx_frame_init_quantizer(cpi);

View File

@ -11,6 +11,7 @@
#include "vpx_config.h"
#include "vp8/common/onyxc_int.h"
#include "vp8/common/blockd.h"
#include "onyx_int.h"
#include "vp8/common/systemdependent.h"
#include "quantize.h"
@ -359,6 +360,11 @@ static void dealloc_compressor_data(VP8_COMP *cpi)
vpx_free(cpi->mb.pip);
cpi->mb.pip = 0;
#if CONFIG_MULTITHREAD
vpx_free(cpi->mt_current_mb_col);
cpi->mt_current_mb_col = NULL;
#endif
}
static void enable_segmentation(VP8_COMP *cpi)
@ -1122,11 +1128,19 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
cpi->mt_sync_range = 8;
else
cpi->mt_sync_range = 16;
if (cpi->oxcf.multi_threaded > 1)
{
vpx_free(cpi->mt_current_mb_col);
CHECK_MEM_ERROR(cpi->mt_current_mb_col,
vpx_malloc(sizeof(*cpi->mt_current_mb_col) * cm->mb_rows));
}
#endif
vpx_free(cpi->tplist);
CHECK_MEM_ERROR(cpi->tplist, vpx_malloc(sizeof(TOKENLIST) * cpi->common.mb_rows));
CHECK_MEM_ERROR(cpi->tplist,
vpx_malloc(sizeof(TOKENLIST) * cpi->common.mb_rows));
}
@ -2032,6 +2046,10 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
cpi->mb.inter_bmode_costs = cpi->rd_costs.inter_bmode_costs;
cpi->mb.token_costs = cpi->rd_costs.token_costs;
/* setup block ptrs & offsets */
vp8_setup_block_ptrs(&cpi->mb);
vp8_setup_block_dptrs(&cpi->mb.e_mbd);
return cpi;
}