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

📄 wlift_bior_7_9_jpeg2000.asm

📁 利用ADI公司 Blackfin dsp实现 jpeg2
💻 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     : wlift_bior_7_9_JPEG2000.asm
Label Name      : __wlift_bior_7_9_JPEG2000
Version         :   1.3
Change History  :

                Version     Date          Author        Comments
                1.3         11/18/2002    Swarnalatha   Tested with VDSP++ 3.0
                                                        compiler 6.2.2 on 
                                                        ADSP-21535 Rev.0.2
                1.2         11/13/2002    Swarnalatha   Tested with VDSP++ 3.0
                                                        on ADSP-21535 Rev. 0.2
                1.1         03/06/2002    Manoj         Modified to match
                                                        silicon cycle count
                1.0         06/29/2001    Manoj         Original 

Description     : This function performs inplace wavelet analysis using the 
                  integer lifting principle. The wavelet chosen for this 
                  function is the bior7.9, which is used in irreversible FWT 
                  scheme of JPEG2000.

                  Let X(0:n-1) be the sequence to be synthesized, Xext is a 
                  periodic repetition of x. For bior7.9 wavelet, Xext is 
                    Xext(-4:n+3)=[x(4) x(3) x(2) x(1) x(0) x(1) .... x(n-1) 
                                                x(n-2) x(n-3) x(n-4) x(n-5)].
                  The extension sequence is required to compute the boundary 
                  pixels.

                  First Lifting:
                    X(2n+1) <- X(2n+1) + (Alpha * [X(2n) + X(2n+2)])
                    X(2n)   <- X(2n) + (Beta * [X(2n-1) + X(2n+1)])
                  Second Lifting:
                    X(2n+1) <- X(2n+1) + (Gamma * [X(2n) + X(2n+2)])
                    X(2n)   <- 1/K * [X(2n) + (Delta * [X(2n-1) + X(2n+1)])]
                  Scaling   
                    X(2n+1) <- -K * X(2n+1)
                  where, 
                  Alpha = 1.586134342 (approximated in 2.14 format as 0x6583)
                  Beta  = 0.052980118 (approximated in 1.15 format as 0x06C8)
                  Gamma = 0.882911075 (approximated in 1.15 format as 0x7103)
                  Delta = 0.443506852 (approximated in 1.15 format as 0x38C5)
                  -K    = -0.443506852 (approximated in 1.15 format as 0xC73B)
                  1/K   = 2.2547306131 (approximated in 3.13 format as 0x4826)

Prototype       : void wlift_bior_7_9_JPEG2000(short im, int N);

                        im -> address of the input vector to be lifted. 
                         N -> length of the vector (k)

Registers used  : A0, A1, R0-R3, R5-R7, I0, I1, M0-M2, L0, P0, P1, LC0.

Performance     :
                Code Size   : 388 Bytes

                Cycle Count : 2072 Cycles (For 256 Samples)
                Core        : N/2*(7+9)
*******************************************************************************/
.extern _Coeff;
.section L1_code;
.global __wlift_bior_7_9_JPEG2000;
.align 8;

__wlift_bior_7_9_JPEG2000:
    
    [--SP] = (R7:5);
    P1.L = _Coeff;
    P1.H = _Coeff;
    R1 += -4;
    P0 = R1;                //Length of input vector
    I0 = R0;                //Address of input vector
    I1 = R0;
    L0 = 0;
    M0 = 6;
    M1 = 10;
