summaryrefslogtreecommitdiff
path: root/songdbj/de/jarnbjo/vorbis/SetupHeader.java
diff options
context:
space:
mode:
Diffstat (limited to 'songdbj/de/jarnbjo/vorbis/SetupHeader.java')
-rw-r--r--songdbj/de/jarnbjo/vorbis/SetupHeader.java131
1 files changed, 131 insertions, 0 deletions
diff --git a/songdbj/de/jarnbjo/vorbis/SetupHeader.java b/songdbj/de/jarnbjo/vorbis/SetupHeader.java
new file mode 100644
index 0000000000..56e400f348
--- /dev/null
+++ b/songdbj/de/jarnbjo/vorbis/SetupHeader.java
@@ -0,0 +1,131 @@
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.1.1.1 2004/04/04 22:09:12 shred
22 * First Import
23 *
24 * Revision 1.2 2003/03/16 01:11:12 jarnbjo
25 * no message
26 *
27 *
28 */
29
30package de.jarnbjo.vorbis;
31
32import java.io.*;
33
34import de.jarnbjo.util.io.*;
35
36class SetupHeader {
37
38 private static final long HEADER = 0x736962726f76L; // 'vorbis'
39
40 private CodeBook[] codeBooks;
41 private Floor[] floors;
42 private Residue[] residues;
43 private Mapping[] mappings;
44 private Mode[] modes;
45
46 public SetupHeader(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException {
47
48 if(source.getLong(48)!=HEADER) {
49 throw new VorbisFormatException("The setup header has an illegal leading.");
50 }
51
52 // read code books
53
54 int codeBookCount=source.getInt(8)+1;
55 codeBooks=new CodeBook[codeBookCount];
56
57 for(int i=0; i<codeBooks.length; i++) {
58 codeBooks[i]=new CodeBook(source);
59 }
60
61 // read the time domain transformations,
62 // these should all be 0
63
64 int timeCount=source.getInt(6)+1;
65 for(int i=0; i<timeCount; i++) {
66 if(source.getInt(16)!=0) {
67 throw new VorbisFormatException("Time domain transformation != 0");
68 }
69 }
70
71 // read floor entries
72
73 int floorCount=source.getInt(6)+1;
74 floors=new Floor[floorCount];
75
76 for(int i=0; i<floorCount; i++) {
77 floors[i]=Floor.createInstance(source, this);
78 }
79
80 // read residue entries
81
82 int residueCount=source.getInt(6)+1;
83 residues=new Residue[residueCount];
84
85 for(int i=0; i<residueCount; i++) {
86 residues[i]=Residue.createInstance(source, this);
87 }
88
89 // read mapping entries
90
91 int mappingCount=source.getInt(6)+1;
92 mappings=new Mapping[mappingCount];
93
94 for(int i=0; i<mappingCount; i++) {
95 mappings[i]=Mapping.createInstance(vorbis, source, this);
96 }
97
98 // read mode entries
99
100 int modeCount=source.getInt(6)+1;
101 modes=new Mode[modeCount];
102
103 for(int i=0; i<modeCount; i++) {
104 modes[i]=new Mode(source, this);
105 }
106
107 if(!source.getBit()) {
108 throw new VorbisFormatException("The setup header framing bit is incorrect.");
109 }
110 }
111
112 public CodeBook[] getCodeBooks() {
113 return codeBooks;
114 }
115
116 public Floor[] getFloors() {
117 return floors;
118 }
119
120 public Residue[] getResidues() {
121 return residues;
122 }
123
124 public Mapping[] getMappings() {
125 return mappings;
126 }
127
128 public Mode[] getModes() {
129 return modes;
130 }
131} \ No newline at end of file