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:  armVCM4P2_DecodeVLCZigzag_AC_unsafe_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; * Description:
270c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Contains modules for zigzag scanning and VLC decoding
280c1bc742181ded4930842b46e9507372f0b1b963James Dong; * for inter, intra block.
290c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
300c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
310c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
320c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Function: omxVCM4P2_DecodeVLCZigzag_AC_unsafe
330c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
340c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Description:
350c1bc742181ded4930842b46e9507372f0b1b963James Dong; * Performs VLC decoding and inverse zigzag scan
360c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
370c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
380c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
390c1bc742181ded4930842b46e9507372f0b1b963James Dong; *
400c1bc742181ded4930842b46e9507372f0b1b963James Dong; */
410c1bc742181ded4930842b46e9507372f0b1b963James Dong
420c1bc742181ded4930842b46e9507372f0b1b963James Dong
430c1bc742181ded4930842b46e9507372f0b1b963James Dong      INCLUDE omxtypes_s.h
440c1bc742181ded4930842b46e9507372f0b1b963James Dong      INCLUDE armCOMM_s.h
450c1bc742181ded4930842b46e9507372f0b1b963James Dong      INCLUDE armCOMM_BitDec_s.h
460c1bc742181ded4930842b46e9507372f0b1b963James Dong
470c1bc742181ded4930842b46e9507372f0b1b963James Dong
480c1bc742181ded4930842b46e9507372f0b1b963James Dong      M_VARIANTS ARM1136JS
490c1bc742181ded4930842b46e9507372f0b1b963James Dong
500c1bc742181ded4930842b46e9507372f0b1b963James Dong
510c1bc742181ded4930842b46e9507372f0b1b963James Dong
520c1bc742181ded4930842b46e9507372f0b1b963James Dong
530c1bc742181ded4930842b46e9507372f0b1b963James Dong
540c1bc742181ded4930842b46e9507372f0b1b963James Dong     IF ARM1136JS
550c1bc742181ded4930842b46e9507372f0b1b963James Dong
560c1bc742181ded4930842b46e9507372f0b1b963James Dong
570c1bc742181ded4930842b46e9507372f0b1b963James Dong
580c1bc742181ded4930842b46e9507372f0b1b963James Dong
590c1bc742181ded4930842b46e9507372f0b1b963James Dong
600c1bc742181ded4930842b46e9507372f0b1b963James Dong;//Input Arguments
610c1bc742181ded4930842b46e9507372f0b1b963James Dong
620c1bc742181ded4930842b46e9507372f0b1b963James DongppBitStream          RN 0
630c1bc742181ded4930842b46e9507372f0b1b963James DongpBitOffset           RN 1
640c1bc742181ded4930842b46e9507372f0b1b963James DongpDst                 RN 2
650c1bc742181ded4930842b46e9507372f0b1b963James DongshortVideoHeader     RN 3
660c1bc742181ded4930842b46e9507372f0b1b963James Dong
670c1bc742181ded4930842b46e9507372f0b1b963James Dong
680c1bc742181ded4930842b46e9507372f0b1b963James Dong;//Local Variables
690c1bc742181ded4930842b46e9507372f0b1b963James Dong
700c1bc742181ded4930842b46e9507372f0b1b963James DongReturn               RN 0
710c1bc742181ded4930842b46e9507372f0b1b963James Dong
720c1bc742181ded4930842b46e9507372f0b1b963James DongpVlcTableL0L1        RN 4
730c1bc742181ded4930842b46e9507372f0b1b963James DongpLMAXTableL0L1       RN 4
740c1bc742181ded4930842b46e9507372f0b1b963James DongpRMAXTableL0L1       RN 4
750c1bc742181ded4930842b46e9507372f0b1b963James DongpZigzagTable         RN 4
760c1bc742181ded4930842b46e9507372f0b1b963James Dong
770c1bc742181ded4930842b46e9507372f0b1b963James Dongftype                RN 0
780c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp3                RN 4
790c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp                 RN 5
800c1bc742181ded4930842b46e9507372f0b1b963James DongCount                RN 6
810c1bc742181ded4930842b46e9507372f0b1b963James DongEscape               RN 5
820c1bc742181ded4930842b46e9507372f0b1b963James Dong
830c1bc742181ded4930842b46e9507372f0b1b963James Dong;// armVCM4P2_FillVLDBuffer
840c1bc742181ded4930842b46e9507372f0b1b963James Dongzigzag               RN 0
850c1bc742181ded4930842b46e9507372f0b1b963James DongstoreLevel           RN 1
860c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp2                RN 4
870c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp1                RN 5
880c1bc742181ded4930842b46e9507372f0b1b963James Dongsign                 RN 5
890c1bc742181ded4930842b46e9507372f0b1b963James DongLast                 RN 7
900c1bc742181ded4930842b46e9507372f0b1b963James DongstoreRun             RN 14
910c1bc742181ded4930842b46e9507372f0b1b963James Dong
920c1bc742181ded4930842b46e9507372f0b1b963James Dong
930c1bc742181ded4930842b46e9507372f0b1b963James DongpackRetIndex         RN 5
940c1bc742181ded4930842b46e9507372f0b1b963James Dong
950c1bc742181ded4930842b46e9507372f0b1b963James Dong
960c1bc742181ded4930842b46e9507372f0b1b963James Dongmarkerbit            RN 5
970c1bc742181ded4930842b46e9507372f0b1b963James Dong
980c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Scratch Registers
990c1bc742181ded4930842b46e9507372f0b1b963James Dong
1000c1bc742181ded4930842b46e9507372f0b1b963James DongRBitStream           RN 8
1010c1bc742181ded4930842b46e9507372f0b1b963James DongRBitBuffer           RN 9
1020c1bc742181ded4930842b46e9507372f0b1b963James DongRBitCount            RN 10
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong
1040c1bc742181ded4930842b46e9507372f0b1b963James DongT1                   RN 11
1050c1bc742181ded4930842b46e9507372f0b1b963James DongT2                   RN 12
1060c1bc742181ded4930842b46e9507372f0b1b963James DongLR                   RN 14
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC4        pppBitStream,4
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC4        ppOffset,4
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ALLOC4        pLinkRegister,4
1130c1bc742181ded4930842b46e9507372f0b1b963James Dong
1140c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_START armVCM4P2_DecodeVLCZigzag_AC_unsafe
1150c1bc742181ded4930842b46e9507372f0b1b963James Dong
1160c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// get the table addresses from stack
1170c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG           ppVlcTableL0L1,4
1180c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG           ppLMAXTableL0L1,4
1190c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG           ppRMAXTableL0L1,4
1200c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_ARG           ppZigzagTable,4
1210c1bc742181ded4930842b46e9507372f0b1b963James Dong
1220c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Store ALL zeros at pDst
1230c1bc742181ded4930842b46e9507372f0b1b963James Dong
1240c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV             temp1,#0                                        ;// Initialize Count to zero
1250c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV             Last,#0
1260c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR           LR,pLinkRegister                                ;// Store Link Register on Stack
1270c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV             temp2,#0
1280c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV             LR,#0
1290c1bc742181ded4930842b46e9507372f0b1b963James Dong
1300c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Initialize the Macro and Store all zeros to pDst
1310c1bc742181ded4930842b46e9507372f0b1b963James Dong
1320c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1330c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_INIT0      ppBitStream, pBitOffset, RBitStream, RBitBuffer, RBitCount
1340c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1350c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_INIT1      T1, T2, T2
1360c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1370c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_INIT2      T1, T2, T2
1380c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1390c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR           ppBitStream,pppBitStream                        ;// Store ppBitstream on stack
1400c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1410c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_STR           pBitOffset,ppOffset                             ;// Store pBitOffset on stack
1420c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1430c1bc742181ded4930842b46e9507372f0b1b963James Dong
1440c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1450c1bc742181ded4930842b46e9507372f0b1b963James Dong        STM             pDst!,{temp2,temp1,Last,LR}
1460c1bc742181ded4930842b46e9507372f0b1b963James Dong
1470c1bc742181ded4930842b46e9507372f0b1b963James Dong
1480c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB             pDst,pDst,#128                                  ;// Restore pDst
1490c1bc742181ded4930842b46e9507372f0b1b963James Dong
1500c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// The armVCM4P2_GetVLCBits begins
1510c1bc742181ded4930842b46e9507372f0b1b963James Dong
1520c1bc742181ded4930842b46e9507372f0b1b963James DonggetVLCbits
1530c1bc742181ded4930842b46e9507372f0b1b963James Dong
1540c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_LOOK8      Escape,7                                        ;// Load Escape Value
1550c1bc742181ded4930842b46e9507372f0b1b963James Dong        LSR             Escape,Escape,#25
1560c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             Escape,#3                                       ;// check for escape mode
1570c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVNE           ftype,#0
1580c1bc742181ded4930842b46e9507372f0b1b963James Dong        BNE             notEscapemode                                   ;// Branch if not in Escape mode 3
1590c1bc742181ded4930842b46e9507372f0b1b963James Dong
1600c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_VSKIP8     #7,T1
1610c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             shortVideoHeader,#0                             ;// Check shortVideoHeader flag to know the type of Escape mode
1620c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ             endFillVLD
1630c1bc742181ded4930842b46e9507372f0b1b963James Dong
1640c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Escape Mode 4
1650c1bc742181ded4930842b46e9507372f0b1b963James Dong
1660c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      Last,1,T1
1670c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      storeRun,6,T1
1680c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      storeLevel,8,T1
1690c1bc742181ded4930842b46e9507372f0b1b963James Dong
1700c1bc742181ded4930842b46e9507372f0b1b963James Dong
1710c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Check whether the Reserved values for Level are used and Exit with an Error Message if it is so
1720c1bc742181ded4930842b46e9507372f0b1b963James Dong
1730c1bc742181ded4930842b46e9507372f0b1b963James Dong        TEQ             storeLevel,#0
1740c1bc742181ded4930842b46e9507372f0b1b963James Dong        TEQNE           storeLevel,#128
1750c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ             ExitError
1760c1bc742181ded4930842b46e9507372f0b1b963James Dong
1770c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             temp2,storeRun,Count
1780c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             temp2,#64
1790c1bc742181ded4930842b46e9507372f0b1b963James Dong        BGE             ExitError                                       ;// error if Count+storeRun >= 64
1800c1bc742181ded4930842b46e9507372f0b1b963James Dong
1810c1bc742181ded4930842b46e9507372f0b1b963James Dong
1820c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load address of zigzagTable
1830c1bc742181ded4930842b46e9507372f0b1b963James Dong
1840c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pZigzagTable,ppZigzagTable                      ;// Loading the Address of Zigzag table
1850c1bc742181ded4930842b46e9507372f0b1b963James Dong
1860c1bc742181ded4930842b46e9507372f0b1b963James Dong
1870c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// armVCM4P2_FillVLDBuffer
1880c1bc742181ded4930842b46e9507372f0b1b963James Dong
1890c1bc742181ded4930842b46e9507372f0b1b963James Dong        SXTB            storeLevel,storeLevel                           ;// Sign Extend storeLevel to 32 bits
1900c1bc742181ded4930842b46e9507372f0b1b963James Dong
1910c1bc742181ded4930842b46e9507372f0b1b963James Dong
1920c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// To Reflect Runlength
1930c1bc742181ded4930842b46e9507372f0b1b963James Dong
1940c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             Count,Count,storeRun
1950c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB            zigzag,[pZigzagTable,Count]
1960c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             Count,Count,#1
1970c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRH            storeLevel,[pDst,zigzag]                        ;// store Level
1980c1bc742181ded4930842b46e9507372f0b1b963James Dong
1990c1bc742181ded4930842b46e9507372f0b1b963James Dong        B               ExitOk
2000c1bc742181ded4930842b46e9507372f0b1b963James Dong
2010c1bc742181ded4930842b46e9507372f0b1b963James Dong
2020c1bc742181ded4930842b46e9507372f0b1b963James Dong
2030c1bc742181ded4930842b46e9507372f0b1b963James DongendFillVLD
2040c1bc742181ded4930842b46e9507372f0b1b963James Dong
2050c1bc742181ded4930842b46e9507372f0b1b963James Dong
2060c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load Ftype( Escape Mode) value based on the two successive bits in the bitstream
2070c1bc742181ded4930842b46e9507372f0b1b963James Dong
2080c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      temp1,1,T1
2090c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             temp1,#0
2100c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ           ftype,#1
2110c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ             notEscapemode
2120c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      temp1,1,T1
2130c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             temp1,#1
2140c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ           ftype,#3
2150c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVNE           ftype,#2
2160c1bc742181ded4930842b46e9507372f0b1b963James Dong
2170c1bc742181ded4930842b46e9507372f0b1b963James Dong
2180c1bc742181ded4930842b46e9507372f0b1b963James DongnotEscapemode
2190c1bc742181ded4930842b46e9507372f0b1b963James Dong
2200c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Load optimized packed VLC table with last=0 and Last=1
2210c1bc742181ded4930842b46e9507372f0b1b963James Dong
2220c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pVlcTableL0L1,ppVlcTableL0L1                    ;// Load Combined VLC Table
2230c1bc742181ded4930842b46e9507372f0b1b963James Dong
2240c1bc742181ded4930842b46e9507372f0b1b963James Dong
2250c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             ftype,#3                                        ;// If ftype >=3 get perform Fixed Length Decoding (Escape Mode 3)
2260c1bc742181ded4930842b46e9507372f0b1b963James Dong        BGE             EscapeMode3                                     ;// Else continue normal VLC Decoding
2270c1bc742181ded4930842b46e9507372f0b1b963James Dong
2280c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Variable lengh decoding, "armUnPackVLC32"
2290c1bc742181ded4930842b46e9507372f0b1b963James Dong
2300c1bc742181ded4930842b46e9507372f0b1b963James Dong
2310c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_VLD        packRetIndex,T1,T2,pVlcTableL0L1,4,2
2320c1bc742181ded4930842b46e9507372f0b1b963James Dong
2330c1bc742181ded4930842b46e9507372f0b1b963James Dong
2340c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDR             temp3,=0xFFF
2350c1bc742181ded4930842b46e9507372f0b1b963James Dong
2360c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             packRetIndex,temp3                              ;// Check for invalid symbol
2370c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ             ExitError                                       ;// if invalid symbol occurs exit with an error message
2380c1bc742181ded4930842b46e9507372f0b1b963James Dong
2390c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND             Last,packRetIndex,#2                            ;// Get Last from packed Index
2400c1bc742181ded4930842b46e9507372f0b1b963James Dong
2410c1bc742181ded4930842b46e9507372f0b1b963James Dong
2420c1bc742181ded4930842b46e9507372f0b1b963James Dong
2430c1bc742181ded4930842b46e9507372f0b1b963James Dong
2440c1bc742181ded4930842b46e9507372f0b1b963James Dong        LSR             storeRun,packRetIndex,#7                        ;// Get Run Value from Packed index
2450c1bc742181ded4930842b46e9507372f0b1b963James Dong        AND             storeLevel,packRetIndex,#0x7c                   ;// storeLevel=packRetIndex[2-6],storeLevel[0-1]=0
2460c1bc742181ded4930842b46e9507372f0b1b963James Dong
2470c1bc742181ded4930842b46e9507372f0b1b963James Dong
2480c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pLMAXTableL0L1,ppLMAXTableL0L1                  ;// Load LMAX table
2490c1bc742181ded4930842b46e9507372f0b1b963James Dong
2500c1bc742181ded4930842b46e9507372f0b1b963James Dong
2510c1bc742181ded4930842b46e9507372f0b1b963James Dong        LSR             storeLevel,storeLevel,#2                        ;// Level value
2520c1bc742181ded4930842b46e9507372f0b1b963James Dong
2530c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             ftype,#1
2540c1bc742181ded4930842b46e9507372f0b1b963James Dong        BNE             ftype2
2550c1bc742181ded4930842b46e9507372f0b1b963James Dong
2560c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// ftype==1; Escape mode =1
2570c1bc742181ded4930842b46e9507372f0b1b963James Dong
2580c1bc742181ded4930842b46e9507372f0b1b963James Dong
2590c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD            temp1, pLMAXTableL0L1, Last, LSL#4              ;// If the Last=1 add 32 to table address
2600c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB            temp1,[temp1,storeRun]
2610c1bc742181ded4930842b46e9507372f0b1b963James Dong
2620c1bc742181ded4930842b46e9507372f0b1b963James Dong
2630c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             storeLevel,temp1,storeLevel
2640c1bc742181ded4930842b46e9507372f0b1b963James Dong
2650c1bc742181ded4930842b46e9507372f0b1b963James Dongftype2
2660c1bc742181ded4930842b46e9507372f0b1b963James Dong
2670c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// ftype =2; Escape mode =2
2680c1bc742181ded4930842b46e9507372f0b1b963James Dong
2690c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pRMAXTableL0L1,ppRMAXTableL0L1                  ;// Load RMAX Table
2700c1bc742181ded4930842b46e9507372f0b1b963James Dong
2710c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             ftype,#2
2720c1bc742181ded4930842b46e9507372f0b1b963James Dong        BNE             FillVLDL1
2730c1bc742181ded4930842b46e9507372f0b1b963James Dong
2740c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD            temp1, pRMAXTableL0L1, Last, LSL#4               ;// If Last=1 add 32 to table address
2750c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUB             temp2,storeLevel,#1
2760c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB            temp1,[temp1,temp2]
2770c1bc742181ded4930842b46e9507372f0b1b963James Dong
2780c1bc742181ded4930842b46e9507372f0b1b963James Dong
2790c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             storeRun,storeRun,#1
2800c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             storeRun,temp1
2810c1bc742181ded4930842b46e9507372f0b1b963James Dong
2820c1bc742181ded4930842b46e9507372f0b1b963James DongFillVLDL1
2830c1bc742181ded4930842b46e9507372f0b1b963James Dong
2840c1bc742181ded4930842b46e9507372f0b1b963James Dong
2850c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// armVCM4P2_FillVLDBuffer
2860c1bc742181ded4930842b46e9507372f0b1b963James Dong
2870c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pZigzagTable,ppZigzagTable                     ;// Load address of zigzagTable
2880c1bc742181ded4930842b46e9507372f0b1b963James Dong
2890c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      sign,1,T1
2900c1bc742181ded4930842b46e9507372f0b1b963James Dong
2910c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             sign,#1
2920c1bc742181ded4930842b46e9507372f0b1b963James Dong        RSBEQ           storeLevel,storeLevel,#0
2930c1bc742181ded4930842b46e9507372f0b1b963James Dong
2940c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             temp1,storeRun,Count                           ;// Exit with an error message if Run + Count exceeds 63
2950c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             temp1,#64
2960c1bc742181ded4930842b46e9507372f0b1b963James Dong        BGE             ExitError
2970c1bc742181ded4930842b46e9507372f0b1b963James Dong
2980c1bc742181ded4930842b46e9507372f0b1b963James Dong
2990c1bc742181ded4930842b46e9507372f0b1b963James Dong
3000c1bc742181ded4930842b46e9507372f0b1b963James Dong
3010c1bc742181ded4930842b46e9507372f0b1b963James Dong
3020c1bc742181ded4930842b46e9507372f0b1b963James Dong
3030c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// To Reflect Runlenght
3040c1bc742181ded4930842b46e9507372f0b1b963James Dong
3050c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             Count,Count,storeRun
3060c1bc742181ded4930842b46e9507372f0b1b963James Dong
3070c1bc742181ded4930842b46e9507372f0b1b963James DongstoreLevelL1
3080c1bc742181ded4930842b46e9507372f0b1b963James Dong
3090c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB            zigzag,[pZigzagTable,Count]
3100c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             Last,#2                                         ;// Check if the Level val is Last non zero val
3110c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             Count,Count,#1
3120c1bc742181ded4930842b46e9507372f0b1b963James Dong        LSR             Last,Last,#1
3130c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRH            storeLevel,[pDst,zigzag]
3140c1bc742181ded4930842b46e9507372f0b1b963James Dong
3150c1bc742181ded4930842b46e9507372f0b1b963James Dong        BNE             end
3160c1bc742181ded4930842b46e9507372f0b1b963James Dong
3170c1bc742181ded4930842b46e9507372f0b1b963James Dong        B               ExitOk
3180c1bc742181ded4930842b46e9507372f0b1b963James Dong
3190c1bc742181ded4930842b46e9507372f0b1b963James Dong
3200c1bc742181ded4930842b46e9507372f0b1b963James Dong
3210c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Fixed Lengh Decoding Escape Mode 3
3220c1bc742181ded4930842b46e9507372f0b1b963James Dong
3230c1bc742181ded4930842b46e9507372f0b1b963James DongEscapeMode3
3240c1bc742181ded4930842b46e9507372f0b1b963James Dong
3250c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      Last,1,T1
3260c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      storeRun,6,T1
3270c1bc742181ded4930842b46e9507372f0b1b963James Dong
3280c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             temp2,storeRun,Count                            ;// Exit with an error message if Run + Count exceeds 63
3290c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             temp2,#64
3300c1bc742181ded4930842b46e9507372f0b1b963James Dong        BGE             ExitError
3310c1bc742181ded4930842b46e9507372f0b1b963James Dong
3320c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      markerbit,1,T1
3330c1bc742181ded4930842b46e9507372f0b1b963James Dong        TEQ             markerbit,#0                                    ;// Exit with an error message if marker bit is zero
3340c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ             ExitError
3350c1bc742181ded4930842b46e9507372f0b1b963James Dong
3360c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ16     storeLevel,12,T1
3370c1bc742181ded4930842b46e9507372f0b1b963James Dong
3380c1bc742181ded4930842b46e9507372f0b1b963James Dong        TST             storeLevel,#0x800                               ;// test if the level is negative
3390c1bc742181ded4930842b46e9507372f0b1b963James Dong        SUBNE           storeLevel,storeLevel,#4096
3400c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             storeLevel,#0
3410c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMPNE           storeLevel,#-2048
3420c1bc742181ded4930842b46e9507372f0b1b963James Dong        BEQ             ExitError                                       ;// Exit with an error message if Level==0 or  -2048
3430c1bc742181ded4930842b46e9507372f0b1b963James Dong
3440c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pZigzagTable,ppZigzagTable                      ;// Load address of zigzagTable
3450c1bc742181ded4930842b46e9507372f0b1b963James Dong
3460c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_READ8      markerbit,1,T1
3470c1bc742181ded4930842b46e9507372f0b1b963James Dong
3480c1bc742181ded4930842b46e9507372f0b1b963James Dong
3490c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// armVCM4P2_FillVLDBuffer ( Sign not used as storeLevel is preprocessed)
3500c1bc742181ded4930842b46e9507372f0b1b963James Dong
3510c1bc742181ded4930842b46e9507372f0b1b963James Dong
3520c1bc742181ded4930842b46e9507372f0b1b963James Dong
3530c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// To Reflect Run Length
3540c1bc742181ded4930842b46e9507372f0b1b963James Dong
3550c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             Count,Count,storeRun
3560c1bc742181ded4930842b46e9507372f0b1b963James Dong
3570c1bc742181ded4930842b46e9507372f0b1b963James Dong
3580c1bc742181ded4930842b46e9507372f0b1b963James Dong
3590c1bc742181ded4930842b46e9507372f0b1b963James DongstoreLevelLast
3600c1bc742181ded4930842b46e9507372f0b1b963James Dong
3610c1bc742181ded4930842b46e9507372f0b1b963James Dong        LDRB            zigzag,[pZigzagTable,Count]
3620c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             Last,#1
3630c1bc742181ded4930842b46e9507372f0b1b963James Dong        ADD             Count,Count,#1
3640c1bc742181ded4930842b46e9507372f0b1b963James Dong        STRH            storeLevel,[pDst,zigzag]
3650c1bc742181ded4930842b46e9507372f0b1b963James Dong
3660c1bc742181ded4930842b46e9507372f0b1b963James Dong        BNE             end
3670c1bc742181ded4930842b46e9507372f0b1b963James Dong
3680c1bc742181ded4930842b46e9507372f0b1b963James Dong        B               ExitOk
3690c1bc742181ded4930842b46e9507372f0b1b963James Dong
3700c1bc742181ded4930842b46e9507372f0b1b963James Dongend
3710c1bc742181ded4930842b46e9507372f0b1b963James Dong
3720c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             Count,#64                                       ;//Run the Loop untill Count reaches 64
3730c1bc742181ded4930842b46e9507372f0b1b963James Dong
3740c1bc742181ded4930842b46e9507372f0b1b963James Dong        BLT             getVLCbits
3750c1bc742181ded4930842b46e9507372f0b1b963James Dong
3760c1bc742181ded4930842b46e9507372f0b1b963James Dong
3770c1bc742181ded4930842b46e9507372f0b1b963James DongExitOk
3780c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Exit When VLC Decoding is done Successfully
3790c1bc742181ded4930842b46e9507372f0b1b963James Dong
3800c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Loading ppBitStream and pBitOffset from stack
3810c1bc742181ded4930842b46e9507372f0b1b963James Dong
3820c1bc742181ded4930842b46e9507372f0b1b963James Dong        CMP             Last,#1
3830c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           ppBitStream,pppBitStream
3840c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pBitOffset,ppOffset
3850c1bc742181ded4930842b46e9507372f0b1b963James Dong
3860c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//Ending the macro
3870c1bc742181ded4930842b46e9507372f0b1b963James Dong
3880c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_FINI       ppBitStream,pBitOffset
3890c1bc742181ded4930842b46e9507372f0b1b963James Dong
3900c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVEQ           Return,#OMX_Sts_NoErr
3910c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOVNE           Return,#OMX_Sts_Err
3920c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           LR,pLinkRegister                               ;// Load the Link Register Back
3930c1bc742181ded4930842b46e9507372f0b1b963James Dong        B               exit2
3940c1bc742181ded4930842b46e9507372f0b1b963James Dong
3950c1bc742181ded4930842b46e9507372f0b1b963James DongExitError
3960c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;// Exit When an Error occurs
3970c1bc742181ded4930842b46e9507372f0b1b963James Dong
3980c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           ppBitStream,pppBitStream
3990c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           pBitOffset,ppOffset
4000c1bc742181ded4930842b46e9507372f0b1b963James Dong        ;//Ending the macro
4010c1bc742181ded4930842b46e9507372f0b1b963James Dong
4020c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_BD_FINI       ppBitStream,pBitOffset
4030c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_LDR           LR,pLinkRegister
4040c1bc742181ded4930842b46e9507372f0b1b963James Dong        MOV             Return,#OMX_Sts_Err
4050c1bc742181ded4930842b46e9507372f0b1b963James Dong
4060c1bc742181ded4930842b46e9507372f0b1b963James Dongexit2
4070c1bc742181ded4930842b46e9507372f0b1b963James Dong
4080c1bc742181ded4930842b46e9507372f0b1b963James Dong
4090c1bc742181ded4930842b46e9507372f0b1b963James Dong        M_END
4100c1bc742181ded4930842b46e9507372f0b1b963James Dong        ENDIF
4110c1bc742181ded4930842b46e9507372f0b1b963James Dong
4120c1bc742181ded4930842b46e9507372f0b1b963James Dong        END
413