• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * 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  */
11 
12 #ifndef AOM_AOM_DSP_BLEND_H_
13 #define AOM_AOM_DSP_BLEND_H_
14 
15 #include "aom_ports/mem.h"
16 
17 // Various blending functions and macros.
18 // See also the aom_blend_* functions in aom_dsp_rtcd.h
19 
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.
22 
23 #define AOM_BLEND_A64_ROUND_BITS 6
24 #define AOM_BLEND_A64_MAX_ALPHA (1 << AOM_BLEND_A64_ROUND_BITS)  // 64
25 
26 #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)
29 
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.
32 #define AOM_BLEND_A256_ROUND_BITS 8
33 #define AOM_BLEND_A256_MAX_ALPHA (1 << AOM_BLEND_A256_ROUND_BITS)  // 256
34 
35 #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)
38 
39 // Blending by averaging.
40 #define AOM_BLEND_AVG(v0, v1) ROUND_POWER_OF_TWO((v0) + (v1), 1)
41 
42 #define DIFF_FACTOR_LOG2 4
43 #define DIFF_FACTOR (1 << DIFF_FACTOR_LOG2)
44 
45 #endif  // AOM_AOM_DSP_BLEND_H_
46