de.jarnbjo.vorbis.Floor1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sound Show documentation
Show all versions of sound Show documentation
Etyl's default sound module
/*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id: Floor1.java,v 1.2 2003/03/16 01:11:12 jarnbjo Exp $multip
* -----------------------------------------------------------
*
* $Author: jarnbjo $
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log: Floor1.java,v $
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
import java.io.IOException;
import java.util.*;
import de.jarnbjo.util.io.BitInputStream;
public class Floor1 extends Floor implements Cloneable {
private int[] partitionClassList;
private int maximumClass, multiplier, rangeBits;
private int[] classDimensions;
private int[] classSubclasses;
private int[] classMasterbooks;
private int[][] subclassBooks;
private int[] xList;
private int[] yList;
private int[] lowNeighbours, highNeighbours;
//private boolean[] step2Flags;
private static final int[] RANGES = {256, 128, 86, 64};
private Floor1() {
}
protected Floor1(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
maximumClass=-1;
int partitions=source.getInt(5);
partitionClassList=new int[partitions];
for(int i=0; imaximumClass) {
maximumClass=partitionClassList[i];
}
}
classDimensions=new int[maximumClass+1];
classSubclasses=new int[maximumClass+1];
classMasterbooks=new int[maximumClass+1];
subclassBooks=new int[maximumClass+1][];
int xListLength=2;
for(int i=0; i<=maximumClass; i++) {
classDimensions[i]=source.getInt(3)+1;
xListLength+=classDimensions[i];
classSubclasses[i]=source.getInt(2);
if(classDimensions[i] > header.getCodeBooks().length ||
classSubclasses[i] > header.getCodeBooks().length) {
throw new VorbisFormatException("There is a class dimension or class subclasses entry higher than the number of codebooks in the setup header.");
}
if(classSubclasses[i]!=0) {
classMasterbooks[i]=source.getInt(8);
}
subclassBooks[i]=new int[1<0) {
cval=source.getInt(vorbis.getSetupHeader().getCodeBooks()[classMasterbooks[cls]].getHuffmanRoot());
//cval=vorbis.getSetupHeader().getCodeBooks()[classMasterbooks[cls]].readInt(source);
//System.out.println("cval: "+cval);
}
//System.out.println("0: "+cls+" "+cdim+" "+cbits+" "+csub+" "+cval);
for(int j=0; j>>=cbits;
if(book>=0) {
clone.yList[j+offset]=source.getInt(vorbis.getSetupHeader().getCodeBooks()[book].getHuffmanRoot());
//clone.yList[j+offset]=vorbis.getSetupHeader().getCodeBooks()[book].readInt(source);
//System.out.println("b: "+(j+offset)+" "+book+" "+clone.yList[j+offset]);
//System.out.println("");
}
else {
clone.yList[j+offset]=0;
}
}
offset+=cdim;
}
//System.out.println("");
//for(int i=0; i=room) {
yList[i]=highRoom>lowRoom?
val-lowRoom+predicted:
-val+highRoom+predicted-1;
}
else {
yList[i]=(val&1)==1?
predicted-((val+1)>>1):
predicted+(val>>1);
}
}
else {
step2Flags[i]=false;
yList[i]=predicted;
}
}
final int[] xList2=new int[values];
System.arraycopy(xList, 0, xList2, 0, values);
sort(xList2, yList, step2Flags);
int hx=0, hy=0, lx=0, ly=yList[0]*multiplier;
float[] vector2=new float[vector.length];
float[] vector3=new float[vector.length];
Arrays.fill(vector2, 1.0f);
System.arraycopy(vector, 0, vector3, 0, vector.length);
for(int i=1; ioff && x[j-1]>x[j]; j--) {
itmp=x[j];
x[j]=x[j-1];
x[j-1]=itmp;
itmp=y[j];
y[j]=y[j-1];
y[j-1]=itmp;
btmp=b[j];
b[j]=b[j-1];
b[j-1]=btmp;
//swap(x, j, j-1);
//swap(y, j, j-1);
//swap(b, j, j-1);
}
}
}
private final static void swap(int x[], int a, int b) {
int t = x[a];
x[a] = x[b];
x[b] = t;
}
private final static void swap(boolean x[], int a, int b) {
boolean t = x[a];
x[a] = x[b];
x[b] = t;
}
}