10c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
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;// File Name:  omxVCM4P10_FilterDeblockingChroma_VerEdge_I_s.s
190c1bc742181ded4930842b46e9507372f0b1b963James Dong;// OpenMAX DL: v1.0.2
200c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Revision:   9641
210c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Date:       Thursday, February 7, 2008
220c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
230c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
240c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
250c1bc742181ded4930842b46e9507372f0b1b963James Dong;//
260c1bc742181ded4930842b46e9507372f0b1b963James Dong
270c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE omxtypes_s.h
280c1bc742181ded4930842b46e9507372f0b1b963James Dong        INCLUDE armCOMM_s.h
290c1bc742181ded4930842b46e9507372f0b1b963James Dong
300c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_VARIANTS ARM1136JS
310c1bc742181ded4930842b46e9507372f0b1b963James Dong
320c1bc742181ded4930842b46e9507372f0b1b963James Dong
330c1bc742181ded4930842b46e9507372f0b1b963James Dong        IF ARM1136JS
340c1bc742181ded4930842b46e9507372f0b1b963James Dong
350c1bc742181ded4930842b46e9507372f0b1b963James Dong
360c1bc742181ded4930842b46e9507372f0b1b963James DongMASK_0      EQU 0x00000000
370c1bc742181ded4930842b46e9507372f0b1b963James DongMASK_1      EQU 0x01010101
380c1bc742181ded4930842b46e9507372f0b1b963James DongMASK_2      EQU 0x0000ff00
390c1bc742181ded4930842b46e9507372f0b1b963James DongLOOP_COUNT  EQU 0x50000000
400c1bc742181ded4930842b46e9507372f0b1b963James Dong
410c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Declare input registers
420c1bc742181ded4930842b46e9507372f0b1b963James Dong
430c1bc742181ded4930842b46e9507372f0b1b963James DongpSrcDst     RN 0
440c1bc742181ded4930842b46e9507372f0b1b963James DongsrcdstStep  RN 1
450c1bc742181ded4930842b46e9507372f0b1b963James DongpAlphaArg   RN 2
460c1bc742181ded4930842b46e9507372f0b1b963James DongpBetaArg    RN 3
470c1bc742181ded4930842b46e9507372f0b1b963James Dong
480c1bc742181ded4930842b46e9507372f0b1b963James DongpThresholds RN 6
490c1bc742181ded4930842b46e9507372f0b1b963James DongpBS         RN 9
500c1bc742181ded4930842b46e9507372f0b1b963James DongpQ0         RN 0
510c1bc742181ded4930842b46e9507372f0b1b963James DongbS          RN 2
520c1bc742181ded4930842b46e9507372f0b1b963James DongbSTemp      RN 10
530c1bc742181ded4930842b46e9507372f0b1b963James Dong
540c1bc742181ded4930842b46e9507372f0b1b963James Dongalpha       RN 6
550c1bc742181ded4930842b46e9507372f0b1b963James Dongalpha0      RN 6
560c1bc742181ded4930842b46e9507372f0b1b963James Dongalpha1      RN 8
570c1bc742181ded4930842b46e9507372f0b1b963James Dong
580c1bc742181ded4930842b46e9507372f0b1b963James Dongbeta        RN 7
590c1bc742181ded4930842b46e9507372f0b1b963James Dongbeta0       RN 7
600c1bc742181ded4930842b46e9507372f0b1b963James Dongbeta1       RN 9
610c1bc742181ded4930842b46e9507372f0b1b963James Dong
620c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Declare Local/Temporary variables
630c1bc742181ded4930842b46e9507372f0b1b963James Dong
640c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Pixels
650c1bc742181ded4930842b46e9507372f0b1b963James Dongp_0         RN 3
660c1bc742181ded4930842b46e9507372f0b1b963James Dongp_1         RN 5
670c1bc742181ded4930842b46e9507372f0b1b963James Dongq_0         RN 8
680c1bc742181ded4930842b46e9507372f0b1b963James Dongq_1         RN 9
690c1bc742181ded4930842b46e9507372f0b1b963James Dong
700c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Unpacking
710c1bc742181ded4930842b46e9507372f0b1b963James Dongmask        RN 11
720c1bc742181ded4930842b46e9507372f0b1b963James Dong
730c1bc742181ded4930842b46e9507372f0b1b963James Dongrow0        RN 2
740c1bc742181ded4930842b46e9507372f0b1b963James Dongrow1        RN 4
750c1bc742181ded4930842b46e9507372f0b1b963James Dongrow2        RN 5
760c1bc742181ded4930842b46e9507372f0b1b963James Dongrow3        RN 3
770c1bc742181ded4930842b46e9507372f0b1b963James Dong
780c1bc742181ded4930842b46e9507372f0b1b963James Dongrow4        RN 8
790c1bc742181ded4930842b46e9507372f0b1b963James Dongrow5        RN 9
800c1bc742181ded4930842b46e9507372f0b1b963James Dongrow6        RN 10
810c1bc742181ded4930842b46e9507372f0b1b963James Dongrow7        RN 12
820c1bc742181ded4930842b46e9507372f0b1b963James Dong
830c1bc742181ded4930842b46e9507372f0b1b963James Dongtunpk0      RN 2
840c1bc742181ded4930842b46e9507372f0b1b963James Dongtunpk2      RN 10
850c1bc742181ded4930842b46e9507372f0b1b963James Dongtunpk3      RN 12
860c1bc742181ded4930842b46e9507372f0b1b963James Dong
870c1bc742181ded4930842b46e9507372f0b1b963James Dongtunpk4      RN 4
880c1bc742181ded4930842b46e9507372f0b1b963James Dongtunpk5      RN 5
890c1bc742181ded4930842b46e9507372f0b1b963James Dongtunpk6      RN 14
900c1bc742181ded4930842b46e9507372f0b1b963James Dongtunpk7      RN 2
910c1bc742181ded4930842b46e9507372f0b1b963James Dong
920c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Filtering
930c1bc742181ded4930842b46e9507372f0b1b963James Dong
940c1bc742181ded4930842b46e9507372f0b1b963James Dongdp0q0       RN 12
950c1bc742181ded4930842b46e9507372f0b1b963James Dongdp1p0       RN 12
960c1bc742181ded4930842b46e9507372f0b1b963James Dongdq1q0       RN 12
970c1bc742181ded4930842b46e9507372f0b1b963James Dong
980c1bc742181ded4930842b46e9507372f0b1b963James Dongap0q0       RN 4
990c1bc742181ded4930842b46e9507372f0b1b963James Dongfilt        RN 2
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong
1010c1bc742181ded4930842b46e9507372f0b1b963James Dongm00         RN 14
1020c1bc742181ded4930842b46e9507372f0b1b963James Dongm01         RN 11
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong
1040c1bc742181ded4930842b46e9507372f0b1b963James DongpQ0         RN 0
1050c1bc742181ded4930842b46e9507372f0b1b963James DongStep        RN 1
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Output
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong
1090c1bc742181ded4930842b46e9507372f0b1b963James DongP_0         RN 6
1100c1bc742181ded4930842b46e9507372f0b1b963James DongQ_0         RN 7
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong;//Declarations for bSLT4 kernel
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong
1140c1bc742181ded4930842b46e9507372f0b1b963James DongtC          RN 12
1150c1bc742181ded4930842b46e9507372f0b1b963James DongtC0         RN 5
1160c1bc742181ded4930842b46e9507372f0b1b963James DongtC1         RN 12
1170c1bc742181ded4930842b46e9507372f0b1b963James Dongpos         RN 5
1180c1bc742181ded4930842b46e9507372f0b1b963James Dongneg         RN 9
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong;//Declarations for bSGE4 kernel
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Miscellanous
1240c1bc742181ded4930842b46e9507372f0b1b963James DongXY          RN 8
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong
1260c1bc742181ded4930842b46e9507372f0b1b963James Donga           RN 10
1270c1bc742181ded4930842b46e9507372f0b1b963James Dongt1          RN 10
1280c1bc742181ded4930842b46e9507372f0b1b963James Dongt2          RN 12
1290c1bc742181ded4930842b46e9507372f0b1b963James Dongt3          RN 14
1300c1bc742181ded4930842b46e9507372f0b1b963James Dongt4          RN 6
1310c1bc742181ded4930842b46e9507372f0b1b963James Dongt5          RN 5
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Allocate stack memory
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC4 ppThresholds,4
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC8 pAlphaBeta0,8
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC8 pAlphaBeta1,8
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC8 pXYBS,4
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC4 ppBS,4
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Function header
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_START omxVCM4P10_FilterDeblockingChroma_VerEdge_I, r11
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//Input arguments on the stack
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG   ppThresholdsArg, 4
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG   ppBSArg, 4
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB    alpha1, [pAlphaArg,#1]
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB    beta1,  [pBetaArg,#1]
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   pThresholds, ppThresholdsArg
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDR     a,=MASK_1
1520c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB    beta0,  [pBetaArg]
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   pThresholds, ppThresholds
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB    alpha0, [pAlphaArg]
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong        MUL     alpha1, alpha1, a
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong        MUL     beta1, beta1, a
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong        MUL     alpha0, alpha0, a
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong        MUL     beta0, beta0, a
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRD  alpha1, beta1, pAlphaBeta1
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   pBS, ppBSArg
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRD  alpha0, beta0, pAlphaBeta0
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDR     XY,=LOOP_COUNT
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRD  XY, pBS, pXYBS
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong
1690c1bc742181ded4930842b46e9507372f0b1b963James DongLoopY
1700c1bc742181ded4930842b46e9507372f0b1b963James DongLoopX
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong;//---------------Load Pixels-------------------
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong;//----------------Pack q0-q1-----------------------
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRH    bS, [pBS], #8
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDR     mask, =MASK_2
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRH  row4, [pQ0], srcdstStep
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP     bS, #0
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   pBS, ppBS
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRH  row5, [pQ0], srcdstStep
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ.W   NoFilterBS0
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRH    row6, [pQ0]
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRH    row7, [pQ0, srcdstStep]
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row4 = [0 0 r0q0 r0q1]
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row5 = [0 0 r1q0 r1q1]
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row6 = [0 0 r2q0 r2q1]
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row7 = [0 0 r3q0 r3q1]
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk4, mask, row4
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk5, mask, row4, LSL#8
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk4, tunpk4, row5, ROR#8
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk5, tunpk5, row5
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk6, mask, row6
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk7, mask, row6, LSL#8
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk6, tunpk6, row7, ROR#8
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk7, tunpk7, row7
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk4 = [0 0 r0q0 r1q0]
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk5 = [0 0 r0q1 r1q1]
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk6 = [0 0 r2q0 r3q0]
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk7 = [0 0 r2q1 r3q1]
2030c1bc742181ded4930842b46e9507372f0b1b963James Dong
2040c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pQ0, pQ0, srcdstStep, LSL #1
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pQ0, pQ0, #2
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong        PKHBT   q_1, tunpk6, tunpk4, LSL#16
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong        PKHBT   q_0, tunpk7, tunpk5, LSL#16
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// q_0 = [r0q0 r1q0 r2q0 r3q0]
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// q_1 = [r0q1 r1q1 r2q1 r3q1]
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong
2130c1bc742181ded4930842b46e9507372f0b1b963James Dong
2140c1bc742181ded4930842b46e9507372f0b1b963James Dong;//----------------Pack p0-p1-----------------------
2150c1bc742181ded4930842b46e9507372f0b1b963James Dong
2160c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRH  row0, [pQ0], srcdstStep
2170c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRH  row1, [pQ0], srcdstStep
2180c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRH    row2, [pQ0]
2190c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRH    row3, [pQ0, srcdstStep]
2200c1bc742181ded4930842b46e9507372f0b1b963James Dong
2210c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row0 = [0 0 r0p0 r0p1]
2220c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row1 = [0 0 r1p0 r1p1]
2230c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row2 = [0 0 r2p0 r2p1]
2240c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// row3 = [0 0 r3p0 r3p1]
2250c1bc742181ded4930842b46e9507372f0b1b963James Dong
2260c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk2, mask, row0
2270c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk6, mask, row0, LSL#8
2280c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk2, tunpk2, row1, ROR#8
2290c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk6, tunpk6, row1
2300c1bc742181ded4930842b46e9507372f0b1b963James Dong
2310c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk0, mask, row2
2320c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     tunpk3, mask, row2, LSL#8
2330c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk0, tunpk0, row3, ROR#8
2340c1bc742181ded4930842b46e9507372f0b1b963James Dong        UXTAB   tunpk3, tunpk3, row3
2350c1bc742181ded4930842b46e9507372f0b1b963James Dong
2360c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk2 = [0 0 r0p0 r1p0]
2370c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk6 = [0 0 r0p1 r1p1]
2380c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk0 = [0 0 r2p0 r3p0]
2390c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// tunpk3 = [0 0 r2p1 r3p1]
2400c1bc742181ded4930842b46e9507372f0b1b963James Dong
2410c1bc742181ded4930842b46e9507372f0b1b963James Dong        PKHBT   p_0, tunpk0, tunpk2, LSL#16
2420c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   bSTemp, ppBS
2430c1bc742181ded4930842b46e9507372f0b1b963James Dong        PKHBT   p_1, tunpk3, tunpk6, LSL#16
2440c1bc742181ded4930842b46e9507372f0b1b963James Dong
2450c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// p_0 = [r0p0 r1p0 r2p0 r3p0]
2460c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// p_1 = [r0p1 r1p1 r2p1 r3p1]
2470c1bc742181ded4930842b46e9507372f0b1b963James Dong
2480c1bc742181ded4930842b46e9507372f0b1b963James Dong;//--------------Filtering Decision -------------------
2490c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   dp0q0, p_0, q_0
2500c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDR     m01, =MASK_1
2510c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRH    bSTemp, [bSTemp ,#-8]
2520c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     m00, #MASK_0                ;//  00000000 mask
2530c1bc742181ded4930842b46e9507372f0b1b963James Dong
2540c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     filt, m01
2550c1bc742181ded4930842b46e9507372f0b1b963James Dong        TST     bSTemp, #0xff00
2560c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ   filt, filt, LSL #16
2570c1bc742181ded4930842b46e9507372f0b1b963James Dong        TST     bSTemp, #0xff
2580c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ   filt, filt, LSR #16
2590c1bc742181ded4930842b46e9507372f0b1b963James Dong        TST     bSTemp, #4
2600c1bc742181ded4930842b46e9507372f0b1b963James Dong
2610c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Check |p0-q0|<Alpha
2620c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   a, q_0, p_0
2630c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     ap0q0, a, dp0q0
2640c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   a, ap0q0, alpha
2650c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     filt, m00, filt
2660c1bc742181ded4930842b46e9507372f0b1b963James Dong
2670c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Check |p1-p0|<Beta
2680c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   dp1p0, p_1, p_0
2690c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   a, p_0, p_1
2700c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     a, a, dp1p0
2710c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   a, a, beta
2720c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     filt, m00, filt
2730c1bc742181ded4930842b46e9507372f0b1b963James Dong
2740c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Check |q1-q0|<Beta
2750c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   dq1q0, q_1, q_0
2760c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   a, q_0, q_1
2770c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     a, a, dq1q0
2780c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   a, a, beta
2790c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     filt, m00, filt
2800c1bc742181ded4930842b46e9507372f0b1b963James Dong
2810c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ     bSLT4
2820c1bc742181ded4930842b46e9507372f0b1b963James Dong;//-------------------Filter--------------------
2830c1bc742181ded4930842b46e9507372f0b1b963James DongbSGE4
2840c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//---------bSGE4 Execution---------------
2850c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP     filt, #0
2860c1bc742181ded4930842b46e9507372f0b1b963James Dong
2870c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   pThresholds, ppThresholds
2880c1bc742181ded4930842b46e9507372f0b1b963James Dong
2890c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Compute P0b
2900c1bc742181ded4930842b46e9507372f0b1b963James Dong        UHADD8  t1, p_0, q_1
2910c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ     NoFilterFilt0
2920c1bc742181ded4930842b46e9507372f0b1b963James Dong        MVN     t2, p_1
2930c1bc742181ded4930842b46e9507372f0b1b963James Dong        UHSUB8  t1, t1, t2
2940c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t2, filt, m01
2950c1bc742181ded4930842b46e9507372f0b1b963James Dong        EOR     t1, t1, m01, LSL #7
2960c1bc742181ded4930842b46e9507372f0b1b963James Dong
2970c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD     pThresholds,pThresholds, #4
2980c1bc742181ded4930842b46e9507372f0b1b963James Dong
2990c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Compute Q0b
3000c1bc742181ded4930842b46e9507372f0b1b963James Dong        UHADD8  t2, q_0, p_1
3010c1bc742181ded4930842b46e9507372f0b1b963James Dong        MVN     t3, q_1
3020c1bc742181ded4930842b46e9507372f0b1b963James Dong        UHSUB8  t2, t2, t3
3030c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   pThresholds, ppThresholds
3040c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     P_0, t1, p_0
3050c1bc742181ded4930842b46e9507372f0b1b963James Dong        EOR     t2, t2, m01, LSL #7
3060c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     Q_0, t2, q_0
3070c1bc742181ded4930842b46e9507372f0b1b963James Dong
3080c1bc742181ded4930842b46e9507372f0b1b963James Dong        B       StoreResultAndExit
3090c1bc742181ded4930842b46e9507372f0b1b963James Dong
3100c1bc742181ded4930842b46e9507372f0b1b963James Dong;//---------- Exit of LoopX --------------
3110c1bc742181ded4930842b46e9507372f0b1b963James Dong;//---- for the case of no filtering -----
3120c1bc742181ded4930842b46e9507372f0b1b963James Dong
3130c1bc742181ded4930842b46e9507372f0b1b963James DongNoFilterFilt0
3140c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD     pQ0, pQ0, #2
3150c1bc742181ded4930842b46e9507372f0b1b963James DongNoFilterBS0
3160c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   pThresholds, ppThresholds
3170c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pQ0, pQ0, srcdstStep, LSL #1
3180c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD     pQ0, pQ0, #4
3190c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD     pThresholds, pThresholds, #4
3200c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load counter for LoopX
3210c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRD  XY, pBS, pXYBS
3220c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   pThresholds, ppThresholds
3230c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRD  alpha, beta, pAlphaBeta1
3240c1bc742181ded4930842b46e9507372f0b1b963James Dong
3250c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Align the pointer
3260c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDS    XY, XY, XY
3270c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   XY, pXYBS
3280c1bc742181ded4930842b46e9507372f0b1b963James Dong        BCC     LoopY
3290c1bc742181ded4930842b46e9507372f0b1b963James Dong        B       ExitLoopY
3300c1bc742181ded4930842b46e9507372f0b1b963James Dong
3310c1bc742181ded4930842b46e9507372f0b1b963James DongbSLT4
3320c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//---------bSLT4 Execution---------------
3330c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   pThresholds, ppThresholds
3340c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP     filt, #0
3350c1bc742181ded4930842b46e9507372f0b1b963James Dong
3360c1bc742181ded4930842b46e9507372f0b1b963James Dong
3370c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Since beta <= 18 and alpha <= 255 we know
3380c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// -254 <= p0-q0 <= 254
3390c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//  -17 <= q1-q0 <= 17
3400c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//  -17 <= p1-p0 <= 17
3410c1bc742181ded4930842b46e9507372f0b1b963James Dong
3420c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// delta = Clip3( -tC, tC, ((((q0-p0)<<2) + (p1-q1) + 4)>>3))
3430c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//
3440c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//    Calculate A = (((q0-p0)<<2) + (p1-q1) + 4)>>3
3450c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//                = (4*q0 - 4*p0 + p1 - q1 + 4)>>3
3460c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//                = ((p1-p0) - (q1-q0) - 3*(p0-q0) + 4)>>3
3470c1bc742181ded4930842b46e9507372f0b1b963James Dong
3480c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t1, p_1, p_0
3490c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t2, q_1, q_0
3500c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ     NoFilterFilt0
3510c1bc742181ded4930842b46e9507372f0b1b963James Dong
3520c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB    tC0, [pThresholds], #1
3530c1bc742181ded4930842b46e9507372f0b1b963James Dong        SSUB8   t1, t1, t2
3540c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB    tC1, [pThresholds], #3
3550c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   pThresholds, ppThresholds
3560c1bc742181ded4930842b46e9507372f0b1b963James Dong        UHSUB8  t4, p_0, q_0
3570c1bc742181ded4930842b46e9507372f0b1b963James Dong        ORR     tC, tC1, tC0, LSL #16
3580c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t5, p_0, q_0
3590c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND     t5, t5, m01
3600c1bc742181ded4930842b46e9507372f0b1b963James Dong        SHSUB8  t1, t1, t5
3610c1bc742181ded4930842b46e9507372f0b1b963James Dong        ORR     tC, tC, LSL #8
3620c1bc742181ded4930842b46e9507372f0b1b963James Dong        SSUB8   t1, t1, t5
3630c1bc742181ded4930842b46e9507372f0b1b963James Dong        SHSUB8  t1, t1, t4
3640c1bc742181ded4930842b46e9507372f0b1b963James Dong        UQADD8  tC, tC, m01
3650c1bc742181ded4930842b46e9507372f0b1b963James Dong        SADD8   t1, t1, m01
3660c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t5, filt, m01
3670c1bc742181ded4930842b46e9507372f0b1b963James Dong        SHSUB8  t1, t1, t4
3680c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     tC, tC, m00
3690c1bc742181ded4930842b46e9507372f0b1b963James Dong
3700c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Split into positive and negative part and clip
3710c1bc742181ded4930842b46e9507372f0b1b963James Dong
3720c1bc742181ded4930842b46e9507372f0b1b963James Dong        SSUB8   t1, t1, m00
3730c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     pos, t1, m00
3740c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   neg, pos, t1
3750c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t3, pos, tC
3760c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     pos, tC, pos
3770c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t3, neg, tC
3780c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     neg, tC, neg
3790c1bc742181ded4930842b46e9507372f0b1b963James Dong        UQADD8  P_0, p_0, pos
3800c1bc742181ded4930842b46e9507372f0b1b963James Dong        UQSUB8  Q_0, q_0, pos
3810c1bc742181ded4930842b46e9507372f0b1b963James Dong        UQSUB8  P_0, P_0, neg
3820c1bc742181ded4930842b46e9507372f0b1b963James Dong        UQADD8  Q_0, Q_0, neg
3830c1bc742181ded4930842b46e9507372f0b1b963James Dong
3840c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Choose to store the filtered
3850c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// value or the original pixel
3860c1bc742181ded4930842b46e9507372f0b1b963James Dong        USUB8   t1, filt, m01
3870c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     P_0, P_0, p_0
3880c1bc742181ded4930842b46e9507372f0b1b963James Dong        SEL     Q_0, Q_0, q_0
3890c1bc742181ded4930842b46e9507372f0b1b963James Dong
3900c1bc742181ded4930842b46e9507372f0b1b963James DongStoreResultAndExit
3910c1bc742181ded4930842b46e9507372f0b1b963James Dong
3920c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//---------Store result---------------
3930c1bc742181ded4930842b46e9507372f0b1b963James Dong
3940c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// P_0 = [r0p0 r1p0 r2p0 r3p0]
3950c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Q_0 = [r0q0 r1q0 r2q0 r3q0]
3960c1bc742181ded4930842b46e9507372f0b1b963James Dong
3970c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pQ0, pQ0, srcdstStep, LSL #1
3980c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD        pQ0, pQ0, #1
3990c1bc742181ded4930842b46e9507372f0b1b963James Dong
4000c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     t1, Q_0, LSR #24
4010c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRB    t1, [pQ0, #1]
4020c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     t1, P_0, LSR #24
4030c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRB  t1, [pQ0], srcdstStep
4040c1bc742181ded4930842b46e9507372f0b1b963James Dong
4050c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     t1, Q_0, LSR #16
4060c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRB    t1, [pQ0, #1]
4070c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     t1, P_0, LSR #16
4080c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STRB  t1, [pQ0], srcdstStep
4090c1bc742181ded4930842b46e9507372f0b1b963James Dong
4100c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     t1, P_0, LSR #8
4110c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRB    t1, [pQ0]
4120c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRB    P_0, [pQ0, srcdstStep]
4130c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     t1, Q_0, LSR #8
4140c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRB    t1, [pQ0, #1]!
4150c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRB    Q_0, [pQ0, srcdstStep]
4160c1bc742181ded4930842b46e9507372f0b1b963James Dong
4170c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRD  XY, pBS, pXYBS
4180c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRD  alpha, beta, pAlphaBeta1
4190c1bc742181ded4930842b46e9507372f0b1b963James Dong
4200c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pQ0, pQ0, srcdstStep, LSL #1
4210c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD     pQ0, pQ0, #4
4220c1bc742181ded4930842b46e9507372f0b1b963James Dong
4230c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADDS    XY, XY, XY
4240c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   XY, pXYBS
4250c1bc742181ded4930842b46e9507372f0b1b963James Dong        BCC     LoopX
4260c1bc742181ded4930842b46e9507372f0b1b963James Dong
4270c1bc742181ded4930842b46e9507372f0b1b963James Dong;//-------- Common Exit of LoopY -----------------
4280c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Align the pointers
4290c1bc742181ded4930842b46e9507372f0b1b963James Dong
4300c1bc742181ded4930842b46e9507372f0b1b963James DongExitLoopY
4310c1bc742181ded4930842b46e9507372f0b1b963James Dong
4320c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR   pThresholds, ppThresholds
4330c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pQ0, pQ0, #8
4340c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD     pQ0, pQ0, srcdstStep, LSL #2
4350c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pBS, pBS, #14
4360c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB     pThresholds, pThresholds, #6
4370c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR   pThresholds, ppThresholds
4380c1bc742181ded4930842b46e9507372f0b1b963James Dong
4390c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDRD  alpha, beta, pAlphaBeta0
4400c1bc742181ded4930842b46e9507372f0b1b963James Dong
4410c1bc742181ded4930842b46e9507372f0b1b963James Dong        BNE     LoopY
4420c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV     r0, #OMX_Sts_NoErr
4430c1bc742181ded4930842b46e9507372f0b1b963James Dong;//-----------------End Filter--------------------
4440c1bc742181ded4930842b46e9507372f0b1b963James Dong
4450c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_END
4460c1bc742181ded4930842b46e9507372f0b1b963James Dong
4470c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
4480c1bc742181ded4930842b46e9507372f0b1b963James Dong
4490c1bc742181ded4930842b46e9507372f0b1b963James Dong        END
4500c1bc742181ded4930842b46e9507372f0b1b963James Dong
4510c1bc742181ded4930842b46e9507372f0b1b963James Dong
452