10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCCOMM_ExpandFrame_I.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 * Description:
120c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function will Expand Frame boundary pixels into Plane
130c1bc742181ded4930842b46e9507372f0b1b963James Dong *
140c1bc742181ded4930842b46e9507372f0b1b963James Dong */
150c1bc742181ded4930842b46e9507372f0b1b963James Dong
160c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h"
170c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h"
180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h"
190c1bc742181ded4930842b46e9507372f0b1b963James Dong
200c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h"
210c1bc742181ded4930842b46e9507372f0b1b963James Dong
220c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
230c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCCOMM_ExpandFrame_I   (6.1.3.2.1)
240c1bc742181ded4930842b46e9507372f0b1b963James Dong *
250c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
260c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function expands a reconstructed frame in-place.  The unexpanded
270c1bc742181ded4930842b46e9507372f0b1b963James Dong * source frame should be stored in a plane buffer with sufficient space
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * pre-allocated for edge expansion, and the input frame should be located in
290c1bc742181ded4930842b46e9507372f0b1b963James Dong * the plane buffer center.  This function executes the pixel expansion by
300c1bc742181ded4930842b46e9507372f0b1b963James Dong * replicating source frame edge pixel intensities in the empty pixel
310c1bc742181ded4930842b46e9507372f0b1b963James Dong * locations (expansion region) between the source frame edge and the plane
320c1bc742181ded4930842b46e9507372f0b1b963James Dong * buffer edge.  The width/height of the expansion regions on the
330c1bc742181ded4930842b46e9507372f0b1b963James Dong * horizontal/vertical edges is controlled by the parameter iExpandPels.
340c1bc742181ded4930842b46e9507372f0b1b963James Dong *
350c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
360c1bc742181ded4930842b46e9507372f0b1b963James Dong *
370c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcDstPlane - pointer to the top-left corner of the frame to be
380c1bc742181ded4930842b46e9507372f0b1b963James Dong *            expanded; must be aligned on an 8-byte boundary.
390c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iFrameWidth - frame width; must be a multiple of 8.
400c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iFrameHeight -frame height; must be a multiple of 8.
410c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iExpandPels - number of pixels to be expanded in the horizontal and
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *            vertical directions; must be a multiple of 8.
430c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iPlaneStep - distance, in bytes, between the start of consecutive lines
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *            in the plane buffer; must be larger than or equal to
450c1bc742181ded4930842b46e9507372f0b1b963James Dong *            (iFrameWidth + 2 * iExpandPels).
460c1bc742181ded4930842b46e9507372f0b1b963James Dong *
470c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
480c1bc742181ded4930842b46e9507372f0b1b963James Dong *
490c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcDstPlane -Pointer to the top-left corner of the frame (NOT the
500c1bc742181ded4930842b46e9507372f0b1b963James Dong *            top-left corner of the plane); must be aligned on an 8-byte
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *            boundary.
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *
530c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
560c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments; returned under any of the following
570c1bc742181ded4930842b46e9507372f0b1b963James Dong *              conditions:
580c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    pSrcDstPlane is NULL.
590c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    pSrcDstPlane is not aligned on an 8-byte boundary.
600c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    one of the following parameters is either equal to zero or is a
610c1bc742181ded4930842b46e9507372f0b1b963James Dong *              non-multiple of 8: iFrameHeight, iFrameWidth, iPlaneStep, or
620c1bc742181ded4930842b46e9507372f0b1b963James Dong *              iExpandPels.
630c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    iPlaneStep < (iFrameWidth + 2 * iExpandPels).
640c1bc742181ded4930842b46e9507372f0b1b963James Dong *
650c1bc742181ded4930842b46e9507372f0b1b963James Dong */
660c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCCOMM_ExpandFrame_I(
670c1bc742181ded4930842b46e9507372f0b1b963James Dong	OMX_U8*	pSrcDstPlane,
680c1bc742181ded4930842b46e9507372f0b1b963James Dong	OMX_U32	iFrameWidth,
690c1bc742181ded4930842b46e9507372f0b1b963James Dong	OMX_U32	iFrameHeight,
700c1bc742181ded4930842b46e9507372f0b1b963James Dong	OMX_U32	iExpandPels,
710c1bc742181ded4930842b46e9507372f0b1b963James Dong	OMX_U32	iPlaneStep
720c1bc742181ded4930842b46e9507372f0b1b963James Dong)
730c1bc742181ded4930842b46e9507372f0b1b963James Dong{
740c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_INT     x, y;
750c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8*     pLeft;
760c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8*     pRight;
770c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8*     pTop;
780c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8*     pBottom;
790c1bc742181ded4930842b46e9507372f0b1b963James Dong
800c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* check for argument error */
810c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSrcDstPlane == NULL, OMX_Sts_BadArgErr)
820c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(armNot8ByteAligned(pSrcDstPlane), OMX_Sts_BadArgErr)
830c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(iFrameWidth == 0 || iFrameWidth & 7, OMX_Sts_BadArgErr)
840c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(iFrameHeight== 0 || iFrameHeight & 7, OMX_Sts_BadArgErr)
850c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(iExpandPels == 0 || iExpandPels & 7, OMX_Sts_BadArgErr)
860c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(iPlaneStep == 0 || iPlaneStep & 7, OMX_Sts_BadArgErr)
870c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(iPlaneStep < (iFrameWidth + 2 * iExpandPels),
880c1bc742181ded4930842b46e9507372f0b1b963James Dong                   OMX_Sts_BadArgErr)
890c1bc742181ded4930842b46e9507372f0b1b963James Dong
900c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Top and Bottom */
910c1bc742181ded4930842b46e9507372f0b1b963James Dong    pTop = pSrcDstPlane - (iExpandPels * iPlaneStep);
920c1bc742181ded4930842b46e9507372f0b1b963James Dong    pBottom = pSrcDstPlane + (iFrameHeight * iPlaneStep);
930c1bc742181ded4930842b46e9507372f0b1b963James Dong
940c1bc742181ded4930842b46e9507372f0b1b963James Dong    for (y = 0; y < (OMX_INT)iExpandPels; y++)
950c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
960c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (x = 0; x < (OMX_INT)iFrameWidth; x++)
970c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
980c1bc742181ded4930842b46e9507372f0b1b963James Dong            pTop [y * iPlaneStep + x] =
990c1bc742181ded4930842b46e9507372f0b1b963James Dong                pSrcDstPlane [x];
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong            pBottom [y * iPlaneStep + x] =
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong                pSrcDstPlane [(iFrameHeight - 1) * iPlaneStep + x];
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Left, Right and Corners */
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong    pLeft = pSrcDstPlane - iExpandPels;
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong    pRight = pSrcDstPlane + iFrameWidth;
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong    for (y = -(OMX_INT)iExpandPels; y < (OMX_INT)(iFrameHeight + iExpandPels); y++)
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (x = 0; x < (OMX_INT)iExpandPels; x++)
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong            pLeft [y * iPlaneStep + x] =
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong                pSrcDstPlane [y * iPlaneStep + 0];
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong            pRight [y * iPlaneStep + x] =
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong                pSrcDstPlane [y * iPlaneStep + (iFrameWidth - 1)];
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong    return OMX_Sts_NoErr;
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong}
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong/*****************************************************************************
1240c1bc742181ded4930842b46e9507372f0b1b963James Dong *                              END OF FILE
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong *****************************************************************************/
1260c1bc742181ded4930842b46e9507372f0b1b963James Dong
127