<feed xmlns='http://www.w3.org/2005/Atom'>
<title>atracdenc/src/atrac3denc.cpp, branch fix_input_file_path</title>
<subtitle>OpenSource ATRAC1 ATRAC3 Encoder</subtitle>
<id>https://code.mastervirt.ru/atracdenc/atom?h=fix_input_file_path</id>
<link rel='self' href='https://code.mastervirt.ru/atracdenc/atom?h=fix_input_file_path'/>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/'/>
<updated>2026-04-19T22:27:45Z</updated>
<entry>
<title>atrac3: reimplement tonal encoding. Use flatness-based tonal extraction</title>
<updated>2026-04-19T22:27:45Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-04-18T14:51:23Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=e784b79cfef682059cf5cc8cf9bed635e714c439'/>
<id>urn:sha1:e784b79cfef682059cf5cc8cf9bed635e714c439</id>
<content type='text'>
- Add shared CalcSpectralFlatnessPerBfu helper in atrac_psy_common
  with BFU-table mapping.
- Implement ATRAC3 tonal extraction: compute MDCT energy, estimate
  per-BFU flatness, extract up to 5-bin strongest tonal run in
  low-flatness BFUs, and zero extracted bins in residual.
- Map extracted tonal bins into TTonalBlocks and integrate them into
  bitstream coding.
- Update ATRAC3 bit allocation - reduce residual bits for BFUs with tonal
  blocks, and increase tonal quantizer selection.
- Restore --notonal CLI option in main.cpp for A/B comparison.
</content>
</entry>
<entry>
<title>Remove dead transient hooks, hack override, and unused RMS helper</title>
<updated>2026-04-09T19:39:52Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-04-09T19:36:07Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=3efb188ade161e9c01cb7550aca95aa8e5c78875'/>
<id>urn:sha1:3efb188ade161e9c01cb7550aca95aa8e5c78875</id>
<content type='text'>
</content>
</entry>
<entry>
<title>atrac3: remove band3 transient boost redirection to band0</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-04-06T19:37:44Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=44fd0465b87e6648a647cf868ab4026d28ff60a7'/>
<id>urn:sha1:44fd0465b87e6648a647cf868ab4026d28ff60a7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>atrac3: add distribution-aware sticky gain quantization</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-04-06T17:14:32Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=90ae01a4fbc62d1e839d749bf2ead6b0c67e29ff'/>
<id>urn:sha1:90ae01a4fbc62d1e839d749bf2ead6b0c67e29ff</id>
<content type='text'>
Problem
Gain curve construction still produced many +/-1 level toggles across long runs
(e.g. 7&lt;-&gt;8 chatter). These transitions are usually quantization noise from
subframe-level RMS rounding, not real envelope changes, and they consume gain
bit budget without improving transient protection.

Feature
Introduce distribution-aware sticky quantization for subframe gain levels.
Instead of quantizing only the subframe centre estimate, we also track a robust
within-subframe range and suppress one-step toggles when the previous level is
still consistent with that range.

Implementation
1) AnalyzeGain now optionally returns per-subframe low/high energy estimates
   (robust inter-quantile bounds from micro-chunk analysis inside each subframe).
2) CalcCurve now accepts optional subframe low/high vectors.
3) During sfLevel quantization:
   - compute centre level via RelationToIdx(filtered/target)
   - if new level differs from previous by exactly 1, and previous level is still
     inside [idx(low), idx(high)], keep previous level (sticky hold)
4) CreateSubbandInfo wires the new AnalyzeGain outputs into CalcCurve.
5) Existing point0 guard/boundary logic remains intact; this feature operates
   earlier at sfLevel formation.

Why this is safe
- Only suppresses +/-1 oscillation when previous level is still supported by
  observed subframe distribution.
- Does not clamp large transitions or remove structurally important points.
- Keeps curve scan/priority flow unchanged after sfLevel is formed.

Measured impact on current HEAD (gain-info bits)
Bit accounting uses ATRAC3 gain syntax: per channel header + per band point-count
fields + 9 bits per gain point.

show_me_your_spine.wav:
- base: 219,552 bits (18,688 points)
- with sticky: 172,158 bits (13,422 points)
- saved: 47,394 bits, 5,266 points (-21.59% gain-info bits)

13.wav:
- base: 1,537,724 bits (123,556 points)
- with sticky: 1,146,746 bits (80,114 points)
- saved: 390,978 bits, 43,442 points (-25.43% gain-info bits)
</content>
</entry>
<entry>
<title>atrac3: make point0 guard boundary-aware to avoid overlap artifacts</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-04-05T21:59:39Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=7ee080508593c7e83080fdca2acfa20e10d1db81'/>
<id>urn:sha1:7ee080508593c7e83080fdca2acfa20e10d1db81</id>
<content type='text'>
Problem
The current point0 guard decides keep/revert only from an early-frame mismatch score.
That can revert a newly inserted point0 even when it is needed for frame-boundary
continuity. In ATRAC3 demodulation, the next frame's first gain level is reused as a
scale term for the overlap region, so removing point0 can change boundary scale by
multiple quantization steps and create audible artifacts.

