Commit 13a4f147 authored by Scott LaVarnway's avatar Scott LaVarnway

Eliminate num_8x8 and num_4x4 width/height lookups

Also some log2 lookups.

Pass in 8x8 block width/height and log2 num4x4s instead.

Change-Id: I8ea9a1ec1e0bbab23f8ba556954a1b5433f4d613
parent 8783a8a9
......@@ -128,6 +128,11 @@ struct macroblockd_plane {
ENTROPY_CONTEXT *left_context;
int16_t seg_dequant[MAX_SEGMENTS][2];
// number of 4x4s in current block
uint16_t n4_w, n4_h;
// log2 of n4_w, n4_h
uint8_t n4_wl, n4_hl;
// encoder
const int16_t *dequant;
};
......@@ -144,6 +149,8 @@ typedef struct RefBuffer {
typedef struct macroblockd {
struct macroblockd_plane plane[MAX_MB_PLANE];
uint8_t bmode_blocks_wl;
uint8_t bmode_blocks_hl;
FRAME_COUNTS *counts;
TileInfo tile;
......
This diff is collapsed.
......@@ -91,41 +91,44 @@ static TX_SIZE read_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
return MIN(max_tx_size, tx_mode_to_biggest_tx_size[tx_mode]);
}
static void set_segment_id(VP9_COMMON *cm, BLOCK_SIZE bsize,
int mi_row, int mi_col, int segment_id) {
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int xmis = MIN(cm->mi_cols - mi_col, bw);
const int ymis = MIN(cm->mi_rows - mi_row, bh);
static int dec_get_segment_id(const VP9_COMMON *cm, const uint8_t *segment_ids,
int mi_offset, int x_mis, int y_mis) {
int x, y, segment_id = INT_MAX;
for (y = 0; y < y_mis; y++)
for (x = 0; x < x_mis; x++)
segment_id = MIN(segment_id,
segment_ids[mi_offset + y * cm->mi_cols + x]);
assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);
return segment_id;
}
static void set_segment_id(VP9_COMMON *cm, int mi_offset,
int x_mis, int y_mis, int segment_id) {
int x, y;
assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);
for (y = 0; y < ymis; y++)
for (x = 0; x < xmis; x++)
for (y = 0; y < y_mis; y++)
for (x = 0; x < x_mis; x++)
cm->current_frame_seg_map[mi_offset + y * cm->mi_cols + x] = segment_id;
}
static void copy_segment_id(const VP9_COMMON *cm,
const uint8_t *last_segment_ids,
uint8_t *current_segment_ids,
BLOCK_SIZE bsize, int mi_row, int mi_col) {
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int xmis = MIN(cm->mi_cols - mi_col, bw);
const int ymis = MIN(cm->mi_rows - mi_row, bh);
int mi_offset, int x_mis, int y_mis) {
int x, y;
for (y = 0; y < ymis; y++)
for (x = 0; x < xmis; x++)
for (y = 0; y < y_mis; y++)
for (x = 0; x < x_mis; x++)
current_segment_ids[mi_offset + y * cm->mi_cols + x] = last_segment_ids ?
last_segment_ids[mi_offset + y * cm->mi_cols + x] : 0;
}
static int read_intra_segment_id(VP9_COMMON *const cm, BLOCK_SIZE bsize,
int mi_row, int mi_col,
static int read_intra_segment_id(VP9_COMMON *const cm, int mi_offset,
int x_mis, int y_mis,
vp9_reader *r) {
struct segmentation *const seg = &cm->seg;
int segment_id;
......@@ -135,12 +138,12 @@ static int read_intra_segment_id(VP9_COMMON *const cm, BLOCK_SIZE bsize,
if (!seg->update_map) {
copy_segment_id(cm, cm->last_frame_seg_map, cm->current_frame_seg_map,
bsize, mi_row, mi_col);
mi_offset, x_mis, y_mis);
return 0;
}
segment_id = read_segment_id(r, seg);
set_segment_id(cm, bsize, mi_row, mi_col, segment_id);
set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
return segment_id;
}
......@@ -148,18 +151,25 @@ static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
int mi_row, int mi_col, vp9_reader *r) {
struct segmentation *const seg = &cm->seg;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type;
int predicted_segment_id, segment_id;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = xd->plane[0].n4_w >> 1;
const int bh = xd->plane[0].n4_h >> 1;
// TODO(slavarnway): move x_mis, y_mis into xd ?????
const int x_mis = MIN(cm->mi_cols - mi_col, bw);
const int y_mis = MIN(cm->mi_rows - mi_row, bh);
if (!seg->enabled)
return 0; // Default for disabled segmentation
predicted_segment_id = cm->last_frame_seg_map ?
get_segment_id(cm, cm->last_frame_seg_map, bsize, mi_row, mi_col) : 0;
dec_get_segment_id(cm, cm->last_frame_seg_map, mi_offset, x_mis, y_mis) :
0;
if (!seg->update_map) {
copy_segment_id(cm, cm->last_frame_seg_map, cm->current_frame_seg_map,
bsize, mi_row, mi_col);
mi_offset, x_mis, y_mis);
return predicted_segment_id;
}
......@@ -171,7 +181,7 @@ static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
} else {
segment_id = read_segment_id(r, seg);
}
set_segment_id(cm, bsize, mi_row, mi_col, segment_id);
set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
return segment_id;
}
......@@ -198,8 +208,15 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm,
const MODE_INFO *left_mi = xd->left_mi;
const BLOCK_SIZE bsize = mbmi->sb_type;
int i;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = xd->plane[0].n4_w >> 1;
const int bh = xd->plane[0].n4_h >> 1;
// TODO(slavarnway): move x_mis, y_mis into xd ?????
const int x_mis = MIN(cm->mi_cols - mi_col, bw);
const int y_mis = MIN(cm->mi_rows - mi_row, bh);
mbmi->segment_id = read_intra_segment_id(cm, bsize, mi_row, mi_col, r);
mbmi->segment_id = read_intra_segment_id(cm, mi_offset, x_mis, y_mis, r);
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
mbmi->tx_size = read_tx_size(cm, xd, 1, r);
mbmi->ref_frame[0] = INTRA_FRAME;
......@@ -519,8 +536,8 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
: cm->interp_filter;
if (bsize < BLOCK_8X8) {
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; // 1 or 2
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; // 1 or 2
const int num_4x4_w = 1 << xd->bmode_blocks_wl;
const int num_4x4_h = 1 << xd->bmode_blocks_hl;
int idx, idy;
PREDICTION_MODE b_mode;
int_mv nearest_sub8x8[2], near_sub8x8[2];
......@@ -589,13 +606,10 @@ static void read_inter_frame_mode_info(VP9Decoder *const pbi,
}
void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd,
int mi_row, int mi_col, vp9_reader *r) {
int mi_row, int mi_col, vp9_reader *r,
int x_mis, int y_mis) {
VP9_COMMON *const cm = &pbi->common;
MODE_INFO *const mi = xd->mi[0];
const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type];
const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type];
const int x_mis = MIN(bw, cm->mi_cols - mi_col);
const int y_mis = MIN(bh, cm->mi_rows - mi_row);
MV_REF* frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
int w, h;
......
......@@ -19,7 +19,8 @@ extern "C" {
#endif
void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd,
int mi_row, int mi_col, vp9_reader *r);
int mi_row, int mi_col, vp9_reader *r,
int x_mis, int y_mis);
#ifdef __cplusplus
} // extern "C"
......
......@@ -205,9 +205,54 @@ static int decode_coefs(const MACROBLOCKD *xd,
return c;
}
// TODO(slavarnway): Decode version of vp9_set_context. Modify vp9_set_context
// after testing is complete, then delete this version.
static
void dec_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
TX_SIZE tx_size, int has_eob,
int aoff, int loff) {
ENTROPY_CONTEXT *const a = pd->above_context + aoff;
ENTROPY_CONTEXT *const l = pd->left_context + loff;
const int tx_size_in_blocks = 1 << tx_size;
// above
if (has_eob && xd->mb_to_right_edge < 0) {
int i;
const int blocks_wide = pd->n4_w +
(xd->mb_to_right_edge >> (5 + pd->subsampling_x));
int above_contexts = tx_size_in_blocks;
if (above_contexts + aoff > blocks_wide)
above_contexts = blocks_wide - aoff;
for (i = 0; i < above_contexts; ++i)
a[i] = has_eob;
for (i = above_contexts; i < tx_size_in_blocks; ++i)
a[i] = 0;
} else {
memset(a, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks);
}
// left
if (has_eob && xd->mb_to_bottom_edge < 0) {
int i;
const int blocks_high = pd->n4_h +
(xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
int left_contexts = tx_size_in_blocks;
if (left_contexts + loff > blocks_high)
left_contexts = blocks_high - loff;
for (i = 0; i < left_contexts; ++i)
l[i] = has_eob;
for (i = left_contexts; i < tx_size_in_blocks; ++i)
l[i] = 0;
} else {
memset(l, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks);
}
}
int vp9_decode_block_tokens(MACROBLOCKD *xd,
int plane, const scan_order *sc,
BLOCK_SIZE plane_bsize, int x, int y,
int x, int y,
TX_SIZE tx_size, vp9_reader *r,
int seg_id) {
struct macroblockd_plane *const pd = &xd->plane[plane];
......@@ -217,7 +262,7 @@ int vp9_decode_block_tokens(MACROBLOCKD *xd,
const int eob = decode_coefs(xd, pd->plane_type,
pd->dqcoeff, tx_size,
dequant, ctx, sc->scan, sc->neighbors, r);
vp9_set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y);
dec_set_contexts(xd, pd, tx_size, eob > 0, x, y);
return eob;
}
......
......@@ -22,7 +22,7 @@ extern "C" {
int vp9_decode_block_tokens(MACROBLOCKD *xd,
int plane, const scan_order *sc,
BLOCK_SIZE plane_bsize, int x, int y,
int x, int y,
TX_SIZE tx_size, vp9_reader *r,
int seg_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment