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