[xiph-cvs] cvs commit: speex/libspeex fixed_arm.h fixed_debug.h fixed_generic.h Makefile.am arch.h misc.c nb_celp.h testenc.c testenc_uwb.c testenc_wb.c

Jean-Marc Valin jm at xiph.org
Fri Nov 28 23:03:59 PST 2003



jm          03/11/29 02:03:59

  Modified:    libspeex Makefile.am arch.h misc.c nb_celp.h testenc.c
                        testenc_uwb.c testenc_wb.c
  Added:       libspeex fixed_arm.h fixed_debug.h fixed_generic.h
  Log:
  separated fixed-point operators in: generic, ARM, debug

Revision  Changes    Path
1.56      +5 -2      speex/libspeex/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/Makefile.am,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- Makefile.am	12 Nov 2003 17:16:38 -0000	1.55
+++ Makefile.am	29 Nov 2003 07:03:58 -0000	1.56
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# $Id: Makefile.am,v 1.55 2003/11/12 17:16:38 jm Exp $
+# $Id: Makefile.am,v 1.56 2003/11/29 07:03:58 jm Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
@@ -70,7 +70,10 @@
         filters_sse.h \
         math_approx.h \
         smallft.h \
-	arch.h
+	arch.h \
+	fixed_arm.h \
+	fixed_debug.h \
+	fixed_generic.h
         
         
 libspeex_la_LDFLAGS = -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@

<p><p>1.6       +4 -103    speex/libspeex/arch.h

Index: arch.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/arch.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- arch.h	28 Nov 2003 05:39:56 -0000	1.5
+++ arch.h	29 Nov 2003 07:03:58 -0000	1.6
@@ -59,115 +59,16 @@
 
 #define VERY_SMALL 0
 
-#ifdef COUNT_MIPS
-extern long long spx_mips;
-#define MIPS_INC spx_mips++,
-#else
-#define MIPS_INC
-#endif
-
-#define SHR(a,shift) ((a) >> (shift))
-#define SHL(a,shift) ((a) << (shift))
-
-
-#define ADD16(a,b) (MIPS_INC(short)((short)(a)+(short)(b)))
-#define SUB16(a,b) (MIPS_INC(a)-(b))
-#define ADD32(a,b) (MIPS_INC(a)+(b))
-#define SUB32(a,b) (MIPS_INC(a)-(b))
-#define ADD64(a,b) (MIPS_INC(a)+(b))
-
-#define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))
-
-/* result fits in 16 bits */
-#define MULT16_16_16(a,b)     (MIPS_INC(short)(((short)(a))*((short)(b))))
-/* Kludge: just making sure results are on 32 bits */
-#ifdef ARM_ASM
-static inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) {
-  int res;
-  asm volatile("smulbb  %0,%1,%2;\n"
-              : "=&r"(res)
-              : "%r"(x),"r"(y));
-  return(MIPS_INC res);
-}
-#else
-#define MULT16_16(a,b)     (MIPS_INC((short)(a))*((short)(b)))
-#endif
-
-
-
-#ifdef ARM_ASM
-
-static inline spx_word32_t MAC16_16(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
-  int res;
-  asm volatile("smlabb  %0,%1,%2,%3;\n"
-              : "=&r"(res)
-               : "%r"(x),"r"(y),"r"(a));
-  return(MIPS_INC res);
-}
-
-#else
-
-#define MAC16_16(c,a,b)     (ADD32((c),MULT16_16((a),(b))))
-
-#endif
-
-#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
-#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
-#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
 
 #ifdef ARM_ASM
-static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
-  int res;
-  asm volatile("smulwb  %0,%1,%2;\n"
-              : "=&r"(res)
-               : "%r"(y<<1),"r"(x));
-  return(MIPS_INC res);
-}
-static inline spx_word32_t MAC16_32_Q15(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
-  int res;
-  asm volatile("smlawb  %0,%1,%2,%3;\n"
-              : "=&r"(res)
-               : "%r"(y<<1),"r"(x),"r"(a));
-  return(MIPS_INC res);
-}
-static inline spx_word32_t MULT16_32_Q11(spx_word16_t x, spx_word32_t y) {
-  int res;
-  asm volatile("smulwb  %0,%1,%2;\n"
-              : "=&r"(res)
-               : "%r"(y<<5),"r"(x));
-  return(MIPS_INC res);
-}
-static inline spx_word32_t MAC16_32_Q11(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
-  int res;
-  asm volatile("smlawb  %0,%1,%2,%3;\n"
-              : "=&r"(res)
-               : "%r"(y<<5),"r"(x),"r"(a));
-  return(MIPS_INC res);
-}
-
+#include "fixed_arm.h"
+#elif defined (FIXED_DEBUG)
+#include "fixed_debug.h"
 #else
