Skip to content

Reduce peak memory and repeated analysis in encode/decode pipelines #15

Description

@audexdev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestperformanceRuntime, memory, and scalability work

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions