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_BlockMatch_Half_8x8.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 *
270c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * Contains modules for Block matching, a full search algorithm
290c1bc742181ded4930842b46e9507372f0b1b963James Dong * is implemented
300c1bc742181ded4930842b46e9507372f0b1b963James Dong *
310c1bc742181ded4930842b46e9507372f0b1b963James Dong */
320c1bc742181ded4930842b46e9507372f0b1b963James Dong
330c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h"
340c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h"
350c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h"
360c1bc742181ded4930842b46e9507372f0b1b963James Dong
370c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h"
380c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h"
390c1bc742181ded4930842b46e9507372f0b1b963James Dong
400c1bc742181ded4930842b46e9507372f0b1b963James Dong
410c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
420c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCM4P2_BlockMatch_Half_8x8   (6.2.4.2.4)
430c1bc742181ded4930842b46e9507372f0b1b963James Dong *
440c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
450c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs an 8x8 block match with half-pixel resolution. Returns the
460c1bc742181ded4930842b46e9507372f0b1b963James Dong * estimated motion vector and associated minimum SAD.  This function
470c1bc742181ded4930842b46e9507372f0b1b963James Dong * estimates the half-pixel motion vector by interpolating the integer
480c1bc742181ded4930842b46e9507372f0b1b963James Dong * resolution motion vector referenced by the input parameter pSrcDstMV, i.e.,
490c1bc742181ded4930842b46e9507372f0b1b963James Dong * the initial integer MV is generated externally.  The input parameters
500c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcRefBuf and pSearchPointRefPos should be shifted by the winning MV of
510c1bc742181ded4930842b46e9507372f0b1b963James Dong * 8x8 integer search prior to calling BlockMatch_Half_8x8. The function
520c1bc742181ded4930842b46e9507372f0b1b963James Dong * BlockMatch_Integer_8x8 may be used for integer motion estimation.
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *
540c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *
560c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcRefBuf - pointer to the reference Y plane; points to the reference
570c1bc742181ded4930842b46e9507372f0b1b963James Dong *            block that corresponds to the location of the current 8x8 block
580c1bc742181ded4930842b46e9507372f0b1b963James Dong *            in the current plane.
590c1bc742181ded4930842b46e9507372f0b1b963James Dong *   refWidth - width of the reference plane
600c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pRefRect - reference plane valid region rectangle
610c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcCurrBuf - pointer to the current block in the current macroblock
620c1bc742181ded4930842b46e9507372f0b1b963James Dong *            buffer extracted from the original plane (linear array, 128
630c1bc742181ded4930842b46e9507372f0b1b963James Dong *            entries); must be aligned on a 8-byte boundary.  The number of
640c1bc742181ded4930842b46e9507372f0b1b963James Dong *            bytes between lines (step) is 16.
650c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSearchPointRefPos - position of the starting point for half pixel
660c1bc742181ded4930842b46e9507372f0b1b963James Dong *            search (specified in terms of integer pixel units) in the
670c1bc742181ded4930842b46e9507372f0b1b963James Dong *            reference plane.
680c1bc742181ded4930842b46e9507372f0b1b963James Dong *   rndVal - rounding control parameter: 0 - disabled; 1 - enabled.
690c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcDstMV - pointer to the initial MV estimate; typically generated
700c1bc742181ded4930842b46e9507372f0b1b963James Dong *            during a prior 8x8 integer search, specified in terms of
710c1bc742181ded4930842b46e9507372f0b1b963James Dong *            half-pixel units.
720c1bc742181ded4930842b46e9507372f0b1b963James Dong *
730c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
740c1bc742181ded4930842b46e9507372f0b1b963James Dong *
750c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcDstMV - pointer to estimated MV
760c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDstSAD - pointer to minimum SAD
770c1bc742181ded4930842b46e9507372f0b1b963James Dong *
780c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
790c1bc742181ded4930842b46e9507372f0b1b963James Dong *
800c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
810c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments.  Returned if one of the following
820c1bc742181ded4930842b46e9507372f0b1b963James Dong *              conditions is true:
830c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    at least one of the following pointers is NULL:
840c1bc742181ded4930842b46e9507372f0b1b963James Dong *         pSrcRefBuf, pRefRect, pSrcCurrBuff, pSearchPointRefPos, pSrcDstMV
850c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    pSrcCurrBuf is not 8-byte aligned
860c1bc742181ded4930842b46e9507372f0b1b963James Dong *
870c1bc742181ded4930842b46e9507372f0b1b963James Dong */
880c1bc742181ded4930842b46e9507372f0b1b963James Dong
890c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P2_BlockMatch_Half_8x8(
900c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcRefBuf,
910c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT refWidth,
920c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMXRect *pRefRect,
930c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcCurrBuf,
940c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMXVCM4P2Coordinate *pSearchPointRefPos,
950c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT rndVal,
960c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCMotionVector *pSrcDstMV,
970c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT *pDstSAD
980c1bc742181ded4930842b46e9507372f0b1b963James Dong)
990c1bc742181ded4930842b46e9507372f0b1b963James Dong{
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* For a blocksize of 8x8 */
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8 BlockSize = 8;
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Argument error checks */
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSrcRefBuf         == NULL, OMX_Sts_BadArgErr);
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pRefRect           == NULL, OMX_Sts_BadArgErr);
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSrcCurrBuf        == NULL, OMX_Sts_BadArgErr);
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSearchPointRefPos == NULL, OMX_Sts_BadArgErr);
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSrcDstMV          == NULL, OMX_Sts_BadArgErr);
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(!armIs8ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong    return (armVCM4P2_BlockMatch_Half(
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong                                pSrcRefBuf,
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong                                refWidth,
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong                                pRefRect,
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong                                pSrcCurrBuf,
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong                                pSearchPointRefPos,
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong                                rndVal,
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong                                pSrcDstMV,
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong                                pDstSAD,
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong                                BlockSize));
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong}
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong
1240c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */
125