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)26 static __inline UWORD32 CLZ(UWORD32 u4_word)
27 {
28 if(u4_word)
29 return (__builtin_clz(u4_word));
30 else
31 return 32;
32 }
CLIP_U8(WORD32 x)33 static __inline WORD32 CLIP_U8(WORD32 x)
34 {
35 asm("usat %0, #8, %1" : "=r"(x) : "r"(x));
36 return x;
37 }
38
CLIP_S8(WORD32 x)39 static __inline WORD32 CLIP_S8(WORD32 x)
40 {
41 asm("ssat %0, #8, %1" : "=r"(x) : "r"(x));
42 return x;
43 }
44
CLIP_U12(WORD32 x)45 static __inline WORD32 CLIP_U12(WORD32 x)
46 {
47 asm("usat %0, #12, %1" : "=r"(x) : "r"(x));
48 return x;
49 }
50
CLIP_S12(WORD32 x)51 static __inline WORD32 CLIP_S12(WORD32 x)
52 {
53 asm("ssat %0, #12, %1" : "=r"(x) : "r"(x));
54 return x;
55 }
56
CLIP_U16(WORD32 x)57 static __inline WORD32 CLIP_U16(WORD32 x)
58 {
59 asm("usat %0, #16, %1" : "=r"(x) : "r"(x));
60 return x;
61 }
CLIP_S16(WORD32 x)62 static __inline WORD32 CLIP_S16(WORD32 x)
63 {
64 asm("ssat %0, #16, %1" : "=r"(x) : "r"(x));
65 return x;
66 }
67
68 #define PLD(x) __pld(x)
69
70 #endif /* __IMPEG2_PLATFORM_MACROS_H__ */
71