shithub: libvpx

Download patch

ref: 22ca468c7c55f76e71c29d0ebe8d9e01ba210fc0
parent: ad9dea1f6d1cea9c704c4f936742288ac5c0c2c6
author: Luca Barbato <[email protected]>
date: Fri Apr 7 22:55:33 EDT 2017

ppc: dc top and left predictor 32x32

6x faster.

Change-Id: I717995b4056e5579c68191d11b495372971fe1ae

--- a/test/test_intra_pred_speed.cc
+++ b/test/test_intra_pred_speed.cc
@@ -321,10 +321,10 @@
                 vpx_v_predictor_16x16_vsx, vpx_h_predictor_16x16_vsx, NULL,
                 NULL, NULL, NULL, NULL, NULL, vpx_tm_predictor_16x16_vsx)
 
-INTRA_PRED_TEST(VSX, TestIntraPred32, NULL, NULL, NULL,
-                vpx_dc_128_predictor_32x32_vsx, vpx_v_predictor_32x32_vsx,
-                vpx_h_predictor_32x32_vsx, NULL, NULL, NULL, NULL, NULL, NULL,
-                vpx_tm_predictor_32x32_vsx)
+INTRA_PRED_TEST(VSX, TestIntraPred32, NULL, vpx_dc_left_predictor_32x32_vsx,
+                vpx_dc_top_predictor_32x32_vsx, vpx_dc_128_predictor_32x32_vsx,
+                vpx_v_predictor_32x32_vsx, vpx_h_predictor_32x32_vsx, NULL,
+                NULL, NULL, NULL, NULL, NULL, vpx_tm_predictor_32x32_vsx)
 #endif  // HAVE_VSX
 
 // -----------------------------------------------------------------------------
--- a/vpx_dsp/ppc/intrapred_vsx.c
+++ b/vpx_dsp/ppc/intrapred_vsx.c
@@ -423,3 +423,31 @@
 
   dc_fill_predictor_16x16(dst, stride, avg16(above));
 }
+
+static uint8x16_t avg32(const uint8_t *values) {
+  const uint8x16_t v0 = vec_vsx_ld(0, values);
+  const uint8x16_t v1 = vec_vsx_ld(16, values);
+  const int32x4_t v16 = vec_sl(vec_splat_s32(1), vec_splat_u32(4));
+  const int32x4_t sum4s =
+      (int32x4_t)vec_sum4s(v0, vec_sum4s(v1, vec_splat_u32(0)));
+  const uint32x4_t sum = (uint32x4_t)vec_sums(sum4s, v16);
+  const uint32x4_t avg = (uint32x4_t)vec_sr(sum, vec_splat_u32(5));
+
+  return vec_splat(vec_pack(vec_pack(avg, vec_splat_u32(0)), vec_splat_u16(0)),
+                   3);
+}
+
+void vpx_dc_left_predictor_32x32_vsx(uint8_t *dst, ptrdiff_t stride,
+                                     const uint8_t *above,
+                                     const uint8_t *left) {
+  (void)above;
+
+  dc_fill_predictor_32x32(dst, stride, avg32(left));
+}
+
+void vpx_dc_top_predictor_32x32_vsx(uint8_t *dst, ptrdiff_t stride,
+                                    const uint8_t *above, const uint8_t *left) {
+  (void)left;
+
+  dc_fill_predictor_32x32(dst, stride, avg32(above));
+}
--- a/vpx_dsp/vpx_dsp_rtcd_defs.pl
+++ b/vpx_dsp/vpx_dsp_rtcd_defs.pl
@@ -177,10 +177,10 @@
 specialize qw/vpx_dc_predictor_32x32 msa neon sse2/;
 
 add_proto qw/void vpx_dc_top_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_dc_top_predictor_32x32 msa neon sse2/;
+specialize qw/vpx_dc_top_predictor_32x32 msa neon sse2 vsx/;
 
 add_proto qw/void vpx_dc_left_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
-specialize qw/vpx_dc_left_predictor_32x32 msa neon sse2/;
+specialize qw/vpx_dc_left_predictor_32x32 msa neon sse2 vsx/;
 
 add_proto qw/void vpx_dc_128_predictor_32x32/, "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
 specialize qw/vpx_dc_128_predictor_32x32 msa neon sse2 vsx/;