Commit 41e3a9ef authored by Ronald S. Bultje's avatar Ronald S. Bultje

Add and consistently use PLANE_TYPE.

Change the macros PLANE_TYPE_{Y_NO_DC,Y2,UV,Y_WITH_DC} to a typed enum,
and use this typed enum consistently across all places where relevant.
In places where the type is implied (e.g. in functions that only handle
second order planes or chroma planes), remove it as a function argument
and instead hardcode the proper enum in the code directly.

Change-Id: I93652b4a36aa43163d49c732b0bf5c4442738c47
parent 5cfff7ce
......@@ -52,10 +52,12 @@ typedef struct {
int r, c;
} POS;
#define PLANE_TYPE_Y_NO_DC 0
#define PLANE_TYPE_Y2 1
#define PLANE_TYPE_UV 2
#define PLANE_TYPE_Y_WITH_DC 3
typedef enum PlaneType {
PLANE_TYPE_Y_NO_DC = 0,
PLANE_TYPE_Y2,
PLANE_TYPE_UV,
PLANE_TYPE_Y_WITH_DC,
} PLANE_TYPE;
typedef char ENTROPY_CONTEXT;
typedef struct {
......
......@@ -137,7 +137,7 @@ int get_token(int v) {
#if CONFIG_HYBRIDTRANSFORM
void static count_tokens_adaptive_scan(const MACROBLOCKD *xd, INT16 *qcoeff_ptr,
int block, int type,
int block, PLANE_TYPE type,
TX_TYPE tx_type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int eob, int seg_eob,
......@@ -182,7 +182,7 @@ void static count_tokens_adaptive_scan(const MACROBLOCKD *xd, INT16 *qcoeff_ptr,
}
#endif
void static count_tokens(INT16 *qcoeff_ptr, int block, int type,
void static count_tokens(INT16 *qcoeff_ptr, int block, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int eob, int seg_eob, FRAME_CONTEXT *const fc) {
int c, pt, token, band;
......@@ -201,7 +201,7 @@ void static count_tokens(INT16 *qcoeff_ptr, int block, int type,
}
}
void static count_tokens_8x8(INT16 *qcoeff_ptr, int block, int type,
void static count_tokens_8x8(INT16 *qcoeff_ptr, int block, PLANE_TYPE type,
#if CONFIG_HYBRIDTRANSFORM8X8
TX_TYPE tx_type,
#endif
......@@ -233,7 +233,7 @@ void static count_tokens_8x8(INT16 *qcoeff_ptr, int block, int type,
}
}
void static count_tokens_16x16(INT16 *qcoeff_ptr, int block, int type,
void static count_tokens_16x16(INT16 *qcoeff_ptr, int block, PLANE_TYPE type,
#if CONFIG_HYBRIDTRANSFORM16X16
TX_TYPE tx_type,
#endif
......@@ -303,7 +303,8 @@ static int vp8_get_signed(BOOL_DECODER *br, int value_to_sign) {
} while (0);
static int vp8_decode_coefs(VP8D_COMP *dx, const MACROBLOCKD *xd,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, int type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
PLANE_TYPE type,
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
TX_TYPE tx_type,
#endif
......@@ -312,7 +313,7 @@ static int vp8_decode_coefs(VP8D_COMP *dx, const MACROBLOCKD *xd,
const int *coef_bands) {
FRAME_CONTEXT *const fc = &dx->common.fc;
BOOL_DECODER *br = xd->current_bc;
int tmp, c = (type == 0);
int tmp, c = (type == PLANE_TYPE_Y_NO_DC);
const vp8_prob *prob, *coef_probs;
switch (block_type) {
......@@ -450,7 +451,8 @@ int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd) {
ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
char* const eobs = xd->eobs;
int c, i, type, eobtotal = 0, seg_eob;
PLANE_TYPE type;
int c, i, eobtotal = 0, seg_eob;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const int seg_active = segfeature_active(xd, segment_id, SEG_LVL_EOB);
INT16 *qcoeff_ptr = &xd->qcoeff[0];
......@@ -471,7 +473,6 @@ int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd) {
// Luma block
{
const int* const scan = vp8_default_zig_zag1d_16x16;
//printf("16: %d\n", tx_type);
c = vp8_decode_coefs(pbi, xd, A, L, type,
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
tx_type,
......@@ -502,7 +503,6 @@ int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd) {
ENTROPY_CONTEXT* const l = L + vp8_block2left_8x8[i];
const int* const scan = vp8_default_zig_zag1d_8x8;
//printf("8: %d\n", tx_type);
c = vp8_decode_coefs(pbi, xd, a, l, type,
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
tx_type,
......@@ -526,7 +526,8 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) {
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
char *const eobs = xd->eobs;
int c, i, type, eobtotal = 0, seg_eob;
PLANE_TYPE type;
int c, i, eobtotal = 0, seg_eob;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const int seg_active = segfeature_active(xd, segment_id, SEG_LVL_EOB);
INT16 *qcoeff_ptr = &xd->qcoeff[0];
......@@ -633,8 +634,8 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd) {
char *const eobs = xd->eobs;
const int *scan = vp8_default_zig_zag1d;
int c, i, type, eobtotal = 0, seg_eob = 16;
PLANE_TYPE type;
int c, i, eobtotal = 0, seg_eob = 16;
INT16 *qcoeff_ptr = &xd->qcoeff[0];
int segment_id = xd->mode_info_context->mbmi.segment_id;
......
......@@ -266,7 +266,7 @@ static const int plane_rd_mult[4] = {
}\
}
void optimize_b(MACROBLOCK *mb, int i, int type,
void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
const VP8_ENCODER_RTCD *rtcd, int tx_type) {
BLOCK *b;
......@@ -343,7 +343,7 @@ void optimize_b(MACROBLOCK *mb, int i, int type,
coeff_ptr = b->coeff;
qcoeff_ptr = d->qcoeff;
dqcoeff_ptr = d->dqcoeff;
i0 = !type;
i0 = (type == PLANE_TYPE_Y_NO_DC);
eob = d->eob;
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
......@@ -517,7 +517,7 @@ fall between -65 and +65.
**************************************************************************/
#define SUM_2ND_COEFF_THRESH 65
static void check_reset_2nd_coeffs(MACROBLOCKD *xd, int type,
static void check_reset_2nd_coeffs(MACROBLOCKD *xd,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
int sum = 0;
int i;
......@@ -540,12 +540,12 @@ static void check_reset_2nd_coeffs(MACROBLOCKD *xd, int type,
bd->dqcoeff[rc] = 0;
}
bd->eob = 0;
*a = *l = (bd->eob != !type);
*a = *l = (bd->eob != 0);
}
}
#define SUM_2ND_COEFF_THRESH_8X8 32
static void check_reset_8x8_2nd_coeffs(MACROBLOCKD *xd, int type,
static void check_reset_8x8_2nd_coeffs(MACROBLOCKD *xd,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
int sum = 0;
BLOCKD *bd = &xd->block[24];
......@@ -570,13 +570,13 @@ static void check_reset_8x8_2nd_coeffs(MACROBLOCKD *xd, int type,
bd->qcoeff[8] = 0;
bd->dqcoeff[8] = 0;
bd->eob = 0;
*a = *l = (bd->eob != !type);
*a = *l = (bd->eob != 0);
}
}
void vp8_optimize_mby_4x4(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
int b;
int type;
PLANE_TYPE type;
int has_2nd_order;
ENTROPY_CONTEXT_PLANES t_above, t_left;
ENTROPY_CONTEXT *ta;
......@@ -604,7 +604,7 @@ void vp8_optimize_mby_4x4(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
b = 24;
optimize_b(x, b, PLANE_TYPE_Y2,
ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd, TX_4X4);
check_reset_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
check_reset_2nd_coeffs(&x->e_mbd,
ta + vp8_block2above[b], tl + vp8_block2left[b]);
}
}
......@@ -637,7 +637,7 @@ static void optimize_mb_4x4(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
void vp8_optimize_mby_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
int b;
int type;
PLANE_TYPE type;
ENTROPY_CONTEXT_PLANES t_above, t_left;
ENTROPY_CONTEXT *ta;
ENTROPY_CONTEXT *tl;
......@@ -650,7 +650,7 @@ void vp8_optimize_mby_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
ta = (ENTROPY_CONTEXT *)&t_above;
tl = (ENTROPY_CONTEXT *)&t_left;
type = 0;
type = PLANE_TYPE_Y_NO_DC;
for (b = 0; b < 16; b += 4) {
optimize_b(x, b, type,
ta + vp8_block2above[b], tl + vp8_block2left[b],
......@@ -660,7 +660,7 @@ void vp8_optimize_mby_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
}
// 8x8 always have 2nd roder haar block
check_reset_8x8_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
check_reset_8x8_2nd_coeffs(&x->e_mbd,
ta + vp8_block2above_8x8[24], tl + vp8_block2left_8x8[24]);
}
......@@ -693,7 +693,7 @@ void optimize_mb_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
vp8_optimize_mbuv_8x8(x, rtcd);
}
void optimize_b_16x16(MACROBLOCK *mb, int i, int type,
void optimize_b_16x16(MACROBLOCK *mb, int i, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
const VP8_ENCODER_RTCD *rtcd) {
BLOCK *b = &mb->block[i];
......
......@@ -568,9 +568,9 @@ int VP8_UVSSE(MACROBLOCK *x, const vp8_variance_rtcd_vtable_t *rtcd) {
}
static int cost_coeffs_2x2(MACROBLOCK *mb,
BLOCKD *b, int type,
BLOCKD *b, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
int c = !type; /* start at coef 0, unless Y with Y2 */
int c = (type == PLANE_TYPE_Y_NO_DC); /* start at coef 0, unless Y with Y2 */
int eob = b->eob;
int pt; /* surrounding block/prev coef predictor */
int cost = 0;
......@@ -596,11 +596,11 @@ static int cost_coeffs_2x2(MACROBLOCK *mb,
return cost;
}
static int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, int type,
static int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int tx_size) {
const int eob = b->eob;
int c = !type; /* start at coef 0, unless Y with Y2 */
int c = (type == PLANE_TYPE_Y_NO_DC); /* start at coef 0, unless Y with Y2 */
int cost = 0, default_eob, seg_eob;
int pt; /* surrounding block/prev coef predictor */
int const *scan, *band;
......
This diff is collapsed.
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