<Sound Dev> [9] Review Request: 8038139 AudioInputStream.getFrameLength() returns wrong value for floating-point WAV

Alex Menkov alexey.menkov at oracle.com
Mon Feb 8 10:28:31 UTC 2016


It seems to me that a-law & m-law can be only 8bit, but if you updated 
calculation in getFileStream method, I suppose write method should be 
updated too:

AiffFileWriter.java
  128             int ssndBlockSize           = 
(aiffFileFormat.getFormat().getChannels() * 
aiffFileFormat.getFormat().getSampleSizeInBits());
  129
  130             int aiffLength=bytesWritten;
  131             int 
ssndChunkSize=aiffLength-aiffFileFormat.getHeaderSize()+16;
  132             long dataSize=ssndChunkSize-16;
  133             int numFrames=(int) (dataSize*8/ssndBlockSize);

--alex

On 05.02.2016 20:20, Sergey Bylokhov wrote:
> Hello, Audio Guru.
>
> Please review the fix for jdk9.
> There are two bugs in this area:
>   - in the WaveExtensibleFileReader.java/WaveFloatFileReader.java we
> create the AudioInputStream using the data size in bytes instead of the
> the size in frames. In the fix the size in bytes is divided by the size
> of the frame.
>   - in AiffFileWriter.java we incorrectly calculate the data size in
> bytes(for example if the sample size is less than 8). instead of
>      numFrames * channels * sampleSize / 8
> it should be
>      numFrames * channels * ((sampleSize + 7) / 8)
>
> And when later we read this data in AiffFilereader we incorrectly
> calculate the FrameLength.
>
> In the test I created some fake stream and converted it to a different
> formats with expectation that FrameLength will be preserved.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8038139
> Webrev can be found at: http://cr.openjdk.java.net/~serb/8038139/webrev.00
>


More information about the sound-dev mailing list