[xiph-cvs] cvs commit: speex/libspeex speex_stereo.h stereo.c Makefile.am

Jean-Marc Valin jm at xiph.org
Tue Nov 5 07:57:19 PST 2002



jm          02/11/05 10:57:19

  Modified:    libspeex Makefile.am
  Added:       libspeex speex_stereo.h stereo.c
  Log:
  before my laptop drops dead... :(

Revision  Changes    Path
1.45      +7 -4      speex/libspeex/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/Makefile.am,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- Makefile.am	30 Oct 2002 22:12:19 -0000	1.44
+++ Makefile.am	5 Nov 2002 15:57:19 -0000	1.45
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# $Id: Makefile.am,v 1.44 2002/10/30 22:12:19 jm Exp $
+# $Id: Makefile.am,v 1.45 2002/11/05 15:57:19 jm Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
@@ -34,13 +34,15 @@
         misc.c \
         speex_header.c \
         speex_callbacks.c \
-	math_approx.c
+	math_approx.c \
+	stereo.c
 
 
 include_HEADERS =  speex.h \
         speex_bits.h \
         speex_header.h \
-	speex_callbacks.h
+	speex_callbacks.h \
+	speex_stereo.h
 
 noinst_HEADERS = lsp.h \
         nb_celp.h \
@@ -57,7 +59,8 @@
         misc.h \
         ltp_sse.h \
         filters_sse.h \
-	math_approx.c
+	math_approx.h \
+	stereo.h
         
         
 libspeex_la_LDFLAGS = -release $(LT_RELEASE)

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

Index: speex_stereo.h
===================================================================
/* Copyright (C) 2002 Jean-Marc Valin 
   File: stereo.c

   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.
*/

#ifndef STEREO_H
#define STEREO_H

#include "speex_bits.h"

typedef struct SpeexStereoState {
   float balance;
   float e_ratio;
} SpeexStereoState;

#define SPEEX_DEFAULT_STEREO_STATE {1,2}

void encode_stereo(float *data, int frame_size, SpeexBits *bits);

void decode_stereo(float *data, int frame_size, SpeexStereoState *stereo);

#endif

<p><p>1.1                  speex/libspeex/stereo.c

Index: stereo.c
===================================================================
/* Copyright (C) 2002 Jean-Marc Valin 
   File: stereo.c

   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 "speex_stereo.h"

void encode_stereo(float *data, int frame_size, SpeexBits *bits)
{
   int i;
   float e_left=0, e_right=0, e_tot=0;
   float balance, e_ratio;
   for (i=0;i<frame_size;i++)
   {
      e_left  += data[2*i]*data[2*i];
      e_right += data[2*i+1]*data[2*i+1];
      data[i] =  data[2*i]+data[2*i+1];
      e_tot   += data[i]*data[i];
   }
   balance=(e_left+1)/(e_right+1);
   e_ratio = e_tot/(1+e_left+e_right);
   
}

void decode_stereo(float *data, int frame_size, SpeexStereoState *stereo)
{
   float balance, e_ratio;
   int i;
   float e_tot=0, e_left, e_right, e_sum;
   balance=stereo->balance;
   e_ratio=stereo->e_ratio;
   for (i=frame_size-1;i>=0;i++)
   {
      e_tot += data[i]*data[i];
   }
   e_sum=e_tot/e_ratio;
   e_left  = e_sum*balance / (1+balance);
   e_right = e_sum-e_left;

   e_left  = sqrt(e_left/e_tot);
   e_right = sqrt(e_right/e_tot);
   
   for (i=frame_size-1;i>=0;i++)
   {
      data[2*i] = e_left*data[i];
      data[2*i+1] = e_right*data[i];
   }
}

<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