Root cause
For frames like 13.wav around 45.1s, point0_guard reverted point0 in key bands,
which changed first-point scale and increased boundary mismatch despite a locally
better early-fit score.

Change
- Keep existing early mismatch metric (fit + leakage proxy).
- Add boundary-aware keep criterion inside point0_guard:
  * compute desired boundary scale in the same HPF domain:
      desiredScale = LimitRel(prevTarget / hpfRmsNextMod)
  * compare log2 distance of first-level scale before/after point0 insertion
  * if point0 reduces boundary error by a material margin (0.2 bits), force keep
    even when early-fit score slightly worsens
- Apply guard only when point0 actually changes the curve.
- Add YAML telemetry for boundary error before/after to support analysis.

Implementation details
- Added helper utilities to reconstruct subframe-average divisors from curve points
  and score early mismatch consistently.
- Updated point0 insertion/update flow to track whether point0 changed.
- Extended guard decision to combine:
  * early mismatch tolerance (existing behavior), and
  * boundary continuity improvement (new behavior).

Observed effect (focused check)
- On 13 clip (~45.1s), exact bad subframe (t=45.103129s, frame256=7769, sf32=23):
  ratio vs no-gain reduced from 9.30x to 1.51x after this change.
- Frame 1942 YAML now shows point0 kept in bands where boundary error drops
  substantially.

Notes
- No full regression run in this commit (intentional for fast iteration).
</content>
</entry>
<entry>
<title>atrac3: trim redundant point0 and skip point0 on band 3</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-04-05T10:24:59Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=1335cbd47c954d1ab93026a41d2132ee87739a05'/>
<id>urn:sha1:1335cbd47c954d1ab93026a41d2132ee87739a05</id>
<content type='text'>
</content>
</entry>
<entry>
<title>atrac3: replace CalcCurve with staircase level-scan algorithm</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-04-02T21:10:11Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=bffcd9b5c634a1864821ef13034f153fbc2eaa5f'/>
<id>urn:sha1:bffcd9b5c634a1864821ef13034f153fbc2eaa5f</id>
<content type='text'>
Replaces the monotone-triplet transient detector with a level-based
staircase scan that builds the gain curve from the target subframe
leftward.  The new algorithm correctly handles rising transients by
attenuating the loud peak region rather than the quiet onset.

Key changes:
- 3-point median filter on gain[] suppresses isolated spikes
- Per-sf level = RelationToIdx(filtered[sf] / target)
- Scan leftward from first-neutral-sf, emit one point per level change
- Priority trim: keep up to 6 points with largest |ΔLevel| first

Co-Authored-By: Claude Sonnet 4.6 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>atrac3: point0 in HPF domain using prevTarget/hpfRmsNextMod; enable band 2</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-03-29T19:12:00Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=9804847d1693bde5621b9172b45ec99f618e2794'/>
<id>urn:sha1:9804847d1693bde5621b9172b45ec99f618e2794</id>
<content type='text'>
Point0 calculation switched from raw-PCM RMS ratio to HPF-filtered domain:
- prevTarget (stored as ctx.LastTarget from previous CalcCurve call) replaces rmsCur
- hpfRmsNextMod = mean(gain[0..loc-1]) / GainLevel[pts[0].Level] replaces rmsNextMod
  (only the pre-ramp constant-level zone, same domain as gain[])
- TCurveBuilderCtx gains LastTarget field; CalcCurve stores target before returning

Also extends gain control to band 2 (~11–16 kHz) by changing the skip threshold
from band &gt;= 2 to band &gt;= 3.  Perceptually sounds better; regression metrics
worsen due to broadband measurement not capturing per-band HF improvement.

Co-Authored-By: Claude Sonnet 4.6 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>atrac3: log plateau result and target source inside CalcCurve</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-03-26T14:13:28Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=f4a16cb5af5db048944eed1b1d8114b1f8dffccf'/>
<id>urn:sha1:f4a16cb5af5db048944eed1b1d8114b1f8dffccf</id>
<content type='text'>
Pass yamlLog into CalcCurve so plateau_level, plateau_max_raw,
plateau_release, and target/source are emitted directly from the
function that computes them, instead of via stale TCurveBuilderCtx
fields. Remove LastTarget and LastTargetFromPlateau from the context
struct entirely.

Co-Authored-By: Claude Sonnet 4.6 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>atrac3: remove aggressive_suppressed heuristic and level clamping</title>
<updated>2026-04-08T21:33:40Z</updated>
<author>
<name>Daniil Cherednik</name>
<email>dan.cherednik@gmail.com</email>
</author>
<published>2026-03-26T11:36:29Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/atracdenc/commit/?id=b18f3a72416dad73d2483423634a59e17b3ec587'/>
<id>urn:sha1:b18f3a72416dad73d2483423634a59e17b3ec587</id>
<content type='text'>
Removes the block that suppressed curves with Level&lt;=2 when ratio was
below 10x or overlap was high, and the soft-min level clamping that
raised extreme levels to 3.  Also removes the scale constraint that
forced curve[0].Level &gt;= 3.

These heuristics degraded sound quality.  The gain curve analysis
should produce correct levels directly rather than post-hoc clamping.

Co-Authored-By: Claude Sonnet 4.6 &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
