153a5a1b3Sopenharmony_ci/* Copyright (C) 2007 Hong Zhiqian */ 253a5a1b3Sopenharmony_ci/** 353a5a1b3Sopenharmony_ci @file fixed_tm.h 453a5a1b3Sopenharmony_ci @author Hong Zhiqian 553a5a1b3Sopenharmony_ci @brief Various compatibility routines for Speex (TriMedia version) 653a5a1b3Sopenharmony_ci*/ 753a5a1b3Sopenharmony_ci/* 853a5a1b3Sopenharmony_ci Redistribution and use in source and binary forms, with or without 953a5a1b3Sopenharmony_ci modification, are permitted provided that the following conditions 1053a5a1b3Sopenharmony_ci are met: 1153a5a1b3Sopenharmony_ci 1253a5a1b3Sopenharmony_ci - Redistributions of source code must retain the above copyright 1353a5a1b3Sopenharmony_ci notice, this list of conditions and the following disclaimer. 1453a5a1b3Sopenharmony_ci 1553a5a1b3Sopenharmony_ci - Redistributions in binary form must reproduce the above copyright 1653a5a1b3Sopenharmony_ci notice, this list of conditions and the following disclaimer in the 1753a5a1b3Sopenharmony_ci documentation and/or other materials provided with the distribution. 1853a5a1b3Sopenharmony_ci 1953a5a1b3Sopenharmony_ci - Neither the name of the Xiph.org Foundation nor the names of its 2053a5a1b3Sopenharmony_ci contributors may be used to endorse or promote products derived from 2153a5a1b3Sopenharmony_ci this software without specific prior written permission. 2253a5a1b3Sopenharmony_ci 2353a5a1b3Sopenharmony_ci THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2453a5a1b3Sopenharmony_ci ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2553a5a1b3Sopenharmony_ci LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2653a5a1b3Sopenharmony_ci A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 2753a5a1b3Sopenharmony_ci CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2853a5a1b3Sopenharmony_ci EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2953a5a1b3Sopenharmony_ci PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 3053a5a1b3Sopenharmony_ci PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 3153a5a1b3Sopenharmony_ci LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 3253a5a1b3Sopenharmony_ci NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3353a5a1b3Sopenharmony_ci SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3453a5a1b3Sopenharmony_ci*/ 3553a5a1b3Sopenharmony_ci#ifndef FIXED_TM_H 3653a5a1b3Sopenharmony_ci#define FIXED_TM_H 3753a5a1b3Sopenharmony_ci 3853a5a1b3Sopenharmony_ci#include <ops/custom_defs.h> 3953a5a1b3Sopenharmony_ci 4053a5a1b3Sopenharmony_ci 4153a5a1b3Sopenharmony_ci#undef SATURATE 4253a5a1b3Sopenharmony_ci#undef SATURATE16 4353a5a1b3Sopenharmony_ci#undef SATURATE32 4453a5a1b3Sopenharmony_ci#define SATURATE(x,a) iclipi(x,a) 4553a5a1b3Sopenharmony_ci#define SATURATE16(x,a) iclipi(x,a) 4653a5a1b3Sopenharmony_ci#define SATURATE32(x,a) iclipi(x,a) 4753a5a1b3Sopenharmony_ci 4853a5a1b3Sopenharmony_ci#undef EXTEND32 4953a5a1b3Sopenharmony_ci#define EXTEND32(x) sex16(x) 5053a5a1b3Sopenharmony_ci 5153a5a1b3Sopenharmony_ci#undef NEG16 5253a5a1b3Sopenharmony_ci#undef NEG32 5353a5a1b3Sopenharmony_ci#define NEG16(x) ineg((int)(x)) 5453a5a1b3Sopenharmony_ci#define NEG32(x) ineg(x) 5553a5a1b3Sopenharmony_ci 5653a5a1b3Sopenharmony_ci#undef ABS 5753a5a1b3Sopenharmony_ci#undef ABS16 5853a5a1b3Sopenharmony_ci#undef ABS32 5953a5a1b3Sopenharmony_ci#define ABS(x) iabs(x) 6053a5a1b3Sopenharmony_ci#define ABS32(x) iabs(x) 6153a5a1b3Sopenharmony_ci#define ABS16(x) iabs((int)(x)) 6253a5a1b3Sopenharmony_ci 6353a5a1b3Sopenharmony_ci#undef MIN16 6453a5a1b3Sopenharmony_ci#undef MIN32 6553a5a1b3Sopenharmony_ci#define MIN16(a,b) imin((int)(a),(int)(b)) 6653a5a1b3Sopenharmony_ci#define MIN32(a,b) imin(a,b) 6753a5a1b3Sopenharmony_ci 6853a5a1b3Sopenharmony_ci#undef MAX16 6953a5a1b3Sopenharmony_ci#undef MAX32 7053a5a1b3Sopenharmony_ci#define MAX16(a,b) imax((int)(a),(int)(b)) 7153a5a1b3Sopenharmony_ci#define MAX32(a,b) imax(a,b) 7253a5a1b3Sopenharmony_ci 7353a5a1b3Sopenharmony_ci#undef ADD16 7453a5a1b3Sopenharmony_ci#undef SUB16 7553a5a1b3Sopenharmony_ci#undef ADD32 7653a5a1b3Sopenharmony_ci#undef SUB32 7753a5a1b3Sopenharmony_ci#undef MULT16_16 7853a5a1b3Sopenharmony_ci#undef MULT16_16_16 7953a5a1b3Sopenharmony_ci 8053a5a1b3Sopenharmony_ci#define ADD16(a,b) ((int)(a) + (int)(b)) 8153a5a1b3Sopenharmony_ci#define SUB16(a,b) ((int)(a) - (int)(b)) 8253a5a1b3Sopenharmony_ci#define ADD32(a,b) ((int)(a) + (int)(b)) 8353a5a1b3Sopenharmony_ci#define SUB32(a,b) ((int)(a) - (int)(b)) 8453a5a1b3Sopenharmony_ci#define MULT16_16_16(a,b) ((int)(a) * (int)(b)) 8553a5a1b3Sopenharmony_ci#define MULT16_16(a,b) ((int)(a) * (int)(b)) 8653a5a1b3Sopenharmony_ci 8753a5a1b3Sopenharmony_ci#if TM_DEBUGMEM_ALIGNNMENT 8853a5a1b3Sopenharmony_ci#include <stdio.h> 8953a5a1b3Sopenharmony_ci#define TMDEBUG_ALIGNMEM(x) \ 9053a5a1b3Sopenharmony_ci { if( ((int)(x) & (int)(0x00000003)) != 0 ) \ 9153a5a1b3Sopenharmony_ci { printf("memory not align. file: %s, line: %d\n", __FILE__, __LINE__); \ 9253a5a1b3Sopenharmony_ci } \ 9353a5a1b3Sopenharmony_ci } 9453a5a1b3Sopenharmony_ci 9553a5a1b3Sopenharmony_ci#else 9653a5a1b3Sopenharmony_ci#define TMDEBUG_ALIGNMEM(x) 9753a5a1b3Sopenharmony_ci#endif 9853a5a1b3Sopenharmony_ci 9953a5a1b3Sopenharmony_ci#endif 10053a5a1b3Sopenharmony_ci 101