Commit ab196b7e authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Code cleanup.

Lower case names of variables. Removing redundant spaces, parentheses,
casts, and variables.

Change-Id: I55b80c55b7d5adca44c1e8adb40a124c0680f229
parent 77a3becf
......@@ -78,68 +78,69 @@ static vp9_prob read_prob_diff_update(vp9_reader *const bc, int oldp) {
void vp9_init_de_quantizer(VP9D_COMP *pbi) {
int i;
int Q;
int q;
VP9_COMMON *const pc = &pbi->common;
for (Q = 0; Q < QINDEX_RANGE; Q++) {
pc->Y1dequant[Q][0] = (int16_t)vp9_dc_quant(Q, pc->y1dc_delta_q);
pc->UVdequant[Q][0] = (int16_t)vp9_dc_uv_quant(Q, pc->uvdc_delta_q);
for (q = 0; q < QINDEX_RANGE; q++) {
pc->Y1dequant[q][0] = (int16_t)vp9_dc_quant(q, pc->y1dc_delta_q);
pc->UVdequant[q][0] = (int16_t)vp9_dc_uv_quant(q, pc->uvdc_delta_q);
/* all the ac values =; */
for (i = 1; i < 16; i++) {
int rc = vp9_default_zig_zag1d_4x4[i];
pc->Y1dequant[Q][rc] = (int16_t)vp9_ac_yquant(Q);
pc->UVdequant[Q][rc] = (int16_t)vp9_ac_uv_quant(Q, pc->uvac_delta_q);
pc->Y1dequant[q][rc] = (int16_t)vp9_ac_yquant(q);
pc->UVdequant[q][rc] = (int16_t)vp9_ac_uv_quant(q, pc->uvac_delta_q);
}
}
}
static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
int i;
int QIndex;
int qindex;
VP9_COMMON *const pc = &pbi->common;
int segment_id = xd->mode_info_context->mbmi.segment_id;
// Set the Q baseline allowing for any segment level adjustment
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_ALT_Q)) {
/* Abs Value */
if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
QIndex = vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
/* Delta Value */
/* Abs Value */
qindex = vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
else {
QIndex = pc->base_qindex +
/* Delta Value */
qindex = pc->base_qindex +
vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */
/* Clamp to valid range */
qindex = (qindex >= 0) ? ((qindex <= MAXQ) ? qindex : MAXQ) : 0;
}
} else
QIndex = pc->base_qindex;
xd->q_index = QIndex;
qindex = pc->base_qindex;
xd->q_index = qindex;
/* Set up the block level dequant pointers */
for (i = 0; i < 16; i++) {
xd->block[i].dequant = pc->Y1dequant[QIndex];
xd->block[i].dequant = pc->Y1dequant[qindex];
}
xd->inv_txm4x4_1 = vp9_short_idct4x4llm_1;
xd->inv_txm4x4 = vp9_short_idct4x4llm;
xd->itxm_add = vp9_dequant_idct_add;
xd->dc_only_itxm_add = vp9_dc_only_idct_add_c;
xd->itxm_add_y_block = vp9_dequant_idct_add_y_block;
xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block;
xd->inv_txm4x4_1 = vp9_short_idct4x4llm_1;
xd->inv_txm4x4 = vp9_short_idct4x4llm;
xd->itxm_add = vp9_dequant_idct_add;
xd->dc_only_itxm_add = vp9_dc_only_idct_add_c;
xd->itxm_add_y_block = vp9_dequant_idct_add_y_block;
xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block;
if (xd->lossless) {
assert(QIndex == 0);
xd->inv_txm4x4_1 = vp9_short_inv_walsh4x4_1_x8;
xd->inv_txm4x4 = vp9_short_inv_walsh4x4_x8;
xd->itxm_add = vp9_dequant_idct_add_lossless_c;
xd->dc_only_itxm_add = vp9_dc_only_inv_walsh_add_c;
xd->itxm_add_y_block = vp9_dequant_idct_add_y_block_lossless_c;
xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block_lossless_c;
assert(qindex == 0);
xd->inv_txm4x4_1 = vp9_short_inv_walsh4x4_1_x8;
xd->inv_txm4x4 = vp9_short_inv_walsh4x4_x8;
xd->itxm_add = vp9_dequant_idct_add_lossless_c;
xd->dc_only_itxm_add = vp9_dc_only_inv_walsh_add_c;
xd->itxm_add_y_block = vp9_dequant_idct_add_y_block_lossless_c;
xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block_lossless_c;
}
for (i = 16; i < 24; i++) {
xd->block[i].dequant = pc->UVdequant[QIndex];
xd->block[i].dequant = pc->UVdequant[qindex];
}
}
......@@ -147,11 +148,13 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
* to dst buffer, we can write the result directly to dst buffer. This eliminates unnecessary copy.
*/
static void skip_recon_mb(VP9D_COMP *pbi, MACROBLOCKD *xd) {
BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
if (sb_type == BLOCK_SIZE_SB64X64) {
vp9_build_intra_predictors_sb64uv_s(xd);
vp9_build_intra_predictors_sb64y_s(xd);
} else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
} else if (sb_type == BLOCK_SIZE_SB32X32) {
vp9_build_intra_predictors_sbuv_s(xd);
vp9_build_intra_predictors_sby_s(xd);
} else {
......@@ -159,14 +162,14 @@ static void skip_recon_mb(VP9D_COMP *pbi, MACROBLOCKD *xd) {
vp9_build_intra_predictors_mby_s(xd);
}
} else {
if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
if (sb_type == BLOCK_SIZE_SB64X64) {
vp9_build_inter64x64_predictors_sb(xd,
xd->dst.y_buffer,
xd->dst.u_buffer,
xd->dst.v_buffer,
xd->dst.y_stride,
xd->dst.uv_stride);
} else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
} else if (sb_type == BLOCK_SIZE_SB32X32) {
vp9_build_inter32x32_predictors_sb(xd,
xd->dst.y_buffer,
xd->dst.u_buffer,
......@@ -830,12 +833,13 @@ static void decode_macroblock(VP9D_COMP *pbi, MACROBLOCKD *xd,
vp9_setup_interp_filters(xd, xd->mode_info_context->mbmi.interp_filter,
&pbi->common);
if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV
&& mode != I8X8_PRED
&& !bool_error(bc)) {
if (eobtotal == 0 &&
mode != B_PRED &&
mode != SPLITMV &&
mode != I8X8_PRED &&
!bool_error(bc)) {
/* Special case: Force the loopfilter to skip when eobtotal and
* mb_skip_coeff are zero.
* */
mb_skip_coeff are zero. */
xd->mode_info_context->mbmi.mb_skip_coeff = 1;
skip_recon_mb(pbi, xd);
return;
......@@ -1098,7 +1102,7 @@ static unsigned int read_partition_size(const unsigned char *cx_size) {
static int read_is_valid(const unsigned char *start,
size_t len,
const unsigned char *end) {
return (start + len > start && start + len <= end);
return start + len > start && start + len <= end;
}
......@@ -1227,8 +1231,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
pc->yv12_fb[pc->new_fb_idx].corrupted = 0;
if (data_end - data < 3) {
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet");
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet");
} else {
pc->last_frame_type = pc->frame_type;
pc->frame_type = (FRAME_TYPE)(data[0] & 1);
......@@ -1259,8 +1262,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
data += 3;
}
{
const int Width = pc->Width;
const int Height = pc->Height;
const int width = pc->Width;
const int height = pc->Height;
/* If error concealment is enabled we should only parse the new size
* if we have enough data. Otherwise we will end up with the wrong
......@@ -1274,15 +1277,15 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
}
data += 4;
if (Width != pc->Width || Height != pc->Height) {
if (width != pc->Width || height != pc->Height) {
if (pc->Width <= 0) {
pc->Width = Width;
pc->Width = width;
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
"Invalid frame width");
}
if (pc->Height <= 0) {
pc->Height = Height;
pc->Height = height;
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
"Invalid frame height");
}
......@@ -1464,11 +1467,9 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
/* Read the default quantizers. */
{
int Q, q_update;
int q_update = 0;
pc->base_qindex = vp9_read_literal(&header_bc, QINDEX_BITS);
Q = vp9_read_literal(&header_bc, QINDEX_BITS);
pc->base_qindex = Q;
q_update = 0;
/* AC 1st order Q = default */
pc->y1dc_delta_q = get_delta_q(&header_bc, pc->y1dc_delta_q, &q_update);
pc->uvdc_delta_q = get_delta_q(&header_bc, pc->uvdc_delta_q, &q_update);
......@@ -1670,18 +1671,18 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
data_ptr2[0][0] = data_ptr;
for (tile_row = 0; tile_row < pc->tile_rows; tile_row++) {
if (tile_row) {
int size = data_ptr2[tile_row - 1][n_cols - 1][0] +
(data_ptr2[tile_row - 1][n_cols - 1][1] << 8) +
(data_ptr2[tile_row - 1][n_cols - 1][2] << 16) +
int size = data_ptr2[tile_row - 1][n_cols - 1][0] |
(data_ptr2[tile_row - 1][n_cols - 1][1] << 8) |
(data_ptr2[tile_row - 1][n_cols - 1][2] << 16) |
(data_ptr2[tile_row - 1][n_cols - 1][3] << 24);
data_ptr2[tile_row - 1][n_cols - 1] += 4;
data_ptr2[tile_row][0] = data_ptr2[tile_row - 1][n_cols - 1] + size;
}
for (tile_col = 1; tile_col < n_cols; tile_col++) {
int size = data_ptr2[tile_row][tile_col - 1][0] +
(data_ptr2[tile_row][tile_col - 1][1] << 8) +
(data_ptr2[tile_row][tile_col - 1][2] << 16) +
int size = data_ptr2[tile_row][tile_col - 1][0] |
(data_ptr2[tile_row][tile_col - 1][1] << 8) |
(data_ptr2[tile_row][tile_col - 1][2] << 16) |
(data_ptr2[tile_row][tile_col - 1][3] << 24);
data_ptr2[tile_row][tile_col - 1] += 4;
data_ptr2[tile_row][tile_col] =
......@@ -1721,8 +1722,11 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
mb_row < pc->cur_tile_mb_row_end; mb_row += 4) {
decode_sb_row(pbi, pc, mb_row, xd, &residual_bc);
}
if (tile_col < pc->tile_columns - 1 || tile_row < pc->tile_rows - 1) {
int size = data_ptr[0] + (data_ptr[1] << 8) + (data_ptr[2] << 16) +
int size = data_ptr[0] |
(data_ptr[1] << 8) |
(data_ptr[2] << 16) |
(data_ptr[3] << 24);
data_ptr += 4 + size;
}
......
......@@ -14,14 +14,14 @@
#include "vpx_mem/vpx_mem.h"
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/common/vp9_common.h"
static void add_residual(const int16_t *diff, const uint8_t *pred, int pitch,
uint8_t *dest, int stride, int width, int height) {
int r, c;
for (r = 0; r < height; r++) {
for (c = 0; c < width; c++) {
for (c = 0; c < width; c++)
dest[c] = clip_pixel(diff[c] + pred[c]);
}
dest += stride;
diff += width;
......@@ -35,9 +35,8 @@ static void add_constant_residual(const int16_t diff, const uint8_t *pred,
int r, c;
for (r = 0; r < height; r++) {
for (c = 0; c < width; c++) {
for (c = 0; c < width; c++)
dest[c] = clip_pixel(diff + pred[c]);
}
dest += stride;
pred += pitch;
......@@ -50,9 +49,8 @@ void vp9_dequantize_b_c(BLOCKD *d) {
const int16_t *q = d->qcoeff;
const int16_t *dqc = d->dequant;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
dq[i] = q[i] * dqc[i];
}
}
......@@ -64,9 +62,8 @@ void vp9_ht_dequant_idct_add_c(TX_TYPE tx_type, int16_t *input,
int16_t *diff_ptr = output;
int i;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
input[i] = dq[i] * input[i];
}
vp9_short_iht4x4(input, output, 8, tx_type);
vpx_memset(input, 0, 32);
......@@ -86,9 +83,8 @@ void vp9_ht_dequant_idct_add_8x8_c(TX_TYPE tx_type, int16_t *input,
vp9_copy_mem8x8(pred, pitch, dest, stride);
} else if (eob > 0) {
input[0] *= dq[0];
for (i = 1; i < 64; i++) {
for (i = 1; i < 64; i++)
input[i] *= dq[1];
}
vp9_short_iht8x8(input, output, 16, tx_type);
vpx_memset(input, 0, 128);
......@@ -103,9 +99,8 @@ void vp9_dequant_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
int16_t *diff_ptr = output;
int i;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
input[i] *= dq[i];
}
/* the idct halves ( >> 1) the pitch */
vp9_short_idct4x4llm_c(input, output, 4 << 1);
......@@ -123,9 +118,8 @@ void vp9_dequant_dc_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
input[0] = dc;
for (i = 1; i < 16; i++) {
for (i = 1; i < 16; i++)
input[i] *= dq[i];
}
/* the idct halves ( >> 1) the pitch */
vp9_short_idct4x4llm_c(input, output, 4 << 1);
......@@ -142,9 +136,8 @@ void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
int16_t *diff_ptr = output;
int i;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
input[i] *= dq[i];
}
vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
......@@ -161,11 +154,10 @@ void vp9_dequant_dc_idct_add_lossless_c(int16_t *input, const int16_t *dq,
int16_t output[16];
int16_t *diff_ptr = output;
input[0] = (int16_t)dc;
input[0] = dc;
for (i = 1; i < 16; i++) {
for (i = 1; i < 16; i++)
input[i] *= dq[i];
}
vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
vpx_memset(input, 0, 32);
......@@ -224,9 +216,9 @@ void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq,
add_residual(diff_ptr, pred, pitch, dest, stride, 8, 8);
} else {
// recover quantizer for 4 4x4 blocks
for (i = 1; i < 64; i++) {
for (i = 1; i < 64; i++)
input[i] *= dq[1];
}
// the idct halves ( >> 1) the pitch
vp9_short_idct8x8_c(input, output, 16);
......
......@@ -161,12 +161,15 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
while (1) {
int val;
const uint8_t *cat6 = cat6_prob;
if (c >= seg_eob) break;
if (c >= seg_eob)
break;
prob = coef_probs[type][ref][get_coef_band(txfm_size, c)][pt];
if (!vp9_read(br, prob[EOB_CONTEXT_NODE]))
break;
SKIP_START:
if (c >= seg_eob) break;
if (c >= seg_eob)
break;
if (!vp9_read(br, prob[ZERO_CONTEXT_NODE])) {
INCREMENT_COUNT(ZERO_TOKEN);
++c;
......@@ -236,7 +239,7 @@ SKIP_START:
if (c < seg_eob)
coef_counts[type][ref][get_coef_band(txfm_size, c)][pt][DCT_EOB_TOKEN]++;
A0[aidx] = L0[lidx] = (c > 0);
A0[aidx] = L0[lidx] = c > 0;
if (txfm_size >= TX_8X8) {
A0[aidx + 1] = L0[lidx + 1] = A0[aidx];
if (txfm_size >= TX_16X16) {
......@@ -268,27 +271,20 @@ SKIP_START:
}
static int get_eob(MACROBLOCKD* const xd, int segment_id, int eob_max) {
int eob;
if (vp9_get_segdata(xd, segment_id, SEG_LVL_SKIP)) {
eob = 0;
} else {
eob = eob_max;
}
return eob;
return vp9_get_segdata(xd, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
}
int vp9_decode_sb_tokens(VP9D_COMP* const pbi,
MACROBLOCKD* const xd,
BOOL_DECODER* const bc) {
const int segment_id = xd->mode_info_context->mbmi.segment_id;
int c, i, eobtotal = 0, seg_eob;
int i, eobtotal = 0, seg_eob;
// Luma block
c = decode_coefs(pbi, xd, bc, 0, PLANE_TYPE_Y_WITH_DC,
DCT_DCT, get_eob(xd, segment_id, 1024),
xd->sb_coeff_data.qcoeff,
vp9_default_zig_zag1d_32x32, TX_32X32);
int c = decode_coefs(pbi, xd, bc, 0, PLANE_TYPE_Y_WITH_DC,
DCT_DCT, get_eob(xd, segment_id, 1024),
xd->sb_coeff_data.qcoeff,
vp9_default_zig_zag1d_32x32, TX_32X32);
xd->block[0].eob = c;
eobtotal += c;
......@@ -309,13 +305,13 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi,
MACROBLOCKD* const xd,
BOOL_DECODER* const bc) {
const int segment_id = xd->mode_info_context->mbmi.segment_id;
int c, i, eobtotal = 0, seg_eob;
int i, eobtotal = 0, seg_eob;
// Luma block
c = decode_coefs(pbi, xd, bc, 0, PLANE_TYPE_Y_WITH_DC,
get_tx_type(xd, &xd->block[0]),
get_eob(xd, segment_id, 256),
xd->qcoeff, vp9_default_zig_zag1d_16x16, TX_16X16);
int c = decode_coefs(pbi, xd, bc, 0, PLANE_TYPE_Y_WITH_DC,
get_tx_type(xd, &xd->block[0]),
get_eob(xd, segment_id, 256),
xd->qcoeff, vp9_default_zig_zag1d_16x16, TX_16X16);
xd->block[0].eob = c;
eobtotal += c;
......@@ -377,12 +373,9 @@ static int decode_coefs_4x4(VP9D_COMP *dx, MACROBLOCKD *xd,
BOOL_DECODER* const bc,
PLANE_TYPE type, int i, int seg_eob,
TX_TYPE tx_type, const int *scan) {
int c;
c = decode_coefs(dx, xd, bc, i, type, tx_type, seg_eob,
xd->block[i].qcoeff, scan, TX_4X4);
int c = decode_coefs(dx, xd, bc, i, type, tx_type, seg_eob,
xd->block[i].qcoeff, scan, TX_4X4);
xd->block[i].eob = c;
return c;
}
......@@ -464,16 +457,13 @@ int vp9_decode_mb_tokens(VP9D_COMP* const dx,
MACROBLOCKD* const xd,
BOOL_DECODER* const bc) {
const TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size;
int eobtotal;
if (tx_size == TX_16X16) {
eobtotal = vp9_decode_mb_tokens_16x16(dx, xd, bc);
} else if (tx_size == TX_8X8) {
eobtotal = vp9_decode_mb_tokens_8x8(dx, xd, bc);
} else {
assert(tx_size == TX_4X4);
eobtotal = vp9_decode_mb_tokens_4x4(dx, xd, bc);
switch (tx_size) {
case TX_16X16:
return vp9_decode_mb_tokens_16x16(dx, xd, bc);
case TX_8X8:
return vp9_decode_mb_tokens_8x8(dx, xd, bc);
default:
assert(tx_size == TX_4X4);
return vp9_decode_mb_tokens_4x4(dx, xd, bc);
}
return eobtotal;
}
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