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;//
160c1bc742181ded4930842b46e9507372f0b1b963James Dong; **********
170c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
180c1bc742181ded4930842b46e9507372f0b1b963James Dong; * File Name:  omxVCM4P2_DecodePadMV_PVOP_s.s
190c1bc742181ded4930842b46e9507372f0b1b963James Dong; * OpenMAX DL: v1.0.2
200c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Revision:   12290
210c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Date:       Wednesday, April 9, 2008
220c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
230c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
240c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
250c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
260c1bc742181ded4930842b46e9507372f0b1b963James Dong; **
270c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Function: omxVCM4P2_DecodePadMV_PVOP
280c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
290c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Description:
300c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Decodes and pads four motion vectors of the non-intra macroblock in P-VOP.
310c1bc742181ded4930842b46e9507372f0b1b963James Dong; * The motion vector padding process is specified in subclause 7.6.1.6 of
320c1bc742181ded4930842b46e9507372f0b1b963James Dong; * ISO/IEC 14496-2.
330c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
340c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Remarks:
350c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
360c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
370c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Parameters:
380c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]    ppBitStream        pointer to the pointer to the current byte in
390c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                            the bit stream buffer
400c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]    pBitOffset         pointer to the bit position in the byte pointed
410c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                            to by *ppBitStream. *pBitOffset is valid within
420c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                            [0-7].
430c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]    pSrcMVLeftMB       pointers to the motion vector buffers of the
440c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                           macroblocks specially at the left side of the current macroblock
450c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     respectively.
460c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]    pSrcMVUpperMB      pointers to the motion vector buffers of the
470c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     macroblocks specially at the upper side of the current macroblock
480c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     respectively.
490c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]    pSrcMVUpperRightMB pointers to the motion vector buffers of the
500c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     macroblocks specially at the upper-right side of the current macroblock
510c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     respectively.
520c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]    fcodeForward       a code equal to vop_fcode_forward in MPEG-4
530c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     bit stream syntax
540c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [in]    MBType         the type of the current macroblock. If MBType
550c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     is not equal to OMX_VC_INTER4V, the destination
560c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     motion vector buffer is still filled with the
570c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     same decoded vector.
580c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [out]   ppBitStream         *ppBitStream is updated after the block is decoded,
590c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     so that it points to the current byte in the bit
600c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     stream buffer
610c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [out]   pBitOffset         *pBitOffset is updated so that it points to the
620c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     current bit position in the byte pointed by
630c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     *ppBitStream
640c1bc742181ded4930842b46e9507372f0b1b963James Dong; * [out]   pDstMVCurMB         pointer to the motion vector buffer of the current
650c1bc742181ded4930842b46e9507372f0b1b963James Dong; *                     macroblock which contains four decoded motion vectors
660c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
670c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Return Value:
680c1bc742181ded4930842b46e9507372f0b1b963James Dong; * OMX_Sts_NoErr -no error
690c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
700c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
710c1bc742181ded4930842b46e9507372f0b1b963James Dong; * OMX_Sts_Err - status error
720c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
730c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
740c1bc742181ded4930842b46e9507372f0b1b963James Dong
750c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE omxtypes_s.h
760c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armCOMM_s.h
770c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armCOMM_BitDec_s.h
780c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE omxVC_s.h
790c1bc742181ded4930842b46e9507372f0b1b963James Dong
800c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_VARIANTS ARM1136JS
810c1bc742181ded4930842b46e9507372f0b1b963James Dong
820c1bc742181ded4930842b46e9507372f0b1b963James Dong
830c1bc742181ded4930842b46e9507372f0b1b963James Dong
840c1bc742181ded4930842b46e9507372f0b1b963James Dong
850c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF ARM1136JS
860c1bc742181ded4930842b46e9507372f0b1b963James Dong
870c1bc742181ded4930842b46e9507372f0b1b963James Dong;//Input Arguments
880c1bc742181ded4930842b46e9507372f0b1b963James Dong
890c1bc742181ded4930842b46e9507372f0b1b963James DongppBitStream           RN 0
900c1bc742181ded4930842b46e9507372f0b1b963James DongpBitOffset            RN 1
910c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcMVLeftMB          RN 2
920c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcMVUpperMB         RN 3
930c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcMVUpperRightMB    RN 4
940c1bc742181ded4930842b46e9507372f0b1b963James DongpDstMVCurMB           RN 5
950c1bc742181ded4930842b46e9507372f0b1b963James DongfcodeForward          RN 6
960c1bc742181ded4930842b46e9507372f0b1b963James DongMBType                RN 7
970c1bc742181ded4930842b46e9507372f0b1b963James Dong
980c1bc742181ded4930842b46e9507372f0b1b963James Dong;//Local Variables
990c1bc742181ded4930842b46e9507372f0b1b963James Dong
1000c1bc742181ded4930842b46e9507372f0b1b963James Dongzero                  RN 4
1010c1bc742181ded4930842b46e9507372f0b1b963James Dongone                   RN 4
1020c1bc742181ded4930842b46e9507372f0b1b963James DongscaleFactor           RN 1
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong
1050c1bc742181ded4930842b46e9507372f0b1b963James DongReturn                RN 0
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong
1070c1bc742181ded4930842b46e9507372f0b1b963James DongVlcMVD                RN 0
1080c1bc742181ded4930842b46e9507372f0b1b963James Dongindex                 RN 4
1090c1bc742181ded4930842b46e9507372f0b1b963James DongCount                 RN 7
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong
1110c1bc742181ded4930842b46e9507372f0b1b963James DongmvHorData             RN 4
1120c1bc742181ded4930842b46e9507372f0b1b963James DongmvHorResidual         RN 0
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong
1140c1bc742181ded4930842b46e9507372f0b1b963James DongmvVerData             RN 4
1150c1bc742181ded4930842b46e9507372f0b1b963James DongmvVerResidual         RN 0
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong
1170c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp                  RN 1
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong
1190c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp1                 RN 3
1200c1bc742181ded4930842b46e9507372f0b1b963James DongHigh                  RN 4
1210c1bc742181ded4930842b46e9507372f0b1b963James DongLow                   RN 2
1220c1bc742181ded4930842b46e9507372f0b1b963James DongRange                 RN 1
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong
1240c1bc742181ded4930842b46e9507372f0b1b963James DongBlkCount              RN 14
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong
1260c1bc742181ded4930842b46e9507372f0b1b963James DongdiffMVdx              RN 0
1270c1bc742181ded4930842b46e9507372f0b1b963James DongdiffMVdy              RN 1
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Scratch Registers
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong
1310c1bc742181ded4930842b46e9507372f0b1b963James DongRBitStream            RN 8
1320c1bc742181ded4930842b46e9507372f0b1b963James DongRBitCount             RN 9
1330c1bc742181ded4930842b46e9507372f0b1b963James DongRBitBuffer            RN 10
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong
1350c1bc742181ded4930842b46e9507372f0b1b963James DongT1                    RN 11
1360c1bc742181ded4930842b46e9507372f0b1b963James DongT2                    RN 12
1370c1bc742181ded4930842b46e9507372f0b1b963James DongLR                    RN 14
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong       IMPORT          armVCM4P2_aVlcMVD
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong       IMPORT          omxVCM4P2_FindMVpred
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Allocate stack memory
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        ppDstMVCurMB,4
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        pDstMVPredME,4
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        pBlkCount,4
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        pppBitStream,4
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        ppBitOffset,4
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        ppSrcMVLeftMB,4
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        ppSrcMVUpperMB,4
1520c1bc742181ded4930842b46e9507372f0b1b963James Dong
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        pdiffMVdx,4
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        pdiffMVdy,4
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ALLOC4        pHigh,4
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_START   omxVCM4P2_DecodePadMV_PVOP,r11
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           pSrcMVUpperRightMBonStack,4           ;// pointer to  pSrcMVUpperRightMB on stack
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           pDstMVCurMBonStack,4                  ;// pointer to pDstMVCurMB on stack
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           fcodeForwardonStack,4                 ;// pointer to fcodeForward on stack
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_ARG           MBTypeonStack,4                       ;// pointer to MBType on stack
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Initializing the BitStream Macro
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_INIT0      ppBitStream, pBitOffset, RBitStream, RBitBuffer, RBitCount
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           MBType,MBTypeonStack                  ;// Load MBType from stack
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           pDstMVCurMB,pDstMVCurMBonStack        ;// Load pDstMVCurMB from stack
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             zero,#0
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQ             MBType,#OMX_VC_INTRA                  ;// Check if MBType=OMX_VC_INTRA
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQNE           MBType,#OMX_VC_INTRA_Q                ;// check if MBType=OMX_VC_INTRA_Q
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong       STREQ           zero,[pDstMVCurMB]
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_INIT1      T1, T2, T2
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong       STREQ           zero,[pDstMVCurMB,#4]
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_INIT2      T1, T2, T2
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong       STREQ           zero,[pDstMVCurMB,#4]
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOVEQ           Return,#OMX_Sts_NoErr
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             BlkCount,#0
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong       STREQ           zero,[pDstMVCurMB,#4]
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong       BEQ             ExitOK
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQ             MBType,#OMX_VC_INTER4V                ;// Check if MBType=OMX_VC_INTER4V
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQNE           MBType,#OMX_VC_INTER4V_Q              ;// Check if MBType=OMX_VC_INTER4V_Q
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOVEQ           Count,#4
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQ             MBType,#OMX_VC_INTER                  ;// Check if MBType=OMX_VC_INTER
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQNE           MBType,#OMX_VC_INTER_Q                ;// Check if MBType=OMX_VC_INTER_Q
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOVEQ           Count,#1
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           fcodeForward,fcodeForwardonStack      ;// Load fcodeForward  from stack
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Storing the values temporarily on stack
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong
2030c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           ppBitStream,pppBitStream
2040c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           pBitOffset,ppBitOffset
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             temp,fcodeForward,#1                  ;// temp=fcodeForward-1
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             one,#1
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           pSrcMVLeftMB,ppSrcMVLeftMB
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSL             scaleFactor,one,temp                  ;// scaleFactor=1<<(fcodeForward-1)
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           pSrcMVUpperMB,ppSrcMVUpperMB
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSL             scaleFactor,scaleFactor,#5
2130c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           scaleFactor,pHigh                     ;// [pHigh]=32*scaleFactor
2140c1bc742181ded4930842b46e9507372f0b1b963James Dong
2150c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// VLD Decoding
2160c1bc742181ded4930842b46e9507372f0b1b963James Dong
2170c1bc742181ded4930842b46e9507372f0b1b963James Dong
2180c1bc742181ded4930842b46e9507372f0b1b963James DongLoop
2190c1bc742181ded4930842b46e9507372f0b1b963James Dong
2200c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             VlcMVD, =armVCM4P2_aVlcMVD        ;// Load the optimized MVD VLC table
2210c1bc742181ded4930842b46e9507372f0b1b963James Dong
2220c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Horizontal Data and Residual calculation
2230c1bc742181ded4930842b46e9507372f0b1b963James Dong
2240c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             temp,=0xFFF
2250c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_VLD        index,T1,T2,VlcMVD,3,2                ;// variable lenght decoding using the macro
2260c1bc742181ded4930842b46e9507372f0b1b963James Dong
2270c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQ             index,temp
2280c1bc742181ded4930842b46e9507372f0b1b963James Dong       BEQ             ExitError                             ;// Exit with an Error Message if the decoded symbol is an invalied symbol
2290c1bc742181ded4930842b46e9507372f0b1b963James Dong
2300c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             mvHorData,index,#32                   ;// mvHorData=index-32
2310c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             mvHorResidual,#1                      ;// mvHorResidual=1
2320c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             fcodeForward,#1
2330c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQNE           mvHorData,#0
2340c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOVEQ           diffMVdx,mvHorData                    ;// if scaleFactor=1(fcodeForward=1) or mvHorData=0 diffMVdx=mvHorData
2350c1bc742181ded4930842b46e9507372f0b1b963James Dong       BEQ             VerticalData
2360c1bc742181ded4930842b46e9507372f0b1b963James Dong
2370c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             temp,fcodeForward,#1
2380c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_VREAD8     mvHorResidual,temp,T1,T2              ;// get mvHorResidual from bitstream if fcodeForward>1 and mvHorData!=0
2390c1bc742181ded4930842b46e9507372f0b1b963James Dong
2400c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             mvHorData,#0
2410c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           mvHorData,mvHorData,#0                ;// mvHorData=abs(mvHorData)
2420c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             mvHorResidual,mvHorResidual,fcodeForward
2430c1bc742181ded4930842b46e9507372f0b1b963James Dong       SMLABB          diffMVdx,mvHorData,fcodeForward,mvHorResidual ;// diffMVdx=abs(mvHorData)*fcodeForward+mvHorResidual-fcodeForward
2440c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             diffMVdx,diffMVdx,#1
2450c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           diffMVdx,diffMVdx,#0
2460c1bc742181ded4930842b46e9507372f0b1b963James Dong
2470c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Vertical Data and Residual calculation
2480c1bc742181ded4930842b46e9507372f0b1b963James Dong
2490c1bc742181ded4930842b46e9507372f0b1b963James DongVerticalData
2500c1bc742181ded4930842b46e9507372f0b1b963James Dong
2510c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           diffMVdx,pdiffMVdx                    ;// Store the diffMVdx on stack
2520c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             VlcMVD, =armVCM4P2_aVlcMVD        ;// Loading the address of optimized VLC tables
2530c1bc742181ded4930842b46e9507372f0b1b963James Dong
2540c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDR             temp,=0xFFF
2550c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_VLD        index,T1,T2,VlcMVD,3,2                ;// VLC decoding using the macro
2560c1bc742181ded4930842b46e9507372f0b1b963James Dong
2570c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQ             index,temp
2580c1bc742181ded4930842b46e9507372f0b1b963James Dong       BEQ             ExitError                             ;// Exit with an Error Message if an Invalied Symbol occurs
2590c1bc742181ded4930842b46e9507372f0b1b963James Dong
2600c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             mvVerData,index,#32                   ;// mvVerData=index-32
2610c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             mvVerResidual,#1
2620c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             fcodeForward,#1
2630c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQNE           mvVerData,#0
2640c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOVEQ           diffMVdy,mvVerData                    ;// diffMVdy = mvVerData if scaleFactor=1(fcodeForward=1) or mvVerData=0
2650c1bc742181ded4930842b46e9507372f0b1b963James Dong       BEQ             FindMVPred
2660c1bc742181ded4930842b46e9507372f0b1b963James Dong
2670c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             temp,fcodeForward,#1
2680c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_VREAD8     mvVerResidual,temp,T1,T2              ;// Get mvVerResidual from bit stream if fcodeForward>1 and mnVerData!=0
2690c1bc742181ded4930842b46e9507372f0b1b963James Dong
2700c1bc742181ded4930842b46e9507372f0b1b963James Dong
2710c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             mvVerData,#0
2720c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           mvVerData,mvVerData,#0
2730c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             mvVerResidual,mvVerResidual,fcodeForward
2740c1bc742181ded4930842b46e9507372f0b1b963James Dong       SMLABB          diffMVdy,mvVerData,fcodeForward,mvVerResidual ;// diffMVdy=abs(mvVerData)*fcodeForward+mvVerResidual-fcodeForward
2750c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             diffMVdy,diffMVdy,#1
2760c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSBLT           diffMVdy,diffMVdy,#0
2770c1bc742181ded4930842b46e9507372f0b1b963James Dong
2780c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;//Calling the Function omxVCM4P2_FindMVpred
2790c1bc742181ded4930842b46e9507372f0b1b963James Dong
2800c1bc742181ded4930842b46e9507372f0b1b963James DongFindMVPred
2810c1bc742181ded4930842b46e9507372f0b1b963James Dong
2820c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           diffMVdy,pdiffMVdy
2830c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             temp,pDstMVCurMB,BlkCount,LSL #2      ;// temp=pDstMVCurMB[BlkCount]
2840c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           temp,ppDstMVCurMB                     ;// store temp on stack for passing as an argument to FindMVPred
2850c1bc742181ded4930842b46e9507372f0b1b963James Dong
2860c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             temp,#0
2870c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           temp,pDstMVPredME                     ;// Pass pDstMVPredME=NULL as an argument
2880c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_STR           BlkCount,pBlkCount                    ;// Passs BlkCount as Argument through stack
2890c1bc742181ded4930842b46e9507372f0b1b963James Dong
2900c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             temp,pSrcMVLeftMB                     ;// temp (RN 1)=pSrcMVLeftMB
2910c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           pSrcMVUpperRightMB,pSrcMVUpperRightMBonStack
2920c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             pSrcMVLeftMB,pSrcMVUpperMB            ;// pSrcMVLeftMB ( RN 2) = pSrcMVUpperMB
2930c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             ppBitStream,pDstMVCurMB               ;// ppBitStream  ( RN 0) = pDstMVCurMB
2940c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             pSrcMVUpperMB,pSrcMVUpperRightMB      ;// pSrcMVUpperMB( RN 3) = pSrcMVUpperRightMB
2950c1bc742181ded4930842b46e9507372f0b1b963James Dong       BL              omxVCM4P2_FindMVpred              ;// Branch to subroutine omxVCM4P2_FindMVpred
2960c1bc742181ded4930842b46e9507372f0b1b963James Dong
2970c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Store Horizontal Motion Vector
2980c1bc742181ded4930842b46e9507372f0b1b963James Dong
2990c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           BlkCount,pBlkCount                    ;// Load BlkCount from stack
3000c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           High,pHigh                            ;// High=32*scaleFactor
3010c1bc742181ded4930842b46e9507372f0b1b963James Dong       LSL             temp1,BlkCount,#2                     ;// temp=BlkCount*4
3020c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           diffMVdx,pdiffMVdx                    ;// Laad diffMVdx
3030c1bc742181ded4930842b46e9507372f0b1b963James Dong
3040c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRSH           temp,[pDstMVCurMB,temp1]              ;// temp=pDstMVCurMB[BlkCount]
3050c1bc742181ded4930842b46e9507372f0b1b963James Dong
3060c1bc742181ded4930842b46e9507372f0b1b963James Dong
3070c1bc742181ded4930842b46e9507372f0b1b963James Dong       RSB             Low,High,#0                           ;// Low = -32*scaleFactor
3080c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             diffMVdx,temp,diffMVdx                ;// diffMVdx=pDstMVCurMB[BlkCount]+diffMVdx
3090c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             Range,High,High                       ;// Range=64*ScaleFactor
3100c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUB             High,High,#1                          ;// High= 32*scaleFactor-1
3110c1bc742181ded4930842b46e9507372f0b1b963James Dong
3120c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             diffMVdx,Low                          ;// If diffMVdx<Low
3130c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADDLT           diffMVdx,diffMVdx,Range               ;// diffMVdx+=Range
3140c1bc742181ded4930842b46e9507372f0b1b963James Dong
3150c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             diffMVdx,High
3160c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUBGT           diffMVdx,diffMVdx,Range               ;// If diffMVdx > High diffMVdx-=Range
3170c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            diffMVdx,[pDstMVCurMB,temp1]
3180c1bc742181ded4930842b46e9507372f0b1b963James Dong
3190c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// Store Vertical
3200c1bc742181ded4930842b46e9507372f0b1b963James Dong
3210c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             temp1,temp1,#2                        ;// temp1=4*BlkCount+2
3220c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           diffMVdx,pdiffMVdy                    ;// Laad diffMVdy
3230c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDRSH           temp,[pDstMVCurMB,temp1]              ;// temp=pDstMVCurMB[BlkCount].diffMVdy
3240c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             BlkCount,BlkCount,#1                  ;// BlkCount=BlkCount+1
3250c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADD             diffMVdx,temp,diffMVdx
3260c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             diffMVdx,Low
3270c1bc742181ded4930842b46e9507372f0b1b963James Dong       ADDLT           diffMVdx,diffMVdx,Range               ;// If diffMVdy<Low  diffMVdy+=Range
3280c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             diffMVdx,High
3290c1bc742181ded4930842b46e9507372f0b1b963James Dong       SUBGT           diffMVdx,diffMVdx,Range               ;// If diffMVdy > High diffMVdy-=Range
3300c1bc742181ded4930842b46e9507372f0b1b963James Dong       STRH            diffMVdx,[pDstMVCurMB,temp1]
3310c1bc742181ded4930842b46e9507372f0b1b963James Dong
3320c1bc742181ded4930842b46e9507372f0b1b963James Dong       CMP             BlkCount,Count
3330c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           pSrcMVLeftMB,ppSrcMVLeftMB
3340c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           pSrcMVUpperMB,ppSrcMVUpperMB
3350c1bc742181ded4930842b46e9507372f0b1b963James Dong
3360c1bc742181ded4930842b46e9507372f0b1b963James Dong       BLT             Loop                                  ;// If BlkCount<Count Continue the Loop
3370c1bc742181ded4930842b46e9507372f0b1b963James Dong
3380c1bc742181ded4930842b46e9507372f0b1b963James Dong
3390c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// If MBType=OMX_VC_INTER or MBtype=OMX_VC_INTER_Q copy pDstMVCurMB[0] to
3400c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;// pDstMVCurMB[1], pDstMVCurMB[2], pDstMVCurMB[3]
3410c1bc742181ded4930842b46e9507372f0b1b963James Dong
3420c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           MBType,MBTypeonStack
3430c1bc742181ded4930842b46e9507372f0b1b963James Dong
3440c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQ             MBType,#OMX_VC_INTER
3450c1bc742181ded4930842b46e9507372f0b1b963James Dong       TEQNE           MBType,#OMX_VC_INTER_Q
3460c1bc742181ded4930842b46e9507372f0b1b963James Dong       LDREQ           temp,[pDstMVCurMB]
3470c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           ppBitStream,pppBitStream
3480c1bc742181ded4930842b46e9507372f0b1b963James Dong       STREQ           temp,[pDstMVCurMB,#4]
3490c1bc742181ded4930842b46e9507372f0b1b963James Dong
3500c1bc742181ded4930842b46e9507372f0b1b963James Dong       STREQ           temp,[pDstMVCurMB,#8]
3510c1bc742181ded4930842b46e9507372f0b1b963James Dong       STREQ           temp,[pDstMVCurMB,#12]
3520c1bc742181ded4930842b46e9507372f0b1b963James Dong
3530c1bc742181ded4930842b46e9507372f0b1b963James Dong
3540c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           pBitOffset,ppBitOffset
3550c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;//Ending the macro
3560c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_FINI       ppBitStream,pBitOffset                 ;// Finishing the Macro
3570c1bc742181ded4930842b46e9507372f0b1b963James Dong
3580c1bc742181ded4930842b46e9507372f0b1b963James Dong
3590c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             Return,#OMX_Sts_NoErr
3600c1bc742181ded4930842b46e9507372f0b1b963James Dong       B               ExitOK
3610c1bc742181ded4930842b46e9507372f0b1b963James Dong
3620c1bc742181ded4930842b46e9507372f0b1b963James DongExitError
3630c1bc742181ded4930842b46e9507372f0b1b963James Dong
3640c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           ppBitStream,pppBitStream
3650c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_LDR           pBitOffset,ppBitOffset
3660c1bc742181ded4930842b46e9507372f0b1b963James Dong       ;//Ending the macro
3670c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_BD_FINI       ppBitStream,pBitOffset
3680c1bc742181ded4930842b46e9507372f0b1b963James Dong
3690c1bc742181ded4930842b46e9507372f0b1b963James Dong       MOV             Return,#OMX_Sts_Err
3700c1bc742181ded4930842b46e9507372f0b1b963James Dong
3710c1bc742181ded4930842b46e9507372f0b1b963James DongExitOK
3720c1bc742181ded4930842b46e9507372f0b1b963James Dong
3730c1bc742181ded4930842b46e9507372f0b1b963James Dong       M_END
3740c1bc742181ded4930842b46e9507372f0b1b963James Dong       ENDIF
3750c1bc742181ded4930842b46e9507372f0b1b963James Dong       END
3760c1bc742181ded4930842b46e9507372f0b1b963James Dong
3770c1bc742181ded4930842b46e9507372f0b1b963James Dong
3780c1bc742181ded4930842b46e9507372f0b1b963James Dong
379