G711ATest.java
1.06 KB
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
package cn.org.hentai.jtt1078.test;
import cn.org.hentai.jtt1078.codec.G711Codec;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* Created by matrixy on 2019/12/21.
*/
public class G711ATest
{
public static void main(String[] args) throws Exception
{
int len = -1;
byte[] block = new byte[1024];
FileInputStream fis = new FileInputStream("E:\\workspace\\enc_dec_audio\\g711\\encode_out.g711a");
FileOutputStream fos = new FileOutputStream("E:\\test\\fuckfuckfuck111.pcm");
G711Codec codec = new G711Codec();
while ((len = fis.read(block)) > -1)
{
byte[] pcmData = null;
if (len == 1024)
{
pcmData = codec.toPCM(block);
}
else
{
byte[] temp = new byte[len];
System.arraycopy(block, 0, temp, 0, len);
pcmData = codec.toPCM(temp);
}
fos.write(pcmData);
fos.flush();
}
fis.close();
fos.close();
}
}