[xiph-cvs] cvs commit: speex/libspeex cb_search_sse.h cb_search.c Makefile.am

Jean-Marc Valin jm at xiph.org
Sun Jan 18 00:13:34 PST 2004



jm          04/01/18 03:13:33

  Modified:    libspeex cb_search.c Makefile.am
  Added:       libspeex cb_search_sse.h
  Log:
  SSE speedup for the codebook response part of split_cb_search_shape_sign

Revision  Changes    Path
1.105     +40 -27    speex/libspeex/cb_search.c

Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- cb_search.c	4 Dec 2003 21:29:17 -0000	1.104
+++ cb_search.c	18 Jan 2004 08:13:31 -0000	1.105
@@ -37,6 +37,45 @@
 #include "misc.h"
 #include <stdio.h>
 
+#ifdef _USE_SSE
+#include "cb_search_sse.h"
+#else
+
+static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *r, spx_word16_t *resp, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
+{
+   int i, j, k;
+   for (i=0;i<shape_cb_size;i++)
+   {
+      spx_word16_t *res;
+      const signed char *shape;
+
+      res = resp+i*subvect_size;
+      shape = shape_cb+i*subvect_size;
+
+      /* Compute codeword response using convolution with impulse response */
+      for(j=0;j<subvect_size;j++)
+      {
+         spx_word32_t resj=0;
+         for (k=0;k<=j;k++)
+            resj = MAC16_16_Q11(resj,shape[k],r[j-k]);
+#ifndef FIXED_POINT
+         resj *= 0.03125;
+#endif
+         res[j] = resj;
+         /*printf ("%d\n", (int)res[j]);*/
+      }
+      
+      /* Compute codeword energy */
+      E[i]=0;
+      for(j=0;j<subvect_size;j++)
+         E[i]=ADD32(E[i],MULT16_16(res[j],res[j]));
+   }
+
+}
+
+#endif
+
+
 void split_cb_search_shape_sign(
 spx_sig_t target[],			/* target vector */
 spx_coef_t ak[],			/* LPCs for this subframe */
@@ -101,7 +140,6 @@
       nt[i]=tmp;
       tmp += nsf;
    }
-
    best_index = PUSH(stack, N, int);
    best_dist = PUSH(stack, N, spx_word32_t);
    ndist = PUSH(stack, N, spx_word32_t);
@@ -130,32 +168,7 @@
      printf ("%d\n", (int)t[i]);*/
 
    /* Pre-compute codewords response and energy */
-   for (i=0;i<shape_cb_size;i++)
-   {
-      spx_word16_t *res;
-      const signed char *shape;
-
-      res = resp+i*subvect_size;
-      shape = shape_cb+i*subvect_size;
-
-      /* Compute codeword response using convolution with impulse response */
-      for(j=0;j<subvect_size;j++)
-      {
-         spx_word32_t resj=0;
-         for (k=0;k<=j;k++)
-            resj = MAC16_16_Q11(resj,shape[k],r[j-k]);
-#ifndef FIXED_POINT
-         resj *= 0.03125;
-#endif
-         res[j] = resj;
-         /*printf ("%d\n", (int)res[j]);*/
-      }
-      
-      /* Compute codeword energy */
-      E[i]=0;
-      for(j=0;j<subvect_size;j++)
-         E[i]=ADD32(E[i],MULT16_16(res[j],res[j]));
-   }
+   compute_weighted_codebook(shape_cb, r, resp, E, shape_cb_size, subvect_size, stack);
 
    for (j=0;j<N;j++)
       odist[j]=0;

<p><p>1.57      +3 -2      speex/libspeex/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/Makefile.am,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- Makefile.am	29 Nov 2003 07:03:58 -0000	1.56
+++ Makefile.am	18 Jan 2004 08:13:31 -0000	1.57
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# $Id: Makefile.am,v 1.56 2003/11/29 07:03:58 jm Exp $
+# $Id: Makefile.am,v 1.57 2004/01/18 08:13:31 jm Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
@@ -73,7 +73,8 @@
         arch.h \
         fixed_arm.h \
         fixed_debug.h \
-	fixed_generic.h
+	fixed_generic.h \
+	cb_search_sse.h
         
         
 libspeex_la_LDFLAGS = -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@

<p><p>1.1                  speex/libspeex/cb_search_sse.h

Index: cb_search_sse.h
===================================================================
/* Copyright (C) 2004 Jean-Marc Valin 
   File: cb_search.c (SSE version)

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:
   
   - Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
   
   - Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
   
   - Neither the name of the Xiph.org Foundation nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.
   
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <xmmintrin.h>

tatic inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W)
{
  union {
    float __a[4];
    __m128 __v;
  } __u;
  
  __u.__v = U;

  *__Z = __u.__a[0];
  *__Y = __u.__a[1];
  *__X = __u.__a[2];
  *__W = __u.__a[3];

}

<p>static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, spx_word16_t *resp, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
{
   int i, j, k;
   __m128 resj, EE;
   __m128 *r, *shape;
   r = PUSH(stack, subvect_size, __m128);
   shape = PUSH(stack, subvect_size, __m128);
   for(j=0;j<subvect_size;j++)
      r[j] = _mm_load_ps1(_r+j);
   for (i=0;i<shape_cb_size;i+=4)
   {
      float *_res = resp+i*subvect_size;
      const signed char *_shape = shape_cb+i*subvect_size;
      EE = _mm_setzero_ps();
      for(j=0;j<subvect_size;j++)
      {
         shape[j] = _mm_setr_ps(0.03125*_shape[j], 0.03125*_shape[subvect_size+j], 0.03125*_shape[2*subvect_size+j], 0.03125*_shape[3*subvect_size+j]);
      }
      for(j=0;j<subvect_size;j++)
      {
         resj = _mm_setzero_ps();
         for (k=0;k<=j;k++)
            resj = _mm_add_ps(resj, _mm_mul_ps(shape[k],r[j-k]));
         _spx_mm_getr_ps(resj, _res+j, _res+subvect_size+j, _res+2*subvect_size+j, _res+3*subvect_size+j);
         EE = _mm_add_ps(EE, _mm_mul_ps(resj, resj));
         _mm_storeu_ps(E+i, EE);
      }
   }
}

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list