]> granicus.if.org Git - libvpx/commitdiff
Add an MMX fwht4x4
authorAlex Converse <aconverse@google.com>
Mon, 5 May 2014 21:10:41 +0000 (14:10 -0700)
committerAlex Converse <aconverse@google.com>
Mon, 5 May 2014 22:10:48 +0000 (15:10 -0700)
7% faster encoding a desktop lossless at RT speed 4.

Change-Id: I41627f5b737752616b6512bb91a36ec45995bf64

test/fdct4x4_test.cc
vp9/common/vp9_rtcd_defs.pl
vp9/encoder/x86/vp9_dct_mmx.c [new file with mode: 0644]
vp9/vp9cx.mk

index 02458db22fafde3b78ebf1b57c8b4a0afc28a469..e2ba8a8655ab438150d92fe031eb29019314155b 100644 (file)
@@ -353,6 +353,13 @@ INSTANTIATE_TEST_CASE_P(
         make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 3)));
 #endif
 
+#if HAVE_MMX
+INSTANTIATE_TEST_CASE_P(
+    MMX, Trans4x4WHT,
+    ::testing::Values(
+        make_tuple(&vp9_fwht4x4_mmx, &vp9_iwht4x4_16_add_c, 0)));
+#endif
+
 #if HAVE_SSE2
 INSTANTIATE_TEST_CASE_P(
     SSE2, Trans4x4DCT,
index d4c30650709ef922569762815579203cc4592c19..68cb5bcb4251362c169c00c6bfad4cde6f569714 100644 (file)
@@ -701,7 +701,7 @@ add_proto qw/void vp9_fht16x16/, "const int16_t *input, int16_t *output, int str
 specialize qw/vp9_fht16x16 sse2 avx2/;
 
 add_proto qw/void vp9_fwht4x4/, "const int16_t *input, int16_t *output, int stride";
-specialize qw/vp9_fwht4x4/;
+specialize qw/vp9_fwht4x4 mmx/;
 
 add_proto qw/void vp9_fdct4x4/, "const int16_t *input, int16_t *output, int stride";
 specialize qw/vp9_fdct4x4 sse2 avx2/;
diff --git a/vp9/encoder/x86/vp9_dct_mmx.c b/vp9/encoder/x86/vp9_dct_mmx.c
new file mode 100644 (file)
index 0000000..4524ba4
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE 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.
+ */
+
+#include <mmintrin.h>
+#include <stdint.h>
+
+#include "./vpx_config.h"
+
+static void INLINE transpose_4x4_mmx(__m64* a, __m64* b, __m64* c, __m64* d) {
+  __m64 w, x, y, z;
+  w = _mm_unpacklo_pi16(*a, *b);
+  x = _mm_unpackhi_pi16(*a, *b);
+  y = _mm_unpacklo_pi16(*c, *d);
+  z = _mm_unpackhi_pi16(*c, *d);
+  *a = _mm_unpacklo_pi32(w, y);
+  *b = _mm_unpackhi_pi32(w, y);
+  *c = _mm_unpacklo_pi32(x, z);
+  *d = _mm_unpackhi_pi32(x, z);
+}
+
+static void INLINE fwht_4x4_cols(__m64* out0,
+                                 __m64* out1,
+                                 __m64* out2,
+                                 __m64* out3,
+                                 __m64 a1,
+                                 __m64 b1,
+                                 __m64 c1,
+                                 __m64 d1) {
+  __m64 e1;
+
+  a1 = _mm_add_pi16(a1, b1);
+  d1 = _mm_sub_pi16(d1, c1);
+  e1 = _mm_sub_pi16(a1, d1);
+  e1 = _mm_srai_pi16(e1, 1);
+  b1 = _mm_sub_pi16(e1, b1);
+  c1 = _mm_sub_pi16(e1, c1);
+  a1 = _mm_sub_pi16(a1, c1);
+  d1 = _mm_add_pi16(d1, b1);
+  *out0 = a1;
+  *out1 = c1;
+  *out2 = d1;
+  *out3 = b1;
+}
+
+void vp9_fwht4x4_mmx(const int16_t* input, int16_t* output, int stride) {
+  __m64 a1 = *(const __m64*)input;
+  __m64 b1 = *(const __m64*)(input + stride);
+  __m64 c1 = *(const __m64*)(input + 2 * stride);
+  __m64 d1 = *(const __m64*)(input + 3 * stride);
+
+  fwht_4x4_cols(&a1, &b1, &c1, &d1, a1, b1, c1, d1);
+  transpose_4x4_mmx(&a1, &b1, &c1, &d1);
+  fwht_4x4_cols(&a1, &b1, &c1, &d1, a1, b1, c1, d1);
+  transpose_4x4_mmx(&a1, &b1, &c1, &d1);
+
+  *(__m64*)output = _mm_slli_pi16(a1, 2);
+  *(__m64*)(output + 4) = _mm_slli_pi16(b1, 2);
+  *(__m64*)(output + 8) = _mm_slli_pi16(c1, 2);
+  *(__m64*)(output + 12) = _mm_slli_pi16(d1, 2);
+}
index 5e88793c86fe5cb44cdfb629d6e2e4ca20212206..154fdae621cdca292a68574a6a52cd3081c24726 100644 (file)
@@ -92,6 +92,7 @@ VP9_CX_SRCS-yes += encoder/vp9_mbgraph.h
 VP9_CX_SRCS-$(HAVE_MMX) += encoder/x86/vp9_variance_mmx.c
 VP9_CX_SRCS-$(HAVE_MMX) += encoder/x86/vp9_variance_impl_mmx.asm
 VP9_CX_SRCS-$(HAVE_MMX) += encoder/x86/vp9_sad_mmx.asm
+VP9_CX_SRCS-$(HAVE_MMX) += encoder/x86/vp9_dct_mmx.c
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_variance_impl_sse2.asm
 VP9_CX_SRCS-$(HAVE_AVX2) += encoder/x86/vp9_variance_impl_intrin_avx2.c
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_sad4d_sse2.asm