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 #ifndef __IMPEG2_MACROS_H__ 21 #define __IMPEG2_MACROS_H__ 22 23 #define ABS(x) ((x) < 0 ? (-1 * (x)) : (x)) 24 25 #define MAX(x,y) ((x) > (y) ? (x) : (y)) 26 27 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 28 29 #define CLIP(Number,Max,Min) if((Number) > (Max)) (Number) = (Max); \ 30 else if((Number) < (Min)) (Number) = (Min) 31 32 #define SIGN(Number) (((Number) < 0) ? -1 : 1) 33 34 35 #define BITS(val,msb,lsb) (UWORD16)((((val) >> (lsb)) & ((1 << ((msb) - (lsb) + 1)) - 1))) 36 37 #define BIT(val,bit) (UWORD16)(((val) >> (bit)) & 0x1) 38 39 #define IS_VAL_IN_RANGE(val,upperLimit,lowerLimit) ((val) >= (lowerLimit) && (val) <= (upperLimit)) 40 41 #define MSW(dword) (dword >> 16) 42 #define LSW(dword) (dword & 0xFFFF) 43 #define DIV_2_RND(mv) (((mv) + ((mv) > 0)) >> 1) 44 #define IS_NEG(Number) (((Number) < 0) ? 1 : 0) 45 46 #define ALIGN128(x) ((((x) + 127) >> 7) << 7) 47 #define ALIGN64(x) ((((x) + 63) >> 6) << 6) 48 #define ALIGN32(x) ((((x) + 31) >> 5) << 5) 49 #define ALIGN16(x) ((((x) + 15) >> 4) << 4) 50 #define ALIGN8(x) ((((x) + 7) >> 3) << 3) 51 52 53 #define RETURN_IF(cond, retval) if(cond) {return (retval);} 54 #define UNUSED(x) ((void)(x)) 55 56 57 #define ASSERT(x) assert(x) 58 59 60 #endif /* __IMPEG2_IT_MACROS_H__ */ 61