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.
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"
23 #define VPXMIN(x, y) (((x) < (y)) ? (x) : (y))
24 #define VPXMAX(x, y) (((x) > (y)) ? (x) : (y))
26 #if CONFIG_VP9_HIGHBITDEPTH
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
;
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
) {
57 return (uint16_t)clamp(val
, 0, 255);
59 return (uint16_t)clamp(val
, 0, 1023);
61 return (uint16_t)clamp(val
, 0, 4095);
64 #endif // CONFIG_VP9_HIGHBITDEPTH
70 #endif // VPX_DSP_COMMON_H_