diff options
Diffstat (limited to 'songdbj/de/jarnbjo/vorbis/Residue2.java')
-rw-r--r-- | songdbj/de/jarnbjo/vorbis/Residue2.java | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/songdbj/de/jarnbjo/vorbis/Residue2.java b/songdbj/de/jarnbjo/vorbis/Residue2.java new file mode 100644 index 0000000000..666d2cd017 --- /dev/null +++ b/songdbj/de/jarnbjo/vorbis/Residue2.java | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * $ProjectName$ | ||
3 | * $ProjectRevision$ | ||
4 | * ----------------------------------------------------------- | ||
5 | * $Id$ | ||
6 | * ----------------------------------------------------------- | ||
7 | * | ||
8 | * $Author$ | ||
9 | * | ||
10 | * Description: | ||
11 | * | ||
12 | * Copyright 2002-2003 Tor-Einar Jarnbjo | ||
13 | * ----------------------------------------------------------- | ||
14 | * | ||
15 | * Change History | ||
16 | * ----------------------------------------------------------- | ||
17 | * $Log$ | ||
18 | * Revision 1.1 2005/07/11 15:42:36 hcl | ||
19 | * Songdb java version, source. only 1.5 compatible | ||
20 | * | ||
21 | * Revision 1.2 2004/09/21 06:39:06 shred | ||
22 | * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-) | ||
23 | * | ||
24 | * Revision 1.1.1.1 2004/04/04 22:09:12 shred | ||
25 | * First Import | ||
26 | * | ||
27 | * Revision 1.2 2003/03/16 01:11:12 jarnbjo | ||
28 | * no message | ||
29 | * | ||
30 | * | ||
31 | */ | ||
32 | |||
33 | package de.jarnbjo.vorbis; | ||
34 | |||
35 | import java.io.IOException; | ||
36 | |||
37 | import de.jarnbjo.util.io.BitInputStream; | ||
38 | |||
39 | class Residue2 extends Residue { | ||
40 | |||
41 | private double[][] decodedVectors; | ||
42 | |||
43 | private Residue2() { | ||
44 | } | ||
45 | |||
46 | protected Residue2(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException { | ||
47 | super(source, header); | ||
48 | } | ||
49 | |||
50 | protected int getType() { | ||
51 | return 2; | ||
52 | } | ||
53 | |||
54 | protected void decodeResidue(VorbisStream vorbis, BitInputStream source, Mode mode, int ch, boolean[] doNotDecodeFlags, float[][] vectors) throws VorbisFormatException, IOException { | ||
55 | |||
56 | Look look=getLook(vorbis, mode); | ||
57 | |||
58 | CodeBook codeBook=vorbis.getSetupHeader().getCodeBooks()[getClassBook()]; | ||
59 | |||
60 | int classvalsPerCodeword=codeBook.getDimensions(); | ||
61 | int nToRead=getEnd()-getBegin(); | ||
62 | int partitionsToRead=nToRead/getPartitionSize(); // partvals | ||
63 | |||
64 | int samplesPerPartition=getPartitionSize(); | ||
65 | int partitionsPerWord=look.getPhraseBook().getDimensions(); | ||
66 | |||
67 | int partWords=(partitionsToRead+partitionsPerWord-1)/partitionsPerWord; | ||
68 | |||
69 | int realCh=0; | ||
70 | for(int i=0; i<doNotDecodeFlags.length; i++) { | ||
71 | if(!doNotDecodeFlags[i]) { | ||
72 | realCh++; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | float[][] realVectors=new float[realCh][]; | ||
77 | |||
78 | realCh=0; | ||
79 | for(int i=0; i<doNotDecodeFlags.length; i++) { | ||
80 | if(!doNotDecodeFlags[i]) { | ||
81 | realVectors[realCh++]=vectors[i]; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | int[][] partword=new int[partWords][]; | ||
86 | for(int s=0;s<look.getStages();s++){ | ||
87 | for(int i=0,l=0;i<partitionsToRead;l++){ | ||
88 | if(s==0){ | ||
89 | //int temp=look.getPhraseBook().readInt(source); | ||
90 | int temp=source.getInt(look.getPhraseBook().getHuffmanRoot()); | ||
91 | if(temp==-1){ | ||
92 | throw new VorbisFormatException(""); | ||
93 | } | ||
94 | partword[l]=look.getDecodeMap()[temp]; | ||
95 | if(partword[l]==null){ | ||
96 | throw new VorbisFormatException(""); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | for(int k=0;k<partitionsPerWord && i<partitionsToRead;k++,i++){ | ||
101 | int offset=begin+i*samplesPerPartition; | ||
102 | if((cascade[partword[l][k]]&(1<<s))!=0){ | ||
103 | CodeBook stagebook=vorbis.getSetupHeader().getCodeBooks()[look.getPartBooks()[partword[l][k]][s]]; | ||
104 | if(stagebook!=null){ | ||
105 | stagebook.readVvAdd(realVectors, source, offset, samplesPerPartition); | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | |||
114 | public Object clone() { | ||
115 | Residue2 clone=new Residue2(); | ||
116 | fill(clone); | ||
117 | return clone; | ||
118 | } | ||
119 | |||
120 | protected double[][] getDecodedVectors() { | ||
121 | return decodedVectors; | ||
122 | } | ||
123 | } \ No newline at end of file | ||