summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <xiphmont@xiph.org>2001-10-11 15:41:56 +0000
committerMonty <xiphmont@xiph.org>2001-10-11 15:41:56 +0000
commit4a0b48db19e0fed8d58c7d9f67ee747c9672e29a (patch)
treefd62c8f3e16e60bf141fc4cdddf3454ca0be65a8
parent5f94292430b302d7798e171e51b36e5f3090d499 (diff)
downloadlibvorbis-git-4a0b48db19e0fed8d58c7d9f67ee747c9672e29a.tar.gz
repair swapped avratemin and max.
the 'burst of static in first/last frame' bug was real; pre/post extrapolate could overflow the autocorr accumulator. This was also throwing off global_specmax, nailing it to infinity if preextrapolate broke. Fixed. svn path=/branches/branch_monty_20011009/vorbis/; revision=2126
-rw-r--r--lib/block.c17
-rw-r--r--lib/books/line_1024x31_0sub0.vqh2
-rw-r--r--lib/books/line_1024x31_0sub1.vqh8
-rw-r--r--lib/books/line_1024x31_1sub0.vqh2
-rw-r--r--lib/books/line_1024x31_1sub1.vqh8
-rw-r--r--lib/books/line_1024x31_2sub1.vqh2
-rw-r--r--lib/books/line_1024x31_2sub2.vqh4
-rw-r--r--lib/books/line_1024x31_2sub3.vqh8
-rw-r--r--lib/books/line_1024x31_3sub1.vqh2
-rw-r--r--lib/books/line_1024x31_3sub2.vqh4
-rw-r--r--lib/books/line_1024x31_3sub3.vqh8
-rw-r--r--lib/books/line_1024x31_class0.vqh2
-rw-r--r--lib/books/line_1024x31_class1.vqh2
-rw-r--r--lib/books/line_1024x31_class2.vqh8
-rw-r--r--lib/books/line_1024x31_class3.vqh8
-rw-r--r--lib/books/line_128x19_0sub0.vqh40
-rw-r--r--lib/books/line_128x19_1sub2.vqh38
-rw-r--r--lib/books/line_128x19_1sub3.vqh40
-rw-r--r--lib/books/line_128x19_2sub1.vqh37
-rw-r--r--lib/books/line_128x19_2sub2.vqh38
-rw-r--r--lib/books/line_128x19_2sub3.vqh40
-rw-r--r--lib/books/line_128x19_class1.vqh40
-rw-r--r--lib/books/line_128x19_class2.vqh40
-rw-r--r--lib/books/res_44c_A_1024aux.vqh43
-rw-r--r--lib/books/res_44c_A_128aux.vqh12
-rw-r--r--lib/books/res_Ac_1.vqh63
-rw-r--r--lib/books/res_Ac_2.vqh63
-rw-r--r--lib/books/res_Ac_3.vqh99
-rw-r--r--lib/books/res_Ac_4.vqh99
-rw-r--r--lib/books/res_Ac_5.vqh99
-rw-r--r--lib/books/res_Ac_6.vqh70
-rw-r--r--lib/books/res_Ac_7.vqh65
-rw-r--r--lib/books/res_Ac_7a.vqh99
-rw-r--r--lib/books/res_Ac_8.vqh80
-rw-r--r--lib/books/res_Ac_8a.vqh80
-rw-r--r--lib/books/res_Ac_9.vqh65
-rw-r--r--lib/books/res_Ac_9a.vqh80
-rw-r--r--lib/books/res_Ac_9b.vqh80
-rw-r--r--lib/codec_internal.h4
-rw-r--r--lib/info.c588
-rw-r--r--lib/lpc.c200
-rw-r--r--lib/mapping0.c175
-rw-r--r--lib/modes/maskadj_A.h155
-rw-r--r--lib/modes/mode_44c_A.h59
-rw-r--r--lib/psy.c1139
-rw-r--r--lib/res0.c18
-rw-r--r--vq/latticehint.c430
-rw-r--r--vq/res_44c_A.vqs44
-rw-r--r--vq/residuesplit.c282
49 files changed, 4450 insertions, 139 deletions
diff --git a/lib/block.c b/lib/block.c
index ad6481e5..b0290445 100644
--- a/lib/block.c
+++ b/lib/block.c
@@ -11,7 +11,7 @@
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.50.2.1 2001/10/09 04:34:45 xiphmont Exp $
+ last mod: $Id: block.c,v 1.50.2.2 2001/10/11 15:41:44 xiphmont Exp $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
@@ -276,7 +276,8 @@ int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi){
ci->bitrate_avg_queuetime)*
vi->rate+(ci->blocksizes[0]-1))/ci->blocksizes[0]+1;
long eighths=8*ci->passlimit[ci->coupling_passes-1];
- if(ci->bitrate_queue_loweravg<=0. && ci->bitrate_queue_upperavg<=0.)eighths=0;
+ if(ci->bitrate_queue_loweravg<=0. &&
+ ci->bitrate_queue_upperavg<=0.)eighths=0;
b->bitrate_queue_size=maxpackets;
b->bitrate_eighths=eighths;
@@ -395,6 +396,7 @@ float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
return(v->pcmret);
}
+static int seq=0;
static void _preextrapolate_helper(vorbis_dsp_state *v){
int i;
int order=32;
@@ -405,21 +407,30 @@ static void _preextrapolate_helper(vorbis_dsp_state *v){
if(v->pcm_current-v->centerW>order*2){ /* safety */
for(i=0;i<v->vi->channels;i++){
-
/* need to run the extrapolation in reverse! */
for(j=0;j<v->pcm_current;j++)
work[j]=v->pcm[i][v->pcm_current-j-1];
+ _analysis_output("preextrap",seq,v->pcm[i],v->pcm_current,0,0);
+ _analysis_output("workextrap",seq,work,v->pcm_current,0,0);
+
/* prime as above */
vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order);
+ _analysis_output("lpc",seq,lpc,order,0,0);
/* run the predictor filter */
vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order,
order,
work+v->pcm_current-v->centerW,
v->centerW);
+
+ _analysis_output("extrap",seq,work,v->pcm_current,0,0);
+
+
for(j=0;j<v->pcm_current;j++)
v->pcm[i][v->pcm_current-j-1]=work[j];
+
+ _analysis_output("postextrap",seq++,v->pcm[i],v->pcm_current,0,0);
}
}
}
diff --git a/lib/books/line_1024x31_0sub0.vqh b/lib/books/line_1024x31_0sub0.vqh
index fd817ecb..041fddbc 100644
--- a/lib/books/line_1024x31_0sub0.vqh
+++ b/lib/books/line_1024x31_0sub0.vqh
@@ -20,7 +20,7 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_0sub0[] = {
- 4, 3, 4, 4, 4, 3, 4, 3, 5, 4, 5, 4, 6, 4, 6, 5,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
};
static static_codebook _huff_book_line_1024x31_0sub0 = {
diff --git a/lib/books/line_1024x31_0sub1.vqh b/lib/books/line_1024x31_0sub1.vqh
index 1d05c0bc..bc59cb0b 100644
--- a/lib/books/line_1024x31_0sub1.vqh
+++ b/lib/books/line_1024x31_0sub1.vqh
@@ -20,10 +20,10 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_0sub1[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, 3, 4, 3, 5, 3, 5, 3, 6, 4, 7, 4, 7, 4, 7, 5,
- 7, 6, 8, 6,10, 9,10,10,11,12,10,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
};
static static_codebook _huff_book_line_1024x31_0sub1 = {
diff --git a/lib/books/line_1024x31_1sub0.vqh b/lib/books/line_1024x31_1sub0.vqh
index 5e25a379..67b8f116 100644
--- a/lib/books/line_1024x31_1sub0.vqh
+++ b/lib/books/line_1024x31_1sub0.vqh
@@ -20,7 +20,7 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_1sub0[] = {
- 2, 3, 4, 4, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
};
static static_codebook _huff_book_line_1024x31_1sub0 = {
diff --git a/lib/books/line_1024x31_1sub1.vqh b/lib/books/line_1024x31_1sub1.vqh
index 68fd0be9..64c88f63 100644
--- a/lib/books/line_1024x31_1sub1.vqh
+++ b/lib/books/line_1024x31_1sub1.vqh
@@ -20,10 +20,10 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_1sub1[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 3, 3, 3, 4, 3, 3, 3, 4, 5, 5, 6, 6, 7,10,10,10,
- 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
- 11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
};
static static_codebook _huff_book_line_1024x31_1sub1 = {
diff --git a/lib/books/line_1024x31_2sub1.vqh b/lib/books/line_1024x31_2sub1.vqh
index c36ad6a7..dfdb2d56 100644
--- a/lib/books/line_1024x31_2sub1.vqh
+++ b/lib/books/line_1024x31_2sub1.vqh
@@ -20,7 +20,7 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_2sub1[] = {
- 0, 2, 4, 2, 4, 3, 4, 3, 4,
+ 0, 3, 3, 3, 3, 3, 3, 3, 3,
};
static static_codebook _huff_book_line_1024x31_2sub1 = {
diff --git a/lib/books/line_1024x31_2sub2.vqh b/lib/books/line_1024x31_2sub2.vqh
index 7396483a..55fe664b 100644
--- a/lib/books/line_1024x31_2sub2.vqh
+++ b/lib/books/line_1024x31_2sub2.vqh
@@ -20,8 +20,8 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_2sub2[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 4, 6, 5, 7,
- 4, 8, 3, 9, 3,10, 4,10, 4,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4,
};
static static_codebook _huff_book_line_1024x31_2sub2 = {
diff --git a/lib/books/line_1024x31_2sub3.vqh b/lib/books/line_1024x31_2sub3.vqh
index 90f0bbcf..084562d3 100644
--- a/lib/books/line_1024x31_2sub3.vqh
+++ b/lib/books/line_1024x31_2sub3.vqh
@@ -20,10 +20,10 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_2sub3[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 2, 7, 3, 7, 2, 7,
- 4, 7, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
+ 0, 0, 2, 0, 0, 0, 0, 1, 0, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
static static_codebook _huff_book_line_1024x31_2sub3 = {
diff --git a/lib/books/line_1024x31_3sub1.vqh b/lib/books/line_1024x31_3sub1.vqh
index 304002a4..efddd628 100644
--- a/lib/books/line_1024x31_3sub1.vqh
+++ b/lib/books/line_1024x31_3sub1.vqh
@@ -20,7 +20,7 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_3sub1[] = {
- 0, 3, 3, 2, 3, 3, 4, 3, 4,
+ 0, 3, 3, 3, 3, 3, 3, 3, 3,
};
static static_codebook _huff_book_line_1024x31_3sub1 = {
diff --git a/lib/books/line_1024x31_3sub2.vqh b/lib/books/line_1024x31_3sub2.vqh
index cc17fea7..babd7dbf 100644
--- a/lib/books/line_1024x31_3sub2.vqh
+++ b/lib/books/line_1024x31_3sub2.vqh
@@ -20,8 +20,8 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_3sub2[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 2, 4, 3, 6, 4,
- 7, 5, 9, 5, 9, 6, 9, 6, 9,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4,
};
static static_codebook _huff_book_line_1024x31_3sub2 = {
diff --git a/lib/books/line_1024x31_3sub3.vqh b/lib/books/line_1024x31_3sub3.vqh
index 487bca22..e04d8f4d 100644
--- a/lib/books/line_1024x31_3sub3.vqh
+++ b/lib/books/line_1024x31_3sub3.vqh
@@ -20,10 +20,10 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_3sub3[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 3, 7, 4, 7, 6,
- 5, 6, 7, 7, 7, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
+ 0, 0, 2, 0, 0, 0, 0, 1, 0, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
static static_codebook _huff_book_line_1024x31_3sub3 = {
diff --git a/lib/books/line_1024x31_class0.vqh b/lib/books/line_1024x31_class0.vqh
index ffc5488c..64b8bb94 100644
--- a/lib/books/line_1024x31_class0.vqh
+++ b/lib/books/line_1024x31_class0.vqh
@@ -20,7 +20,7 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_class0[] = {
- 1, 2, 4, 6, 3, 5, 7, 7,
+ 3, 3, 3, 3, 3, 3, 3, 3,
};
static static_codebook _huff_book_line_1024x31_class0 = {
diff --git a/lib/books/line_1024x31_class1.vqh b/lib/books/line_1024x31_class1.vqh
index e4d83449..bcc6ca69 100644
--- a/lib/books/line_1024x31_class1.vqh
+++ b/lib/books/line_1024x31_class1.vqh
@@ -20,7 +20,7 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_class1[] = {
- 1, 5, 2, 4, 7,11,10,12, 3, 8, 6,10,11,12,12,12,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
};
static static_codebook _huff_book_line_1024x31_class1 = {
diff --git a/lib/books/line_1024x31_class2.vqh b/lib/books/line_1024x31_class2.vqh
index 74527b7e..ec2e70bb 100644
--- a/lib/books/line_1024x31_class2.vqh
+++ b/lib/books/line_1024x31_class2.vqh
@@ -20,10 +20,10 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_class2[] = {
- 1, 3, 4,10, 7, 5, 6,10, 9, 6,11,15,15,15,15,15,
- 6, 3, 5,11, 7, 5, 7,11,11, 8,12,15,15,15,15,15,
- 10, 8, 8,13,11, 9,10,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,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
};
static static_codebook _huff_book_line_1024x31_class2 = {
diff --git a/lib/books/line_1024x31_class3.vqh b/lib/books/line_1024x31_class3.vqh
index ab1be065..95622bd6 100644
--- a/lib/books/line_1024x31_class3.vqh
+++ b/lib/books/line_1024x31_class3.vqh
@@ -20,10 +20,10 @@
#include "codebook.h"
static long _huff_lengthlist_line_1024x31_class3[] = {
- 1, 3, 5,11, 7, 3, 5,11, 9, 7, 9,15,15,15,15,14,
- 7, 4, 6,11, 7, 5, 6,12,10, 8, 9,14,14,14,14,14,
- 11, 8, 9,12,11, 8, 8,11,13,10,11,14,14,14,14,14,
- 14,14,14,13,14,14,14,14,14,14,14,14,14,14,14,14,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
};
static static_codebook _huff_book_line_1024x31_class3 = {
diff --git a/lib/books/line_128x19_0sub0.vqh b/lib/books/line_128x19_0sub0.vqh
new file mode 100644
index 00000000..8172aca0
--- /dev/null
+++ b/lib/books/line_128x19_0sub0.vqh
@@ -0,0 +1,40 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_0sub0_VQH_
+#define _V_line_128x19_0sub0_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_0sub0[] = {
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+};
+
+static static_codebook _huff_book_line_128x19_0sub0 = {
+ 1, 64,
+ _huff_lengthlist_line_128x19_0sub0,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/line_128x19_1sub2.vqh b/lib/books/line_128x19_1sub2.vqh
new file mode 100644
index 00000000..8a17c39f
--- /dev/null
+++ b/lib/books/line_128x19_1sub2.vqh
@@ -0,0 +1,38 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_1sub2_VQH_
+#define _V_line_128x19_1sub2_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_1sub2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4,
+};
+
+static static_codebook _huff_book_line_128x19_1sub2 = {
+ 1, 25,
+ _huff_lengthlist_line_128x19_1sub2,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/line_128x19_1sub3.vqh b/lib/books/line_128x19_1sub3.vqh
new file mode 100644
index 00000000..a0154e55
--- /dev/null
+++ b/lib/books/line_128x19_1sub3.vqh
@@ -0,0 +1,40 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_1sub3_VQH_
+#define _V_line_128x19_1sub3_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_1sub3[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
+ 0, 0, 2, 0, 0, 0, 0, 1, 0, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+};
+
+static static_codebook _huff_book_line_128x19_1sub3 = {
+ 1, 64,
+ _huff_lengthlist_line_128x19_1sub3,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/line_128x19_2sub1.vqh b/lib/books/line_128x19_2sub1.vqh
new file mode 100644
index 00000000..449a1d8f
--- /dev/null
+++ b/lib/books/line_128x19_2sub1.vqh
@@ -0,0 +1,37 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_2sub1_VQH_
+#define _V_line_128x19_2sub1_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_2sub1[] = {
+ 0, 3, 3, 3, 3, 3, 3, 3, 3,
+};
+
+static static_codebook _huff_book_line_128x19_2sub1 = {
+ 1, 9,
+ _huff_lengthlist_line_128x19_2sub1,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/line_128x19_2sub2.vqh b/lib/books/line_128x19_2sub2.vqh
new file mode 100644
index 00000000..b37b69ab
--- /dev/null
+++ b/lib/books/line_128x19_2sub2.vqh
@@ -0,0 +1,38 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_2sub2_VQH_
+#define _V_line_128x19_2sub2_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_2sub2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4,
+};
+
+static static_codebook _huff_book_line_128x19_2sub2 = {
+ 1, 25,
+ _huff_lengthlist_line_128x19_2sub2,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/line_128x19_2sub3.vqh b/lib/books/line_128x19_2sub3.vqh
new file mode 100644
index 00000000..bb650698
--- /dev/null
+++ b/lib/books/line_128x19_2sub3.vqh
@@ -0,0 +1,40 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_2sub3_VQH_
+#define _V_line_128x19_2sub3_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_2sub3[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
+ 0, 0, 2, 0, 0, 0, 0, 1, 0, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+};
+
+static static_codebook _huff_book_line_128x19_2sub3 = {
+ 1, 64,
+ _huff_lengthlist_line_128x19_2sub3,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/line_128x19_class1.vqh b/lib/books/line_128x19_class1.vqh
new file mode 100644
index 00000000..74a95715
--- /dev/null
+++ b/lib/books/line_128x19_class1.vqh
@@ -0,0 +1,40 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_class1_VQH_
+#define _V_line_128x19_class1_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_class1[] = {
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+};
+
+static static_codebook _huff_book_line_128x19_class1 = {
+ 1, 64,
+ _huff_lengthlist_line_128x19_class1,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/line_128x19_class2.vqh b/lib/books/line_128x19_class2.vqh
new file mode 100644
index 00000000..8a154cdf
--- /dev/null
+++ b/lib/books/line_128x19_class2.vqh
@@ -0,0 +1,40 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_line_128x19_class2_VQH_
+#define _V_line_128x19_class2_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_line_128x19_class2[] = {
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+};
+
+static static_codebook _huff_book_line_128x19_class2 = {
+ 1, 64,
+ _huff_lengthlist_line_128x19_class2,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_44c_A_1024aux.vqh b/lib/books/res_44c_A_1024aux.vqh
new file mode 100644
index 00000000..2b85116a
--- /dev/null
+++ b/lib/books/res_44c_A_1024aux.vqh
@@ -0,0 +1,43 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
+ * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by huff/huffbuld
+
+ ********************************************************************/
+
+#ifndef _V_res_44c_A_1024aux_VQH_
+#define _V_res_44c_A_1024aux_VQH_
+#include "codebook.h"
+
+static long _huff_lengthlist_res_44c_A_1024aux[] = {
+ 3,11, 6,17,11,10,10, 9,17,17,11, 5,17, 7, 5,17,
+ 6, 8,15,17, 5,17, 3,17,17, 7, 8, 9,17,17,15, 6,
+ 17, 5,17,17, 6, 7,14,17,10, 5,17,16, 4,16, 5, 8,
+ 16,16,10,16, 6,16,16, 9,10,11,16,16,10, 6, 7, 5,
+ 6,10, 4, 5,12,16,11, 7, 9, 6, 8,11, 4, 4, 8,16,
+ 15,12,16,12,16,16,11, 7, 5,14,16,16,16,16,16,16,
+ 15, 8, 8,14,
+};
+
+static static_codebook _huff_book_res_44c_A_1024aux = {
+ 2, 100,
+ _huff_lengthlist_res_44c_A_1024aux,
+ 0, 0, 0, 0, 0,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_44c_A_128aux.vqh b/lib/books/res_44c_A_128aux.vqh
index e2f0988a..2144de1a 100644
--- a/lib/books/res_44c_A_128aux.vqh
+++ b/lib/books/res_44c_A_128aux.vqh
@@ -20,13 +20,13 @@
#include "codebook.h"
static long _huff_lengthlist_res_44c_A_128aux[] = {
- 8,16, 9,16,16,11,12,15,16,16,13, 5,16,16, 5,16,
- 7,13,16,16, 6,15, 2,15,15, 6, 6,11,15,15,15, 6,
- 15,15, 4,15, 6,11,15,15,14, 4,15,15, 3,15, 6,10,
- 15,15,10,15, 6,15,15, 8,11,13,15,15,11, 5, 8,14,
- 4,10, 5,10,15,15,13, 9,10,10, 7,13, 8,11,15,15,
+ 8,15, 9,15,15,12,12,11,15,15,13, 6,15,15, 5,15,
+ 7,13,15,15, 6,15, 2,15,15, 6, 7, 7,15,15,15, 6,
+ 15,15, 4,15, 6,10,15,15,14, 4,15,15, 3,15, 5,10,
+ 15,15, 9,15, 6,15,15, 9,11,13,15,15,10, 5, 8,15,
+ 4,11, 5, 9,15,15,12, 9,10,11, 7,12, 8,11,15,15,
15,11,15, 5,15,15, 4, 6,15,15,15,14,15, 7,15,15,
- 5, 7,13,15,
+ 5, 7,15,15,
};
static static_codebook _huff_book_res_44c_A_128aux = {
diff --git a/lib/books/res_Ac_1.vqh b/lib/books/res_Ac_1.vqh
new file mode 100644
index 00000000..3be9ed89
--- /dev/null
+++ b/lib/books/res_Ac_1.vqh
@@ -0,0 +1,63 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_1_VQH_
+#define _V_res_Ac_1_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_1[] = {
+ 1,
+ 0,
+ 2,
+};
+
+static long _vq_lengthlist_res_Ac_1[] = {
+ 2, 6, 6, 0, 5, 4, 0, 5, 4, 6, 9, 8, 0, 7, 8, 0,
+ 9, 7, 6, 8, 9, 0, 8, 7, 0, 7, 9, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 4, 9, 7, 0, 7, 6, 0, 7, 6, 4, 7, 9,
+ 0, 6, 7, 0, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
+ 7, 8, 0, 6, 7, 0, 7, 6, 4, 8, 8, 0, 7, 6, 0, 6,
+ 7,
+};
+
+static float _vq_quantthresh_res_Ac_1[] = {
+ -0.5, 0.5,
+};
+
+static long _vq_quantmap_res_Ac_1[] = {
+ 1, 0, 2,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_1 = {
+ _vq_quantthresh_res_Ac_1,
+ _vq_quantmap_res_Ac_1,
+ 3,
+ 3
+};
+
+static static_codebook _vq_book_res_Ac_1 = {
+ 4, 81,
+ _vq_lengthlist_res_Ac_1,
+ 1, -535822336, 1611661312, 2, 0,
+ _vq_quantlist_res_Ac_1,
+ NULL,
+ &_vq_auxt_res_Ac_1,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_2.vqh b/lib/books/res_Ac_2.vqh
new file mode 100644
index 00000000..1efb00c4
--- /dev/null
+++ b/lib/books/res_Ac_2.vqh
@@ -0,0 +1,63 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_2_VQH_
+#define _V_res_Ac_2_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_2[] = {
+ 1,
+ 0,
+ 2,
+};
+
+static long _vq_lengthlist_res_Ac_2[] = {
+ 1, 3, 3, 0, 0, 0, 0, 0, 0, 4, 5, 5, 0, 0, 0, 0,
+ 0, 0, 4, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,
+};
+
+static float _vq_quantthresh_res_Ac_2[] = {
+ -0.5, 0.5,
+};
+
+static long _vq_quantmap_res_Ac_2[] = {
+ 1, 0, 2,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_2 = {
+ _vq_quantthresh_res_Ac_2,
+ _vq_quantmap_res_Ac_2,
+ 3,
+ 3
+};
+
+static static_codebook _vq_book_res_Ac_2 = {
+ 4, 81,
+ _vq_lengthlist_res_Ac_2,
+ 1, -535822336, 1611661312, 2, 0,
+ _vq_quantlist_res_Ac_2,
+ NULL,
+ &_vq_auxt_res_Ac_2,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_3.vqh b/lib/books/res_Ac_3.vqh
new file mode 100644
index 00000000..05d0fdd6
--- /dev/null
+++ b/lib/books/res_Ac_3.vqh
@@ -0,0 +1,99 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_3_VQH_
+#define _V_res_Ac_3_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_3[] = {
+ 2,
+ 1,
+ 3,
+ 0,
+ 4,
+};
+
+static long _vq_lengthlist_res_Ac_3[] = {
+ 3, 6, 6,10,10, 0, 5, 5, 9, 9, 0, 5, 5, 9, 9, 0,
+ 7, 7, 9, 9, 0, 0, 0, 9, 9, 6, 8, 8,12,11, 0, 7,
+ 8,10,10, 0, 8, 7,11,10, 0, 9,10,10,11, 0, 0, 0,
+ 12,10, 6, 7, 8,11,12, 0, 8, 7,10,10, 0, 7, 8,10,
+ 11, 0,10, 9,11,10, 0, 0, 0,10,11,10,12,11,14,13,
+ 0,11,12,12,13, 0,12,10,14,12, 0,12,13,13,15, 0,
+ 0, 0,16,13,10,11,12,13,13, 0,12,11,13,13, 0,10,
+ 12,13,13, 0,14,12,16,13, 0, 0, 0,12,14, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 5, 8, 7,12,11, 0, 7, 7,11, 9,
+ 0, 7, 6,11,10, 0, 8, 8,10,10, 0, 0, 0,11,10, 5,
+ 7, 8,10,13, 0, 7, 7,10,11, 0, 6, 7,10,11, 0, 8,
+ 8,10,10, 0, 0, 0,10,11, 9,11,10,15,13, 0,10,11,
+ 12,12, 0,11, 9,13,11, 0,11,12,13,13, 0, 0, 0,14,
+ 12, 9, 9,11,12,13, 0,10,10,12,13, 0, 9,11,11,13,
+ 0,12,11,13,13, 0, 0, 0,12,14, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 5, 7, 8,10,12, 0, 6, 7,10,11, 0, 7, 6,
+ 10,10, 0, 7, 9,10,11, 0, 0, 0,11,10, 5, 8, 7,12,
+ 11, 0, 7, 6,11, 9, 0, 7, 7,10,10, 0, 9, 8,11,10,
+ 0, 0, 0,10,10, 9,11,10,12,13, 0, 9,11,12,13, 0,
+ 11, 9,12,12, 0,11,12,12,14, 0, 0, 0,14,12, 9,10,
+ 10,13,12, 0,10, 9,13,11, 0, 9,11,12,12, 0,13,11,
+ 13,12, 0, 0, 0,12,14, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 6,10, 9,14,12, 0, 9, 8,12,11, 0, 8, 8,12,11, 0,
+ 9, 9,12,11, 0, 0, 0,11,11, 6, 9,10,12,15, 0, 8,
+ 9,11,12, 0, 8, 8,11,12, 0, 9, 9,11,12, 0, 0, 0,
+ 11,11, 9,11,10,15,12, 0,10,10,14,12, 0,11,10,15,
+ 12, 0,11,12,13,12, 0, 0, 0,13,12, 9,10,11,12,15,
+ 0,10,11,12,13, 0,10,11,12,13, 0,11,12,12,13, 0,
+ 0, 0,12,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
+ 11,11,13,14, 0,10,11,12,14, 0,10,10,13,13, 0,11,
+ 12,12,13, 0, 0, 0,13,12, 9,11,10,14,13, 0,11,10,
+ 15,12, 0,10,10,13,12, 0,12,11,13,12, 0, 0, 0,12,
+ 13,
+};
+
+static float _vq_quantthresh_res_Ac_3[] = {
+ -1.5, -0.5, 0.5, 1.5,
+};
+
+static long _vq_quantmap_res_Ac_3[] = {
+ 3, 1, 0, 2, 4,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_3 = {
+ _vq_quantthresh_res_Ac_3,
+ _vq_quantmap_res_Ac_3,
+ 5,
+ 5
+};
+
+static static_codebook _vq_book_res_Ac_3 = {
+ 4, 625,
+ _vq_lengthlist_res_Ac_3,
+ 1, -533725184, 1611661312, 3, 0,
+ _vq_quantlist_res_Ac_3,
+ NULL,
+ &_vq_auxt_res_Ac_3,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_4.vqh b/lib/books/res_Ac_4.vqh
new file mode 100644
index 00000000..143c2a35
--- /dev/null
+++ b/lib/books/res_Ac_4.vqh
@@ -0,0 +1,99 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_4_VQH_
+#define _V_res_Ac_4_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_4[] = {
+ 2,
+ 1,
+ 3,
+ 0,
+ 4,
+};
+
+static long _vq_lengthlist_res_Ac_4[] = {
+ 2, 7, 7,13,13, 0, 5, 5,10,10, 0, 5, 5,10,10, 0,
+ 6, 6, 9, 9, 0, 0, 0,10,10, 7,10, 9,15,14, 0, 8,
+ 8,12,12, 0, 9, 7,13,11, 0, 9,10,11,12, 0, 0, 0,
+ 13,11, 7, 9,10,13,15, 0, 8, 8,12,12, 0, 7, 9,11,
+ 14, 0,10, 9,12,11, 0, 0, 0,11,14,13,16,15, 0,18,
+ 0,14,14,16,15, 0,16,13, 0,14, 0,14,15,15,16, 0,
+ 0, 0,18,15,13,14,15, 0,17, 0,15,14,18,17, 0,13,
+ 15,15,18, 0,17,14,16,17, 0, 0, 0,14,17, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 5, 9, 7,16,12, 0, 7, 7,12,11,
+ 0, 7, 6,13,11, 0, 8, 8,11,10, 0, 0, 0,11,10, 5,
+ 7, 9,13,16, 0, 7, 7,11,12, 0, 6, 7,10,12, 0, 8,
+ 8,10,11, 0, 0, 0,10,11,10,14,11,18,15, 0,11,12,
+ 15,14, 0,13,10,17,13, 0,12,13,15,14, 0, 0, 0,15,
+ 13,10,11,14,16, 0, 0,11,12,13,18, 0,10,13,13,17,
+ 0,14,12,15,14, 0, 0, 0,13,16, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 5, 8, 8,14,15, 0, 6, 7,11,12, 0, 7, 6,
+ 11,11, 0, 8, 8,10,11, 0, 0, 0,11,10, 5, 8, 8,14,
+ 14, 0, 7, 6,12,11, 0, 7, 7,11,11, 0, 9, 8,11,10,
+ 0, 0, 0,10,11,10,12,12,15,16, 0,11,12,14,15, 0,
+ 12,11,16,14, 0,11,14,14,18, 0, 0, 0,18,13,10,12,
+ 13,16,18, 0,13,11,18,14, 0,11,12,14,16, 0,14,12,
+ 15,13, 0, 0, 0,13,16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 6,10, 9,17,14, 0, 8, 7,13,12, 0, 8, 8,13,12, 0,
+ 9, 8,13,11, 0, 0, 0,12,12, 6, 9,10,14,16, 0, 8,
+ 8,12,15, 0, 8, 8,12,14, 0, 8, 9,11,13, 0, 0, 0,
+ 12,12,10,13,11,18,14, 0,11,10,15,13, 0,12,10,16,
+ 13, 0,12,12,14,13, 0, 0, 0,15,13, 9,11,13,15,18,
+ 0,10,11,13,16, 0,10,11,13, 0, 0,12,12,13,14, 0,
+ 0, 0,14,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,
+ 11,12,16,17, 0,10,11,13,15, 0,11,10,14,14, 0,11,
+ 13,13,16, 0, 0, 0,15,13,10,13,11,17,16, 0,12,10,
+ 16,13, 0,10,11,14,14, 0,13,11,15,13, 0, 0, 0,13,
+ 14,
+};
+
+static float _vq_quantthresh_res_Ac_4[] = {
+ -1.5, -0.5, 0.5, 1.5,
+};
+
+static long _vq_quantmap_res_Ac_4[] = {
+ 3, 1, 0, 2, 4,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_4 = {
+ _vq_quantthresh_res_Ac_4,
+ _vq_quantmap_res_Ac_4,
+ 5,
+ 5
+};
+
+static static_codebook _vq_book_res_Ac_4 = {
+ 4, 625,
+ _vq_lengthlist_res_Ac_4,
+ 1, -533725184, 1611661312, 3, 0,
+ _vq_quantlist_res_Ac_4,
+ NULL,
+ &_vq_auxt_res_Ac_4,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_5.vqh b/lib/books/res_Ac_5.vqh
new file mode 100644
index 00000000..0c08b817
--- /dev/null
+++ b/lib/books/res_Ac_5.vqh
@@ -0,0 +1,99 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_5_VQH_
+#define _V_res_Ac_5_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_5[] = {
+ 2,
+ 1,
+ 3,
+ 0,
+ 4,
+};
+
+static long _vq_lengthlist_res_Ac_5[] = {
+ 2, 3, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 6, 6, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 4, 4, 4, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 8, 8,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 7, 6, 6, 8, 8, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,
+};
+
+static float _vq_quantthresh_res_Ac_5[] = {
+ -1.5, -0.5, 0.5, 1.5,
+};
+
+static long _vq_quantmap_res_Ac_5[] = {
+ 3, 1, 0, 2, 4,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_5 = {
+ _vq_quantthresh_res_Ac_5,
+ _vq_quantmap_res_Ac_5,
+ 5,
+ 5
+};
+
+static static_codebook _vq_book_res_Ac_5 = {
+ 4, 625,
+ _vq_lengthlist_res_Ac_5,
+ 1, -533725184, 1611661312, 3, 0,
+ _vq_quantlist_res_Ac_5,
+ NULL,
+ &_vq_auxt_res_Ac_5,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_6.vqh b/lib/books/res_Ac_6.vqh
new file mode 100644
index 00000000..3f4d7103
--- /dev/null
+++ b/lib/books/res_Ac_6.vqh
@@ -0,0 +1,70 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_6_VQH_
+#define _V_res_Ac_6_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_6[] = {
+ 4,
+ 3,
+ 5,
+ 2,
+ 6,
+ 1,
+ 7,
+ 0,
+ 8,
+};
+
+static long _vq_lengthlist_res_Ac_6[] = {
+ 2, 4, 4, 7, 7, 9, 9,10,10, 0, 4, 4, 6, 6, 8, 8,
+ 10,10, 0, 4, 4, 6, 6, 8, 8,10,10, 0, 5, 4, 6, 6,
+ 8, 8,10,10, 0, 0, 0, 6, 6, 8, 8,10,10, 0, 0, 0,
+ 6, 6, 9, 9,10,10, 0, 0, 0, 6, 6, 8, 8,10,10, 0,
+ 0, 0, 8, 8, 9, 9,11,11, 0, 0, 0, 0, 0, 9, 9,11,
+ 11,
+};
+
+static float _vq_quantthresh_res_Ac_6[] = {
+ -3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5,
+};
+
+static long _vq_quantmap_res_Ac_6[] = {
+ 7, 5, 3, 1, 0, 2, 4, 6,
+ 8,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_6 = {
+ _vq_quantthresh_res_Ac_6,
+ _vq_quantmap_res_Ac_6,
+ 9,
+ 9
+};
+
+static static_codebook _vq_book_res_Ac_6 = {
+ 2, 81,
+ _vq_lengthlist_res_Ac_6,
+ 1, -531628032, 1611661312, 4, 0,
+ _vq_quantlist_res_Ac_6,
+ NULL,
+ &_vq_auxt_res_Ac_6,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_7.vqh b/lib/books/res_Ac_7.vqh
new file mode 100644
index 00000000..b66aea7d
--- /dev/null
+++ b/lib/books/res_Ac_7.vqh
@@ -0,0 +1,65 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_7_VQH_
+#define _V_res_Ac_7_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_7[] = {
+ 3,
+ 2,
+ 4,
+ 1,
+ 5,
+ 0,
+ 6,
+};
+
+static long _vq_lengthlist_res_Ac_7[] = {
+ 1, 4, 4, 7, 7, 9, 9, 5, 5, 4, 8, 7, 9,10, 5, 4,
+ 4, 7, 7, 9, 9, 0, 8, 7, 9, 9,11,11, 0, 8, 8, 8,
+ 8,10,10, 0,13,12,10,10,12,13, 0,13,13,10,10,11,
+ 11,
+};
+
+static float _vq_quantthresh_res_Ac_7[] = {
+ -12.5, -7.5, -2.5, 2.5, 7.5, 12.5,
+};
+
+static long _vq_quantmap_res_Ac_7[] = {
+ 5, 3, 1, 0, 2, 4, 6,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_7 = {
+ _vq_quantthresh_res_Ac_7,
+ _vq_quantmap_res_Ac_7,
+ 7,
+ 7
+};
+
+static static_codebook _vq_book_res_Ac_7 = {
+ 2, 49,
+ _vq_lengthlist_res_Ac_7,
+ 1, -528613376, 1616117760, 3, 0,
+ _vq_quantlist_res_Ac_7,
+ NULL,
+ &_vq_auxt_res_Ac_7,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_7a.vqh b/lib/books/res_Ac_7a.vqh
new file mode 100644
index 00000000..a3960895
--- /dev/null
+++ b/lib/books/res_Ac_7a.vqh
@@ -0,0 +1,99 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_7a_VQH_
+#define _V_res_Ac_7a_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_7a[] = {
+ 2,
+ 1,
+ 3,
+ 0,
+ 4,
+};
+
+static long _vq_lengthlist_res_Ac_7a[] = {
+ 3, 6, 6, 8, 8,11, 6, 6, 8, 8,11, 6, 6, 8, 8,10,
+ 8, 8, 8, 8,11,11,11, 8, 9, 6, 8, 7, 9, 9,11, 8,
+ 8,10, 9,11, 8, 8,10, 9,11, 9,10,10, 9,11,11,11,
+ 10, 9, 6, 7, 8, 9,10,11, 8, 8, 9,10,11, 8, 8, 9,
+ 10,11,10,10,10, 9,11,11,11, 9,10, 8, 9, 9,10,10,
+ 12,10,10,10,10,12,10,10,10,10,12,10,10,10,11,12,
+ 12,12,10,10, 9, 9, 9,10,10,12,10,10,10,10,12,10,
+ 10,10,10,11,10,10,10,10,12,12,12,10,10,10,11,11,
+ 12,12,13,11,12,12,12,13,11,11,12,12,13,12,12,12,
+ 12,13,13,13,12,12, 6, 8, 8,10,10,11, 8, 8,10,10,
+ 11, 8, 8, 9,10,11, 9, 9,10, 9,11,11,11,10, 9, 6,
+ 8, 8,10,10,11, 8, 8,10,10,11, 8, 8, 9,10,11, 9,
+ 9, 9, 9,11,11,11, 9,10, 8, 9, 9,10,10,12,10,10,
+ 10,10,11,10, 9,10,10,12,10,10,10,10,11,11,12,10,
+ 10, 8, 9, 9,10,10,12,10,10,11,10,12, 9,10,10,10,
+ 12,10,10,10,10,11,12,11,10,10,11,11,11,12,12,13,
+ 11,11,11,12,13,11,11,12,11,14,12,12,12,12,13,13,
+ 12,11,12, 6, 8, 8,10,10,11, 8, 8, 9, 9,11, 8, 8,
+ 9,10,11, 9, 9, 9, 9,11,11,11,10, 9, 6, 8, 8,10,
+ 10,11, 8, 8,10,10,11, 8, 8, 9,10,11, 9, 9,10, 9,
+ 11,11,11, 9, 9, 8,10, 9,10,10,11, 9, 9,10,10,11,
+ 10, 9,10,10,11,10,10,10,10,12,11,11,10,10, 8, 9,
+ 10,10,10,12, 9, 9,10,10,12, 9,10,10,10,11,10,10,
+ 10,10,12,11,12,10,10,11,11,11,12,12,13,11,12,12,
+ 12,13,11,11,12,11,13,12,12,11,11,13,13,13,11,11,
+ 8,10,10,11,10,12, 9, 9,11,10,12, 9, 9,10,10,12,
+ 10, 9,10,10,11,12,12,10,10, 8, 9,10,11,10,12, 9,
+ 9,10,10,11, 9, 9,10,10,12, 9,10,10,10,12,12,12,
+ 10,10, 8,10,10,10,10,11, 9, 9,10,10,11, 9, 9,10,
+ 10,12,10,10,10,10,11,11,11,10,10, 8, 9,10,10,10,
+ 11, 9,10,10,10,11, 9, 9,10,10,12,10,10,10,10,12,
+ 12,11,10,10,11,11,11,12,12,14,11,11,12,11,13,11,
+ 12,12,12,13,12,12,12,12,12,12,13,12,11,11,11,12,
+ 12,12,12,11,11,12,12,13,11,11,11,12,12,12,12,12,
+ 11,12,13,13,11,12,11,12,11,12,12,13,11,11,12,12,
+ 13,12,11,12,12,12,12,12,12,12,13,13,13,12,12, 8,
+ 10,10,10,10,11, 9,10,10,10,12, 9, 9,10,10,12,10,
+ 10,10,10,12,11,11,10,10, 8,10,10,10,10,11, 9, 9,
+ 10,10,12, 9, 9,10,10,11,10,10,10,10,11,12,11,10,
+ 10,
+};
+
+static float _vq_quantthresh_res_Ac_7a[] = {
+ -1.5, -0.5, 0.5, 1.5,
+};
+
+static long _vq_quantmap_res_Ac_7a[] = {
+ 3, 1, 0, 2, 4,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_7a = {
+ _vq_quantthresh_res_Ac_7a,
+ _vq_quantmap_res_Ac_7a,
+ 5,
+ 5
+};
+
+static static_codebook _vq_book_res_Ac_7a = {
+ 4, 625,
+ _vq_lengthlist_res_Ac_7a,
+ 1, -533725184, 1611661312, 3, 0,
+ _vq_quantlist_res_Ac_7a,
+ NULL,
+ &_vq_auxt_res_Ac_7a,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_8.vqh b/lib/books/res_Ac_8.vqh
new file mode 100644
index 00000000..79728c62
--- /dev/null
+++ b/lib/books/res_Ac_8.vqh
@@ -0,0 +1,80 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_8_VQH_
+#define _V_res_Ac_8_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_8[] = {
+ 6,
+ 5,
+ 7,
+ 4,
+ 8,
+ 3,
+ 9,
+ 2,
+ 10,
+ 1,
+ 11,
+ 0,
+ 12,
+};
+
+static long _vq_lengthlist_res_Ac_8[] = {
+ 1, 3, 4, 6, 6, 8, 8, 9, 9,11,10,12,11, 6, 5, 5,
+ 7, 7, 9, 9,10,10,12,12,13,13, 6, 5, 5, 7, 7, 9,
+ 9,10,10,11,11,13,13, 0, 7, 8, 8, 8,10, 9,12,11,
+ 13,14,13,13, 0, 7, 7, 8, 8, 9, 9,11,12,12,13,13,
+ 13, 0,13,14,10,10,10,11,13,12,14,13,16,15, 0,14,
+ 14, 9,10,11,11,12,12,13,13,13,14, 0, 0, 0,12,12,
+ 12,11,13,13,14,14,16,15, 0, 0, 0,12,12,12,12,13,
+ 13,14,14,16,16, 0, 0, 0,16, 0,12,13,13,13,14,16,
+ 16,16, 0, 0, 0, 0,15,14,13,14,13,15,13,15,15, 0,
+ 0, 0, 0, 0,16,16,14,15,16,14, 0,16, 0, 0, 0, 0,
+ 0,16,16,15,15,16,16, 0,15,
+};
+
+static float _vq_quantthresh_res_Ac_8[] = {
+ -71.5, -58.5, -45.5, -32.5, -19.5, -6.5, 6.5, 19.5,
+ 32.5, 45.5, 58.5, 71.5,
+};
+
+static long _vq_quantmap_res_Ac_8[] = {
+ 11, 9, 7, 5, 3, 1, 0, 2,
+ 4, 6, 8, 10, 12,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_8 = {
+ _vq_quantthresh_res_Ac_8,
+ _vq_quantmap_res_Ac_8,
+ 13,
+ 13
+};
+
+static static_codebook _vq_book_res_Ac_8 = {
+ 2, 169,
+ _vq_lengthlist_res_Ac_8,
+ 1, -523010048, 1618608128, 4, 0,
+ _vq_quantlist_res_Ac_8,
+ NULL,
+ &_vq_auxt_res_Ac_8,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_8a.vqh b/lib/books/res_Ac_8a.vqh
new file mode 100644
index 00000000..236c2c09
--- /dev/null
+++ b/lib/books/res_Ac_8a.vqh
@@ -0,0 +1,80 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_8a_VQH_
+#define _V_res_Ac_8a_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_8a[] = {
+ 6,
+ 5,
+ 7,
+ 4,
+ 8,
+ 3,
+ 9,
+ 2,
+ 10,
+ 1,
+ 11,
+ 0,
+ 12,
+};
+
+static long _vq_lengthlist_res_Ac_8a[] = {
+ 4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 6, 6,
+ 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 9, 6, 6, 6, 6, 7,
+ 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 7, 7, 7, 7, 7,
+ 8, 7, 7, 7, 9, 9, 9, 7, 7, 7, 7, 7, 8, 8, 8, 7,
+ 8, 9, 9, 9, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9,
+ 9, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 8, 8, 8,
+ 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8,
+ 8, 8, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 9,
+ 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
+ 9, 9, 9, 8, 8, 8, 8, 8, 8,
+};
+
+static float _vq_quantthresh_res_Ac_8a[] = {
+ -5.5, -4.5, -3.5, -2.5, -1.5, -0.5, 0.5, 1.5,
+ 2.5, 3.5, 4.5, 5.5,
+};
+
+static long _vq_quantmap_res_Ac_8a[] = {
+ 11, 9, 7, 5, 3, 1, 0, 2,
+ 4, 6, 8, 10, 12,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_8a = {
+ _vq_quantthresh_res_Ac_8a,
+ _vq_quantmap_res_Ac_8a,
+ 13,
+ 13
+};
+
+static static_codebook _vq_book_res_Ac_8a = {
+ 2, 169,
+ _vq_lengthlist_res_Ac_8a,
+ 1, -531103744, 1611661312, 4, 0,
+ _vq_quantlist_res_Ac_8a,
+ NULL,
+ &_vq_auxt_res_Ac_8a,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_9.vqh b/lib/books/res_Ac_9.vqh
new file mode 100644
index 00000000..dd825698
--- /dev/null
+++ b/lib/books/res_Ac_9.vqh
@@ -0,0 +1,65 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_9_VQH_
+#define _V_res_Ac_9_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_9[] = {
+ 3,
+ 2,
+ 4,
+ 1,
+ 5,
+ 0,
+ 6,
+};
+
+static long _vq_lengthlist_res_Ac_9[] = {
+ 1, 4, 3, 9,10,11,11, 3,10, 5,11,11,11,11, 4, 4,
+ 9,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
+ 11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,
+ 10,
+};
+
+static float _vq_quantthresh_res_Ac_9[] = {
+ -422.5, -253.5, -84.5, 84.5, 253.5, 422.5,
+};
+
+static long _vq_quantmap_res_Ac_9[] = {
+ 5, 3, 1, 0, 2, 4, 6,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_9 = {
+ _vq_quantthresh_res_Ac_9,
+ _vq_quantmap_res_Ac_9,
+ 7,
+ 7
+};
+
+static static_codebook _vq_book_res_Ac_9 = {
+ 2, 49,
+ _vq_lengthlist_res_Ac_9,
+ 1, -518017024, 1626677248, 3, 0,
+ _vq_quantlist_res_Ac_9,
+ NULL,
+ &_vq_auxt_res_Ac_9,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_9a.vqh b/lib/books/res_Ac_9a.vqh
new file mode 100644
index 00000000..f7218c0b
--- /dev/null
+++ b/lib/books/res_Ac_9a.vqh
@@ -0,0 +1,80 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_9a_VQH_
+#define _V_res_Ac_9a_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_9a[] = {
+ 6,
+ 5,
+ 7,
+ 4,
+ 8,
+ 3,
+ 9,
+ 2,
+ 10,
+ 1,
+ 11,
+ 0,
+ 12,
+};
+
+static long _vq_lengthlist_res_Ac_9a[] = {
+ 2, 3, 3, 7, 7, 8, 8, 9, 9, 8, 9, 7, 7, 4, 5, 4,
+ 8, 8, 9, 9,10,10,10,10, 8, 8, 6, 5, 6, 9, 9,10,
+ 9,10, 9,10,10, 9, 8,12, 5, 5, 7, 6,10,11,13,10,
+ 9,11, 8, 9,13, 9, 7,10, 9,10,11,11,11,10,10, 9,
+ 8,13, 9, 9, 7, 6,11,10,11,11, 9,11, 9,12,12,12,
+ 9,10, 9,10,12,12,11,12,10,11, 8,13,12,13,13, 9,
+ 11,10,13,13,10,13,12,12,13,13,13,11,11,12,12,12,
+ 12,13,10,12, 9,12,13,12,13,13,12,12,11,13,11,13,
+ 13,13,13,12,13,13,13,11,13,12,12,11,11,12,12,13,
+ 13,13,13,13,12,13,11,13,13,11,12,11,13,13,13,12,
+ 13,13,12,12,11,12,11,11,12,
+};
+
+static float _vq_quantthresh_res_Ac_9a[] = {
+ -71.5, -58.5, -45.5, -32.5, -19.5, -6.5, 6.5, 19.5,
+ 32.5, 45.5, 58.5, 71.5,
+};
+
+static long _vq_quantmap_res_Ac_9a[] = {
+ 11, 9, 7, 5, 3, 1, 0, 2,
+ 4, 6, 8, 10, 12,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_9a = {
+ _vq_quantthresh_res_Ac_9a,
+ _vq_quantmap_res_Ac_9a,
+ 13,
+ 13
+};
+
+static static_codebook _vq_book_res_Ac_9a = {
+ 2, 169,
+ _vq_lengthlist_res_Ac_9a,
+ 1, -523010048, 1618608128, 4, 0,
+ _vq_quantlist_res_Ac_9a,
+ NULL,
+ &_vq_auxt_res_Ac_9a,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/books/res_Ac_9b.vqh b/lib/books/res_Ac_9b.vqh
new file mode 100644
index 00000000..d048497a
--- /dev/null
+++ b/lib/books/res_Ac_9b.vqh
@@ -0,0 +1,80 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
+ * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company, http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: static codebook autogenerated by vq/somethingorother
+
+ ********************************************************************/
+
+#ifndef _V_res_Ac_9b_VQH_
+#define _V_res_Ac_9b_VQH_
+#include "codebook.h"
+
+static long _vq_quantlist_res_Ac_9b[] = {
+ 6,
+ 5,
+ 7,
+ 4,
+ 8,
+ 3,
+ 9,
+ 2,
+ 10,
+ 1,
+ 11,
+ 0,
+ 12,
+};
+
+static long _vq_lengthlist_res_Ac_9b[] = {
+ 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 9, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 9, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 9, 7, 8, 7, 8, 7, 8, 7, 8,
+ 7, 7, 7, 7, 9, 8, 9, 8, 8, 8, 8, 7, 8, 7, 7, 7,
+ 7, 8, 8, 8, 8, 8, 7, 8, 7, 8, 7, 7, 7, 7, 9, 8,
+ 9, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 8, 9, 8, 8, 8,
+ 8, 8, 7, 8, 7, 7, 7, 7, 9, 9, 8, 9, 8, 8, 8, 8,
+ 8, 8, 7, 7, 7, 8, 9, 8, 8, 8, 8, 8, 8, 7, 7, 7,
+ 7, 7, 8, 9, 8, 8, 9, 8, 8, 7, 7, 8, 7, 7, 7, 8,
+ 9, 8, 8, 8, 7, 8, 8, 7, 7, 8, 8, 7, 9, 8, 9, 9,
+ 8, 8, 8, 8, 7, 8, 7, 7, 7,
+};
+
+static float _vq_quantthresh_res_Ac_9b[] = {
+ -5.5, -4.5, -3.5, -2.5, -1.5, -0.5, 0.5, 1.5,
+ 2.5, 3.5, 4.5, 5.5,
+};
+
+static long _vq_quantmap_res_Ac_9b[] = {
+ 11, 9, 7, 5, 3, 1, 0, 2,
+ 4, 6, 8, 10, 12,
+};
+
+static encode_aux_threshmatch _vq_auxt_res_Ac_9b = {
+ _vq_quantthresh_res_Ac_9b,
+ _vq_quantmap_res_Ac_9b,
+ 13,
+ 13
+};
+
+static static_codebook _vq_book_res_Ac_9b = {
+ 2, 169,
+ _vq_lengthlist_res_Ac_9b,
+ 1, -531103744, 1611661312, 4, 0,
+ _vq_quantlist_res_Ac_9b,
+ NULL,
+ &_vq_auxt_res_Ac_9b,
+ NULL,
+ 0
+};
+
+
+#endif
diff --git a/lib/codec_internal.h b/lib/codec_internal.h
index 7894d8bb..5f84f1a5 100644
--- a/lib/codec_internal.h
+++ b/lib/codec_internal.h
@@ -10,7 +10,7 @@
********************************************************************
function: libvorbis codec headers
- last mod: $Id: codec_internal.h,v 1.9.4.1 2001/10/09 04:34:45 xiphmont Exp $
+ last mod: $Id: codec_internal.h,v 1.9.4.2 2001/10/11 15:41:44 xiphmont Exp $
********************************************************************/
@@ -134,8 +134,8 @@ typedef struct codec_setup_info {
double bitrate_absolute_min;
double bitrate_queue_max;
double bitrate_queue_min;
- double bitrate_queue_upperavg;
double bitrate_queue_loweravg;
+ double bitrate_queue_upperavg;
int passlimit[32]; /* iteration limit per couple/quant pass */
int coupling_passes;
diff --git a/lib/info.c b/lib/info.c
new file mode 100644
index 00000000..8abbe9a9
--- /dev/null
+++ b/lib/info.c
@@ -0,0 +1,588 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company http://www.xiph.org/ *
+
+ ********************************************************************
+
+ function: maintain the info structure, info <-> header packets
+ last mod: $Id: info.c,v 1.46.2.1 2001/10/11 15:41:44 xiphmont Exp $
+
+ ********************************************************************/
+
+/* general handling of the header and the vorbis_info structure (and
+ substructures) */
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <ogg/ogg.h>
+#include "vorbis/codec.h"
+#include "codec_internal.h"
+#include "codebook.h"
+#include "registry.h"
+#include "window.h"
+#include "psy.h"
+#include "misc.h"
+#include "os.h"
+
+/* helpers */
+static int ilog2(unsigned int v){
+ int ret=0;
+ while(v>1){
+ ret++;
+ v>>=1;
+ }
+ return(ret);
+}
+
+static void _v_writestring(oggpack_buffer *o,char *s){
+ while(*s){
+ oggpack_write(o,*s++,8);
+ }
+}
+
+static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
+ while(bytes--){
+ *buf++=oggpack_read(o,8);
+ }
+}
+
+void vorbis_comment_init(vorbis_comment *vc){
+ memset(vc,0,sizeof(*vc));
+}
+
+void vorbis_comment_add(vorbis_comment *vc,char *comment){
+ vc->user_comments=_ogg_realloc(vc->user_comments,
+ (vc->comments+2)*sizeof(*vc->user_comments));
+ vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
+ (vc->comments+2)*sizeof(*vc->comment_lengths));
+ vc->user_comments[vc->comments]=strdup(comment);
+ vc->comment_lengths[vc->comments]=strlen(comment);
+ vc->comments++;
+ vc->user_comments[vc->comments]=NULL;
+}
+
+void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents){
+ char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
+ strcpy(comment, tag);
+ strcat(comment, "=");
+ strcat(comment, contents);
+ vorbis_comment_add(vc, comment);
+}
+
+/* This is more or less the same as strncasecmp - but that doesn't exist
+ * everywhere, and this is a fairly trivial function, so we include it */
+static int tagcompare(const char *s1, const char *s2, int n){
+ int c=0;
+ while(c < n){
+ if(toupper(s1[c]) != toupper(s2[c]))
+ return !0;
+ c++;
+ }
+ return 0;
+}
+
+char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
+ long i;
+ int found = 0;
+ int taglen = strlen(tag)+1; /* +1 for the = we append */
+ char *fulltag = alloca(taglen+ 1);
+
+ strcpy(fulltag, tag);
+ strcat(fulltag, "=");
+
+ for(i=0;i<vc->comments;i++){
+ if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
+ if(count == found)
+ /* We return a pointer to the data, not a copy */
+ return vc->user_comments[i] + taglen;
+ else
+ found++;
+ }
+ }
+ return NULL; /* didn't find anything */
+}
+
+int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
+ int i,count=0;
+ int taglen = strlen(tag)+1; /* +1 for the = we append */
+ char *fulltag = alloca(taglen+1);
+ strcpy(fulltag,tag);
+ strcat(fulltag, "=");
+
+ for(i=0;i<vc->comments;i++){
+ if(!tagcompare(vc->user_comments[i], fulltag, taglen))
+ count++;
+ }
+
+ return count;
+}
+
+void vorbis_comment_clear(vorbis_comment *vc){
+ if(vc){
+ long i;
+ for(i=0;i<vc->comments;i++)
+ if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
+ if(vc->user_comments)_ogg_free(vc->user_comments);
+ if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
+ if(vc->vendor)_ogg_free(vc->vendor);
+ }
+ memset(vc,0,sizeof(*vc));
+}
+
+/* used by synthesis, which has a full, alloced vi */
+void vorbis_info_init(vorbis_info *vi){
+ memset(vi,0,sizeof(*vi));
+ vi->codec_setup=_ogg_calloc(1,sizeof(codec_setup_info));
+}
+
+void vorbis_info_clear(vorbis_info *vi){
+ codec_setup_info *ci=vi->codec_setup;
+ int i;
+
+ if(ci){
+
+ for(i=0;i<ci->modes;i++)
+ if(ci->mode_param[i])_ogg_free(ci->mode_param[i]);
+
+ for(i=0;i<ci->maps;i++) /* unpack does the range checking */
+ _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
+
+ for(i=0;i<ci->times;i++) /* unpack does the range checking */
+ _time_P[ci->time_type[i]]->free_info(ci->time_param[i]);
+
+ for(i=0;i<ci->floors;i++) /* unpack does the range checking */
+ _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
+
+ for(i=0;i<ci->residues;i++) /* unpack does the range checking */
+ _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
+
+ for(i=0;i<ci->books;i++){
+ if(ci->book_param[i]){
+ /* knows if the book was not alloced */
+ vorbis_staticbook_destroy(ci->book_param[i]);
+ }
+ }
+
+ for(i=0;i<ci->psys;i++)
+ _vi_psy_free(ci->psy_param[i]);
+
+ _ogg_free(ci);
+ }
+
+ memset(vi,0,sizeof(*vi));
+}
+
+/* Header packing/unpacking ********************************************/
+
+static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
+ codec_setup_info *ci=vi->codec_setup;
+ if(!ci)return(OV_EFAULT);
+
+ vi->version=oggpack_read(opb,32);
+ if(vi->version!=0)return(OV_EVERSION);
+
+ vi->channels=oggpack_read(opb,8);
+ vi->rate=oggpack_read(opb,32);
+
+ vi->bitrate_upper=oggpack_read(opb,32);
+ vi->bitrate_nominal=oggpack_read(opb,32);
+ vi->bitrate_lower=oggpack_read(opb,32);
+
+ ci->blocksizes[0]=1<<oggpack_read(opb,4);
+ ci->blocksizes[1]=1<<oggpack_read(opb,4);
+
+ if(vi->rate<1)goto err_out;
+ if(vi->channels<1)goto err_out;
+ if(ci->blocksizes[0]<8)goto err_out;
+ if(ci->blocksizes[1]<ci->blocksizes[0])goto err_out;
+
+ if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+
+ return(0);
+ err_out:
+ vorbis_info_clear(vi);
+ return(OV_EBADHEADER);
+}
+
+static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
+ int i;
+ int vendorlen=oggpack_read(opb,32);
+ if(vendorlen<0)goto err_out;
+ vc->vendor=_ogg_calloc(vendorlen+1,1);
+ _v_readstring(opb,vc->vendor,vendorlen);
+ vc->comments=oggpack_read(opb,32);
+ if(vc->comments<0)goto err_out;
+ vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
+ vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths));
+
+ for(i=0;i<vc->comments;i++){
+ int len=oggpack_read(opb,32);
+ if(len<0)goto err_out;
+ vc->comment_lengths[i]=len;
+ vc->user_comments[i]=_ogg_calloc(len+1,1);
+ _v_readstring(opb,vc->user_comments[i],len);
+ }
+ if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+
+ return(0);
+ err_out:
+ vorbis_comment_clear(vc);
+ return(OV_EBADHEADER);
+}
+
+/* all of the real encoding details are here. The modes, books,
+ everything */
+static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
+ codec_setup_info *ci=vi->codec_setup;
+ int i;
+ if(!ci)return(OV_EFAULT);
+
+ /* codebooks */
+ ci->books=oggpack_read(opb,8)+1;
+ /*ci->book_param=_ogg_calloc(ci->books,sizeof(*ci->book_param));*/
+ for(i=0;i<ci->books;i++){
+ ci->book_param[i]=_ogg_calloc(1,sizeof(*ci->book_param[i]));
+ if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out;
+ }
+
+ /* time backend settings */
+ ci->times=oggpack_read(opb,6)+1;
+ /*ci->time_type=_ogg_malloc(ci->times*sizeof(*ci->time_type));*/
+ /*ci->time_param=_ogg_calloc(ci->times,sizeof(void *));*/
+ for(i=0;i<ci->times;i++){
+ ci->time_type[i]=oggpack_read(opb,16);
+ if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out;
+ ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb);
+ if(!ci->time_param[i])goto err_out;
+ }
+
+ /* floor backend settings */
+ ci->floors=oggpack_read(opb,6)+1;
+ /*ci->floor_type=_ogg_malloc(ci->floors*sizeof(*ci->floor_type));*/
+ /*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/
+ for(i=0;i<ci->floors;i++){
+ ci->floor_type[i]=oggpack_read(opb,16);
+ if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
+ ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb);
+ if(!ci->floor_param[i])goto err_out;
+ }
+
+ /* residue backend settings */
+ ci->residues=oggpack_read(opb,6)+1;
+ /*ci->residue_type=_ogg_malloc(ci->residues*sizeof(*ci->residue_type));*/
+ /*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/
+ for(i=0;i<ci->residues;i++){
+ ci->residue_type[i]=oggpack_read(opb,16);
+ if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out;
+ ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb);
+ if(!ci->residue_param[i])goto err_out;
+ }
+
+ /* map backend settings */
+ ci->maps=oggpack_read(opb,6)+1;
+ /*ci->map_type=_ogg_malloc(ci->maps*sizeof(*ci->map_type));*/
+ /*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/
+ for(i=0;i<ci->maps;i++){
+ ci->map_type[i]=oggpack_read(opb,16);
+ if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out;
+ ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb);
+ if(!ci->map_param[i])goto err_out;
+ }
+
+ /* mode settings */
+ ci->modes=oggpack_read(opb,6)+1;
+ /*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/
+ for(i=0;i<ci->modes;i++){
+ ci->mode_param[i]=_ogg_calloc(1,sizeof(*ci->mode_param[i]));
+ ci->mode_param[i]->blockflag=oggpack_read(opb,1);
+ ci->mode_param[i]->windowtype=oggpack_read(opb,16);
+ ci->mode_param[i]->transformtype=oggpack_read(opb,16);
+ ci->mode_param[i]->mapping=oggpack_read(opb,8);
+
+ if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out;
+ if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out;
+ if(ci->mode_param[i]->mapping>=ci->maps)goto err_out;
+ }
+
+ if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
+
+ return(0);
+ err_out:
+ vorbis_info_clear(vi);
+ return(OV_EBADHEADER);
+}
+
+/* The Vorbis header is in three packets; the initial small packet in
+ the first page that identifies basic parameters, a second packet
+ with bitstream comments and a third packet that holds the
+ codebook. */
+
+int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){
+ oggpack_buffer opb;
+
+ if(op){
+ oggpack_readinit(&opb,op->packet,op->bytes);
+
+ /* Which of the three types of header is this? */
+ /* Also verify header-ness, vorbis */
+ {
+ char buffer[6];
+ int packtype=oggpack_read(&opb,8);
+ memset(buffer,0,6);
+ _v_readstring(&opb,buffer,6);
+ if(memcmp(buffer,"vorbis",6)){
+ /* not a vorbis header */
+ return(OV_ENOTVORBIS);
+ }
+ switch(packtype){
+ case 0x01: /* least significant *bit* is read first */
+ if(!op->b_o_s){
+ /* Not the initial packet */
+ return(OV_EBADHEADER);
+ }
+ if(vi->rate!=0){
+ /* previously initialized info header */
+ return(OV_EBADHEADER);
+ }
+
+ return(_vorbis_unpack_info(vi,&opb));
+
+ case 0x03: /* least significant *bit* is read first */
+ if(vi->rate==0){
+ /* um... we didn't get the initial header */
+ return(OV_EBADHEADER);
+ }
+
+ return(_vorbis_unpack_comment(vc,&opb));
+
+ case 0x05: /* least significant *bit* is read first */
+ if(vi->rate==0 || vc->vendor==NULL){
+ /* um... we didn;t get the initial header or comments yet */
+ return(OV_EBADHEADER);
+ }
+
+ return(_vorbis_unpack_books(vi,&opb));
+
+ default:
+ /* Not a valid vorbis header type */
+ return(OV_EBADHEADER);
+ break;
+ }
+ }
+ }
+ return(OV_EBADHEADER);
+}
+
+/* pack side **********************************************************/
+
+static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
+ codec_setup_info *ci=vi->codec_setup;
+ if(!ci)return(OV_EFAULT);
+
+ /* preamble */
+ oggpack_write(opb,0x01,8);
+ _v_writestring(opb,"vorbis");
+
+ /* basic information about the stream */
+ oggpack_write(opb,0x00,32);
+ oggpack_write(opb,vi->channels,8);
+ oggpack_write(opb,vi->rate,32);
+
+ oggpack_write(opb,vi->bitrate_upper,32);
+ oggpack_write(opb,vi->bitrate_nominal,32);
+ oggpack_write(opb,vi->bitrate_lower,32);
+
+ oggpack_write(opb,ilog2(ci->blocksizes[0]),4);
+ oggpack_write(opb,ilog2(ci->blocksizes[1]),4);
+ oggpack_write(opb,1,1);
+
+ return(0);
+}
+
+static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
+ char temp[]="Xiphophorus libVorbis I 20011009";
+
+ /* preamble */
+ oggpack_write(opb,0x03,8);
+ _v_writestring(opb,"vorbis");
+
+ /* vendor */
+ oggpack_write(opb,strlen(temp),32);
+ _v_writestring(opb,temp);
+
+ /* comments */
+
+ oggpack_write(opb,vc->comments,32);
+ if(vc->comments){
+ int i;
+ for(i=0;i<vc->comments;i++){
+ if(vc->user_comments[i]){
+ oggpack_write(opb,vc->comment_lengths[i],32);
+ _v_writestring(opb,vc->user_comments[i]);
+ }else{
+ oggpack_write(opb,0,32);
+ }
+ }
+ }
+ oggpack_write(opb,1,1);
+
+ return(0);
+}
+
+static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){
+ codec_setup_info *ci=vi->codec_setup;
+ int i;
+ if(!ci)return(OV_EFAULT);
+
+ oggpack_write(opb,0x05,8);
+ _v_writestring(opb,"vorbis");
+
+ /* books */
+ oggpack_write(opb,ci->books-1,8);
+ for(i=0;i<ci->books;i++)
+ if(vorbis_staticbook_pack(ci->book_param[i],opb))goto err_out;
+
+ /* times */
+ oggpack_write(opb,ci->times-1,6);
+ for(i=0;i<ci->times;i++){
+ oggpack_write(opb,ci->time_type[i],16);
+ _time_P[ci->time_type[i]]->pack(ci->time_param[i],opb);
+ }
+
+ /* floors */
+ oggpack_write(opb,ci->floors-1,6);
+ for(i=0;i<ci->floors;i++){
+ oggpack_write(opb,ci->floor_type[i],16);
+ _floor_P[ci->floor_type[i]]->pack(ci->floor_param[i],opb);
+ }
+
+ /* residues */
+ oggpack_write(opb,ci->residues-1,6);
+ for(i=0;i<ci->residues;i++){
+ oggpack_write(opb,ci->residue_type[i],16);
+ _residue_P[ci->residue_type[i]]->pack(ci->residue_param[i],opb);
+ }
+
+ /* maps */
+ oggpack_write(opb,ci->maps-1,6);
+ for(i=0;i<ci->maps;i++){
+ oggpack_write(opb,ci->map_type[i],16);
+ _mapping_P[ci->map_type[i]]->pack(vi,ci->map_param[i],opb);
+ }
+
+ /* modes */
+ oggpack_write(opb,ci->modes-1,6);
+ for(i=0;i<ci->modes;i++){
+ oggpack_write(opb,ci->mode_param[i]->blockflag,1);
+ oggpack_write(opb,ci->mode_param[i]->windowtype,16);
+ oggpack_write(opb,ci->mode_param[i]->transformtype,16);
+ oggpack_write(opb,ci->mode_param[i]->mapping,8);
+ }
+ oggpack_write(opb,1,1);
+
+ return(0);
+err_out:
+ return(-1);
+}
+
+int vorbis_commentheader_out(vorbis_comment *vc,
+ ogg_packet *op){
+
+ oggpack_buffer opb;
+
+ oggpack_writeinit(&opb);
+ if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
+
+ op->packet = _ogg_malloc(oggpack_bytes(&opb));
+ memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
+
+ op->bytes=oggpack_bytes(&opb);
+ op->b_o_s=0;
+ op->e_o_s=0;
+ op->granulepos=0;
+
+ return 0;
+}
+
+int vorbis_analysis_headerout(vorbis_dsp_state *v,
+ vorbis_comment *vc,
+ ogg_packet *op,
+ ogg_packet *op_comm,
+ ogg_packet *op_code){
+ int ret=OV_EIMPL;
+ vorbis_info *vi=v->vi;
+ oggpack_buffer opb;
+ backend_lookup_state *b=v->backend_state;
+
+ if(!b){
+ ret=OV_EFAULT;
+ goto err_out;
+ }
+
+ /* first header packet **********************************************/
+
+ oggpack_writeinit(&opb);
+ if(_vorbis_pack_info(&opb,vi))goto err_out;
+
+ /* build the packet */
+ if(b->header)_ogg_free(b->header);
+ b->header=_ogg_malloc(oggpack_bytes(&opb));
+ memcpy(b->header,opb.buffer,oggpack_bytes(&opb));
+ op->packet=b->header;
+ op->bytes=oggpack_bytes(&opb);
+ op->b_o_s=1;
+ op->e_o_s=0;
+ op->granulepos=0;
+
+ /* second header packet (comments) **********************************/
+
+ oggpack_reset(&opb);
+ if(_vorbis_pack_comment(&opb,vc))goto err_out;
+
+ if(b->header1)_ogg_free(b->header1);
+ b->header1=_ogg_malloc(oggpack_bytes(&opb));
+ memcpy(b->header1,opb.buffer,oggpack_bytes(&opb));
+ op_comm->packet=b->header1;
+ op_comm->bytes=oggpack_bytes(&opb);
+ op_comm->b_o_s=0;
+ op_comm->e_o_s=0;
+ op_comm->granulepos=0;
+
+ /* third header packet (modes/codebooks) ****************************/
+
+ oggpack_reset(&opb);
+ if(_vorbis_pack_books(&opb,vi))goto err_out;
+
+ if(b->header2)_ogg_free(b->header2);
+ b->header2=_ogg_malloc(oggpack_bytes(&opb));
+ memcpy(b->header2,opb.buffer,oggpack_bytes(&opb));
+ op_code->packet=b->header2;
+ op_code->bytes=oggpack_bytes(&opb);
+ op_code->b_o_s=0;
+ op_code->e_o_s=0;
+ op_code->granulepos=0;
+
+ oggpack_writeclear(&opb);
+ return(0);
+ err_out:
+ oggpack_writeclear(&opb);
+ memset(op,0,sizeof(*op));
+ memset(op_comm,0,sizeof(*op_comm));
+ memset(op_code,0,sizeof(*op_code));
+
+ if(b->header)_ogg_free(b->header);
+ if(b->header1)_ogg_free(b->header1);
+ if(b->header2)_ogg_free(b->header2);
+ b->header=NULL;
+ b->header1=NULL;
+ b->header2=NULL;
+ return(ret);
+}
+
diff --git a/lib/lpc.c b/lib/lpc.c
new file mode 100644
index 00000000..5f184ae4
--- /dev/null
+++ b/lib/lpc.c
@@ -0,0 +1,200 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company http://www.xiph.org/ *
+
+ ********************************************************************
+
+ function: LPC low level routines
+ last mod: $Id: lpc.c,v 1.32.2.1 2001/10/11 15:41:44 xiphmont Exp $
+
+ ********************************************************************/
+
+/* Some of these routines (autocorrelator, LPC coefficient estimator)
+ are derived from code written by Jutta Degener and Carsten Bormann;
+ thus we include their copyright below. The entirety of this file
+ is freely redistributable on the condition that both of these
+ copyright notices are preserved without modification. */
+
+/* Preserved Copyright: *********************************************/
+
+/* Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
+Technische Universita"t Berlin
+
+Any use of this software is permitted provided that this notice is not
+removed and that neither the authors nor the Technische Universita"t
+Berlin are deemed to have made any representations as to the
+suitability of this software for any purpose nor are held responsible
+for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR
+THIS SOFTWARE.
+
+As a matter of courtesy, the authors request to be informed about uses
+this software has found, about bugs in this software, and about any
+improvements that may be of general interest.
+
+Berlin, 28.11.1994
+Jutta Degener
+Carsten Bormann
+
+*********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "os.h"
+#include "smallft.h"
+#include "lpc.h"
+#include "scales.h"
+#include "misc.h"
+
+/* Autocorrelation LPC coeff generation algorithm invented by
+ N. Levinson in 1947, modified by J. Durbin in 1959. */
+
+/* Input : n elements of time doamin data
+ Output: m lpc coefficients, excitation energy */
+
+float vorbis_lpc_from_data(float *data,float *lpc,int n,int m){
+ float *aut=alloca(sizeof(*aut)*(m+1));
+ float error;
+ int i,j;
+
+ /* autocorrelation, p+1 lag coefficients */
+
+ j=m+1;
+ while(j--){
+ double d=0; /* double needed for accumulator depth */
+ for(i=j;i<n;i++)d+=data[i]*data[i-j];
+ aut[j]=d;
+ }
+
+ /* Generate lpc coefficients from autocorr values */
+
+ error=aut[0];
+
+ for(i=0;i<m;i++){
+ float r= -aut[i+1];
+
+ if(error==0){
+ memset(lpc,0,m*sizeof(*lpc));
+ return 0;
+ }
+
+ /* Sum up this iteration's reflection coefficient; note that in
+ Vorbis we don't save it. If anyone wants to recycle this code
+ and needs reflection coefficients, save the results of 'r' from
+ each iteration. */
+
+ for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
+ r/=error;
+
+ /* Update LPC coefficients and total error */
+
+ lpc[i]=r;
+ for(j=0;j<i/2;j++){
+ float tmp=lpc[j];
+ lpc[j]+=r*lpc[i-1-j];
+ lpc[i-1-j]+=r*tmp;
+ }
+ if(i%2)lpc[j]+=lpc[j]*r;
+
+ error*=1.f-r*r;
+ }
+
+ /* we need the error value to know how big an impulse to hit the
+ filter with later */
+
+ return error;
+}
+
+/* Input : n element envelope spectral curve
+ Output: m lpc coefficients, excitation energy */
+
+float vorbis_lpc_from_curve(float *curve,float *lpc,lpc_lookup *l){
+ int n=l->ln;
+ int m=l->m;
+ float *work=alloca(sizeof(*work)*(n+n));
+ float fscale=.5f/n;
+ int i,j;
+
+ /* input is a real curve. make it complex-real */
+ /* This mixes phase, but the LPC generation doesn't care. */
+ for(i=0;i<n;i++){
+ work[i*2]=curve[i]*fscale;
+ work[i*2+1]=0;
+ }
+ work[n*2-1]=curve[n-1]*fscale;
+
+ n*=2;
+ drft_backward(&l->fft,work);
+
+ /* The autocorrelation will not be circular. Shift, else we lose
+ most of the power in the edges. */
+
+ for(i=0,j=n/2;i<n/2;){
+ float temp=work[i];
+ work[i++]=work[j];
+ work[j++]=temp;
+ }
+
+ /* we *could* shave speed here by skimping on the edges (thus
+ speeding up the autocorrelation in vorbis_lpc_from_data) but we
+ don't right now. */
+
+ return(vorbis_lpc_from_data(work,lpc,n,m));
+}
+
+void lpc_init(lpc_lookup *l,long mapped, int m){
+ memset(l,0,sizeof(*l));
+
+ l->ln=mapped;
+ l->m=m;
+
+ /* we cheat decoding the LPC spectrum via FFTs */
+ drft_init(&l->fft,mapped*2);
+
+}
+
+void lpc_clear(lpc_lookup *l){
+ if(l){
+ drft_clear(&l->fft);
+ }
+}
+
+void vorbis_lpc_predict(float *coeff,float *prime,int m,
+ float *data,long n){
+
+ /* in: coeff[0...m-1] LPC coefficients
+ prime[0...m-1] initial values (allocated size of n+m-1)
+ out: data[0...n-1] data samples */
+
+ long i,j,o,p;
+ float y;
+ float *work=alloca(sizeof(*work)*(m+n));
+
+ if(!prime)
+ for(i=0;i<m;i++)
+ work[i]=0.f;
+ else
+ for(i=0;i<m;i++)
+ work[i]=prime[i];
+
+ for(i=0;i<n;i++){
+ y=0;
+ o=i;
+ p=m;
+ for(j=0;j<m;j++)
+ y-=work[o++]*coeff[--p];
+
+ data[i]=work[o]=y;
+ }
+}
+
+
+
+
+
diff --git a/lib/mapping0.c b/lib/mapping0.c
index cafe943a..27cc1fd7 100644
--- a/lib/mapping0.c
+++ b/lib/mapping0.c
@@ -11,7 +11,7 @@
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.37.2.1 2001/10/09 04:34:45 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.37.2.2 2001/10/11 15:41:44 xiphmont Exp $
********************************************************************/
@@ -286,7 +286,9 @@ static double floater_interpolate(backend_lookup_state *b,vorbis_info *vi,
int eighth=b->bitrate_floatinglimit*8-1.;
double lobitrate;
double hibitrate;
-
+
+ if(desired_rate<=0.)return(0.);
+
lobitrate=(double)(eighth==0?0.:
b->bitrate_avgbitacc[eighth-1])/b->bitrate_avgsampleacc*vi->rate;
while(lobitrate>desired_rate && eighth>0){
@@ -388,6 +390,8 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
temp=logfft[(j+1)>>1]=todB(&temp);
if(temp>local_ampmax[i])local_ampmax[i]=temp;
}
+
+ if(local_ampmax[i]>0.f)local_ampmax[i]=0.f;
if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[i];
_analysis_output("fft",seq+i,logfft,n/2,1,0);
@@ -409,7 +413,6 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
for(j=0;j<n/2;j++)
logmdct[j]=todB(mdct+j);
_analysis_output("mdct",seq+i,logmdct,n/2,1,0);
- _analysis_output("lmdct",seq+i,mdct,n/2,0,0);
/* perform psychoacoustics; do masking */
@@ -435,7 +438,6 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
codedflr);
- _analysis_output("mdct2",seq+i,mdct,n/2,1,1);
_vp_remove_floor(look->psy_look[blocktype],
b->psy_g_look,
logmdct,
@@ -608,6 +610,73 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
i,classifications[j],b->bitrate_floatinglimit,queueptr);
}
i++;
+
+ }
+
+ {
+ char buf[80];
+ int k;
+ float *pcmM=sofar[info->coupling_mag[0]];
+ float *pcmA=sofar[info->coupling_ang[0]];
+ float *a=alloca(sizeof(*a)*n/2);
+ float *b=alloca(sizeof(*b)*n/2);
+ sprintf(buf,"sofar%d",i);
+
+ /* channel coupling */
+
+ for(j=0;j<n/2;j++){
+ float mag=pcmM[j];
+ float ang=pcmA[j];
+
+ if(mag>0)
+ if(ang>0){
+ a[j]=mag;
+ b[j]=mag-ang;
+ }else{
+ b[j]=mag;
+ a[j]=mag+ang;
+ }
+ else
+ if(ang>0){
+ a[j]=mag;
+ b[j]=mag+ang;
+ }else{
+ b[j]=mag;
+ a[j]=mag-ang;
+ }
+ }
+
+ _analysis_output(buf,seq,a,n/2,1,0);
+ _analysis_output(buf,seq+1,b,n/2,1,0);
+
+ pcmM=quantized[info->coupling_mag[0]];
+ pcmA=quantized[info->coupling_ang[0]];
+ sprintf(buf,"uquant%d",i);
+
+ for(j=0;j<n/2;j++){
+ float mag=pcmM[j];
+ float ang=pcmA[j];
+
+ if(mag>0)
+ if(ang>0){
+ a[j]=mag;
+ b[j]=mag-ang;
+ }else{
+ b[j]=mag;
+ a[j]=mag+ang;
+ }
+ else
+ if(ang>0){
+ a[j]=mag;
+ b[j]=mag+ang;
+ }else{
+ b[j]=mag;
+ a[j]=mag-ang;
+ }
+ }
+
+ _analysis_output(buf,seq,a,n/2,1,0);
+ _analysis_output(buf,seq+1,b,n/2,1,0);
}
/* bitrate management.... deciding when it's time to stop. */
@@ -642,14 +711,17 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
if(info->coupling_steps==0){
/* this assumes all or nothing coupling right now. it should pass
through any channels left uncoupled, but it doesn't do that now */
- for(i=0;i<vi->channels;i++){
- float *lpcm=pcm[i];
- float *lsof=sofar[i];
- float *lqua=quantized[i];
+ int k;
+ for(k=0;k<vi->channels;k++){
+ float *lpcm=pcm[k];
+ float *lsof=sofar[k];
+ float *lqua=quantized[k];
for(j=0;j<n/2;j++)
lqua[j]=lpcm[j]-lsof[j];
}
}else{
+ char buf[80];
+
_vp_quantize_couple(look->psy_look[blocktype],
info,
pcm,
@@ -657,19 +729,25 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
quantized,
nonzero,
i);
+
+ sprintf(buf,"quant%d",i);
+ for(j=0;j<vi->channels;j++)
+ _analysis_output(buf,seq+j,quantized[j],n/2,1,0);
+
}
}
-
- /* truncate the packet according to stoppos */
- if(!stoppos)stoppos=oggpack_bytes(&vb->opb);
- if(minbits && stoppos*8<minbits)stoppos=(minbits+7)/8;
- if(maxbits && stoppos*8>maxbits)stoppos=maxbits/8;
- if(stoppos>oggpack_bytes(&vb->opb))stoppos=oggpack_bytes(&vb->opb);
- vb->opb.endbyte=stoppos;
- vb->opb.endbit=0;
/* steady as she goes */
}
+
+ /* truncate the packet according to stoppos */
+ if(!stoppos)stoppos=oggpack_bytes(&vb->opb);
+ if(minbits && stoppos*8<minbits)stoppos=(minbits+7)/8;
+ if(maxbits && stoppos*8>maxbits)stoppos=maxbits/8;
+ if(stoppos>oggpack_bytes(&vb->opb))stoppos=oggpack_bytes(&vb->opb);
+ vb->opb.endbyte=stoppos;
+ vb->opb.endbit=0;
+
seq+=vi->channels;
fprintf(stderr,"Bitrate: cav %d, cmin %ld, cmax %ld, float %.1f,"
@@ -711,40 +789,39 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
{
int bits=oggpack_bytes(&vb->opb)*8;
- if(bits>32){ /* (avoid pushing the floater too far in digital silence) */
-
- /* boundaries */
- b->bitrate_queue[b->bitrate_queue_head]=bits;
- if(vb->W)b->bitrate_queue[b->bitrate_queue_head]|=0x80000000UL;
- b->bitrate_boundbitacc+=bits;
- b->bitrate_boundsampleacc+=ci->blocksizes[vb->W]>>1;
-
- /* eighths */
- if(b->bitrate_eighths){
- for(i=0;i<b->bitrate_eighths;i++)
- b->bitrate_avgbitacc[i]+=
- b->bitrate_queue_eighths[b->bitrate_queue_head*b->bitrate_eighths+i];
- b->bitrate_avgsampleacc+=ci->blocksizes[vb->W]>>1;
- }
-
- b->bitrate_queue_head++;
- if(b->bitrate_queue_head>=b->bitrate_queue_size)b->bitrate_queue_head=0;
-
- /* adjust the floater to offset bitrate above/below desired average */
- /* look for the eighth settings in recent history that bracket
- the desired bitrate, and interpolate twixt them for the
- flaoter setting we want */
-
- if(b->bitrate_eighths>0){
- double upper=floater_interpolate(b,vi,ci->bitrate_queue_upperavg);
- double lower=floater_interpolate(b,vi,ci->bitrate_queue_loweravg);
- b->bitrate_floatinglimit=ci->bitrate_floatinglimit_initial;
- if(upper>0 && upper<b->bitrate_floatinglimit)
- b->bitrate_floatinglimit=upper;
- if(lower>b->bitrate_floatinglimit)
- b->bitrate_floatinglimit=lower;
- }
+ /* boundaries */
+ b->bitrate_queue[b->bitrate_queue_head]=bits;
+ if(vb->W)b->bitrate_queue[b->bitrate_queue_head]|=0x80000000UL;
+ b->bitrate_boundbitacc+=bits;
+ b->bitrate_boundsampleacc+=ci->blocksizes[vb->W]>>1;
+
+ /* eighths */
+ if(b->bitrate_eighths){
+ for(i=0;i<b->bitrate_eighths;i++)
+ b->bitrate_avgbitacc[i]+=
+ b->bitrate_queue_eighths[b->bitrate_queue_head*b->bitrate_eighths+i];
+ b->bitrate_avgsampleacc+=ci->blocksizes[vb->W]>>1;
}
+
+ b->bitrate_queue_head++;
+ if(b->bitrate_queue_head>=b->bitrate_queue_size)b->bitrate_queue_head=0;
+
+ /* adjust the floater to offset bitrate above/below desired average */
+ /* look for the eighth settings in recent history that bracket
+ the desired bitrate, and interpolate twixt them for the
+ flaoter setting we want */
+
+ if(b->bitrate_eighths>0){
+ double upper=floater_interpolate(b,vi,ci->bitrate_queue_upperavg);
+ double lower=floater_interpolate(b,vi,ci->bitrate_queue_loweravg);
+
+ fprintf(stderr,"\tupper:%g :: lower:%g\n",upper,lower);
+ b->bitrate_floatinglimit=ci->bitrate_floatinglimit_initial;
+ if(upper>0. && upper<b->bitrate_floatinglimit)
+ b->bitrate_floatinglimit=upper;
+ if(lower>b->bitrate_floatinglimit)
+ b->bitrate_floatinglimit=lower;
+ }
}
}
diff --git a/lib/modes/maskadj_A.h b/lib/modes/maskadj_A.h
new file mode 100644
index 00000000..87c0b6d7
--- /dev/null
+++ b/lib/modes/maskadj_A.h
@@ -0,0 +1,155 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company http://www.xiph.org/ *
+
+ ********************************************************************
+
+ function: predefined encoding modes; masking adjustments for low bitrate
+ last mod: $Id $
+
+ ********************************************************************/
+
+#ifndef _V_MASKADJ_A_H_
+#define _V_MASKADJ_A_H_
+
+#include <stdio.h>
+#include "vorbis/codec.h"
+#include "backends.h"
+
+static vp_attenblock _vp_tonemask_consbass_A={
+ {{-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*63*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*88*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*125*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*175*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*250*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*350*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*500*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*700*/
+
+ {-35.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1000*/
+ {-35.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1400*/
+ {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2000*/
+ {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2800*/
+ {-35.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*4000*/
+ {-35.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*5600*/
+
+ {-30.f,-30.f,-33.f,-35.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*8000*/
+ {-30.f,-30.f,-33.f,-35.f,-35.f,-45.f,-50.f,-60.f,-70.f,-90.f,-100.f}, /*11500*/
+ {-24.f,-24.f,-26.f,-32.f,-32.f,-42.f,-50.f,-60.f,-70.f,-90.f,-100.f}, /*16000*/
+}};
+
+static vp_attenblock _vp_tonemask_A={
+
+ {{-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*63*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*88*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*125*/
+
+
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*175*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*250*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*350*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*500*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*700*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1000*/
+ {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1400*/
+ {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2000*/
+ {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2800*/
+ {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*4000*/
+
+ {-30.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*5600*/
+
+ {-30.f,-30.f,-33.f,-35.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*8000*/
+ {-30.f,-30.f,-33.f,-35.f,-40.f,-45.f,-50.f,-60.f,-70.f,-85.f,-100.f}, /*11500*/
+ {-24.f,-24.f,-26.f,-32.f,-32.f,-42.f,-50.f,-60.f,-70.f,-85.f,-100.f}, /*16000*/
+}};
+
+static vp_attenblock _vp_tonemask_E={
+ {{-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*63*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*88*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*125*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*175*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*250*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*350*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*500*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*700*/
+
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f}, /*1k*/
+ {-40.f,-40.f,-40.f,-45.f,-55.f,-65.f,-75.f,-85.f,-95.f,-105.f,-115.f},
+ {-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f}, /*2k*/
+ {-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f},
+ {-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f}, /*4k*/
+ {-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f}, /*8000*/
+
+ {-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f}, /*8000*/
+ {-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f},
+ {-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f,-9e9f},
+}};
+
+static vp_attenblock _vp_peakatt_A={
+ {{-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*63*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*88*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*125*/
+ {-14.f,-20.f,-20.f,-20.f,-20.f,-20.f,-20.f,-30.f,-32.f,-32.f,-40.f},/*175*/
+ {-14.f,-20.f,-20.f,-20.f,-20.f,-20.f,-20.f,-30.f,-32.f,-32.f,-40.f},/*250*/
+ {-14.f,-20.f,-20.f,-20.f,-20.f,-20.f,-20.f,-24.f,-32.f,-32.f,-40.f},/*350*/
+ {-14.f,-20.f,-20.f,-20.f,-20.f,-20.f,-20.f,-24.f,-32.f,-32.f,-40.f},/*500*/
+ {-10.f,-10.f,-10.f,-10.f,-14.f,-16.f,-20.f,-24.f,-26.f,-32.f,-40.f},/*700*/
+ {-10.f,-10.f,-10.f,-10.f,-14.f,-16.f,-20.f,-24.f,-22.f,-32.f,-40.f},/*1000*/
+ {-10.f,-10.f,-10.f,-10.f,-14.f,-16.f,-20.f,-24.f,-22.f,-32.f,-40.f},/*1400*/
+ {-10.f,-10.f,-10.f,-10.f,-14.f,-16.f,-20.f,-24.f,-22.f,-32.f,-40.f},/*2000*/
+ {-10.f,-10.f,-10.f,-10.f,-14.f,-16.f,-20.f,-24.f,-22.f,-32.f,-40.f},/*2400*/
+ {-10.f,-10.f,-10.f,-10.f,-14.f,-14.f,-16.f,-20.f,-22.f,-32.f,-40.f},/*4000*/
+ {-10.f,-10.f,-10.f,-10.f,-10.f,-11.f,-12.f,-13.f,-22.f,-32.f,-40.f},/*5600*/
+ {-10.f,-10.f,-10.f,-10.f,-10.f,-11.f,-12.f,-13.f,-22.f,-32.f,-40.f},/*8000*/
+ {-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-11.f,-22.f,-32.f,-40.f},/*11500*/
+ {-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-20.f,-32.f,-40.f},/*16000*/
+}};
+
+static vp_attenblock _vp_peakatt_B={
+ {{-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*63*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*88*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*125*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*175*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*250*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*350*/
+ {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-32.f,-32.f,-32.f,-32.f,-40.f},/*500*/
+ {-10.f,-10.f,-10.f,-14.f,-20.f,-20.f,-20.f,-24.f,-26.f,-32.f,-40.f},/*700*/
+ {-10.f,-10.f,-10.f,-14.f,-20.f,-20.f,-20.f,-24.f,-26.f,-32.f,-40.f},/*1000*/
+ {-10.f,-10.f,-10.f,-14.f,-20.f,-20.f,-20.f,-24.f,-26.f,-32.f,-40.f},/*1400*/
+ {-10.f,-10.f,-10.f,-14.f,-20.f,-20.f,-20.f,-24.f,-26.f,-32.f,-40.f},/*2000*/
+ {-10.f,-10.f,-10.f,-14.f,-20.f,-20.f,-20.f,-24.f,-26.f,-32.f,-40.f},/*2800*/
+ {-10.f,-10.f,-10.f,-10.f,-18.f,-20.f,-20.f,-22.f,-24.f,-32.f,-40.f},/*4000*/
+ {-10.f,-10.f,-10.f,-10.f,-12.f,-14.f,-16.f,-18.f,-22.f,-32.f,-40.f},/*5600*/
+ {-10.f,-10.f,-10.f,-10.f,-10.f,-11.f,-12.f,-13.f,-22.f,-32.f,-40.f},/*8000*/
+ {-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-11.f,-22.f,-32.f,-40.f},/*11500*/
+ {-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-10.f,-20.f,-32.f,-40.f},/*16000*/
+}};
+
+static vp_attenblock _vp_peakatt_D={
+ {{-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*63*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*88*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*125*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*170*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*250*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*350*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*500*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*700*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*1000*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*1400*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*2000*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*2800*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*4000*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*5600*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*8000*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*11500*/
+ {-14.f,-20.f,-24.f,-26.f,-32.f,-34.f,-36.f,-38.f,-40.f,-40.f,-40.f},/*16600*/
+ }};
+
+
+#endif
diff --git a/lib/modes/mode_44c_A.h b/lib/modes/mode_44c_A.h
index 96a85706..f2d0f750 100644
--- a/lib/modes/mode_44c_A.h
+++ b/lib/modes/mode_44c_A.h
@@ -11,7 +11,7 @@
********************************************************************
function: predefined encoding modes; 44kHz stereo ~64kbps true VBR
- last mod: $Id: mode_44c_A.h,v 1.4.2.1 2001/10/09 04:34:55 xiphmont Exp $
+ last mod: $Id: mode_44c_A.h,v 1.4.2.2 2001/10/11 15:41:55 xiphmont Exp $
********************************************************************/
@@ -52,14 +52,18 @@
#include "books/res_44c_A_128aux.vqh"
#include "books/res_44c_A_1024aux.vqh"
+#include "books/res_Ac_0a.vqh"
#include "books/res_Ac_1.vqh"
#include "books/res_Ac_2.vqh"
+#include "books/res_Ac_2a.vqh"
#include "books/res_Ac_3.vqh"
#include "books/res_Ac_4.vqh"
#include "books/res_Ac_5.vqh"
+#include "books/res_Ac_5a.vqh"
#include "books/res_Ac_6.vqh"
#include "books/res_Ac_7.vqh"
#include "books/res_Ac_7a.vqh"
+#include "books/res_Ac_7b.vqh"
#include "books/res_Ac_8.vqh"
#include "books/res_Ac_8a.vqh"
#include "books/res_Ac_9.vqh"
@@ -168,7 +172,7 @@ static vorbis_info_psy _psy_set_44c_A={
0.f,-26.f,-30.f,
&_vp_tonemask_consbass_A,
/* peakattp, curvelimitp */
- 1, 4, &_vp_peakatt_A,
+ 0, 4, &_vp_peakatt_A,
/*noisemaskp */
1, -10.f, /* suppress any noise curve over maxspec+n */
@@ -239,16 +243,16 @@ static vorbis_info_floor1 _floor_set_44c_A={
60,30,400,
20,8,1,18.,
20,600,
- 896};
+ 928};
static vorbis_info_residue0 _residue_set_44c_A0={
0,192, 16, 10,23,
- {0,4,40,
- 1,2,20,
- 4,6,6,7},
- {25, 26,26,
- 27, 28, 29,29,
- 30, 31,32, 33,34, 35,36,37},
+ {64,4,40,
+ 2,2,20,
+ 18,22,22,7},
+ {38, 25, 26,39,
+ 27, 28, 29,40,
+ 30,40, 31,32,41, 33,34,41, 35,36,37},
{9999,9999,9999,9999,9999,9999,
9999,9999,9999,9999},
{.5f,
@@ -259,13 +263,13 @@ static vorbis_info_residue0 _residue_set_44c_A0={
{99,8,99,3,8,99,99,99,99,99}};
static vorbis_info_residue0 _residue_set_44c_A={
- 0,1792, 32,10,24,
- {0,4,40,
- 1,2,20,
- 4,6,6,7},
- {25, 26,26,
- 27, 28, 29,29,
- 30, 31,32, 33,34, 35,36,37},
+ 0,1856, 32,10,24,
+ {64,4,40,
+ 2,2,20,
+ 18,22,22,7},
+ {38, 25, 26,39,
+ 27, 28, 29,40,
+ 30,40, 31,32,41, 33,34,41, 35,36,37},
{9999,9999,9999,9999,9999,9999,
9999,9999,9999,9999},
{.5f,
@@ -288,7 +292,7 @@ codec_setup_info info_44c_A={
/* smallblock, largeblock */
{256, 2048},
/* modes,maps,times,floors,residues,books,psys */
- 2, 2, 1, 2, 2, 38, 3,
+ 2, 2, 1, 2, 2, 42, 3,
/* modes */
{&_mode_set_44c_A0,&_mode_set_44c_A},
/* maps */
@@ -332,12 +336,12 @@ codec_setup_info info_44c_A={
&_huff_book_res_44c_A_128aux,
&_huff_book_res_44c_A_1024aux,
- &_vq_book_res_Ac_1,
+ &_vq_book_res_Ac_1, /* 25 */
&_vq_book_res_Ac_2,
- &_vq_book_res_Ac_3,
+ &_vq_book_res_Ac_3, /* 27 */
&_vq_book_res_Ac_4,
&_vq_book_res_Ac_5,
- &_vq_book_res_Ac_6,
+ &_vq_book_res_Ac_6, /* 30 */
&_vq_book_res_Ac_7,
&_vq_book_res_Ac_7a,
&_vq_book_res_Ac_8,
@@ -346,6 +350,11 @@ codec_setup_info info_44c_A={
&_vq_book_res_Ac_9a,
&_vq_book_res_Ac_9b,
+ &_vq_book_res_Ac_0a, /* 38 */
+ &_vq_book_res_Ac_2a,
+ &_vq_book_res_Ac_5a,
+ &_vq_book_res_Ac_7b,
+
},
/* psy */
@@ -353,18 +362,18 @@ codec_setup_info info_44c_A={
&_psy_set_44c_AG,
/* progressive coding and bitrate controls */
- 3.0,
+ 4.0,
1.,4.,
0,
- 0,
+ 100000,
0,
- 0,
+ 0000,
- 0,0,
+ 120000,0,
- {4,6},
+ {4,7},
2,
};
diff --git a/lib/psy.c b/lib/psy.c
new file mode 100644
index 00000000..36ca9f33
--- /dev/null
+++ b/lib/psy.c
@@ -0,0 +1,1139 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: psychoacoustics not including preecho
+ last mod: $Id: psy.c,v 1.56.2.1 2001/10/11 15:41:44 xiphmont Exp $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include "vorbis/codec.h"
+#include "codec_internal.h"
+
+#include "masking.h"
+#include "psy.h"
+#include "os.h"
+#include "lpc.h"
+#include "smallft.h"
+#include "scales.h"
+#include "misc.h"
+
+#define NEGINF -9999.f
+
+/* Why Bark scale for encoding but not masking computation? Because
+ masking has a strong harmonic dependency */
+
+vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){
+ int i,j;
+ codec_setup_info *ci=vi->codec_setup;
+ vorbis_info_psy_global *gi=ci->psy_g_param;
+ vorbis_look_psy_global *look=_ogg_calloc(1,sizeof(*look));
+
+ int shiftoc=rint(log(gi->eighth_octave_lines*8)/log(2))-1;
+ look->decaylines=toOC(96000.f)*(1<<(shiftoc+1))+.5f; /* max sample
+ rate of
+ 192000kHz
+ for now */
+ look->decay=_ogg_calloc(vi->channels,sizeof(*look->decay));
+ for(i=0;i<vi->channels;i++){
+ look->decay[i]=_ogg_calloc(look->decaylines,sizeof(*look->decay[i]));
+ for(j=0;j<look->decaylines;j++)
+ look->decay[i][j]=-9999.;
+ }
+ look->channels=vi->channels;
+
+ look->ampmax=-9999.;
+ look->gi=gi;
+ return(look);
+}
+
+void _vp_global_free(vorbis_look_psy_global *look){
+ int i;
+ if(look->decay){
+ for(i=0;i<look->channels;i++)
+ _ogg_free(look->decay[i]);
+ _ogg_free(look->decay);
+ }
+ memset(look,0,sizeof(*look));
+ _ogg_free(look);
+}
+
+void _vi_psy_free(vorbis_info_psy *i){
+ if(i){
+ memset(i,0,sizeof(*i));
+ _ogg_free(i);
+ }
+}
+
+vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i){
+ vorbis_info_psy *ret=_ogg_malloc(sizeof(*ret));
+ memcpy(ret,i,sizeof(*ret));
+ return(ret);
+}
+
+/* Set up decibel threshold slopes on a Bark frequency scale */
+/* ATH is the only bit left on a Bark scale. No reason to change it
+ right now */
+static void set_curve(float *ref,float *c,int n, float crate){
+ int i,j=0;
+
+ for(i=0;i<MAX_BARK-1;i++){
+ int endpos=rint(fromBARK(i+1)*2*n/crate);
+ float base=ref[i];
+ if(j<endpos){
+ float delta=(ref[i+1]-base)/(endpos-j);
+ for(;j<endpos && j<n;j++){
+ c[j]=base;
+ base+=delta;
+ }
+ }
+ }
+}
+
+static void min_curve(float *c,
+ float *c2){
+ int i;
+ for(i=0;i<EHMER_MAX;i++)if(c2[i]<c[i])c[i]=c2[i];
+}
+static void max_curve(float *c,
+ float *c2){
+ int i;
+ for(i=0;i<EHMER_MAX;i++)if(c2[i]>c[i])c[i]=c2[i];
+}
+
+static void attenuate_curve(float *c,float att){
+ int i;
+ for(i=0;i<EHMER_MAX;i++)
+ c[i]+=att;
+}
+
+static void interp_curve(float *c,float *c1,float *c2,float del){
+ int i;
+ for(i=0;i<EHMER_MAX;i++)
+ c[i]=c2[i]*del+c1[i]*(1.f-del);
+}
+
+extern int analysis_noisy;
+static void setup_curve(float **c,
+ int band,
+ float *curveatt_dB){
+ int i,j;
+ float ath[EHMER_MAX];
+ float tempc[P_LEVELS][EHMER_MAX];
+ float *ATH=ATH_Bark_dB_lspconservative; /* just for limiting here */
+
+ memcpy(c[0]+2,c[4]+2,sizeof(*c[0])*EHMER_MAX);
+ memcpy(c[2]+2,c[4]+2,sizeof(*c[2])*EHMER_MAX);
+
+ /* we add back in the ATH to avoid low level curves falling off to
+ -infinity and unnecessarily cutting off high level curves in the
+ curve limiting (last step). But again, remember... a half-band's
+ settings must be valid over the whole band, and it's better to
+ mask too little than too much, so be pessimistical. */
+
+ for(i=0;i<EHMER_MAX;i++){
+ float oc_min=band*.5+(i-EHMER_OFFSET)*.125;
+ float oc_max=band*.5+(i-EHMER_OFFSET+1)*.125;
+ float bark=toBARK(fromOC(oc_min));
+ int ibark=floor(bark);
+ float del=bark-ibark;
+ float ath_min,ath_max;
+
+ if(ibark<26)
+ ath_min=ATH[ibark]*(1.f-del)+ATH[ibark+1]*del;
+ else
+ ath_min=ATH[25];
+
+ bark=toBARK(fromOC(oc_max));
+ ibark=floor(bark);
+ del=bark-ibark;
+
+ if(ibark<26)
+ ath_max=ATH[ibark]*(1.f-del)+ATH[ibark+1]*del;
+ else
+ ath_max=ATH[25];
+
+ ath[i]=min(ath_min,ath_max);
+ }
+
+ /* The c array comes in as dB curves at 20 40 60 80 100 dB.
+ interpolate intermediate dB curves */
+ for(i=1;i<P_LEVELS;i+=2){
+ interp_curve(c[i]+2,c[i-1]+2,c[i+1]+2,.5);
+ }
+
+ /* normalize curves so the driving amplitude is 0dB */
+ /* make temp curves with the ATH overlayed */
+ for(i=0;i<P_LEVELS;i++){
+ attenuate_curve(c[i]+2,curveatt_dB[i]);
+ memcpy(tempc[i],ath,EHMER_MAX*sizeof(*tempc[i]));
+ attenuate_curve(tempc[i],-i*10.f);
+ max_curve(tempc[i],c[i]+2);
+ }
+
+ /* Now limit the louder curves.
+
+ the idea is this: We don't know what the playback attenuation
+ will be; 0dB SL moves every time the user twiddles the volume
+ knob. So that means we have to use a single 'most pessimal' curve
+ for all masking amplitudes, right? Wrong. The *loudest* sound
+ can be in (we assume) a range of ...+100dB] SL. However, sounds
+ 20dB down will be in a range ...+80], 40dB down is from ...+60],
+ etc... */
+
+ for(j=1;j<P_LEVELS;j++){
+ min_curve(tempc[j],tempc[j-1]);
+ min_curve(c[j]+2,tempc[j]);
+ }
+
+ /* add fenceposts */
+ for(j=0;j<P_LEVELS;j++){
+
+ for(i=0;i<EHMER_OFFSET;i++)
+ if(c[j][i+2]>-200.f)break;
+ c[j][0]=i;
+
+ for(i=EHMER_MAX-1;i>EHMER_OFFSET+1;i--)
+ if(c[j][i+2]>-200.f)
+ break;
+ c[j][1]=i;
+
+ }
+}
+
+void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
+ vorbis_info_psy_global *gi,int n,long rate){
+ long i,j,k,lo=-99,hi=0;
+ long maxoc;
+ memset(p,0,sizeof(*p));
+
+
+ p->eighth_octave_lines=gi->eighth_octave_lines;
+ p->shiftoc=rint(log(gi->eighth_octave_lines*8)/log(2))-1;
+
+ p->firstoc=toOC(.25f*rate/n)*(1<<(p->shiftoc+1))-gi->eighth_octave_lines;
+ maxoc=toOC((n*.5f-.25f)*rate/n)*(1<<(p->shiftoc+1))+.5f;
+ p->total_octave_lines=maxoc-p->firstoc+1;
+
+ if(vi->ath)
+ p->ath=_ogg_malloc(n*sizeof(*p->ath));
+ p->octave=_ogg_malloc(n*sizeof(*p->octave));
+ p->bark=_ogg_malloc(n*sizeof(*p->bark));
+ p->vi=vi;
+ p->n=n;
+ p->rate=rate;
+
+ /* set up the lookups for a given blocksize and sample rate */
+ if(vi->ath)
+ set_curve(vi->ath, p->ath,n,rate);
+ for(i=0;i<n;i++){
+ float bark=toBARK(rate/(2*n)*i);
+
+ for(;lo+vi->noisewindowlomin<i &&
+ toBARK(rate/(2*n)*lo)<(bark-vi->noisewindowlo);lo++);
+
+ for(;hi<n && (hi<i+vi->noisewindowhimin ||
+ toBARK(rate/(2*n)*hi)<(bark+vi->noisewindowhi));hi++);
+
+ p->bark[i]=(lo<<16)+hi;
+
+ }
+
+ for(i=0;i<n;i++)
+ p->octave[i]=toOC((i*.5f+.25f)*rate/n)*(1<<(p->shiftoc+1))+.5f;
+
+ p->tonecurves=_ogg_malloc(P_BANDS*sizeof(*p->tonecurves));
+ p->noisethresh=_ogg_malloc(n*sizeof(*p->noisethresh));
+ p->noiseoffset=_ogg_malloc(n*sizeof(*p->noiseoffset));
+ for(i=0;i<P_BANDS;i++)
+ p->tonecurves[i]=_ogg_malloc(P_LEVELS*sizeof(*p->tonecurves[i]));
+
+ for(i=0;i<P_BANDS;i++)
+ for(j=0;j<P_LEVELS;j++)
+ p->tonecurves[i][j]=_ogg_malloc((EHMER_MAX+2)*sizeof(*p->tonecurves[i][j]));
+
+
+ /* OK, yeah, this was a silly way to do it */
+ memcpy(p->tonecurves[0][4]+2,tone_125_40dB_SL,sizeof(*p->tonecurves[0][4])*EHMER_MAX);
+ memcpy(p->tonecurves[0][6]+2,tone_125_60dB_SL,sizeof(*p->tonecurves[0][6])*EHMER_MAX);
+ memcpy(p->tonecurves[0][8]+2,tone_125_80dB_SL,sizeof(*p->tonecurves[0][8])*EHMER_MAX);
+ memcpy(p->tonecurves[0][10]+2,tone_125_100dB_SL,sizeof(*p->tonecurves[0][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[2][4]+2,tone_125_40dB_SL,sizeof(*p->tonecurves[2][4])*EHMER_MAX);
+ memcpy(p->tonecurves[2][6]+2,tone_125_60dB_SL,sizeof(*p->tonecurves[2][6])*EHMER_MAX);
+ memcpy(p->tonecurves[2][8]+2,tone_125_80dB_SL,sizeof(*p->tonecurves[2][8])*EHMER_MAX);
+ memcpy(p->tonecurves[2][10]+2,tone_125_100dB_SL,sizeof(*p->tonecurves[2][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[4][4]+2,tone_250_40dB_SL,sizeof(*p->tonecurves[4][4])*EHMER_MAX);
+ memcpy(p->tonecurves[4][6]+2,tone_250_60dB_SL,sizeof(*p->tonecurves[4][6])*EHMER_MAX);
+ memcpy(p->tonecurves[4][8]+2,tone_250_80dB_SL,sizeof(*p->tonecurves[4][8])*EHMER_MAX);
+ memcpy(p->tonecurves[4][10]+2,tone_250_100dB_SL,sizeof(*p->tonecurves[4][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[6][4]+2,tone_500_40dB_SL,sizeof(*p->tonecurves[6][4])*EHMER_MAX);
+ memcpy(p->tonecurves[6][6]+2,tone_500_60dB_SL,sizeof(*p->tonecurves[6][6])*EHMER_MAX);
+ memcpy(p->tonecurves[6][8]+2,tone_500_80dB_SL,sizeof(*p->tonecurves[6][8])*EHMER_MAX);
+ memcpy(p->tonecurves[6][10]+2,tone_500_100dB_SL,sizeof(*p->tonecurves[6][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[8][4]+2,tone_1000_40dB_SL,sizeof(*p->tonecurves[8][4])*EHMER_MAX);
+ memcpy(p->tonecurves[8][6]+2,tone_1000_60dB_SL,sizeof(*p->tonecurves[8][6])*EHMER_MAX);
+ memcpy(p->tonecurves[8][8]+2,tone_1000_80dB_SL,sizeof(*p->tonecurves[8][8])*EHMER_MAX);
+ memcpy(p->tonecurves[8][10]+2,tone_1000_100dB_SL,sizeof(*p->tonecurves[8][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[10][4]+2,tone_2000_40dB_SL,sizeof(*p->tonecurves[10][4])*EHMER_MAX);
+ memcpy(p->tonecurves[10][6]+2,tone_2000_60dB_SL,sizeof(*p->tonecurves[10][6])*EHMER_MAX);
+ memcpy(p->tonecurves[10][8]+2,tone_2000_80dB_SL,sizeof(*p->tonecurves[10][8])*EHMER_MAX);
+ memcpy(p->tonecurves[10][10]+2,tone_2000_100dB_SL,sizeof(*p->tonecurves[10][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[12][4]+2,tone_4000_40dB_SL,sizeof(*p->tonecurves[12][4])*EHMER_MAX);
+ memcpy(p->tonecurves[12][6]+2,tone_4000_60dB_SL,sizeof(*p->tonecurves[12][6])*EHMER_MAX);
+ memcpy(p->tonecurves[12][8]+2,tone_4000_80dB_SL,sizeof(*p->tonecurves[12][8])*EHMER_MAX);
+ memcpy(p->tonecurves[12][10]+2,tone_4000_100dB_SL,sizeof(*p->tonecurves[12][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[14][4]+2,tone_8000_40dB_SL,sizeof(*p->tonecurves[14][4])*EHMER_MAX);
+ memcpy(p->tonecurves[14][6]+2,tone_8000_60dB_SL,sizeof(*p->tonecurves[14][6])*EHMER_MAX);
+ memcpy(p->tonecurves[14][8]+2,tone_8000_80dB_SL,sizeof(*p->tonecurves[14][8])*EHMER_MAX);
+ memcpy(p->tonecurves[14][10]+2,tone_8000_100dB_SL,sizeof(*p->tonecurves[14][10])*EHMER_MAX);
+
+ memcpy(p->tonecurves[16][4]+2,tone_8000_40dB_SL,sizeof(*p->tonecurves[16][4])*EHMER_MAX);
+ memcpy(p->tonecurves[16][6]+2,tone_8000_60dB_SL,sizeof(*p->tonecurves[16][6])*EHMER_MAX);
+ memcpy(p->tonecurves[16][8]+2,tone_8000_80dB_SL,sizeof(*p->tonecurves[16][8])*EHMER_MAX);
+ memcpy(p->tonecurves[16][10]+2,tone_8000_100dB_SL,sizeof(*p->tonecurves[16][10])*EHMER_MAX);
+
+ for(i=0;i<P_BANDS;i+=2)
+ for(j=4;j<P_LEVELS;j+=2)
+ for(k=2;k<EHMER_MAX+2;k++)
+ p->tonecurves[i][j][k]+=vi->tone_masteratt;
+
+ /* interpolate curves between */
+ for(i=1;i<P_BANDS;i+=2)
+ for(j=4;j<P_LEVELS;j+=2){
+ memcpy(p->tonecurves[i][j]+2,p->tonecurves[i-1][j]+2,EHMER_MAX*sizeof(*p->tonecurves[i][j]));
+ /*interp_curve(p->tonecurves[i][j],
+ p->tonecurves[i-1][j],
+ p->tonecurves[i+1][j],.5);*/
+ min_curve(p->tonecurves[i][j]+2,p->tonecurves[i+1][j]+2);
+ }
+
+ /* set up the final curves */
+ for(i=0;i<P_BANDS;i++)
+ setup_curve(p->tonecurves[i],i,vi->toneatt->block[i]);
+
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_63Hz",i,p->tonecurves[0][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_88Hz",i,p->tonecurves[1][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_125Hz",i,p->tonecurves[2][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_170Hz",i,p->tonecurves[3][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_250Hz",i,p->tonecurves[4][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_350Hz",i,p->tonecurves[5][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_500Hz",i,p->tonecurves[6][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_700Hz",i,p->tonecurves[7][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_1kHz",i,p->tonecurves[8][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_1.4Hz",i,p->tonecurves[9][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_2kHz",i,p->tonecurves[10][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_2.4kHz",i,p->tonecurves[11][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_4kHz",i,p->tonecurves[12][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_5.6kHz",i,p->tonecurves[13][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_8kHz",i,p->tonecurves[14][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_11.5kHz",i,p->tonecurves[15][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("curve_16kHz",i,p->tonecurves[16][i]+2,EHMER_MAX,0,0);
+
+ if(vi->curvelimitp){
+ /* value limit the tonal masking curves; the peakatt not only
+ optionally specifies maximum dynamic depth, but also
+ limits the masking curves to a minimum depth */
+ for(i=0;i<P_BANDS;i++)
+ for(j=0;j<P_LEVELS;j++){
+ for(k=2;k<EHMER_OFFSET+2+vi->curvelimitp;k++)
+ if(p->tonecurves[i][j][k]> vi->peakatt->block[i][j])
+ p->tonecurves[i][j][k]= vi->peakatt->block[i][j];
+ else
+ break;
+ }
+ }
+
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_63Hz",i,p->tonecurves[0][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_88Hz",i,p->tonecurves[1][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_125Hz",i,p->tonecurves[2][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_170Hz",i,p->tonecurves[3][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_250Hz",i,p->tonecurves[4][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_350Hz",i,p->tonecurves[5][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_500Hz",i,p->tonecurves[6][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_700Hz",i,p->tonecurves[7][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_1kHz",i,p->tonecurves[8][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_1.4Hz",i,p->tonecurves[9][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_2kHz",i,p->tonecurves[10][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_2.4kHz",i,p->tonecurves[11][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_4kHz",i,p->tonecurves[12][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_5.6kHz",i,p->tonecurves[13][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_8kHz",i,p->tonecurves[14][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_11.5kHz",i,p->tonecurves[15][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("licurve_16kHz",i,p->tonecurves[16][i]+2,EHMER_MAX,0,0);
+
+ if(vi->peakattp) /* we limit maximum depth only optionally */
+ for(i=0;i<P_BANDS;i++)
+ for(j=0;j<P_LEVELS;j++)
+ if(p->tonecurves[i][j][EHMER_OFFSET+2]< vi->peakatt->block[i][j])
+ p->tonecurves[i][j][EHMER_OFFSET+2]= vi->peakatt->block[i][j];
+
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_63Hz",i,p->tonecurves[0][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_88Hz",i,p->tonecurves[1][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_125Hz",i,p->tonecurves[2][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_170Hz",i,p->tonecurves[3][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_250Hz",i,p->tonecurves[4][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_350Hz",i,p->tonecurves[5][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_500Hz",i,p->tonecurves[6][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_700Hz",i,p->tonecurves[7][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_1kHz",i,p->tonecurves[8][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_1.4Hz",i,p->tonecurves[9][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_2kHz",i,p->tonecurves[10][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_2.4kHz",i,p->tonecurves[11][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_4kHz",i,p->tonecurves[12][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_5.6kHz",i,p->tonecurves[13][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_8kHz",i,p->tonecurves[14][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_11.5kHz",i,p->tonecurves[15][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("pcurve_16kHz",i,p->tonecurves[16][i]+2,EHMER_MAX,0,0);
+
+ /* but guarding is mandatory */
+ for(i=0;i<P_BANDS;i++)
+ for(j=0;j<P_LEVELS;j++)
+ if(p->tonecurves[i][j][EHMER_OFFSET+2]< vi->tone_guard)
+ p->tonecurves[i][j][EHMER_OFFSET+2]= vi->tone_guard;
+
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_63Hz",i,p->tonecurves[0][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_88Hz",i,p->tonecurves[1][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_125Hz",i,p->tonecurves[2][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_170Hz",i,p->tonecurves[3][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_250Hz",i,p->tonecurves[4][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_350Hz",i,p->tonecurves[5][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_500Hz",i,p->tonecurves[6][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_700Hz",i,p->tonecurves[7][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_1kHz",i,p->tonecurves[8][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_1.4Hz",i,p->tonecurves[9][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_2kHz",i,p->tonecurves[10][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_2.4kHz",i,p->tonecurves[11][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_4kHz",i,p->tonecurves[12][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_5.6kHz",i,p->tonecurves[13][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_8kHz",i,p->tonecurves[14][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_11.5kHz",i,p->tonecurves[15][i]+2,EHMER_MAX,0,0);
+ for(i=0;i<P_LEVELS;i++)
+ _analysis_output("fcurve_16kHz",i,p->tonecurves[16][i]+2,EHMER_MAX,0,0);
+
+ /* set up rolling noise median */
+ for(i=0;i<n;i++){
+ float halfoc=toOC((i+.5)*rate/(2.*n))*2.;
+ int inthalfoc;
+ float del;
+
+ if(halfoc<0)halfoc=0;
+ if(halfoc>=P_BANDS-1)halfoc=P_BANDS-1;
+ inthalfoc=(int)halfoc;
+ del=halfoc-inthalfoc;
+ p->noiseoffset[i]=
+ p->vi->noiseoff[inthalfoc]*(1.-del) +
+ p->vi->noiseoff[inthalfoc+1]*del;
+ }
+
+ analysis_noisy=1;
+ _analysis_output("noiseoff",0,p->noiseoffset,n,1,0);
+ _analysis_output("noisethresh",0,p->noisethresh,n,1,0);
+ analysis_noisy=1;
+
+}
+
+void _vp_psy_clear(vorbis_look_psy *p){
+ int i,j;
+ if(p){
+ if(p->ath)_ogg_free(p->ath);
+ if(p->octave)_ogg_free(p->octave);
+ if(p->bark)_ogg_free(p->bark);
+ if(p->tonecurves){
+ for(i=0;i<P_BANDS;i++){
+ for(j=0;j<P_LEVELS;j++){
+ _ogg_free(p->tonecurves[i][j]);
+ }
+ _ogg_free(p->tonecurves[i]);
+ }
+ _ogg_free(p->tonecurves);
+ }
+ _ogg_free(p->noiseoffset);
+ _ogg_free(p->noisethresh);
+ memset(p,0,sizeof(*p));
+ }
+}
+
+/* octave/(8*eighth_octave_lines) x scale and dB y scale */
+static void seed_curve(float *seed,
+ const float **curves,
+ float amp,
+ int oc, int n,
+ int linesper,float dBoffset){
+ int i,post1;
+ int seedptr;
+ const float *posts,*curve;
+
+ int choice=(int)((amp+dBoffset)*.1f);
+ choice=max(choice,0);
+ choice=min(choice,P_LEVELS-1);
+ posts=curves[choice];
+ curve=posts+2;
+ post1=(int)posts[1];
+ seedptr=oc+(posts[0]-16)*linesper-(linesper>>1);
+
+ for(i=posts[0];i<post1;i++){
+ if(seedptr>0){
+ float lin=amp+curve[i];
+ if(seed[seedptr]<lin)seed[seedptr]=lin;
+ }
+ seedptr+=linesper;
+ if(seedptr>=n)break;
+ }
+}
+
+static void seed_loop(vorbis_look_psy *p,
+ const float ***curves,
+ const float *f,
+ const float *flr,
+ float *seed,
+ float specmax){
+ vorbis_info_psy *vi=p->vi;
+ long n=p->n,i;
+ float dBoffset=vi->max_curve_dB-specmax;
+
+ /* prime the working vector with peak values */
+
+ for(i=0;i<n;i++){
+ float max=f[i];
+ long oc=p->octave[i];
+ while(i+1<n && p->octave[i+1]==oc){
+ i++;
+ if(f[i]>max)max=f[i];
+ }
+
+ if(max+6.f>flr[i]){
+ oc=oc>>p->shiftoc;
+ if(oc>=P_BANDS)oc=P_BANDS-1;
+ if(oc<0)oc=0;
+ seed_curve(seed,
+ curves[oc],
+ max,
+ p->octave[i]-p->firstoc,
+ p->total_octave_lines,
+ p->eighth_octave_lines,
+ dBoffset);
+ }
+ }
+}
+
+static void seed_chase(float *seeds, int linesper, long n){
+ long *posstack=alloca(n*sizeof(*posstack));
+ float *ampstack=alloca(n*sizeof(*ampstack));
+ long stack=0;
+ long pos=0;
+ long i;
+
+ for(i=0;i<n;i++){
+ if(stack<2){
+ posstack[stack]=i;
+ ampstack[stack++]=seeds[i];
+ }else{
+ while(1){
+ if(seeds[i]<ampstack[stack-1]){
+ posstack[stack]=i;
+ ampstack[stack++]=seeds[i];
+ break;
+ }else{
+ if(i<posstack[stack-1]+linesper){
+ if(stack>1 && ampstack[stack-1]<=ampstack[stack-2] &&
+ i<posstack[stack-2]+linesper){
+ /* we completely overlap, making stack-1 irrelevant. pop it */
+ stack--;
+ continue;
+ }
+ }
+ posstack[stack]=i;
+ ampstack[stack++]=seeds[i];
+ break;
+
+ }
+ }
+ }
+ }
+
+ /* the stack now contains only the positions that are relevant. Scan
+ 'em straight through */
+
+ for(i=0;i<stack;i++){
+ long endpos;
+ if(i<stack-1 && ampstack[i+1]>ampstack[i]){
+ endpos=posstack[i+1];
+ }else{
+ endpos=posstack[i]+linesper+1; /* +1 is important, else bin 0 is
+ discarded in short frames */
+ }
+ if(endpos>n)endpos=n;
+ for(;pos<endpos;pos++)
+ seeds[pos]=ampstack[i];
+ }
+
+ /* there. Linear time. I now remember this was on a problem set I
+ had in Grad Skool... I didn't solve it at the time ;-) */
+
+}
+
+/* bleaugh, this is more complicated than it needs to be */
+static void max_seeds(vorbis_look_psy *p,
+ vorbis_look_psy_global *g,
+ int channel,
+ float *seed,
+ float *flr){
+ long n=p->total_octave_lines;
+ int linesper=p->eighth_octave_lines;
+ long linpos=0;
+ long pos;
+
+ seed_chase(seed,linesper,n); /* for masking */
+
+ pos=p->octave[0]-p->firstoc-(linesper>>1);
+ while(linpos+1<p->n){
+ float minV=seed[pos];
+ long end=((p->octave[linpos]+p->octave[linpos+1])>>1)-p->firstoc;
+ if(minV>p->vi->tone_abs_limit)minV=p->vi->tone_abs_limit;
+ while(pos+1<=end){
+ pos++;
+ if((seed[pos]>NEGINF && seed[pos]<minV) || minV==NEGINF)
+ minV=seed[pos];
+ }
+
+ /* seed scale is log. Floor is linear. Map back to it */
+ end=pos+p->firstoc;
+ for(;linpos<p->n && p->octave[linpos]<=end;linpos++)
+ if(flr[linpos]<minV)flr[linpos]=minV;
+ }
+
+ {
+ float minV=seed[p->total_octave_lines-1];
+ for(;linpos<p->n;linpos++)
+ if(flr[linpos]<minV)flr[linpos]=minV;
+ }
+
+}
+
+static void bark_noise_hybridmp(int n,const long *b,
+ const float *f,
+ float *noise,
+ const float offset,
+ const int fixed){
+ long i,hi=b[0]>>16,lo=b[0]>>16,hif=0,lof=0;
+ double xa=0,xb=0;
+ double ya=0,yb=0;
+ double x2a=0,x2b=0;
+ double y2a=0,y2b=0;
+ double xya=0,xyb=0;
+ double na=0,nb=0;
+
+ for(i=0;i<n;i++){
+ if(hi<n){
+ /* find new lo/hi */
+ int bi=b[i]&0xffffL;
+ for(;hi<bi;hi++){
+ int ii=(hi<0?-hi:hi);
+ double bin=(f[ii]<-offset?1.:f[ii]+offset);
+ double nn= bin*bin;
+ na += nn;
+ xa += hi*nn;
+ ya += bin*nn;
+ x2a += hi*hi*nn;
+ y2a += bin*bin*nn;
+ xya += hi*bin*nn;
+ }
+ bi=b[i]>>16;
+ for(;lo<bi;lo++){
+ int ii=(lo<0?-lo:lo);
+ double bin=(f[ii]<-offset?1.:f[ii]+offset);
+ double nn= bin*bin;
+ na -= nn;
+ xa -= lo*nn;
+ ya -= bin*nn;
+ x2a -= lo*lo*nn;
+ y2a -= bin*bin*nn;
+ xya -= lo*bin*nn;
+ }
+ }
+
+ if(hif<n && fixed>0){
+ int bi=i+fixed/2;
+ if(bi>n)bi=n;
+
+ for(;hif<bi;hif++){
+ int ii=(hif<0?-hif:hif);
+ double bin=(f[ii]<-offset?1.:f[ii]+offset);
+ double nn= bin*bin;
+ nb += nn;
+ xb += hif*nn;
+ yb += bin*nn;
+ x2b += hif*hif*nn;
+ y2b += bin*bin*nn;
+ xyb += hif*bin*nn;
+ }
+ bi=i-(fixed+1)/2;
+ for(;lof<bi;lof++){
+ int ii=(lof<0?-lof:lof);
+ double bin=(f[ii]<-offset?1.:f[ii]+offset);
+ double nn= bin*bin;
+ nb -= nn;
+ xb -= lof*nn;
+ yb -= bin*nn;
+ x2b -= lof*lof*nn;
+ y2b -= bin*bin*nn;
+ xyb -= lof*bin*nn;
+ }
+ }
+
+ {
+ double va=0.f;
+
+ if(na>2){
+ double denom=1./(na*x2a-xa*xa);
+ double a=(ya*x2a-xya*xa)*denom;
+ double b=(na*xya-xa*ya)*denom;
+ va=a+b*i;
+ }
+ if(va<0.)va=0.;
+
+ if(fixed>0){
+ double vb=0.f;
+
+ if(nb>2){
+ double denomf=1./(nb*x2b-xb*xb);
+ double af=(yb*x2b-xyb*xb)*denomf;
+ double bf=(nb*xyb-xb*yb)*denomf;
+ vb=af+bf*i;
+ }
+ if(vb<0.)vb=0.;
+ if(va>vb && vb>0.)va=vb;
+
+ }
+
+ noise[i]=va-offset;
+ }
+ }
+}
+
+
+void _vp_remove_floor(vorbis_look_psy *p,
+ vorbis_look_psy_global *g,
+ float *logmdct,
+ float *mdct,
+ float *codedflr,
+ float *residue,
+ float local_specmax){
+ int i,n=p->n;
+
+ for(i=0;i<n;i++)
+ if(mdct[i]!=0.f)
+ residue[i]=mdct[i]/codedflr[i];
+ else
+ residue[i]=0.f;
+}
+
+
+void _vp_compute_mask(vorbis_look_psy *p,
+ vorbis_look_psy_global *g,
+ int channel,
+ float *logfft,
+ float *logmdct,
+ float *logmask,
+ float global_specmax,
+ float local_specmax,
+ int lastsize){
+ int i,n=p->n;
+ static int seq=0;
+
+ float *seed=alloca(sizeof(*seed)*p->total_octave_lines);
+ for(i=0;i<p->total_octave_lines;i++)seed[i]=NEGINF;
+
+ /* noise masking */
+ if(p->vi->noisemaskp){
+ float *work=alloca(n*sizeof(*work));
+
+ bark_noise_hybridmp(n,p->bark,logmdct,logmask,
+ 140.,-1);
+
+ for(i=0;i<n;i++)work[i]=logmdct[i]-logmask[i];
+
+ bark_noise_hybridmp(n,p->bark,work,logmask,0.,
+ p->vi->noisewindowfixed);
+
+ for(i=0;i<n;i++)work[i]=logmdct[i]-work[i];
+
+ /* work[i] holds the median line (.5), logmask holds the upper
+ envelope line (1.) */
+
+ for(i=0;i<n;i++){
+ int dB=logmask[i]+.5;
+ if(dB>=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1;
+ logmask[i]= work[i]+p->vi->noisecompand[dB]+p->noiseoffset[i];
+ if(logmask[i]>p->vi->noisemaxsupp)logmask[i]=p->vi->noisemaxsupp;
+ }
+
+ }else{
+ for(i=0;i<n;i++)logmask[i]=NEGINF;
+ }
+
+ /* set the ATH (floating below localmax, not global max by a
+ specified att) */
+ if(p->vi->ath){
+ float att=local_specmax+p->vi->ath_adjatt;
+ if(att<p->vi->ath_maxatt)att=p->vi->ath_maxatt;
+
+ for(i=0;i<n;i++){
+ float av=p->ath[i]+att;
+ if(av>logmask[i])logmask[i]=av;
+ }
+ }
+
+ /* tone masking */
+ seed_loop(p,(const float ***)p->tonecurves,logfft,logmask,seed,global_specmax);
+ max_seeds(p,g,channel,seed,logmask);
+
+ /* doing this here is clean, but we need to find a faster way to do
+ it than to just tack it on */
+
+ for(i=0;i<n;i++)if(logmdct[i]>=logmask[i])break;
+ if(i==n)
+ for(i=0;i<n;i++)logmask[i]=NEGINF;
+ else
+ for(i=0;i<n;i++)
+ logfft[i]=max(logmdct[i],logfft[i]);
+
+ seq++;
+
+}
+
+float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){
+ vorbis_info *vi=vd->vi;
+ codec_setup_info *ci=vi->codec_setup;
+ vorbis_info_psy_global *gi=ci->psy_g_param;
+
+ int n=ci->blocksizes[vd->W]/2;
+ float secs=(float)n/vi->rate;
+
+ amp+=secs*gi->ampmax_att_per_sec;
+ if(amp<-9999)amp=-9999;
+ return(amp);
+}
+
+static void couple_lossless(float A, float B,
+ float granule,float igranule,
+ float *mag, float *ang){
+
+ A=rint(A*igranule)*granule;
+ B=rint(B*igranule)*granule;
+
+ if(fabs(A)>fabs(B)){
+ *mag=A; *ang=(A>0.f?A-B:B-A);
+ }else{
+ *mag=B; *ang=(B>0.f?A-B:B-A);
+ }
+
+ if(*ang>fabs(*mag)*1.9999f)*ang=-fabs(*mag)*2.f;
+
+}
+
+static void couple_8phase(float A, float B, float fA, float fB,
+ float granule,float igranule,
+ float fmag, float *mag, float *ang){
+
+ float origmag=FAST_HYPOT(A*fA,B*fB),corr;
+
+ if(fmag!=0.f){
+ float phase=rint((A-B)/fmag);
+
+ if(fabs(A)>fabs(B)){
+ *mag=A;phase=(A>0?phase:-phase);
+ }else{
+ *mag=B;phase=(B>0?phase:-phase);
+ }
+
+ switch((int)phase){
+ case 0:
+ corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB);
+ *mag=rint(*mag*corr*igranule)*granule;
+ *ang=0.f;
+ break;
+ case 1:
+ *mag=rint(*mag*igranule)*granule;
+ *ang=fabs(*mag);
+ break;
+ case -1:
+ *mag=rint(*mag*igranule)*granule;
+ *ang= -fabs(*mag);
+ break;
+ case -2:
+ corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB);
+ *mag=rint(*mag*corr*igranule)*granule;
+ *ang= -2.f*fabs(*mag);
+ break;
+ case 2:
+ corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB);
+ *mag= -rint(*mag*corr*igranule)*granule;
+ *ang= -2.f*fabs(*mag);
+ break;
+ }
+ }else{
+ *mag=0.f;
+ *ang=0.f;
+ }
+}
+
+static void couple_6phase(float A, float B, float fA, float fB,
+ float granule,float igranule,
+ float fmag, float *mag, float *ang){
+
+ float origmag=FAST_HYPOT(A*fA,B*fB),corr;
+
+ if(fmag!=0.f){
+ float phase=rint((A-B)/fmag);
+
+ if(fabs(A)>fabs(B)){
+ *mag=A;phase=(A>0?phase:-phase);
+ }else{
+ *mag=B;phase=(B>0?phase:-phase);
+ }
+
+ switch((int)phase){
+ case 0:
+ corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB);
+ *mag=rint(*mag*corr*igranule)*granule;
+ *ang=0.f;
+ break;
+ case 1:case 2:
+ *mag=rint(*mag*igranule)*granule;
+ *ang= fabs(*mag);
+ break;
+ case -1:case -2:
+ *mag=rint(*mag*igranule)*granule;
+ *ang= -fabs(*mag);
+ break;
+ default:
+ *mag=0.f;
+ *ang=0.f;
+
+ }
+ }else{
+ *mag=0.f;
+ *ang=0.f;
+ }
+}
+
+static void couple_4phase(float A, float B, float fA, float fB,
+ float granule,float igranule,
+ float fmag, float *mag, float *ang){
+
+ float origmag=FAST_HYPOT(A*fA,B*fB),corr;
+
+ if(fmag!=0.f){
+ float phase=rint((A-B)*.5/fmag);
+
+ if(fabs(A)>fabs(B)){
+ *mag=A;phase=(A>0?phase:-phase);
+ }else{
+ *mag=B;phase=(B>0?phase:-phase);
+ }
+
+ corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB);
+ *mag=rint(*mag*corr*igranule)*granule;
+ switch((int)phase){
+ case 0:
+ *ang=0.f;
+ break;
+ case -1:
+ *ang=-2.f*fabs(*mag);
+ break;
+ default:
+ *mag=-*mag;
+ *ang=-2.f*fabs(*mag);
+ break;
+ }
+ }else{
+ *mag=0.f;
+ *ang=0.f;
+ }
+}
+
+static void couple_point(float A, float B, float fA, float fB,
+ float granule,float igranule,
+ float fmag, float *mag, float *ang){
+
+ float origmag=FAST_HYPOT(A*fA,B*fB),corr;
+
+ if(fmag!=0.f){
+ //float phase=rint((A-B)*.5/fmag);
+
+ if(fabs(A)>fabs(B)){
+ *mag=A;//phase=(A>0?phase:-phase);
+ }else{
+ *mag=B;//phase=(B>0?phase:-phase);
+ }
+
+ //switch((int)phase){
+ //case 0:
+ corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB);
+ *mag=rint(*mag*corr*igranule)*granule;
+ *ang=0.f;
+ //break;
+ //default:
+ //*mag=0.f;
+ //*ang=0.f;
+ //break;
+ //}
+ }else{
+ *mag=0.f;
+ *ang=0.f;
+ }
+}
+
+
+void _vp_quantize_couple(vorbis_look_psy *p,
+ vorbis_info_mapping0 *vi,
+ float **pcm,
+ float **sofar,
+ float **quantized,
+ int *nonzero,
+ int passno){
+
+ int i,j,k,n=p->n;
+ vorbis_info_psy *info=p->vi;
+
+ /* perform any requested channel coupling */
+ for(i=0;i<vi->coupling_steps;i++){
+ float granulem=info->couple_pass[passno].granulem;
+ float igranulem=info->couple_pass[passno].igranulem;
+
+ /* make sure coupling a zero and a nonzero channel results in two
+ nonzero channels. */
+ if(nonzero[vi->coupling_mag[i]] ||
+ nonzero[vi->coupling_ang[i]]){
+
+ float *pcmM=pcm[vi->coupling_mag[i]];
+ float *pcmA=pcm[vi->coupling_ang[i]];
+ float *floorM=pcm[vi->coupling_mag[i]]+n;
+ float *floorA=pcm[vi->coupling_ang[i]]+n;
+ float *sofarM=sofar[vi->coupling_mag[i]];
+ float *sofarA=sofar[vi->coupling_ang[i]];
+ float *qM=quantized[vi->coupling_mag[i]];
+ float *qA=quantized[vi->coupling_ang[i]];
+
+ nonzero[vi->coupling_mag[i]]=1;
+ nonzero[vi->coupling_ang[i]]=1;
+
+ for(j=0,k=0;j<n;k++){
+ vp_couple *part=info->couple_pass[passno].couple_pass+k;
+
+ for(;j<part->limit && j<p->n;j++){
+ /* partition by partition; k is our by-location partition
+ class counter */
+ float ang,mag,fmag=max(fabs(pcmM[j]),fabs(pcmA[j]));
+
+ if(fmag<part->amppost_point){
+ couple_point(pcmM[j],pcmA[j],floorM[j],floorA[j],
+ granulem,igranulem,fmag,&mag,&ang);
+ }else{
+ if(fmag<part->amppost_6phase){
+ couple_6phase(pcmM[j],pcmA[j],floorM[j],floorA[j],
+ granulem,igranulem,fmag,&mag,&ang);
+ }else{
+ if(fmag<part->amppost_8phase){
+ couple_8phase(pcmM[j],pcmA[j],floorM[j],floorA[j],
+ granulem,igranulem,fmag,&mag,&ang);
+ }else{
+ couple_lossless(pcmM[j],pcmA[j],
+ granulem,igranulem,&mag,&ang);
+ }
+ }
+ }
+
+ qM[j]=mag-sofarM[j];
+ qA[j]=ang-sofarA[j];
+ }
+ }
+ }
+ }
+}
diff --git a/lib/res0.c b/lib/res0.c
index bef7cbf3..521ffb52 100644
--- a/lib/res0.c
+++ b/lib/res0.c
@@ -11,7 +11,7 @@
********************************************************************
function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.37.2.1 2001/10/09 04:34:45 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.37.2.2 2001/10/11 15:41:45 xiphmont Exp $
********************************************************************/
@@ -513,14 +513,6 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
long partialpass;
int stoppos=0;
- if((int)passlimit<ci->passlimit[pass]){
- wholepasses=passlimit;
- partialpass=rint((passlimit-wholepasses)*partvals);
- }else{
- wholepasses=ci->passlimit[pass];
- partialpass=0;
- }
-
#ifdef TRAIN_RES
FILE *of;
char buffer[80];
@@ -536,6 +528,14 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
}
#endif
+ if((int)passlimit<ci->passlimit[pass]){
+ wholepasses=passlimit;
+ partialpass=rint((passlimit-wholepasses)*partvals);
+ }else{
+ wholepasses=ci->passlimit[pass];
+ partialpass=0;
+ }
+
memset(resbits,0,sizeof(resbits));
memset(resvals,0,sizeof(resvals));
diff --git a/vq/latticehint.c b/vq/latticehint.c
new file mode 100644
index 00000000..14a1258c
--- /dev/null
+++ b/vq/latticehint.c
@@ -0,0 +1,430 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company http://www.xiph.org/ *
+
+ ********************************************************************
+
+ function: utility main for building thresh/pigeonhole encode hints
+ last mod: $Id: latticehint.c,v 1.10.4.1 2001/10/11 15:41:56 xiphmont Exp $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <errno.h>
+#include "../lib/scales.h"
+#include "bookutil.h"
+#include "vqgen.h"
+#include "vqsplit.h"
+
+/* The purpose of this util is to build encode hints for lattice
+ codebooks so that brute forcing each codebook entry isn't needed.
+ Threshhold hints are for books in which each scalar in the vector
+ is independant (eg, residue) and pigeonhole lookups provide a
+ minimum error fit for words where the scalars are interdependant
+ (each affecting the fit of the next in sequence) as in an LSP
+ sequential book (or can be used along with a sparse threshhold map,
+ like a splitting tree that need not be trained)
+
+ If the input book is non-sequential, a threshhold hint is built.
+ If the input book is sequential, a pigeonholing hist is built.
+ If the book is sparse, a pigeonholing hint is built, possibly in addition
+ to the threshhold hint
+
+ command line:
+ latticehint book.vqh [threshlist]
+
+ latticehint produces book.vqh on stdout */
+
+static int longsort(const void *a, const void *b){
+ return(**((long **)a)-**((long **)b));
+}
+
+static int addtosearch(int entry,long **tempstack,long *tempcount,int add){
+ long *ptr=tempstack[entry];
+ long i=tempcount[entry];
+
+ if(ptr){
+ while(i--)
+ if(*ptr++==add)return(0);
+ tempstack[entry]=_ogg_realloc(tempstack[entry],
+ (tempcount[entry]+1)*sizeof(long));
+ }else{
+ tempstack[entry]=_ogg_malloc(sizeof(long));
+ }
+
+ tempstack[entry][tempcount[entry]++]=add;
+ return(1);
+}
+
+static void setvals(int dim,encode_aux_pigeonhole *p,
+ long *temptrack,float *tempmin,float *tempmax,
+ int seqp){
+ int i;
+ float last=0.f;
+ for(i=0;i<dim;i++){
+ tempmin[i]=(temptrack[i])*p->del+p->min+last;
+ tempmax[i]=tempmin[i]+p->del;
+ if(seqp)last=tempmin[i];
+ }
+}
+
+/* note that things are currently set up such that input fits that
+ quantize outside the pigeonmap are dropped and brute-forced. So we
+ can ignore the <0 and >=n boundary cases in min/max error */
+
+static float minerror(int dim,float *a,encode_aux_pigeonhole *p,
+ long *temptrack,float *tempmin,float *tempmax){
+ int i;
+ float err=0.f;
+ for(i=0;i<dim;i++){
+ float eval=0.f;
+ if(a[i]<tempmin[i]){
+ eval=tempmin[i]-a[i];
+ }else if(a[i]>tempmax[i]){
+ eval=a[i]-tempmax[i];
+ }
+ err+=eval*eval;
+ }
+ return(err);
+}
+
+static float maxerror(int dim,float *a,encode_aux_pigeonhole *p,
+ long *temptrack,float *tempmin,float *tempmax){
+ int i;
+ float err=0.f,eval;
+ for(i=0;i<dim;i++){
+ if(a[i]<tempmin[i]){
+ eval=tempmax[i]-a[i];
+ }else if(a[i]>tempmax[i]){
+ eval=a[i]-tempmin[i];
+ }else{
+ float t1=a[i]-tempmin[i];
+ eval=tempmax[i]-a[i];
+ if(t1>eval)eval=t1;
+ }
+ err+=eval*eval;
+ }
+ return(err);
+}
+
+int main(int argc,char *argv[]){
+ codebook *b;
+ static_codebook *c;
+ int entries=-1,dim=-1;
+ float min,del;
+ char *name;
+ long i,j;
+ float *suggestions;
+ int suggcount=0;
+
+ if(argv[1]==NULL){
+ fprintf(stderr,"Need a lattice book on the command line.\n");
+ exit(1);
+ }
+
+ {
+ char *ptr;
+ char *filename=strdup(argv[1]);
+
+ b=codebook_load(filename);
+ c=(static_codebook *)(b->c);
+
+ ptr=strrchr(filename,'.');
+ if(ptr){
+ *ptr='\0';
+ name=strdup(filename);
+ }else{
+ name=strdup(filename);
+ }
+ }
+
+ if(c->maptype!=1){
+ fprintf(stderr,"Provided book is not a latticebook.\n");
+ exit(1);
+ }
+
+ entries=b->entries;
+ dim=b->dim;
+ min=_float32_unpack(c->q_min);
+ del=_float32_unpack(c->q_delta);
+
+ /* Do we want to gen a threshold hint? */
+ if(c->q_sequencep==0){
+ /* yes. Discard any preexisting threshhold hint */
+ long quantvals=_book_maptype1_quantvals(c);
+ long **quantsort=alloca(quantvals*sizeof(long *));
+ encode_aux_threshmatch *t=_ogg_calloc(1,sizeof(encode_aux_threshmatch));
+ c->thresh_tree=t;
+
+ fprintf(stderr,"Adding threshold hint to %s...\n",name);
+
+ /* partial/complete suggestions */
+ if(argv[2]){
+ char *ptr=strdup(argv[2]);
+ suggestions=alloca(sizeof(float)*quantvals);
+
+ for(suggcount=0;ptr && suggcount<quantvals;suggcount++){
+ char *ptr2=strchr(ptr,',');
+ if(ptr2)*ptr2++='\0';
+ suggestions[suggcount]=atof(ptr);
+ ptr=ptr2;
+ }
+ }
+
+ /* simplest possible threshold hint only */
+ t->quantthresh=_ogg_calloc(quantvals-1,sizeof(float));
+ t->quantmap=_ogg_calloc(quantvals,sizeof(int));
+ t->threshvals=quantvals;
+ t->quantvals=quantvals;
+
+ /* the quantvals may not be in order; sort em first */
+ for(i=0;i<quantvals;i++)quantsort[i]=c->quantlist+i;
+ qsort(quantsort,quantvals,sizeof(long *),longsort);
+
+ /* ok, gen the map and thresholds */
+ for(i=0;i<quantvals;i++)t->quantmap[i]=quantsort[i]-c->quantlist;
+ for(i=0;i<quantvals-1;i++){
+ float v1=*(quantsort[i])*del+min;
+ float v2=*(quantsort[i+1])*del+min;
+
+ for(j=0;j<suggcount;j++)
+ if(v1<suggestions[j] && suggestions[j]<v2){
+ t->quantthresh[i]=suggestions[j];
+ break;
+ }
+
+ if(j==suggcount){
+ t->quantthresh[i]=(v1+v2)*.5;
+ }
+ }
+ }
+
+ /* Do we want to gen a pigeonhole hint? */
+#if 0
+ for(i=0;i<entries;i++)if(c->lengthlist[i]==0)break;
+ if(c->q_sequencep || i<entries){
+ long **tempstack;
+ long *tempcount;
+ long *temptrack;
+ float *tempmin;
+ float *tempmax;
+ long totalstack=0;
+ long pigeons;
+ long subpigeons;
+ long quantvals=_book_maptype1_quantvals(c);
+ int changep=1,factor;
+
+ encode_aux_pigeonhole *p=_ogg_calloc(1,sizeof(encode_aux_pigeonhole));
+ c->pigeon_tree=p;
+
+ fprintf(stderr,"Adding pigeonhole hint to %s...\n",name);
+
+ /* the idea is that we quantize uniformly, even in a nonuniform
+ lattice, so that quantization of one scalar has a predictable
+ result on the next sequential scalar in a greedy matching
+ algorithm. We generate a lookup based on the quantization of
+ the vector (pigeonmap groups quantized entries together) and
+ list the entries that could possible be the best fit for any
+ given member of that pigeonhole. The encode process then has a
+ much smaller list to brute force */
+
+ /* find our pigeonhole-specific quantization values, fill in the
+ quant value->pigeonhole map */
+ factor=3;
+ p->del=del;
+ p->min=min;
+ p->quantvals=quantvals;
+ {
+ int max=0;
+ for(i=0;i<quantvals;i++)if(max<c->quantlist[i])max=c->quantlist[i];
+ p->mapentries=max;
+ }
+ p->pigeonmap=_ogg_malloc(p->mapentries*sizeof(long));
+ p->quantvals=(quantvals+factor-1)/factor;
+
+ /* pigeonhole roughly on the boundaries of the quantvals; the
+ exact pigeonhole grouping is an optimization issue, not a
+ correctness issue */
+ for(i=0;i<p->mapentries;i++){
+ float thisval=del*i+min; /* middle of the quant zone */
+ int quant=0;
+ float err=fabs(c->quantlist[0]*del+min-thisval);
+ for(j=1;j<quantvals;j++){
+ float thiserr=fabs(c->quantlist[j]*del+min-thisval);
+ if(thiserr<err){
+ quant=j/factor;
+ err=thiserr;
+ }
+ }
+ p->pigeonmap[i]=quant;
+ }
+
+ /* pigeonmap complete. Now do the grungy business of finding the
+ entries that could possibly be the best fit for a value appearing
+ in the pigeonhole. The trick that allows the below to work is the
+ uniform quantization; even though the scalars may be 'sequential'
+ (each a delta from the last), the uniform quantization means that
+ the error variance is *not* dependant. Given a pigeonhole and an
+ entry, we can find the minimum and maximum possible errors
+ (relative to the entry) for any point that could appear in the
+ pigeonhole */
+
+ /* must iterate over both pigeonholes and entries */
+ /* temporarily (in order to avoid thinking hard), we grow each
+ pigeonhole seperately, the build a stack of 'em later */
+ pigeons=1;
+ subpigeons=1;
+ for(i=0;i<dim;i++)subpigeons*=p->mapentries;
+ for(i=0;i<dim;i++)pigeons*=p->quantvals;
+ temptrack=_ogg_calloc(dim,sizeof(long));
+ tempmin=_ogg_calloc(dim,sizeof(float));
+ tempmax=_ogg_calloc(dim,sizeof(float));
+ tempstack=_ogg_calloc(pigeons,sizeof(long *));
+ tempcount=_ogg_calloc(pigeons,sizeof(long));
+
+ while(1){
+ float errorpost=-1;
+ char buffer[80];
+
+ /* map our current pigeonhole to a 'big pigeonhole' so we know
+ what list we're after */
+ int entry=0;
+ for(i=dim-1;i>=0;i--)entry=entry*p->quantvals+p->pigeonmap[temptrack[i]];
+ setvals(dim,p,temptrack,tempmin,tempmax,c->q_sequencep);
+ sprintf(buffer,"Building pigeonhole search list [%ld]...",totalstack);
+
+
+ /* Search all entries to find the one with the minimum possible
+ maximum error. Record that error */
+ for(i=0;i<entries;i++){
+ if(c->lengthlist[i]>0){
+ float this=maxerror(dim,b->valuelist+i*dim,p,
+ temptrack,tempmin,tempmax);
+ if(errorpost==-1 || this<errorpost)errorpost=this;
+ spinnit(buffer,subpigeons);
+ }
+ }
+
+ /* Our search list will contain all entries with a minimum
+ possible error <= our errorpost */
+ for(i=0;i<entries;i++)
+ if(c->lengthlist[i]>0){
+ spinnit(buffer,subpigeons);
+ if(minerror(dim,b->valuelist+i*dim,p,
+ temptrack,tempmin,tempmax)<errorpost)
+ totalstack+=addtosearch(entry,tempstack,tempcount,i);
+ }
+
+ for(i=0;i<dim;i++){
+ temptrack[i]++;
+ if(temptrack[i]<p->mapentries)break;
+ temptrack[i]=0;
+ }
+ if(i==dim)break;
+ subpigeons--;
+ }
+
+ fprintf(stderr,"\r "
+ "\rTotal search list size (all entries): %ld\n",totalstack);
+
+ /* pare the index of lists for improbable quantizations (where
+ improbable is determined by c->lengthlist; we assume that
+ pigeonholing is in sync with the codeword cells, which it is */
+ /*for(i=0;i<entries;i++){
+ float probability= 1.f/(1<<c->lengthlist[i]);
+ if(c->lengthlist[i]==0 || probability*entries<cutoff){
+ totalstack-=tempcount[i];
+ tempcount[i]=0;
+ }
+ }*/
+
+ /* pare the list of shortlists; merge contained and similar lists
+ together */
+ p->fitmap=_ogg_malloc(pigeons*sizeof(long));
+ for(i=0;i<pigeons;i++)p->fitmap[i]=-1;
+ while(changep){
+ char buffer[80];
+ changep=0;
+
+ for(i=0;i<pigeons;i++){
+ if(p->fitmap[i]<0 && tempcount[i]){
+ for(j=i+1;j<pigeons;j++){
+ if(p->fitmap[j]<0 && tempcount[j]){
+ /* is one list a superset, or are they sufficiently similar? */
+ int amiss=0,bmiss=0,ii,jj;
+ for(ii=0;ii<tempcount[i];ii++){
+ for(jj=0;jj<tempcount[j];jj++)
+ if(tempstack[i][ii]==tempstack[j][jj])break;
+ if(jj==tempcount[j])amiss++;
+ }
+ for(jj=0;jj<tempcount[j];jj++){
+ for(ii=0;ii<tempcount[i];ii++)
+ if(tempstack[i][ii]==tempstack[j][jj])break;
+ if(ii==tempcount[i])bmiss++;
+ }
+ if(amiss==0 ||
+ bmiss==0 ||
+ (amiss*2<tempcount[i] && bmiss*2<tempcount[j] &&
+ tempcount[i]+bmiss<entries/30)){
+
+ /*superset/similar Add all of one to the other. */
+ for(jj=0;jj<tempcount[j];jj++)
+ totalstack+=addtosearch(i,tempstack,tempcount,
+ tempstack[j][jj]);
+ totalstack-=tempcount[j];
+ p->fitmap[j]=i;
+ changep=1;
+ }
+ }
+ }
+ sprintf(buffer,"Consolidating [%ld total, %s]... ",totalstack,
+ changep?"reit":"nochange");
+ spinnit(buffer,pigeons-i);
+ }
+ }
+ }
+
+ /* repack the temp stack in final form */
+ fprintf(stderr,"\r "
+ "\rFinal total list size: %ld\n",totalstack);
+
+
+ p->fittotal=totalstack;
+ p->fitlist=_ogg_malloc((totalstack+1)*sizeof(long));
+ p->fitlength=_ogg_malloc(pigeons*sizeof(long));
+ {
+ long usage=0;
+ for(i=0;i<pigeons;i++){
+ if(p->fitmap[i]==-1){
+ if(tempcount[i])
+ memcpy(p->fitlist+usage,tempstack[i],tempcount[i]*sizeof(long));
+ p->fitmap[i]=usage;
+ p->fitlength[i]=tempcount[i];
+ usage+=tempcount[i];
+ if(usage>totalstack){
+ fprintf(stderr,"Internal error; usage>totalstack\n");
+ exit(1);
+ }
+ }else{
+ p->fitlength[i]=p->fitlength[p->fitmap[i]];
+ p->fitmap[i]=p->fitmap[p->fitmap[i]];
+ }
+ }
+ }
+ }
+#endif
+
+ write_codebook(stdout,name,c);
+ fprintf(stderr,"\r "
+ "\nDone.\n");
+ exit(0);
+}
diff --git a/vq/res_44c_A.vqs b/vq/res_44c_A.vqs
index d4ad4064..35c7fabd 100644
--- a/vq/res_44c_A.vqs
+++ b/vq/res_44c_A.vqs
@@ -9,13 +9,30 @@ huffbuild line_128x19_2sub1.vqd 1-9
huffbuild line_128x19_2sub2.vqd 9-25
huffbuild line_128x19_2sub3.vqd 25-64
+huffbuild line_1024x31_class0.vqd 0-8
+huffbuild line_1024x31_class1.vqd 0-16
+huffbuild line_1024x31_class2.vqd 0-64
+huffbuild line_1024x31_class3.vqd 0-64
+
+huffbuild line_1024x31_0sub0.vqd 0-16
+huffbuild line_1024x31_0sub1.vqd 16-64
+
+huffbuild line_1024x31_1sub0.vqd 0-16
+huffbuild line_1024x31_1sub1.vqd 16-64
+
+huffbuild line_1024x31_2sub1.vqd 1-9
+huffbuild line_1024x31_2sub2.vqd 9-25
+huffbuild line_1024x31_2sub3.vqd 25-64
+huffbuild line_1024x31_3sub1.vqd 1-9
+huffbuild line_1024x31_3sub2.vqd 9-25
+huffbuild line_1024x31_3sub3.vqd 25-64
+
residuesplit residue_0#0.vqd 0,192,16 res_A ,.7, ,1.5,8 ,1.5 ,2.5,3 ,2.5,8 ,2.5 ,4.5 ,17.5 ,84.5
mv res_Aaux.vqd res_44c_A_128aux.vqd
-residuesplit residue_1#0.vqd 0,1792,32 res_B ,.7, ,1.5,32 ,1.5 ,2.5,18 ,2.5,32 ,2.5 ,4.5 ,17.5 ,84.5
+residuesplit residue_1#0.vqd residue_1#1.vqd 0,1792,32 res_B ,.7, ,1.5,32 ,1.5 ,2.5,18 ,2.5,32 ,2.5 ,4.5 ,17.5 ,84.5
mv res_Baux.vqd res_44c_A_1024aux.vqd
-
GO
>res_Ac_128 noninterleaved
@@ -24,23 +41,28 @@ haux res_44c_A_128aux.vqd 0,12,2
>res_Ac noninterleaved
haux res_44c_A_1024aux.vqd 0,56,2
-:_1 res_B_1.vqd, 4, nonseq cull, 0 +- 1
-:_2 res_B_2.vqd, 4, nonseq cull, 0 +- 1
-:_3 res_B_3.vqd, 4, nonseq cull, 0 +- 1 2
-:_4 res_B_4.vqd, 4, nonseq cull, 0 +- 1 2
-:_5 res_B_5.vqd, 4, nonseq cull, 0 +- 1 2
-:_6 res_B_6.vqd, 2, nonseq cull, 0 +- 1 2 3 4
-:_7 res_B_7.vqd, 2, nonseq cull, 0 +- 5 10 15
+:_1 res_B_1A.vqd, 4, nonseq cull, 0 +- 1
+:_2 res_B_2A.vqd, 4, nonseq cull, 0 +- 1
+:_3 res_B_3A.vqd, 4, nonseq cull, 0 +- 1 2
+:_4 res_B_4A.vqd, 4, nonseq cull, 0 +- 1 2
+:_5 res_B_5A.vqd, 4, nonseq cull, 0 +- 1 2
+:_6 res_B_6A.vqd, 2, nonseq cull, 0 +- 1 2 3 4
+:_7 res_B_7A.vqd, 2, nonseq cull, 0 +- 5 10 15
+_7a, 4, nonseq cull, 0 +- 1 2
-:_8 res_B_8.vqd, 2, nonseq cull, 0 +- 13 26 39 52 65 78
+:_8 res_B_8A.vqd, 2, nonseq cull, 0 +- 13 26 39 52 65 78
+_8a, 2, nonseq cull, 0 +- 1 2 3 4 5 6
-:_9 res_B_9.vqd, 2, nonseq, 0 +- 169 338 507
+:_9 res_B_9A.vqd, 2, nonseq, 0 +- 169 338 507
+_9a, 2, nonseq, 0 +- 13 26 39 52 65 78
+_9b, 2, nonseq, 0 +- 1 2 3 4 5 6
+:_0a res_B_0B.vqd, 4, nonseq cull, 0 +- 1 2
+:_2a res_B_2B.vqd, 2, nonseq cull, 0 +- 1 2 3
+:_5a res_B_5B.vqd, 2, nonseq cull, 0 +- 1 2 3 4
+:_7b res_B_7B.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6
+
diff --git a/vq/residuesplit.c b/vq/residuesplit.c
new file mode 100644
index 00000000..d8df5353
--- /dev/null
+++ b/vq/residuesplit.c
@@ -0,0 +1,282 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company http://www.xiph.org/ *
+
+ ********************************************************************
+
+ function: residue backend 0 partitioner/classifier
+ last mod: $Id: residuesplit.c,v 1.11.4.1 2001/10/11 15:41:56 xiphmont Exp $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <stdio.h>
+#include "bookutil.h"
+
+/* does not guard against invalid settings; eg, a subn of 16 and a
+ subgroup request of 32. Max subn of 128 */
+static float _testhack(float *vec,int n){
+ int i,j=0;
+ float max=0.f;
+ float temp[128];
+ float entropy=0.;
+
+ /* setup */
+ for(i=0;i<n;i++)temp[i]=fabs(vec[i]);
+
+ /* handle case subgrp==1 outside */
+ for(i=0;i<n;i++)
+ if(temp[i]>max)max=temp[i];
+
+ for(i=0;i<n;i++)temp[i]=rint(temp[i]);
+
+ for(i=0;i<n;i++)
+ entropy+=temp[i];
+ return entropy;
+
+ /*while(1){
+ entropy[j]=max;
+ n>>=1;
+ j++;
+
+ if(n<=0)break;
+ for(i=0;i<n;i++){
+ temp[i]+=temp[i+n];
+ }
+ max=0.f;
+ for(i=0;i<n;i++)
+ if(temp[i]>max)max=temp[i];
+ }*/
+}
+
+static FILE *of;
+static FILE **or;
+
+/* we evaluate the the entropy measure for each interleaved subgroup */
+/* This is currently a bit specific to/hardwired for mapping 0; things
+ will need to change in the future when we get real multichannel
+ mappings */
+int quantaux(float *res,int n,float *ebound,float *mbound,int *subgrp,int parts, int subn,
+ int *class){
+ long i,j,part=0;
+ int aux;
+
+ for(i=0;i<=n-subn;i+=subn,part++){
+ float max=0.f;
+ float lentropy=0.f;
+
+ lentropy=_testhack(res+i,subn);
+
+ for(j=0;j<subn;j++)
+ if(fabs(res[i+j])>max)max=fabs(res[i+j]);
+
+ for(j=0;j<parts-1;j++)
+ if(lentropy<=ebound[j] &&
+ max<=mbound[j] &&
+ part<subgrp[j])
+ break;
+ class[part]=aux=j;
+
+ fprintf(of,"%d, ",aux);
+ }
+ fprintf(of,"\n");
+
+ return(0);
+}
+
+int quantwrite(float *res,int n,int subn, int *class,int offset){
+ long i,j,part=0;
+ int aux;
+
+ for(i=0;i<=n-subn;i+=subn,part++){
+ aux=class[part];
+
+ for(j=0;j<subn;j++)
+ fprintf(or[aux+offset],"%g, ",res[j+i]);
+
+ fprintf(or[aux+offset],"\n");
+ }
+
+ return(0);
+}
+
+static int getline(FILE *in,float *vec,int begin,int n){
+ int i,next=0;
+
+ reset_next_value();
+ if(get_next_value(in,vec))return(0);
+ if(begin){
+ for(i=1;i<begin;i++)
+ get_line_value(in,vec);
+ next=0;
+ }else{
+ next=1;
+ }
+
+ for(i=next;i<n;i++)
+ if(get_line_value(in,vec+i)){
+ fprintf(stderr,"ran out of columns in input data\n");
+ exit(1);
+ }
+
+ return(1);
+}
+
+static void usage(){
+ fprintf(stderr,
+ "usage:\n"
+ "residuesplit <res> [<res>] <begin,n,group> <baseout> <ent,peak,sub> [<ent,peak,sub>]...\n"
+ " where begin,n,group is first scalar, \n"
+ " number of scalars of each in line,\n"
+ " number of scalars in a group\n"
+ " ent is the maximum entropy value allowed for membership in a group\n"
+ " peak is the maximum amplitude value allowed for membership in a group\n"
+ " subn is the maximum subpartiton number allowed in the group\n\n");
+ exit(1);
+}
+
+int main(int argc, char *argv[]){
+ char *buffer;
+ char *base;
+ int i,j,parts,begin,n,subn,*subgrp,*class;
+ FILE **res;
+ int resfiles=0;
+ float *ebound,*mbound,*vec;
+ long c=0;
+ if(argc<5)usage();
+
+ /* count the res file names, open the files */
+ while(!strcmp(argv[resfiles+1]+strlen(argv[resfiles+1])-4,".vqd"))
+ resfiles++;
+ if(resfiles<1)usage();
+
+ res=alloca(sizeof(*res)*resfiles);
+ for(i=0;i<resfiles;i++){
+ res[i]=fopen(argv[i+1],"r");
+ if(!(res+i)){
+ fprintf(stderr,"Could not open file %s\n",argv[1+i]);
+ exit(1);
+ }
+ }
+
+ base=strdup(argv[2+resfiles]);
+ buffer=alloca(strlen(base)+20);
+ {
+ char *pos=strchr(argv[1+resfiles],',');
+ begin=atoi(argv[1+resfiles]);
+ if(!pos)
+ usage();
+ else
+ n=atoi(pos+1);
+ pos=strchr(pos+1,',');
+ if(!pos)
+ usage();
+ else
+ subn=atoi(pos+1);
+ if(n/subn*subn != n){
+ fprintf(stderr,"n must be divisible by group\n");
+ exit(1);
+ }
+ }
+
+ /* how many parts?... */
+ parts=argc-resfiles-2;
+
+ ebound=_ogg_malloc(sizeof(float)*parts);
+ mbound=_ogg_malloc(sizeof(float)*parts);
+ subgrp=_ogg_malloc(sizeof(int)*parts);
+
+ for(i=0;i<parts-1;i++){
+ char *pos=strchr(argv[3+i+resfiles],',');
+ subgrp[i]=0;
+ if(*argv[3+i+resfiles]==',')
+ ebound[i]=1e50f;
+ else
+ ebound[i]=atof(argv[3+i+resfiles]);
+
+ if(!pos){
+ mbound[i]=1e50f;
+ }else{
+ if(*(pos+1)==',')
+ mbound[i]=1e50f;
+ else
+ mbound[i]=atof(pos+1);
+ pos=strchr(pos+1,',');
+
+ if(pos)
+ subgrp[i]=atoi(pos+1);
+
+ }
+ if(subgrp[i]<=0)subgrp[i]=99999;
+ }
+
+ ebound[i]=1e50f;
+ mbound[i]=1e50f;
+ subgrp[i]=9999999;
+
+ or=alloca(parts*resfiles*sizeof(FILE*));
+ sprintf(buffer,"%saux.vqd",base);
+ of=fopen(buffer,"w");
+ if(!of){
+ fprintf(stderr,"Could not open file %s for writing\n",buffer);
+ exit(1);
+ }
+
+ for(j=0;j<resfiles;j++){
+ for(i=0;i<parts;i++){
+ sprintf(buffer,"%s_%d%c.vqd",base,i,j+65);
+ or[i+j*parts]=fopen(buffer,"w");
+ if(!or[i+j*parts]){
+ fprintf(stderr,"Could not open file %s for writing\n",buffer);
+ exit(1);
+ }
+ }
+ }
+
+ vec=_ogg_malloc(sizeof(float)*n);
+ class=_ogg_malloc(sizeof(float)*n);
+ /* get the input line by line and process it */
+ while(1){
+ if(getline(res[0],vec,begin,n)){
+ quantaux(vec,n,ebound,mbound,subgrp,parts,subn,class);
+ quantwrite(vec,n,subn,class,0);
+
+ for(i=1;i<resfiles;i++){
+ if(getline(res[i],vec,begin,n)){
+ quantwrite(vec,n,subn,class,parts*i);
+ }else{
+ fprintf(stderr,"Getline loss of sync (%d).\n\n",i);
+ exit(1);
+ }
+ }
+ }else{
+ if(feof(res[0]))break;
+ fprintf(stderr,"Getline loss of sync (0).\n\n");
+ exit(1);
+ }
+
+ c++;
+ if(!(c&0xf)){
+ spinnit("kB so far...",(int)(ftell(res[0])/1024));
+ }
+ }
+ for(i=0;i<resfiles;i++)
+ fclose(res[i]);
+ fclose(of);
+ for(i=0;i<parts*resfiles;i++)
+ fclose(or[i]);
+ fprintf(stderr,"\rDone \n");
+ return(0);
+}
+
+
+
+