bitdepth_conversion_avx2.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2017 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. #ifndef VPX_VPX_DSP_X86_BITDEPTH_CONVERSION_AVX2_H_
  11. #define VPX_VPX_DSP_X86_BITDEPTH_CONVERSION_AVX2_H_
  12. #include <immintrin.h>
  13. #include "./vpx_config.h"
  14. #include "vpx/vpx_integer.h"
  15. #include "vpx_dsp/vpx_dsp_common.h"
  16. // Load 16 16 bit values. If the source is 32 bits then pack down with
  17. // saturation.
  18. static INLINE __m256i load_tran_low(const tran_low_t *a) {
  19. #if CONFIG_VP9_HIGHBITDEPTH
  20. const __m256i a_low = _mm256_loadu_si256((const __m256i *)a);
  21. const __m256i a_high = _mm256_loadu_si256((const __m256i *)(a + 8));
  22. return _mm256_packs_epi32(a_low, a_high);
  23. #else
  24. return _mm256_loadu_si256((const __m256i *)a);
  25. #endif
  26. }
  27. static INLINE void store_tran_low(__m256i a, tran_low_t *b) {
  28. #if CONFIG_VP9_HIGHBITDEPTH
  29. const __m256i one = _mm256_set1_epi16(1);
  30. const __m256i a_hi = _mm256_mulhi_epi16(a, one);
  31. const __m256i a_lo = _mm256_mullo_epi16(a, one);
  32. const __m256i a_1 = _mm256_unpacklo_epi16(a_lo, a_hi);
  33. const __m256i a_2 = _mm256_unpackhi_epi16(a_lo, a_hi);
  34. _mm256_storeu_si256((__m256i *)b, a_1);
  35. _mm256_storeu_si256((__m256i *)(b + 8), a_2);
  36. #else
  37. _mm256_storeu_si256((__m256i *)b, a);
  38. #endif
  39. }
  40. #endif // VPX_VPX_DSP_X86_BITDEPTH_CONVERSION_AVX2_H_