-#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
-#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))
-
-#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
-#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
+#include "fixed_generic.h"
 #endif
 
 
-#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
-#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
-#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
-
-#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
-#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
-#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
-
-#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
-
-
-
-#define DIV32_16(a,b) ((short)(((signed int)(a))/((short)(b))))
-#define DIV32(a,b) (((signed int)(a))/((signed int)(b)))
 
 #else
 

<p><p>1.12      +1 -1      speex/libspeex/misc.c

Index: misc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- misc.c	2 Nov 2003 07:44:35 -0000	1.11
+++ misc.c	29 Nov 2003 07:03:58 -0000	1.12
@@ -46,7 +46,7 @@
 }
 #endif
 
-#ifdef COUNT_MIPS
+#ifdef FIXED_DEBUG
 long long spx_mips=0;
 #endif
 

<p><p>1.63      +1 -1      speex/libspeex/nb_celp.h

Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- nb_celp.h	29 Nov 2003 05:17:31 -0000	1.62
+++ nb_celp.h	29 Nov 2003 07:03:58 -0000	1.63
@@ -139,7 +139,7 @@
    int    lbr_48k;
 #endif
 
-   float  last_ol_gain;   /**< Open-loop gain for previous frame */
+   spx_word16_t  last_ol_gain;   /**< Open-loop gain for previous frame */
 
    float  gamma1;         /**< Perceptual filter: A(z/gamma1) */
    float  gamma2;         /**< Perceptual filter: A(z/gamma2) */

<p><p>1.55      +1 -1      speex/libspeex/testenc.c

Index: testenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- testenc.c	25 Nov 2003 16:40:25 -0000	1.54
+++ testenc.c	29 Nov 2003 07:03:58 -0000	1.55
@@ -124,7 +124,7 @@
    seg_snr /= snr_frames;
    fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
 
-#ifdef COUNT_MIPS
+#ifdef FIXED_DEBUG
    printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
 #endif
    

<p><p>1.6       +1 -1      speex/libspeex/testenc_uwb.c

Index: testenc_uwb.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc_uwb.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- testenc_uwb.c	12 Nov 2003 05:09:27 -0000	1.5
+++ testenc_uwb.c	29 Nov 2003 07:03:58 -0000	1.6
@@ -124,7 +124,7 @@
    seg_snr /= snr_frames;
    fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
 
-#ifdef COUNT_MIPS
+#ifdef FIXED_DEBUG
    printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
 #endif
    

<p><p>1.36      +1 -1      speex/libspeex/testenc_wb.c

Index: testenc_wb.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc_wb.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- testenc_wb.c	14 Nov 2003 18:28:45 -0000	1.35
+++ testenc_wb.c	29 Nov 2003 07:03:58 -0000	1.36
@@ -129,7 +129,7 @@
    seg_snr /= snr_frames;
    fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
 
-#ifdef COUNT_MIPS
+#ifdef FIXED_DEBUG
    printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
 #endif
    

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

Index: fixed_arm.h
===================================================================
/* Copyright (C) 2003 Jean-Marc Valin */
/**
   @file fixed_generic.h
   @brief ARM-tuned fixed-point operations
*/
/*
   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 FIXED_ARM_H
#define FIXED_ARM_H

#define SHR(a,shift) ((a) >> (shift))
#define SHL(a,shift) ((a) << (shift))

<p>#define ADD16(a,b) ((short)((short)(a)+(short)(b)))
#define SUB16(a,b) ((a)-(b))
#define ADD32(a,b) ((a)+(b))
#define SUB32(a,b) ((a)-(b))
#define ADD64(a,b) ((a)+(b))

#define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))

/* result fits in 16 bits */
#define MULT16_16_16(a,b)     (((short)(a))*((short)(b)))

tatic inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) {
  int res;
  asm volatile("smulbb  %0,%1,%2;\n"
              : "=&r"(res)
              : "%r"(x),"r"(y));
  return(res);
}

