Merge changes I6226456d,I97925178,I766c4b74

* changes:
  Use a separate MODE_INFO stream for each tile column
  Get rid of "this_mi", use "mi_8x8[0]" everywhere instead
  Make the static_segmentation feature work again
This commit is contained in:
Guillaume Martres
2013-10-16 17:05:39 -07:00
committed by Gerrit Code Review
20 changed files with 155 additions and 150 deletions

View File

@@ -111,7 +111,7 @@ static int read_intra_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r) {
MACROBLOCKD *const xd = &pbi->mb;
struct segmentation *const seg = &pbi->common.seg;
const BLOCK_SIZE bsize = xd->this_mi->mbmi.sb_type;
const BLOCK_SIZE bsize = xd->mi_8x8[0]->mbmi.sb_type;
int segment_id;
if (!seg->enabled)
@@ -130,7 +130,7 @@ static int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
struct segmentation *const seg = &cm->seg;
const BLOCK_SIZE bsize = xd->this_mi->mbmi.sb_type;
const BLOCK_SIZE bsize = xd->mi_8x8[0]->mbmi.sb_type;
int pred_segment_id, segment_id;
if (!seg->enabled)
@@ -661,7 +661,7 @@ void vp9_prepare_read_mode_info(VP9D_COMP* pbi, vp9_reader *r) {
void vp9_read_mode_info(VP9D_COMP* pbi, int mi_row, int mi_col, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MODE_INFO *mi = xd->this_mi;
MODE_INFO *mi = xd->mi_8x8[0];
const BLOCK_SIZE bsize = mi->mbmi.sb_type;
const int bw = 1 << mi_width_log2(bsize);
const int bh = 1 << mi_height_log2(bsize);

View File

@@ -134,7 +134,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, void *arg) {
MACROBLOCKD* const xd = arg;
struct macroblockd_plane *const pd = &xd->plane[plane];
MODE_INFO *const mi = xd->this_mi;
MODE_INFO *const mi = xd->mi_8x8[0];
const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size,
block);
uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block,
@@ -158,7 +158,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE bsize, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MB_MODE_INFO *const mbmi = &xd->this_mi->mbmi;
MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi;
if (mbmi->skip_coeff) {
reset_skip_context(xd, bsize);
@@ -174,6 +174,7 @@ static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE bsize, vp9_reader *r) {
}
static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize,
int tile_col,
int mi_row, int mi_col) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
@@ -187,10 +188,9 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize,
xd->prev_mi_8x8 = cm->prev_mi_grid_visible + offset;
// we are using the mode info context stream here
xd->this_mi =
xd->mi_8x8[0] = xd->mic_stream_ptr;
xd->this_mi->mbmi.sb_type = bsize;
xd->mic_stream_ptr++;
xd->mi_8x8[0] = pbi->mi_streams[tile_col];
xd->mi_8x8[0]->mbmi.sb_type = bsize;
pbi->mi_streams[tile_col]++;
// Special case: if prev_mi is NULL, the previous mode info context
// cannot be used.
@@ -209,7 +209,7 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize,
static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MB_MODE_INFO *const mbmi = &xd->this_mi->mbmi;
MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi;
const int ref = mbmi->ref_frame[i] - LAST_FRAME;
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[ref]];
const struct scale_factors *sf = &cm->active_ref_scale[ref];
@@ -222,7 +222,8 @@ static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) {
xd->corrupted |= cfg->corrupted;
}
static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
static void decode_modes_b(VP9D_COMP *pbi, int tile_col,
int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE bsize) {
MACROBLOCKD *const xd = &pbi->mb;
const int less8x8 = bsize < BLOCK_8X8;
@@ -233,14 +234,14 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
if (xd->ab_index > 0)
return;
set_offsets(pbi, bsize, mi_row, mi_col);
set_offsets(pbi, bsize, tile_col, mi_row, mi_col);
vp9_read_mode_info(pbi, mi_row, mi_col, r);
if (less8x8)
bsize = BLOCK_8X8;
// Has to be called after set_offsets
mbmi = &xd->this_mi->mbmi;
mbmi = &xd->mi_8x8[0]->mbmi;
eobtotal = decode_tokens(pbi, bsize, r);
if (!is_inter_block(mbmi)) {
@@ -270,7 +271,8 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
xd->corrupted |= vp9_reader_has_error(r);
}
static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
static void decode_modes_sb(VP9D_COMP *pbi, int tile_col,
int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
@@ -308,26 +310,27 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
switch (partition) {
case PARTITION_NONE:
decode_modes_b(pbi, mi_row, mi_col, r, subsize);
decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize);
break;
case PARTITION_HORZ:
decode_modes_b(pbi, mi_row, mi_col, r, subsize);
decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize);
*get_sb_index(xd, subsize) = 1;
if (mi_row + hbs < cm->mi_rows)
decode_modes_b(pbi, mi_row + hbs, mi_col, r, subsize);
decode_modes_b(pbi, tile_col, mi_row + hbs, mi_col, r, subsize);
break;
case PARTITION_VERT:
decode_modes_b(pbi, mi_row, mi_col, r, subsize);
decode_modes_b(pbi, tile_col, mi_row, mi_col, r, subsize);
*get_sb_index(xd, subsize) = 1;
if (mi_col + hbs < cm->mi_cols)
decode_modes_b(pbi, mi_row, mi_col + hbs, r, subsize);
decode_modes_b(pbi, tile_col, mi_row, mi_col + hbs, r, subsize);
break;
case PARTITION_SPLIT: {
int n;
for (n = 0; n < 4; n++) {
const int j = n >> 1, i = n & 1;
*get_sb_index(xd, subsize) = n;
decode_modes_sb(pbi, mi_row + j * hbs, mi_col + i * hbs, r, subsize);
decode_modes_sb(pbi, tile_col, mi_row + j * hbs, mi_col + i * hbs,
r, subsize);
}
} break;
default:
@@ -583,7 +586,7 @@ static void setup_frame_size_with_refs(VP9D_COMP *pbi,
setup_display_size(cm, rb);
}
static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
static void decode_tile(VP9D_COMP *pbi, vp9_reader *r, int tile_col) {
const int num_threads = pbi->oxcf.max_threads;
VP9_COMMON *const cm = &pbi->common;
int mi_row, mi_col;
@@ -608,7 +611,7 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
vp9_zero(cm->left_seg_context);
for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end;
mi_col += MI_BLOCK_SIZE)
decode_modes_sb(pbi, mi_row, mi_col, r, BLOCK_64X64);
decode_modes_sb(pbi, tile_col, mi_row, mi_col, r, BLOCK_64X64);
if (pbi->do_loopfilter_inline) {
// delay the loopfilter by 1 macroblock row.
@@ -710,7 +713,7 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
setup_token_decoder(pbi, data_ptr2[tile_row][tile_col],
data_end - data_ptr2[tile_row][tile_col],
&residual_bc);
decode_tile(pbi, &residual_bc);
decode_tile(pbi, &residual_bc, tile_col);
if (tile_row == tile_rows - 1 && tile_col == tile_cols - 1)
bc_bak = residual_bc;
}
@@ -739,7 +742,7 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
}
setup_token_decoder(pbi, data, size, &residual_bc);
decode_tile(pbi, &residual_bc);
decode_tile(pbi, &residual_bc, tile_col);
data += size;
}
}
@@ -955,6 +958,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
const size_t first_partition_size = read_uncompressed_header(pbi, &rb);
const int keyframe = cm->frame_type == KEY_FRAME;
YV12_BUFFER_CONFIG *new_fb = &cm->yv12_fb[cm->new_fb_idx];
const int tile_cols = 1 << cm->log2_tile_cols;
int tile_col;
if (!first_partition_size) {
if (!keyframe) {
@@ -983,9 +988,17 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
setup_plane_dequants(cm, &pbi->mb, cm->base_qindex);
xd->mi_8x8 = cm->mi_grid_visible;
xd->mic_stream_ptr = cm->mi;
xd->mode_info_stride = cm->mode_info_stride;
CHECK_MEM_ERROR(cm, pbi->mi_streams,
vpx_realloc(pbi->mi_streams, tile_cols *
sizeof(*pbi->mi_streams)));
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
vp9_get_tile_col_offsets(cm, tile_col);
pbi->mi_streams[tile_col] =
&cm->mi[cm->mi_rows * cm->cur_tile_mi_col_start];
}
cm->fc = cm->frame_contexts[cm->frame_context_idx];
vp9_zero(cm->counts);

View File

@@ -91,7 +91,7 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
TX_SIZE tx_size, const int16_t *dq, int pt) {
const FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
const int ref = is_inter_block(&xd->this_mi->mbmi);
const int ref = is_inter_block(&xd->mi_8x8[0]->mbmi);
int band, c = 0;
const vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size][type][ref];
@@ -218,7 +218,7 @@ static void decode_block(int plane, int block, BLOCK_SIZE plane_bsize,
MACROBLOCKD *xd = &arg->pbi->mb;
struct segmentation *seg = &arg->pbi->common.seg;
struct macroblockd_plane* pd = &xd->plane[plane];
const int segment_id = xd->this_mi->mbmi.segment_id;
const int segment_id = xd->mi_8x8[0]->mbmi.segment_id;
const int seg_eob = get_tx_eob(seg, segment_id, tx_size);
int aoff, loff, eob, pt;

View File

@@ -163,6 +163,7 @@ void vp9_remove_decompressor(VP9D_PTR ptr) {
vp9_remove_common(&pbi->common);
vp9_worker_end(&pbi->lf_worker);
vpx_free(pbi->lf_worker.data1);
vpx_free(pbi->mi_streams);
vpx_free(pbi);
}
@@ -396,7 +397,6 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
pbi->mb.mi_8x8 = cm->mi_grid_visible;
pbi->mb.mi_8x8[0] = cm->mi;
pbi->mb.this_mi = cm->mi;
cm->current_video_frame++;
}

View File

@@ -39,6 +39,10 @@ typedef struct VP9Decompressor {
int do_loopfilter_inline; // apply loopfilter to available rows immediately
VP9Worker lf_worker;
/* Each tile column has its own MODE_INFO stream. This array indexes them by
tile column index. */
MODE_INFO **mi_streams;
} VP9D_COMP;
#endif // VP9_DECODER_VP9_ONYXD_INT_H_