524 |
return pmv[last_cand]; /* no point calculating median mv */ |
return pmv[last_cand]; /* no point calculating median mv */ |
525 |
} |
} |
526 |
|
|
527 |
|
VECTOR get_pmv2_interlaced(const MACROBLOCK * const mbs, |
528 |
|
const int mb_width, |
529 |
|
const int bound, |
530 |
|
const int x, |
531 |
|
const int y, |
532 |
|
const int block) |
533 |
|
{ |
534 |
|
int lx, ly, lz; /* left */ |
535 |
|
int tx, ty, tz; /* top */ |
536 |
|
int rx, ry, rz; /* top-right */ |
537 |
|
int lpos, tpos, rpos; |
538 |
|
int num_cand = 0, last_cand = 1; |
539 |
|
|
540 |
|
VECTOR pmv[4]; /* left neighbour, top neighbour, top-right neighbour */ |
541 |
|
|
542 |
|
lx=x-1; ly=y; lz=1; |
543 |
|
tx=x; ty=y-1; tz=2; |
544 |
|
rx=x+1; ry=y-1; rz=2; |
545 |
|
|
546 |
|
lpos=lx+ly*mb_width; |
547 |
|
rpos=rx+ry*mb_width; |
548 |
|
tpos=tx+ty*mb_width; |
549 |
|
|
550 |
|
if(lx>=0 && lpos>=bound) |
551 |
|
{ |
552 |
|
num_cand++; |
553 |
|
if(mbs[lpos].field_pred) |
554 |
|
pmv[1] = mbs[lpos].mvs_avg; |
555 |
|
else |
556 |
|
pmv[1] = mbs[lpos].mvs[lz]; |
557 |
|
} |
558 |
|
else |
559 |
|
{ |
560 |
|
pmv[1] = zeroMV; |
561 |
|
} |
562 |
|
|
563 |
|
if(tpos>=bound) |
564 |
|
{ |
565 |
|
num_cand++; |
566 |
|
last_cand=2; |
567 |
|
if(mbs[tpos].field_pred) |
568 |
|
pmv[2] = mbs[tpos].mvs_avg; |
569 |
|
else |
570 |
|
pmv[2] = mbs[tpos].mvs[tz]; |
571 |
|
} |
572 |
|
else |
573 |
|
{ |
574 |
|
pmv[2] = zeroMV; |
575 |
|
} |
576 |
|
|
577 |
|
if(rx<mb_width && rpos>=bound) |
578 |
|
{ |
579 |
|
num_cand++; |
580 |
|
last_cand = 3; |
581 |
|
if(mbs[rpos].field_pred) |
582 |
|
pmv[3] = mbs[rpos].mvs_avg; |
583 |
|
else |
584 |
|
pmv[3] = mbs[rpos].mvs[rz]; |
585 |
|
} |
586 |
|
else |
587 |
|
{ |
588 |
|
pmv[3] = zeroMV; |
589 |
|
} |
590 |
|
|
591 |
|
/* If there're more than one candidate, we return the median vector */ |
592 |
|
if(num_cand>1) |
593 |
|
{ |
594 |
|
/* set median */ |
595 |
|
pmv[0].x = MIN(MAX(pmv[1].x, pmv[2].x), |
596 |
|
MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x))); |
597 |
|
pmv[0].y = MIN(MAX(pmv[1].y, pmv[2].y), |
598 |
|
MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y))); |
599 |
|
|
600 |
|
return pmv[0]; |
601 |
|
} |
602 |
|
|
603 |
|
return pmv[last_cand]; /* no point calculating median mv */ |
604 |
|
} |
605 |
|
|
606 |
VECTOR |
VECTOR |
607 |
get_qpmv2(const MACROBLOCK * const mbs, |
get_qpmv2(const MACROBLOCK * const mbs, |
608 |
const int mb_width, |
const int mb_width, |