Home | History | Annotate | Download | only in vpx_ports
      1 /*
      2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 
     12 #ifndef VPX_PORTS_MEM_H_
     13 #define VPX_PORTS_MEM_H_
     14 
     15 #include "vpx_config.h"
     16 #include "vpx/vpx_integer.h"
     17 
     18 #if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C)
     19 #define DECLARE_ALIGNED(n,typ,val)  typ val __attribute__ ((aligned (n)))
     20 #elif defined(_MSC_VER)
     21 #define DECLARE_ALIGNED(n,typ,val)  __declspec(align(n)) typ val
     22 #else
     23 #warning No alignment directives known for this compiler.
     24 #define DECLARE_ALIGNED(n,typ,val)  typ val
     25 #endif
     26 
     27 /* Indicates that the usage of the specified variable has been audited to assure
     28  * that it's safe to use uninitialized. Silences 'may be used uninitialized'
     29  * warnings on gcc.
     30  */
     31 #if defined(__GNUC__) && __GNUC__
     32 #define UNINITIALIZED_IS_SAFE(x) x=x
     33 #else
     34 #define UNINITIALIZED_IS_SAFE(x) x
     35 #endif
     36 
     37 #if HAVE_NEON && defined(_MSC_VER)
     38 #define __builtin_prefetch(x)
     39 #endif
     40 
     41 /* Shift down with rounding */
     42 #define ROUND_POWER_OF_TWO(value, n) \
     43     (((value) + (1 << ((n) - 1))) >> (n))
     44 
     45 #define ALIGN_POWER_OF_TWO(value, n) \
     46     (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
     47 
     48 #if CONFIG_VP9_HIGHBITDEPTH
     49 #define CONVERT_TO_SHORTPTR(x) ((uint16_t*)(((uintptr_t)x) << 1))
     50 #define CONVERT_TO_BYTEPTR(x) ((uint8_t*)(((uintptr_t)x) >> 1))
     51 #endif  // CONFIG_VP9_HIGHBITDEPTH
     52 
     53 #endif  // VPX_PORTS_MEM_H_
     54