/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ #ifndef AOM_AOM_DSP_AOM_DSP_COMMON_H_ #define AOM_AOM_DSP_AOM_DSP_COMMON_H_ #include <limits.h> #include "config/aom_config.h" #include "aom/aom_integer.h" #include "aom_ports/mem.h" #ifdef __cplusplus extern "C" { #endif #if defined(_MSC_VER) #define AOM_FORCE_INLINE … #else #define AOM_FORCE_INLINE … #endif #define PI … #define AOMMIN(x, y) … #define AOMMAX(x, y) … #define AOMSIGN(x) … #define NELEMENTS(x) … #define IMPLIES(a, b) … #define IS_POWER_OF_TWO(x) … /* Left shifting a negative value became undefined behavior in C99 (downgraded from merely implementation-defined in C89). This should still compile to the correct thing on any two's-complement machine, but avoid ubsan warnings.*/ #define AOM_SIGNED_SHL(x, shift) … // These can be used to give a hint about branch outcomes. // This can have an effect, even if your target processor has a // good branch predictor, as these hints can affect basic block // ordering by the compiler. #ifdef __GNUC__ #define LIKELY(v) … #define UNLIKELY(v) … #else #define LIKELY … #define UNLIKELY … #endif qm_val_t; #define AOM_QM_BITS … // Note: // tran_low_t is the datatype used for final transform coefficients. // tran_high_t is the datatype used for intermediate transform stages. tran_high_t; tran_low_t; static inline uint8_t clip_pixel(int val) { … } static inline int clamp(int value, int low, int high) { … } static inline int64_t clamp64(int64_t value, int64_t low, int64_t high) { … } static inline double fclamp(double value, double low, double high) { … } static inline uint16_t clip_pixel_highbd(int val, int bd) { … } // The result of this branchless code is equivalent to (value < 0 ? 0 : value) // or max(0, value) and might be faster in some cases. // Care should be taken since the behavior of right shifting signed type // negative value is undefined by C standards and implementation defined, static inline unsigned int negative_to_zero(int value) { … } // Returns the saturating cast of a double value to int. static inline int saturate_cast_double_to_int(double d) { … } #ifdef __cplusplus } // extern "C" #endif #endif // AOM_AOM_DSP_AOM_DSP_COMMON_H_