667 |
for(i = 0; i < 4; i++) { |
for(i = 0; i < 4; i++) { |
668 |
int s = 8*((i&1) + (i>>1)*data->iEdgedWidth); |
int s = 8*((i&1) + (i>>1)*data->iEdgedWidth); |
669 |
transfer_8to16subro(in, data->Cur + s, ptr + s, data->iEdgedWidth); |
transfer_8to16subro(in, data->Cur + s, ptr + s, data->iEdgedWidth); |
670 |
bits += data->temp[i] = Block_CalcBits(coeff, in, data->iQuant, data->quant_type, &cbp, i); |
bits += data->temp[i] = Block_CalcBits(coeff, in, data->dctSpace + 128, data->iQuant, data->quant_type, &cbp, i); |
671 |
} |
} |
672 |
|
|
673 |
bits += t = BITS_MULT*d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0); |
bits += t = BITS_MULT*d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0); |
674 |
|
|
675 |
|
//8x8 blocks for inter4v mode |
676 |
|
if (data->temp[0] + t < data->iMinSAD[1]) { |
677 |
|
data->iMinSAD[1] = data->temp[0] + t; current[1].x = x; current[1].y = y; } |
678 |
|
if (data->temp[1] < data->iMinSAD[2]) { |
679 |
|
data->iMinSAD[2] = data->temp[1]; current[2].x = x; current[2].y = y; } |
680 |
|
if (data->temp[2] < data->iMinSAD[3]) { |
681 |
|
data->iMinSAD[3] = data->temp[2]; current[3].x = x; current[3].y = y; } |
682 |
|
if (data->temp[3] < data->iMinSAD[4]) { |
683 |
|
data->iMinSAD[4] = data->temp[3]; current[4].x = x; current[4].y = y; } |
684 |
|
|
685 |
bits += BITS_MULT*xvid_cbpy_tab[15-(cbp>>2)].len; |
bits += BITS_MULT*xvid_cbpy_tab[15-(cbp>>2)].len; |
686 |
|
|
687 |
if (bits >= data->iMinSAD[0]) return; |
if (bits >= data->iMinSAD[0]) return; |
693 |
//chroma U |
//chroma U |
694 |
ptr = interpolate8x8_switch2(data->RefQ + 64, data->RefP[4], 0, 0, xc, yc, data->iEdgedWidth/2, data->rounding); |
ptr = interpolate8x8_switch2(data->RefQ + 64, data->RefP[4], 0, 0, xc, yc, data->iEdgedWidth/2, data->rounding); |
695 |
transfer_8to16subro(in, ptr, data->CurU, data->iEdgedWidth/2); |
transfer_8to16subro(in, ptr, data->CurU, data->iEdgedWidth/2); |
696 |
bits += Block_CalcBits(coeff, in, data->iQuant, data->quant_type, &cbp, 4); |
bits += Block_CalcBits(coeff, in, data->dctSpace + 128, data->iQuant, data->quant_type, &cbp, 4); |
697 |
if (bits >= data->iMinSAD[0]) return; |
if (bits >= data->iMinSAD[0]) return; |
698 |
|
|
699 |
//chroma V |
//chroma V |
700 |
ptr = interpolate8x8_switch2(data->RefQ + 64, data->RefP[5], 0, 0, xc, yc, data->iEdgedWidth/2, data->rounding); |
ptr = interpolate8x8_switch2(data->RefQ + 64, data->RefP[5], 0, 0, xc, yc, data->iEdgedWidth/2, data->rounding); |
701 |
transfer_8to16subro(in, ptr, data->CurV, data->iEdgedWidth/2); |
transfer_8to16subro(in, ptr, data->CurV, data->iEdgedWidth/2); |
702 |
bits += Block_CalcBits(coeff, in, data->iQuant, data->quant_type, &cbp, 5); |
bits += Block_CalcBits(coeff, in, data->dctSpace + 128, data->iQuant, data->quant_type, &cbp, 5); |
703 |
|
|
704 |
bits += BITS_MULT*mcbpc_inter_tab[(MODE_INTER & 7) | ((cbp & 3) << 3)].len; |
bits += BITS_MULT*mcbpc_inter_tab[(MODE_INTER & 7) | ((cbp & 3) << 3)].len; |
705 |
|
|
708 |
current[0].x = x; current[0].y = y; |
current[0].x = x; current[0].y = y; |
709 |
*dir = Direction; |
*dir = Direction; |
710 |
} |
} |
|
|
|
|
if (data->temp[0] + t < data->iMinSAD[1]) { |
|
|
data->iMinSAD[1] = data->temp[0] + t; current[1].x = x; current[1].y = y; } |
|
|
if (data->temp[1] < data->iMinSAD[2]) { |
|
|
data->iMinSAD[2] = data->temp[1]; current[2].x = x; current[2].y = y; } |
|
|
if (data->temp[2] < data->iMinSAD[3]) { |
|
|
data->iMinSAD[3] = data->temp[2]; current[3].x = x; current[3].y = y; } |
|
|
if (data->temp[3] < data->iMinSAD[4]) { |
|
|
data->iMinSAD[4] = data->temp[3]; current[4].x = x; current[4].y = y; } |
|
|
|
|
711 |
} |
} |
712 |
static void |
static void |
713 |
CheckCandidateBits8(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
CheckCandidateBits8(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
731 |
} |
} |
732 |
|
|
733 |
transfer_8to16subro(in, data->Cur, ptr, data->iEdgedWidth); |
transfer_8to16subro(in, data->Cur, ptr, data->iEdgedWidth); |
734 |
bits = Block_CalcBits(coeff, in, data->iQuant, data->quant_type, &cbp, 5); |
bits = Block_CalcBits(coeff, in, data->dctSpace + 128, data->iQuant, data->quant_type, &cbp, 5); |
735 |
bits += BITS_MULT*d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0); |
bits += BITS_MULT*d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0); |
736 |
|
|
737 |
if (bits < data->iMinSAD[0]) { |
if (bits < data->iMinSAD[0]) { |
949 |
const int x, const int y, |
const int x, const int y, |
950 |
const MBParam * const pParam, |
const MBParam * const pParam, |
951 |
const uint32_t MotionFlags, |
const uint32_t MotionFlags, |
952 |
const uint32_t VopFlags, |
const uint32_t GlobalFlags, |
|
const uint32_t VolFlags, |
|
953 |
const IMAGE * const pCurrent, |
const IMAGE * const pCurrent, |
954 |
const IMAGE * const pRef) |
const IMAGE * const pRef) |
955 |
{ |
{ |
956 |
int mode = MODE_INTER; |
int mode = MODE_INTER; |
957 |
int inter4v = (VopFlags & XVID_VOP_INTER4V) && (pMB->dquant == 0); |
int inter4v = (GlobalFlags & XVID_INTER4V) && (pMB->dquant == NO_CHANGE); |
958 |
const uint32_t iQuant = pMB->quant; |
const uint32_t iQuant = pMB->quant; |
959 |
|
|
960 |
const int skip_possible = (!(VolFlags & XVID_VOL_GMC)) && (pMB->dquant == 0); |
const int skip_possible = (!(GlobalFlags & XVID_GMC)) && (pMB->dquant == NO_CHANGE); |
961 |
|
|
962 |
if (!(VopFlags & XVID_VOP_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision |
if (!(GlobalFlags & XVID_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision |
963 |
int sad; |
int sad; |
964 |
int InterBias = MV16_INTER_BIAS; |
int InterBias = MV16_INTER_BIAS; |
965 |
if (inter4v == 0 || Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] + |
if (inter4v == 0 || Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] + |
973 |
Data->iMinSAD[0] = sad; |
Data->iMinSAD[0] = sad; |
974 |
} |
} |
975 |
|
|
976 |
/* final skip decision, a.k.a. "the vector you found, really that good?" */ |
// final skip decision, a.k.a. "the vector you found, really that good?" |
977 |
if (skip_possible && (pMB->sad16 < (int)iQuant * MAX_SAD00_FOR_SKIP)) |
if (skip_possible && (pMB->sad16 < (int)iQuant * MAX_SAD00_FOR_SKIP)) |
978 |
if ( (100*sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH) |
if ( (100*sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH) |
979 |
if (Data->chroma || SkipDecisionP(pCurrent, pRef, x, y, Data->iEdgedWidth/2, iQuant, Data->rrv)) { |
if (Data->chroma || SkipDecisionP(pCurrent, pRef, x, y, Data->iEdgedWidth/2, iQuant, Data->rrv)) { |
981 |
sad = 0; |
sad = 0; |
982 |
} |
} |
983 |
|
|
984 |
/* intra decision */ |
// intra decision |
985 |
|
|
986 |
if (iQuant > 8) InterBias += 100 * (iQuant - 8); // to make high quants work |
if (iQuant > 8) InterBias += 100 * (iQuant - 8); // to make high quants work |
987 |
if (y != 0) |
if (y != 0) |
1073 |
uint32_t mb_width = pParam->mb_width; |
uint32_t mb_width = pParam->mb_width; |
1074 |
uint32_t mb_height = pParam->mb_height; |
uint32_t mb_height = pParam->mb_height; |
1075 |
const uint32_t iEdgedWidth = pParam->edged_width; |
const uint32_t iEdgedWidth = pParam->edged_width; |
1076 |
const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags); |
const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->global_flags); |
1077 |
|
|
1078 |
uint32_t x, y; |
uint32_t x, y; |
1079 |
uint32_t iIntra = 0; |
uint32_t iIntra = 0; |
1080 |
int32_t quant = current->quant, sad00; |
int32_t quant = current->quant, sad00; |
1081 |
int skip_thresh = \ |
int skip_thresh = INITIAL_SKIP_THRESH * |
1082 |
INITIAL_SKIP_THRESH * \ |
(current->global_flags & XVID_REDUCED ? 4:1) * |
1083 |
(current->vop_flags & XVID_VOP_REDUCED ? 4:1) * \ |
(current->global_flags & XVID_MODEDECISION_BITS ? 2:1); |
|
(current->vop_flags & XVID_VOP_MODEDECISION_BITS ? 2:1); |
|
1084 |
|
|
1085 |
// some pre-initialized thingies for SearchP |
// some pre-initialized thingies for SearchP |
1086 |
int32_t temp[8]; |
int32_t temp[8]; |
1087 |
VECTOR currentMV[5]; |
VECTOR currentMV[5]; |
1088 |
VECTOR currentQMV[5]; |
VECTOR currentQMV[5]; |
1089 |
int32_t iMinSAD[5]; |
int32_t iMinSAD[5]; |
1090 |
DECLARE_ALIGNED_MATRIX(dct_space, 2, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(dct_space, 3, 64, int16_t, CACHE_LINE); |
1091 |
SearchData Data; |
SearchData Data; |
1092 |
memset(&Data, 0, sizeof(SearchData)); |
memset(&Data, 0, sizeof(SearchData)); |
1093 |
Data.iEdgedWidth = iEdgedWidth; |
Data.iEdgedWidth = iEdgedWidth; |
1097 |
Data.temp = temp; |
Data.temp = temp; |
1098 |
Data.iFcode = current->fcode; |
Data.iFcode = current->fcode; |
1099 |
Data.rounding = pParam->m_rounding_type; |
Data.rounding = pParam->m_rounding_type; |
1100 |
Data.qpel = (current->vol_flags & XVID_VOL_QUARTERPEL ? 1:0); |
Data.qpel = pParam->m_quarterpel; |
1101 |
Data.chroma = MotionFlags & XVID_ME_CHROMA16; |
Data.chroma = MotionFlags & PMV_CHROMA16; |
1102 |
Data.rrv = (current->vop_flags & XVID_VOP_REDUCED ? 1:0); |
Data.rrv = current->global_flags & XVID_REDUCED; |
1103 |
Data.dctSpace = dct_space; |
Data.dctSpace = dct_space; |
1104 |
Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT); |
Data.quant_type = pParam->m_quant_type; |
1105 |
|
|
1106 |
if ((current->vop_flags & XVID_VOP_REDUCED)) { |
if ((current->global_flags & XVID_REDUCED)) { |
1107 |
mb_width = (pParam->width + 31) / 32; |
mb_width = (pParam->width + 31) / 32; |
1108 |
mb_height = (pParam->height + 31) / 32; |
mb_height = (pParam->height + 31) / 32; |
1109 |
Data.qpel = 0; |
Data.qpel = 0; |
1136 |
|
|
1137 |
sad00 = pMB->sad16; |
sad00 = pMB->sad16; |
1138 |
|
|
1139 |
if (pMB->dquant != 0) { |
if (!(current->global_flags & XVID_LUMIMASKING)) |
1140 |
|
pMB->dquant = NO_CHANGE; |
1141 |
|
else { |
1142 |
|
if (pMB->dquant != NO_CHANGE) { |
1143 |
quant += DQtab[pMB->dquant]; |
quant += DQtab[pMB->dquant]; |
1144 |
if (quant > 31) quant = 31; |
if (quant > 31) quant = 31; |
1145 |
else if (quant < 1) quant = 1; |
else if (quant < 1) quant = 1; |
1146 |
} |
} |
1147 |
|
} |
1148 |
pMB->quant = quant; |
pMB->quant = quant; |
1149 |
|
|
1150 |
//initial skip decision |
//initial skip decision |
1151 |
/* no early skip for GMC (global vector = skip vector is unknown!) */ |
/* no early skip for GMC (global vector = skip vector is unknown!) */ |
1152 |
if (!(current->vol_flags & XVID_VOL_GMC)) { /* no fast SKIP for S(GMC)-VOPs */ |
if (!(current->global_flags & XVID_GMC)) { /* no fast SKIP for S(GMC)-VOPs */ |
1153 |
if (pMB->dquant == 0 && sad00 < pMB->quant * skip_thresh) |
if (pMB->dquant == NO_CHANGE && sad00 < quant * skip_thresh) |
1154 |
if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) { |
if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) { |
1155 |
SkipMacroblockP(pMB, sad00); |
SkipMacroblockP(pMB, sad00); |
1156 |
continue; |
continue; |
1158 |
} |
} |
1159 |
|
|
1160 |
SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x, |
SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x, |
1161 |
y, MotionFlags, current->vop_flags, current->vol_flags, |
y, MotionFlags, current->global_flags, |
1162 |
&Data, pParam, pMBs, reference->mbs, pMB); |
&Data, pParam, pMBs, reference->mbs, pMB); |
1163 |
|
|
1164 |
ModeDecision(&Data, pMB, pMBs, x, y, pParam, |
ModeDecision(&Data, pMB, pMBs, x, y, pParam, |
1165 |
MotionFlags, current->vop_flags, current->vol_flags, |
MotionFlags, current->global_flags, |
1166 |
pCurrent, pRef); |
pCurrent, pRef); |
1167 |
|
|
1168 |
if (pMB->mode == MODE_INTRA) |
if (pMB->mode == MODE_INTRA) |
1170 |
} |
} |
1171 |
} |
} |
1172 |
|
|
1173 |
if (current->vol_flags & XVID_VOL_GMC ) /* GMC only for S(GMC)-VOPs */ |
if (current->global_flags & XVID_GMC ) /* GMC only for S(GMC)-VOPs */ |
1174 |
{ |
{ |
1175 |
current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV); |
current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV); |
1176 |
} |
} |
1246 |
const int x, |
const int x, |
1247 |
const int y, |
const int y, |
1248 |
const uint32_t MotionFlags, |
const uint32_t MotionFlags, |
1249 |
const uint32_t VopFlags, |
const uint32_t GlobalFlags, |
|
const uint32_t VolFlags, |
|
1250 |
SearchData * const Data, |
SearchData * const Data, |
1251 |
const MBParam * const pParam, |
const MBParam * const pParam, |
1252 |
const MACROBLOCK * const pMBs, |
const MACROBLOCK * const pMBs, |
1256 |
|
|
1257 |
int i, iDirection = 255, mask, threshA; |
int i, iDirection = 255, mask, threshA; |
1258 |
VECTOR pmv[7]; |
VECTOR pmv[7]; |
1259 |
int inter4v = (VopFlags & XVID_VOP_INTER4V) && (pMB->dquant == 0); |
int inter4v = (GlobalFlags & XVID_INTER4V) && (pMB->dquant == NO_CHANGE); |
1260 |
|
|
1261 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
1262 |
pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv); |
pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv); |
1292 |
Data->iMinSAD[3] = pMB->sad8[2]; |
Data->iMinSAD[3] = pMB->sad8[2]; |
1293 |
Data->iMinSAD[4] = pMB->sad8[3]; |
Data->iMinSAD[4] = pMB->sad8[3]; |
1294 |
|
|
1295 |
if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) || (x | y)) { |
if ((!(GlobalFlags & XVID_MODEDECISION_BITS)) && (x | y)) { |
1296 |
threshA = Data->temp[0]; // that's where we keep this SAD atm |
threshA = Data->temp[0]; // that's where we keep this SAD atm |
1297 |
if (threshA < 512) threshA = 512; |
if (threshA < 512) threshA = 512; |
1298 |
else if (threshA > 1024) threshA = 1024; |
else if (threshA > 1024) threshA = 1024; |
1322 |
else { |
else { |
1323 |
|
|
1324 |
MainSearchFunc * MainSearchPtr; |
MainSearchFunc * MainSearchPtr; |
1325 |
if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch; |
if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch; |
1326 |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
1327 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1328 |
|
|
1329 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
1332 |
note that this search is/might be done in halfpel positions, |
note that this search is/might be done in halfpel positions, |
1333 |
which makes it more different than the diamond above */ |
which makes it more different than the diamond above */ |
1334 |
|
|
1335 |
if (MotionFlags & XVID_ME_EXTSEARCH16) { |
if (MotionFlags & PMV_EXTSEARCH16) { |
1336 |
int32_t bSAD; |
int32_t bSAD; |
1337 |
VECTOR startMV = Data->predMV, backupMV = Data->currentMV[0]; |
VECTOR startMV = Data->predMV, backupMV = Data->currentMV[0]; |
1338 |
if (Data->rrv) { |
if (Data->rrv) { |
1363 |
} |
} |
1364 |
} |
} |
1365 |
|
|
1366 |
if (MotionFlags & XVID_ME_HALFPELREFINE16) |
if (MotionFlags & PMV_HALFPELREFINE16) |
1367 |
SubpelRefine(Data); |
SubpelRefine(Data); |
1368 |
|
|
1369 |
for(i = 0; i < 5; i++) { |
for(i = 0; i < 5; i++) { |
1375 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
1376 |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
1377 |
Data->qpel_precision = 1; |
Data->qpel_precision = 1; |
1378 |
if (MotionFlags & XVID_ME_QUARTERPELREFINE16) |
if (MotionFlags & PMV_QUARTERPELREFINE16) |
1379 |
SubpelRefine(Data); |
SubpelRefine(Data); |
1380 |
} |
} |
1381 |
|
|
1391 |
Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8); |
Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8); |
1392 |
Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8); |
Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8); |
1393 |
|
|
1394 |
if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_BITS))) { |
if ((Data->chroma) && (!(GlobalFlags & XVID_MODEDECISION_BITS))) { |
1395 |
// chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, it will not be used |
// chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, it will not be used |
1396 |
int sumx = 0, sumy = 0; |
int sumx = 0, sumy = 0; |
1397 |
|
|
1439 |
|
|
1440 |
*(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10; |
*(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10; |
1441 |
|
|
1442 |
if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) { |
if (MotionFlags & (PMV_EXTSEARCH8|PMV_HALFPELREFINE8|PMV_QUARTERPELREFINE8)) { |
1443 |
|
|
1444 |
if (Data->rrv) i = 16; else i = 8; |
if (Data->rrv) i = 16; else i = 8; |
1445 |
|
|
1457 |
if (!Data->rrv) CheckCandidate = CheckCandidate8; |
if (!Data->rrv) CheckCandidate = CheckCandidate8; |
1458 |
else CheckCandidate = CheckCandidate16no4v; |
else CheckCandidate = CheckCandidate16no4v; |
1459 |
|
|
1460 |
if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_BITS))) { |
if (MotionFlags & PMV_EXTSEARCH8 && (!(MotionFlags & EXTSEARCH_BITS))) { |
1461 |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
1462 |
|
|
1463 |
MainSearchFunc *MainSearchPtr; |
MainSearchFunc *MainSearchPtr; |
1464 |
if (MotionFlags & XVID_ME_USESQUARES8) MainSearchPtr = SquareSearch; |
if (MotionFlags & PMV_USESQUARES8) MainSearchPtr = SquareSearch; |
1465 |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & PMV_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch; |
1466 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1467 |
|
|
1468 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255); |
1473 |
} |
} |
1474 |
} |
} |
1475 |
|
|
1476 |
if (MotionFlags & XVID_ME_HALFPELREFINE8) { |
if (MotionFlags & PMV_HALFPELREFINE8) { |
1477 |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
1478 |
|
|
1479 |
SubpelRefine(Data); // perform halfpel refine of current best vector |
SubpelRefine(Data); // perform halfpel refine of current best vector |
1484 |
} |
} |
1485 |
} |
} |
1486 |
|
|
1487 |
if (Data->qpel && MotionFlags & XVID_ME_QUARTERPELREFINE8) { |
if (Data->qpel && MotionFlags & PMV_QUARTERPELREFINE8) { |
1488 |
Data->qpel_precision = 1; |
Data->qpel_precision = 1; |
1489 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8, |
1490 |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
1608 |
CheckCandidate16no4v(pmv[i].x, pmv[i].y, mask, &iDirection, Data); |
CheckCandidate16no4v(pmv[i].x, pmv[i].y, mask, &iDirection, Data); |
1609 |
} |
} |
1610 |
|
|
1611 |
if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch; |
if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch; |
1612 |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
1613 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1614 |
|
|
1615 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
1792 |
// DIRECT MODE DELTA VECTOR SEARCH. |
// DIRECT MODE DELTA VECTOR SEARCH. |
1793 |
// This has to be made more effective, but at the moment I'm happy it's running at all |
// This has to be made more effective, but at the moment I'm happy it's running at all |
1794 |
|
|
1795 |
if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch; |
if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch; |
1796 |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
1797 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1798 |
|
|
1799 |
MainSearchPtr(0, 0, Data, 255); |
MainSearchPtr(0, 0, Data, 255); |
2002 |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
2003 |
Data.iMinSAD = &iMinSAD; |
Data.iMinSAD = &iMinSAD; |
2004 |
Data.lambda16 = lambda_vec16[frame->quant]; |
Data.lambda16 = lambda_vec16[frame->quant]; |
2005 |
Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL; |
Data.qpel = pParam->m_quarterpel; |
2006 |
Data.rounding = 0; |
Data.rounding = 0; |
2007 |
Data.chroma = frame->motion_flags & XVID_ME_CHROMA8; |
Data.chroma = frame->motion_flags & PMV_CHROMA8; |
2008 |
Data.temp = temp; |
Data.temp = temp; |
2009 |
|
|
2010 |
Data.RefQ = f_refV->u; // a good place, also used in MC (for similar purpose) |
Data.RefQ = f_refV->u; // a good place, also used in MC (for similar purpose) |
2112 |
{ |
{ |
2113 |
|
|
2114 |
int i, mask; |
int i, mask; |
|
int quarterpel = (pParam->vol_flags & XVID_VOL_QUARTERPEL)? 1: 0; |
|
2115 |
VECTOR pmv[3]; |
VECTOR pmv[3]; |
2116 |
MACROBLOCK * const pMB = &pMBs[x + y * pParam->mb_width]; |
MACROBLOCK * const pMB = &pMBs[x + y * pParam->mb_width]; |
2117 |
|
|
2127 |
else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median |
else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median |
2128 |
|
|
2129 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
2130 |
pParam->width, pParam->height, Data->iFcode - quarterpel, 0, 0); |
pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel, 0, 0); |
2131 |
|
|
2132 |
Data->Cur = pCur + (x + y * pParam->edged_width) * 16; |
Data->Cur = pCur + (x + y * pParam->edged_width) * 16; |
2133 |
Data->RefP[0] = pRef + (x + y * pParam->edged_width) * 16; |
Data->RefP[0] = pRef + (x + y * pParam->edged_width) * 16; |
2159 |
} |
} |
2160 |
} |
} |
2161 |
|
|
2162 |
#define INTRA_THRESH 1700 |
#define INTRA_THRESH 2200 |
2163 |
#define INTER_THRESH 1200 |
#define INTER_THRESH 50 |
2164 |
|
#define INTRA_THRESH2 95 |
2165 |
|
|
2166 |
int |
int |
2167 |
MEanalysis( const IMAGE * const pRef, |
MEanalysis( const IMAGE * const pRef, |
2176 |
int sSAD = 0; |
int sSAD = 0; |
2177 |
MACROBLOCK * const pMBs = Current->mbs; |
MACROBLOCK * const pMBs = Current->mbs; |
2178 |
const IMAGE * const pCurrent = &Current->image; |
const IMAGE * const pCurrent = &Current->image; |
2179 |
int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH + 10*b_thresh; |
int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH + b_thresh; |
2180 |
int s = 0, blocks = 0; |
int s = 0, blocks = 0; |
2181 |
|
int complexity = 0; |
2182 |
|
|
2183 |
int32_t iMinSAD[5], temp[5]; |
int32_t iMinSAD[5], temp[5]; |
2184 |
VECTOR currentMV[5]; |
VECTOR currentMV[5]; |
2190 |
Data.temp = temp; |
Data.temp = temp; |
2191 |
CheckCandidate = CheckCandidate32I; |
CheckCandidate = CheckCandidate32I; |
2192 |
|
|
2193 |
|
|
2194 |
if (intraCount != 0) { |
if (intraCount != 0) { |
2195 |
if (intraCount < 10) // we're right after an I frame |
if (intraCount < 10) // we're right after an I frame |
2196 |
IntraThresh += 15* (intraCount - 10) * (intraCount - 10); |
IntraThresh += 15* (intraCount - 10) * (intraCount - 10); |
2199 |
IntraThresh -= (IntraThresh * (maxIntra - 8*(maxIntra - intraCount)))/maxIntra; |
IntraThresh -= (IntraThresh * (maxIntra - 8*(maxIntra - intraCount)))/maxIntra; |
2200 |
} |
} |
2201 |
|
|
2202 |
InterThresh -= (350 - 8*b_thresh) * bCount; |
InterThresh -= 12 * bCount; |
2203 |
if (InterThresh < 300 + 5*b_thresh) InterThresh = 300 + 5*b_thresh; |
if (InterThresh < 15 + b_thresh) InterThresh = 15 + b_thresh; |
2204 |
|
|
2205 |
if (sadInit) (*sadInit) (); |
if (sadInit) (*sadInit) (); |
2206 |
|
|
2207 |
for (y = 1; y < pParam->mb_height-1; y += 2) { |
for (y = 1; y < pParam->mb_height-1; y += 2) { |
2208 |
for (x = 1; x < pParam->mb_width-1; x += 2) { |
for (x = 1; x < pParam->mb_width-1; x += 2) { |
2209 |
int i; |
int i; |
2210 |
blocks += 4; |
blocks += 10; |
2211 |
|
|
2212 |
if (bCount == 0) pMBs[x + y * pParam->mb_width].mvs[0] = zeroMV; |
if (bCount == 0) pMBs[x + y * pParam->mb_width].mvs[0] = zeroMV; |
2213 |
else { //extrapolation of the vector found for last frame |
else { //extrapolation of the vector found for last frame |
2222 |
for (i = 0; i < 4; i++) { |
for (i = 0; i < 4; i++) { |
2223 |
int dev; |
int dev; |
2224 |
MACROBLOCK *pMB = &pMBs[x+(i&1) + (y+(i>>1)) * pParam->mb_width]; |
MACROBLOCK *pMB = &pMBs[x+(i&1) + (y+(i>>1)) * pParam->mb_width]; |
|
if (pMB->sad16 > IntraThresh) { |
|
2225 |
dev = dev16(pCurrent->y + (x + (i&1) + (y + (i>>1)) * pParam->edged_width) * 16, |
dev = dev16(pCurrent->y + (x + (i&1) + (y + (i>>1)) * pParam->edged_width) * 16, |
2226 |
pParam->edged_width); |
pParam->edged_width); |
2227 |
|
|
2228 |
|
complexity += dev; |
2229 |
if (dev + IntraThresh < pMB->sad16) { |
if (dev + IntraThresh < pMB->sad16) { |
2230 |
pMB->mode = MODE_INTRA; |
pMB->mode = MODE_INTRA; |
2231 |
if (++intra > ((pParam->mb_height-2)*(pParam->mb_width-2))/2) return I_VOP; |
if (++intra > ((pParam->mb_height-2)*(pParam->mb_width-2))/2) return I_VOP; |
2232 |
} |
} |
2233 |
} |
|
2234 |
if (pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0) s++; |
if (pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0) |
2235 |
|
if (dev > 500 && pMB->sad16 < 1000) |
2236 |
|
sSAD += 1000; |
2237 |
|
|
2238 |
sSAD += pMB->sad16; |
sSAD += pMB->sad16; |
2239 |
} |
} |
2240 |
} |
} |
2241 |
} |
} |
2242 |
|
complexity >>= 7; |
2243 |
|
|
2244 |
sSAD /= blocks; |
sSAD /= complexity + 4*blocks; |
|
|
|
|
if (b_thresh < 20) { |
|
|
s = (10*s) / blocks; |
|
|
if (s > 4) sSAD += (s - 2) * (40 - 2*b_thresh); //static block - looks bad when in bframe... |
|
|
} |
|
2245 |
|
|
2246 |
|
if (intraCount > 12 && sSAD > INTRA_THRESH2 ) return I_VOP; |
2247 |
if (sSAD > InterThresh ) return P_VOP; |
if (sSAD > InterThresh ) return P_VOP; |
2248 |
emms(); |
emms(); |
2249 |
return B_VOP; |
return B_VOP; |
2453 |
Data->qpel_precision = 1; |
Data->qpel_precision = 1; |
2454 |
CheckCandidateBits16(Data->currentQMV[0].x, Data->currentQMV[0].y, 255, &iDirection, Data); |
CheckCandidateBits16(Data->currentQMV[0].x, Data->currentQMV[0].y, 255, &iDirection, Data); |
2455 |
|
|
2456 |
if (MotionFlags & (XVID_ME_HALFPELREFINE16_BITS | XVID_ME_EXTSEARCH_BITS)) { //we have to prepare for halfpixel-precision search |
if (MotionFlags & (HALFPELREFINE16_BITS | EXTSEARCH_BITS)) { //we have to prepare for halfpixel-precision search |
2457 |
for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i]; |
for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i]; |
2458 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
2459 |
pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv); |
pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv); |
2467 |
CheckCandidateBits16(Data->currentMV[0].x, Data->currentMV[0].y, 255, &iDirection, Data); |
CheckCandidateBits16(Data->currentMV[0].x, Data->currentMV[0].y, 255, &iDirection, Data); |
2468 |
} |
} |
2469 |
|
|
2470 |
if (MotionFlags&XVID_ME_EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
if (MotionFlags&EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
2471 |
|
|
2472 |
if (MotionFlags&XVID_ME_HALFPELREFINE16_BITS) SubpelRefine(Data); |
if (MotionFlags&HALFPELREFINE16_BITS) SubpelRefine(Data); |
2473 |
|
|
2474 |
if (Data->qpel) { |
if (Data->qpel) { |
2475 |
if (MotionFlags&(XVID_ME_EXTSEARCH_BITS | XVID_ME_HALFPELREFINE16_BITS)) { // there was halfpel-precision search |
if (MotionFlags&(EXTSEARCH_BITS | HALFPELREFINE16_BITS)) { // there was halfpel-precision search |
2476 |
for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) { |
for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) { |
2477 |
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // we have found a better match |
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // we have found a better match |
2478 |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
2483 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
2484 |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
2485 |
} |
} |
2486 |
if (MotionFlags&XVID_ME_QUARTERPELREFINE16_BITS) SubpelRefine(Data); |
if (MotionFlags&QUARTERPELREFINE16_BITS) SubpelRefine(Data); |
2487 |
} |
} |
2488 |
|
|
2489 |
if (MotionFlags&XVID_ME_CHECKPREDICTION_BITS) { //let's check vector equal to prediction |
if (MotionFlags&CHECKPREDICTION_BITS) { //let's check vector equal to prediction |
2490 |
VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV; |
VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV; |
2491 |
if (!(Data->predMV.x == v->x && Data->predMV.y == v->y)) |
if (!(Data->predMV.x == v->x && Data->predMV.y == v->y)) |
2492 |
CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data); |
CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data); |
2546 |
} |
} |
2547 |
|
|
2548 |
if (Data8->qpel) { |
if (Data8->qpel) { |
2549 |
if (MotionFlags&XVID_ME_HALFPELREFINE8_BITS || (MotionFlags&XVID_ME_EXTSEARCH8 && MotionFlags&XVID_ME_EXTSEARCH_BITS)) { // halfpixel motion search follows |
if (MotionFlags&HALFPELREFINE8_BITS || (MotionFlags&PMV_EXTSEARCH8 && MotionFlags&EXTSEARCH_BITS)) { // halfpixel motion search follows |
2550 |
int32_t s = *Data8->iMinSAD; |
int32_t s = *Data8->iMinSAD; |
2551 |
Data8->currentMV->x = Data8->currentQMV->x/2; |
Data8->currentMV->x = Data8->currentQMV->x/2; |
2552 |
Data8->currentMV->y = Data8->currentQMV->y/2; |
Data8->currentMV->y = Data8->currentQMV->y/2; |
2557 |
if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1) |
if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1) |
2558 |
CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8); |
CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8); |
2559 |
|
|
2560 |
if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_BITS) |
if (MotionFlags & PMV_EXTSEARCH8 && MotionFlags & EXTSEARCH_BITS) |
2561 |
SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255); |
SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255); |
2562 |
|
|
2563 |
if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS) |
if (MotionFlags & HALFPELREFINE8_BITS) |
2564 |
SubpelRefine(Data8); |
SubpelRefine(Data8); |
2565 |
|
|
2566 |
if(s > *Data8->iMinSAD) { //we have found a better match |
if(s > *Data8->iMinSAD) { //we have found a better match |
2573 |
pParam->width, pParam->height, Data8->iFcode, 1, 0); |
pParam->width, pParam->height, Data8->iFcode, 1, 0); |
2574 |
|
|
2575 |
} |
} |
2576 |
if (MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS) SubpelRefine(Data8); |
if (MotionFlags & QUARTERPELREFINE8_BITS) SubpelRefine(Data8); |
2577 |
|
|
2578 |
} else { // not qpel |
} else { // not qpel |
2579 |
|
|
2580 |
if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_BITS) //extsearch |
if (MotionFlags & PMV_EXTSEARCH8 && MotionFlags & EXTSEARCH_BITS) //extsearch |
2581 |
SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255); |
SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255); |
2582 |
|
|
2583 |
if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS) |
if (MotionFlags & HALFPELREFINE8_BITS) |
2584 |
SubpelRefine(Data8); //halfpel refinement |
SubpelRefine(Data8); //halfpel refinement |
2585 |
} |
} |
2586 |
|
|
2587 |
//checking vector equal to predicion |
//checking vector equal to predicion |
2588 |
if (i != 0 && MotionFlags & XVID_ME_CHECKPREDICTION_BITS) { |
if (i != 0 && MotionFlags & CHECKPREDICTION_BITS) { |
2589 |
const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV; |
const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV; |
2590 |
if (!MVequal(*v, Data8->predMV)) |
if (!MVequal(*v, Data8->predMV)) |
2591 |
CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8); |
CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8); |
2622 |
//chroma U |
//chroma U |
2623 |
ptr = interpolate8x8_switch2(Data->RefQ + 64, Data->RefP[4], 0, 0, sumx, sumy, Data->iEdgedWidth/2, Data->rounding); |
ptr = interpolate8x8_switch2(Data->RefQ + 64, Data->RefP[4], 0, 0, sumx, sumy, Data->iEdgedWidth/2, Data->rounding); |
2624 |
transfer_8to16subro(in, Data->CurU, ptr, Data->iEdgedWidth/2); |
transfer_8to16subro(in, Data->CurU, ptr, Data->iEdgedWidth/2); |
2625 |
bits += Block_CalcBits(coeff, in, Data->iQuant, Data->quant_type, &cbp, 4); |
bits += Block_CalcBits(coeff, in, Data->dctSpace + 128, Data->iQuant, Data->quant_type, &cbp, 4); |
2626 |
|
|
2627 |
if (bits >= *Data->iMinSAD) return bits; |
if (bits >= *Data->iMinSAD) return bits; |
2628 |
|
|
2629 |
//chroma V |
//chroma V |
2630 |
ptr = interpolate8x8_switch2(Data->RefQ + 64, Data->RefP[5], 0, 0, sumx, sumy, Data->iEdgedWidth/2, Data->rounding); |
ptr = interpolate8x8_switch2(Data->RefQ + 64, Data->RefP[5], 0, 0, sumx, sumy, Data->iEdgedWidth/2, Data->rounding); |
2631 |
transfer_8to16subro(in, Data->CurV, ptr, Data->iEdgedWidth/2); |
transfer_8to16subro(in, Data->CurV, ptr, Data->iEdgedWidth/2); |
2632 |
bits += Block_CalcBits(coeff, in, Data->iQuant, Data->quant_type, &cbp, 5); |
bits += Block_CalcBits(coeff, in, Data->dctSpace + 128, Data->iQuant, Data->quant_type, &cbp, 5); |
2633 |
|
|
2634 |
bits += BITS_MULT*mcbpc_inter_tab[(MODE_INTER4V & 7) | ((cbp & 3) << 3)].len; |
bits += BITS_MULT*mcbpc_inter_tab[(MODE_INTER4V & 7) | ((cbp & 3) << 3)].len; |
2635 |
|
|
2646 |
for(i = 0; i < 4; i++) { |
for(i = 0; i < 4; i++) { |
2647 |
int s = 8*((i&1) + (i>>1)*Data->iEdgedWidth); |
int s = 8*((i&1) + (i>>1)*Data->iEdgedWidth); |
2648 |
transfer_8to16copy(in, Data->Cur + s, Data->iEdgedWidth); |
transfer_8to16copy(in, Data->Cur + s, Data->iEdgedWidth); |
2649 |
bits += Block_CalcBitsIntra(coeff, in, Data->iQuant, Data->quant_type, &cbp, i, &dc); |
bits += Block_CalcBitsIntra(coeff, in, Data->dctSpace + 128, Data->iQuant, Data->quant_type, &cbp, i, &dc); |
2650 |
|
|
2651 |
if (bits >= Data->iMinSAD[0]) return bits; |
if (bits >= Data->iMinSAD[0]) return bits; |
2652 |
} |
} |
2655 |
|
|
2656 |
//chroma U |
//chroma U |
2657 |
transfer_8to16copy(in, Data->CurU, Data->iEdgedWidth/2); |
transfer_8to16copy(in, Data->CurU, Data->iEdgedWidth/2); |
2658 |
bits += Block_CalcBitsIntra(coeff, in, Data->iQuant, Data->quant_type, &cbp, 4, &dc); |
bits += Block_CalcBitsIntra(coeff, in, Data->dctSpace + 128, Data->iQuant, Data->quant_type, &cbp, 4, &dc); |
2659 |
|
|
2660 |
if (bits >= Data->iMinSAD[0]) return bits; |
if (bits >= Data->iMinSAD[0]) return bits; |
2661 |
|
|
2662 |
//chroma V |
//chroma V |
2663 |
transfer_8to16copy(in, Data->CurV, Data->iEdgedWidth/2); |
transfer_8to16copy(in, Data->CurV, Data->iEdgedWidth/2); |
2664 |
bits += Block_CalcBitsIntra(coeff, in, Data->iQuant, Data->quant_type, &cbp, 5, &dc); |
bits += Block_CalcBitsIntra(coeff, in, Data->dctSpace + 128, Data->iQuant, Data->quant_type, &cbp, 5, &dc); |
2665 |
|
|
2666 |
bits += BITS_MULT*mcbpc_inter_tab[(MODE_INTRA & 7) | ((cbp & 3) << 3)].len; |
bits += BITS_MULT*mcbpc_inter_tab[(MODE_INTRA & 7) | ((cbp & 3) << 3)].len; |
2667 |
|
|