/***********************First Lifting********************************/
    
    R1.L = W[I0] || I0 += 4;//Read x[0]. Point to x[2]
    R0 = [P1];              // R0.L -> Alpha-1, R0.H -> Beta
    A1 = R1.L * R0.L || R1.H = W[I0--];
                            //x[0]* Alpha. Read x[2]. Point to x[1] 
    R3 = (A1 += R1.H * R0.L) (S2RND)|| R2.L = W[I0];
                            //Alpha*x[2]. Read x[1]. Point to x[1] 
    R3.L = R2.L + R3.H (S); //y[1]=x[1]+Alpha*(x[0]+x[2])
    R3 = R3 << 1 (V) || W[I0] = R3.L || I0 += M0;
                            //2*y[1], Store y[1]. Point to x[4] 
    M2 = 8; 
    R3.L = R3.L * R0.H || R2.L = W[I0--];
                            //Beta*(2*y[1]). Read x[4]. Point to x[3] 
    R7.L = R1.L - R3.L (S)|| R1.L = W[I0] || I0 += M0;
                            //y[0]=x[0]-Beta*(2*y[1]). Read x[3]. Point to x[6] 
    
//R1.L -> x[3], R1.H -> x[2], R2.L -> x[4], R3.L -> y[0]
    
    LSETUP($1LP_ST,$1LP_END) LC0 = P0 >> 1;
                            //(length-4)/2 
$1LP_ST:
        A1 = R2.L * R0.L     || R2.L = W[I0] || I0 -= M1;
                            //x[4]*Alpha. Read x[6]. Point to y[1] 
        R3 = (A1 += R1.H * R0.L) (S2RND)|| R2.H = W[I0--];
                            //Alpha*x[2]. Read y[1]. Point to x[0] 
        R3.L = R1.L + R3.H (S)|| W[I0] = R7.L || I0 += M1 ;
                            //y[3]=x[3]+Alpha*(x[2]+x[4]). Read x[5]. 
                            // Point to x[3]
        A0 = R2.H * R0.H || R1.L = W[I0] || I0 -= 4;
                            //(y[1]+y[3]). Store y[3] 
        R3.L = (A0 += R3.L * R0.H)|| W[I0++] = R3.L;
                            //Beta*(y[1]+y[3]) 
$1LP_END:
        R7.L = R1.H - R3.L (S) || R1.H = W[I0]|| I0 += M2;
                            //y[0]=x[0]-Beta*(y[1]+y[3]). Read x[4]. 
                            // Point to x[8] 
    
//R1.L -> x[2n+1], R1.H -> x[2n], R2.L -> x[2n+2], R3.L -> y[2n-2]
    
    R3 = (A1 = R1.H*R0.L)  || I0 -= M1;
                            //Alpha*x[2n]. Point to y[2n-1] 
    
    R3 = R3 << 2 ;          //(Alpha*x[2n]<<1)*2.
    R3.L = R1.L + R3.H (S) || R2.H = W[I0--];
                            //y[2n+1]=x[2n+1]+2*Alpha*x[2n].Read y[2n-1]. 
                            // Point to x[2n-2] 
    A0 = R2.H * R0.H || W[I0] = R7.L || I0 += M0;
                            //(y[2n-1]+y[2n+1]).Store y[2n-2]. Point to x[2n+1]
    R3.L = (A0 += R3.L * R0.H)|| R0 = [P1+4] || W[I0--] = R3.L;
                            //Beta*(y[2n-1]+y[2n+1]).Read Gamma and Delta Store 
                            // y[2n+1]. Point to  x[2n] 
    R7.L = R1.H - R3.L (S) || R6 = [P1+8];
                            //y[2n]=x[2n]-Beta*(y[2n-1]+y[2n+1]). R6.L -> -K, 
                            // R6.H -> 1/K 
    W[I0] = R7.L;           //Store y[2n].
    I0 = I1;
/***********************Second Lifting********************************/
    R1.L = W[I0] || I0 += 4;//Read y[0]. Point to y[2]
    A1 = R1.L * R0.L || R1.H = W[I0--];
                            //y[0]* Alpha. Read y[2]. Point to y[1] 
    R3.H = (A1 += R1.H * R0.L) || R2.L = W[I0];
                            //Alpha*y[2]. Read y[1]. Point to y[1] 
    R7.L = R2.L + R3.H (S); //y[1]=y[1]+Alpha*(y[0]+y[2])
    R3 = R7 << 1 (V) || W[I0] = R7.L || I0 += M0;
                            //2*y[1], Store y[1]. Point to y[4] 
    R5.L = R7.L * R6.L;     //Scaling with -K
    
     
    R3.L = R3.L * R0.H || R2.L = W[I0--];
                            //Beta*(2*y[1]). Read y[4]. Point to y[3] 
    R7.L = R1.L + R3.L (S)|| R1.L = W[I0] || I0 += M0;
                            //y[0]=y[0]-Beta*(2*y[1]). Read y[3]. Point to y[6] 
    
