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