10 秒をデコードするのに 1 分かかりますが、MP3 をより速くデコードするにはどうすればよいですか?
public static byte[] decode(String path, int startMs, int maxMs) throws FileNotFoundException
{
float totalMs = 0;
ByteArrayOutputStream os = new ByteArrayOutputStream();
File file = new File(path);
InputStream inputStream = new BufferedInputStream(new FileInputStream(file), 8 * 1024);
try {
Bitstream bitstream = new Bitstream(inputStream);
Decoder decoder = new Decoder();
boolean done = false;
while (! done) {
Header frameHeader = bitstream.readFrame();
totalMs += frameHeader.ms_per_frame();
SampleBuffer output = (SampleBuffer) decoder.decodeFrame(frameHeader, bitstream);
short[] pcm = output.getBuffer();
for (short s : pcm) {
os.write(s & 0xff);
os.write((s >> 8 ) & 0xff);
}
if (totalMs >= (startMs + maxMs)) {
done = true;
}
bitstream.closeFrame();
}
return os.toByteArray();
}catch(Exception e){
e.printStackTrace();
}
return null;
}