120 |
unsigned int lambda, |
unsigned int lambda, |
121 |
const uint16_t * mpeg_quant_matrices, |
const uint16_t * mpeg_quant_matrices, |
122 |
const unsigned int quant_sq, |
const unsigned int quant_sq, |
123 |
const unsigned int metric) |
const unsigned int metric, |
124 |
|
const int bound) |
125 |
{ |
{ |
126 |
int direction; |
int direction; |
127 |
int16_t *pCurrent; |
int16_t *pCurrent; |
140 |
} |
} |
141 |
|
|
142 |
predict_acdc(pMB-(x+mb_width*y), x, y, mb_width, block, qcoeff, |
predict_acdc(pMB-(x+mb_width*y), x, y, mb_width, block, qcoeff, |
143 |
quant, iDcScaler, predictors, 0); |
quant, iDcScaler, predictors, bound); |
144 |
|
|
145 |
direction = pMB->acpred_directions[block]; |
direction = pMB->acpred_directions[block]; |
146 |
pCurrent = (int16_t*)pMB->pred_values[block]; |
pCurrent = (int16_t*)pMB->pred_values[block]; |
372 |
MACROBLOCK * const pMB, const MACROBLOCK * const pMBs, |
MACROBLOCK * const pMB, const MACROBLOCK * const pMBs, |
373 |
const int x, const int y, |
const int x, const int y, |
374 |
const MBParam * const pParam, const uint32_t MotionFlags, |
const MBParam * const pParam, const uint32_t MotionFlags, |
375 |
const VECTOR * const backup) |
const VECTOR * const backup, const int bound) |
376 |
{ |
{ |
377 |
|
|
378 |
unsigned int cbp = 0, t = 0, i; |
unsigned int cbp = 0, t = 0, i; |
401 |
Data8->rel_var8[0] = Data->rel_var8[i]; |
Data8->rel_var8[0] = Data->rel_var8[i]; |
402 |
|
|
403 |
if(Data->qpel) { |
if(Data->qpel) { |
404 |
Data8->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x, y, i); |
Data8->predMV = get_qpmv2(pMBs, pParam->mb_width, bound, x, y, i); |
405 |
if (i != 0) t = d_mv_bits( Data8->currentQMV->x, Data8->currentQMV->y, |
if (i != 0) t = d_mv_bits( Data8->currentQMV->x, Data8->currentQMV->y, |
406 |
Data8->predMV, Data8->iFcode, 0) - 2; |
Data8->predMV, Data8->iFcode, 0) - 2; |
407 |
} else { |
} else { |
408 |
Data8->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, i); |
Data8->predMV = get_pmv2(pMBs, pParam->mb_width, bound, x, y, i); |
409 |
if (i != 0) t = d_mv_bits( Data8->currentMV->x, Data8->currentMV->y, |
if (i != 0) t = d_mv_bits( Data8->currentMV->x, Data8->currentMV->y, |
410 |
Data8->predMV, Data8->iFcode, 0) - 2; |
Data8->predMV, Data8->iFcode, 0) - 2; |
411 |
} |
} |
536 |
|
|
537 |
static int |
static int |
538 |
findRD_intra(SearchData * const Data, MACROBLOCK * pMB, |
findRD_intra(SearchData * const Data, MACROBLOCK * pMB, |
539 |
const int x, const int y, const int mb_width) |
const int x, const int y, const int mb_width, const int bound) |
540 |
{ |
{ |
541 |
unsigned int cbp[2] = {0, 0}, bits[2], i; |
unsigned int cbp[2] = {0, 0}, bits[2], i; |
542 |
/* minimum number of bits that WILL be coded in intra - mcbpc 5, cby 2 acdc flag - 1 and DC coeffs - 4*3+2*2 */ |
/* minimum number of bits that WILL be coded in intra - mcbpc 5, cby 2 acdc flag - 1 and DC coeffs - 4*3+2*2 */ |
554 |
|
|
555 |
distortion = Block_CalcBitsIntra(pMB, x, y, mb_width, i, in, coeff, dqcoeff, |
distortion = Block_CalcBitsIntra(pMB, x, y, mb_width, i, in, coeff, dqcoeff, |
556 |
predictors[i], iQuant, Data->quant_type, bits, cbp, |
predictors[i], iQuant, Data->quant_type, bits, cbp, |
557 |
Data->lambda[i], Data->mpeg_quant_matrices, Data->quant_sq, Data->metric); |
Data->lambda[i], Data->mpeg_quant_matrices, Data->quant_sq, |
558 |
|
Data->metric, bound); |
559 |
bits1 += distortion + BITS_MULT * bits[0]; |
bits1 += distortion + BITS_MULT * bits[0]; |
560 |
bits2 += distortion + BITS_MULT * bits[1]; |
bits2 += distortion + BITS_MULT * bits[1]; |
561 |
|
|
570 |
transfer_8to16copy(in, Data->CurU, Data->iEdgedWidth/2); |
transfer_8to16copy(in, Data->CurU, Data->iEdgedWidth/2); |
571 |
distortion = Block_CalcBitsIntra(pMB, x, y, mb_width, 4, in, coeff, dqcoeff, |
distortion = Block_CalcBitsIntra(pMB, x, y, mb_width, 4, in, coeff, dqcoeff, |
572 |
predictors[4], iQuant, Data->quant_type, bits, cbp, |
predictors[4], iQuant, Data->quant_type, bits, cbp, |
573 |
Data->lambda[4], Data->mpeg_quant_matrices, Data->quant_sq, Data->metric); |
Data->lambda[4], Data->mpeg_quant_matrices, Data->quant_sq, |
574 |
|
Data->metric, bound); |
575 |
bits1 += distortion + BITS_MULT * bits[0]; |
bits1 += distortion + BITS_MULT * bits[0]; |
576 |
bits2 += distortion + BITS_MULT * bits[1]; |
bits2 += distortion + BITS_MULT * bits[1]; |
577 |
|
|
582 |
transfer_8to16copy(in, Data->CurV, Data->iEdgedWidth/2); |
transfer_8to16copy(in, Data->CurV, Data->iEdgedWidth/2); |
583 |
distortion = Block_CalcBitsIntra(pMB, x, y, mb_width, 5, in, coeff, dqcoeff, |
distortion = Block_CalcBitsIntra(pMB, x, y, mb_width, 5, in, coeff, dqcoeff, |
584 |
predictors[5], iQuant, Data->quant_type, bits, cbp, |
predictors[5], iQuant, Data->quant_type, bits, cbp, |
585 |
Data->lambda[5], Data->mpeg_quant_matrices, Data->quant_sq, Data->metric); |
Data->lambda[5], Data->mpeg_quant_matrices, Data->quant_sq, |
586 |
|
Data->metric, bound); |
587 |
|
|
588 |
bits1 += distortion + BITS_MULT * bits[0]; |
bits1 += distortion + BITS_MULT * bits[0]; |
589 |
bits2 += distortion + BITS_MULT * bits[1]; |
bits2 += distortion + BITS_MULT * bits[1]; |
649 |
const IMAGE * const pCurrent, |
const IMAGE * const pCurrent, |
650 |
const IMAGE * const pRef, |
const IMAGE * const pRef, |
651 |
const IMAGE * const vGMC, |
const IMAGE * const vGMC, |
652 |
const int coding_type) |
const int coding_type, |
653 |
|
const int bound) |
654 |
{ |
{ |
655 |
int mode = MODE_INTER; |
int mode = MODE_INTER; |
656 |
int mcsel = 0; |
int mcsel = 0; |
694 |
|
|
695 |
if (inter4v) { |
if (inter4v) { |
696 |
int v4_rd; |
int v4_rd; |
697 |
v4_rd = findRD_inter4v(Data, pMB, pMBs, x, y, pParam, MotionFlags, backup); |
v4_rd = findRD_inter4v(Data, pMB, pMBs, x, y, pParam, MotionFlags, backup, bound); |
698 |
if (v4_rd < min_rd) { |
if (v4_rd < min_rd) { |
699 |
Data->iMinSAD[0] = min_rd = v4_rd; |
Data->iMinSAD[0] = min_rd = v4_rd; |
700 |
mode = MODE_INTER4V; |
mode = MODE_INTER4V; |
704 |
|
|
705 |
/* there is no way for INTRA to take less than 24 bits - go to findRD_intra() for calculations */ |
/* there is no way for INTRA to take less than 24 bits - go to findRD_intra() for calculations */ |
706 |
if (min_rd > 24*BITS_MULT) { |
if (min_rd > 24*BITS_MULT) { |
707 |
intra_rd = findRD_intra(Data, pMB, x, y, pParam->mb_width); |
intra_rd = findRD_intra(Data, pMB, x, y, pParam->mb_width, bound); |
708 |
if (intra_rd < min_rd) { |
if (intra_rd < min_rd) { |
709 |
*Data->iMinSAD = min_rd = intra_rd; |
*Data->iMinSAD = min_rd = intra_rd; |
710 |
mode = MODE_INTRA; |
mode = MODE_INTRA; |
758 |
const IMAGE * const pCurrent, |
const IMAGE * const pCurrent, |
759 |
const IMAGE * const pRef, |
const IMAGE * const pRef, |
760 |
const IMAGE * const vGMC, |
const IMAGE * const vGMC, |
761 |
const int coding_type) |
const int coding_type, |
762 |
|
const int bound) |
763 |
{ |
{ |
764 |
int mode = MODE_INTER; |
int mode = MODE_INTER; |
765 |
int mcsel = 0; |
int mcsel = 0; |
871 |
|
|
872 |
if (inter4v) { |
if (inter4v) { |
873 |
int v4_rd; |
int v4_rd; |
874 |
v4_rd = findRD_inter4v(Data, pMB, pMBs, x, y, pParam, MotionFlags, backup); |
v4_rd = findRD_inter4v(Data, pMB, pMBs, x, y, pParam, MotionFlags, backup, bound); |
875 |
if (v4_rd < min_rd) { |
if (v4_rd < min_rd) { |
876 |
Data->iMinSAD[0] = min_rd = v4_rd; |
Data->iMinSAD[0] = min_rd = v4_rd; |
877 |
mode = MODE_INTER4V; |
mode = MODE_INTER4V; |
947 |
|
|
948 |
if(mode == MODE_INTER4V) { |
if(mode == MODE_INTER4V) { |
949 |
int v4_rd; |
int v4_rd; |
950 |
v4_rd = findRD_inter4v(Data, pMB, pMBs, x, y, pParam, MotionFlags, backup); |
v4_rd = findRD_inter4v(Data, pMB, pMBs, x, y, pParam, MotionFlags, backup, bound); |
951 |
if (v4_rd < min_rd) { |
if (v4_rd < min_rd) { |
952 |
Data->iMinSAD[0] = min_rd = v4_rd; |
Data->iMinSAD[0] = min_rd = v4_rd; |
953 |
mode = MODE_INTER4V; |
mode = MODE_INTER4V; |
956 |
} |
} |
957 |
} |
} |
958 |
|
|
959 |
intra_rd = findRD_intra(Data, pMB, x, y, pParam->mb_width); |
intra_rd = findRD_intra(Data, pMB, x, y, pParam->mb_width, bound); |
960 |
if (intra_rd < min_rd) { |
if (intra_rd < min_rd) { |
961 |
*Data->iMinSAD = min_rd = intra_rd; |
*Data->iMinSAD = min_rd = intra_rd; |
962 |
mode = MODE_INTRA; |
mode = MODE_INTRA; |