tatic inline spx_word32_t MAC16_16(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
  int res;
  asm volatile("smlabb  %0,%1,%2,%3;\n"
              : "=&r"(res)
               : "%r"(x),"r"(y),"r"(a));
  return(res);
}

#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))

tatic inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
  int res;
  asm volatile("smulwb  %0,%1,%2;\n"
              : "=&r"(res)
               : "%r"(y<<1),"r"(x));
  return(res);
}
static inline spx_word32_t MAC16_32_Q15(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
  int res;
  asm volatile("smlawb  %0,%1,%2,%3;\n"
              : "=&r"(res)
               : "%r"(y<<1),"r"(x),"r"(a));
  return(res);
}
static inline spx_word32_t MULT16_32_Q11(spx_word16_t x, spx_word32_t y) {
  int res;
  asm volatile("smulwb  %0,%1,%2;\n"
              : "=&r"(res)
               : "%r"(y<<5),"r"(x));
  return(res);
}
static inline spx_word32_t MAC16_32_Q11(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
  int res;
  asm volatile("smlawb  %0,%1,%2,%3;\n"
              : "=&r"(res)
               : "%r"(y<<5),"r"(x),"r"(a));
  return(res);
}

#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))

#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))

#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))

<p><p>#define DIV32_16(a,b) ((short)(((signed int)(a))/((short)(b))))
#define DIV32(a,b) (((signed int)(a))/((signed int)(b)))

<p><p>#endif

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

Index: fixed_debug.h
===================================================================
/* Copyright (C) 2003 Jean-Marc Valin */
/**
   @file fixed_debug.h
   @brief Fixed-point operations with debugging
*/
/*
   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 FIXED_DEBUG_H
#define FIXED_DEBUG_H

#ifdef FIXED_DEBUG
extern long long spx_mips;
#define MIPS_INC spx_mips++,
#else
#define MIPS_INC
#endif

#define SHR(a,shift) ((a) >> (shift))
#define SHL(a,shift) ((a) << (shift))

<p>#define ADD16(a,b) (MIPS_INC(short)((short)(a)+(short)(b)))
#define SUB16(a,b) (MIPS_INC(a)-(b))
#define ADD32(a,b) (MIPS_INC(a)+(b))
#define SUB32(a,b) (MIPS_INC(a)-(b))
#define ADD64(a,b) (MIPS_INC(a)+(b))

#define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))

/* result fits in 16 bits */
#define MULT16_16_16(a,b)     (MIPS_INC(short)(((short)(a))*((short)(b))))
#define MULT16_16(a,b)     (MIPS_INC((short)(a))*((short)(b)))

#define MAC16_16(c,a,b)     (ADD32((c),MULT16_16((a),(b))))

#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))

#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))

#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))

<p>#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))

#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))

#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))

<p><p>#define DIV32_16(a,b) ((short)(((signed int)(a))/((short)(b))))
#define DIV32(a,b) (((signed int)(a))/((signed int)(b)))

<p><p>#endif

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

Index: fixed_generic.h
===================================================================
/* Copyright (C) 2003 Jean-Marc Valin */
/**
   @file fixed_generic.h
   @brief Generic fixed-point operations
*/
/*
   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 FIXED_GENERIC_H
#define FIXED_GENERIC_H

#define SHR(a,shift) ((a) >> (shift))
#define SHL(a,shift) ((a) << (shift))

<p>#define ADD16(a,b) ((short)((short)(a)+(short)(b)))
#define SUB16(a,b) ((a)-(b))
#define ADD32(a,b) ((a)+(b))
#define SUB32(a,b) ((a)-(b))
#define ADD64(a,b) ((a)+(b))

#define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))

/* result fits in 16 bits */
#define MULT16_16_16(a,b)     ((((short)(a))*((short)(b))))

#define MULT16_16(a,b)     (((short)(a))*((short)(b)))

<p><p><p>#define MAC16_16(c,a,b)     (ADD32((c),MULT16_16((a),(b))))
#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))

#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))

#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))

<p>#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))

#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))

#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))

<p><p>#define DIV32_16(a,b) ((short)(((signed int)(a))/((short)(b))))
#define DIV32(a,b) (((signed int)(a))/((signed int)(b)))

<p><p>#endif

<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