1/****************************************************************************** 2* 3* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore 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/** 19******************************************************************************* 20* @file 21* ihevc_platform_macros.h 22* 23* @brief 24* Platform specific Macro definitions used in the codec 25* 26* @author 27* Ittiam 28* 29* @remarks 30* None 31* 32******************************************************************************* 33*/ 34#ifndef _IHEVC_PLATFORM_MACROS_H_ 35#define _IHEVC_PLATFORM_MACROS_H_ 36 37 38#define CLIP_U8(x) CLIP3((x), 0, 255) 39#define CLIP_S8(x) CLIP3((x), -128, 127) 40 41#define CLIP_U10(x) CLIP3((x), 0, 1023); 42#define CLIP_S10(x) CLIP3((x), -512, 511); 43 44#define CLIP_U12(x) CLIP3((x), 0, 4095); 45#define CLIP_S12(x) CLIP3((x), -2048, 2047); 46 47#define CLIP_U16(x) CLIP3((x), 0, 65535) 48#define CLIP_S16(x) CLIP3((x), -32768, 32767) 49 50#define ITT_BIG_ENDIAN(x) ((x << 24)) | \ 51 ((x & 0x0000ff00) << 8) | \ 52 ((x & 0x00ff0000) >> 8) | \ 53 ((UWORD32)x >> 24); 54 55#define SHL(x,y) (((y) < 32) ? ((x) << (y)) : 0) 56#define SHR(x,y) (((y) < 32) ? ((x) >> (y)) : 0) 57 58#define SHR_NEG(val,shift) ((shift>0)?(val>>shift):(val<<(-shift))) 59#define SHL_NEG(val,shift) ((shift<0)?(val>>(-shift)):(val<<shift)) 60 61static inline UWORD32 CLZ(UWORD32 x) 62{ 63 asm("clz %0, %1" : "=r"(x) : "r"(x)); 64 return x; 65} 66 67static inline UWORD32 CTZ(UWORD32 u4_word) 68{ 69 if(0 == u4_word) 70 return 31; 71 else 72 { 73 unsigned int index; 74 index = __builtin_ctz(u4_word); 75 return (UWORD32)index; 76 } 77} 78 79#define NOP(nop_cnt) {UWORD32 nop_i; for (nop_i = 0; nop_i < nop_cnt; nop_i++);} 80 81#define INLINE 82 83#define MEM_ALIGN8 __attribute__ ((aligned (8))) 84#define MEM_ALIGN16 __attribute__ ((aligned (16))) 85#define MEM_ALIGN32 __attribute__ ((aligned (32))) 86 87#endif /* _IHEVC_PLATFORM_MACROS_H_ */ 88