author | serb |
Sun, 09 Jun 2019 14:12:18 -0700 | |
changeset 55364 | 13ec0d88815b |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
55364
13ec0d88815b
8222083: Support of "64-bit IEEE floating point" encoding for the AU file format
serb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.media.sound; |
|
27 |
||
28 |
import javax.sound.sampled.AudioFileFormat; |
|
29 |
import javax.sound.sampled.AudioFormat; |
|
30 |
||
31 |
/** |
|
32 |
* AU file format. |
|
33 |
* |
|
34 |
* @author Jan Borgersen |
|
35 |
*/ |
|
38399
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
36 |
final class AuFileFormat extends StandardFileFormat { |
2 | 37 |
|
38 |
// magic numbers |
|
35656 | 39 |
static final int AU_SUN_MAGIC = 0x2e736e64; // ".snd" |
2 | 40 |
|
41 |
// encodings |
|
42 |
static final int AU_ULAW_8 = 1; /* 8-bit ISDN u-law */ |
|
43 |
static final int AU_LINEAR_8 = 2; /* 8-bit linear PCM */ |
|
44 |
static final int AU_LINEAR_16 = 3; /* 16-bit linear PCM */ |
|
45 |
static final int AU_LINEAR_24 = 4; /* 24-bit linear PCM */ |
|
46 |
static final int AU_LINEAR_32 = 5; /* 32-bit linear PCM */ |
|
47 |
static final int AU_FLOAT = 6; /* 32-bit IEEE floating point */ |
|
55364
13ec0d88815b
8222083: Support of "64-bit IEEE floating point" encoding for the AU file format
serb
parents:
47216
diff
changeset
|
48 |
static final int AU_DOUBLE = 7; /* 64-bit IEEE floating point */ |
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
49 |
// we don't support these ... |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
50 |
// static final int AU_ADPCM_G721 = 23; /* 4-bit CCITT g.721 ADPCM */ |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
51 |
// static final int AU_ADPCM_G722 = 24; /* CCITT g.722 ADPCM */ |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
52 |
// static final int AU_ADPCM_G723_3 = 25; /* CCITT g.723 3-bit ADPCM */ |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
53 |
// static final int AU_ADPCM_G723_5 = 26; /* CCITT g.723 5-bit ADPCM */ |
2 | 54 |
static final int AU_ALAW_8 = 27; /* 8-bit ISDN A-law */ |
55 |
||
56 |
static final int AU_HEADERSIZE = 24; |
|
57 |
||
38399
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
58 |
/** |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
59 |
* According the specification of AU file format this is the value for |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
60 |
* length field if length is not known. This is a maximum possible value for |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
61 |
* the unsigned int. |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
62 |
*/ |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
63 |
static final long /*unsigned int */ UNKNOWN_SIZE = 0xffffffffL; |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
64 |
|
18215 | 65 |
private int auType; |
2 | 66 |
|
38399
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
67 |
AuFileFormat(final AudioFileFormat.Type type, final long byteLength, |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
68 |
final AudioFormat format, final long frameLength) { |
bd91ce346b5b
6729836: JavaSound treats large file sizes as negative and cannot read or skip
serb
parents:
36888
diff
changeset
|
69 |
super(type, byteLength, format, frameLength); |
2 | 70 |
|
71 |
AudioFormat.Encoding encoding = format.getEncoding(); |
|
72 |
||
73 |
auType = -1; |
|
74 |
||
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
75 |
if (AudioFormat.Encoding.ALAW.equals(encoding)) { |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
76 |
if (format.getSampleSizeInBits() == 8) { |
2 | 77 |
auType = AU_ALAW_8; |
78 |
} |
|
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
79 |
} else if (AudioFormat.Encoding.ULAW.equals(encoding)) { |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
80 |
if (format.getSampleSizeInBits() == 8) { |
2 | 81 |
auType = AU_ULAW_8; |
82 |
} |
|
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
83 |
} else if (AudioFormat.Encoding.PCM_SIGNED.equals(encoding)) { |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
84 |
if (format.getSampleSizeInBits() == 8) { |
2 | 85 |
auType = AU_LINEAR_8; |
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
86 |
} else if (format.getSampleSizeInBits() == 16) { |
2 | 87 |
auType = AU_LINEAR_16; |
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
88 |
} else if (format.getSampleSizeInBits() == 24) { |
2 | 89 |
auType = AU_LINEAR_24; |
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
90 |
} else if (format.getSampleSizeInBits() == 32) { |
2 | 91 |
auType = AU_LINEAR_32; |
92 |
} |
|
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
93 |
} else if (AudioFormat.Encoding.PCM_FLOAT.equals(encoding)) { |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
94 |
if (format.getSampleSizeInBits() == 32) { |
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
95 |
auType = AU_FLOAT; |
55364
13ec0d88815b
8222083: Support of "64-bit IEEE floating point" encoding for the AU file format
serb
parents:
47216
diff
changeset
|
96 |
} else if (format.getSampleSizeInBits() == 64) { |
13ec0d88815b
8222083: Support of "64-bit IEEE floating point" encoding for the AU file format
serb
parents:
47216
diff
changeset
|
97 |
auType = AU_DOUBLE; |
36888
0905e6c2d1af
8146239: Support of PCM_FLOAT for the AU file format
serb
parents:
35656
diff
changeset
|
98 |
} |
2 | 99 |
} |
100 |
} |
|
101 |
||
102 |
public int getAuType() { |
|
103 |
return auType; |
|
104 |
} |
|
105 |
} |