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