Commit 53ce9e87 authored by Monty's avatar Monty

Nicolas Pitre's LOW_ACCURACY patch


git-svn-id: https://svn.xiph.org/trunk/Tremor@4012 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 93e8099a
......@@ -11,7 +11,7 @@ libvorbisidec_la_SOURCES = mdct.c block.c window.c \
sharedbook.c framing.c bitwise.c \
codebook.h misc.h mdct_lookup.h\
os.h mdct.h ivorbisfile.h lsp_lookup.h\
registry.h window.h\
registry.h window.h window_lookup.h\
codec_internal.h backends.h ogg.h \
asm_arm.h ivorbiscodec.h
libvorbisidec_la_LDFLAGS = -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@
......
......@@ -16,7 +16,8 @@
********************************************************************/
#ifdef _ARM_ASSEM_
#ifndef _V_WIDE_MATH
#if !defined(_V_WIDE_MATH) && !defined(_LOW_ACCURACY_)
#define _V_WIDE_MATH
static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
......@@ -32,10 +33,6 @@ static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return MULT32(x,y)<<1;
}
static inline ogg_int32_t MULT30(ogg_int32_t x, ogg_int32_t y) {
return MULT32(x,y)<<2;
}
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
int lo,hi;
asm volatile("smull %0, %1, %2, %3\n\t"
......@@ -47,19 +44,6 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
return(hi);
}
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int tmp;
asm volatile("subs %1, %0, #32768\n\t"
"movpl %0, #0x7f00\n\t"
"orrpl %0, %0, #0xff\n"
"adds %1, %0, #32768\n\t"
"movmi %0, #0x8000"
: "+r"(x),"=r"(tmp)
:
: "cc");
return(x);
}
#define MB() asm volatile ("" : : : "memory")
static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
......@@ -118,6 +102,24 @@ static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
#endif
#ifndef _V_CLIP_MATH
#define _V_CLIP_MATH
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int tmp;
asm volatile("subs %1, %0, #32768\n\t"
"movpl %0, #0x7f00\n\t"
"orrpl %0, %0, #0xff\n"
"adds %1, %0, #32768\n\t"
"movmi %0, #0x8000"
: "+r"(x),"=r"(tmp)
:
: "cc");
return(x);
}
#endif
#ifndef _V_LSP_MATH_ASM
#define _V_LSP_MATH_ASM
......@@ -238,3 +240,4 @@ static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){
#endif
#endif
......@@ -39,7 +39,7 @@ typedef void vorbis_info_mapping;
typedef struct private_state {
/* local lookup storage */
const ogg_int32_t *window[2];
const void *window[2];
/* backend lookups are tied to the mode, not the backend or naked mapping */
int modebits;
......
......@@ -67,6 +67,16 @@ fi
CFLAGS="$CFLAGS $cflags_save -D_REENTRANT"
LDFLAGS="$LDFLAGS $ldflags_save"
dnl --------------------------------------------------
dnl Options
dnl --------------------------------------------------
AC_ARG_ENABLE(
low-accuracy,
[ --enable-low-accuracy enable 32 bit only multiply operations],
CFLAGS="$CFLAGS -D_LOW_ACCURACY_"
)
dnl --------------------------------------------------
dnl Check for headers
dnl --------------------------------------------------
......
......@@ -117,21 +117,21 @@ static inline ogg_int32_t toBARK(int n){
}
}
static const int MLOOP_1[64]={
static const unsigned char MLOOP_1[64]={
0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
};
static const int MLOOP_2[64]={
static const unsigned char MLOOP_2[64]={
0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
};
static const int MLOOP_3[8]={0,1,2,2,3,3,3,3};
static const unsigned char MLOOP_3[8]={0,1,2,2,3,3,3,3};
void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
ogg_int32_t *lsp,int m,
......@@ -146,10 +146,13 @@ void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
int ampoffseti=ampoffset*4096;
int ampi=amp;
ogg_int32_t *ilsp=(ogg_int32_t *)alloca(m*sizeof(*ilsp));
ogg_int32_t invsq=0x517cc2;
/* lsp is in 8.24, range 0 to PI; coslook wants it in .16 0 to 1*/
for(i=0;i<m;i++){
ogg_int32_t val=MULT32(lsp[i],invsq);
#ifndef _LOW_ACCURACY_
ogg_int32_t val=MULT32(lsp[i],0x517cc2);
#else
ogg_int32_t val=((lsp[i]>>10)*0x517d)>>14;
#endif
/* safeguard against a malicious stream */
if(val<0 || (val>>COS_LOOKUP_I_SHIFT)>=COS_LOOKUP_I_SZ){
......@@ -272,6 +275,9 @@ void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
/* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */
#ifdef _LOW_ACCURACY_
amp>>=9;
#endif
curve[i]= MULT31_SHIFT15(curve[i],amp);
while(map[++i]==k) curve[i]= MULT31_SHIFT15(curve[i],amp);
}
......
......@@ -25,8 +25,6 @@
#include "codebook.h"
#include "misc.h"
#include <stdio.h>
#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
typedef struct {
......@@ -216,73 +214,79 @@ static int render_point(int x0,int x1,int y0,int y1,int x){
}
}
#ifdef _LOW_ACCURACY_
# define X(n) ((((n)>>8)+1)>>1)
#else
# define X(n) (n)
#endif
static const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
0x000000e5, 0x000000f4, 0x00000103, 0x00000114,
0x00000126, 0x00000139, 0x0000014e, 0x00000163,
0x0000017a, 0x00000193, 0x000001ad, 0x000001c9,
0x000001e7, 0x00000206, 0x00000228, 0x0000024c,
0x00000272, 0x0000029b, 0x000002c6, 0x000002f4,
0x00000326, 0x0000035a, 0x00000392, 0x000003cd,
0x0000040c, 0x00000450, 0x00000497, 0x000004e4,
0x00000535, 0x0000058c, 0x000005e8, 0x0000064a,
0x000006b3, 0x00000722, 0x00000799, 0x00000818,
0x0000089e, 0x0000092e, 0x000009c6, 0x00000a69,
0x00000b16, 0x00000bcf, 0x00000c93, 0x00000d64,
0x00000e43, 0x00000f30, 0x0000102d, 0x0000113a,
0x00001258, 0x0000138a, 0x000014cf, 0x00001629,
0x0000179a, 0x00001922, 0x00001ac4, 0x00001c82,
0x00001e5c, 0x00002055, 0x0000226f, 0x000024ac,
0x0000270e, 0x00002997, 0x00002c4b, 0x00002f2c,
0x0000323d, 0x00003581, 0x000038fb, 0x00003caf,
0x000040a0, 0x000044d3, 0x0000494c, 0x00004e10,
0x00005323, 0x0000588a, 0x00005e4b, 0x0000646b,
0x00006af2, 0x000071e5, 0x0000794c, 0x0000812e,
0x00008993, 0x00009283, 0x00009c09, 0x0000a62d,
0x0000b0f9, 0x0000bc79, 0x0000c8b9, 0x0000d5c4,
0x0000e3a9, 0x0000f274, 0x00010235, 0x000112fd,
0x000124dc, 0x000137e4, 0x00014c29, 0x000161bf,
0x000178bc, 0x00019137, 0x0001ab4a, 0x0001c70e,
0x0001e4a1, 0x0002041f, 0x000225aa, 0x00024962,
0x00026f6d, 0x000297f0, 0x0002c316, 0x0002f109,
0x000321f9, 0x00035616, 0x00038d97, 0x0003c8b4,
0x000407a7, 0x00044ab2, 0x00049218, 0x0004de23,
0x00052f1e, 0x0005855c, 0x0005e135, 0x00064306,
0x0006ab33, 0x00071a24, 0x0007904b, 0x00080e20,
0x00089422, 0x000922da, 0x0009bad8, 0x000a5cb6,
0x000b091a, 0x000bc0b1, 0x000c8436, 0x000d5471,
0x000e3233, 0x000f1e5f, 0x001019e4, 0x001125c1,
0x00124306, 0x001372d5, 0x0014b663, 0x00160ef7,
0x00177df0, 0x001904c1, 0x001aa4f9, 0x001c603d,
0x001e384f, 0x00202f0f, 0x0022467a, 0x002480b1,
0x0026dff7, 0x002966b3, 0x002c1776, 0x002ef4fc,
0x0032022d, 0x00354222, 0x0038b828, 0x003c67c2,
0x004054ae, 0x004482e8, 0x0048f6af, 0x004db488,
0x0052c142, 0x005821ff, 0x005ddc33, 0x0063f5b0,
0x006a74a7, 0x00715faf, 0x0078bdce, 0x0080967f,
0x0088f1ba, 0x0091d7f9, 0x009b5247, 0x00a56a41,
0x00b02a27, 0x00bb9ce2, 0x00c7ce12, 0x00d4ca17,
0x00e29e20, 0x00f15835, 0x0101074b, 0x0111bb4e,
0x01238531, 0x01367704, 0x014aa402, 0x016020a7,
0x017702c3, 0x018f6190, 0x01a955cb, 0x01c4f9cf,
0x01e269a8, 0x0201c33b, 0x0223265a, 0x0246b4ea,
0x026c9302, 0x0294e716, 0x02bfda13, 0x02ed9793,
0x031e4e09, 0x03522ee4, 0x03896ed0, 0x03c445e2,
0x0402efd6, 0x0445ac4b, 0x048cbefc, 0x04d87013,
0x05290c67, 0x057ee5ca, 0x05da5364, 0x063bb204,
0x06a36485, 0x0711d42b, 0x0787710e, 0x0804b299,
0x088a17ef, 0x0918287e, 0x09af747c, 0x0a50957e,
0x0afc2f19, 0x0bb2ef7f, 0x0c759034, 0x0d44d6ca,
0x0e2195bc, 0x0f0cad0d, 0x10070b62, 0x1111aeea,
0x122da66c, 0x135c120f, 0x149e24d9, 0x15f525b1,
0x176270e3, 0x18e7794b, 0x1a85c9ae, 0x1c3f06d1,
0x1e14f07d, 0x200963d7, 0x221e5ccd, 0x2455f870,
0x26b2770b, 0x29363e2b, 0x2be3db5c, 0x2ebe06b6,
0x31c7a55b, 0x3503ccd4, 0x3875c5aa, 0x3c210f44,
0x4009632b, 0x4432b8cf, 0x48a149bc, 0x4d59959e,
0x52606733, 0x57bad899, 0x5d6e593a, 0x6380b298,
0x69f80e9a, 0x70dafda8, 0x78307d76, 0x7fffffff,
X(0x000000e5), X(0x000000f4), X(0x00000103), X(0x00000114),
X(0x00000126), X(0x00000139), X(0x0000014e), X(0x00000163),
X(0x0000017a), X(0x00000193), X(0x000001ad), X(0x000001c9),
X(0x000001e7), X(0x00000206), X(0x00000228), X(0x0000024c),
X(0x00000272), X(0x0000029b), X(0x000002c6), X(0x000002f4),
X(0x00000326), X(0x0000035a), X(0x00000392), X(0x000003cd),
X(0x0000040c), X(0x00000450), X(0x00000497), X(0x000004e4),
X(0x00000535), X(0x0000058c), X(0x000005e8), X(0x0000064a),
X(0x000006b3), X(0x00000722), X(0x00000799), X(0x00000818),
X(0x0000089e), X(0x0000092e), X(0x000009c6), X(0x00000a69),
X(0x00000b16), X(0x00000bcf), X(0x00000c93), X(0x00000d64),
X(0x00000e43), X(0x00000f30), X(0x0000102d), X(0x0000113a),
X(0x00001258), X(0x0000138a), X(0x000014cf), X(0x00001629),
X(0x0000179a), X(0x00001922), X(0x00001ac4), X(0x00001c82),
X(0x00001e5c), X(0x00002055), X(0x0000226f), X(0x000024ac),
X(0x0000270e), X(0x00002997), X(0x00002c4b), X(0x00002f2c),
X(0x0000323d), X(0x00003581), X(0x000038fb), X(0x00003caf),
X(0x000040a0), X(0x000044d3), X(0x0000494c), X(0x00004e10),
X(0x00005323), X(0x0000588a), X(0x00005e4b), X(0x0000646b),
X(0x00006af2), X(0x000071e5), X(0x0000794c), X(0x0000812e),
X(0x00008993), X(0x00009283), X(0x00009c09), X(0x0000a62d),
X(0x0000b0f9), X(0x0000bc79), X(0x0000c8b9), X(0x0000d5c4),
X(0x0000e3a9), X(0x0000f274), X(0x00010235), X(0x000112fd),
X(0x000124dc), X(0x000137e4), X(0x00014c29), X(0x000161bf),
X(0x000178bc), X(0x00019137), X(0x0001ab4a), X(0x0001c70e),
X(0x0001e4a1), X(0x0002041f), X(0x000225aa), X(0x00024962),
X(0x00026f6d), X(0x000297f0), X(0x0002c316), X(0x0002f109),
X(0x000321f9), X(0x00035616), X(0x00038d97), X(0x0003c8b4),
X(0x000407a7), X(0x00044ab2), X(0x00049218), X(0x0004de23),
X(0x00052f1e), X(0x0005855c), X(0x0005e135), X(0x00064306),
X(0x0006ab33), X(0x00071a24), X(0x0007904b), X(0x00080e20),
X(0x00089422), X(0x000922da), X(0x0009bad8), X(0x000a5cb6),
X(0x000b091a), X(0x000bc0b1), X(0x000c8436), X(0x000d5471),
X(0x000e3233), X(0x000f1e5f), X(0x001019e4), X(0x001125c1),
X(0x00124306), X(0x001372d5), X(0x0014b663), X(0x00160ef7),
X(0x00177df0), X(0x001904c1), X(0x001aa4f9), X(0x001c603d),
X(0x001e384f), X(0x00202f0f), X(0x0022467a), X(0x002480b1),
X(0x0026dff7), X(0x002966b3), X(0x002c1776), X(0x002ef4fc),
X(0x0032022d), X(0x00354222), X(0x0038b828), X(0x003c67c2),
X(0x004054ae), X(0x004482e8), X(0x0048f6af), X(0x004db488),
X(0x0052c142), X(0x005821ff), X(0x005ddc33), X(0x0063f5b0),
X(0x006a74a7), X(0x00715faf), X(0x0078bdce), X(0x0080967f),
X(0x0088f1ba), X(0x0091d7f9), X(0x009b5247), X(0x00a56a41),
X(0x00b02a27), X(0x00bb9ce2), X(0x00c7ce12), X(0x00d4ca17),
X(0x00e29e20), X(0x00f15835), X(0x0101074b), X(0x0111bb4e),
X(0x01238531), X(0x01367704), X(0x014aa402), X(0x016020a7),
X(0x017702c3), X(0x018f6190), X(0x01a955cb), X(0x01c4f9cf),
X(0x01e269a8), X(0x0201c33b), X(0x0223265a), X(0x0246b4ea),
X(0x026c9302), X(0x0294e716), X(0x02bfda13), X(0x02ed9793),
X(0x031e4e09), X(0x03522ee4), X(0x03896ed0), X(0x03c445e2),
X(0x0402efd6), X(0x0445ac4b), X(0x048cbefc), X(0x04d87013),
X(0x05290c67), X(0x057ee5ca), X(0x05da5364), X(0x063bb204),
X(0x06a36485), X(0x0711d42b), X(0x0787710e), X(0x0804b299),
X(0x088a17ef), X(0x0918287e), X(0x09af747c), X(0x0a50957e),
X(0x0afc2f19), X(0x0bb2ef7f), X(0x0c759034), X(0x0d44d6ca),
X(0x0e2195bc), X(0x0f0cad0d), X(0x10070b62), X(0x1111aeea),
X(0x122da66c), X(0x135c120f), X(0x149e24d9), X(0x15f525b1),
X(0x176270e3), X(0x18e7794b), X(0x1a85c9ae), X(0x1c3f06d1),
X(0x1e14f07d), X(0x200963d7), X(0x221e5ccd), X(0x2455f870),
X(0x26b2770b), X(0x29363e2b), X(0x2be3db5c), X(0x2ebe06b6),
X(0x31c7a55b), X(0x3503ccd4), X(0x3875c5aa), X(0x3c210f44),
X(0x4009632b), X(0x4432b8cf), X(0x48a149bc), X(0x4d59959e),
X(0x52606733), X(0x57bad899), X(0x5d6e593a), X(0x6380b298),
X(0x69f80e9a), X(0x70dafda8), X(0x78307d76), X(0x7fffffff),
};
static void render_line(int x0,int x1,int y0,int y1,ogg_int32_t *d){
int dy=y1-y0;
int adx=x1-x0;
......
......@@ -13,7 +13,7 @@
function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ]
last mod: $Id: mdct.c,v 1.7 2002/10/16 08:10:08 xiphmont Exp $
last mod: $Id: mdct.c,v 1.8 2002/10/16 09:07:00 xiphmont Exp $
Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer,
......@@ -32,15 +32,11 @@
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "ivorbiscodec.h"
#include "os.h"
#include "misc.h"
#include "mdct.h"
#include "mdct_lookup.h"
#include "misc.h"
/* 8 point butterfly (in place) */
......@@ -151,7 +147,7 @@ STIN void mdct_butterfly_32(DATA_TYPE *x){
/* N/stage point generic N stage butterfly (in place, 2 register) */
STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
const DATA_TYPE *T = sincos_lookup0;
LOOKUP_T *T = sincos_lookup0;
DATA_TYPE *x1 = x + points - 8;
DATA_TYPE *x2 = x + (points>>1) - 8;
REG_TYPE r0;
......@@ -261,8 +257,8 @@ STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
int bit = 0;
DATA_TYPE *w0 = x;
DATA_TYPE *w1 = x = w0+(n>>1);
const DATA_TYPE *T = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
const DATA_TYPE *Ttop = T+1024;
LOOKUP_T *T = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
LOOKUP_T *Ttop = T+1024;
DATA_TYPE r2;
do{
......@@ -270,10 +266,10 @@ STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
DATA_TYPE *x0 = x + ((r3 ^ 0xfff)>>shift) -1;
DATA_TYPE *x1 = x + (r3>>shift);
REG_TYPE r0 = x1[1] - x0[1];
REG_TYPE r1 = x0[0] + x1[0];
REG_TYPE r0 = x0[0] + x1[0];
REG_TYPE r1 = x1[1] - x0[1];
XPROD32( T[0], T[1], r0, r1, &r2, &r3 ); T+=step;
XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
w1 -= 4;
......@@ -288,10 +284,10 @@ STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
x0 = x + ((r3 ^ 0xfff)>>shift) -1;
x1 = x + (r3>>shift);
r0 = x1[1] - x0[1];
r1 = x0[0] + x1[0];
r0 = x0[0] + x1[0];
r1 = x1[1] - x0[1];
XPROD32( T[0], T[1], r0, r1, &r2, &r3 ); T+=step;
XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
r0 = (x0[1] + x1[1])>>1;
r1 = (x0[0] - x1[0])>>1;
......@@ -346,8 +342,8 @@ void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out){
int n4=n>>2;
DATA_TYPE *iX;
DATA_TYPE *oX;
const DATA_TYPE *T;
const DATA_TYPE *V;
LOOKUP_T *T;
LOOKUP_T *V;
int shift;
int step;
......
......@@ -23,9 +23,16 @@
#define DATA_TYPE ogg_int32_t
#define REG_TYPE register ogg_int32_t
#define cPI3_8 (0x61f78a9bUL>>1)
#define cPI2_8 (0xb504f334UL>>1)
#define cPI1_8 (0xec835e7aUL>>1)
#ifdef _LOW_ACCURACY_
#define cPI3_8 (0x0062)
#define cPI2_8 (0x00b5)
#define cPI1_8 (0x00ed)
#else
#define cPI3_8 (0x30fbc54d)
#define cPI2_8 (0x5a82799a)
#define cPI1_8 (0x7641af3d)
#endif
extern void mdct_forward(int n, DATA_TYPE *in, DATA_TYPE *out);
extern void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out);
......
This diff is collapsed.
......@@ -25,10 +25,15 @@ extern void _vorbis_block_ripcord(vorbis_block *vb);
extern void _analysis_output(char *base,int i,ogg_int32_t *v,int point,
int n,int bark,int dB);
#include "asm_arm.h"
#ifdef _ARM_ASSEM_
#include "asm_arm.h"
#endif
#ifndef _V_WIDE_MATH
#define _V_WIDE_MATH
#ifndef _LOW_ACCURACY_
/* 64 bit multiply */
#include <sys/types.h>
......@@ -62,23 +67,42 @@ static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return MULT32(x,y)<<1;
}
static inline ogg_int32_t MULT30(ogg_int32_t x, ogg_int32_t y) {
return MULT32(x,y)<<2;
}
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
union magic magic;
magic.whole = (ogg_int64_t)x * y;
return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
}
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int ret=x;
ret-= ((x<=32767)-1)&(x-32767);
ret-= ((x>=-32768)-1)&(x+32768);
return(ret);
#else
/* 32 bit multiply, more portable but less accurate */
/*
* Note: Precision is biased towards the first argument therefore ordering
* is important. Shift values were chosen for the best sound quality after
* many listening tests.
*/
/*
* For MULT32 and MULT31: The second argument is always a lookup table
* value already preshifted from 31 to 8 bits. We therefore take the
* opportunity to save on text space and use unsigned char for those
* tables in this case.
*/
static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
return (x >> 9) * y; /* y preshifted >>23 */
}
static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return (x >> 8) * y; /* y preshifted >>23 */
}
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
return (x >> 6) * y; /* y preshifted >>9 */
}
#endif
/*
* This should be used as a memory barrier, forcing all cached values in
* registers to wr writen back to memory. Might or might not be beneficial
......@@ -98,15 +122,15 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
#ifdef __i386__
#define XPROD32(_a, _b, _t, _v, _x, _y) \
{ *(_x)= MULT32(_a,_t)+MULT32(_b,_v) ; \
*(_y)= MULT32(_b,_t)-MULT32(_a,_v) ; }
#define XPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=(MULT32(_a,_t)+MULT32(_b,_v))<<1; \
*(_y)=(MULT32(_b,_t)-MULT32(_a,_v))<<1; }
#define XPROD32(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT32(_a,_t)+MULT32(_b,_v); \
*(_y)=MULT32(_b,_t)-MULT32(_a,_v); }
#define XPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
#define XNPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=(MULT32(_a,_t)-MULT32(_b,_v))<<1; \
*(_y)=(MULT32(_b,_t)+MULT32(_a,_v))<<1; }
{ *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
#else
......@@ -122,28 +146,45 @@ static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
*x = (MULT32(a, t) + MULT32(b, v))<<1;
*y = (MULT32(b, t) - MULT32(a, v))<<1;
*x = MULT31(a, t) + MULT31(b, v);
*y = MULT31(b, t) - MULT31(a, v);
}
static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
*x = (MULT32(a, t) - MULT32(b, v))<<1;
*y = (MULT32(b, t) + MULT32(a, v))<<1;
*x = MULT31(a, t) - MULT31(b, v);
*y = MULT31(b, t) + MULT31(a, v);
}
#endif
#endif
#ifndef _V_CLIP_MATH
#define _V_CLIP_MATH
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int ret=x;
ret-= ((x<=32767)-1)&(x-32767);
ret-= ((x>=-32768)-1)&(x+32768);
return(ret);
}
#endif
static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){
if(a && b){
#ifndef _LOW_ACCURACY_
*p=ap+bp+32;
return MULT32(a,b);
#else
*p=ap+bp+31;
return (a>>15)*(b>>16);
#endif
}else
return 0;
}
......
......@@ -17,6 +17,14 @@
#ifndef _OS_TYPES_H
#define _OS_TYPES_H
#ifdef _LOW_ACCURACY_
# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9))
# define LOOKUP_T const unsigned char
#else
# define X(n) (n)
# define LOOKUP_T const ogg_int32_t
#endif
/* make it easy on the folks that want to compile the libs with a
different malloc than stdlib */
#define _ogg_malloc malloc
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -18,8 +18,8 @@
#ifndef _V_WINDOW_
#define _V_WINDOW_
extern const ogg_int32_t *_vorbis_window(int type,int left);
extern void _vorbis_apply_window(ogg_int32_t *d,const ogg_int32_t *window[2],
extern const void *_vorbis_window(int type,int left);
extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2],
long *blocksizes,
int lW,int W,int nW);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment