Repository navigation
Conversation
read_wav() accepted format tag 1 (integer PCM) and tag 0xFFFE (WAVE_FORMAT_EXTENSIBLE) without checking the sub-format, so a 44.1 kHz stereo 32-bit integer file passed the check and its samples were read as float. Accept only IEEE float: tag 3, or tag 0xFFFE with the float sub-format. Refs Arm-Examples#205 Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the patch from #205.
Changes
read_wav()in the audiogen app now accepts only IEEE float input:WAVE_FORMAT_EXTENSIBLE) whose sub-format is 3. The sub-format is read from the first two bytes of the SubFormat GUID, aftercbSize,wValidBitsPerSampleanddwChannelMask. An extensible fmt chunk shorter than 40 bytes fails the check.The rest of the fmt chunk is skipped as before, minus the 10 bytes already read. Tag 1 (integer PCM) is no longer accepted, so a 32-bit integer file gets the existing "Unsupported WAV format" message with the ffmpeg command, like a 16-bit file does today.
How I found it
I read
read_wav()while looking at the audio input path and noticed that the format check allows integer PCM, while the README and the error message ask for 32-bit float.Where this can show up in practice
This is my estimate; I have not seen a field report. Any 44.1 kHz stereo 32-bit integer WAV passed with
-ihits it. Examples areffmpeg ... -c:a pcm_s32le,afconvert -d LEI32@44100, or a "32-bit integer" export from an audio editor. Before this change, the samples are read as float, so the encoder input has values up to about ±3e38, plus inf and NaN.Validation
macOS, Apple clang. I compiled
read_wav()from before and after this change in a small harness that prints the decoded samples. Input: 1 s, 440 Hz, 0.5 amplitude sine, 44.1 kHz stereo.afconvert -d LEI32@44100)pcm_s32le)Controls, decoded output identical before and after:
afconvert -d LEF32@44100, also the format FFmpeg writes forpcm_f32lestereo): accepted, peak 0.5, no inf/NaN.The harness build gives no warnings with
-Wall, before or after.Not run: the full app build (no LiteRT here), the encoder and models, an Android build, and real files from ffmpeg (not installed here). The two extensible files were written by my own script, following the header layout in FFmpeg's
ff_put_wav_header().