10c1bc742181ded4930842b46e9507372f0b1b963James Dong;// 20c1bc742181ded4930842b46e9507372f0b1b963James Dong;// 30c1bc742181ded4930842b46e9507372f0b1b963James Dong;// File Name: armVCM4P10_DecodeCoeffsToPair_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 130c1bc742181ded4930842b46e9507372f0b1b963James Dong INCLUDE omxtypes_s.h 140c1bc742181ded4930842b46e9507372f0b1b963James Dong INCLUDE armCOMM_s.h 150c1bc742181ded4930842b46e9507372f0b1b963James Dong INCLUDE armCOMM_BitDec_s.h 160c1bc742181ded4930842b46e9507372f0b1b963James Dong 170c1bc742181ded4930842b46e9507372f0b1b963James Dong IMPORT armVCM4P10_CAVLCCoeffTokenTables 180c1bc742181ded4930842b46e9507372f0b1b963James Dong IMPORT armVCM4P10_CAVLCTotalZeroTables 190c1bc742181ded4930842b46e9507372f0b1b963James Dong IMPORT armVCM4P10_CAVLCTotalZeros2x2Tables 200c1bc742181ded4930842b46e9507372f0b1b963James Dong IMPORT armVCM4P10_CAVLCRunBeforeTables 210c1bc742181ded4930842b46e9507372f0b1b963James Dong IMPORT armVCM4P10_SuffixToLevel 220c1bc742181ded4930842b46e9507372f0b1b963James Dong IMPORT armVCM4P10_ZigZag_4x4 230c1bc742181ded4930842b46e9507372f0b1b963James Dong IMPORT armVCM4P10_ZigZag_2x2 240c1bc742181ded4930842b46e9507372f0b1b963James Dong 250c1bc742181ded4930842b46e9507372f0b1b963James Dong M_VARIANTS ARM1136JS 260c1bc742181ded4930842b46e9507372f0b1b963James Dong 270c1bc742181ded4930842b46e9507372f0b1b963James Dong;//DEBUG_ON SETL {TRUE} 280c1bc742181ded4930842b46e9507372f0b1b963James Dong 290c1bc742181ded4930842b46e9507372f0b1b963James DongLAST_COEFF EQU 0x20 ;// End of block flag 300c1bc742181ded4930842b46e9507372f0b1b963James DongTWO_BYTE_COEFF EQU 0x10 310c1bc742181ded4930842b46e9507372f0b1b963James Dong 320c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Declare input registers 330c1bc742181ded4930842b46e9507372f0b1b963James Dong 340c1bc742181ded4930842b46e9507372f0b1b963James DongppBitStream RN 0 350c1bc742181ded4930842b46e9507372f0b1b963James DongpOffset RN 1 360c1bc742181ded4930842b46e9507372f0b1b963James DongpNumCoeff RN 2 370c1bc742181ded4930842b46e9507372f0b1b963James DongppPosCoefbuf RN 3 380c1bc742181ded4930842b46e9507372f0b1b963James DongnC RN 4 ;// number of coeffs or 17 for chroma 390c1bc742181ded4930842b46e9507372f0b1b963James DongsMaxNumCoeff RN 5 400c1bc742181ded4930842b46e9507372f0b1b963James Dong 410c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Declare inner loop registers 420c1bc742181ded4930842b46e9507372f0b1b963James Dong 430c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Level loop 440c1bc742181ded4930842b46e9507372f0b1b963James DongCount RN 0 450c1bc742181ded4930842b46e9507372f0b1b963James DongTrailingOnes RN 1 460c1bc742181ded4930842b46e9507372f0b1b963James DongpLevel RN 2 470c1bc742181ded4930842b46e9507372f0b1b963James DongLevelSuffix RN 3 480c1bc742181ded4930842b46e9507372f0b1b963James DongSuffixLength RN 4 490c1bc742181ded4930842b46e9507372f0b1b963James DongTotalCoeff RN 5 500c1bc742181ded4930842b46e9507372f0b1b963James Dong 510c1bc742181ded4930842b46e9507372f0b1b963James DongpVLDTable RN 6 520c1bc742181ded4930842b46e9507372f0b1b963James DongSymbol RN 7 530c1bc742181ded4930842b46e9507372f0b1b963James DongT1 RN 8 540c1bc742181ded4930842b46e9507372f0b1b963James DongT2 RN 9 550c1bc742181ded4930842b46e9507372f0b1b963James DongRBitStream RN 10 560c1bc742181ded4930842b46e9507372f0b1b963James DongRBitBuffer RN 11 570c1bc742181ded4930842b46e9507372f0b1b963James DongRBitCount RN 12 580c1bc742181ded4930842b46e9507372f0b1b963James Donglr RN 14 590c1bc742181ded4930842b46e9507372f0b1b963James Dong 600c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Run loop 610c1bc742181ded4930842b46e9507372f0b1b963James DongCount RN 0 620c1bc742181ded4930842b46e9507372f0b1b963James DongZerosLeft RN 1 630c1bc742181ded4930842b46e9507372f0b1b963James DongpLevel RN 2 640c1bc742181ded4930842b46e9507372f0b1b963James DongppRunTable RN 3 650c1bc742181ded4930842b46e9507372f0b1b963James DongpRun RN 4 660c1bc742181ded4930842b46e9507372f0b1b963James DongTotalCoeff RN 5 670c1bc742181ded4930842b46e9507372f0b1b963James Dong 680c1bc742181ded4930842b46e9507372f0b1b963James DongpVLDTable RN 6 690c1bc742181ded4930842b46e9507372f0b1b963James DongSymbol RN 7 700c1bc742181ded4930842b46e9507372f0b1b963James DongT1 RN 8 710c1bc742181ded4930842b46e9507372f0b1b963James DongT2 RN 9 720c1bc742181ded4930842b46e9507372f0b1b963James DongRBitStream RN 10 730c1bc742181ded4930842b46e9507372f0b1b963James DongRBitBuffer RN 11 740c1bc742181ded4930842b46e9507372f0b1b963James DongRBitCount RN 12 750c1bc742181ded4930842b46e9507372f0b1b963James Donglr RN 14 760c1bc742181ded4930842b46e9507372f0b1b963James Dong 770c1bc742181ded4930842b46e9507372f0b1b963James Dong;// Fill in coefficients loop 780c1bc742181ded4930842b46e9507372f0b1b963James DongpPosCoefbuf RN 0 790c1bc742181ded4930842b46e9507372f0b1b963James Dongtemp RN 1 800c1bc742181ded4930842b46e9507372f0b1b963James DongpLevel RN 2 810c1bc742181ded4930842b46e9507372f0b1b963James DongppPosCoefbuf RN 3 820c1bc742181ded4930842b46e9507372f0b1b963James DongpRun RN 4 830c1bc742181ded4930842b46e9507372f0b1b963James DongTotalCoeff RN 5 840c1bc742181ded4930842b46e9507372f0b1b963James DongpZigZag RN 6 850c1bc742181ded4930842b46e9507372f0b1b963James Dong 860c1bc742181ded4930842b46e9507372f0b1b963James DongT1 RN 8 870c1bc742181ded4930842b46e9507372f0b1b963James DongT2 RN 9 880c1bc742181ded4930842b46e9507372f0b1b963James DongRBitStream RN 10 890c1bc742181ded4930842b46e9507372f0b1b963James DongRBitBuffer RN 11 900c1bc742181ded4930842b46e9507372f0b1b963James DongRBitCount RN 12 910c1bc742181ded4930842b46e9507372f0b1b963James DongCoeffNum RN 14 920c1bc742181ded4930842b46e9507372f0b1b963James Dong 930c1bc742181ded4930842b46e9507372f0b1b963James Dong 940c1bc742181ded4930842b46e9507372f0b1b963James Dong 950c1bc742181ded4930842b46e9507372f0b1b963James Dong IF ARM1136JS 960c1bc742181ded4930842b46e9507372f0b1b963James Dong 970c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Allocate stack memory required by the function 980c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ALLOC4 pppBitStream, 4 990c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ALLOC4 ppOffset, 4 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ALLOC4 pppPosCoefbuf, 4 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ALLOC4 ppLevel, 16*2 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ALLOC4 ppRun, 16 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Write function header 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong M_START armVCM4P10_DecodeCoeffsToPair, r11 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Define stack arguments 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ARG pNC, 4 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ARG pSMaxNumCoeff,4 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Code start 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_INIT0 ppBitStream, pOffset, RBitStream, RBitBuffer, RBitCount 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong LDR pVLDTable, =armVCM4P10_CAVLCCoeffTokenTables 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong M_LDR nC, pNC 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_INIT1 T1, T2, lr 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong LDR pVLDTable, [pVLDTable, nC, LSL #2] ;// Find VLD table 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_INIT2 T1, T2, lr 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Decode Symbol = TotalCoeff*4 + TrailingOnes 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_VLD Symbol, T1, T2, pVLDTable, 4, 2 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVS TotalCoeff, Symbol, LSR #2 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong STRB TotalCoeff, [pNumCoeff] 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "TotalCoeff=%d\n", TotalCoeff 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong BEQ.W EndNoError ;// Finished if no coefficients 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP Symbol, #17*4 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong BGE.W EndBadSymbol ;// Error if bad symbol 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Save bitstream pointers 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong M_STR ppBitStream, pppBitStream 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong M_STR pOffset, ppOffset 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong M_STR ppPosCoefbuf, pppPosCoefbuf 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Decode Trailing Ones 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong ANDS TrailingOnes, Symbol, #3 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ADR pLevel, ppLevel 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "TrailingOnes=%d\n", TrailingOnes 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong BEQ TrailingOnesDone 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV Count, TrailingOnes 1430c1bc742181ded4930842b46e9507372f0b1b963James DongTrailingOnesLoop 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_READ8 Symbol, 1, T1 1450c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS Count, Count, #1 1460c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV T1, #1 1470c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB T1, T1, Symbol, LSL #1 1480c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "Level=%d\n", T1 1490c1bc742181ded4930842b46e9507372f0b1b963James Dong STRH T1, [pLevel], #2 1500c1bc742181ded4930842b46e9507372f0b1b963James Dong BGT TrailingOnesLoop 1510c1bc742181ded4930842b46e9507372f0b1b963James DongTrailingOnesDone 1520c1bc742181ded4930842b46e9507372f0b1b963James Dong 1530c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Decode level values 1540c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS Count, TotalCoeff, TrailingOnes ;// Number of levels to read 1550c1bc742181ded4930842b46e9507372f0b1b963James Dong BEQ DecodeRuns ;// None left 1560c1bc742181ded4930842b46e9507372f0b1b963James Dong 1570c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV SuffixLength, #1 1580c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP TotalCoeff, #10 1590c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVLE SuffixLength, #0 1600c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP TrailingOnes, #3 ;// if (TrailingOnes<3) 1610c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVLT TrailingOnes, #4 ;// then TrailingOnes = +4 1620c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVGE TrailingOnes, #2 ;// else TrailingOnes = +2 1630c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVGE SuffixLength, #0 ;// SuffixLength = 0 1640c1bc742181ded4930842b46e9507372f0b1b963James Dong 1650c1bc742181ded4930842b46e9507372f0b1b963James DongLevelLoop 1660c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_CLZ16 Symbol, T1, T2 ;// Symbol=LevelPrefix 1670c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP Symbol,#16 1680c1bc742181ded4930842b46e9507372f0b1b963James Dong BGE EndBadSymbol 1690c1bc742181ded4930842b46e9507372f0b1b963James Dong 1700c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVS lr, SuffixLength ;// if LevelSuffixSize==0 1710c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQEQ Symbol, #14 ;// and LevelPrefix==14 1720c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVEQ lr, #4 ;// then LevelSuffixSize=4 1730c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQ Symbol, #15 ;// if LevelSuffixSize==15 1740c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVEQ lr, #12 ;// then LevelSuffixSize=12 1750c1bc742181ded4930842b46e9507372f0b1b963James Dong 1760c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQEQ SuffixLength,#0 1770c1bc742181ded4930842b46e9507372f0b1b963James Dong ADDEQ Symbol,Symbol,#15 1780c1bc742181ded4930842b46e9507372f0b1b963James Dong 1790c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQ lr, #0 ;// if LevelSuffixSize==0 1800c1bc742181ded4930842b46e9507372f0b1b963James Dong BEQ LevelCodeRead ;// LevelCode = LevelPrefix 1810c1bc742181ded4930842b46e9507372f0b1b963James Dong 1820c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_VREAD16 LevelSuffix, lr, T1, T2 ;// Read Level Suffix 1830c1bc742181ded4930842b46e9507372f0b1b963James Dong 1840c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV Symbol, Symbol, LSL SuffixLength 1850c1bc742181ded4930842b46e9507372f0b1b963James Dong ADD Symbol, LevelSuffix, Symbol 1860c1bc742181ded4930842b46e9507372f0b1b963James Dong 1870c1bc742181ded4930842b46e9507372f0b1b963James DongLevelCodeRead 1880c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Symbol = LevelCode 1890c1bc742181ded4930842b46e9507372f0b1b963James Dong ADD Symbol, Symbol, TrailingOnes ;// +4 if level cannot be +/-1, +2 o/w 1900c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV TrailingOnes, #2 1910c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVS T1, Symbol, LSR #1 1920c1bc742181ded4930842b46e9507372f0b1b963James Dong RSBCS T1, T1, #0 ;// If Symbol odd then negate 1930c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "Level=%d\n", T1 1940c1bc742181ded4930842b46e9507372f0b1b963James Dong STRH T1, [pLevel], #2 ;// Store level. 1950c1bc742181ded4930842b46e9507372f0b1b963James Dong 1960c1bc742181ded4930842b46e9507372f0b1b963James Dong LDR T2, =armVCM4P10_SuffixToLevel 1970c1bc742181ded4930842b46e9507372f0b1b963James Dong LDRSB T1, [T2, SuffixLength] ;// Find increment level 1980c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQ SuffixLength, #0 1990c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVEQ SuffixLength, #1 2000c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP Symbol, T1 2010c1bc742181ded4930842b46e9507372f0b1b963James Dong ADDCS SuffixLength, SuffixLength, #1 2020c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS Count, Count, #1 2030c1bc742181ded4930842b46e9507372f0b1b963James Dong BGT LevelLoop 2040c1bc742181ded4930842b46e9507372f0b1b963James Dong 2050c1bc742181ded4930842b46e9507372f0b1b963James DongDecodeRuns 2060c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Find number of zeros 2070c1bc742181ded4930842b46e9507372f0b1b963James Dong M_LDR T1, pSMaxNumCoeff ;// sMaxNumCoeff 2080c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB Count, TotalCoeff, #1 ;// Number of runs excluding last 2090c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS ZerosLeft, T1, TotalCoeff ;// Maximum number of zeros there could be 2100c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ADR pRun, ppRun 2110c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV CoeffNum,TotalCoeff 2120c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB CoeffNum,CoeffNum,#1 2130c1bc742181ded4930842b46e9507372f0b1b963James Dong BEQ NoZerosLeft 2140c1bc742181ded4930842b46e9507372f0b1b963James Dong 2150c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Unpack number of zeros from bitstream 2160c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQ T1, #4 2170c1bc742181ded4930842b46e9507372f0b1b963James Dong LDREQ pVLDTable, =(armVCM4P10_CAVLCTotalZeros2x2Tables-4) 2180c1bc742181ded4930842b46e9507372f0b1b963James Dong LDRNE pVLDTable, =(armVCM4P10_CAVLCTotalZeroTables-4) 2190c1bc742181ded4930842b46e9507372f0b1b963James Dong LDR pVLDTable, [pVLDTable, TotalCoeff, LSL #2] 2200c1bc742181ded4930842b46e9507372f0b1b963James Dong 2210c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_VLD Symbol, T1, T2, pVLDTable, 4, 2 ;// Symbol = ZerosLeft 2220c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP Symbol,#16 2230c1bc742181ded4930842b46e9507372f0b1b963James Dong BGE EndBadSymbol 2240c1bc742181ded4930842b46e9507372f0b1b963James Dong 2250c1bc742181ded4930842b46e9507372f0b1b963James Dong LDR ppRunTable, =(armVCM4P10_CAVLCRunBeforeTables-4) 2260c1bc742181ded4930842b46e9507372f0b1b963James Dong M_ADR pRun, ppRun 2270c1bc742181ded4930842b46e9507372f0b1b963James Dong MOVS ZerosLeft, Symbol 2280c1bc742181ded4930842b46e9507372f0b1b963James Dong 2290c1bc742181ded4930842b46e9507372f0b1b963James Dong ADD CoeffNum,CoeffNum,ZerosLeft 2300c1bc742181ded4930842b46e9507372f0b1b963James Dong 2310c1bc742181ded4930842b46e9507372f0b1b963James Dong BEQ NoZerosLeft 2320c1bc742181ded4930842b46e9507372f0b1b963James Dong 2330c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Decode runs while zeros are left and more than one coefficient 2340c1bc742181ded4930842b46e9507372f0b1b963James DongRunLoop 2350c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS Count, Count, #1 2360c1bc742181ded4930842b46e9507372f0b1b963James Dong LDR pVLDTable, [ppRunTable, ZerosLeft, LSL#2] 2370c1bc742181ded4930842b46e9507372f0b1b963James Dong BLT LastRun 2380c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_VLD Symbol, T1, T2, pVLDTable, 3, 2 ;// Symbol = Run 2390c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP Symbol,#15 2400c1bc742181ded4930842b46e9507372f0b1b963James Dong BGE EndBadSymbol 2410c1bc742181ded4930842b46e9507372f0b1b963James Dong 2420c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS ZerosLeft, ZerosLeft, Symbol 2430c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "Run=%d\n", Symbol 2440c1bc742181ded4930842b46e9507372f0b1b963James Dong STRB Symbol, [pRun], #1 2450c1bc742181ded4930842b46e9507372f0b1b963James Dong BGT RunLoop 2460c1bc742181ded4930842b46e9507372f0b1b963James Dong 2470c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Decode runs while no zeros are left 2480c1bc742181ded4930842b46e9507372f0b1b963James DongNoZerosLeft 2490c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS Count, Count, #1 2500c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "Run=%d\n", ZerosLeft 2510c1bc742181ded4930842b46e9507372f0b1b963James Dong STRGEB ZerosLeft, [pRun], #1 2520c1bc742181ded4930842b46e9507372f0b1b963James Dong BGT NoZerosLeft 2530c1bc742181ded4930842b46e9507372f0b1b963James Dong 2540c1bc742181ded4930842b46e9507372f0b1b963James DongLastRun 2550c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Final run length is remaining zeros 2560c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "LastRun=%d\n", ZerosLeft 2570c1bc742181ded4930842b46e9507372f0b1b963James Dong STRB ZerosLeft, [pRun], #1 2580c1bc742181ded4930842b46e9507372f0b1b963James Dong 2590c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Write coefficients to output array 2600c1bc742181ded4930842b46e9507372f0b1b963James Dong M_LDR T1, pSMaxNumCoeff ;// sMaxNumCoeff 2610c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQ T1, #15 2620c1bc742181ded4930842b46e9507372f0b1b963James Dong ADDEQ CoeffNum,CoeffNum,#1 2630c1bc742181ded4930842b46e9507372f0b1b963James Dong 2640c1bc742181ded4930842b46e9507372f0b1b963James Dong 2650c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB pRun,pRun,TotalCoeff 2660c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB pLevel,pLevel,TotalCoeff 2670c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB pLevel,pLevel,TotalCoeff 2680c1bc742181ded4930842b46e9507372f0b1b963James Dong 2690c1bc742181ded4930842b46e9507372f0b1b963James Dong M_LDR ppPosCoefbuf, pppPosCoefbuf 2700c1bc742181ded4930842b46e9507372f0b1b963James Dong LDR pPosCoefbuf, [ppPosCoefbuf] 2710c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQ T1, #4 2720c1bc742181ded4930842b46e9507372f0b1b963James Dong LDREQ pZigZag, =armVCM4P10_ZigZag_2x2 2730c1bc742181ded4930842b46e9507372f0b1b963James Dong LDRNE pZigZag, =armVCM4P10_ZigZag_4x4 2740c1bc742181ded4930842b46e9507372f0b1b963James Dong 2750c1bc742181ded4930842b46e9507372f0b1b963James Dong 2760c1bc742181ded4930842b46e9507372f0b1b963James Dong 2770c1bc742181ded4930842b46e9507372f0b1b963James DongOutputLoop 2780c1bc742181ded4930842b46e9507372f0b1b963James Dong 2790c1bc742181ded4930842b46e9507372f0b1b963James Dong LDRB T2, [pRun],#1 2800c1bc742181ded4930842b46e9507372f0b1b963James Dong LDRB T1, [pZigZag, CoeffNum] 2810c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB CoeffNum, CoeffNum, #1 ;// Skip Non zero 2820c1bc742181ded4930842b46e9507372f0b1b963James Dong SUB CoeffNum, CoeffNum, T2 ;// Skip Zero run 2830c1bc742181ded4930842b46e9507372f0b1b963James Dong 2840c1bc742181ded4930842b46e9507372f0b1b963James Dong LDRSH T2, [pLevel],#2 2850c1bc742181ded4930842b46e9507372f0b1b963James Dong 2860c1bc742181ded4930842b46e9507372f0b1b963James Dong SUBS TotalCoeff, TotalCoeff, #1 2870c1bc742181ded4930842b46e9507372f0b1b963James Dong ORREQ T1, T1, #LAST_COEFF 2880c1bc742181ded4930842b46e9507372f0b1b963James Dong 2890c1bc742181ded4930842b46e9507372f0b1b963James Dong ADD temp, T2, #128 2900c1bc742181ded4930842b46e9507372f0b1b963James Dong CMP temp, #256 2910c1bc742181ded4930842b46e9507372f0b1b963James Dong ORRCS T1, T1, #TWO_BYTE_COEFF 2920c1bc742181ded4930842b46e9507372f0b1b963James Dong 2930c1bc742181ded4930842b46e9507372f0b1b963James Dong 2940c1bc742181ded4930842b46e9507372f0b1b963James Dong TEQ TotalCoeff, #0 ;// Preserves carry 2950c1bc742181ded4930842b46e9507372f0b1b963James Dong 2960c1bc742181ded4930842b46e9507372f0b1b963James Dong M_PRINTF "Output=%02x %04x\n", T1, T2 2970c1bc742181ded4930842b46e9507372f0b1b963James Dong STRB T1, [pPosCoefbuf], #1 2980c1bc742181ded4930842b46e9507372f0b1b963James Dong STRB T2, [pPosCoefbuf], #1 2990c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV T2, T2, LSR #8 3000c1bc742181ded4930842b46e9507372f0b1b963James Dong STRCSB T2, [pPosCoefbuf], #1 3010c1bc742181ded4930842b46e9507372f0b1b963James Dong BNE OutputLoop 3020c1bc742181ded4930842b46e9507372f0b1b963James Dong 3030c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Finished 3040c1bc742181ded4930842b46e9507372f0b1b963James Dong STR pPosCoefbuf, [ppPosCoefbuf] 3050c1bc742181ded4930842b46e9507372f0b1b963James Dong M_LDR ppBitStream, pppBitStream 3060c1bc742181ded4930842b46e9507372f0b1b963James Dong M_LDR pOffset, ppOffset 3070c1bc742181ded4930842b46e9507372f0b1b963James Dong B EndNoError 3080c1bc742181ded4930842b46e9507372f0b1b963James Dong 3090c1bc742181ded4930842b46e9507372f0b1b963James DongEndBadSymbol 3100c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV r0, #OMX_Sts_Err 3110c1bc742181ded4930842b46e9507372f0b1b963James Dong B End 3120c1bc742181ded4930842b46e9507372f0b1b963James Dong 3130c1bc742181ded4930842b46e9507372f0b1b963James DongEndNoError 3140c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Finished reading from the bitstream 3150c1bc742181ded4930842b46e9507372f0b1b963James Dong M_BD_FINI ppBitStream, pOffset 3160c1bc742181ded4930842b46e9507372f0b1b963James Dong 3170c1bc742181ded4930842b46e9507372f0b1b963James Dong ;// Set return value 3180c1bc742181ded4930842b46e9507372f0b1b963James Dong MOV r0, #OMX_Sts_NoErr 3190c1bc742181ded4930842b46e9507372f0b1b963James DongEnd 3200c1bc742181ded4930842b46e9507372f0b1b963James Dong M_END 3210c1bc742181ded4930842b46e9507372f0b1b963James Dong 3220c1bc742181ded4930842b46e9507372f0b1b963James Dong ENDIF 3230c1bc742181ded4930842b46e9507372f0b1b963James Dong 3240c1bc742181ded4930842b46e9507372f0b1b963James Dong END 3250c1bc742181ded4930842b46e9507372f0b1b963James Dong 326