xref: /aosp_15_r20/external/speex/tmv/fixed_tm.h (revision 28e138c64d234588b5cd2a8a403b584bd3036e4e)
1 /* Copyright (C) 2007 Hong Zhiqian */
2 /**
3    @file fixed_tm.h
4    @author Hong Zhiqian
5    @brief Various compatibility routines for Speex (TriMedia version)
6 */
7 /*
8    Redistribution and use in source and binary forms, with or without
9    modification, are permitted provided that the following conditions
10    are met:
11 
12    - Redistributions of source code must retain the above copyright
13    notice, this list of conditions and the following disclaimer.
14 
15    - Redistributions in binary form must reproduce the above copyright
16    notice, this list of conditions and the following disclaimer in the
17    documentation and/or other materials provided with the distribution.
18 
19    - Neither the name of the Xiph.org Foundation nor the names of its
20    contributors may be used to endorse or promote products derived from
21    this software without specific prior written permission.
22 
23    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
27    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 #ifndef FIXED_TM_H
36 #define FIXED_TM_H
37 
38 #include <ops/custom_defs.h>
39 
40 
41 #undef	SATURATE
42 #undef	SATURATE16
43 #undef	SATURATE32
44 #define SATURATE(x,a)			iclipi(x,a)
45 #define SATURATE16(x,a) 		iclipi(x,a)
46 #define SATURATE32(x,a) 		iclipi(x,a)
47 
48 #undef	EXTEND32
49 #define	EXTEND32(x)				sex16(x)
50 
51 #undef	NEG16
52 #undef	NEG32
53 #define NEG16(x)				ineg((int)(x))
54 #define NEG32(x)				ineg(x)
55 
56 #undef	ABS
57 #undef	ABS16
58 #undef	ABS32
59 #define	ABS(x)					iabs(x)
60 #define	ABS32(x)				iabs(x)
61 #define	ABS16(x)				iabs((int)(x))
62 
63 #undef	MIN16
64 #undef	MIN32
65 #define	MIN16(a,b)				imin((int)(a),(int)(b))
66 #define	MIN32(a,b)				imin(a,b)
67 
68 #undef	MAX16
69 #undef	MAX32
70 #define	MAX16(a,b)				imax((int)(a),(int)(b))
71 #define	MAX32(a,b)				imax(a,b)
72 
73 #undef	ADD16
74 #undef	SUB16
75 #undef	ADD32
76 #undef	SUB32
77 #undef	MULT16_16
78 #undef	MULT16_16_16
79 
80 #define ADD16(a,b)				((int)(a) + (int)(b))
81 #define SUB16(a,b)				((int)(a) - (int)(b))
82 #define ADD32(a,b)				((int)(a) + (int)(b))
83 #define SUB32(a,b)				((int)(a) - (int)(b))
84 #define MULT16_16_16(a,b)		((int)(a) * (int)(b))
85 #define MULT16_16(a,b)			((int)(a) * (int)(b))
86 
87 #if TM_DEBUGMEM_ALIGNNMENT
88 #include <stdio.h>
89 #define TMDEBUG_ALIGNMEM(x)																	\
90 		{	if( ((int)(x) & (int)(0x00000003)) != 0 )										\
91 			{	printf("memory not align. file: %s, line: %d\n",  __FILE__, __LINE__);		\
92 			}																				\
93 		}
94 
95 #else
96 #define TMDEBUG_ALIGNMEM(x)
97 #endif
98 
99 #endif
100 
101