Merge "VP9: refactor read_switchable_interp_filter()"
[aom.git] / vpx_dsp / vpx_dsp_common.h
bloba9e180e7934038c20b576feb541e9b9f16d2a9b9
1 /*
2 * Copyright (c) 2015 The WebM project authors. All Rights Reserved.
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 */
11 #ifndef VPX_DSP_COMMON_H_
12 #define VPX_DSP_COMMON_H_
14 #include "./vpx_config.h"
15 #include "vpx/vpx_integer.h"
16 #include "vpx_dsp/vpx_dsp_common.h"
17 #include "vpx_ports/mem.h"
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
23 #define VPXMIN(x, y) (((x) < (y)) ? (x) : (y))
24 #define VPXMAX(x, y) (((x) > (y)) ? (x) : (y))
26 #if CONFIG_VP9_HIGHBITDEPTH
27 // Note:
28 // tran_low_t is the datatype used for final transform coefficients.
29 // tran_high_t is the datatype used for intermediate transform stages.
30 typedef int64_t tran_high_t;
31 typedef int32_t tran_low_t;
32 #else
33 // Note:
34 // tran_low_t is the datatype used for final transform coefficients.
35 // tran_high_t is the datatype used for intermediate transform stages.
36 typedef int32_t tran_high_t;
37 typedef int16_t tran_low_t;
38 #endif // CONFIG_VP9_HIGHBITDEPTH
40 static INLINE uint8_t clip_pixel(int val) {
41 return (val > 255) ? 255 : (val < 0) ? 0 : val;
44 static INLINE int clamp(int value, int low, int high) {
45 return value < low ? low : (value > high ? high : value);
48 static INLINE double fclamp(double value, double low, double high) {
49 return value < low ? low : (value > high ? high : value);
52 #if CONFIG_VP9_HIGHBITDEPTH
53 static INLINE uint16_t clip_pixel_highbd(int val, int bd) {
54 switch (bd) {
55 case 8:
56 default:
57 return (uint16_t)clamp(val, 0, 255);
58 case 10:
59 return (uint16_t)clamp(val, 0, 1023);
60 case 12:
61 return (uint16_t)clamp(val, 0, 4095);
64 #endif // CONFIG_VP9_HIGHBITDEPTH
66 #ifdef __cplusplus
67 } // extern "C"
68 #endif
70 #endif // VPX_DSP_COMMON_H_