Summary
The current encode/decode path buffers large inputs and outputs in multiple places, and the encoder repeats expensive LPC/Rice analysis while evaluating stereo and zero-run choices.
Affected areas
src/io/wav_io.cpp
src/main.cpp
src/codec/lac/encoder.cpp
src/codec/lac/decoder.cpp
src/codec/block/encoder.cpp
Problem details
Known memory/performance pressure points:
- WAV reader loads the full
data chunk into raw, then expands into channel vectors.
- CLI loads the full
.lac file before decode.
- Decoder allocates complete output vectors up front.
- Encoder stores every encoded block before copying to the final bitstream.
- Auto stereo and zero-run selection repeat block analysis and residual estimation.
- Block encoder stores residual vectors for many predictor candidates.
Acceptance criteria
- Add benchmark or measurement notes for peak memory and runtime.
- Avoid the most obvious duplicate allocations/copies in hot paths.
- Consider span-based partition analysis and moving only the winning residual candidate.
- Document whether streaming encode/decode is in scope for the current format.
Summary
The current encode/decode path buffers large inputs and outputs in multiple places, and the encoder repeats expensive LPC/Rice analysis while evaluating stereo and zero-run choices.
Affected areas
src/io/wav_io.cppsrc/main.cppsrc/codec/lac/encoder.cppsrc/codec/lac/decoder.cppsrc/codec/block/encoder.cppProblem details
Known memory/performance pressure points:
datachunk intoraw, then expands into channel vectors..lacfile before decode.Acceptance criteria