1 /****************************************************************************** 2 * 3 * Copyright (C) 2015 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19 */ 20 /** 21 ******************************************************************************* 22 * @file 23 * icv_macros.h 24 * 25 * @brief 26 * This header files contains all the common macros 27 * 28 * @author 29 * Ittiam 30 * 31 * @par List of Functions: 32 * 33 * @remarks 34 * None 35 * 36 ******************************************************************************* 37 */ 38 #ifndef __ICV_MACROS_H__ 39 #define __ICV_MACROS_H__ 40 41 #define ABS(x) ((x) < 0 ? (-1 * (x)) : (x)) 42 43 #define MAX(x,y) ((x) > (y) ? (x) : (y)) 44 45 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 46 47 /* Absolute difference */ 48 #define ABS_DIF(x,y) (((x) > (y)) ? ((x) - (y)) : ((y) - (x))) 49 50 #define MED3(a,b,c) (MIN(MAX( MIN((a),(b)), (c)), MAX((a),(b)))) 51 52 #define AVG(a,b) (((a) + (b) + 1) >> 1) 53 54 #define MEAN(a, b) AVG(a, b) 55 56 #define CLIP3(min, max, x) (((x) > (max)) ? (max) :(((x) < (min))? (min):(x))) 57 #define SIGN(x) (((x) < 0) ? -1 : 1) 58 59 60 #define ALIGN128(x) ((((x) + 127) >> 7) << 7) 61 #define ALIGN64(x) ((((x) + 63) >> 6) << 6) 62 #define ALIGN32(x) ((((x) + 31) >> 5) << 5) 63 #define ALIGN16(x) ((((x) + 15) >> 4) << 4) 64 #define ALIGN8(x) ((((x) + 7) >> 3) << 3) 65 66 67 #define RETURN_IF(cond, retval) if(cond) {return (retval);} 68 #define UNUSED(x) ((void)(x)) 69 70 #define ASSERT(x) assert(x) 71 72 73 #endif /* __ICV_IT_MACROS_H__ */ 74