ref: 3ccbd4803bcc75be860dd67bb3a56b114251433b
dir: /vpx_dsp/vpx_dsp_common.h/
/* * Copyright (c) 2015 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef VPX_VPX_DSP_VPX_DSP_COMMON_H_ #define VPX_VPX_DSP_VPX_DSP_COMMON_H_ #include "./vpx_config.h" #include "vpx/vpx_integer.h" #include "vpx_ports/mem.h" #ifdef __cplusplus extern "C" { #endif #define VPXMIN(x, y) (((x) < (y)) ? (x) : (y)) #define VPXMAX(x, y) (((x) > (y)) ? (x) : (y)) #define VPX_SWAP(type, a, b) \ do { \ type c = (b); \ (b) = a; \ (a) = c; \ } while (0) #if CONFIG_VP9_HIGHBITDEPTH // Note: // tran_low_t is the datatype used for final transform coefficients. // tran_high_t is the datatype used for intermediate transform stages. typedef int64_t tran_high_t; typedef int32_t tran_low_t; #else // Note: // tran_low_t is the datatype used for final transform coefficients. // tran_high_t is the datatype used for intermediate transform stages. typedef int32_t tran_high_t; typedef int16_t tran_low_t; #endif // CONFIG_VP9_HIGHBITDEPTH typedef int16_t tran_coef_t; #define clip_pixel(val) (uint8_t)(((int)(val) > 255) ? 255 : (((int)(val) < 0) ? 0 : (val))) #define clamp(value, low, high) (int)((int)(value) < (int)(low) ? (low) : ((int)(value) > (int)(high) ? (high) : (value))) #define fcclamp(value, low, high) (double)((double)(value) < (double)(low) ? (low) : ((double)(value) > (double)(high) ? (high) : (value))) #define lclamp(value, low, high) (int64_t)((int64_t)(value) < (int64_t)(low) ? (low) : ((int64_t)(value) > (int64_t)(high) ? (high) : (value))) #define clip_pixel_highbd(val, bd) (uint16_t)((bd) == 12 ? clamp((val), 0, 4095) : ((bd) == 10 ? clamp((val), 0, 1023) : clamp((val), 0, 255))) #ifdef __cplusplus } // extern "C" #endif #endif // VPX_VPX_DSP_VPX_DSP_COMMON_H_