📄 mark_coeffs.asm
字号:
/*******************************************************************************
Copyright(c) 2000 - 2002 Analog Devices. All Rights Reserved.
Developed by Joint Development Software Application Team, IPDC, Bangalore, India
for Blackfin DSPs ( Micro Signal Architecture 1.0 specification).
By using this module you agree to the terms of the Analog Devices License
Agreement for DSP Software.
********************************************************************************
Module name : mark_coeffs.asm
Label name : __mark_coeffs
Version : 1.1
Change History :
Version Date Author Comments
1.1 02/24/2002 Sunder Modified to match
silicon cycle count
1.0 10/20/2001 Sunder Original
Description : This function generates a zerotree map which contains
a 2 bit label for each coeff. as explained below.
Bit 0 : 0 - coeff. is zero , 1 - coeff is non-zero
Bit 1 : 0 - All children are zero , 1 - some child is non-zero
Prototype : void __mark_coeffs(int levels, unsigned short width,
unsigned short height, char q_image[], char zerotreemap[]);
levels -> No. of wavelet decomposition levels
width -> Width of image
height -> Height of image
q_image -> Address of quantized image
zerotreemap -> Address of zerotree map.
Registers used : R0-R7, I1, I2, M0-M3, L1, L2, P0-P5, LC0, LC1.
Performance :
Code Size : 302 Bytes
Core Cycle count : (L-1)*24 + 8*H + 23*H*W/4 - 12*H*(1/2)^L -
(11*H*W/4)*(1/4)^(L-1)
where L = no. of levels, W = image width, H = image Height
*******************************************************************************/
.section L1_code;
.global __mark_coeffs;
.align 8;
__mark_coeffs:
[--SP] = (R7:4,P5:3); //PUSH R7-R4,P5-P3 ON STACK
L1 = 0;
L2 = 0;
M0 = R1; //Width in M0
R1 = R1>>1 || P3 = [SP+44];
//Address of zerotreemap(ztmap) in P3;
// Width/2
R5 = R2>>1 || P2 = [SP+40];
//Height/2 in R5 ; Address of first element in P2
R2 = R1.L*R2.L (FU); //Width * Height/2 in R2
P4 = R2;
P0 = R1; // Width/2 in P0;
P5 = 1;
P1 = R5;
P5 -= P4; //-(width*height/2 -1)
P4 -= P0; //(height-1)*width/2
R7 = P5;
P2 = P2+P0;
/* The following nested loops are for marking coeffs in the highest band*/
/* The following nested loop is only for the highest HL band*/
LSETUP(_out_loop_hl_start,_out_loop_hl_end) LC0 = P1;
//outer loop
P1 = R2;
_out_loop_hl_start:
P3 = P3+P0;
LSETUP(_in_loop_hl_start,_in_loop_hl_end) LC1 = P0;
//inner loop
_in_loop_hl_start:
R3 = B[P2++](Z);
CC = R3;
R3 = CC;
_in_loop_hl_end:
B[P3++] = R3;
_out_loop_hl_end:
P2 = P2+P0;
P2 -= P0;
/* The follwing nested loop is for LH and HH bands*/
LSETUP(_out_loop_lhhh_start,_out_loop_lhhh_end) LC0 = P1>>1;
//outer loop
_out_loop_lhhh_start:
R3 = B[P2++](Z);
CC = R3;
R3 = CC;
B[P3++] = R3;
R3 = B[P2++](Z);
CC = R3;
R3 = CC;
_out_loop_lhhh_end:
B[P3++] = R3 ;
/* The following three nested loops are for bands at lower scales */
R0 += -1; // levels-1: counter for the level_loop
_level_loop_start:
M1 = P4; //(h-1)*width/2 in M1
M2 = P0; // (width/2) in M2
P5 += 1;
M3 = P5; //-(width*height/2 -2) in M3
R5 = R5>>1 || P3 = [SP+44];
//height/4 || Reload start address of ztmap;
P0 = P0>>1; //width/4
P1 = R5; //h/4 in P1 to be loaded in LC0
P2 = [SP+40]; //Reload start address of image;
I1 = P3; //I1 = ztmap start
I1 += M2; //I1 = ztmap+w/2, for a pair of children
I2 = I1;
R2 = R2>>1 || I2 += M0; //height*width/4 || I2 = ztmap+w+w/2,
// for the lower children pair
P2 = P2+P0; //P2 = q_image+w/4
P3 = P3+P0; //P3 = ztmap+w/4
P4 = P4>>1; //(height-1)*width/4
R7 = R7+R2;
P5 = R7;
LSETUP(_out_loop_2_start,_out_loop_2_end) LC0 = P1;
//outer loop
_out_loop_2_start:
LSETUP(_in_loop_2_start,_in_loop_2_end) LC1 = P0;
//inner loop
_in_loop_2_start:
R3 = B[P2](Z)||R4.L = W[I1];
//load the current q_image value || load the ztmap
R4.H = W[I2] || I1 += M1;
//value of the children || I1 = I1+(h-1)*w/2
CC = R4;
R4 = CC;
CC = R3;
R3 = CC;
P2 = P2+P4; //P2 = P2+(h-1)*w/4
R4 = R4<<1 || I2 += M1;
R3 = R3|R4;
B[P3] = R3;
P3 = P3+P4; //P3 = P3+(h-1)*w/4
R3 = B[P2](Z) || R4.L = W[I1];
R4.H = W[I2] || I1 += M2;
CC = R4;
R4 = CC;
CC = R3;
R3 = CC;
P2 = P2+P0;
R4 = R4<<1 || I2 += M2;
R3 = R3|R4;
B[P3] = R3;
P3 = P3+P0;
R3 = B[P2](Z) || R4.L = W[I1];
R4.H = W[I2] || I1 += M3;
CC = R4;
R4 = CC;
CC = R3;
R3 = CC;
P2 = P2+P5;
R4 = R4<<1 || I2 += M3;
R3 = R3|R4;
B[P3] = R3;
_in_loop_2_end:
P3 = P3+P5;
P1 = M0; //P1 = width
P2 = P2+P1;
P3 = P3+P1;
P2 -= P0; //P2 = P2+width-width/4
P3 -= P0;
I1 += M0;
I1 += M0;
I2 += M0;
I2 += M0;
I1 -= M2; //I1 = I1+2*width-width/2
_out_loop_2_end:
I2 -= M2;
R0 += -1;
CC = R0 == 0;
IF !CC JUMP _level_loop_start (bp);
(R7:4,P5:3) = [SP++]; //POP R7-R4,P5-P3 FROM STACK
RTS;
NOP; //to avoid one stall if LINK or UNLINK happens to be
//the next instruction after RTS in the memory.
__mark_coeffs.end:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -