178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar/* 278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Copyright (C) 2007-2008 ARM Limited 378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Licensed under the Apache License, Version 2.0 (the "License"); 578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * you may not use this file except in compliance with the License. 678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * You may obtain a copy of the License at 778e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 878e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * http://www.apache.org/licenses/LICENSE-2.0 978e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 1078e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Unless required by applicable law or agreed to in writing, software 1178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * distributed under the License is distributed on an "AS IS" BASIS, 1278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * See the License for the specific language governing permissions and 1478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * limitations under the License. 1578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 1678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar */ 170c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 180c1bc742181ded4930842b46e9507372f0b1b963James Dong * 190c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name: omxVCCOMM_ExpandFrame_I.c 200c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2 210c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision: 9641 220c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date: Thursday, February 7, 2008 230c1bc742181ded4930842b46e9507372f0b1b963James Dong * 240c1bc742181ded4930842b46e9507372f0b1b963James Dong * 250c1bc742181ded4930842b46e9507372f0b1b963James Dong * 260c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 270c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function will Expand Frame boundary pixels into Plane 280c1bc742181ded4930842b46e9507372f0b1b963James Dong * 290c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 300c1bc742181ded4930842b46e9507372f0b1b963James Dong 310c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h" 320c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h" 330c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h" 340c1bc742181ded4930842b46e9507372f0b1b963James Dong 350c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h" 360c1bc742181ded4930842b46e9507372f0b1b963James Dong 370c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 380c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: omxVCCOMM_ExpandFrame_I (6.1.3.2.1) 390c1bc742181ded4930842b46e9507372f0b1b963James Dong * 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function expands a reconstructed frame in-place. The unexpanded 420c1bc742181ded4930842b46e9507372f0b1b963James Dong * source frame should be stored in a plane buffer with sufficient space 430c1bc742181ded4930842b46e9507372f0b1b963James Dong * pre-allocated for edge expansion, and the input frame should be located in 440c1bc742181ded4930842b46e9507372f0b1b963James Dong * the plane buffer center. This function executes the pixel expansion by 450c1bc742181ded4930842b46e9507372f0b1b963James Dong * replicating source frame edge pixel intensities in the empty pixel 460c1bc742181ded4930842b46e9507372f0b1b963James Dong * locations (expansion region) between the source frame edge and the plane 470c1bc742181ded4930842b46e9507372f0b1b963James Dong * buffer edge. The width/height of the expansion regions on the 480c1bc742181ded4930842b46e9507372f0b1b963James Dong * horizontal/vertical edges is controlled by the parameter iExpandPels. 490c1bc742181ded4930842b46e9507372f0b1b963James Dong * 500c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments: 510c1bc742181ded4930842b46e9507372f0b1b963James Dong * 520c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcDstPlane - pointer to the top-left corner of the frame to be 530c1bc742181ded4930842b46e9507372f0b1b963James Dong * expanded; must be aligned on an 8-byte boundary. 540c1bc742181ded4930842b46e9507372f0b1b963James Dong * iFrameWidth - frame width; must be a multiple of 8. 550c1bc742181ded4930842b46e9507372f0b1b963James Dong * iFrameHeight -frame height; must be a multiple of 8. 560c1bc742181ded4930842b46e9507372f0b1b963James Dong * iExpandPels - number of pixels to be expanded in the horizontal and 570c1bc742181ded4930842b46e9507372f0b1b963James Dong * vertical directions; must be a multiple of 8. 580c1bc742181ded4930842b46e9507372f0b1b963James Dong * iPlaneStep - distance, in bytes, between the start of consecutive lines 590c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the plane buffer; must be larger than or equal to 600c1bc742181ded4930842b46e9507372f0b1b963James Dong * (iFrameWidth + 2 * iExpandPels). 610c1bc742181ded4930842b46e9507372f0b1b963James Dong * 620c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments: 630c1bc742181ded4930842b46e9507372f0b1b963James Dong * 640c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcDstPlane -Pointer to the top-left corner of the frame (NOT the 650c1bc742181ded4930842b46e9507372f0b1b963James Dong * top-left corner of the plane); must be aligned on an 8-byte 660c1bc742181ded4930842b46e9507372f0b1b963James Dong * boundary. 670c1bc742181ded4930842b46e9507372f0b1b963James Dong * 680c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 690c1bc742181ded4930842b46e9507372f0b1b963James Dong * 700c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_NoErr - no error 710c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_BadArgErr - bad arguments; returned under any of the following 720c1bc742181ded4930842b46e9507372f0b1b963James Dong * conditions: 730c1bc742181ded4930842b46e9507372f0b1b963James Dong * - pSrcDstPlane is NULL. 740c1bc742181ded4930842b46e9507372f0b1b963James Dong * - pSrcDstPlane is not aligned on an 8-byte boundary. 750c1bc742181ded4930842b46e9507372f0b1b963James Dong * - one of the following parameters is either equal to zero or is a 760c1bc742181ded4930842b46e9507372f0b1b963James Dong * non-multiple of 8: iFrameHeight, iFrameWidth, iPlaneStep, or 770c1bc742181ded4930842b46e9507372f0b1b963James Dong * iExpandPels. 780c1bc742181ded4930842b46e9507372f0b1b963James Dong * - iPlaneStep < (iFrameWidth + 2 * iExpandPels). 790c1bc742181ded4930842b46e9507372f0b1b963James Dong * 800c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 810c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCCOMM_ExpandFrame_I( 820c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8* pSrcDstPlane, 830c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iFrameWidth, 840c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iFrameHeight, 850c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iExpandPels, 860c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iPlaneStep 870c1bc742181ded4930842b46e9507372f0b1b963James Dong) 880c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 890c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT x, y; 900c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8* pLeft; 910c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8* pRight; 920c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8* pTop; 930c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8* pBottom; 940c1bc742181ded4930842b46e9507372f0b1b963James Dong 950c1bc742181ded4930842b46e9507372f0b1b963James Dong /* check for argument error */ 960c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pSrcDstPlane == NULL, OMX_Sts_BadArgErr) 970c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(armNot8ByteAligned(pSrcDstPlane), OMX_Sts_BadArgErr) 980c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(iFrameWidth == 0 || iFrameWidth & 7, OMX_Sts_BadArgErr) 990c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(iFrameHeight== 0 || iFrameHeight & 7, OMX_Sts_BadArgErr) 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(iExpandPels == 0 || iExpandPels & 7, OMX_Sts_BadArgErr) 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(iPlaneStep == 0 || iPlaneStep & 7, OMX_Sts_BadArgErr) 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(iPlaneStep < (iFrameWidth + 2 * iExpandPels), 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_Sts_BadArgErr) 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Top and Bottom */ 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong pTop = pSrcDstPlane - (iExpandPels * iPlaneStep); 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong pBottom = pSrcDstPlane + (iFrameHeight * iPlaneStep); 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong for (y = 0; y < (OMX_INT)iExpandPels; y++) 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong for (x = 0; x < (OMX_INT)iFrameWidth; x++) 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong pTop [y * iPlaneStep + x] = 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcDstPlane [x]; 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong pBottom [y * iPlaneStep + x] = 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcDstPlane [(iFrameHeight - 1) * iPlaneStep + x]; 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Left, Right and Corners */ 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong pLeft = pSrcDstPlane - iExpandPels; 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong pRight = pSrcDstPlane + iFrameWidth; 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong for (y = -(OMX_INT)iExpandPels; y < (OMX_INT)(iFrameHeight + iExpandPels); y++) 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong for (x = 0; x < (OMX_INT)iExpandPels; x++) 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong pLeft [y * iPlaneStep + x] = 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcDstPlane [y * iPlaneStep + 0]; 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong pRight [y * iPlaneStep + x] = 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcDstPlane [y * iPlaneStep + (iFrameWidth - 1)]; 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_NoErr; 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong/***************************************************************************** 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong * END OF FILE 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong *****************************************************************************/ 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong 142