blob: fd87dc18109b81b27473fa4df0d1b52bb0b8245f [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
Yaowu Xuc27fc142016-08-22 16:08:15 -070011
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AOM_DSP_BLEND_H_
13#define AOM_AOM_DSP_BLEND_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include "aom_ports/mem.h"
16
17// Various blending functions and macros.
Yaowu Xuf883b422016-08-30 14:01:10 -070018// See also the aom_blend_* functions in aom_dsp_rtcd.h
Yaowu Xuc27fc142016-08-22 16:08:15 -070019
20// Alpha blending with alpha values from the range [0, 64], where 64
21// means use the first input and 0 means use the second input.
Yaowu Xu9c01aa12016-09-01 14:32:49 -070022
Yaowu Xuf883b422016-08-30 14:01:10 -070023#define AOM_BLEND_A64_ROUND_BITS 6
24#define AOM_BLEND_A64_MAX_ALPHA (1 << AOM_BLEND_A64_ROUND_BITS) // 64
Yaowu Xuc27fc142016-08-22 16:08:15 -070025
Yaowu Xuf883b422016-08-30 14:01:10 -070026#define AOM_BLEND_A64(a, v0, v1) \
27 ROUND_POWER_OF_TWO((a) * (v0) + (AOM_BLEND_A64_MAX_ALPHA - (a)) * (v1), \
28 AOM_BLEND_A64_ROUND_BITS)
Yaowu Xuc27fc142016-08-22 16:08:15 -070029
30// Alpha blending with alpha values from the range [0, 256], where 256
31// means use the first input and 0 means use the second input.
Yaowu Xuf883b422016-08-30 14:01:10 -070032#define AOM_BLEND_A256_ROUND_BITS 8
33#define AOM_BLEND_A256_MAX_ALPHA (1 << AOM_BLEND_A256_ROUND_BITS) // 256
Yaowu Xuc27fc142016-08-22 16:08:15 -070034
Yaowu Xuf883b422016-08-30 14:01:10 -070035#define AOM_BLEND_A256(a, v0, v1) \
36 ROUND_POWER_OF_TWO((a) * (v0) + (AOM_BLEND_A256_MAX_ALPHA - (a)) * (v1), \
37 AOM_BLEND_A256_ROUND_BITS)
Yaowu Xuc27fc142016-08-22 16:08:15 -070038
39// Blending by averaging.
Yaowu Xuf883b422016-08-30 14:01:10 -070040#define AOM_BLEND_AVG(v0, v1) ROUND_POWER_OF_TWO((v0) + (v1), 1)
Yaowu Xuc27fc142016-08-22 16:08:15 -070041
Ravi Chaudharyea665b02018-04-10 18:39:47 +053042#define DIFF_FACTOR_LOG2 4
43#define DIFF_FACTOR (1 << DIFF_FACTOR_LOG2)
44
James Zerne1cbb132018-08-22 14:10:36 -070045#endif // AOM_AOM_DSP_BLEND_H_