blend.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef AOM_AOM_DSP_BLEND_H_
  12. #define AOM_AOM_DSP_BLEND_H_
  13. #include "aom_ports/mem.h"
  14. // Various blending functions and macros.
  15. // See also the aom_blend_* functions in aom_dsp_rtcd.h
  16. // Alpha blending with alpha values from the range [0, 64], where 64
  17. // means use the first input and 0 means use the second input.
  18. #define AOM_BLEND_A64_ROUND_BITS 6
  19. #define AOM_BLEND_A64_MAX_ALPHA (1 << AOM_BLEND_A64_ROUND_BITS) // 64
  20. #define AOM_BLEND_A64(a, v0, v1) \
  21. ROUND_POWER_OF_TWO((a) * (v0) + (AOM_BLEND_A64_MAX_ALPHA - (a)) * (v1), \
  22. AOM_BLEND_A64_ROUND_BITS)
  23. // Alpha blending with alpha values from the range [0, 256], where 256
  24. // means use the first input and 0 means use the second input.
  25. #define AOM_BLEND_A256_ROUND_BITS 8
  26. #define AOM_BLEND_A256_MAX_ALPHA (1 << AOM_BLEND_A256_ROUND_BITS) // 256
  27. #define AOM_BLEND_A256(a, v0, v1) \
  28. ROUND_POWER_OF_TWO((a) * (v0) + (AOM_BLEND_A256_MAX_ALPHA - (a)) * (v1), \
  29. AOM_BLEND_A256_ROUND_BITS)
  30. // Blending by averaging.
  31. #define AOM_BLEND_AVG(v0, v1) ROUND_POWER_OF_TWO((v0) + (v1), 1)
  32. #define DIFF_FACTOR_LOG2 4
  33. #define DIFF_FACTOR (1 << DIFF_FACTOR_LOG2)
  34. #endif // AOM_AOM_DSP_BLEND_H_