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