⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vld.s

📁 代码实现了基于ARM7的MPEG-4视频解码器
💻 S
字号:
;//*********************************************
;//File name:  vld.s
;//Author:     Anna
;//Date:
;//**********************************************
   
    AREA VLD,CODE,READONLY
    EXPORT  vld_intra_dct
    
    IMPORT  showbits
    IMPORT  flushbits
    IMPORT  getbits

vld_intra_dct   

   ;// B vldtableB16
   ;// vldtableB16  //  tab=vldtableB16(showbits(12))
    MOV R0,#12
    BL showbits
    CMP R0,#512
    BGE tableB16_1
    CMP R0,#128
    BGE tableB16_2
    CMP R0,#8
    BGE tableB16_3 
    
tableB16_1
    MOV R1,#16
    RSB R2,R1,R0,ASR#5    ;//code>>5-16
    LDR R1,=tableB16_1_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_1_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
    B first_compute_event   
    
tableB16_2
    MOV R1,#32
    RSB R2,R1,R0,ASR#2
    LDR R1,=tabelB16_2_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_2_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
    B first_compute_event

tableB16_3
    MOV R1,#8
    RSB R2,R1,R0
    LDR R1,=tableB16_3_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_3_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
    B first_compute_event
    
first_compute_event    
    LDR R1,=7167
    CMP R3,R1
    BEQ escape_mode
    MOV R5,R3,ASR#6
    AND R5,R5,#63   ;//get event.run
    AND R6,R3,#63   ;//get event.level
    MOV R7,R3,ASR#12
    AND R7,R7,#1    ;//get event.last
    MOV R0,#1
    BL getbits
    CMP R0,#1
    RSBEQ R6,R6,#0  ;//get the result level
    MOV LR,PC

;/***/    
    
escape_mode
    MOV R0,#2
    BL showbits
    CMP R0,#0x0
    BEQ type1
    CMP R0,#0x1
    BEQ type1
    CMP R0,#0x2
    BEQ type2
    CMP R0,#0x3
    BEQ type3
    
    
type1 ;/*Type 1*/
    MOV R0,#1
    BL flushbits
   ;//use table B-16
    MOV R0,#12
    BL showbits
    CMP R0,#512
    BGE sec_tableB16_1
    CMP R0,#128
    BGE sec_tableB16_2
    CMP R0,#8
    BGE sec_tableB16_3 
    
sec_tableB16_1
    MOV R1,#16
    RSB R2,R1,R0,ASR#5    ;//code>>5-16
    LDR R1,=tableB16_1_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_1_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
    B second_compute_event   
    
sec_tableB16_2
    MOV R1,#32
    RSB R2,R1,R0,ASR#2
    LDR R1,=tabelB16_2_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_2_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
    B second_compute_event

sec_tableB16_3
    MOV R1,#8
    RSB R2,R1,R0
    LDR R1,=tableB16_3_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_3_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
  ;//  B second_compute_event  

second_compute_event
    MOV R5,R3,ASR#6
    AND R5,R5,#63   ;//get event.run
    AND R6,R3,#63   ;//get event.level
    MOV R7,R3,ASR#12
    AND R7,R7,#1    ;//get event.last
    B vldtableB19   ;//use table B-19
compute_level 
    ADD R6,R6,R4
    MOV R0,#1
    BL getbits
    CMP R0,#1
    RSBEQ R6,R6,#0  ;//get the result level
    MOV LR,PC
      
type2  ;/*Type 2*/
    MOV R0,#2
    BL flushbits
    ;//use table B-16
    MOV R0,#12
    BL showbits
    CMP R0,#512
    BGE third_tableB16_1
    CMP R0,#128
    BGE third_tableB16_2
    CMP R0,#8
    BGE third_tableB16_3 
    
third_tableB16_1
    MOV R1,#16
    RSB R2,R1,R0,ASR#5    ;//code>>5-16
    LDR R1,=tableB16_1_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_1_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
    B third_compute_event  
   
third_tableB16_2
    MOV R1,#32
    RSB R2,R1,R0,ASR#2
    LDR R1,=tabelB16_2_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_2_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
    B third_compute_event
