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: armVCM4P10_Interpolate_Luma.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 calculate interpolation for luma components 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#include "armVC.h" 370c1bc742181ded4930842b46e9507372f0b1b963James Dong 380c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 390c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armM4P10_Copy 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 420c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function performs copy a block of data from source to destination 430c1bc742181ded4930842b46e9507372f0b1b963James Dong * 440c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 450c1bc742181ded4930842b46e9507372f0b1b963James Dong * 460c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrc Pointer to top-left corner of block 470c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iSrcStep Step of the source buffer. 480c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iDstStep Step of the destination buffer. 490c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iWidth Width of the current block 500c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iHeight Height of the current block 510c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst Pointer to the interpolation buffer 520c1bc742181ded4930842b46e9507372f0b1b963James Dong * 530c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 540c1bc742181ded4930842b46e9507372f0b1b963James Dong * Standard OMXResult value. 550c1bc742181ded4930842b46e9507372f0b1b963James Dong * 560c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 570c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic OMXResult armM4P10_Copy( 580c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8* pSrc, 590c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iSrcStep, 600c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8* pDst, 610c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iDstStep, 620c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iWidth, 630c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iHeight 640c1bc742181ded4930842b46e9507372f0b1b963James Dong) 650c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 660c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 x, y; 670c1bc742181ded4930842b46e9507372f0b1b963James Dong 680c1bc742181ded4930842b46e9507372f0b1b963James Dong for (y = 0; y < iHeight; y++) 690c1bc742181ded4930842b46e9507372f0b1b963James Dong { 700c1bc742181ded4930842b46e9507372f0b1b963James Dong for (x = 0; x < iWidth; x++) 710c1bc742181ded4930842b46e9507372f0b1b963James Dong { 720c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst [y * iDstStep + x] = pSrc [y * iSrcStep + x]; 730c1bc742181ded4930842b46e9507372f0b1b963James Dong } 740c1bc742181ded4930842b46e9507372f0b1b963James Dong } 750c1bc742181ded4930842b46e9507372f0b1b963James Dong 760c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_NoErr; 770c1bc742181ded4930842b46e9507372f0b1b963James Dong} 780c1bc742181ded4930842b46e9507372f0b1b963James Dong 790c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 800c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P10_Interpolate_Luma 810c1bc742181ded4930842b46e9507372f0b1b963James Dong * 820c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 830c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function performs interpolation for luma components. 840c1bc742181ded4930842b46e9507372f0b1b963James Dong * 850c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 860c1bc742181ded4930842b46e9507372f0b1b963James Dong * 870c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrc Pointer to top-left corner of block used to 880c1bc742181ded4930842b46e9507372f0b1b963James Dong * interpolate in the reconstructed frame plane 890c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iSrcStep Step of the source buffer. 900c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iDstStep Step of the destination(interpolation) buffer. 910c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iWidth Width of the current block 920c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] iHeight Height of the current block 930c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] dx Fractional part of horizontal motion vector 940c1bc742181ded4930842b46e9507372f0b1b963James Dong * component in 1/4 pixel unit (0~3) 950c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] dy Fractional part of vertical motion vector 960c1bc742181ded4930842b46e9507372f0b1b963James Dong * component in 1/4 pixel unit (0~3) 970c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst Pointer to the interpolation buffer 980c1bc742181ded4930842b46e9507372f0b1b963James Dong * 990c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong * Standard OMXResult value. 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong OMXResult armVCM4P10_Interpolate_Luma( 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrc, 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iSrcStep, 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 *pDst, 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iDstStep, 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iWidth, 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 iHeight, 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 dx, 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 dy 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong) 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 pBuf1 [16*16]; 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrcHalfHor = pSrc; 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrcHalfVer = pSrc; 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong /* check for argument error */ 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr) 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr) 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(dx > 3, OMX_Sts_BadArgErr) 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(dy > 3, OMX_Sts_BadArgErr) 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Work out positions for half pixel interpolation */ 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong if (dx == 3) 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcHalfVer += 1; 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong if (dy == 3) 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcHalfHor += iSrcStep; 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Switch on type of pixel 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong * Pixels are named 'a' to 's' as in the H.264 standard 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong if (dx == 0 && dy == 0) 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong /* G */ 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong armM4P10_Copy(pSrc, iSrcStep, pDst, iDstStep, iWidth, iHeight); 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1430c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (dy == 0) 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1450c1bc742181ded4930842b46e9507372f0b1b963James Dong /* a, b, c */ 1460c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_InterpolateHalfHor_Luma 1470c1bc742181ded4930842b46e9507372f0b1b963James Dong (pSrcHalfHor, iSrcStep, pDst, iDstStep, iWidth, iHeight); 1480c1bc742181ded4930842b46e9507372f0b1b963James Dong 1490c1bc742181ded4930842b46e9507372f0b1b963James Dong if (dx == 1 || dx == 3) 1500c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1510c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCCOMM_Average 1520c1bc742181ded4930842b46e9507372f0b1b963James Dong (pDst, pSrcHalfVer, iDstStep, iSrcStep, pDst, iDstStep, iWidth, iHeight); 1530c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1540c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1550c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (dx == 0) 1560c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1570c1bc742181ded4930842b46e9507372f0b1b963James Dong /* d, h, n */ 1580c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_InterpolateHalfVer_Luma 1590c1bc742181ded4930842b46e9507372f0b1b963James Dong (pSrcHalfVer, iSrcStep, pDst, iDstStep, iWidth, iHeight); 1600c1bc742181ded4930842b46e9507372f0b1b963James Dong 1610c1bc742181ded4930842b46e9507372f0b1b963James Dong if (dy == 1 || dy == 3) 1620c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1630c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCCOMM_Average 1640c1bc742181ded4930842b46e9507372f0b1b963James Dong (pDst, pSrcHalfHor, iDstStep, iSrcStep, pDst, iDstStep, iWidth, iHeight); 1650c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1660c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1670c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (dx == 2 || dy == 2) 1680c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1690c1bc742181ded4930842b46e9507372f0b1b963James Dong /* j */ 1700c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_InterpolateHalfDiag_Luma 1710c1bc742181ded4930842b46e9507372f0b1b963James Dong (pSrc, iSrcStep, pDst, iDstStep, iWidth, iHeight); 1720c1bc742181ded4930842b46e9507372f0b1b963James Dong 1730c1bc742181ded4930842b46e9507372f0b1b963James Dong if (dx == 1 || dx == 3) 1740c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1750c1bc742181ded4930842b46e9507372f0b1b963James Dong /* i, k */ 1760c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_InterpolateHalfVer_Luma 1770c1bc742181ded4930842b46e9507372f0b1b963James Dong (pSrcHalfVer, iSrcStep, pBuf1, iWidth, iWidth, iHeight); 1780c1bc742181ded4930842b46e9507372f0b1b963James Dong 1790c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCCOMM_Average 1800c1bc742181ded4930842b46e9507372f0b1b963James Dong (pDst, pBuf1, iDstStep, iWidth, pDst, iDstStep, iWidth, iHeight); 1810c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1820c1bc742181ded4930842b46e9507372f0b1b963James Dong if (dy == 1 || dy == 3) 1830c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1840c1bc742181ded4930842b46e9507372f0b1b963James Dong /* f,q */ 1850c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_InterpolateHalfHor_Luma 1860c1bc742181ded4930842b46e9507372f0b1b963James Dong (pSrcHalfHor, iSrcStep, pBuf1, iWidth, iWidth, iHeight); 1870c1bc742181ded4930842b46e9507372f0b1b963James Dong 1880c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCCOMM_Average 1890c1bc742181ded4930842b46e9507372f0b1b963James Dong (pDst, pBuf1, iDstStep, iWidth, pDst, iDstStep, iWidth, iHeight); 1900c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1910c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1920c1bc742181ded4930842b46e9507372f0b1b963James Dong else /* dx=1,3 and dy=1,3 */ 1930c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1940c1bc742181ded4930842b46e9507372f0b1b963James Dong /* e, g, p, r */ 1950c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_InterpolateHalfHor_Luma 1960c1bc742181ded4930842b46e9507372f0b1b963James Dong (pSrcHalfHor, iSrcStep, pBuf1, iWidth, iWidth, iHeight); 1970c1bc742181ded4930842b46e9507372f0b1b963James Dong 1980c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P10_InterpolateHalfVer_Luma 1990c1bc742181ded4930842b46e9507372f0b1b963James Dong (pSrcHalfVer, iSrcStep, pDst, iDstStep, iWidth, iHeight); 2000c1bc742181ded4930842b46e9507372f0b1b963James Dong 2010c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCCOMM_Average 2020c1bc742181ded4930842b46e9507372f0b1b963James Dong (pBuf1, pDst, iWidth, iDstStep, pDst, iDstStep, iWidth, iHeight); 2030c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2040c1bc742181ded4930842b46e9507372f0b1b963James Dong 2050c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_NoErr; 2060c1bc742181ded4930842b46e9507372f0b1b963James Dong} 2070c1bc742181ded4930842b46e9507372f0b1b963James Dong 2080c1bc742181ded4930842b46e9507372f0b1b963James Dong/***************************************************************************** 2090c1bc742181ded4930842b46e9507372f0b1b963James Dong * END OF FILE 2100c1bc742181ded4930842b46e9507372f0b1b963James Dong *****************************************************************************/ 211