blob: 56e400f348df97d6d81d6efd8ea26f784eec56cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/*
* $ProjectName$
* $ProjectRevision$
* -----------------------------------------------------------
* $Id$
* -----------------------------------------------------------
*
* $Author$
*
* Description:
*
* Copyright 2002-2003 Tor-Einar Jarnbjo
* -----------------------------------------------------------
*
* Change History
* -----------------------------------------------------------
* $Log$
* Revision 1.1 2005/07/11 15:42:36 hcl
* Songdb java version, source. only 1.5 compatible
*
* Revision 1.1.1.1 2004/04/04 22:09:12 shred
* First Import
*
* Revision 1.2 2003/03/16 01:11:12 jarnbjo
* no message
*
*
*/
package de.jarnbjo.vorbis;
import java.io.*;
import de.jarnbjo.util.io.*;
class SetupHeader {
private static final long HEADER = 0x736962726f76L; // 'vorbis'
private CodeBook[] codeBooks;
private Floor[] floors;
private Residue[] residues;
private Mapping[] mappings;
private Mode[] modes;
public SetupHeader(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException {
if(source.getLong(48)!=HEADER) {
throw new VorbisFormatException("The setup header has an illegal leading.");
}
// read code books
int codeBookCount=source.getInt(8)+1;
codeBooks=new CodeBook[codeBookCount];
for(int i=0; i<codeBooks.length; i++) {
codeBooks[i]=new CodeBook(source);
}
// read the time domain transformations,
// these should all be 0
int timeCount=source.getInt(6)+1;
for(int i=0; i<timeCount; i++) {
if(source.getInt(16)!=0) {
throw new VorbisFormatException("Time domain transformation != 0");
}
}
// read floor entries
int floorCount=source.getInt(6)+1;
floors=new Floor[floorCount];
for(int i=0; i<floorCount; i++) {
floors[i]=Floor.createInstance(source, this);
}
// read residue entries
int residueCount=source.getInt(6)+1;
residues=new Residue[residueCount];
for(int i=0; i<residueCount; i++) {
residues[i]=Residue.createInstance(source, this);
}
// read mapping entries
int mappingCount=source.getInt(6)+1;
mappings=new Mapping[mappingCount];
for(int i=0; i<mappingCount; i++) {
mappings[i]=Mapping.createInstance(vorbis, source, this);
}
// read mode entries
int modeCount=source.getInt(6)+1;
modes=new Mode[modeCount];
for(int i=0; i<modeCount; i++) {
modes[i]=new Mode(source, this);
}
if(!source.getBit()) {
throw new VorbisFormatException("The setup header framing bit is incorrect.");
}
}
public CodeBook[] getCodeBooks() {
return codeBooks;
}
public Floor[] getFloors() {
return floors;
}
public Residue[] getResidues() {
return residues;
}
public Mapping[] getMappings() {
return mappings;
}
public Mode[] getModes() {
return modes;
}
}
|