Home | History | Annotate | Download | only in src
      1 /**
      2  *
      3  * File Name:  omxVCCOMM_LimitMVToRect.c
      4  * OpenMAX DL: v1.0.2
      5  * Revision:   9641
      6  * Date:       Thursday, February 7, 2008
      7  *
      8  * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
      9  *
     10  *
     11  *
     12  * Description:
     13  * Contains module for limiting the MV
     14  *
     15  */
     16 
     17 #include "omxtypes.h"
     18 #include "armOMX.h"
     19 #include "omxVC.h"
     20 
     21 #include "armCOMM.h"
     22 
     23 /**
     24  * Function:  omxVCCOMM_LimitMVToRect   (6.1.4.1.3)
     25  *
     26  * Description:
     27  * Limits the motion vector associated with the current block/macroblock to
     28  * prevent the motion compensated block/macroblock from moving outside a
     29  * bounding rectangle as shown in Figure 6-1.
     30  *
     31  * Input Arguments:
     32  *
     33  *   pSrcMV - pointer to the motion vector associated with the current block
     34  *            or macroblock
     35  *   pRectVOPRef - pointer to the bounding rectangle
     36  *   Xcoord, Ycoord  - coordinates of the current block or macroblock
     37  *   size - size of the current block or macroblock; must be equal to 8 or
     38  *            16.
     39  *
     40  * Output Arguments:
     41  *
     42  *   pDstMV - pointer to the limited motion vector
     43  *
     44  * Return Value:
     45  *
     46  *    OMX_Sts_NoErr - no error
     47  *    OMX_Sts_BadArgErr - bad arguments.  Returned if one or more of the
     48  *              following conditions is true:
     49  *    -    at least one of the following pointers is NULL:
     50  *         pSrcMV, pDstMV, or pRectVOPRef.
     51  *    -    size is not equal to either 8 or 16.
     52  *    -    the width or height of the bounding rectangle is less than
     53  *         twice the block size.
     54  */
     55 OMXResult omxVCCOMM_LimitMVToRect(
     56      const OMXVCMotionVector * pSrcMV,
     57      OMXVCMotionVector *pDstMV,
     58      const OMXRect * pRectVOPRef,
     59      OMX_INT Xcoord,
     60      OMX_INT Ycoord,
     61      OMX_INT size
     62 )
     63 {
     64     /* Argument error checks */
     65     armRetArgErrIf(pSrcMV == NULL, OMX_Sts_BadArgErr);
     66     armRetArgErrIf(pDstMV == NULL, OMX_Sts_BadArgErr);
     67     armRetArgErrIf(pRectVOPRef == NULL, OMX_Sts_BadArgErr);
     68     armRetArgErrIf((size != 8) && (size != 16), OMX_Sts_BadArgErr);
     69     armRetArgErrIf((pRectVOPRef->width < (2* size)), OMX_Sts_BadArgErr);
     70     armRetArgErrIf((pRectVOPRef->height < (2* size)), OMX_Sts_BadArgErr);
     71 
     72     pDstMV->dx = armMin (armMax (pSrcMV->dx, 2*pRectVOPRef->x - Xcoord),
     73                     (2*pRectVOPRef->x + pRectVOPRef->width - Xcoord - size));
     74     pDstMV->dy = armMin (armMax (pSrcMV->dy, 2*pRectVOPRef->y - Ycoord),
     75                     (2*pRectVOPRef->y + pRectVOPRef->height - Ycoord - size));
     76 
     77 
     78     return OMX_Sts_NoErr;
     79 }
     80 
     81 /* End of file */
     82