Skip to content

[Bug]: Matroska save leaves a stale in-cluster Position #118

Open

Description

@decriptor

Problem Statement

The Matroska tag save updates CueClusterPosition when an unknown-size cluster moves because the tags grew. The Position element inside that cluster (0xA7) stores the cluster's position in the segment and is copied with the old value. A reader that trusts Position then seeks to the offset from before the edit.

Pull request #106 documents this under "Not rewritten."

Proposed Solution

When a cluster's position in the segment changes, add the same delta to each in-cluster Position (0xA7). If that cluster has a CRC-32, recompute it after the update. A cluster that does not move keeps its original bytes, including a known-size cluster that the tag splice only appends after.

Implement from RFC 9559. This stays open after #53 closes on the tag round-trip.

Alternatives Considered

Stripping Position on save. The element is how a damaged file resynchronizes, so the updated value is the useful one.

Additional Context

CueClusterPosition is already adjusted, including the Cues CRC-32. This issue is the cluster-local Position element only.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions