1;/** 2; * 3; * File Name: armVCM4P2_DecodeVLCZigzag_AC_unsafe_s.s 4; * OpenMAX DL: v1.0.2 5; * Revision: 9641 6; * Date: Thursday, February 7, 2008 7; * 8; * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. 9; * 10; * 11; * 12; * Description: 13; * Contains modules for zigzag scanning and VLC decoding 14; * for inter, intra block. 15; * 16; * 17; * 18; * Function: omxVCM4P2_DecodeVLCZigzag_AC_unsafe 19; * 20; * Description: 21; * Performs VLC decoding and inverse zigzag scan 22; * 23; * 24; * 25; * 26; */ 27 28 29 INCLUDE omxtypes_s.h 30 INCLUDE armCOMM_s.h 31 INCLUDE armCOMM_BitDec_s.h 32 33 34 M_VARIANTS ARM1136JS 35 36 37 38 39 40 IF ARM1136JS 41 42 43 44 45 46;//Input Arguments 47 48ppBitStream RN 0 49pBitOffset RN 1 50pDst RN 2 51shortVideoHeader RN 3 52 53 54;//Local Variables 55 56Return RN 0 57 58pVlcTableL0L1 RN 4 59pLMAXTableL0L1 RN 4 60pRMAXTableL0L1 RN 4 61pZigzagTable RN 4 62 63ftype RN 0 64temp3 RN 4 65temp RN 5 66Count RN 6 67Escape RN 5 68 69;// armVCM4P2_FillVLDBuffer 70zigzag RN 0 71storeLevel RN 1 72temp2 RN 4 73temp1 RN 5 74sign RN 5 75Last RN 7 76storeRun RN 14 77 78 79packRetIndex RN 5 80 81 82markerbit RN 5 83 84;// Scratch Registers 85 86RBitStream RN 8 87RBitBuffer RN 9 88RBitCount RN 10 89 90T1 RN 11 91T2 RN 12 92LR RN 14 93 94 95 96 M_ALLOC4 pppBitStream,4 97 M_ALLOC4 ppOffset,4 98 M_ALLOC4 pLinkRegister,4 99 100 M_START armVCM4P2_DecodeVLCZigzag_AC_unsafe 101 102 ;// get the table addresses from stack 103 M_ARG ppVlcTableL0L1,4 104 M_ARG ppLMAXTableL0L1,4 105 M_ARG ppRMAXTableL0L1,4 106 M_ARG ppZigzagTable,4 107 108 ;// Store ALL zeros at pDst 109 110 MOV temp1,#0 ;// Initialize Count to zero 111 MOV Last,#0 112 M_STR LR,pLinkRegister ;// Store Link Register on Stack 113 MOV temp2,#0 114 MOV LR,#0 115 116 ;// Initialize the Macro and Store all zeros to pDst 117 118 STM pDst!,{temp2,temp1,Last,LR} 119 M_BD_INIT0 ppBitStream, pBitOffset, RBitStream, RBitBuffer, RBitCount 120 STM pDst!,{temp2,temp1,Last,LR} 121 M_BD_INIT1 T1, T2, T2 122 STM pDst!,{temp2,temp1,Last,LR} 123 M_BD_INIT2 T1, T2, T2 124 STM pDst!,{temp2,temp1,Last,LR} 125 M_STR ppBitStream,pppBitStream ;// Store ppBitstream on stack 126 STM pDst!,{temp2,temp1,Last,LR} 127 M_STR pBitOffset,ppOffset ;// Store pBitOffset on stack 128 STM pDst!,{temp2,temp1,Last,LR} 129 130 STM pDst!,{temp2,temp1,Last,LR} 131 STM pDst!,{temp2,temp1,Last,LR} 132 133 134 SUB pDst,pDst,#128 ;// Restore pDst 135 136 ;// The armVCM4P2_GetVLCBits begins 137 138getVLCbits 139 140 M_BD_LOOK8 Escape,7 ;// Load Escape Value 141 LSR Escape,Escape,#25 142 CMP Escape,#3 ;// check for escape mode 143 MOVNE ftype,#0 144 BNE notEscapemode ;// Branch if not in Escape mode 3 145 146 M_BD_VSKIP8 #7,T1 147 CMP shortVideoHeader,#0 ;// Check shortVideoHeader flag to know the type of Escape mode 148 BEQ endFillVLD 149 150 ;// Escape Mode 4 151 152 M_BD_READ8 Last,1,T1 153 M_BD_READ8 storeRun,6,T1 154 M_BD_READ8 storeLevel,8,T1 155 156 157 ;// Check whether the Reserved values for Level are used and Exit with an Error Message if it is so 158 159 TEQ storeLevel,#0 160 TEQNE storeLevel,#128 161 BEQ ExitError 162 163 ADD temp2,storeRun,Count 164 CMP temp2,#64 165 BGE ExitError ;// error if Count+storeRun >= 64 166 167 168 ;// Load address of zigzagTable 169 170 M_LDR pZigzagTable,ppZigzagTable ;// Loading the Address of Zigzag table 171 172 173 ;// armVCM4P2_FillVLDBuffer 174 175 SXTB storeLevel,storeLevel ;// Sign Extend storeLevel to 32 bits 176 177 178 ;// To Reflect Runlength 179 180 ADD Count,Count,storeRun 181 LDRB zigzag,[pZigzagTable,Count] 182 ADD Count,Count,#1 183 STRH storeLevel,[pDst,zigzag] ;// store Level 184 185 B ExitOk 186 187 188 189endFillVLD 190 191 192 ;// Load Ftype( Escape Mode) value based on the two successive bits in the bitstream 193 194 M_BD_READ8 temp1,1,T1 195 CMP temp1,#0 196 MOVEQ ftype,#1 197 BEQ notEscapemode 198 M_BD_READ8 temp1,1,T1 199 CMP temp1,#1 200 MOVEQ ftype,#3 201 MOVNE ftype,#2 202 203 204notEscapemode 205 206 ;// Load optimized packed VLC table with last=0 and Last=1 207 208 M_LDR pVlcTableL0L1,ppVlcTableL0L1 ;// Load Combined VLC Table 209 210 211 CMP ftype,#3 ;// If ftype >=3 get perform Fixed Length Decoding (Escape Mode 3) 212 BGE EscapeMode3 ;// Else continue normal VLC Decoding 213 214 ;// Variable lengh decoding, "armUnPackVLC32" 215 216 217 M_BD_VLD packRetIndex,T1,T2,pVlcTableL0L1,4,2 218 219 220 LDR temp3,=0xFFF 221 222 CMP packRetIndex,temp3 ;// Check for invalid symbol 223 BEQ ExitError ;// if invalid symbol occurs exit with an error message 224 225 AND Last,packRetIndex,#2 ;// Get Last from packed Index 226 227 228 229 230 LSR storeRun,packRetIndex,#7 ;// Get Run Value from Packed index 231 AND storeLevel,packRetIndex,#0x7c ;// storeLevel=packRetIndex[2-6],storeLevel[0-1]=0 232 233 234 M_LDR pLMAXTableL0L1,ppLMAXTableL0L1 ;// Load LMAX table 235 236 237 LSR storeLevel,storeLevel,#2 ;// Level value 238 239 CMP ftype,#1 240 BNE ftype2 241 242 ;// ftype==1; Escape mode =1 243 244 245 ADD temp1, pLMAXTableL0L1, Last, LSL#4 ;// If the Last=1 add 32 to table address 246 LDRB temp1,[temp1,storeRun] 247 248 249 ADD storeLevel,temp1,storeLevel 250 251ftype2 252 253 ;// ftype =2; Escape mode =2 254 255 M_LDR pRMAXTableL0L1,ppRMAXTableL0L1 ;// Load RMAX Table 256 257 CMP ftype,#2 258 BNE FillVLDL1 259 260 ADD temp1, pRMAXTableL0L1, Last, LSL#4 ;// If Last=1 add 32 to table address 261 SUB temp2,storeLevel,#1 262 LDRB temp1,[temp1,temp2] 263 264 265 ADD storeRun,storeRun,#1 266 ADD storeRun,temp1 267 268FillVLDL1 269 270 271 ;// armVCM4P2_FillVLDBuffer 272 273 M_LDR pZigzagTable,ppZigzagTable ;// Load address of zigzagTable 274 275 M_BD_READ8 sign,1,T1 276 277 CMP sign,#1 278 RSBEQ storeLevel,storeLevel,#0 279 280 ADD temp1,storeRun,Count ;// Exit with an error message if Run + Count exceeds 63 281 CMP temp1,#64 282 BGE ExitError 283 284 285 286 287 288 289 ;// To Reflect Runlenght 290 291 ADD Count,Count,storeRun 292 293storeLevelL1 294 295 LDRB zigzag,[pZigzagTable,Count] 296 CMP Last,#2 ;// Check if the Level val is Last non zero val 297 ADD Count,Count,#1 298 LSR Last,Last,#1 299 STRH storeLevel,[pDst,zigzag] 300 301 BNE end 302 303 B ExitOk 304 305 306 307 ;// Fixed Lengh Decoding Escape Mode 3 308 309EscapeMode3 310 311 M_BD_READ8 Last,1,T1 312 M_BD_READ8 storeRun,6,T1 313 314 ADD temp2,storeRun,Count ;// Exit with an error message if Run + Count exceeds 63 315 CMP temp2,#64 316 BGE ExitError 317 318 M_BD_READ8 markerbit,1,T1 319 TEQ markerbit,#0 ;// Exit with an error message if marker bit is zero 320 BEQ ExitError 321 322 M_BD_READ16 storeLevel,12,T1 323 324 TST storeLevel,#0x800 ;// test if the level is negative 325 SUBNE storeLevel,storeLevel,#4096 326 CMP storeLevel,#0 327 CMPNE storeLevel,#-2048 328 BEQ ExitError ;// Exit with an error message if Level==0 or -2048 329 330 M_LDR pZigzagTable,ppZigzagTable ;// Load address of zigzagTable 331 332 M_BD_READ8 markerbit,1,T1 333 334 335 ;// armVCM4P2_FillVLDBuffer ( Sign not used as storeLevel is preprocessed) 336 337 338 339 ;// To Reflect Run Length 340 341 ADD Count,Count,storeRun 342 343 344 345storeLevelLast 346 347 LDRB zigzag,[pZigzagTable,Count] 348 CMP Last,#1 349 ADD Count,Count,#1 350 STRH storeLevel,[pDst,zigzag] 351 352 BNE end 353 354 B ExitOk 355 356end 357 358 CMP Count,#64 ;//Run the Loop untill Count reaches 64 359 360 BLT getVLCbits 361 362 363ExitOk 364 ;// Exit When VLC Decoding is done Successfully 365 366 ;// Loading ppBitStream and pBitOffset from stack 367 368 CMP Last,#1 369 M_LDR ppBitStream,pppBitStream 370 M_LDR pBitOffset,ppOffset 371 372 ;//Ending the macro 373 374 M_BD_FINI ppBitStream,pBitOffset 375 376 MOVEQ Return,#OMX_Sts_NoErr 377 MOVNE Return,#OMX_Sts_Err 378 M_LDR LR,pLinkRegister ;// Load the Link Register Back 379 B exit2 380 381ExitError 382 ;// Exit When an Error occurs 383 384 M_LDR ppBitStream,pppBitStream 385 M_LDR pBitOffset,ppOffset 386 ;//Ending the macro 387 388 M_BD_FINI ppBitStream,pBitOffset 389 M_LDR LR,pLinkRegister 390 MOV Return,#OMX_Sts_Err 391 392exit2 393 394 395 M_END 396 ENDIF 397 398 END 399