1;// 2;// Copyright (C) 2007-2008 ARM Limited 3;// 4;// Licensed under the Apache License, Version 2.0 (the "License"); 5;// you may not use this file except in compliance with the License. 6;// You may obtain a copy of the License at 7;// 8;// http://www.apache.org/licenses/LICENSE-2.0 9;// 10;// Unless required by applicable law or agreed to in writing, software 11;// distributed under the License is distributed on an "AS IS" BASIS, 12;// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13;// See the License for the specific language governing permissions and 14;// limitations under the License. 15;// 16;/** 17; * 18; * File Name: omxVCM4P2_DecodeVLCZigzag_IntraDCVLC_s.s 19; * OpenMAX DL: v1.0.2 20; * Revision: 9641 21; * Date: Thursday, February 7, 2008 22; * 23; * 24; * 25; * 26; * Description: 27; * Contains modules for zigzag scanning and VLC decoding 28; * for inter block. 29; * 30; * 31; * 32; * Function: omxVCM4P2_DecodeVLCZigzag_Inter 33; * 34; * Description: 35; * Performs VLC decoding and inverse zigzag scan for one intra coded block. 36; * 37; * Remarks: 38; * 39; * Parameters: 40; * [in] ppBitStream pointer to the pointer to the current byte in 41; * the bitstream buffer 42; * [in] pBitOffset pointer to the bit position in the byte pointed 43; * to by *ppBitStream. *pBitOffset is valid within [0-7]. 44; * [in] shortVideoHeader binary flag indicating presence of short_video_header; 45; * escape modes 0-3 are used if shortVideoHeader==0, 46; * and escape mode 4 is used when shortVideoHeader==1. 47; * [out] ppBitStream *ppBitStream is updated after the block is 48; * decoded, so that it points to the current byte 49; * in the bit stream buffer 50; * [out] pBitOffset *pBitOffset is updated so that it points to the 51; * current bit position in the byte pointed by 52; * *ppBitStream 53; * [out] pDst pointer to the coefficient buffer of current 54; * block. Must be 16-byte aligned 55; * 56; * Return Value: 57; * OMX_Sts_BadArgErr - bad arguments 58; * -At least one of the following pointers is NULL: ppBitStream, *ppBitStream, pBitOffset, pDst, or 59; * -pDst is not 16-byte aligned, or 60; * -*pBitOffset exceeds [0,7]. 61; * OMX_Sts_Err - status error 62; * -At least one mark bit is equal to zero 63; * -Encountered an illegal stream code that cannot be found in the VLC table 64; * -Encountered and illegal code in the VLC FLC table 65; * -The number of coefficients is greater than 64 66; * 67; */ 68 69 70 INCLUDE omxtypes_s.h 71 INCLUDE armCOMM_s.h 72 INCLUDE armCOMM_BitDec_s.h 73 74 75 M_VARIANTS ARM1136JS 76 77 78 79 80 81 IF ARM1136JS :LOR: CortexA8 82 83 84 ;// Import various tables needed for the function 85 86 87 IMPORT armVCM4P2_IntraVlcL0L1 ;// Contains optimized and packed VLC Tables for both Last =1 and last=0 88 ;// Packed in Run:Level:Last format 89 IMPORT armVCM4P2_IntraL0L1LMAX ;// Contains LMAX table entries with both Last=0 and Last=1 90 IMPORT armVCM4P2_IntraL0L1RMAX ;// Contains RMAX table entries with both Last=0 and Last=1 91 IMPORT armVCM4P2_aClassicalZigzagScan ;// contains CLassical, Horizontal, Vertical Zigzag table entries with double the original values 92 IMPORT armVCM4P2_aIntraDCLumaChromaIndex ;// Contains Optimized DCLuma and DCChroma Index table Entries 93 94 95 IMPORT armVCM4P2_DecodeVLCZigzag_AC_unsafe 96 97;//Input Arguments 98 99ppBitStream RN 0 100pBitOffset RN 1 101pDst RN 2 102PredDir RN 3 103shortVideoHeader RN 3 104videoComp RN 5 105;//Local Variables 106 107Return RN 0 108 109pDCLumaChromaIndex RN 4 110pDCChromaIndex RN 7 111pVlcTableL0L1 RN 4 112pLMAXTableL0L1 RN 4 113pRMAXTableL0L1 RN 4 114pZigzagTable RN 4 115Count RN 6 116DCValueSize RN 6 117powOfSize RN 7 118temp1 RN 5 119 120 121;// Scratch Registers 122 123RBitStream RN 8 124RBitBuffer RN 9 125RBitCount RN 10 126 127T1 RN 11 128T2 RN 12 129DCVal RN 14 130 131 132 ;// Allocate stack memory to store optimized VLC,Zigzag, RMAX, LMAX Table Addresses 133 134 M_ALLOC4 ppVlcTableL0L1,4 135 M_ALLOC4 ppLMAXTableL0L1,4 136 M_ALLOC4 ppRMAXTableL0L1,4 137 M_ALLOC4 ppZigzagTable,4 138 M_ALLOC4 pDCCoeff,4 139 140 141 142 M_START omxVCM4P2_DecodeVLCZigzag_IntraDCVLC,r12 143 144 M_ARG shortVideoHeaderonStack,4 ;// Pointer to argument on stack 145 M_ARG videoComponstack,4 ;// Pointer to argument on stack 146 147 148 ;// Decode DC Coefficient 149 150 151 LDR pDCLumaChromaIndex, =armVCM4P2_aIntraDCLumaChromaIndex ;// Load Optimized VLC Table for Luminance and Chrominance 152 153 ;// Initializing the Bitstream Macro 154 155 M_BD_INIT0 ppBitStream, pBitOffset, RBitStream, RBitBuffer, RBitCount 156 M_LDR videoComp,videoComponstack 157 M_BD_INIT1 T1, T2, T2 158 ADD pDCLumaChromaIndex,pDCLumaChromaIndex,videoComp, LSL #6 159 M_BD_INIT2 T1, T2, T2 160 161 162 M_BD_VLD DCValueSize,T1,T2,pDCLumaChromaIndex,4,2 ;// VLC Decode using optimized Luminance and Chrominance VLC Table 163 164 165 166 167DecodeDC 168 169 CMP DCValueSize,#12 170 BGT ExitError 171 172 CMP DCValueSize,#0 173 MOVEQ DCVal,#0 ;// If DCValueSize is zero then DC coeff =0 174 BEQ ACDecode ;// Branch to perform AC Coeff Decoding 175 176 M_BD_VREAD16 DCVal,DCValueSize,T1,T2 ;// Get DC Value From Bit stream 177 178 179 MOV powOfSize,#1 180 LSL powOfSize,DCValueSize ;// powOfSize=pow(2,DCValueSize) 181 CMP DCVal,powOfSize,LSR #1 ;// Compare DCVal with powOfSize/2 182 ADDLT DCVal,DCVal,#1 183 SUBLT DCVal,DCVal,powOfSize ;// If Lessthan powOfSize/2 DCVal=DCVal-powOfSize+1 184 ;// Else DCVal= fetchbits from bit stream 185 186CheckDCValueSize 187 188 CMP DCValueSize,#8 ;// If DCValueSize greater than 8 check marker bit 189 190 BLE ACDecode 191 192 M_BD_READ8 temp1,1,T1 193 TEQ temp1,#0 ;// If Marker bit is zero Exit with an Error Message 194 BEQ ExitError 195 196 197 198 ;// Decode AC Coefficient 199 200ACDecode 201 202 M_STR DCVal,pDCCoeff ;// Store Decoded DC Coeff on Stack 203 M_BD_FINI ppBitStream,pBitOffset ;// Terminating the Bit stream Macro 204 205 LDR pZigzagTable, =armVCM4P2_aClassicalZigzagScan ;// Load Zigzag talbe address 206 ADD pZigzagTable, pZigzagTable, PredDir, LSL #6 ;// Modify the Zigzag table adress based on PredDir 207 208 M_STR pZigzagTable,ppZigzagTable ;// Store zigzag table on stack 209 LDR pVlcTableL0L1, =armVCM4P2_IntraVlcL0L1 ;// Load Optimized VLC Table With both Last=0 and Last=1 Entries 210 M_STR pVlcTableL0L1,ppVlcTableL0L1 ;// Store Optimized VLC Table on stack 211 LDR pLMAXTableL0L1, =armVCM4P2_IntraL0L1LMAX ;// Load LMAX Table 212 M_STR pLMAXTableL0L1,ppLMAXTableL0L1 ;// Store LMAX table on stack 213 LDR pRMAXTableL0L1, =armVCM4P2_IntraL0L1RMAX ;// Load RMAX Table 214 MOV Count,#1 ;// Set Start =1 215 216 M_STR pRMAXTableL0L1,ppRMAXTableL0L1 ;// Store RMAX Table on Stack 217 218 219 M_LDR shortVideoHeader,shortVideoHeaderonStack ;// Load the Input Argument From Stack 220 221 BL armVCM4P2_DecodeVLCZigzag_AC_unsafe ;// Call the Unsafe Function 222 223 M_LDR DCVal,pDCCoeff ;// Get the Decoded DC Value From Stack 224 STRH DCVal,[pDst] ;// Store the DC Value 225 B ExitOK 226 227 228 229ExitError 230 231 M_BD_FINI ppBitStream,pBitOffset ;// Terminating the Bit Stream Macro in case of an Error 232 MOV Return,#OMX_Sts_Err ;// Exit with an Error Message 233ExitOK 234 235 M_END 236 ENDIF 237 238 END 239