summaryrefslogtreecommitdiff
path: root/songdbj/de/jarnbjo/vorbis/Mode.java
blob: ab88944a2539fb0d53dc69dcf0f04244d1d41505 (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
/*
 * $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 Mode {

   private boolean blockFlag;
   private int windowType, transformType, mapping;

   protected Mode(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
      blockFlag=source.getBit();
      windowType=source.getInt(16);
      transformType=source.getInt(16);
      mapping=source.getInt(8);

      if(windowType!=0) {
         throw new VorbisFormatException("Window type = "+windowType+", != 0");
      }

      if(transformType!=0) {
         throw new VorbisFormatException("Transform type = "+transformType+", != 0");
      }

      if(mapping>header.getMappings().length) {
         throw new VorbisFormatException("Mode mapping number is higher than total number of mappings.");
      }
   }

   protected boolean getBlockFlag() {
      return blockFlag;
   }

   protected int getWindowType() {
      return windowType;
   }

   protected int getTransformType() {
      return transformType;
   }

   protected int getMapping() {
      return mapping;
   }
}