Skip to content

Commit

Permalink
Fix AVI extractor WAVE format extraction
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andrewlewis authored and Copybara-Service committed Jun 13, 2024
1 parent d4802a4 commit a031261
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
`ExportException.codecInfo`.
* Track Selection:
* Extractors:
* Fix PCM audio format extraction in AVI containers.
* Audio:
* Video:
* Text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ private static AviChunk parseWaveFormatEx(ParsableByteArray body) {
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);

Expand Down

0 comments on commit a031261

Please sign in to comment.