//R1.L -> y[3], R1.H -> y[2], R2.L -> y[4], R3.L -> y[0]
    
    LSETUP($2LP_ST,$2LP_END) LC0 = P0 >> 1;
                            //(length-4)/2 
   
    
$2LP_ST:
        A1 = R2.L * R0.L || R2.L = W[I0] || I0 -= M1;
                            //y[4]*Alpha. Read y[6]. Point to y[1] 
        R7 = R7.L * R6.H;   //Scaling with 1/K
        R3.H = (A1 += R1.H * R0.L)|| R2.H = W[I0] ;
                            //Alpha*y[2]. Read y[1] 
        R7 = R7 << 2 ;      //Shift by 2 as 1/K is in 3.13 format.
        R3.L = R1.L + R3.H (S) || W[I0] = R5.L || I0 += M2;
                            //y[3]=y[3]+Alpha*(y[2]+y[4]). Store y[1]. 
                            // Point to y[5] 
        A0 = R2.H * R0.H || R1.L = W[I0] || I0 -= 4;
                            //(y[1]+y[3]). Read y[5]. Point to y[3] 
        R5.L = R3.L * R6.L || W[I0] = R3.L || I0 -= M0;
                            //Scaling with K Store y[3]. Point to y[0] 
        R3.L = (A0 += R3.L* R0.H) || W[I0] = R7.H ||I0 += M2;
                            //Beta*(y[1]+y[3]). Store y[0]. Point to y[4] 
$2LP_END:
        R7.L = R1.H+R3.L (S) || R1.H = W[I0]|| I0 += M2;
                            //y[0] = y[0]-Beta*(y[1]+y[3]). Read y[4]. 
                            // Point to y[8] 
    
//R1.L -> y[2n+1], R1.H -> y[2n], R2.L -> y[2n+2], R3.L -> y[2n-2]
    
    R3 = (A1 = R1.H * R0.L)(S2RND)  || I0 -= M1;
                            //Alpha*y[2n]. Point to y[2n-1] 
    R7 = R7.L * R6.H || R2.H = W[I0];
                            //Scaling with 1/K, Read y[2n-1] 
    R3.L = R1.L + R3.H (S) || W[I0--] = R5.L ;
                            //y[2n+1]=y[2n+1]+2*Alpha*y[2n].Point to y[2n-2] 
    A0 = R2.H * R0.H ;      //(y[2n-1]+y[2n+1])
    R2.L = (A0 += R3.L*R0.H);
                            //Beta*(y[2n-1]+y[2n+1]). Store y[2n+1]. 
                            // Point to  y[2n] 
    R0.L = R1.H + R2.L (S) ;//y[2n]=y[2n]-Beta*(y[2n-1]+y[2n+1]).
    R7 = R7 << 2 ;          //
    R0 = R0.L * R6.H || W[I0] = R7.H || I0 += M0;
                            //Scaling with 1/KStore y[2n-2]. Point to y[2n+1] 
    R5.L = R3.L * R6.L || R7 = [SP++];
                            //Scaling with K 
    R0 = R0 << 2 || W[I0--] = R5.L || R6 = [SP++];
    W[I0] = R0.H || R5 = [SP++];
                            //Store y[2n]. 
    RTS;
    NOP;                    //to avoid one stall if LINK or UNLINK happens to be
                            //the next instruction after RTS in the memory.
__wlift_bior_7_9_JPEG2000.end:
                            

⌨️ 快捷键说明

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