Home | History | Annotate | Download | only in src
      1 /**
      2  *
      3  * File Name:  omxVCCOMM_ExpandFrame_I.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  * Description:
     12  * This function will Expand Frame boundary pixels into Plane
     13  *
     14  */
     15 
     16 #include "omxtypes.h"
     17 #include "armOMX.h"
     18 #include "omxVC.h"
     19 
     20 #include "armCOMM.h"
     21 
     22 /**
     23  * Function:  omxVCCOMM_ExpandFrame_I   (6.1.3.2.1)
     24  *
     25  * Description:
     26  * This function expands a reconstructed frame in-place.  The unexpanded
     27  * source frame should be stored in a plane buffer with sufficient space
     28  * pre-allocated for edge expansion, and the input frame should be located in
     29  * the plane buffer center.  This function executes the pixel expansion by
     30  * replicating source frame edge pixel intensities in the empty pixel
     31  * locations (expansion region) between the source frame edge and the plane
     32  * buffer edge.  The width/height of the expansion regions on the
     33  * horizontal/vertical edges is controlled by the parameter iExpandPels.
     34  *
     35  * Input Arguments:
     36  *
     37  *   pSrcDstPlane - pointer to the top-left corner of the frame to be
     38  *            expanded; must be aligned on an 8-byte boundary.
     39  *   iFrameWidth - frame width; must be a multiple of 8.
     40  *   iFrameHeight -frame height; must be a multiple of 8.
     41  *   iExpandPels - number of pixels to be expanded in the horizontal and
     42  *            vertical directions; must be a multiple of 8.
     43  *   iPlaneStep - distance, in bytes, between the start of consecutive lines
     44  *            in the plane buffer; must be larger than or equal to
     45  *            (iFrameWidth + 2 * iExpandPels).
     46  *
     47  * Output Arguments:
     48  *
     49  *   pSrcDstPlane -Pointer to the top-left corner of the frame (NOT the
     50  *            top-left corner of the plane); must be aligned on an 8-byte
     51  *            boundary.
     52  *
     53  * Return Value:
     54  *
     55  *    OMX_Sts_NoErr - no error
     56  *    OMX_Sts_BadArgErr - bad arguments; returned under any of the following
     57  *              conditions:
     58  *    -    pSrcDstPlane is NULL.
     59  *    -    pSrcDstPlane is not aligned on an 8-byte boundary.
     60  *    -    one of the following parameters is either equal to zero or is a
     61  *              non-multiple of 8: iFrameHeight, iFrameWidth, iPlaneStep, or
     62  *              iExpandPels.
     63  *    -    iPlaneStep < (iFrameWidth + 2 * iExpandPels).
     64  *
     65  */
     66 OMXResult omxVCCOMM_ExpandFrame_I(
     67 	OMX_U8*	pSrcDstPlane,
     68 	OMX_U32	iFrameWidth,
     69 	OMX_U32	iFrameHeight,
     70 	OMX_U32	iExpandPels,
     71 	OMX_U32	iPlaneStep
     72 )
     73 {
     74     OMX_INT     x, y;
     75     OMX_U8*     pLeft;
     76     OMX_U8*     pRight;
     77     OMX_U8*     pTop;
     78     OMX_U8*     pBottom;
     79 
     80     /* check for argument error */
     81     armRetArgErrIf(pSrcDstPlane == NULL, OMX_Sts_BadArgErr)
     82     armRetArgErrIf(armNot8ByteAligned(pSrcDstPlane), OMX_Sts_BadArgErr)
     83     armRetArgErrIf(iFrameWidth == 0 || iFrameWidth & 7, OMX_Sts_BadArgErr)
     84     armRetArgErrIf(iFrameHeight== 0 || iFrameHeight & 7, OMX_Sts_BadArgErr)
     85     armRetArgErrIf(iExpandPels == 0 || iExpandPels & 7, OMX_Sts_BadArgErr)
     86     armRetArgErrIf(iPlaneStep == 0 || iPlaneStep & 7, OMX_Sts_BadArgErr)
     87     armRetArgErrIf(iPlaneStep < (iFrameWidth + 2 * iExpandPels),
     88                    OMX_Sts_BadArgErr)
     89 
     90     /* Top and Bottom */
     91     pTop = pSrcDstPlane - (iExpandPels * iPlaneStep);
     92     pBottom = pSrcDstPlane + (iFrameHeight * iPlaneStep);
     93 
     94     for (y = 0; y < (OMX_INT)iExpandPels; y++)
     95     {
     96         for (x = 0; x < (OMX_INT)iFrameWidth; x++)
     97         {
     98             pTop [y * iPlaneStep + x] =
     99                 pSrcDstPlane [x];
    100             pBottom [y * iPlaneStep + x] =
    101                 pSrcDstPlane [(iFrameHeight - 1) * iPlaneStep + x];
    102         }
    103     }
    104 
    105     /* Left, Right and Corners */
    106     pLeft = pSrcDstPlane - iExpandPels;
    107     pRight = pSrcDstPlane + iFrameWidth;
    108 
    109     for (y = -(OMX_INT)iExpandPels; y < (OMX_INT)(iFrameHeight + iExpandPels); y++)
    110     {
    111         for (x = 0; x < (OMX_INT)iExpandPels; x++)
    112         {
    113             pLeft [y * iPlaneStep + x] =
    114                 pSrcDstPlane [y * iPlaneStep + 0];
    115             pRight [y * iPlaneStep + x] =
    116                 pSrcDstPlane [y * iPlaneStep + (iFrameWidth - 1)];
    117         }
    118     }
    119 
    120     return OMX_Sts_NoErr;
    121 }
    122 
    123 /*****************************************************************************
    124  *                              END OF FILE
    125  *****************************************************************************/
    126 
    127