tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

odintrin.h (2550B)


      1 /*
      2 * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved.
      3 *
      4 * This source code is subject to the terms of the BSD 2 Clause License and
      5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      6 * was not distributed with this source code in the LICENSE file, you can
      7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
      8 * Media Patent License 1.0 was not distributed with this source code in the
      9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     10 */
     11 
     12 /* clang-format off */
     13 
     14 #ifndef AOM_AOM_DSP_ODINTRIN_H_
     15 #define AOM_AOM_DSP_ODINTRIN_H_
     16 
     17 #include <stdlib.h>
     18 #include <string.h>
     19 
     20 #include "aom/aom_integer.h"
     21 #include "aom_dsp/aom_dsp_common.h"
     22 #include "aom_ports/bitops.h"
     23 
     24 #ifdef __cplusplus
     25 extern "C" {
     26 #endif
     27 
     28 typedef int od_coeff;
     29 
     30 #define OD_DIVU_DMAX (1024)
     31 
     32 extern uint32_t OD_DIVU_SMALL_CONSTS[OD_DIVU_DMAX][2];
     33 
     34 /*Translate unsigned division by small divisors into multiplications.*/
     35 #define OD_DIVU_SMALL(_x, _d)                                     \
     36  ((uint32_t)((OD_DIVU_SMALL_CONSTS[(_d)-1][0] * (uint64_t)(_x) + \
     37               OD_DIVU_SMALL_CONSTS[(_d)-1][1]) >>                \
     38              32) >>                                              \
     39   (OD_ILOG_NZ(_d) - 1))
     40 
     41 #define OD_DIVU(_x, _d) \
     42  (((_d) < OD_DIVU_DMAX) ? (OD_DIVU_SMALL((_x), (_d))) : ((_x) / (_d)))
     43 
     44 #define OD_MINI AOMMIN
     45 #define OD_MAXI AOMMAX
     46 #define OD_CLAMPI(min, val, max) (OD_MAXI(min, OD_MINI(val, max)))
     47 
     48 /*Integer logarithm (base 2) of a nonzero unsigned 32-bit integer.
     49  OD_ILOG_NZ(x) = (int)floor(log2(x)) + 1.*/
     50 #define OD_ILOG_NZ(x) (1 + get_msb(x))
     51 
     52 /*Enable special features for gcc and compatible compilers.*/
     53 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
     54 #define OD_GNUC_PREREQ(maj, min, pat)                                \
     55  ((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__ >= \
     56   ((maj) << 16) + ((min) << 8) + pat)  // NOLINT
     57 #else
     58 #define OD_GNUC_PREREQ(maj, min, pat) (0)
     59 #endif
     60 
     61 #if OD_GNUC_PREREQ(3, 4, 0)
     62 #define OD_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
     63 #else
     64 #define OD_WARN_UNUSED_RESULT
     65 #endif
     66 
     67 #if OD_GNUC_PREREQ(3, 4, 0)
     68 #define OD_ARG_NONNULL(x) __attribute__((__nonnull__(x)))
     69 #else
     70 #define OD_ARG_NONNULL(x)
     71 #endif
     72 
     73 /*All of these macros should expect floats as arguments.*/
     74 # define OD_SIGNMASK(a) (-((a) < 0))
     75 # define OD_FLIPSIGNI(a, b) (((a) + OD_SIGNMASK(b)) ^ OD_SIGNMASK(b))
     76 
     77 #ifdef __cplusplus
     78 }  // extern "C"
     79 #endif
     80 
     81 #endif  // AOM_AOM_DSP_ODINTRIN_H_