10c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
20c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
30c1bc742181ded4930842b46e9507372f0b1b963James Dong;// File Name:  omxVCM4P2_FindMVpred_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:
140c1bc742181ded4930842b46e9507372f0b1b963James Dong;//     omxVCM4P2_FindMVpred
150c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
160c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Include headers
170c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE omxtypes_s.h
180c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armCOMM_s.h
190c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armVCCOMM_s.h
200c1bc742181ded4930842b46e9507372f0b1b963James Dong
210c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Define cpu variants
220c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_VARIANTS ARM1136JS
230c1bc742181ded4930842b46e9507372f0b1b963James Dong
240c1bc742181ded4930842b46e9507372f0b1b963James Dong
250c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF ARM1136JS
260c1bc742181ded4930842b46e9507372f0b1b963James Dong
270c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_TABLE armVCM4P2_pBlkIndexTable
280c1bc742181ded4930842b46e9507372f0b1b963James Dong        DCD  OMXVCBlk0, OMXVCBlk1
290c1bc742181ded4930842b46e9507372f0b1b963James Dong        DCD  OMXVCBlk2, OMXVCBlk3
300c1bc742181ded4930842b46e9507372f0b1b963James Dong
310c1bc742181ded4930842b46e9507372f0b1b963James Dong;//--------------------------------------------
320c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Declare input registers
330c1bc742181ded4930842b46e9507372f0b1b963James Dong;//--------------------------------------------
340c1bc742181ded4930842b46e9507372f0b1b963James Dong
350c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcMVCurMB            RN 0
360c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcCandMV1            RN 1
370c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcCandMV2            RN 2
380c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcCandMV3            RN 3
390c1bc742181ded4930842b46e9507372f0b1b963James DongpDstMVPred             RN 4
400c1bc742181ded4930842b46e9507372f0b1b963James DongpDstMVPredME           RN 5
410c1bc742181ded4930842b46e9507372f0b1b963James DongiBlk                   RN 6
420c1bc742181ded4930842b46e9507372f0b1b963James Dong
430c1bc742181ded4930842b46e9507372f0b1b963James DongpTable                 RN 4
440c1bc742181ded4930842b46e9507372f0b1b963James DongCandMV                 RN 12
450c1bc742181ded4930842b46e9507372f0b1b963James Dong
460c1bc742181ded4930842b46e9507372f0b1b963James DongpCandMV1               RN 7
470c1bc742181ded4930842b46e9507372f0b1b963James DongpCandMV2               RN 8
480c1bc742181ded4930842b46e9507372f0b1b963James DongpCandMV3               RN 9
490c1bc742181ded4930842b46e9507372f0b1b963James Dong
500c1bc742181ded4930842b46e9507372f0b1b963James DongCandMV1dx              RN 0
510c1bc742181ded4930842b46e9507372f0b1b963James DongCandMV1dy              RN 1
520c1bc742181ded4930842b46e9507372f0b1b963James DongCandMV2dx              RN 2
530c1bc742181ded4930842b46e9507372f0b1b963James DongCandMV2dy              RN 3
540c1bc742181ded4930842b46e9507372f0b1b963James DongCandMV3dx              RN 10
550c1bc742181ded4930842b46e9507372f0b1b963James DongCandMV3dy              RN 11
560c1bc742181ded4930842b46e9507372f0b1b963James Dong
570c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp                   RN 14
580c1bc742181ded4930842b46e9507372f0b1b963James Dong
590c1bc742181ded4930842b46e9507372f0b1b963James Dongzero                   RN 14
600c1bc742181ded4930842b46e9507372f0b1b963James Dongreturn                 RN 0
610c1bc742181ded4930842b46e9507372f0b1b963James Dong
620c1bc742181ded4930842b46e9507372f0b1b963James Dong; ----------------------------------------------
630c1bc742181ded4930842b46e9507372f0b1b963James Dong; Main routine
640c1bc742181ded4930842b46e9507372f0b1b963James Dong; ----------------------------------------------
650c1bc742181ded4930842b46e9507372f0b1b963James Dong
660c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC4 MV, 4
670c1bc742181ded4930842b46e9507372f0b1b963James Dong
680c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Function header
690c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_START omxVCM4P2_FindMVpred, r11
700c1bc742181ded4930842b46e9507372f0b1b963James Dong
710c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Define stack arguments
720c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG   ppDstMVPred,  4
730c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG   ppDstMVPredME, 4
740c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG   Blk, 4
750c1bc742181ded4930842b46e9507372f0b1b963James Dong
760c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ADR CandMV, MV
770c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV   zero, #0
780c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR iBlk, Blk
790c1bc742181ded4930842b46e9507372f0b1b963James Dong
800c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Set the default value for these
810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// to be used if pSrcCandMV[1|2|3] == NULL
820c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV   pCandMV1, CandMV
830c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV   pCandMV2, CandMV
840c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV   pCandMV3, CandMV
850c1bc742181ded4930842b46e9507372f0b1b963James Dong
860c1bc742181ded4930842b46e9507372f0b1b963James Dong        STR   zero, [CandMV]
870c1bc742181ded4930842b46e9507372f0b1b963James Dong
880c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Branch to the case based on blk number
890c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_SWITCH iBlk
900c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_CASE   OMXVCBlk0      ;// iBlk=0
910c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_CASE   OMXVCBlk1      ;// iBlk=0
920c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_CASE   OMXVCBlk2      ;// iBlk=0
930c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_CASE   OMXVCBlk3      ;// iBlk=0
940c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ENDSWITCH
950c1bc742181ded4930842b46e9507372f0b1b963James Dong
960c1bc742181ded4930842b46e9507372f0b1b963James DongOMXVCBlk0
970c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV1, #0
980c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDNE pCandMV1, pSrcCandMV1, #4
990c1bc742181ded4930842b46e9507372f0b1b963James Dong
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV2, #0
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDNE pCandMV2, pSrcCandMV2, #8
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV3, #0
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDNE pCandMV3, pSrcCandMV3, #8
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMPEQ pSrcCandMV1, #0
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV3, pCandMV2
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV1, pCandMV2
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV1, #0
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMPEQ pSrcCandMV2, #0
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV1, pCandMV3
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV2, pCandMV3
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV2, #0
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMPEQ pSrcCandMV3, #0
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV2, pCandMV1
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV3, pCandMV1
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong        B     BlkEnd
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong
1240c1bc742181ded4930842b46e9507372f0b1b963James DongOMXVCBlk1
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV   pCandMV1, pSrcMVCurMB
1260c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV3, #0
1270c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDNE pCandMV3, pSrcCandMV3, #8
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV2, #0
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDNE pCandMV2, pSrcCandMV2, #12
1310c1bc742181ded4930842b46e9507372f0b1b963James Dong
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMPEQ pSrcCandMV3, #0
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV2, pCandMV1
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ pCandMV3, pCandMV1
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong        B     BlkEnd
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong
1390c1bc742181ded4930842b46e9507372f0b1b963James DongOMXVCBlk2
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP   pSrcCandMV1, #0
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV   pCandMV2, pSrcMVCurMB
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD   pCandMV3, pSrcMVCurMB, #4
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDNE pCandMV1, pSrcCandMV1, #12
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong        B     BlkEnd
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong
1460c1bc742181ded4930842b46e9507372f0b1b963James DongOMXVCBlk3
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD   pCandMV1, pSrcMVCurMB, #8
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV   pCandMV2, pSrcMVCurMB
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD   pCandMV3, pSrcMVCurMB, #4
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong
1510c1bc742181ded4930842b46e9507372f0b1b963James DongBlkEnd
1520c1bc742181ded4930842b46e9507372f0b1b963James Dong
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Using the transperancy info, zero
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// out the candidate MV if neccesary
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSH CandMV1dx, [pCandMV1], #2
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSH CandMV2dx, [pCandMV2], #2
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSH CandMV3dx, [pCandMV3], #2
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load argument from the stack
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR pDstMVPredME, ppDstMVPredME
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSH CandMV1dy, [pCandMV1]
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSH CandMV2dy, [pCandMV2]
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRSH CandMV3dy, [pCandMV3]
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP pDstMVPredME, #0
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Store the candidate MV's into the pDstMVPredME,
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// these can be used in the fast algorithm if implemented
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRHNE CandMV1dx, [pDstMVPredME], #2
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRHNE CandMV1dy, [pDstMVPredME], #2
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRHNE CandMV2dx, [pDstMVPredME], #2
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRHNE CandMV2dy, [pDstMVPredME], #2
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRHNE CandMV3dx, [pDstMVPredME], #2
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRHNE CandMV3dy, [pDstMVPredME]
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong        ; Find the median of the 3 candidate MV's
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_MEDIAN3 CandMV1dx, CandMV2dx, CandMV3dx, temp
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load argument from the stack
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR pDstMVPred, ppDstMVPred
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_MEDIAN3 CandMV1dy, CandMV2dy, CandMV3dy, temp
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRH CandMV3dx, [pDstMVPred], #2
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRH CandMV3dy, [pDstMVPred]
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV return, #OMX_Sts_NoErr
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_END
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong    ENDIF ;// ARM1136JS :LOR: CortexA8
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong    END