Skip to content

feat(sv56): WAV I/O integration with multi-bit-depth support#7

Open
ludomal wants to merge 53 commits into
STL_2026_itu_submissionfrom
STL2026_sv56_wavio
Open

feat(sv56): WAV I/O integration with multi-bit-depth support#7
ludomal wants to merge 53 commits into
STL_2026_itu_submissionfrom
STL2026_sv56_wavio

Conversation

@ludomal

@ludomal ludomal commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Re-integrate wav_io into sv56demo with support for 8/16/24/32-bit PCM and 32-bit IEEE float WAV files.

Changes

  • Auto-detect bit depth and sample rate from WAV header
  • -bits flag sets A/D resolution for P.56 algorithm (simulates lower-res ADC)
  • Raw PCM files remain 16-bit (full backward compatibility)
  • Endian-safe WAV read/write (correct on big-endian and LP64 platforms)
  • 24/32-bit equalization uses double precision (no float round-trip loss)

Tests (25 total)

  • Binary output comparison: 24-bit, 32-bit, float, very-quiet signals
  • Text statistics verification via -log
  • Key demonstration: very quiet (-91 dBov) signal detected with 32-bit (90% activity) but invisible to 16-bit ADC simulation (0% activity)

Backward compatibility

  • Existing raw 16-bit test vectors pass bit-exactly
  • sv56demo file.src file.prc behaves identically to before

sdoehla-iis and others added 11 commits May 27, 2026 14:26
The random tool was developed to have pseudo-random selection
of entries from a list based on a master seed as required by
the EVS processing scripts.
Document the random tool from PR openitu#182 (3GPP S4-121078) in the
unsup.tex appendix with algorithm description, usage examples,
options reference, and test information.
Re-integrate wav_io library into sv56demo, supporting 8/16/24/32-bit
PCM and 32-bit IEEE float WAV files transparently.

Key design:
- File bit depth auto-detected from WAV header (raw PCM defaults to 16-bit)
- Sample rate auto-detected from WAV header
- -bits flag sets A/D resolution for P.56 algorithm (must be <= file depth)
- Full backward compatibility: raw 16-bit files behave identically

WAV I/O fixes (endian-safe):
- Route all WAV reads through byte-extraction path (LE->native)
- Write WAV samples as explicit little-endian bytes
- Fix LP64 bug: 24/32-bit samples into sizeof(long)==8 slots
- Keep direct fread only for raw (native-endian) files

Equalization precision:
- 24/32-bit: apply gain in double precision directly on integers
- Float input: convert to 32-bit PCM output
- 16-bit: preserve original float round-trip for bit-exact compat

Tests (25 total):
- Binary output comparison for 24-bit, 32-bit, float, very-quiet
- Text statistics verification via -log
- Very quiet (-91 dBov) file demonstrates 32-bit advantage:
  32-bit resolution detects speech (90% activity),
  16-bit ADC simulation reports zero activity
# Conflicts:
#	src/sv56/CMakeLists.txt
#	src/utl/wav_io.c
@ludomal ludomal changed the base branch from STL_2026_itu_submission to dev June 4, 2026 20:26
@ludomal ludomal changed the base branch from dev to STL_2026_itu_submission June 4, 2026 20:40
@ludomal ludomal force-pushed the STL2026_sv56_wavio branch from 8b82776 to 559b282 Compare June 4, 2026 20:49
Ludovic Malfait and others added 13 commits June 4, 2026 21:59
LaTeX build fixes for random tool documentation
Add sv56demo4 test that exercises bitno=12 (sub-16-bit resolution),
verifying both binary output and log output against references.
This covers a code path not previously tested.
Remove sv56-util.h, sv56test.c, and sv56-convert.c — their functionality
is superseded by wav_io.h which handles variable bit-depth I/O at the
file abstraction layer.

Update actlevel.c to use AUDIO_FILE/audio_open_read/audio_read/audio_close
consistent with sv56demo.c.
# Conflicts:
#	src/sv56/CMakeLists.txt
The eid-amr tool was integrated into src/eid/ but the root
CMakeLists.txt still referenced the old standalone directory.
- CMakeLists.txt: project name STL2023 -> STL2026
- STLmanual.tex: title, header, copyright updated to 2026
- intro.tex: add 'In 2026' section, STL2026 acknowledgements, acronym entry
- g191.md: update summary to STL2026 with new feature list
- g191_Annex_A.md: add dlyerr_2_errpat, eid-amr, random entries and
  SHQ2/SHQ3/HP50 filter functions
ludomal and others added 16 commits June 8, 2026 13:53
Add GitHub Actions CI workflow (replace Travis CI)
Same ±1 LSB cross-platform FP rounding as other IIR/FIR filter tests.
Guard Python-dependent wmc_tool tests with if(Python3_FOUND) so they
are cleanly skipped on platforms without Python3 (e.g. i386 container).
Better use of bitno and WAV integration
reltol was used uninitialized when -reltol flag not provided,
causing a crash in MSVC debug builds on Windows.
±1 LSB cross-platform FP rounding at clipping boundary (seen on WSL).
Catches bugs like the reltol issue at compile time rather than
relying on Debug-mode runtime checks that cause dialog popups.
cf (compfile) does not support -equiv flag; signal-diff does.
- item_type: could be used uninitialized if no region type matched
- ps: could be used uninitialized if keyword had no delimiter

Detected by clang -Wconditional-uninitialized and MSVC /we4700.
@ludomal ludomal force-pushed the STL2026_sv56_wavio branch from 95bdd97 to 2f6150e Compare June 9, 2026 17:15
Jan.Reimes and others added 10 commits June 9, 2026 21:56
/we4700 on C++ causes wmc_tool runtime test failures on MSVC due to
optimizer behavior differences, even with the uninit vars fixed.
Keep it for C only where it catches real bugs (like compfile reltol).
Same pattern as sv56demo: auto-detect bit depth from WAV header,
use -bits flag for A/D resolution override. Demonstrates 32-bit
detecting speech at -91 dBov while 16-bit reports zero activity.

Tests: 24-bit normal, 32-bit vquiet, 16-bit ADC simulation, multi-file.
feat(sv56): WAV I/O integration with multi-bit-depth support
- src/eid/bs-stats.c: initialize out_file to "-" (default stdout)
- src/g728/g728fixed/g728fpdec.c: initialize gaindb to 0
- src/is54/lag.c: initialize E to 0.0
- src/mnru/p50fbmnru.c: initialize dcFilterMode to 0
- src/mnru/snr.c: initialize total_snr_dB in reset block
- src/wmc_tool/c_parser.cpp: use calloc instead of malloc for
  Insert Table allocation (zeroes padding bytes)

Remaining: test_precision.c is a consequence of basop W_round issue (openitu#189)
- src/eid/bs-stats.c: initialize out_file to "-" (default stdout)
- src/g728/g728fixed/g728fpdec.c: initialize d->ogaindb in decoder state
- src/is54/g_quant.c: initialize Rpc0, Rcc00, Rcc01, Rcc02, savePtr
- src/is54/init.c: calloc all global arrays (prevents tainted data)
- src/mnru/p50fbmnru.c: initialize dcFilterMode to 0
- src/mnru/snr.c: initialize total_snr_dB in reset block
- src/wmc_tool/c_parser.cpp: memset Insert record, use calloc for table
- src/wmc_tool/wmc_tool.cpp: memset ParseContext to zero

Verified with Clang Memory Sanitizer: all uninitialized reads resolved
except test_precision.c (consequence of basop W_round bug, issue openitu#189).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants