// Copyright 2016 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // SSE2 code common to several files. // // Author: Vincent Rabaud ([email protected]) #ifndef WEBP_DSP_COMMON_SSE2_H_ #define WEBP_DSP_COMMON_SSE2_H_ #ifdef __cplusplus extern "C" { #endif #if defined(WEBP_USE_SSE2) #include <emmintrin.h> //------------------------------------------------------------------------------ // Quite useful macro for debugging. Left here for convenience. #if 0 #include <stdio.h> static WEBP_INLINE void PrintReg(const __m128i r, const char* const name, int size) { int n; union { __m128i r; uint8_t i8[16]; uint16_t i16[8]; uint32_t i32[4]; uint64_t i64[2]; } tmp; tmp.r = r; fprintf(stderr, "%s\t: ", name); if (size == 8) { for (n = 0; n < 16; ++n) fprintf(stderr, "%.2x ", tmp.i8[n]); } else if (size == 16) { for (n = 0; n < 8; ++n) fprintf(stderr, "%.4x ", tmp.i16[n]); } else if (size == 32) { for (n = 0; n < 4; ++n) fprintf(stderr, "%.8x ", tmp.i32[n]); } else { for (n = 0; n < 2; ++n) fprintf(stderr, "%.16lx ", tmp.i64[n]); } fprintf(stderr, "\n"); } #endif //------------------------------------------------------------------------------ // Math functions. // Return the sum of all the 8b in the register. static WEBP_INLINE int VP8HorizontalAdd8b(const __m128i* const a) { … } // Transpose two 4x4 16b matrices horizontally stored in registers. static WEBP_INLINE void VP8Transpose_2_4x4_16b( const __m128i* const in0, const __m128i* const in1, const __m128i* const in2, const __m128i* const in3, __m128i* const out0, __m128i* const out1, __m128i* const out2, __m128i* const out3) { … } //------------------------------------------------------------------------------ // Channel mixing. // Function used several times in VP8PlanarTo24b. // It samples the in buffer as follows: one every two unsigned char is stored // at the beginning of the buffer, while the other half is stored at the end. #define VP8PlanarTo24bHelper … // Pack the planar buffers // rrrr... rrrr... gggg... gggg... bbbb... bbbb.... // triplet by triplet in the output buffer rgb as rgbrgbrgbrgb ... static WEBP_INLINE void VP8PlanarTo24b_SSE2( __m128i* const in0, __m128i* const in1, __m128i* const in2, __m128i* const in3, __m128i* const in4, __m128i* const in5) { … } #undef VP8PlanarTo24bHelper // Convert four packed four-channel buffers like argbargbargbargb... into the // split channels aaaaa ... rrrr ... gggg .... bbbbb ...... static WEBP_INLINE void VP8L32bToPlanar_SSE2(__m128i* const in0, __m128i* const in1, __m128i* const in2, __m128i* const in3) { … } #endif // WEBP_USE_SSE2 #ifdef __cplusplus } // extern "C" #endif #endif // WEBP_DSP_COMMON_SSE2_H_