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 *
200c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCM4P10_PredictIntraChroma_8x8.c
210c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2
220c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision:   9641
230c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date:       Thursday, February 7, 2008
240c1bc742181ded4930842b46e9507372f0b1b963James Dong *
250c1bc742181ded4930842b46e9507372f0b1b963James Dong *
260c1bc742181ded4930842b46e9507372f0b1b963James Dong *
270c1bc742181ded4930842b46e9507372f0b1b963James Dong *
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * H.264 Chroma 8x8 intra prediction module
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#include "armVC.h"
380c1bc742181ded4930842b46e9507372f0b1b963James Dong
390c1bc742181ded4930842b46e9507372f0b1b963James Dong/*
400c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
410c1bc742181ded4930842b46e9507372f0b1b963James Dong * Perform DC style intra prediction, upper block has priority
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *
430c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
440c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	pSrcLeft		Pointer to the buffer of 16 left coefficients:
450c1bc742181ded4930842b46e9507372f0b1b963James Dong *								p[x, y] (x = -1, y = 0..3)
460c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	pSrcAbove		Pointer to the buffer of 16 above coefficients:
470c1bc742181ded4930842b46e9507372f0b1b963James Dong *								p[x,y] (x = 0..3, y = -1)
480c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	leftStep		Step of left coefficient buffer
490c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	dstStep			Step of the destination buffer
500c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	availability	Neighboring 16x16 MB availability flag
510c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]	pDst			Pointer to the destination buffer
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *
530c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
540c1bc742181ded4930842b46e9507372f0b1b963James Dong * None
550c1bc742181ded4930842b46e9507372f0b1b963James Dong */
560c1bc742181ded4930842b46e9507372f0b1b963James Dong
570c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic void armVCM4P10_PredictIntraDCUp4x4(
580c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8* pSrcLeft,
590c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcAbove,
600c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U8* pDst,
610c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT leftStep,
620c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT dstStep,
630c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_S32 availability
640c1bc742181ded4930842b46e9507372f0b1b963James Dong)
650c1bc742181ded4930842b46e9507372f0b1b963James Dong{
660c1bc742181ded4930842b46e9507372f0b1b963James Dong    int x, y, Sum=0, Count = 0;
670c1bc742181ded4930842b46e9507372f0b1b963James Dong
680c1bc742181ded4930842b46e9507372f0b1b963James Dong    if (availability & OMX_VC_UPPER)
690c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
700c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (x=0; x<4; x++)
710c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
720c1bc742181ded4930842b46e9507372f0b1b963James Dong            Sum += pSrcAbove[x];
730c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
740c1bc742181ded4930842b46e9507372f0b1b963James Dong        Count++;
750c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
760c1bc742181ded4930842b46e9507372f0b1b963James Dong    else if (availability & OMX_VC_LEFT)
770c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
780c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (y=0; y<4; y++)
790c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
800c1bc742181ded4930842b46e9507372f0b1b963James Dong            Sum += pSrcLeft[y*leftStep];
810c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
820c1bc742181ded4930842b46e9507372f0b1b963James Dong        Count++;
830c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
840c1bc742181ded4930842b46e9507372f0b1b963James Dong    if (Count==0)
850c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
860c1bc742181ded4930842b46e9507372f0b1b963James Dong        Sum = 128;
870c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
880c1bc742181ded4930842b46e9507372f0b1b963James Dong    else
890c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
900c1bc742181ded4930842b46e9507372f0b1b963James Dong        Sum = (Sum + 2) >> 2;
910c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
920c1bc742181ded4930842b46e9507372f0b1b963James Dong    for (y=0; y<4; y++)
930c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
940c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (x=0; x<4; x++)
950c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
960c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDst[y*dstStep+x] = (OMX_U8)Sum;
970c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
980c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
990c1bc742181ded4930842b46e9507372f0b1b963James Dong}
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong/*
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong * Perform DC style intra prediction, left block has priority
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters:
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	pSrcLeft		Pointer to the buffer of 16 left coefficients:
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong *								p[x, y] (x = -1, y = 0..3)
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	pSrcAbove		Pointer to the buffer of 16 above coefficients:
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong *								p[x,y] (x = 0..3, y = -1)
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	leftStep		Step of left coefficient buffer
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	dstStep			Step of the destination buffer
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in]	availability	Neighboring 16x16 MB availability flag
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out]	pDst			Pointer to the destination buffer
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong * None
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong */
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong
1190c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic void armVCM4P10_PredictIntraDCLeft4x4(
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8* pSrcLeft,
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcAbove,
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U8* pDst,
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT leftStep,
1240c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT dstStep,
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_S32 availability
1260c1bc742181ded4930842b46e9507372f0b1b963James Dong)
1270c1bc742181ded4930842b46e9507372f0b1b963James Dong{
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong    int x, y, Sum=0, Count = 0;
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong    if (availability & OMX_VC_LEFT)
1310c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (y=0; y<4; y++)
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong            Sum += pSrcLeft[y*leftStep];
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong        Count++;
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong    else if (availability & OMX_VC_UPPER)
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (x=0; x<4; x++)
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong            Sum += pSrcAbove[x];
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong        Count++;
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong    if (Count==0)
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong        Sum = 128;
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong    else
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1520c1bc742181ded4930842b46e9507372f0b1b963James Dong        Sum = (Sum + 2) >> 2;
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong    for (y=0; y<4; y++)
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (x=0; x<4; x++)
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDst[y*dstStep+x] = (OMX_U8)Sum;
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong}
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCM4P10_PredictIntraChroma_8x8   (6.3.3.1.3)
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs intra prediction for chroma samples.
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcLeft - Pointer to the buffer of 8 left pixels: p[x, y] (x = -1, y=
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong *            0..7).
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcAbove - Pointer to the buffer of 8 above pixels: p[x,y] (x = 0..7, y
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong *            = -1); must be aligned on an 8-byte boundary.
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcAboveLeft - Pointer to the above left pixels: p[x,y] (x = -1, y = -1)
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong *   leftStep - Step of left pixel buffer; must be a multiple of 8.
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong *   dstStep - Step of the destination buffer; must be a multiple of 8.
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong *   predMode - Intra chroma prediction mode, please refer to section 3.4.3.
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong *   availability - Neighboring chroma block availability flag, please refer
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong *            to  "Neighboring Macroblock Availability".
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDst - Pointer to the destination buffer; must be aligned on an 8-byte
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong *            boundary.
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong *
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong *    If the function runs without error, it returns OMX_Sts_NoErr.
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong *    If any of the following cases occurs, the function returns
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong *              OMX_Sts_BadArgErr:
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong *    pDst is NULL.
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong *    dstStep < 8 or dstStep is not a multiple of 8.
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong *    leftStep is not a multiple of 8.
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong *    predMode is not in the valid range of enumeration
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong *              OMXVCM4P10IntraChromaPredMode.
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong *    predMode is OMX_VC_CHROMA_VERT, but availability doesn't set
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong *              OMX_VC_UPPER indicating p[x,-1] (x = 0..7) is not available.
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong *    predMode is OMX_VC_CHROMA_HOR, but availability doesn't set OMX_VC_LEFT
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong *              indicating p[-1,y] (y = 0..7) is not available.
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong *    predMode is OMX_VC_CHROMA_PLANE, but availability doesn't set
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong *              OMX_VC_UPPER_LEFT or OMX_VC_UPPER or OMX_VC_LEFT indicating
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong *              p[x,-1](x = 0..7), or p[-1,y] (y = 0..7), or p[-1,-1] is not
2030c1bc742181ded4930842b46e9507372f0b1b963James Dong *              available.
2040c1bc742181ded4930842b46e9507372f0b1b963James Dong *    availability sets OMX_VC_UPPER, but pSrcAbove is NULL.
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong *    availability sets OMX_VC_LEFT, but pSrcLeft is NULL.
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong *    availability sets OMX_VC_UPPER_LEFT, but pSrcAboveLeft is NULL.
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong *    either pSrcAbove or pDst is not aligned on a 8-byte boundary.  Note:
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong *              pSrcAbove, pSrcAbove, pSrcAboveLeft may be invalid pointer if
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong *              they are not used by intra prediction implied in predMode.
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong *               Note: OMX_VC_UPPER_RIGHT is not used in intra chroma
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong *              prediction.
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong *
2130c1bc742181ded4930842b46e9507372f0b1b963James Dong */
2140c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P10_PredictIntraChroma_8x8(
2150c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8* pSrcLeft,
2160c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcAbove,
2170c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcAboveLeft,
2180c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U8* pDst,
2190c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT leftStep,
2200c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT dstStep,
2210c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCM4P10IntraChromaPredMode predMode,
2220c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_S32 availability
2230c1bc742181ded4930842b46e9507372f0b1b963James Dong )
2240c1bc742181ded4930842b46e9507372f0b1b963James Dong{
2250c1bc742181ded4930842b46e9507372f0b1b963James Dong    int x, y, Sum;
2260c1bc742181ded4930842b46e9507372f0b1b963James Dong    int H, V, a, b, c;
2270c1bc742181ded4930842b46e9507372f0b1b963James Dong
2280c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
2290c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(dstStep < 8,  OMX_Sts_BadArgErr);
2300c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((dstStep % 8) != 0,  OMX_Sts_BadArgErr);
2310c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((leftStep % 8) != 0,  OMX_Sts_BadArgErr);
2320c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(armNot8ByteAligned(pSrcAbove), OMX_Sts_BadArgErr);
2330c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(armNot8ByteAligned(pDst), OMX_Sts_BadArgErr);
2340c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((availability & OMX_VC_UPPER)      && pSrcAbove     == NULL, OMX_Sts_BadArgErr);
2350c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((availability & OMX_VC_LEFT )      && pSrcLeft      == NULL, OMX_Sts_BadArgErr);
2360c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((availability & OMX_VC_UPPER_LEFT) && pSrcAboveLeft == NULL, OMX_Sts_BadArgErr);
2370c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(predMode==OMX_VC_CHROMA_VERT  && !(availability & OMX_VC_UPPER),      OMX_Sts_BadArgErr);
2380c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(predMode==OMX_VC_CHROMA_HOR   && !(availability & OMX_VC_LEFT),       OMX_Sts_BadArgErr);
2390c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(predMode==OMX_VC_CHROMA_PLANE && !(availability & OMX_VC_UPPER),      OMX_Sts_BadArgErr);
2400c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(predMode==OMX_VC_CHROMA_PLANE && !(availability & OMX_VC_UPPER_LEFT), OMX_Sts_BadArgErr);
2410c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(predMode==OMX_VC_CHROMA_PLANE && !(availability & OMX_VC_LEFT),       OMX_Sts_BadArgErr);
2420c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((unsigned)predMode > OMX_VC_CHROMA_PLANE,   OMX_Sts_BadArgErr);
2430c1bc742181ded4930842b46e9507372f0b1b963James Dong
2440c1bc742181ded4930842b46e9507372f0b1b963James Dong    switch (predMode)
2450c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
2460c1bc742181ded4930842b46e9507372f0b1b963James Dong    case OMX_VC_CHROMA_DC:
2470c1bc742181ded4930842b46e9507372f0b1b963James Dong        armVCM4P10_PredictIntraDC4x4(       pSrcLeft,            pSrcAbove,   pDst,             leftStep, dstStep, availability);
2480c1bc742181ded4930842b46e9507372f0b1b963James Dong        armVCM4P10_PredictIntraDCUp4x4(     pSrcLeft,            pSrcAbove+4, pDst+4,           leftStep, dstStep, availability);
2490c1bc742181ded4930842b46e9507372f0b1b963James Dong        armVCM4P10_PredictIntraDCLeft4x4(   pSrcLeft+4*leftStep, pSrcAbove,   pDst+4*dstStep,   leftStep, dstStep, availability);
2500c1bc742181ded4930842b46e9507372f0b1b963James Dong        armVCM4P10_PredictIntraDC4x4(       pSrcLeft+4*leftStep, pSrcAbove+4, pDst+4+4*dstStep, leftStep, dstStep, availability);
2510c1bc742181ded4930842b46e9507372f0b1b963James Dong        break;
2520c1bc742181ded4930842b46e9507372f0b1b963James Dong
2530c1bc742181ded4930842b46e9507372f0b1b963James Dong    case OMX_VC_CHROMA_HOR:
2540c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (y=0; y<8; y++)
2550c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2560c1bc742181ded4930842b46e9507372f0b1b963James Dong            for (x=0; x<8; x++)
2570c1bc742181ded4930842b46e9507372f0b1b963James Dong            {
2580c1bc742181ded4930842b46e9507372f0b1b963James Dong                pDst[y*dstStep+x] = pSrcLeft[y*leftStep];
2590c1bc742181ded4930842b46e9507372f0b1b963James Dong            }
2600c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2610c1bc742181ded4930842b46e9507372f0b1b963James Dong        break;
2620c1bc742181ded4930842b46e9507372f0b1b963James Dong
2630c1bc742181ded4930842b46e9507372f0b1b963James Dong    case OMX_VC_CHROMA_VERT:
2640c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (y=0; y<8; y++)
2650c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2660c1bc742181ded4930842b46e9507372f0b1b963James Dong            for (x=0; x<8; x++)
2670c1bc742181ded4930842b46e9507372f0b1b963James Dong            {
2680c1bc742181ded4930842b46e9507372f0b1b963James Dong                pDst[y*dstStep+x] = pSrcAbove[x];
2690c1bc742181ded4930842b46e9507372f0b1b963James Dong            }
2700c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2710c1bc742181ded4930842b46e9507372f0b1b963James Dong        break;
2720c1bc742181ded4930842b46e9507372f0b1b963James Dong
2730c1bc742181ded4930842b46e9507372f0b1b963James Dong    case OMX_VC_CHROMA_PLANE:
2740c1bc742181ded4930842b46e9507372f0b1b963James Dong        H = 4*(pSrcAbove[7] - pSrcAboveLeft[0]);
2750c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (x=2; x>=0; x--)
2760c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2770c1bc742181ded4930842b46e9507372f0b1b963James Dong            H += (x+1)*(pSrcAbove[4+x] - pSrcAbove[2-x]);
2780c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2790c1bc742181ded4930842b46e9507372f0b1b963James Dong        V = 4*(pSrcLeft[7*leftStep] - pSrcAboveLeft[0]);
2800c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (y=2; y>=0; y--)
2810c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2820c1bc742181ded4930842b46e9507372f0b1b963James Dong            V += (y+1)*(pSrcLeft[(4+y)*leftStep] - pSrcLeft[(2-y)*leftStep]);
2830c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2840c1bc742181ded4930842b46e9507372f0b1b963James Dong        a = 16*(pSrcAbove[7] + pSrcLeft[7*leftStep]);
2850c1bc742181ded4930842b46e9507372f0b1b963James Dong        b = (17*H+16)>>5;
2860c1bc742181ded4930842b46e9507372f0b1b963James Dong        c = (17*V+16)>>5;
2870c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (y=0; y<8; y++)
2880c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2890c1bc742181ded4930842b46e9507372f0b1b963James Dong            for (x=0; x<8; x++)
2900c1bc742181ded4930842b46e9507372f0b1b963James Dong            {
2910c1bc742181ded4930842b46e9507372f0b1b963James Dong                Sum = (a + b*(x-3) + c*(y-3) + 16)>>5;
2920c1bc742181ded4930842b46e9507372f0b1b963James Dong                pDst[y*dstStep+x] = (OMX_U8)armClip(0,255,Sum);
2930c1bc742181ded4930842b46e9507372f0b1b963James Dong            }
2940c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2950c1bc742181ded4930842b46e9507372f0b1b963James Dong        break;
2960c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
2970c1bc742181ded4930842b46e9507372f0b1b963James Dong
2980c1bc742181ded4930842b46e9507372f0b1b963James Dong    return OMX_Sts_NoErr;
2990c1bc742181ded4930842b46e9507372f0b1b963James Dong}
300