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_PLATFORM_MACROS_H__ 21 #define __IMPEG2_PLATFORM_MACROS_H__ 22 23 24 #define CONV_LE_TO_BE(u4_temp2,u4_temp1) u4_temp2 = __builtin_bswap32(u4_temp1); 25 CLZ(UWORD32 u4_word)26static __inline UWORD32 CLZ(UWORD32 u4_word) 27 { 28 if(u4_word) 29 return (__builtin_clz(u4_word)); 30 else 31 return 32; 32 } 33 34 35 #define CLIP_U8(x) ((x) > 255) ? (255) : (((x) < 0) ? (0) : (x)) 36 #define CLIP_S8(x) ((x) > 127) ? (127) : (((x) < -128) ? (-128) : (x)) 37 38 #define CLIP_U12(x) ((x) > 4095) ? (4095) : (((x) < 0) ? (0) : (x)) 39 #define CLIP_S12(x) ((x) > 2047) ? (2047) : (((x) < -2048) ? (-2048) : (x)) 40 41 #define CLIP_U16(x) ((x) > 65535) ? (65535) : (((x) < 0) ? (0) : (x)) 42 #define CLIP_S16(x) ((x) > 32767) ? (32767) : (((x) < -32768) ? (-32768) : (x)) 43 44 #endif /* __IMPEG2_PLATFORM_MACROS_H__ */ 45