third_tableB16_3
    MOV R1,#8
    RSB R2,R1,R0
    LDR R1,=tableB16_3_val
    LDR R3,[R1,R2,LSL#2]   ;//get value
    LDR R1,=tableB16_3_len
    LDR R4,[R1,R2,LSL#2]   ;//get length
    MOV R0,R4              ;//mov length to R0
    BL flushbits           ;//flush the bits of length number
   ;// B third_compute_event

third_compute_event
    MOV R5,R3,ASR#6
    AND R5,R5,#63   ;//get event.run
    AND R6,R3,#63   ;//get event.level
    MOV R7,R3,ASR#12
    AND R7,R7,#1    ;//get event.last  
    B vldtableB21   ;//use table B-21
compute_run_level
    ADD R5,R5,R4
    ADD R5,R5,#1    ;//get result run
    MOV R0,#0
    BL getbits
    CMP R0,#1
    RSBEQ R6,R6,#0
    MOV LR,PC
    
type3   ;/*Type 3*/
    MOV R0,#2
    BL flushbits
    MOV R0,#1
    BL getbits
    MOV R7,R0      ;//get event.last
    MOV R0,#6 
    BL getbits
    MOV R5,R0      ;//get event.run
    MOV R0,#1
    BL getbits     ;//marker bit
    MOV R0,#12
    BL getbits     
    MOV R6,R0      ;//get event.level   table B-18
    ;/*sign extend level...*/
    AND R4,R6,#0x800
    BEQ last_marker 
    LDR R4,=-4096   ;//-1^0xfff
    ORR R6,R6,R4    ;//level
last_marker
    MOV R0,#0
    BL getbits    
    MOV LR,PC
    
           

;/* Table B-19 -- ESCL(a),LMAX values of intra macroblock*/

vldtableB19
    CMP R7,#0
    BNE last_equ_one
    CMP R5,#0      ;//LAST==0
    MOVEQ R4,#27   ;//here R4 is LMAX  
    CMP R5,#1
    MOVEQ R4,#10
    CMP R5,#2
    MOVEQ R4,#5
    CMP R5,#3
    MOVEQ R4,#4
    CMP R5,#7
    MOVLS R4,#3
    CMP R5,#9
    MOVLS R4,#2
    CMP R5,#14
    MOVLS R4,#1
    MOVHI R4,#0
    B  compute_level
             
last_equ_one          ;//LAST==1
    CMP R5,#0
    MOVEQ R4,#8
    CMP R5,#1
    MOVEQ R4,#3
    CMP R5,#6
    MOVLS R4,#2
    CMP R5,#20
    MOVLS R4,#1
    MOVHI R4,#0
    B compute_level

;/*Table B-21 -- ESCR(a),RMAX values of intra macroblocks */
vldtableB21 
    CMP R7,#0
    BNE last_equ_one_B21
    CMP R6,#1
    MOVEQ R4,#14   ;//here R4 is RMAX
    CMP R6,#2
    MOVEQ R4,#9
    CMP R6,#3
    MOVEQ R4,#7
    CMP R6,#4
    MOVEQ R4,#3
    CMP R6,#5
    MOVEQ R4,#2
    CMP R6,#10
    MOVLS R4,#1
    MOVHI R4,#0
    B  compute_run_level
    
last_equ_one_B21     ;//LAST==1
    CMP R6,#1
    MOVEQ R4,#20
    CMP R6,#2
    MOVEQ R4,#6
    CMP R6,#3
    MOVEQ R4,#1
    MOVNE R4,#0
    B compute_run_level 
         
;/*tables*/    
    
tableB16_1_val  DCD 4353,4289,385,4417,449,130,67,9,4098,4098  
	            DCD  321,321,4225,4225,4161,4161,257,257,193,193 
	            DCD   8,  8,  7,   7,   66,  66,  6,  6, 129,129  
	            DCD  129,129, 5,   5,   5,    5,  4,  4,  4,  4 
	            DCD  4097,4097,4097,4097,4097,4097,4097,4097,1, 1  
	            DCD    1,   1,  1,   1,   1,    1,  1,   1,  1, 1  
	            DCD    1,   1,  1,   1,   1,    1,  1,   1,  1, 1 
	            DCD    1,   1,  1,   1,   1,    1,  1,   1,  1, 1  
	            DCD    2,   2,  2,   2,   2,    2,  2,   2,  2, 2  
	            DCD    2,   2,  2,   2,   2,    2,  65,  65, 65,65  
	            DCD    65,  65, 65,  65,  3,    3,  3,   3,   3, 3  
	            DCD    3,   3 
    
tableB16_1_len  DCD    7,   7,   7,  7,   7,    7,  7,   7,  6,  6  
	            DCD    6,   6,   6,  6,   6,    6,  6,   6,  6,  6 
	            DCD    6,   6,   6,  6,   6,    6,  6,   6,  5,  5  
	            DCD    5,   5,   5,  5,   5,    5,  5,   5,  5,  5  
	            DCD    4,   4,   4,  4,   4,    4,  4,   4,  2,  2  
	            DCD    2,   2,   2,  2,   2,    2,  2,   2,  2,  2 
	            DCD    2,   2,   2,  2,   2,    2,  2,   2,  2,  2  
            	DCD    2,   2,   2,  2,   2,    2,  2,   2,  2,  2  
	            DCD    3,   3,   3,  3,   3,    3,  3,   3,  3,  3  
	            DCD    3,   3,   3,  3,   3,    3,  4,   4,  4,  4  
	            DCD    4,   4,   4,  4,   4,    4,  4,   4,  4,  4  
	            DCD    4,   4 
          
tabelB16_2_val DCD  18,   17,  4993,  4993, 4929,  4929,  4865,  4865,  4801, 4801
               DCD  4737, 4737,4162,  4162, 4100,  4100,  769,   769,   705,  705  
               DCD  450,  450, 386,   386,  322,   322,   195,   195,   131,  131
               DCD  70,   70,   69,   69,   16,    16,    258,   258,   15,   15
               DCD  14,   14,  13,    13,   4609,  4609,  4609,  4609,  4545, 4545
               DCD  4545, 4545,4481,  4481, 4481,  4481,  4099,  4099,  4099, 4099
               DCD  641,  641,  641,  641,  577,   577,   577,   577,   513,  513
               DCD  513,  513,  4673, 4673, 4673,  4673,  194,   194,   194,  194
               DCD  68,   68,   68,   68,   12,    12,    12,    12,    11,   11
               DCD  11,   11,   10,   10,   10,    10 

tableB16_2_len DCD  10,   10,   9,    9,    9,   9,    9,     9,     9,    9
               DCD   9,    9,   9,    9,    9,   9,    9,     9,     9,    9
               DCD   9,    9,   9,    9,    9,   9,    9,     9,     9,    9
               DCD   9,    9,   9,    9,    9,   9,    9,     9,     9,    9
               DCD  14,    14,  13,   13,   8,   8,    8,     8,     8,    8
               DCD   8,    8,   8,    8,    8,   8,    8,     8,     8,    8
               DCD   8,    8,   8,    8,    8,   8,    8,     8,     8,    8
               DCD   8,    8,   8,    8,    8,   8,    8,     8,     8,    8
               DCD   8,    8,   8,    8,    8,   8,    8,     8,     8,    8
               DCD   8,    8,   8,    8,    8,   8    
    
tableB16_3_val DCD  4103,  4103,  4102,  4102,  22,  22,  21,  21,  4226,  4226
               DCD  4226,  4226,  4163,  4163,  4163,4163,4101,4101,4101,  4101
               DCD  833,   833,   833,   833,   323, 323, 323, 323, 514,   514
               DCD  514,   514,   259,   259,   259, 259, 196, 196, 196,   196
               DCD  132,   132,   132,   132,   71,  71,  71,  71,   20,    20 
               DCD  20,    20,    19,    19,    19,  19,  23,  23,   24,    24
               DCD  72,    72,    578,   578,   4290,4290,4354,4354, 5057,  5057
               DCD  5121,  5121,  25,    26,    27,  73,  387,  74,  133,   451
               DCD  897,   4104,  4418,  4482,  5185,5249,5313, 5377, 7167, 7167
               DCD  7167,  7167,  7167,  7167,  7167, 7167,7167,7167, 7167, 7167
               DCD  7167,  7167,  7167,  7167,  7167, 7167,7167,7167, 7167, 7167
               DCD  7167,  7167,  7167,  7167,  7167, 7167,7167,7167, 7167, 7167   

tableB16_3_len DCD  11,    11,    11,     11,   11,   11,  11,  11,   10,   10
               DCD  10,    10,    10,     10,   10,   10,  10,  10,   10,   10
               DCD  10,    10,    10,     10,   10,   10,  10,  10,   10,   10
               DCD  10,    10,    10,     10,   10,   10,  10,  10,   10,   10
               DCD  10,    10,    10,     10,   10,   10,  10,  10,   10,   10
               DCD  10,    10,    10,     10,   10,   10,  11,  11,   11,   11
               DCD  11,    11,    11,     11,   11,   11,  11,  11,   11,   11
               DCD  11,    11,    12,     12,   12,   12,  12,  12,   12,   12
               DCD  12,    12,    12,     12,   12,   12,  12,  12,   7,    7
               DCD   7,     7,    7,      7,    7,    7,   7,   7,   7,    7
               DCD   7,     7,    7,      7,   7,     7,   7,   7,   7,    7
               DCD   7,     7,    7,      7,   7,     7,   7,   7,   7,    7   
           
        
    END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -