21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: estimation_pvop.c,v 1.9 2004-12-05 04:53:01 syskin Exp $ |
* $Id: estimation_pvop.c,v 1.10 2004-12-08 12:43:48 syskin Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
751 |
return Flags; |
return Flags; |
752 |
} |
} |
753 |
|
|
754 |
|
static __inline void |
755 |
|
motionStatsPVOP(int * const MVmax, int * const mvCount, int * const mvSum, |
756 |
|
const MACROBLOCK * const pMB, const int qpel) |
757 |
|
{ |
758 |
|
const VECTOR * const mv = qpel ? pMB->qmvs : pMB->mvs; |
759 |
|
int i; |
760 |
|
int max = *MVmax; |
761 |
|
|
762 |
|
switch (pMB->mode) { |
763 |
|
case MODE_INTER4V: |
764 |
|
*mvCount += 3; |
765 |
|
for(i = 3; i; i--) { |
766 |
|
if (mv[i].x > max) max = mv[i].x; |
767 |
|
else if (-mv[i].x - 1 > max) max = -mv[i].x - 1; |
768 |
|
*mvSum += mv[i].x * mv[i].x; |
769 |
|
if (mv[i].y > max) max = mv[i].y; |
770 |
|
else if (-mv[i].y - 1 > max) max = -mv[i].y - 1; |
771 |
|
*mvSum += mv[i].y * mv[i].y; |
772 |
|
} |
773 |
|
case MODE_INTER: |
774 |
|
(*mvCount)++; /* add mcsel==1 vector to statistics too, or else we ignore useful motion range info */ |
775 |
|
*mvSum += mv[0].x * mv[0].x; |
776 |
|
*mvSum += mv[0].y * mv[0].y; |
777 |
|
if (pMB->mcsel == 0) { |
778 |
|
if (mv[0].x > max) max = mv[0].x; |
779 |
|
else if (-mv[0].x - 1 > max) max = -mv[0].x - 1; |
780 |
|
if (mv[0].y > max) max = mv[0].y; |
781 |
|
else if (-mv[0].y - 1 > max) max = -mv[0].y - 1; |
782 |
|
*MVmax = max; |
783 |
|
} |
784 |
|
default: |
785 |
|
break; |
786 |
|
} |
787 |
|
} |
788 |
|
|
789 |
bool |
bool |
790 |
MotionEstimation(MBParam * const pParam, |
MotionEstimation(MBParam * const pParam, |
791 |
FRAMEINFO * const current, |
FRAMEINFO * const current, |
805 |
const uint32_t iEdgedWidth = pParam->edged_width; |
const uint32_t iEdgedWidth = pParam->edged_width; |
806 |
const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags); |
const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags); |
807 |
int stat_thresh = 0; |
int stat_thresh = 0; |
808 |
|
int MVmax = 0, mvSum = 0, mvCount = 0; |
809 |
|
|
810 |
uint32_t x, y; |
uint32_t x, y; |
811 |
int32_t sad00; |
int32_t sad00; |
904 |
pCurrent, pRef, pGMC, current->coding_type, sad00); |
pCurrent, pRef, pGMC, current->coding_type, sad00); |
905 |
|
|
906 |
|
|
907 |
|
motionStatsPVOP(&MVmax, &mvCount, &mvSum, pMB, Data.qpel); |
908 |
} |
} |
909 |
} |
} |
|
return 0; |
|
|
} |
|
910 |
|
|
911 |
|
current->fcode = getMinFcode(MVmax); |
912 |
|
current->sStat.iMvSum = mvSum; |
913 |
|
current->sStat.iMvCount = mvCount; |
914 |
|
|
915 |
|
return 0; |
916 |
|
} |