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

📄 ztw_mpeg4.asm

📁 用于视频图像的解压缩
💻 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     : ztw_mpeg4.asm
Label name      : __ztw_mpeg4
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         02/24/2002  Sunder        Modified to match
                                                      silicon cycle count
                1.0         10/20/2001  Sunder        Original 

Description     : This is the main asm function in the "zero tree scanning 
                  module".It takes a quantized, transformed image as input. 
                  This function calls the __mark_coeffs function that computes 
                  a "zero tree map". It then generates the offsets and then 
                  calls the __scan_block function in a loop to scan the 
                  coefficients in "tree-depth fashion".

Assumptions     : The width and height of the image must be divisible by 
                  2^(levels), where "levels" is the no. of wavelet decomposition
                  levels.

Prototype       : int __ztw_mpeg4(int levels,int width,int height,
                                  char q_image[],char ztmap[],
                                  char out_bitstream[],int offsets[]);

                    levels        -> No. of wavelet decomposition levels, 
                    width         -> Width of image,
                    height        -> Height of image, 
                    q_image       -> Address of the quantized image, 
                    ztmap         -> Address of zero tree map, 
                    out_bitstream -> Address of the output bitstream
                    offsets       -> Address of the offsets array

Registers used  : R0-R7, I0, M0-M3, L0, P0-P5, LC0, LC1.
    
Performance     : 
                Code Size   : 262 Bytes
                Cycle Count : 72699 Cycles
(The image used was "woman", size 64x64. The 'DB1' wavelet with 2 levels of 
decomposition was used. The wavelet coefficients were shifted and scaled so that
they lie between 0-255 and then quantized with 128 as the threshold.)

Reference       : ISO/IEC 14496-2:1999(E), MPEG-4 Document
*******************************************************************************/
.section L1_code;
.global    __ztw_mpeg4;
.align 8;
.extern __scan_block;
.extern __mark_coeffs;

__ztw_mpeg4:

    [--SP] = (R7:4,P5:3);   //PUSH R7-R4,P5-P3 ON STACK
    L0 = 0;
    LINK 32;
    R6 = R1<<0 || P0 = [FP+48];
                            // width in R6 || Address of start of q_image 
    R7 = R2<<0 || P4 = [FP+52];
                            //height in R7 || Address of start of ZT map 
    P3 = [FP+60];           //Address of start Offsets
    R5 = R0<<0; 
    [SP+12] = P0;
                            //levels in R5 || store q_image in stack for 
                            //coeff_mark 
    [SP+16] = P4;           //store ztmap in stack for coeff_mark

    CALL __mark_coeffs;
    [SP+16] = R6;           //store width in stack for scan_block
    P1 = 0x07;              //Loop counter

    LSETUP(_offset_loop_start,_offset_loop_end) LC0 = P1;
    [SP+12] = P3;           //store offsets in stack for scan_block
    
    R3 = 2;                 // Power of 2 count used for offset generation
    R2 = R3-R6;             //offsets for odd multiples of 4,16,64....
    R1 = R6<<0;             //offsets for odd multiples of 8,32,128...
    [P3++] = R1;
    [P3++] = R2; 
    
    
_offset_loop_start:
        R1 = R1-R3;
    
        R4 = R3.L*R6.L (FU)|| [P3++] = R1;
        R2 = R2-R4;
    
_offset_loop_end:
        R3 = R3<<1 || [P3++] = R2;
    
    M3 = R6;                //width in M3
    R6 >>= R5;              // dcwidth in R6 = width/(2^levels)
    R1 = R1-R3;             //generate the last offset
    R3 = R7.L*R6.L (FU) || [P3] = R1;
                            //width*height/(2^levels) in R3 || store last offset
    R2 = R3-R6;             //width*(height-1)/(2^levels) in R3
    M0 = R2;                //width*(height-1)/(2^levels) in M0
    R2 = -R3;               //-(width*height/(2^levels))
    R2 += 1;
    M2 = R2;                //-(width*height/(2^levels) -1) in M2
    M1 = R6;                //width/(2^lev) in M1
    R7 >>= R5;              //dcheight in R7 = height/(2^levels)
    R5 += -1;
    P5 = R5;                //(levels-1) in P5 to be loaded into the loop 
                            //counter
    R5 = 0x02;              //For XORing with the ztmap value
    P2 = [FP+56];           //Address of out_bit_stream
    I0 = M1;                //Coordinate of the first element to be 
                            //scanned (lowest HL band)
    
_main_loop_start:
    P3 = I0;
    P1 = P4+P3;             //Actual address of the first element to be scanned
    R0 = B[P1](Z);
    R0 = R0^R5;
    B[P2++] = R0;           //Store the zerotree symbol in the bitstream
    R4 = 0x01;
    LSETUP(_scan_loop_1_start,_scan_loop_1_end) LC1 = P5;
    
_scan_loop_1_start:
        R4 <<= 2;           //Totalsize of the block to be scanned
        P3 = P3<<1;
        P1 = P4+P3;         //start address of the block
        R0 = P1;
        R1 = R4;
        R2 = P2;            //Bitstream location where the next element has to 
                            //be stored
        CALL __scan_block;
_scan_loop_1_end:
        P2 = R0;            //Address of the next location in bitstream after 
                            //scan block
    
    
    I0 += M0;               //Modify I0 to point to the element in level LH
    P3 = I0;
    P1 = P4+P3;
    R0 = B[P1](Z);
    R0 = R0^R5;
    B[P2++] = R0;
    R4 = 0x01;
    LSETUP(_scan_loop_2_start,_scan_loop_2_end) LC1 = P5;
    
_scan_loop_2_start:
        R4 <<= 2;
        P3 = P3<<1;
        P1 = P4+P3;
        R0 = P1;
        R1 = R4;
        R2 = P2;
        CALL __scan_block;
_scan_loop_2_end:
        P2 = R0;
    
    I0 += M1;               //Modify I0 to point to the element in level HH
    P3 = I0;
    P1 = P4+P3;
    R0 = B[P1](Z);
    R0 = R0^R5;
    B[P2++] = R0;
    R4 = 0x01;
    LSETUP(_scan_loop_3_start,_scan_loop_3_end) LC1 = P5;
    
_scan_loop_3_start:
        R4 <<= 2;
        P3 = P3<<1;
        P1 = P4+P3;
        R0 = P1;
        R1 = R4;
        R2 = P2;
        CALL __scan_block;
_scan_loop_3_end:
        P2 = R0;
    
    I0 += M2;
    R6 += -1;               //Decrement R6
    CC = R6 == 0;
    
    IF !CC JUMP _main_loop_start (bp);
    
    R6 = M1;                //Reload DCwidth in R6
    I0 += M3;
    I0 -= M1;
    R7 += -1;               //decrement R7
    CC = R7 == 0;
    IF !CC JUMP _main_loop_start (bp);
    
    P1 = [FP+56];           //Reload start address of bitstream
    UNLINK;
    P2 -= P1;               // Compute No. of symbols written
    (R7:4,P5:3) = [SP++];   //POP R7-R4,P5-P3 FROM STACK
    R0 = P2;                //Return no. of symbols written
    RTS;
    
__ztw_mpeg4.end:    

⌨️ 快捷键说明

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