blob: 2ceb4c78f854eb47a4a20c68dbcbc122ffb93c5a [file] [log] [blame]
Geza Lorebfa59b42016-07-11 12:43:47 +01001/*
2* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
3*
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*/
10
11#ifndef VPX_DSP_BLEND_H_
12#define VPX_DSP_BLEND_H_
13
14#include "vpx_ports/mem.h"
15
16// Various blending functions and macros.
17// See also the vpx_blend_* functions in vpx_dsp_rtcd.h
18
19// Alpha blending with alpha values from the range [0, 64], where 64
20// means use the first input and 0 means use the second input.
clang-format1214cee2016-08-08 22:59:08 -070021#define VPX_BLEND_A64_ROUND_BITS 6
22#define VPX_BLEND_A64_MAX_ALPHA (1 << VPX_BLEND_A64_ROUND_BITS) // 64
Geza Lorebfa59b42016-07-11 12:43:47 +010023
clang-format1214cee2016-08-08 22:59:08 -070024#define VPX_BLEND_A64(a, v0, v1) \
25 ROUND_POWER_OF_TWO((a) * (v0) + (VPX_BLEND_A64_MAX_ALPHA - (a)) * (v1), \
Geza Lorebfa59b42016-07-11 12:43:47 +010026 VPX_BLEND_A64_ROUND_BITS)
27
28// Alpha blending with alpha values from the range [0, 256], where 256
29// means use the first input and 0 means use the second input.
30#define VPX_BLEND_A256_ROUND_BITS 8
clang-format1214cee2016-08-08 22:59:08 -070031#define VPX_BLEND_A256_MAX_ALPHA (1 << VPX_BLEND_A256_ROUND_BITS) // 256
Geza Lorebfa59b42016-07-11 12:43:47 +010032
clang-format1214cee2016-08-08 22:59:08 -070033#define VPX_BLEND_A256(a, v0, v1) \
34 ROUND_POWER_OF_TWO((a) * (v0) + (VPX_BLEND_A256_MAX_ALPHA - (a)) * (v1), \
Geza Lorebfa59b42016-07-11 12:43:47 +010035 VPX_BLEND_A256_ROUND_BITS)
36
37// Blending by averaging.
clang-format1214cee2016-08-08 22:59:08 -070038#define VPX_BLEND_AVG(v0, v1) ROUND_POWER_OF_TWO((v0) + (v1), 1)
Geza Lorebfa59b42016-07-11 12:43:47 +010039
40#endif // VPX_DSP_BLEND_H_