1/* 2 * Copyright (C) 2007-2008 ARM Limited 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17/** 18 * 19 * File Name: omxVCCOMM_LimitMVToRect.c 20 * OpenMAX DL: v1.0.2 21 * Revision: 9641 22 * Date: Thursday, February 7, 2008 23 * 24 * 25 * 26 * 27 * Description: 28 * Contains module for limiting the MV 29 * 30 */ 31 32#include "omxtypes.h" 33#include "armOMX.h" 34#include "omxVC.h" 35 36#include "armCOMM.h" 37 38/** 39 * Function: omxVCCOMM_LimitMVToRect (6.1.4.1.3) 40 * 41 * Description: 42 * Limits the motion vector associated with the current block/macroblock to 43 * prevent the motion compensated block/macroblock from moving outside a 44 * bounding rectangle as shown in Figure 6-1. 45 * 46 * Input Arguments: 47 * 48 * pSrcMV - pointer to the motion vector associated with the current block 49 * or macroblock 50 * pRectVOPRef - pointer to the bounding rectangle 51 * Xcoord, Ycoord - coordinates of the current block or macroblock 52 * size - size of the current block or macroblock; must be equal to 8 or 53 * 16. 54 * 55 * Output Arguments: 56 * 57 * pDstMV - pointer to the limited motion vector 58 * 59 * Return Value: 60 * 61 * OMX_Sts_NoErr - no error 62 * OMX_Sts_BadArgErr - bad arguments. Returned if one or more of the 63 * following conditions is true: 64 * - at least one of the following pointers is NULL: 65 * pSrcMV, pDstMV, or pRectVOPRef. 66 * - size is not equal to either 8 or 16. 67 * - the width or height of the bounding rectangle is less than 68 * twice the block size. 69 */ 70OMXResult omxVCCOMM_LimitMVToRect( 71 const OMXVCMotionVector * pSrcMV, 72 OMXVCMotionVector *pDstMV, 73 const OMXRect * pRectVOPRef, 74 OMX_INT Xcoord, 75 OMX_INT Ycoord, 76 OMX_INT size 77) 78{ 79 /* Argument error checks */ 80 armRetArgErrIf(pSrcMV == NULL, OMX_Sts_BadArgErr); 81 armRetArgErrIf(pDstMV == NULL, OMX_Sts_BadArgErr); 82 armRetArgErrIf(pRectVOPRef == NULL, OMX_Sts_BadArgErr); 83 armRetArgErrIf((size != 8) && (size != 16), OMX_Sts_BadArgErr); 84 armRetArgErrIf((pRectVOPRef->width < (2* size)), OMX_Sts_BadArgErr); 85 armRetArgErrIf((pRectVOPRef->height < (2* size)), OMX_Sts_BadArgErr); 86 87 pDstMV->dx = armMin (armMax (pSrcMV->dx, 2*pRectVOPRef->x - Xcoord), 88 (2*pRectVOPRef->x + pRectVOPRef->width - Xcoord - size)); 89 pDstMV->dy = armMin (armMax (pSrcMV->dy, 2*pRectVOPRef->y - Ycoord), 90 (2*pRectVOPRef->y + pRectVOPRef->height - Ycoord - size)); 91 92 93 return OMX_Sts_NoErr; 94} 95 96/* End of file */ 97