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: omxVCM4P2_MCReconBlock.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 * MPEG4 motion compensation prediction for an 8x8 block using 280c1bc742181ded4930842b46e9507372f0b1b963James Dong * interpolation 290c1bc742181ded4930842b46e9507372f0b1b963James Dong * 300c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 310c1bc742181ded4930842b46e9507372f0b1b963James Dong 320c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h" 330c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h" 340c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h" 350c1bc742181ded4930842b46e9507372f0b1b963James Dong 360c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h" 370c1bc742181ded4930842b46e9507372f0b1b963James Dong 380c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 390c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_HalfPelVer 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 420c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs half pel motion compensation for an 8x8 block using vertical 430c1bc742181ded4930842b46e9507372f0b1b963James Dong * interpolation described in ISO/IEC 14496-2, subclause 7.6.2. 440c1bc742181ded4930842b46e9507372f0b1b963James Dong * 450c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 460c1bc742181ded4930842b46e9507372f0b1b963James Dong * 470c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 480c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrc pointer to the block in the reference plane. 490c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] srcStep distance between the start of consecutive lines 500c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the reference plane, in bytes; must be a multiple 510c1bc742181ded4930842b46e9507372f0b1b963James Dong * of 8. 520c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled. 530c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst pointer to the linaer 8x8 destination buffer; 540c1bc742181ded4930842b46e9507372f0b1b963James Dong * 550c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 560c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic OMXVoid armVCM4P2_HalfPelVer( 570c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrc, 580c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT srcStep, 590c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 *pDst, 600c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT rndVal) 610c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 620c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc1; 630c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc2; 640c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT y, x; 650c1bc742181ded4930842b46e9507372f0b1b963James Dong 660c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc1 = pSrc; 670c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc2 = pSrc + srcStep; 680c1bc742181ded4930842b46e9507372f0b1b963James Dong srcStep -= 8; 690c1bc742181ded4930842b46e9507372f0b1b963James Dong for (y = 0; y < 8; y++) 700c1bc742181ded4930842b46e9507372f0b1b963James Dong { 710c1bc742181ded4930842b46e9507372f0b1b963James Dong for (x = 0; x < 8; x++) 720c1bc742181ded4930842b46e9507372f0b1b963James Dong { 730c1bc742181ded4930842b46e9507372f0b1b963James Dong *pDst++ = ((*pTempSrc1++ + *pTempSrc2++) + 1 - rndVal) >> 1; 740c1bc742181ded4930842b46e9507372f0b1b963James Dong } 750c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc1 += srcStep; 760c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc2 += srcStep; 770c1bc742181ded4930842b46e9507372f0b1b963James Dong } 780c1bc742181ded4930842b46e9507372f0b1b963James Dong} 790c1bc742181ded4930842b46e9507372f0b1b963James Dong 800c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 810c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_HalfPelHor 820c1bc742181ded4930842b46e9507372f0b1b963James Dong * 830c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 840c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs half pel motion compensation for an 8x8 block using horizontal 850c1bc742181ded4930842b46e9507372f0b1b963James Dong * interpolation described in ISO/IEC 14496-2, subclause 7.6.2. 860c1bc742181ded4930842b46e9507372f0b1b963James Dong * 870c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 880c1bc742181ded4930842b46e9507372f0b1b963James Dong * 890c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 900c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrc pointer to the block in the reference plane. 910c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] srcStep distance between the start of consecutive lines 920c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the reference plane, in bytes; must be a multiple 930c1bc742181ded4930842b46e9507372f0b1b963James Dong * of 8. 940c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled. 950c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst pointer to the linaer 8x8 destination buffer; 960c1bc742181ded4930842b46e9507372f0b1b963James Dong * 970c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 980c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic OMXVoid armVCM4P2_HalfPelHor( 990c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrc, 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT srcStep, 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 *pDst, 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT rndVal) 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc1; 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc2; 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT y, x; 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc1 = pSrc; 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc2 = pTempSrc1 + 1; 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong srcStep -= 8; 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong for (y=0; y<8; y++) 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong for (x=0; x<8; x++) 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong *pDst++ = ((*pTempSrc1++ + *pTempSrc2++) + 1 - rndVal) >> 1; 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc1 += srcStep; 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc2 += srcStep; 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_HalfPelVerHor 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs half pel motion compensation for an 8x8 block using both 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong * horizontal and vertical interpolation described in ISO/IEC 14496-2, 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong * subclause 7.6.2. 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrc pointer to the block in the reference plane. 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] srcStep distance between the start of consecutive lines 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the reference plane, in bytes; must be a multiple 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong * of 8. 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled. 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst pointer to the linaer 8x8 destination buffer; 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 1430c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic OMXVoid armVCM4P2_HalfPelVerHor( 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrc, 1450c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT srcStep, 1460c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 *pDst, 1470c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT rndVal) 1480c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 1490c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc1; 1500c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc2; 1510c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc3; 1520c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pTempSrc4; 1530c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT y, x; 1540c1bc742181ded4930842b46e9507372f0b1b963James Dong 1550c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc1 = pSrc; 1560c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc2 = pSrc + srcStep; 1570c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc3 = pSrc + 1; 1580c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc4 = pSrc + srcStep + 1; 1590c1bc742181ded4930842b46e9507372f0b1b963James Dong 1600c1bc742181ded4930842b46e9507372f0b1b963James Dong srcStep -= 8; 1610c1bc742181ded4930842b46e9507372f0b1b963James Dong for (y=0; y<8; y++) 1620c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1630c1bc742181ded4930842b46e9507372f0b1b963James Dong for (x=0; x<8; x++) 1640c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1650c1bc742181ded4930842b46e9507372f0b1b963James Dong *pDst++ = ((*pTempSrc1++ + *pTempSrc2++ + *pTempSrc3++ + *pTempSrc4++) + 1660c1bc742181ded4930842b46e9507372f0b1b963James Dong 2 - rndVal) >> 2; 1670c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1680c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc1 += srcStep; 1690c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc2 += srcStep; 1700c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc3 += srcStep; 1710c1bc742181ded4930842b46e9507372f0b1b963James Dong pTempSrc4 += srcStep; 1720c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1730c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1740c1bc742181ded4930842b46e9507372f0b1b963James Dong 1750c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 1760c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_MCReconBlock_NoRes 1770c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1780c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 1790c1bc742181ded4930842b46e9507372f0b1b963James Dong * Do motion compensation and copy the result to the current block. 1800c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1810c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 1820c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1830c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 1840c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrc pointer to the block in the reference plane. 1850c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] srcStep distance between the start of consecutive lines 1860c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the reference plane, in bytes; must be a multiple 1870c1bc742181ded4930842b46e9507372f0b1b963James Dong * of 8. 1880c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] dstStep distance between the start of consecutive lines in the 1890c1bc742181ded4930842b46e9507372f0b1b963James Dong * destination plane, in bytes; must be a multiple of 8. 1900c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] predictType bilinear interpolation type, as defined in section 6.2.1.2. 1910c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] rndVal rounding control parameter: 0 - disabled; 1 - enabled. 1920c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst pointer to the destination buffer; must be 8-byte aligned. 1930c1bc742181ded4930842b46e9507372f0b1b963James Dong * If prediction residuals are added then output intensities 1940c1bc742181ded4930842b46e9507372f0b1b963James Dong * are clipped to the range [0,255]. 1950c1bc742181ded4930842b46e9507372f0b1b963James Dong * 1960c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 1970c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic OMXVoid armVCM4P2_MCReconBlock_NoRes( 1980c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrc, 1990c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT srcStep, 2000c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 *pDst, 2010c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT dstStep) 2020c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 2030c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 x,y,count,index; 2040c1bc742181ded4930842b46e9507372f0b1b963James Dong 2050c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Copying the ref 8x8 blk to the curr blk */ 2060c1bc742181ded4930842b46e9507372f0b1b963James Dong for (y = 0, count = 0, index = 0; y < 8; y++,index += (srcStep -8), count += (dstStep - 8)) 2070c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2080c1bc742181ded4930842b46e9507372f0b1b963James Dong for (x = 0; x < 8; x++, count++,index++) 2090c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2100c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[count] = pSrc[index]; 2110c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2120c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2130c1bc742181ded4930842b46e9507372f0b1b963James Dong} 2140c1bc742181ded4930842b46e9507372f0b1b963James Dong 2150c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 2160c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_MCReconBlock_Res 2170c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2180c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 2190c1bc742181ded4930842b46e9507372f0b1b963James Dong * Reconstructs INTER block by summing the motion compensation results 2200c1bc742181ded4930842b46e9507372f0b1b963James Dong * and the results of the inverse transformation (prediction residuals). 2210c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output intensities are clipped to the range [0,255]. 2220c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2230c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 2240c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2250c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 2260c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrc pointer to the block in the reference plane. 2270c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pSrcResidue pointer to a buffer containing the 16-bit prediction 2280c1bc742181ded4930842b46e9507372f0b1b963James Dong * residuals. If the pointer is NULL,then no prediction 2290c1bc742181ded4930842b46e9507372f0b1b963James Dong * is done, only motion compensation, i.e., the block is 2300c1bc742181ded4930842b46e9507372f0b1b963James Dong * moved with interpolation. 2310c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] dstStep distance between the start of consecutive lines in the 2320c1bc742181ded4930842b46e9507372f0b1b963James Dong * destination plane, in bytes; must be a multiple of 8. 2330c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst pointer to the destination buffer; must be 8-byte aligned. 2340c1bc742181ded4930842b46e9507372f0b1b963James Dong * If prediction residuals are added then output intensities 2350c1bc742181ded4930842b46e9507372f0b1b963James Dong * are clipped to the range [0,255]. 2360c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2370c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 2380c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic OMXVoid armVCM4P2_MCReconBlock_Res( 2390c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrc, 2400c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_S16 *pSrcResidue, 2410c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 *pDst, 2420c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT dstStep) 2430c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 2440c1bc742181ded4930842b46e9507372f0b1b963James Dong 2450c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 x,y; 2460c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT temp; 2470c1bc742181ded4930842b46e9507372f0b1b963James Dong 2480c1bc742181ded4930842b46e9507372f0b1b963James Dong for(y = 0; y < 8; y++) 2490c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2500c1bc742181ded4930842b46e9507372f0b1b963James Dong for(x = 0; x < 8; x++) 2510c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2520c1bc742181ded4930842b46e9507372f0b1b963James Dong temp = pSrc[x] + pSrcResidue[x]; 2530c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[x] = armClip(0,255,temp); 2540c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2550c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst += dstStep; 2560c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrc += 8; 2570c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcResidue += 8; 2580c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2590c1bc742181ded4930842b46e9507372f0b1b963James Dong} 2600c1bc742181ded4930842b46e9507372f0b1b963James Dong 2610c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 2620c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: omxVCM4P2_MCReconBlock (6.2.5.5.1) 2630c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2640c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 2650c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs motion compensation prediction for an 8x8 block using 2660c1bc742181ded4930842b46e9507372f0b1b963James Dong * interpolation described in [ISO14496-2], subclause 7.6.2. 2670c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2680c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments: 2690c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2700c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrc - pointer to the block in the reference plane. 2710c1bc742181ded4930842b46e9507372f0b1b963James Dong * srcStep - distance between the start of consecutive lines in the 2720c1bc742181ded4930842b46e9507372f0b1b963James Dong * reference plane, in bytes; must be a multiple of 8. 2730c1bc742181ded4930842b46e9507372f0b1b963James Dong * dstStep - distance between the start of consecutive lines in the 2740c1bc742181ded4930842b46e9507372f0b1b963James Dong * destination plane, in bytes; must be a multiple of 8. 2750c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcResidue - pointer to a buffer containing the 16-bit prediction 2760c1bc742181ded4930842b46e9507372f0b1b963James Dong * residuals; must be 16-byte aligned. If the pointer is NULL, then 2770c1bc742181ded4930842b46e9507372f0b1b963James Dong * no prediction is done, only motion compensation, i.e., the block 2780c1bc742181ded4930842b46e9507372f0b1b963James Dong * is moved with interpolation. 2790c1bc742181ded4930842b46e9507372f0b1b963James Dong * predictType - bilinear interpolation type, as defined in section 2800c1bc742181ded4930842b46e9507372f0b1b963James Dong * 6.2.1.2. 2810c1bc742181ded4930842b46e9507372f0b1b963James Dong * rndVal - rounding control parameter: 0 - disabled; 1 - enabled. 2820c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2830c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments: 2840c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2850c1bc742181ded4930842b46e9507372f0b1b963James Dong * pDst - pointer to the destination buffer; must be 8-byte aligned. If 2860c1bc742181ded4930842b46e9507372f0b1b963James Dong * prediction residuals are added then output intensities are 2870c1bc742181ded4930842b46e9507372f0b1b963James Dong * clipped to the range [0,255]. 2880c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2890c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 2900c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2910c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_NoErr - no error 2920c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_BadArgErr - bad arguments; returned under any of the following 2930c1bc742181ded4930842b46e9507372f0b1b963James Dong * conditions: 2940c1bc742181ded4930842b46e9507372f0b1b963James Dong * - pDst is not 8-byte aligned. 2950c1bc742181ded4930842b46e9507372f0b1b963James Dong * - pSrcResidue is not 16-byte aligned. 2960c1bc742181ded4930842b46e9507372f0b1b963James Dong * - one or more of the following pointers is NULL: pSrc or pDst. 2970c1bc742181ded4930842b46e9507372f0b1b963James Dong * - either srcStep or dstStep is not a multiple of 8. 2980c1bc742181ded4930842b46e9507372f0b1b963James Dong * - invalid type specified for the parameter predictType. 2990c1bc742181ded4930842b46e9507372f0b1b963James Dong * - the parameter rndVal is not equal either to 0 or 1. 3000c1bc742181ded4930842b46e9507372f0b1b963James Dong * 3010c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 3020c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P2_MCReconBlock( 3030c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrc, 3040c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT srcStep, 3050c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_S16 *pSrcResidue, 3060c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 *pDst, 3070c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT dstStep, 3080c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT predictType, 3090c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT rndVal) 3100c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 3110c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Definitions and Initializations*/ 3120c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 pTempDst[64]; 3130c1bc742181ded4930842b46e9507372f0b1b963James Dong 3140c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Argument error checks */ 3150c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr); 3160c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 3170c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(!armIs8ByteAligned(pDst), OMX_Sts_BadArgErr); 3180c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(!armIs16ByteAligned(pSrcResidue), OMX_Sts_BadArgErr); 3190c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(((dstStep % 8) || (srcStep % 8)), OMX_Sts_BadArgErr); 3200c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(((predictType != OMX_VC_INTEGER_PIXEL) && 3210c1bc742181ded4930842b46e9507372f0b1b963James Dong (predictType != OMX_VC_HALF_PIXEL_X) && 3220c1bc742181ded4930842b46e9507372f0b1b963James Dong (predictType != OMX_VC_HALF_PIXEL_Y) && 3230c1bc742181ded4930842b46e9507372f0b1b963James Dong (predictType != OMX_VC_HALF_PIXEL_XY) 3240c1bc742181ded4930842b46e9507372f0b1b963James Dong ),OMX_Sts_BadArgErr); 3250c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(((rndVal != 0) && (rndVal != 1)),OMX_Sts_BadArgErr); 3260c1bc742181ded4930842b46e9507372f0b1b963James Dong 3270c1bc742181ded4930842b46e9507372f0b1b963James Dong switch(predictType) 3280c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3290c1bc742181ded4930842b46e9507372f0b1b963James Dong case OMX_VC_INTEGER_PIXEL: 3300c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_MCReconBlock_NoRes(pSrc, 3310c1bc742181ded4930842b46e9507372f0b1b963James Dong srcStep, 3320c1bc742181ded4930842b46e9507372f0b1b963James Dong &(pTempDst[0]), 3330c1bc742181ded4930842b46e9507372f0b1b963James Dong 8); 3340c1bc742181ded4930842b46e9507372f0b1b963James Dong break; 3350c1bc742181ded4930842b46e9507372f0b1b963James Dong case OMX_VC_HALF_PIXEL_X: 3360c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_HalfPelHor(pSrc, 3370c1bc742181ded4930842b46e9507372f0b1b963James Dong srcStep, 3380c1bc742181ded4930842b46e9507372f0b1b963James Dong &(pTempDst[0]), 3390c1bc742181ded4930842b46e9507372f0b1b963James Dong rndVal); 3400c1bc742181ded4930842b46e9507372f0b1b963James Dong break; 3410c1bc742181ded4930842b46e9507372f0b1b963James Dong case OMX_VC_HALF_PIXEL_Y: 3420c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_HalfPelVer(pSrc, 3430c1bc742181ded4930842b46e9507372f0b1b963James Dong srcStep, 3440c1bc742181ded4930842b46e9507372f0b1b963James Dong &(pTempDst[0]), 3450c1bc742181ded4930842b46e9507372f0b1b963James Dong rndVal); 3460c1bc742181ded4930842b46e9507372f0b1b963James Dong break; 3470c1bc742181ded4930842b46e9507372f0b1b963James Dong case OMX_VC_HALF_PIXEL_XY: 3480c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_HalfPelVerHor(pSrc, 3490c1bc742181ded4930842b46e9507372f0b1b963James Dong srcStep, 3500c1bc742181ded4930842b46e9507372f0b1b963James Dong &(pTempDst[0]), 3510c1bc742181ded4930842b46e9507372f0b1b963James Dong rndVal); 3520c1bc742181ded4930842b46e9507372f0b1b963James Dong break; 3530c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3540c1bc742181ded4930842b46e9507372f0b1b963James Dong 3550c1bc742181ded4930842b46e9507372f0b1b963James Dong if(pSrcResidue == NULL) 3560c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3570c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_MCReconBlock_NoRes(&(pTempDst[0]), 3580c1bc742181ded4930842b46e9507372f0b1b963James Dong 8, 3590c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst, 3600c1bc742181ded4930842b46e9507372f0b1b963James Dong dstStep); 3610c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3620c1bc742181ded4930842b46e9507372f0b1b963James Dong else 3630c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3640c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_MCReconBlock_Res(&(pTempDst[0]), 3650c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcResidue, 3660c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst, 3670c1bc742181ded4930842b46e9507372f0b1b963James Dong dstStep); 3680c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3690c1bc742181ded4930842b46e9507372f0b1b963James Dong 3700c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_NoErr; 3710c1bc742181ded4930842b46e9507372f0b1b963James Dong} 3720c1bc742181ded4930842b46e9507372f0b1b963James Dong 373