Commit 854c007a authored by Yaowu Xu's avatar Yaowu Xu
Browse files

Remove duplicate and unused functions

Change-Id: I944035e720ef834561a9da0d723879a4f787312c
parent 09202d80
......@@ -106,7 +106,6 @@ typedef struct
void (*short_walsh4x4)(short *input, short *output, int pitch);
void (*quantize_b)(BLOCK *b, BLOCKD *d);
void (*quantize_brd)(BLOCK *b, BLOCKD *d);
......
......@@ -68,7 +68,7 @@ void vp8_encode_intra4x4block_rd(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x, BL
x->short_fdct4x4rd(be->src_diff, be->coeff, 32);
x->quantize_brd(be, b);
x->quantize_b(be, b);
x->e_mbd.mbmi.mb_skip_coeff &= (!b->eob);
......@@ -160,8 +160,7 @@ void vp8_encode_intra16x16mbyrd(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
x->e_mbd.mbmi.mb_skip_coeff = 1;
vp8_quantize_mbyrd(x);
vp8_quantize_mby(x);
vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
......@@ -227,9 +226,7 @@ void vp8_encode_intra16x16mbuvrd(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
vp8_transform_mbuvrd(x);
vp8_quantize_mbuvrd(x);
vp8_quantize_mbuv(x);
vp8_inverse_transform_mbuv(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
......
......@@ -494,140 +494,6 @@ void vp8_optimize_b(MACROBLOCK *x, int i, int type, ENTROPY_CONTEXT *a, ENTROPY_
return;
}
void vp8_optimize_bplus(MACROBLOCK *x, int i, int type, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, const VP8_ENCODER_RTCD *rtcd)
{
BLOCK *b = &x->block[i];
BLOCKD *bd = &x->e_mbd.block[i];
short *dequant_ptr = &bd->dequant[0][0];
int nzpos[16] = {0};
short saved_qcoefs[16];
short saved_dqcoefs[16];
int baserate, baseerror, baserd;
int rate, error, thisrd;
int k;
int nzcoefcount = 0;
int nc, bestnc = 0;
int besteob;
// count potential coefficient to be optimized
for (k = !type; k < 16; k++)
{
int qcoef = abs(bd->qcoeff[k]);
int coef = abs(b->coeff[k]);
int dq = dequant_ptr[k];
if (qcoef && (qcoef * dq < coef) && (coef < (qcoef * dq + dq)))
{
nzpos[nzcoefcount] = k;
nzcoefcount++;
}
}
// if nothing here, do nothing for this block.
if (!nzcoefcount)
{
//do not update context, we need do the other half.
//*a = *l = (bd->eob != !type);
return;
}
// save a copy of quantized coefficients
vpx_memcpy(saved_qcoefs, bd->qcoeff, 32);
vpx_memcpy(saved_dqcoefs, bd->dqcoeff, 32);
besteob = bd->eob;
baserate = cost_coeffs(x, bd, type, a, l);
baseerror = ENCODEMB_INVOKE(&rtcd->encodemb, berr)(b->coeff, bd->dqcoeff) >> 2;
baserd = RDFUNC(x->rdmult, x->rddiv, baserate, baseerror, 100);
for (nc = 1; nc < (1 << nzcoefcount); nc++)
{
//reset coefficients
vpx_memcpy(bd->qcoeff, saved_qcoefs, 32);
vpx_memcpy(bd->dqcoeff, saved_dqcoefs, 32);
for (k = 0; k < nzcoefcount; k++)
{
int pos = nzpos[k];
if ((nc & (1 << k)))
{
int cur_qcoef = bd->qcoeff[pos];
if (cur_qcoef < 0)
{
bd->qcoeff[pos]--;
bd->dqcoeff[pos] = bd->qcoeff[pos] * dequant_ptr[pos];
}
else
{
bd->qcoeff[pos]++;
bd->dqcoeff[pos] = bd->qcoeff[pos] * dequant_ptr[pos];
}
}
}
{
int eob = -1;
int rc;
int m;
for (m = 0; m < 16; m++)
{
rc = vp8_default_zig_zag1d[m];
if (bd->qcoeff[rc])
eob = m;
}
bd->eob = eob + 1;
}
rate = cost_coeffs(x, bd, type, a, l);
error = ENCODEMB_INVOKE(&rtcd->encodemb, berr)(b->coeff, bd->dqcoeff) >> 2;
thisrd = RDFUNC(x->rdmult, x->rddiv, rate, error, 100);
if (thisrd < baserd)
{
baserd = thisrd;
bestnc = nc;
besteob = bd->eob;
}
}
//reset coefficients
vpx_memcpy(bd->qcoeff, saved_qcoefs, 32);
vpx_memcpy(bd->dqcoeff, saved_dqcoefs, 32);
if (bestnc)
{
for (k = 0; k < nzcoefcount; k++)
{
int pos = nzpos[k];
if (bestnc & (1 << k))
{
int cur_qcoef = bd->qcoeff[pos];
if (cur_qcoef < 0)
{
bd->qcoeff[pos]++;
bd->dqcoeff[pos] = bd->qcoeff[pos] * dequant_ptr[pos];
}
else
{
bd->qcoeff[pos]--;
bd->dqcoeff[pos] = bd->qcoeff[pos] * dequant_ptr[pos];
}
}
}
}
bd->eob = besteob;
//do not update context, we need do the other half.
//*a = *l = (bd->eob != !type);
return;
}
void vp8_optimize_y2b(MACROBLOCK *x, int i, int type, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, const VP8_ENCODER_RTCD *rtcd)
{
......@@ -752,181 +618,6 @@ void vp8_optimize_mb(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
void vp8_super_slow_yquant_optimization(MACROBLOCK *x, int type, const VP8_ENCODER_RTCD *rtcd)
{
BLOCK *b = &x->block[0];
BLOCKD *bd = &x->e_mbd.block[0];
short *dequant_ptr = &bd->dequant[0][0];
struct
{
int block;
int pos;
} nzpos[256];
short saved_qcoefs[256];
short saved_dqcoefs[256];
short *coef_ptr = x->coeff;
short *qcoef_ptr = x->e_mbd.qcoeff;
short *dqcoef_ptr = x->e_mbd.dqcoeff;
int baserate, baseerror, baserd;
int rate, error, thisrd;
int i, k;
int nzcoefcount = 0;
int nc, bestnc = 0;
int besteob;
//this code has assumption in macroblock coeff buffer layout
for (i = 0; i < 16; i++)
{
// count potential coefficient to be optimized
for (k = !type; k < 16; k++)
{
int qcoef = abs(qcoef_ptr[i*16 + k]);
int coef = abs(coef_ptr[i*16 + k]);
int dq = dequant_ptr[k];
if (qcoef && (qcoef * dq > coef) && (qcoef * dq < coef + dq))
{
nzpos[nzcoefcount].block = i;
nzpos[nzcoefcount].pos = k;
nzcoefcount++;
}
}
}
// if nothing here, do nothing for this macro_block.
if (!nzcoefcount || nzcoefcount > 15)
{
return;
}
/******************************************************************************
looking from each coeffient's perspective, each identifed coefficent above could
have 2 values:roundeddown(x) and roundedup(x). Therefore the total number of
different states is less than 2**nzcoefcount.
******************************************************************************/
// save the qunatized coefficents and dequantized coefficicents
vpx_memcpy(saved_qcoefs, x->e_mbd.qcoeff, 256);
vpx_memcpy(saved_dqcoefs, x->e_mbd.dqcoeff, 256);
baserate = mbycost_coeffs(x);
baseerror = ENCODEMB_INVOKE(&rtcd->encodemb, mberr)(x, !type);
baserd = RDFUNC(x->rdmult, x->rddiv, baserate, baseerror, 100);
for (nc = 1; nc < (1 << nzcoefcount); nc++)
{
//reset coefficients
vpx_memcpy(x->e_mbd.qcoeff, saved_qcoefs, 256);
vpx_memcpy(x->e_mbd.dqcoeff, saved_dqcoefs, 256);
for (k = 0; k < nzcoefcount; k++)
{
int bk = nzpos[k].block;
int pos = nzpos[k].pos;
int mbkpos = bk * 16 + pos;
if ((nc & (1 << k)))
{
int cur_qcoef = x->e_mbd.qcoeff[mbkpos];
if (cur_qcoef < 0)
{
x->e_mbd.qcoeff[mbkpos]++;
x->e_mbd.dqcoeff[mbkpos] = x->e_mbd.qcoeff[mbkpos] * dequant_ptr[pos];
}
else
{
x->e_mbd.qcoeff[mbkpos]--;
x->e_mbd.dqcoeff[mbkpos] = x->e_mbd.qcoeff[mbkpos] * dequant_ptr[pos];
}
}
}
for (i = 0; i < 16; i++)
{
BLOCKD *bd = &x->e_mbd.block[i];
{
int eob = -1;
int rc;
int l;
for (l = 0; l < 16; l++)
{
rc = vp8_default_zig_zag1d[l];
if (bd->qcoeff[rc])
eob = l;
}
bd->eob = eob + 1;
}
}
rate = mbycost_coeffs(x);
error = ENCODEMB_INVOKE(&rtcd->encodemb, mberr)(x, !type);;
thisrd = RDFUNC(x->rdmult, x->rddiv, rate, error, 100);
if (thisrd < baserd)
{
baserd = thisrd;
bestnc = nc;
besteob = bd->eob;
}
}
//reset coefficients
vpx_memcpy(x->e_mbd.qcoeff, saved_qcoefs, 256);
vpx_memcpy(x->e_mbd.dqcoeff, saved_dqcoefs, 256);
if (bestnc)
{
for (k = 0; k < nzcoefcount; k++)
{
int bk = nzpos[k].block;
int pos = nzpos[k].pos;
int mbkpos = bk * 16 + pos;
if ((nc & (1 << k)))
{
int cur_qcoef = x->e_mbd.qcoeff[mbkpos];
if (cur_qcoef < 0)
{
x->e_mbd.qcoeff[mbkpos]++;
x->e_mbd.dqcoeff[mbkpos] = x->e_mbd.qcoeff[mbkpos] * dequant_ptr[pos];
}
else
{
x->e_mbd.qcoeff[mbkpos]--;
x->e_mbd.dqcoeff[mbkpos] = x->e_mbd.qcoeff[mbkpos] * dequant_ptr[pos];
}
}
}
}
for (i = 0; i < 16; i++)
{
BLOCKD *bd = &x->e_mbd.block[i];
{
int eob = -1;
int rc;
int l;
for (l = 0; l < 16; l++)
{
rc = vp8_default_zig_zag1d[l];
if (bd->qcoeff[rc])
eob = l;
}
bd->eob = eob + 1;
}
}
return;
}
static void vp8_find_mb_skip_coef(MACROBLOCK *x)
{
int i;
......@@ -955,42 +646,6 @@ static void vp8_find_mb_skip_coef(MACROBLOCK *x)
}
void vp8_optimize_mb_slow(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
{
int b;
TEMP_CONTEXT t, t2;
int type = 0;
vp8_setup_temp_context(&t, x->e_mbd.above_context[Y1CONTEXT], x->e_mbd.left_context[Y1CONTEXT], 4);
if (x->e_mbd.mbmi.mode == SPLITMV || x->e_mbd.mbmi.mode == B_PRED)
type = 3;
vp8_super_slow_yquant_optimization(x, type, rtcd);
/*
for(b=0;b<16;b++)
{
vp8_optimize_b(x, b, type, t.a + vp8_block2above[b], t.l + vp8_block2left[b]);
}
*/
vp8_setup_temp_context(&t, x->e_mbd.above_context[UCONTEXT], x->e_mbd.left_context[UCONTEXT], 2);
for (b = 16; b < 20; b++)
{
vp8_optimize_b(x, b, vp8_block2type[b], t.a + vp8_block2above[b], t.l + vp8_block2left[b], rtcd);
}
vp8_setup_temp_context(&t2, x->e_mbd.above_context[VCONTEXT], x->e_mbd.left_context[VCONTEXT], 2);
for (b = 20; b < 24; b++)
{
vp8_optimize_b(x, b, vp8_block2type[b], t2.a + vp8_block2above[b], t2.l + vp8_block2left[b], rtcd);
}
}
void vp8_optimize_mby(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
{
int b;
......@@ -1105,7 +760,7 @@ void vp8_encode_inter16x16uv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
vp8_transform_mbuv(x);
vp8_quantize_mbuv(x);
vp8_quantize_mb(x);
vp8_inverse_transform_mbuv(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
......@@ -1120,6 +775,6 @@ void vp8_encode_inter16x16uvrd(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
vp8_transform_mbuvrd(x);
vp8_quantize_mbuvrd(x);
vp8_quantize_mbuv(x);
}
......@@ -263,7 +263,6 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
z->vp8_short_fdct4x4_ptr = x->vp8_short_fdct4x4_ptr;
z->short_walsh4x4 = x->short_walsh4x4;
z->quantize_b = x->quantize_b;
z->quantize_brd = x->quantize_brd;
/*
z->mvc = x->mvc;
......
......@@ -1150,12 +1150,10 @@ void vp8_set_speed_features(VP8_COMP *cpi)
if (cpi->sf.improved_quant)
{
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize, quantb);
cpi->mb.quantize_brd = QUANTIZE_INVOKE(&cpi->rtcd.quantize, quantb);
}
else
{
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquantb);
cpi->mb.quantize_brd = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquantb);
}
#if CONFIG_RUNTIME_CPU_DETECT
......
......@@ -180,71 +180,3 @@ void vp8_quantize_mbuv(MACROBLOCK *x)
x->e_mbd.mbmi.mb_skip_coeff &= (!x->e_mbd.block[i].eob);
}
}
// This function is not currently called
void vp8_quantize_mbrd(MACROBLOCK *x)
{
int i;
x->e_mbd.mbmi.mb_skip_coeff = 1;
if (x->e_mbd.mbmi.mode != B_PRED && x->e_mbd.mbmi.mode != SPLITMV)
{
for (i = 0; i < 16; i++)
{
x->quantize_brd(&x->block[i], &x->e_mbd.block[i]);
x->e_mbd.mbmi.mb_skip_coeff &= (x->e_mbd.block[i].eob < 2);
}
for (i = 16; i < 25; i++)
{
x->quantize_brd(&x->block[i], &x->e_mbd.block[i]);
x->e_mbd.mbmi.mb_skip_coeff &= (!x->e_mbd.block[i].eob);
}
}
else
{
for (i = 0; i < 24; i++)
{
x->quantize_brd(&x->block[i], &x->e_mbd.block[i]);
x->e_mbd.mbmi.mb_skip_coeff &= (!x->e_mbd.block[i].eob);
}
}
}
void vp8_quantize_mbuvrd(MACROBLOCK *x)
{
int i;
for (i = 16; i < 24; i++)
{
x->quantize_brd(&x->block[i], &x->e_mbd.block[i]);
x->e_mbd.mbmi.mb_skip_coeff &= (!x->e_mbd.block[i].eob);
}
}
void vp8_quantize_mbyrd(MACROBLOCK *x)
{
int i;
if (x->e_mbd.mbmi.mode != B_PRED && x->e_mbd.mbmi.mode != SPLITMV)
{
for (i = 0; i < 16; i++)
{
x->quantize_brd(&x->block[i], &x->e_mbd.block[i]);
x->e_mbd.mbmi.mb_skip_coeff &= (x->e_mbd.block[i].eob < 2);
}
x->quantize_brd(&x->block[24], &x->e_mbd.block[24]);
x->e_mbd.mbmi.mb_skip_coeff &= (!x->e_mbd.block[24].eob);
}
else
{
for (i = 0; i < 16; i++)
{
x->quantize_brd(&x->block[i], &x->e_mbd.block[i]);
x->e_mbd.mbmi.mb_skip_coeff &= (!x->e_mbd.block[i].eob);
}
}
}
......@@ -46,8 +46,5 @@ typedef struct
extern void vp8_quantize_mb(MACROBLOCK *x);
extern void vp8_quantize_mbuv(MACROBLOCK *x);
extern void vp8_quantize_mby(MACROBLOCK *x);
extern void vp8_quantize_mbyrd(MACROBLOCK *x);
extern void vp8_quantize_mbuvrd(MACROBLOCK *x);
extern void vp8_quantize_mbrd(MACROBLOCK *x);
#endif
......@@ -1038,7 +1038,7 @@ static unsigned int vp8_encode_inter_mb_segment(MACROBLOCK *x, int const *labels
// set to 0 no way to account for 2nd order DC so discount
//be->coeff[0] = 0;
x->quantize_brd(be, bd);
x->quantize_b(be, bd);
distortion += ENCODEMB_INVOKE(rtcd, berr)(be->coeff, bd->dqcoeff);
}
......@@ -1076,7 +1076,7 @@ static void macro_block_yrd(MACROBLOCK *mb, int *Rate, int *Distortion, const vp
// Quantization
for (b = 0; b < 16; b++)
{
mb->quantize_brd(&mb->block[b], &mb->e_mbd.block[b]);
mb->quantize_b(&mb->block[b], &mb->e_mbd.block[b]);
}
// DC predication and Quantization of 2nd Order block
......@@ -1084,7 +1084,7 @@ static void macro_block_yrd(MACROBLOCK *mb, int *Rate, int *Distortion, const vp
{
{
mb->quantize_brd(mb_y2, x_y2);
mb->quantize_b(mb_y2, x_y2);
}
}
......
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