Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 1 | /* |
| 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-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 21 | #define VPX_BLEND_A64_ROUND_BITS 6 |
| 22 | #define VPX_BLEND_A64_MAX_ALPHA (1 << VPX_BLEND_A64_ROUND_BITS) // 64 |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 23 | |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 24 | #define VPX_BLEND_A64(a, v0, v1) \ |
| 25 | ROUND_POWER_OF_TWO((a) * (v0) + (VPX_BLEND_A64_MAX_ALPHA - (a)) * (v1), \ |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 26 | 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-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 31 | #define VPX_BLEND_A256_MAX_ALPHA (1 << VPX_BLEND_A256_ROUND_BITS) // 256 |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 32 | |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 33 | #define VPX_BLEND_A256(a, v0, v1) \ |
| 34 | ROUND_POWER_OF_TWO((a) * (v0) + (VPX_BLEND_A256_MAX_ALPHA - (a)) * (v1), \ |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 35 | VPX_BLEND_A256_ROUND_BITS) |
| 36 | |
| 37 | // Blending by averaging. |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 38 | #define VPX_BLEND_AVG(v0, v1) ROUND_POWER_OF_TWO((v0) + (v1), 1) |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 39 | |
| 40 | #endif // VPX_DSP_BLEND_H_ |