Fix AVI extractor WAVE format extraction

Allow `WAVEFORMAT` (in addition to `WAVEFORMATEX`), which omits initialization
data.

Fix reading of bits per sample to use little endian byte order like the other
reads. See also the wave format docs linked from
https://learn.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference#avi-stream-headers.

PiperOrigin-RevId: 642962893
This commit is contained in:
andrewlewis 2024-06-13 06:17:12 -07:00 committed by Copybara-Service
parent d4802a429b
commit a0312615f2
2 changed files with 3 additions and 2 deletions

View File

@ -13,6 +13,7 @@
`ExportException.codecInfo`.
* Track Selection:
* Extractors:
* Fix PCM audio format extraction in AVI containers.
* Audio:
* Video:
* Text:

View File

@ -83,9 +83,9 @@ import com.google.common.collect.ImmutableList;
int channelCount = body.readLittleEndianUnsignedShort();
int samplesPerSecond = body.readLittleEndianInt();
body.skipBytes(6); // averageBytesPerSecond (4 bytes), nBlockAlign (2 bytes).
int bitsPerSample = body.readUnsignedShort();
int bitsPerSample = body.readLittleEndianUnsignedShort();
int pcmEncoding = Util.getPcmEncoding(bitsPerSample);
int cbSize = body.readLittleEndianUnsignedShort();
int cbSize = body.bytesLeft() > 0 ? body.readLittleEndianUnsignedShort() : 0;
byte[] codecData = new byte[cbSize];
body.readBytes(codecData, /* offset= */ 0, codecData.length);