parse WAV fmt chunk, downmix multi-channel to mono, widen file sizes …#864
Open
rajaamirapu wants to merge 1 commit intoSIPp:masterfrom
Open
parse WAV fmt chunk, downmix multi-channel to mono, widen file sizes …#864rajaamirapu wants to merge 1 commit intoSIPp:masterfrom
rajaamirapu wants to merge 1 commit intoSIPp:masterfrom
Conversation
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.
fix(rtpstream): parse WAV fmt chunk, downmix multi-channel to mono, widen file sizes to int64_t
Problems Fixed
Problem 1 — WAV header parser ignored the
fmtchunkget_wav_header_size()only scanned for the start of thedatachunkand never read
NumChannels,BitsPerSample, orSampleRate. Stereo(or higher) files were forwarded as raw interleaved bytes, producing
heavily distorted audio at 2× (or worse) the correct duration.
Problem 2 — File sizes capped at ~2 GB
cached_file_t::filesize,cached_pattern_t::filesize, and allplayback-tracking fields in
taskentry_t(
audio/video_file_num_bytes,audio/video_file_bytes_left,new_audio/video_file_size) were declared asint(32-bit signed),capping supported file size at ~2 GB — reached even sooner with
multi-channel or high-rate formats.
Changes
include/rtpstream.hpp#include <stdint.h>; widened 6intfields intaskentry_ttoint64_tsrc/rtpstream.cppget_wav_header_size(); addedparse_wav_header()andwav_downmix_to_mono(); updatedrtpstream_cache_file()andrtpstream_play(); widenedfilesizein both cache structs toint64_tparse_wav_header()— walks all RIFF chunks and extractsNumChannels,BitsPerSample,SampleRate, and the exactdata-chunk byte offset from thefmtchunk.wav_downmix_to_mono()— averages interleaved channels to monoat cache time; supports 8-bit unsigned and 16-bit signed PCM.
cached_file_t::wav_processedflag — WAV stripping and downmixnow happen once in
rtpstream_cache_file();rtpstream_play()skipsall header logic for already-processed files.
malloc