Merge "vp9_ethread: calculate and save the tok starting address for tiles"
This commit is contained in:
commit
7af927e324
@ -934,29 +934,21 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
|
|||||||
VP9_COMMON *const cm = &cpi->common;
|
VP9_COMMON *const cm = &cpi->common;
|
||||||
vp9_writer residual_bc;
|
vp9_writer residual_bc;
|
||||||
int tile_row, tile_col;
|
int tile_row, tile_col;
|
||||||
TOKENEXTRA *tok[4][1 << 6], *tok_end;
|
TOKENEXTRA *tok_end;
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
const int tile_cols = 1 << cm->log2_tile_cols;
|
const int tile_cols = 1 << cm->log2_tile_cols;
|
||||||
const int tile_rows = 1 << cm->log2_tile_rows;
|
const int tile_rows = 1 << cm->log2_tile_rows;
|
||||||
TOKENEXTRA *pre_tok = cpi->tok;
|
|
||||||
int tile_tok = 0;
|
|
||||||
|
|
||||||
vpx_memset(cm->above_seg_context, 0, sizeof(*cm->above_seg_context) *
|
vpx_memset(cm->above_seg_context, 0, sizeof(*cm->above_seg_context) *
|
||||||
mi_cols_aligned_to_sb(cm->mi_cols));
|
mi_cols_aligned_to_sb(cm->mi_cols));
|
||||||
|
|
||||||
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
|
|
||||||
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
|
|
||||||
int tile_idx = tile_row * tile_cols + tile_col;
|
|
||||||
tok[tile_row][tile_col] = pre_tok + tile_tok;
|
|
||||||
pre_tok = tok[tile_row][tile_col];
|
|
||||||
tile_tok = allocated_tokens(cpi->tile_data[tile_idx].tile_info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
|
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
|
||||||
for (tile_col = 0; tile_col < tile_cols; tile_col++) {
|
for (tile_col = 0; tile_col < tile_cols; tile_col++) {
|
||||||
int tile_idx = tile_row * tile_cols + tile_col;
|
int tile_idx = tile_row * tile_cols + tile_col;
|
||||||
tok_end = tok[tile_row][tile_col] + cpi->tok_count[tile_row][tile_col];
|
TOKENEXTRA *tok = cpi->tile_tok[tile_row][tile_col];
|
||||||
|
|
||||||
|
tok_end = cpi->tile_tok[tile_row][tile_col] +
|
||||||
|
cpi->tok_count[tile_row][tile_col];
|
||||||
|
|
||||||
if (tile_col < tile_cols - 1 || tile_row < tile_rows - 1)
|
if (tile_col < tile_cols - 1 || tile_row < tile_rows - 1)
|
||||||
vp9_start_encode(&residual_bc, data_ptr + total_size + 4);
|
vp9_start_encode(&residual_bc, data_ptr + total_size + 4);
|
||||||
@ -964,8 +956,8 @@ static size_t encode_tiles(VP9_COMP *cpi, uint8_t *data_ptr) {
|
|||||||
vp9_start_encode(&residual_bc, data_ptr + total_size);
|
vp9_start_encode(&residual_bc, data_ptr + total_size);
|
||||||
|
|
||||||
write_modes(cpi, &cpi->tile_data[tile_idx].tile_info,
|
write_modes(cpi, &cpi->tile_data[tile_idx].tile_info,
|
||||||
&residual_bc, &tok[tile_row][tile_col], tok_end);
|
&residual_bc, &tok, tok_end);
|
||||||
assert(tok[tile_row][tile_col] == tok_end);
|
assert(tok == tok_end);
|
||||||
vp9_stop_encode(&residual_bc);
|
vp9_stop_encode(&residual_bc);
|
||||||
if (tile_col < tile_cols - 1 || tile_row < tile_rows - 1) {
|
if (tile_col < tile_cols - 1 || tile_row < tile_rows - 1) {
|
||||||
// size of this tile
|
// size of this tile
|
||||||
|
@ -3422,32 +3422,29 @@ static int get_skip_encode_frame(const VP9_COMMON *cm, ThreadData *const td) {
|
|||||||
cm->show_frame;
|
cm->show_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tile_data_init(TileDataEnc *tile_data) {
|
static void init_tile_data(VP9_COMP *cpi) {
|
||||||
int i, j;
|
|
||||||
for (i = 0; i < BLOCK_SIZES; ++i) {
|
|
||||||
for (j = 0; j < MAX_MODES; ++j) {
|
|
||||||
tile_data->thresh_freq_fact[i][j] = 32;
|
|
||||||
tile_data->mode_map[i][j] = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void encode_tiles(VP9_COMP *cpi) {
|
|
||||||
VP9_COMMON *const cm = &cpi->common;
|
VP9_COMMON *const cm = &cpi->common;
|
||||||
const int tile_cols = 1 << cm->log2_tile_cols;
|
const int tile_cols = 1 << cm->log2_tile_cols;
|
||||||
const int tile_rows = 1 << cm->log2_tile_rows;
|
const int tile_rows = 1 << cm->log2_tile_rows;
|
||||||
|
|
||||||
int tile_col, tile_row;
|
int tile_col, tile_row;
|
||||||
TOKENEXTRA *tok[4][1 << 6];
|
TOKENEXTRA *pre_tok = cpi->tile_tok[0][0];
|
||||||
TOKENEXTRA *pre_tok = cpi->tok;
|
|
||||||
int tile_tok = 0;
|
int tile_tok = 0;
|
||||||
|
|
||||||
if (cpi->tile_data == NULL) {
|
if (cpi->tile_data == NULL) {
|
||||||
CHECK_MEM_ERROR(cm, cpi->tile_data,
|
CHECK_MEM_ERROR(cm, cpi->tile_data,
|
||||||
vpx_malloc(tile_cols * tile_rows * sizeof(*cpi->tile_data)));
|
vpx_malloc(tile_cols * tile_rows * sizeof(*cpi->tile_data)));
|
||||||
for (tile_row = 0; tile_row < tile_rows; ++tile_row)
|
for (tile_row = 0; tile_row < tile_rows; ++tile_row)
|
||||||
for (tile_col = 0; tile_col < tile_cols; ++tile_col)
|
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
|
||||||
tile_data_init(&cpi->tile_data[tile_row * tile_cols + tile_col]);
|
TileDataEnc *tile_data =
|
||||||
|
&cpi->tile_data[tile_row * tile_cols + tile_col];
|
||||||
|
int i, j;
|
||||||
|
for (i = 0; i < BLOCK_SIZES; ++i) {
|
||||||
|
for (j = 0; j < MAX_MODES; ++j) {
|
||||||
|
tile_data->thresh_freq_fact[i][j] = 32;
|
||||||
|
tile_data->mode_map[i][j] = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
|
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
|
||||||
@ -3456,32 +3453,41 @@ static void encode_tiles(VP9_COMP *cpi) {
|
|||||||
&cpi->tile_data[tile_row * tile_cols + tile_col].tile_info;
|
&cpi->tile_data[tile_row * tile_cols + tile_col].tile_info;
|
||||||
vp9_tile_init(tile_info, cm, tile_row, tile_col);
|
vp9_tile_init(tile_info, cm, tile_row, tile_col);
|
||||||
|
|
||||||
tok[tile_row][tile_col] = pre_tok + tile_tok;
|
cpi->tile_tok[tile_row][tile_col] = pre_tok + tile_tok;
|
||||||
pre_tok = tok[tile_row][tile_col];
|
pre_tok = cpi->tile_tok[tile_row][tile_col];
|
||||||
tile_tok = allocated_tokens(*tile_info);
|
tile_tok = allocated_tokens(*tile_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void encode_tiles(VP9_COMP *cpi) {
|
||||||
|
VP9_COMMON *const cm = &cpi->common;
|
||||||
|
const int tile_cols = 1 << cm->log2_tile_cols;
|
||||||
|
const int tile_rows = 1 << cm->log2_tile_rows;
|
||||||
|
int tile_col, tile_row;
|
||||||
|
|
||||||
|
init_tile_data(cpi);
|
||||||
|
|
||||||
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
|
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
|
||||||
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
|
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
|
||||||
const TileInfo * const tile_info =
|
const TileInfo * const tile_info =
|
||||||
&cpi->tile_data[tile_row * tile_cols + tile_col].tile_info;
|
&cpi->tile_data[tile_row * tile_cols + tile_col].tile_info;
|
||||||
TOKENEXTRA * const old_tok = tok[tile_row][tile_col];
|
TOKENEXTRA *tok = cpi->tile_tok[tile_row][tile_col];
|
||||||
int mi_row;
|
int mi_row;
|
||||||
TileDataEnc *this_tile = &cpi->tile_data[tile_row * tile_cols + tile_col];
|
TileDataEnc *this_tile =
|
||||||
|
&cpi->tile_data[tile_row * tile_cols + tile_col];
|
||||||
|
|
||||||
for (mi_row = tile_info->mi_row_start; mi_row < tile_info->mi_row_end;
|
for (mi_row = tile_info->mi_row_start; mi_row < tile_info->mi_row_end;
|
||||||
mi_row += MI_BLOCK_SIZE) {
|
mi_row += MI_BLOCK_SIZE) {
|
||||||
if (cpi->sf.use_nonrd_pick_mode)
|
if (cpi->sf.use_nonrd_pick_mode)
|
||||||
encode_nonrd_sb_row(cpi, &cpi->td, this_tile, mi_row,
|
encode_nonrd_sb_row(cpi, &cpi->td, this_tile, mi_row, &tok);
|
||||||
&tok[tile_row][tile_col]);
|
|
||||||
else
|
else
|
||||||
encode_rd_sb_row(cpi, &cpi->td, this_tile, mi_row,
|
encode_rd_sb_row(cpi, &cpi->td, this_tile, mi_row, &tok);
|
||||||
&tok[tile_row][tile_col]);
|
|
||||||
}
|
}
|
||||||
cpi->tok_count[tile_row][tile_col] =
|
cpi->tok_count[tile_row][tile_col] =
|
||||||
(unsigned int)(tok[tile_row][tile_col] - old_tok);
|
(unsigned int)(tok - cpi->tile_tok[tile_row][tile_col]);
|
||||||
assert(tok[tile_row][tile_col] - old_tok <= allocated_tokens(*tile_info));
|
assert(tok - cpi->tile_tok[tile_row][tile_col] <=
|
||||||
|
allocated_tokens(*tile_info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,8 +247,8 @@ static void dealloc_compressor_data(VP9_COMP *cpi) {
|
|||||||
vp9_free_frame_buffer(&cpi->alt_ref_buffer);
|
vp9_free_frame_buffer(&cpi->alt_ref_buffer);
|
||||||
vp9_lookahead_destroy(cpi->lookahead);
|
vp9_lookahead_destroy(cpi->lookahead);
|
||||||
|
|
||||||
vpx_free(cpi->tok);
|
vpx_free(cpi->tile_tok[0][0]);
|
||||||
cpi->tok = 0;
|
cpi->tile_tok[0][0] = 0;
|
||||||
|
|
||||||
vp9_free_pc_tree(&cpi->td);
|
vp9_free_pc_tree(&cpi->td);
|
||||||
|
|
||||||
@ -543,11 +543,12 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) {
|
|||||||
|
|
||||||
vp9_alloc_context_buffers(cm, cm->width, cm->height);
|
vp9_alloc_context_buffers(cm, cm->width, cm->height);
|
||||||
|
|
||||||
vpx_free(cpi->tok);
|
vpx_free(cpi->tile_tok[0][0]);
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols);
|
unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols);
|
||||||
CHECK_MEM_ERROR(cm, cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok)));
|
CHECK_MEM_ERROR(cm, cpi->tile_tok[0][0],
|
||||||
|
vpx_calloc(tokens, sizeof(*cpi->tile_tok[0][0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
vp9_setup_pc_tree(&cpi->common, &cpi->td);
|
vp9_setup_pc_tree(&cpi->common, &cpi->td);
|
||||||
@ -1800,7 +1801,6 @@ void vp9_remove_compressor(VP9_COMP *cpi) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
dealloc_compressor_data(cpi);
|
dealloc_compressor_data(cpi);
|
||||||
vpx_free(cpi->tok);
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(cpi->mbgraph_stats) /
|
for (i = 0; i < sizeof(cpi->mbgraph_stats) /
|
||||||
sizeof(cpi->mbgraph_stats[0]); ++i) {
|
sizeof(cpi->mbgraph_stats[0]); ++i) {
|
||||||
|
@ -297,7 +297,7 @@ typedef struct VP9_COMP {
|
|||||||
|
|
||||||
YV12_BUFFER_CONFIG last_frame_uf;
|
YV12_BUFFER_CONFIG last_frame_uf;
|
||||||
|
|
||||||
TOKENEXTRA *tok;
|
TOKENEXTRA *tile_tok[4][1 << 6];
|
||||||
unsigned int tok_count[4][1 << 6];
|
unsigned int tok_count[4][1 << 6];
|
||||||
|
|
||||||
// Ambient reconstruction err target for force key frames
|
// Ambient reconstruction err target for force key frames
|
||||||
|
Loading…
x
Reference in New Issue
Block a user