47 |
#define FINAL_SKIP_THRESH (50) |
#define FINAL_SKIP_THRESH (50) |
48 |
#define MAX_SAD00_FOR_SKIP (20) |
#define MAX_SAD00_FOR_SKIP (20) |
49 |
#define MAX_CHROMA_SAD_FOR_SKIP (22) |
#define MAX_CHROMA_SAD_FOR_SKIP (22) |
50 |
#define SKIP_THRESH_B (25) |
#define SKIP_THRESH_B (15) |
51 |
|
|
52 |
#define CHECK_CANDIDATE(X,Y,D) { \ |
#define CHECK_CANDIDATE(X,Y,D) { \ |
53 |
(*CheckCandidate)((const int)(X),(const int)(Y), (D), &iDirection, data ); } |
(*CheckCandidate)((const int)(X),(const int)(Y), (D), &iDirection, data ); } |
137 |
Interpolate8x8qpel(const int x, const int y, const int block, const int dir, const SearchData * const data) |
Interpolate8x8qpel(const int x, const int y, const int block, const int dir, const SearchData * const data) |
138 |
{ |
{ |
139 |
// create or find a qpel-precision reference picture; return pointer to it |
// create or find a qpel-precision reference picture; return pointer to it |
140 |
uint8_t * Reference = (uint8_t *)data->RefQ; |
uint8_t * Reference = (uint8_t *)data->RefQ + 16*dir; |
141 |
const int32_t iEdgedWidth = data->iEdgedWidth; |
const int32_t iEdgedWidth = data->iEdgedWidth; |
142 |
const uint32_t rounding = data->rounding; |
const uint32_t rounding = data->rounding; |
143 |
const int halfpel_x = x/2; |
const int halfpel_x = x/2; |
155 |
case 1: // x halfpel, y qpel - top or bottom during qpel refinement |
case 1: // x halfpel, y qpel - top or bottom during qpel refinement |
156 |
ref2 = GetReference(halfpel_x, y - halfpel_y, dir, data); |
ref2 = GetReference(halfpel_x, y - halfpel_y, dir, data); |
157 |
ref2 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth; |
ref2 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth; |
158 |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8); |
159 |
break; |
break; |
160 |
|
|
161 |
case 2: // x qpel, y halfpel - left or right during qpel refinement |
case 2: // x qpel, y halfpel - left or right during qpel refinement |
162 |
ref2 = GetReference(x - halfpel_x, halfpel_y, dir, data); |
ref2 = GetReference(x - halfpel_x, halfpel_y, dir, data); |
163 |
ref2 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth; |
ref2 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth; |
164 |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8); |
165 |
break; |
break; |
166 |
|
|
167 |
default: // x and y in qpel resolution - the "corners" (top left/right and |
default: // x and y in qpel resolution - the "corners" (top left/right and |
182 |
Interpolate16x16qpel(const int x, const int y, const int dir, const SearchData * const data) |
Interpolate16x16qpel(const int x, const int y, const int dir, const SearchData * const data) |
183 |
{ |
{ |
184 |
// create or find a qpel-precision reference picture; return pointer to it |
// create or find a qpel-precision reference picture; return pointer to it |
185 |
uint8_t * Reference = (uint8_t *)data->RefQ; |
uint8_t * Reference = (uint8_t *)data->RefQ + 16*dir; |
186 |
const int32_t iEdgedWidth = data->iEdgedWidth; |
const int32_t iEdgedWidth = data->iEdgedWidth; |
187 |
const uint32_t rounding = data->rounding; |
const uint32_t rounding = data->rounding; |
188 |
const int halfpel_x = x/2; |
const int halfpel_x = x/2; |
195 |
return (uint8_t *) GetReference(halfpel_x, halfpel_y, dir, data); |
return (uint8_t *) GetReference(halfpel_x, halfpel_y, dir, data); |
196 |
case 1: // x halfpel, y qpel - top or bottom during qpel refinement |
case 1: // x halfpel, y qpel - top or bottom during qpel refinement |
197 |
ref2 = GetReference(halfpel_x, y - halfpel_y, dir, data); |
ref2 = GetReference(halfpel_x, y - halfpel_y, dir, data); |
198 |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8); |
199 |
interpolate8x8_avg2(Reference+8, ref1+8, ref2+8, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference+8, ref1+8, ref2+8, iEdgedWidth, rounding, 8); |
200 |
interpolate8x8_avg2(Reference+8*iEdgedWidth, ref1+8*iEdgedWidth, ref2+8*iEdgedWidth, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference+8*iEdgedWidth, ref1+8*iEdgedWidth, ref2+8*iEdgedWidth, iEdgedWidth, rounding, 8); |
201 |
interpolate8x8_avg2(Reference+8*iEdgedWidth+8, ref1+8*iEdgedWidth+8, ref2+8*iEdgedWidth+8, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference+8*iEdgedWidth+8, ref1+8*iEdgedWidth+8, ref2+8*iEdgedWidth+8, iEdgedWidth, rounding, 8); |
202 |
break; |
break; |
203 |
|
|
204 |
case 2: // x qpel, y halfpel - left or right during qpel refinement |
case 2: // x qpel, y halfpel - left or right during qpel refinement |
205 |
ref2 = GetReference(x - halfpel_x, halfpel_y, dir, data); |
ref2 = GetReference(x - halfpel_x, halfpel_y, dir, data); |
206 |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8); |
207 |
interpolate8x8_avg2(Reference+8, ref1+8, ref2+8, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference+8, ref1+8, ref2+8, iEdgedWidth, rounding, 8); |
208 |
interpolate8x8_avg2(Reference+8*iEdgedWidth, ref1+8*iEdgedWidth, ref2+8*iEdgedWidth, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference+8*iEdgedWidth, ref1+8*iEdgedWidth, ref2+8*iEdgedWidth, iEdgedWidth, rounding, 8); |
209 |
interpolate8x8_avg2(Reference+8*iEdgedWidth+8, ref1+8*iEdgedWidth+8, ref2+8*iEdgedWidth+8, iEdgedWidth, rounding); |
interpolate8x8_avg2(Reference+8*iEdgedWidth+8, ref1+8*iEdgedWidth+8, ref2+8*iEdgedWidth+8, iEdgedWidth, rounding, 8); |
210 |
break; |
break; |
211 |
|
|
212 |
default: // x and y in qpel resolution - the "corners" (top left/right and |
default: // x and y in qpel resolution - the "corners" (top left/right and |
1368 |
Data->min_dy *= 2; |
Data->min_dy *= 2; |
1369 |
Data->referencemv = b_mb->qmvs; |
Data->referencemv = b_mb->qmvs; |
1370 |
} else Data->referencemv = b_mb->mvs; |
} else Data->referencemv = b_mb->mvs; |
1371 |
Data->qpel_precision = 0; // it'm a trick. it's 1 not 0, but we need 0 here |
Data->qpel_precision = 0; // it's a trick. it's 1 not 0, but we need 0 here |
1372 |
|
|
1373 |
for (k = 0; k < 4; k++) { |
for (k = 0; k < 4; k++) { |
1374 |
pMB->mvs[k].x = Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD); |
pMB->mvs[k].x = Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD); |
1458 |
*Data->iMinSAD += 1 * Data->lambda16; // one bit is needed to code direct mode |
*Data->iMinSAD += 1 * Data->lambda16; // one bit is needed to code direct mode |
1459 |
*best_sad = *Data->iMinSAD; |
*best_sad = *Data->iMinSAD; |
1460 |
|
|
1461 |
// if (b_mb->mode == MODE_INTER4V) |
if (b_mb->mode == MODE_INTER4V) |
1462 |
pMB->mode = MODE_DIRECT; |
pMB->mode = MODE_DIRECT; |
1463 |
// else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation |
else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation |
1464 |
|
|
1465 |
pMB->pmvs[3] = *Data->currentMV; |
pMB->pmvs[3] = *Data->currentMV; |
1466 |
|
|
2037 |
} |
} |
2038 |
|
|
2039 |
#define INTRA_THRESH 1350 |
#define INTRA_THRESH 1350 |
2040 |
#define INTER_THRESH 900 |
#define INTER_THRESH 1200 |
2041 |
|
|
2042 |
|
|
2043 |
int |
int |
2070 |
IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra; |
IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra; |
2071 |
|
|
2072 |
|
|
2073 |
InterThresh += 300 * (1 - bCount); |
InterThresh += 400 * (1 - bCount); |
2074 |
if (InterThresh < 200) InterThresh = 200; |
if (InterThresh < 200) InterThresh = 200; |
2075 |
|
|
2076 |
if (sadInit) (*sadInit) (); |
if (sadInit) (*sadInit) (); |