Commit f2bb2d27 by andrewlewis Committed by Oliver Woodman

Add support for extracting 32-bit float WAVE

Issue: #3379

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179925320
parent 61b9e846
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
* DefaultTrackSelector: Support disabling of individual text track selection * DefaultTrackSelector: Support disabling of individual text track selection
flags. flags.
* New Cast extension: Simplifies toggling between local and Cast playbacks. * New Cast extension: Simplifies toggling between local and Cast playbacks.
* Add support for extracting 32-bit WAVE files
([#3379](https://github.com/google/ExoPlayer/issues/3379)).
### 2.6.1 ### ### 2.6.1 ###
......
...@@ -31,6 +31,8 @@ import java.io.IOException; ...@@ -31,6 +31,8 @@ import java.io.IOException;
/** Integer PCM audio data. */ /** Integer PCM audio data. */
private static final int TYPE_PCM = 0x0001; private static final int TYPE_PCM = 0x0001;
/** Float PCM audio data. */
private static final int TYPE_FLOAT = 0x0003;
/** Extended WAVE format. */ /** Extended WAVE format. */
private static final int TYPE_WAVE_FORMAT_EXTENSIBLE = 0xFFFE; private static final int TYPE_WAVE_FORMAT_EXTENSIBLE = 0xFFFE;
...@@ -87,14 +89,22 @@ import java.io.IOException; ...@@ -87,14 +89,22 @@ import java.io.IOException;
+ blockAlignment); + blockAlignment);
} }
@C.PcmEncoding int encoding = Util.getPcmEncoding(bitsPerSample); @C.PcmEncoding int encoding;
if (encoding == C.ENCODING_INVALID) { switch (type) {
Log.e(TAG, "Unsupported WAV bit depth: " + bitsPerSample); case TYPE_PCM:
return null; 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) { if (encoding == C.ENCODING_INVALID) {
Log.e(TAG, "Unsupported WAV format type: " + type); Log.e(TAG, "Unsupported WAV bit depth " + bitsPerSample + " for type " + type);
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment