You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

196 lines
11 KiB

;* ======================================================================== *;
;* TEXAS INSTRUMENTS, INC. *;
;* *;
;* IMGLIB DSP Image/Video Processing Library *;
;* *;
;* Release: Revision 1.04b *;
;* CVS Revision: 1.5 Sun Sep 29 03:32:27 2002 (UTC) *;
;* Snapshot date: 23-Oct-2003 *;
;* *;
;* This library contains proprietary intellectual property of Texas *;
;* Instruments, Inc. The library and its source code are protected by *;
;* various copyrights, and portions may also be protected by patents or *;
;* other legal protections. *;
;* *;
;* This software is licensed for use with Texas Instruments TMS320 *;
;* family DSPs. This license was provided to you prior to installing *;
;* the software. You may review this license by consulting the file *;
;* TI_license.PDF which accompanies the files in this library. *;
;* ------------------------------------------------------------------------ *;
;* Copyright (C) 2003 Texas Instruments, Incorporated. *;
;* All Rights Reserved. *;
;* ======================================================================== *;
;* ======================================================================== *;
;* Assembler compatibility shim for assembling 4.30 and later code on *;
;* tools prior to 4.30. *;
;* ======================================================================== *;
.if $isdefed(".ASSEMBLER_VERSION")
.asg .ASSEMBLER_VERSION, $asmver
.else
.asg 0, $asmver
.endif
.if ($asmver < 430)
.asg B, CALL ; Function Call
.asg B, RET ; Return from a Function
.asg B, CALLRET ; Function call with Call / Ret chaining.
.if .TMS320C6400
.asg BNOP, CALLNOP ; C64x BNOP as a Fn. Call
.asg BNOP, RETNOP ; C64x BNOP as a Fn. Return
.asg BNOP, CRNOP ; C64x Fn call w/, Call/Ret chaining via BNOP.
.endif
.asg , .asmfunc ; .func equivalent for hand-assembly code
.asg , .endasmfunc ; .endfunc equivalent for hand-assembly code
.endif
;* ======================================================================== *;
;* End of assembler compatibility shim. *;
;* ======================================================================== *;
* ========================================================================= *
* TEXAS INSTRUMENTS, INC. *
* *
* NAME *
* IMG_pix_sat -- Pixel saturate and pack. *
* *
* REVISION DATE *
* 23-May-2000 *
* *
* USAGE *
* This routine is C callable, and has the following C prototype: *
* *
* void IMG_pix_sat *
* ( *
* int n, /* Number of pixels */ *
* const short *restrict in_data, /* Incoming data */ *
* unsigned char *restrict out_data /* Outgoing data */ *
* ); *
* *
* DESCRIPTION *
* The function IMG_pix_sat() takes signed 16-bit input pixels and *
* saturates them to unsigned 8-bit results. Pixel values above *
* 255 are clamped to 255, and values below 0 are clamped to 0. *
* *
* TECHNIQUES *
* The inner loop has been unrolled to fill a 6 cycle loop. This *
* allows the code to be interruptible. *
* *
* The prolog and epilog have been collapsed into the kernel. Also, *
* most of the setup and all of the exit code has been overlapped *
* with the kernel. The result is that the function runs with a *
* very minimum amount of overhead. *
* *
* ASSUMPTIONS *
* The input size must be a multiple of 32 pixels. The code behaves *
* correctly if a pixel count of zero is passed in. *
* *
* NOTES *
* This code is fully interruptible. *
* *
* MEMORY NOTE *
* The input and output data must be double-word aligned. *
* *
* This code accesses 128 bits every cycle. No bank conflicts occur. *
* *
* CYCLES *
* cycles = (pixels / 16) * 3 + 13 *
* (This includes 6 cycles of function call overhead.) *
* For pixels = 640, cycles = 133. *
* *
* CODESIZE *
* 116 bytes. *
* *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *
.sect ".text:_pix_sat"
.global _IMG_pix_sat
_IMG_pix_sat:
; ====================== SYMBOLIC REGISTER ASSIGNMENTS ==================== ;
.asg A4, A_n
.asg A0, A_i
.asg A1, A_c
.asg A2, A_l
.asg B3, B_ret
.asg A6, A_o_data
.asg B4, B_i_data
.asg A3, A_i_data
.asg B21, B_FE
.asg B20, B_DC
.asg B17, B_BA
.asg B16, B_98
.asg B23, B_76
.asg B22, B_54
.asg B9, B_32
.asg B8, B_10
.asg A21, A_FE
.asg A20, A_DC
.asg A23, A_BA
.asg A22, A_98
.asg A25, A_76
.asg A24, A_54
.asg A17, A_32
.asg A16, A_10
.asg B19, B_FEDC
.asg B18, B_BA98
.asg B7, B_7654
.asg B6, B_3210
.asg A9, A_FEDC
.asg A8, A_BA98
.asg A19, A_7654
.asg A18, A_3210
.asg B5, B_o_data
; ========================================================================= ;
MV .L1X B_i_data, A_i_data
|| SHRU .S1 A_n, 5, A_i
|| MVK .D1 1, A_c
; ============================ PIPE LOOP KERNEL =========================== ;
loop:
[ A_i]BDEC .S1 loop, A_i ;[ 7,1]
||[ A_i]LDDW .D2T1 *+B_i_data [6], A_BA:A_98 ;[ 1,2]
||[ A_i]LDDW .D1T2 *+A_i_data [1], B_76:B_54 ;[ 1,2]
||[!A_i]RET .S2 B_ret
|| MV .L1 A_i, A_l
SPACKU4 .S1 A_FE, A_DC, A_FEDC ;[ 8,1]
|| SPACKU4 .S2 B_32, B_10, B_3210 ;[ 8,1]
||[ A_l]LDDW .D2T1 *+B_i_data [7], A_FE:A_DC ;[ 2,2]
||[ A_l]LDDW .D1T2 * A_i_data++[8], B_32:B_10 ;[ 2,2]
|| MV .L2X A_o_data, B_o_data
SPACKU4 .S1 A_32, A_10, A_3210 ;[ 9,1]
|| SPACKU4 .S2 B_FE, B_DC, B_FEDC ;[ 9,1]
||[ A_l]LDDW .D2T1 *+B_i_data [4], A_32:A_10 ;[ 3,2]
||[ A_l]LDDW .D1T2 *-A_i_data [5], B_FE:B_DC ;[ 3,2]
SPACKU4 .S1 A_76, A_54, A_7654 ;[10,1]
|| SPACKU4 .S2 B_BA, B_98, B_BA98 ;[10,1]
||[ A_l]LDDW .D2T1 *+B_i_data [5], A_76:A_54 ;[ 4,2]
||[ A_l]LDDW .D1T2 *-A_i_data [6], B_BA:B_98 ;[ 4,2]
[!A_c]STDW .D2T1 A_7654:A_3210, *+B_o_data [2] ;[11,1]
||[!A_c]STDW .D1T2 B_FEDC:B_BA98, *+A_o_data [1] ;[11,1]
[!A_c]STDW .D2T1 A_FEDC:A_BA98, *+B_o_data [3] ;[12,1]
||[!A_c]STDW .D1T2 B_7654:B_3210, * A_o_data++[4] ;[12,1]
|| SPACKU4 .S1 A_BA, A_98, A_BA98 ;[ 6,2]
|| SPACKU4 .S2 B_76, B_54, B_7654 ;[ 6,2]
|| MVK .L1 0, A_c
|| MV .L2X A_i_data, B_i_data
; ========================================================================= ;
* ========================================================================= *
* End of file: img_pix_sat.asm *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *