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