Skip to content

Commit

Permalink
Add support for extracting 32-bit float WAVE
Browse files Browse the repository at this point in the history
Issue: google#3379

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179925320
  • Loading branch information
andrewlewis authored and ojw28 committed Jan 3, 2018
1 parent f8c76f6 commit 42a3e2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* Audio:
* Support 32-bit PCM float output from `DefaultAudioSink`, and add an option
to use this with `FfmpegAudioRenderer`.
* Add support for extracting 32-bit WAVE files
([#3379](https://github.com/google/ExoPlayer/issues/3379)).
* Support extraction and decoding of Dolby Atmos
([#2465](https://github.com/google/ExoPlayer/issues/2465)).
* Fix handling of playback parameter changes while paused when followed by a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

/** Integer PCM audio data. */
private static final int TYPE_PCM = 0x0001;
/** Float PCM audio data. */
private static final int TYPE_FLOAT = 0x0003;
/** Extended WAVE format. */
private static final int TYPE_WAVE_FORMAT_EXTENSIBLE = 0xFFFE;

Expand Down Expand Up @@ -87,14 +89,22 @@ public static WavHeader peek(ExtractorInput input) throws IOException, Interrupt
+ blockAlignment);
}

@C.PcmEncoding int encoding = Util.getPcmEncoding(bitsPerSample);
if (encoding == C.ENCODING_INVALID) {
Log.e(TAG, "Unsupported WAV bit depth: " + bitsPerSample);
return null;
@C.PcmEncoding int encoding;
switch (type) {
case TYPE_PCM:
case TYPE_WAVE_FORMAT_EXTENSIBLE:
encoding = Util.getPcmEncoding(bitsPerSample);
break;
case TYPE_FLOAT:
encoding = bitsPerSample == 32 ? C.ENCODING_PCM_FLOAT : C.ENCODING_INVALID;
break;
default:
Log.e(TAG, "Unsupported WAV format type: " + type);
return null;
}

if (type != TYPE_PCM && type != TYPE_WAVE_FORMAT_EXTENSIBLE) {
Log.e(TAG, "Unsupported WAV format type: " + type);
if (encoding == C.ENCODING_INVALID) {
Log.e(TAG, "Unsupported WAV bit depth " + bitsPerSample + " for type " + type);
return null;
}

Expand Down

0 comments on commit 42a3e2e

Please sign in to comment.