summaryrefslogtreecommitdiff
path: root/songdbj/de/jarnbjo/vorbis/IdentificationHeader.java
blob: 1e18163385e5d5838e94d6942f8586a7c6597cbe (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
/*
 * $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.2  2004/09/21 06:39:06  shred
 * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
 *
 * Revision 1.1.1.1  2004/04/04 22:09:12  shred
 * First Import
 *
 * Revision 1.3  2003/03/31 00:20:16  jarnbjo
 * no message
 *
 * Revision 1.2  2003/03/16 01:11:12  jarnbjo
 * no message
 *
 *
 */

package de.jarnbjo.vorbis;

import java.io.IOException;

import de.jarnbjo.util.io.BitInputStream;

/**
 */

public class IdentificationHeader {

   private int version, channels, sampleRate, bitrateMaximum, bitrateNominal, bitrateMinimum, blockSize0, blockSize1;
   private boolean framingFlag;
   private MdctFloat[] mdct=new MdctFloat[2];
   //private MdctLong[] mdctInt=new MdctLong[2];

   private static final long HEADER = 0x736962726f76L; // 'vorbis'

   public IdentificationHeader(BitInputStream source) throws VorbisFormatException, IOException {
      //equalizer=new Equalizer();
      //equalizer.pack();
      //equalizer.show();

      long leading=source.getLong(48);
      if(leading!=HEADER) {
         throw new VorbisFormatException("The identification header has an illegal leading.");
      }
      version=source.getInt(32);
      channels=source.getInt(8);
      sampleRate=source.getInt(32);
      bitrateMaximum=source.getInt(32);
      bitrateNominal=source.getInt(32);
      bitrateMinimum=source.getInt(32);
      int bs=source.getInt(8);
      blockSize0=1<<(bs&0xf);
      blockSize1=1<<(bs>>4);

      mdct[0]=new MdctFloat(blockSize0);
      mdct[1]=new MdctFloat(blockSize1);
      //mdctInt[0]=new MdctLong(blockSize0);
      //mdctInt[1]=new MdctLong(blockSize1);

      framingFlag=source.getInt(8)!=0;
   }

   public int getSampleRate() {
      return sampleRate;
   }

   public int getMaximumBitrate() {
      return bitrateMaximum;
   }

   public int getNominalBitrate() {
      return bitrateNominal;
   }

   public int getMinimumBitrate() {
      return bitrateMinimum;
   }

   public int getChannels() {
      return channels;
   }

   public int getBlockSize0() {
      return blockSize0;
   }

   public int getBlockSize1() {
      return blockSize1;
   }

   protected MdctFloat getMdct0() {
      return mdct[0];
   }

   protected MdctFloat getMdct1() {
      return mdct[1];
   }

   public int getVersion() {
      return version;
   }
}