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_DecodePadMV_PVOP.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 module for decoding MV and padding the same
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_Bitstream.h"
370c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h"
380c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVCM4P2_Huff_Tables_VLC.h"
390c1bc742181ded4930842b46e9507372f0b1b963James Dong
400c1bc742181ded4930842b46e9507372f0b1b963James Dong
410c1bc742181ded4930842b46e9507372f0b1b963James Dong
420c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
430c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCM4P2_DecodePadMV_PVOP   (6.2.5.1.1)
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *
450c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
460c1bc742181ded4930842b46e9507372f0b1b963James Dong * Decodes and pads the four motion vectors associated with a non-intra P-VOP
470c1bc742181ded4930842b46e9507372f0b1b963James Dong * macroblock.  For macroblocks of type OMX_VC_INTER4V, the output MV is
480c1bc742181ded4930842b46e9507372f0b1b963James Dong * padded as specified in [ISO14496-2], subclause 7.6.1.6. Otherwise, for
490c1bc742181ded4930842b46e9507372f0b1b963James Dong * macroblocks of types other than OMX_VC_INTER4V, the decoded MV is copied to
500c1bc742181ded4930842b46e9507372f0b1b963James Dong * all four output MV buffer entries.
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *
520c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *   ppBitStream - pointer to the pointer to the current byte in the bit
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *            stream buffer
560c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pBitOffset - pointer to the bit position in the byte pointed to by
570c1bc742181ded4930842b46e9507372f0b1b963James Dong *            *ppBitStream. *pBitOffset is valid within [0-7].
580c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcMVLeftMB, pSrcMVUpperMB, and pSrcMVUpperRightMB - pointers to the
590c1bc742181ded4930842b46e9507372f0b1b963James Dong *            motion vector buffers of the macroblocks specially at the left,
600c1bc742181ded4930842b46e9507372f0b1b963James Dong *            upper, and upper-right side of the current macroblock,
610c1bc742181ded4930842b46e9507372f0b1b963James Dong *            respectively; a value of NULL indicates unavailability.  Note:
620c1bc742181ded4930842b46e9507372f0b1b963James Dong *            Any neighborhood macroblock outside the current VOP or video
630c1bc742181ded4930842b46e9507372f0b1b963James Dong *            packet or outside the current GOB (when short_video_header is
640c1bc742181ded4930842b46e9507372f0b1b963James Dong *             1 ) for which gob_header_empty is  0  is treated as
650c1bc742181ded4930842b46e9507372f0b1b963James Dong *            transparent, according to [ISO14496-2], subclause 7.6.5.
660c1bc742181ded4930842b46e9507372f0b1b963James Dong *   fcodeForward - a code equal to vop_fcode_forward in MPEG-4 bit stream
670c1bc742181ded4930842b46e9507372f0b1b963James Dong *            syntax
680c1bc742181ded4930842b46e9507372f0b1b963James Dong *   MBType - the type of the current macroblock. If MBType is not equal to
690c1bc742181ded4930842b46e9507372f0b1b963James Dong *            OMX_VC_INTER4V, the destination motion vector buffer is still
700c1bc742181ded4930842b46e9507372f0b1b963James Dong *            filled with the same decoded vector.
710c1bc742181ded4930842b46e9507372f0b1b963James Dong *
720c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
730c1bc742181ded4930842b46e9507372f0b1b963James Dong *
740c1bc742181ded4930842b46e9507372f0b1b963James Dong *   ppBitStream - *ppBitStream is updated after the block is decoded, so
750c1bc742181ded4930842b46e9507372f0b1b963James Dong *            that it points to the current byte in the bit stream buffer
760c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pBitOffset - *pBitOffset is updated so that it points to the current bit
770c1bc742181ded4930842b46e9507372f0b1b963James Dong *            position in the byte pointed by *ppBitStream
780c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDstMVCurMB - pointer to the motion vector buffer for the current
790c1bc742181ded4930842b46e9507372f0b1b963James Dong *            macroblock; contains four decoded motion vectors
800c1bc742181ded4930842b46e9507372f0b1b963James Dong *
810c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
820c1bc742181ded4930842b46e9507372f0b1b963James Dong *
830c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
840c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments:
850c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    At least one of the following pointers is NULL:
860c1bc742181ded4930842b46e9507372f0b1b963James Dong *         ppBitStream, *ppBitStream, pBitOffset, pDstMVCurMB
870c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    *pBitOffset exceeds [0,7]
880c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    fcodeForward exceeds (0,7]
890c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    MBType less than zero
900c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    motion vector buffer is not 4-byte aligned.
910c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_Err - status error
920c1bc742181ded4930842b46e9507372f0b1b963James Dong *
930c1bc742181ded4930842b46e9507372f0b1b963James Dong */
940c1bc742181ded4930842b46e9507372f0b1b963James Dong
950c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P2_DecodePadMV_PVOP(
960c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 ** ppBitStream,
970c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT * pBitOffset,
980c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCMotionVector * pSrcMVLeftMB,
990c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCMotionVector *pSrcMVUpperMB,
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCMotionVector * pSrcMVUpperRightMB,
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCMotionVector * pDstMVCurMB,
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT fcodeForward,
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCM4P2MacroblockType MBType
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong )
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong{
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMXVCMotionVector diffMV;
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMXVCMotionVector dstMVPredME[12];
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_INT iBlk, i, count = 1;
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_S32 mvHorResidual = 1, mvVerResidual = 1, mvHorData, mvVerData;
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_S8 scaleFactor, index;
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_S16 high, low, range;
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Argument error checks */
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pDstMVCurMB == NULL, OMX_Sts_BadArgErr);
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(((*pBitOffset < 0) || (*pBitOffset > 7)), OMX_Sts_BadArgErr);
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(((fcodeForward < 1) || (fcodeForward > 7)), \
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong                    OMX_Sts_BadArgErr);
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(!armIs4ByteAligned(pDstMVCurMB), OMX_Sts_BadArgErr);
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong
1240c1bc742181ded4930842b46e9507372f0b1b963James Dong    if ((MBType == OMX_VC_INTRA) ||
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong        (MBType == OMX_VC_INTRA_Q)
1260c1bc742181ded4930842b46e9507372f0b1b963James Dong       )
1270c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong        /* All MV's are zero */
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong        for (i = 0; i < 4; i++)
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1310c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDstMVCurMB[i].dx = 0;
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDstMVCurMB[i].dy = 0;
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong        return OMX_Sts_NoErr;
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong    if ((MBType == OMX_VC_INTER4V) || (MBType == OMX_VC_INTER4V_Q))
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong        count = 4;
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong    else if ((MBType == OMX_VC_INTER) || (MBType == OMX_VC_INTER_Q))
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong        count = 1;
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Calculating the scale factor */
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong    scaleFactor = 1 << (fcodeForward -1);
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong    high =  ( 32 * scaleFactor) - 1;
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong    low =   ( (-32) * scaleFactor);
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong    range = ( 64 * scaleFactor);
1520c1bc742181ded4930842b46e9507372f0b1b963James Dong
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Huffman decoding and MV reconstruction */
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong    for (iBlk = 0; iBlk < count; iBlk++)
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong        /* Huffman decoding to get Horizontal data and residual */
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong        index = armUnPackVLC32(ppBitStream, pBitOffset,
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong                                            armVCM4P2_aVlcMVD);
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong        armRetDataErrIf(index == -1, OMX_Sts_Err);
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong        mvHorData = index - 32;
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong        if ((fcodeForward > 1) && (mvHorData != 0))
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong            mvHorResidual = (OMX_S32) armGetBits(ppBitStream,
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong                                            pBitOffset, (fcodeForward -1));
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong        /* Huffman decoding to get Vertical data and residual */
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong        index = armUnPackVLC32(ppBitStream, pBitOffset, armVCM4P2_aVlcMVD);
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong        armRetDataErrIf(index == -1, OMX_Sts_Err);
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong        mvVerData = index - 32;
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong        if ((fcodeForward > 1) && (mvVerData != 0))
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong            mvVerResidual = (OMX_S32) armGetBits(ppBitStream,
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong                                            pBitOffset, (fcodeForward -1));
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong        /* Calculating the differtial MV */
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong        if ( (scaleFactor == 1) || (mvHorData == 0) )
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong            diffMV.dx = mvHorData;
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong        else
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong            diffMV.dx = ((armAbs(mvHorData) - 1) * fcodeForward)
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong                         + mvHorResidual + 1;
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong            if (mvHorData < 0)
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong            {
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong                diffMV.dx = -diffMV.dx;
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong            }
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong        if ( (scaleFactor == 1) || (mvVerData == 0) )
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong            diffMV.dy = mvVerData;
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong        else
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2030c1bc742181ded4930842b46e9507372f0b1b963James Dong            diffMV.dy = ((armAbs(mvVerData) - 1) * fcodeForward)
2040c1bc742181ded4930842b46e9507372f0b1b963James Dong                         + mvVerResidual + 1;
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong            if (mvVerData < 0)
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong            {
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong                diffMV.dy = -diffMV.dy;
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong            }
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong        /* Find the predicted vector */
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong        omxVCM4P2_FindMVpred (
2130c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDstMVCurMB,
2140c1bc742181ded4930842b46e9507372f0b1b963James Dong            pSrcMVLeftMB,
2150c1bc742181ded4930842b46e9507372f0b1b963James Dong            pSrcMVUpperMB,
2160c1bc742181ded4930842b46e9507372f0b1b963James Dong            pSrcMVUpperRightMB,
2170c1bc742181ded4930842b46e9507372f0b1b963James Dong            &pDstMVCurMB[iBlk],
2180c1bc742181ded4930842b46e9507372f0b1b963James Dong            dstMVPredME,
2190c1bc742181ded4930842b46e9507372f0b1b963James Dong            iBlk);
2200c1bc742181ded4930842b46e9507372f0b1b963James Dong
2210c1bc742181ded4930842b46e9507372f0b1b963James Dong        /* Adding the difference to the predicted MV to reconstruct MV */
2220c1bc742181ded4930842b46e9507372f0b1b963James Dong        pDstMVCurMB[iBlk].dx += diffMV.dx;
2230c1bc742181ded4930842b46e9507372f0b1b963James Dong        pDstMVCurMB[iBlk].dy += diffMV.dy;
2240c1bc742181ded4930842b46e9507372f0b1b963James Dong
2250c1bc742181ded4930842b46e9507372f0b1b963James Dong        /* Checking the range and keeping it within the limits */
2260c1bc742181ded4930842b46e9507372f0b1b963James Dong        if ( pDstMVCurMB[iBlk].dx < low )
2270c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2280c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDstMVCurMB[iBlk].dx += range;
2290c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2300c1bc742181ded4930842b46e9507372f0b1b963James Dong        if (pDstMVCurMB[iBlk].dx > high)
2310c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2320c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDstMVCurMB[iBlk].dx -= range;
2330c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2340c1bc742181ded4930842b46e9507372f0b1b963James Dong
2350c1bc742181ded4930842b46e9507372f0b1b963James Dong        if ( pDstMVCurMB[iBlk].dy < low )
2360c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2370c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDstMVCurMB[iBlk].dy += range;
2380c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2390c1bc742181ded4930842b46e9507372f0b1b963James Dong        if (pDstMVCurMB[iBlk].dy > high)
2400c1bc742181ded4930842b46e9507372f0b1b963James Dong        {
2410c1bc742181ded4930842b46e9507372f0b1b963James Dong            pDstMVCurMB[iBlk].dy -= range;
2420c1bc742181ded4930842b46e9507372f0b1b963James Dong        }
2430c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
2440c1bc742181ded4930842b46e9507372f0b1b963James Dong
2450c1bc742181ded4930842b46e9507372f0b1b963James Dong    if ((MBType == OMX_VC_INTER) || (MBType == OMX_VC_INTER_Q))
2460c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
2470c1bc742181ded4930842b46e9507372f0b1b963James Dong        pDstMVCurMB[1] = pDstMVCurMB[0];
2480c1bc742181ded4930842b46e9507372f0b1b963James Dong        pDstMVCurMB[2] = pDstMVCurMB[0];
2490c1bc742181ded4930842b46e9507372f0b1b963James Dong        pDstMVCurMB[3] = pDstMVCurMB[0];
2500c1bc742181ded4930842b46e9507372f0b1b963James Dong    }
2510c1bc742181ded4930842b46e9507372f0b1b963James Dong
2520c1bc742181ded4930842b46e9507372f0b1b963James Dong    return OMX_Sts_NoErr;
2530c1bc742181ded4930842b46e9507372f0b1b963James Dong}
2540c1bc742181ded4930842b46e9507372f0b1b963James Dong
2550c1bc742181ded4930842b46e9507372f0b1b963James Dong
2560c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */
2570c1bc742181ded4930842b46e9507372f0b1b963James Dong
2580c1bc742181ded4930842b46e9507372f0b1b963James Dong
259