460 |
VECTOR * b_predMV, |
VECTOR * b_predMV, |
461 |
const uint32_t MotionFlags, |
const uint32_t MotionFlags, |
462 |
const MBParam * const pParam, |
const MBParam * const pParam, |
463 |
int x, int y) |
int x, int y, |
464 |
|
int best_sad) |
465 |
{ |
{ |
466 |
int mode = MODE_DIRECT, k; |
int mode = MODE_DIRECT, k; |
467 |
int f_rd, b_rd, i_rd, d_rd, best_rd; |
int f_rd, b_rd, i_rd, d_rd, best_rd; |
469 |
const uint32_t iQuant = Data_d->iQuant; |
const uint32_t iQuant = Data_d->iQuant; |
470 |
int i; |
int i; |
471 |
int ref_quant = b_mb->quant; |
int ref_quant = b_mb->quant; |
472 |
|
int no_of_checks = 0; |
473 |
|
|
474 |
int order[4] = {MODE_DIRECT, MODE_FORWARD, MODE_BACKWARD, MODE_INTERPOLATE}; |
int order[4] = {MODE_DIRECT, MODE_FORWARD, MODE_BACKWARD, MODE_INTERPOLATE}; |
475 |
|
|
476 |
Data_d->scan_table = Data_b->scan_table = Data_f->scan_table = Data_i->scan_table |
Data_d->scan_table = Data_b->scan_table = Data_f->scan_table = Data_i->scan_table |
477 |
= /*VopFlags & XVID_VOP_ALTERNATESCAN ? scan_tables[2] : */scan_tables[0]; |
= /*VopFlags & XVID_VOP_ALTERNATESCAN ? scan_tables[2] : */scan_tables[0]; |
478 |
|
*Data_f->cbp = *Data_b->cbp = *Data_i->cbp = *Data_d->cbp = 63; |
479 |
|
|
480 |
f_rd = b_rd = i_rd = d_rd = best_rd = 256*4096; |
f_rd = b_rd = i_rd = d_rd = best_rd = 256*4096; |
481 |
|
|
503 |
} |
} |
504 |
} |
} |
505 |
|
|
506 |
|
for(i = 0; i < 4; i++) |
507 |
|
if (get_sad_for_mode(order[i], Data_d, Data_b, Data_f, Data_i) < 2*best_sad) |
508 |
|
no_of_checks++; |
509 |
|
|
510 |
|
if (no_of_checks > 1) { |
511 |
/* evaluate cost of all modes */ |
/* evaluate cost of all modes */ |
512 |
for (i = 0; i < 4; i++) { |
for (i = 0; i < no_of_checks; i++) { |
513 |
int rd; |
int rd; |
514 |
|
if (2*best_sad < get_sad_for_mode(order[i], Data_d, Data_b, Data_f, Data_i)) |
515 |
|
break; /* further SADs are too big */ |
516 |
|
|
517 |
switch (order[i]) { |
switch (order[i]) { |
518 |
case MODE_DIRECT: |
case MODE_DIRECT: |
534 |
best_rd = rd; |
best_rd = rd; |
535 |
} |
} |
536 |
} |
} |
537 |
|
} else { |
538 |
|
/* only 1 mode is below the threshold */ |
539 |
|
mode = order[0]; |
540 |
|
best_rd = 0; |
541 |
|
} |
542 |
|
|
543 |
pMB->sad16 = best_rd; |
pMB->sad16 = best_rd; |
544 |
pMB->mode = mode; |
pMB->mode = mode; |