Commit cbd3b98d authored by John Koleszar's avatar John Koleszar Committed by Gerrit Code Review

Merge "General code cleanup." into experimental

parents 4add99aa d5a01730
......@@ -16,13 +16,8 @@ typedef enum {
DEST = 1
} BLOCKSET;
static void setup_block(BLOCKD *b,
int mv_stride,
uint8_t **base,
uint8_t **base2,
int stride,
int offset,
BLOCKSET bs) {
static void setup_block(BLOCKD *b, uint8_t **base, uint8_t **base2,
int stride, int offset, BLOCKSET bs) {
if (bs == DEST) {
b->dst_stride = stride;
b->dst = offset;
......@@ -35,81 +30,84 @@ static void setup_block(BLOCKD *b,
}
}
static void setup_macroblock(MACROBLOCKD *xd, BLOCKSET bs) {
int block;
uint8_t **y, **u, **v;
uint8_t **y2 = NULL, **u2 = NULL, **v2 = NULL;
BLOCKD *blockd = xd->block;
int stride;
static void setup_macroblock(MACROBLOCKD *mb, BLOCKSET bs) {
BLOCKD *blockd = mb->block;
uint8_t **y, **u, **v, **y2, **u2, **v2;
int i, stride;
if (bs == DEST) {
y = &xd->dst.y_buffer;
u = &xd->dst.u_buffer;
v = &xd->dst.v_buffer;
y = &mb->dst.y_buffer;
u = &mb->dst.u_buffer;
v = &mb->dst.v_buffer;
y2 = NULL;
u2 = NULL;
v2 = NULL;
} else {
y = &xd->pre.y_buffer;
u = &xd->pre.u_buffer;
v = &xd->pre.v_buffer;
y = &mb->pre.y_buffer;
u = &mb->pre.u_buffer;
v = &mb->pre.v_buffer;
y2 = &xd->second_pre.y_buffer;
u2 = &xd->second_pre.u_buffer;
v2 = &xd->second_pre.v_buffer;
y2 = &mb->second_pre.y_buffer;
u2 = &mb->second_pre.u_buffer;
v2 = &mb->second_pre.v_buffer;
}
stride = xd->dst.y_stride;
for (block = 0; block < 16; block++) { /* y blocks */
setup_block(&blockd[block], stride, y, y2, stride,
(block >> 2) * 4 * stride + (block & 3) * 4, bs);
// luma
stride = mb->dst.y_stride;
for (i = 0; i < 16; ++i) {
const int offset = (i >> 2) * 4 * stride + (i & 3) * 4;
setup_block(&blockd[i], y, y2, stride, offset, bs);
}
stride = xd->dst.uv_stride;
for (block = 16; block < 20; block++) { /* U and V blocks */
setup_block(&blockd[block], stride, u, u2, stride,
((block - 16) >> 1) * 4 * stride + (block & 1) * 4, bs);
setup_block(&blockd[block + 4], stride, v, v2, stride,
((block - 16) >> 1) * 4 * stride + (block & 1) * 4, bs);
// chroma
stride = mb->dst.uv_stride;
for (i = 16; i < 20; i++) {
const int offset = ((i - 16) >> 1) * 4 * stride + (i & 1) * 4;
setup_block(&blockd[i], u, u2, stride, offset, bs);
setup_block(&blockd[i + 4], v, v2, stride, offset, bs);
}
}
void vp9_setup_block_dptrs(MACROBLOCKD *xd) {
void vp9_setup_block_dptrs(MACROBLOCKD *mb) {
int r, c;
BLOCKD *blockd = xd->block;
BLOCKD *blockd = mb->block;
for (r = 0; r < 4; r++) {
for (c = 0; c < 4; c++) {
blockd[r * 4 + c].diff = &xd->diff[r * 4 * 16 + c * 4];
blockd[r * 4 + c].predictor = xd->predictor + r * 4 * 16 + c * 4;
const int to = r * 4 + c;
const int from = r * 4 * 16 + c * 4;
blockd[to].diff = &mb->diff[from];
blockd[to].predictor = &mb->predictor[from];
}
}
for (r = 0; r < 2; r++) {
for (c = 0; c < 2; c++) {
blockd[16 + r * 2 + c].diff = &xd->diff[256 + r * 4 * 8 + c * 4];
blockd[16 + r * 2 + c].predictor =
xd->predictor + 256 + r * 4 * 8 + c * 4;
const int to = 16 + r * 2 + c;
const int from = 256 + r * 4 * 8 + c * 4;
blockd[to].diff = &mb->diff[from];
blockd[to].predictor = &mb->predictor[from];
}
}
for (r = 0; r < 2; r++) {
for (c = 0; c < 2; c++) {
blockd[20 + r * 2 + c].diff = &xd->diff[320 + r * 4 * 8 + c * 4];
blockd[20 + r * 2 + c].predictor =
xd->predictor + 320 + r * 4 * 8 + c * 4;
const int to = 20 + r * 2 + c;
const int from = 320 + r * 4 * 8 + c * 4;
blockd[to].diff = &mb->diff[from];
blockd[to].predictor = &mb->predictor[from];
}
}
for (r = 0; r < 24; r++) {
blockd[r].qcoeff = xd->qcoeff + r * 16;
blockd[r].dqcoeff = xd->dqcoeff + r * 16;
blockd[r].qcoeff = &mb->qcoeff[r * 16];
blockd[r].dqcoeff = &mb->dqcoeff[r * 16];
}
}
void vp9_build_block_doffsets(MACROBLOCKD *xd) {
/* handle the destination pitch features */
setup_macroblock(xd, DEST);
setup_macroblock(xd, PRED);
void vp9_build_block_doffsets(MACROBLOCKD *mb) {
// handle the destination pitch features
setup_macroblock(mb, DEST);
setup_macroblock(mb, PRED);
}
......@@ -15,17 +15,16 @@
void vp9_setup_intra_recon(YV12_BUFFER_CONFIG *ybf) {
int i;
/* set up frame new frame for intra coded blocks */
// luma
vpx_memset(ybf->y_buffer - 1 - ybf->y_stride, 127, ybf->y_width + 5);
for (i = 0; i < ybf->y_height; i++)
ybf->y_buffer[ybf->y_stride * i - 1] = (uint8_t) 129;
ybf->y_buffer[ybf->y_stride * i - 1] = 129;
// chroma
vpx_memset(ybf->u_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
for (i = 0; i < ybf->uv_height; i++)
ybf->u_buffer[ybf->uv_stride * i - 1] = (uint8_t) 129;
vpx_memset(ybf->v_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
for (i = 0; i < ybf->uv_height; i++)
ybf->v_buffer[ybf->uv_stride * i - 1] = (uint8_t) 129;
for (i = 0; i < ybf->uv_height; i++) {
ybf->u_buffer[ybf->uv_stride * i - 1] = 129;
ybf->v_buffer[ybf->uv_stride * i - 1] = 129;
}
}
......@@ -1057,7 +1057,6 @@ static void decode_sb_row(VP9D_COMP *pbi, VP9_COMMON *pc,
set_refs(pbi, 16, mb_row + y_idx, mb_col + x_idx);
decode_mb(pbi, xd, mb_row + y_idx, mb_col + x_idx, bc);
/* check if the boolean decoder has suffered an error */
xd->corrupted |= bool_error(bc);
}
}
......@@ -1791,13 +1790,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
// Read inter mode probability context updates
if (pc->frame_type != KEY_FRAME) {
int i, j;
for (i = 0; i < INTER_MODE_CONTEXTS; i++) {
for (j = 0; j < 4; j++) {
if (vp9_read(&header_bc, 252)) {
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
for (j = 0; j < 4; ++j)
if (vp9_read(&header_bc, 252))
pc->fc.vp9_mode_contexts[i][j] = vp9_read_prob(&header_bc);
}
}
}
}
#if CONFIG_MODELCOEFPROB && ADJUST_KF_COEF_PROBS
if (pc->frame_type == KEY_FRAME)
......@@ -1812,16 +1808,13 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
for (i = 0; i < MAX_REF_FRAMES; ++i) {
// Skip the dummy entry for intra ref frame.
if (i == INTRA_FRAME) {
if (i == INTRA_FRAME)
continue;
}
// Read any updates to probabilities
for (j = 0; j < MAX_MV_REF_CANDIDATES - 1; ++j) {
if (vp9_read(&header_bc, VP9_MVREF_UPDATE_PROB)) {
for (j = 0; j < MAX_MV_REF_CANDIDATES - 1; ++j)
if (vp9_read(&header_bc, VP9_MVREF_UPDATE_PROB))
xd->mb_mv_ref_probs[i][j] = vp9_read_prob(&header_bc);
}
}
}
}
#endif
......@@ -1849,18 +1842,17 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
CHECK_MEM_ERROR(pc->last_frame_seg_map,
vpx_calloc((pc->mb_rows * pc->mb_cols), 1));
/* set up frame new frame for intra coded blocks */
// set up frame new frame for intra coded blocks
vp9_setup_intra_recon(&pc->yv12_fb[pc->new_fb_idx]);
vp9_setup_block_dptrs(xd);
vp9_build_block_doffsets(xd);
/* clear out the coeff buffer */
// clear out the coeff buffer
vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
/* Read the mb_no_coeff_skip flag */
pc->mb_no_coeff_skip = (int)vp9_read_bit(&header_bc);
// Read the mb_no_coeff_skip flag
pc->mb_no_coeff_skip = vp9_read_bit(&header_bc);
vp9_decode_mode_mvs_init(pbi, &header_bc);
......@@ -1916,7 +1908,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
}
#endif
/* Find the end of the coded buffer */
// Find the end of the coded buffer
while (residual_bc.count > CHAR_BIT &&
residual_bc.count < VP9_BD_VALUE_SIZE) {
residual_bc.count -= CHAR_BIT;
......
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