10c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 20c1bc742181ded4930842b46e9507372f0b1b963James Dong * 30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name: armVCM4P2_CompareMV.c 40c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2 50c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision: 9641 60c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date: Thursday, February 7, 2008 70c1bc742181ded4930842b46e9507372f0b1b963James Dong * 80c1bc742181ded4930842b46e9507372f0b1b963James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. 90c1bc742181ded4930842b46e9507372f0b1b963James Dong * 100c1bc742181ded4930842b46e9507372f0b1b963James Dong * 110c1bc742181ded4930842b46e9507372f0b1b963James Dong * 120c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 130c1bc742181ded4930842b46e9507372f0b1b963James Dong * Contains module for comparing motion vectors and SAD's to decide 140c1bc742181ded4930842b46e9507372f0b1b963James Dong * the best MV and SAD 150c1bc742181ded4930842b46e9507372f0b1b963James Dong * 160c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 170c1bc742181ded4930842b46e9507372f0b1b963James Dong 180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h" 190c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h" 200c1bc742181ded4930842b46e9507372f0b1b963James Dong 210c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h" 220c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h" 230c1bc742181ded4930842b46e9507372f0b1b963James Dong 240c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 250c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_CompareMV 260c1bc742181ded4930842b46e9507372f0b1b963James Dong * 270c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 280c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs comparision of motion vectors and SAD's to decide the 290c1bc742181ded4930842b46e9507372f0b1b963James Dong * best MV and SAD 300c1bc742181ded4930842b46e9507372f0b1b963James Dong * 310c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 320c1bc742181ded4930842b46e9507372f0b1b963James Dong * 330c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 340c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] mvX x coordinate of the candidate motion vector 350c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] mvY y coordinate of the candidate motion vector 360c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] candSAD Candidate SAD 370c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] bestMVX x coordinate of the best motion vector 380c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] bestMVY y coordinate of the best motion vector 390c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] bestSAD best SAD 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 420c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_INT -- 1 to indicate that the current sad is the best 430c1bc742181ded4930842b46e9507372f0b1b963James Dong * 0 to indicate that it is NOT the best SAD 440c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 450c1bc742181ded4930842b46e9507372f0b1b963James Dong 460c1bc742181ded4930842b46e9507372f0b1b963James DongOMX_INT armVCM4P2_CompareMV ( 470c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16 mvX, 480c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16 mvY, 490c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT candSAD, 500c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16 bestMVX, 510c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16 bestMVY, 520c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT bestSAD 530c1bc742181ded4930842b46e9507372f0b1b963James Dong) 540c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 550c1bc742181ded4930842b46e9507372f0b1b963James Dong if (candSAD < bestSAD) 560c1bc742181ded4930842b46e9507372f0b1b963James Dong { 570c1bc742181ded4930842b46e9507372f0b1b963James Dong return 1; 580c1bc742181ded4930842b46e9507372f0b1b963James Dong } 590c1bc742181ded4930842b46e9507372f0b1b963James Dong if (candSAD > bestSAD) 600c1bc742181ded4930842b46e9507372f0b1b963James Dong { 610c1bc742181ded4930842b46e9507372f0b1b963James Dong return 0; 620c1bc742181ded4930842b46e9507372f0b1b963James Dong } 630c1bc742181ded4930842b46e9507372f0b1b963James Dong /* shorter motion vector */ 640c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( (mvX * mvX + mvY * mvY) < (bestMVX*bestMVX+bestMVY*bestMVY) ) 650c1bc742181ded4930842b46e9507372f0b1b963James Dong { 660c1bc742181ded4930842b46e9507372f0b1b963James Dong return 1; 670c1bc742181ded4930842b46e9507372f0b1b963James Dong } 680c1bc742181ded4930842b46e9507372f0b1b963James Dong return 0; 690c1bc742181ded4930842b46e9507372f0b1b963James Dong} 700c1bc742181ded4930842b46e9507372f0b1b963James Dong 710c1bc742181ded4930842b46e9507372f0b1b963James Dong/*End of File*/ 72