Repository navigation
fix: Keep a moved Matroska element listed in the SeekHead and move later elements for a track flag - #149
Merged
decriptor merged 31 commits intoNov 22, 2026
Conversation
This was referenced Nov 21, 2026
decriptor
force-pushed
the
fix/matroska-seekhead-fallback
branch
2 times, most recently
from
November 21, 2026 19:40
0311603 to
22f84e7
Compare
decriptor
force-pushed
the
feat/matroska-cover-attachments
branch
from
November 21, 2026 19:56
e7b7d9d to
2afe3b2
Compare
decriptor
force-pushed
the
fix/matroska-seekhead-fallback
branch
from
November 21, 2026 20:17
39c4b3f to
04d5de3
Compare
decriptor
force-pushed
the
feat/matroska-cover-attachments
branch
2 times, most recently
from
November 22, 2026 02:13
0dc60cb to
07d9906
Compare
This was referenced Nov 22, 2026
decriptor
force-pushed
the
feat/matroska-cover-attachments
branch
from
November 22, 2026 03:14
07d9906 to
f3a6078
Compare
An edited or added top-level element stays listed in the SeekHead (RFC 9559 section 6.1). When the SeekHead has no room for the element's Seek, or the Seek cannot hold the new offset, the element goes right after the first SeekHead and everything after it moves once. Without a SeekHead the element goes before the first Cluster. Every Segment Position follows a move through one map: each SeekPosition in every SeekHead, the Cues CueClusterPosition, CueCodecState, CueRefCluster and CueRefCodecState (RFC 9559 sections 5.1.5, A.37, A.39), and Cluster Position (section 5.1.3.2), with their CRC-32 values. A value that no longer fits its field is written wider (RFC 8794 sections 6.1 and 7.2), and its SeekHead or Cues grows. The lengths settle in linear work, going to eight octets after four rounds and capped at seven. A Cluster Position that cannot widen in place is voided, since it is optional. This replaces the in-place Delta patching from main (#132) on the same path: - Cluster Position and CueCodecState now follow the shared map. - A CueCodecState that outgrows its field is widened rather than voided. A missing CueCodecState reads as 0, "the codec state is in the TrackEntry", which is a different value. - The Cues walkers follow only the RFC 9559 section 5.1.5 paths, so a file that nests CuePoints thousands deep cannot exhaust the stack. - Main's names (MatroskaIds.Position, TryVoidElement, OffsetSteps) are kept. Before this, an artist edit or a no-op save on test1.mkv or test6.mkv dropped the Tags Seek, a cover over about 64 KB on a file with two-byte CueClusterPositions was refused, and a nested-CuePoint Cues overflowed the stack on a live insert.
Adding a missing FlagEnabled used to need a Void right after Tracks; without one the save failed. Now the room comes from that Void when it has enough, and otherwise Tracks grows through TryGrow: everything after it moves once, and every SeekHead, Cues and Cluster Position value and CRC-32 follows, widened when it no longer fits. DocTypeVersion is still raised to at least 2 in every copy. A save still fails, writing nothing, when an unknown-size or second Tracks has no Void to give the room. The DocTypeVersion tests move to MatroskaTrackEnabledShiftTests with the other shift tests, and the in-place-only refusals become move tests. A new test checks that every Cluster Position, including one under a CRC-32, follows its Cluster after the move. The real-file toggled-track test checks every Seek and compares clusters without their Position, and the combined cover and track-flag tests check their Seeks against the original file.
decriptor
force-pushed
the
fix/matroska-seekhead-fallback
branch
from
November 22, 2026 03:18
336ed70 to
fbce9f2
Compare
RFC 8794 section 7.2 reads an empty unsigned integer with no default as 0, and CueClusterPosition, CueCodecState, CueRefCluster and CueRefCodecState have none. The Cues walkers refused an empty CueClusterPosition or CueRefCluster, so a save that moved the Cues failed on a file that readers accept; since this branch walks CueReference, that included an artist edit on a live stream. An empty value is now 0: it stays as it is when 0 does not move, and is written wider when it does. When the move after the first SeekHead fails and the first plan cannot list the element either, the error is now the move's, which names what the file needs fixed, instead of the SeekHead one.
…e save When adding FlagEnabled must grow Tracks and TryGrow cannot move what follows, the save fails, writes nothing, Render is empty, and the error names the Cues. Reporting success there would silently drop the flag.
The Pictures remarks still said a SeekHead without room fails the save. The Attachments now go right after the first SeekHead, or before the first Cluster without one, and the save fails only when the first SeekHead cannot be read or the later elements cannot be moved.
… real-file tests The toggled-track test compared Cluster payloads with only Position zeroed, so a correct save of a file whose moved Cluster has a CRC-32, or whose Position had to be voided, failed it. It now leaves out Position, CRC-32 and Void as ClusterPayloads does. The large-cover test required every Position to name its Cluster, which a Position already wrong in the source cannot; such a Position must now be kept as stored, and a correct one must still be correct or voided.
… own cause An Attachments save that must move after a full SeekHead either lists the element or fails with the cause of that refusal and leaves the file as it was: malformed Cues name the Cues, an unreadable SeekHead names the SeekHead, and WebM names WebM.
An empty Position is 0 (RFC 8794 section 7.2), which names a Cluster at Segment offset 0. Such a Position was skipped, so after an insert before that Cluster it still claimed offset 0. It now follows like any other Position: it cannot widen in place, so it is voided as optional. The CueClusterPosition that names offset 0 the same way is written wider. The fallback-build branch of the move no longer replaces its own error: it rebuilds the plan that just succeeded, so it cannot fail there, and the move's error still reaches the caller through the reachability check.
… is widened RFC 9559 section 5.1.5.1.2.6 gives CueCodecState a default of 0, so an empty one reads as 0 by that default; the other three Cues positions have none and read as 0 by RFC 8794 section 7.2. An empty position is kept, or written wider when the offset 0 it names moves.
… empty added edition
…h a stored track flag
Owner
Author
|
Review: 0 findings at 686041d. This branch now also contains #146 (Matroska chapters, approved at 8766d27). It is stacked on #142. Merge order: #151 first, then #142, then this PR. #151 fixes the Cues and SimpleTag stack overflow (#150), and its tests sit on top of this PR's Cues walker. When #151 is merged into this branch, take this PR's What was checked:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Stacked on #142 (
feat/matroska-cover-attachments@ f3a6078, rebased on main ebd6138, which has #140, #132, #135 and #143). Merge order: #142 → this PR → the chapters PR (#146). The track-flag shift that was #148 is merged into this branch, so this PR also carries it. See "Restack onto main ebd6138" at the end.When a Matroska save writes a top-level element (Tags, Attachments, and later Chapters) and the existing plan leaves it unlisted, the element now moves right after the first SeekHead. That happens when the SeekHead has no room for a new Seek, or when the element's Seek cannot hold its new offset. The SeekHead is written again with every Seek at the width it needs, and everything after it moves once. This replaces #142's "Matroska SeekHead has no room to reference the attachments" refusal, and it fixes a bug already on main where Tags disappear.
Invariant: after a save that moves elements, every Seek that named an element still names it, at whatever width it now needs, and the element that was written is listed in the first SeekHead. Every CueClusterPosition, CueCodecState, CueRefCluster and CueRefCodecState still names its position; a Cluster
Positionfollows its Cluster, or is voided when it cannot widen in place. The deprecated ReferenceVirtual (RFC 9559 Appendix A.4) is left as it is. Block bytes are unchanged.Remaining cases where the written element is not listed:
Position: one that cannot widen in place is voided.The bug on main
An artist edit of
TaglibSharpSamples/matroska/test1.mkvortest6.mkvre-rendersTagsa few bytes larger. Before #132's Tags rendering change, a no-op save did the same; on mainebd6138a no-op save of these two files is byte-identical. The larger Tags no longer fit, so they are appended after the clusters. The old 2-byte SeekPosition cannot hold the new offset, so the Seek is voided, and ffprobe and mediainfo then show no tags. With this PR, the Tags move after the SeekHead and stay listed. See the table below.Spec references
Positionis the cluster's own Segment Position.Design
Plan.Map (ulong old)is the only place a shift is applied. It adds the insert (ShiftFrom,Delta) and the growth of every rewritten SeekHead or Cues. SeekPosition, every Cues position, ClusterPositionand the reachability check all go through it.TryGrow, or the insert before a live cluster. Its growth is added to the map, and the lengths are settled until they stop changing. A rendered piece never shrinks below its last length; a Void takes the slack. A Seek for another element is never voided for lack of room. Only the written element's own Seek may be voided, because the move lists it again.TryPlanMove). The first SeekHead is rendered like the pieces above, with a Seek for the target added. The new element goes right after it, and old copies are voided in place. A second SeekHead is patched in place throughPlan.Map, or rewritten wider when a value does not fit.internal static bool MatroskaRewrite.TryGrow (ReadOnlySpan<byte> data, byte[] replacement, out byte[] rewritten, out string error)). It replaces the first top-level element that has the replacement's ID. A shorter replacement is padded with a Void in place. A longer one grows in place, and everything after it moves once, with SeekHead, Cues, ClusterPositionand CRC-32 values updated. The replacement's own CRC-32 is recomputed. The [Feature]: Honor Matroska TrackFlagEnabled #117 TrackEntry follow-up uses this.Positionand fix: Update Matroska cluster positions and disc numbers #132. fix: Update Matroska cluster positions and disc numbers #132, now on main, patched ClusterPositionandCueCodecStatein place. This PR folds both intoPlan.Map(see "Restack onto main ebd6138"). APositionis rewritten only when it equalled the cluster's old offset, and it is voided if it cannot be widened.Tagsis always re-rendered. The chapters PR fixes it by comparing against what was read.Tests changed from #142
Save_NewAttachments_WithoutSeekHeadRoom_FailsAndLeavesTheFileis now..._GoAfterTheSeekHeadAndAreListed. It asserts the attachments are listed, are before the cluster, and that the cluster is intact.Save_NewSeekEntry_NeverGoesInTheSecondSeekHeadnow succeeds. The first SeekHead lists the attachments, and the second still lists only the Cluster.Save_NewAttachments_WithoutASeekHead_GoBeforeTheClusters_OrFailis now..._GoBeforeTheClusters. The cluster moves whole.Save_RewritesCommonFields_AndLeavesTheClusterBytescovers a file with no SeekHead. The grown Tags now go before the cluster, and the cluster moves whole. I checked that ffprobe does not find Tags after the clusters in a file with no SeekHead.MatroskaIntegrationTests: cluster comparisons ignorePositionand CRC-32. The "SeekHead" inconclusive branch is gone, because test1/3/6/8 now pass outright. A newSave_RealMatroska_ArtistEdit_KeepsTheTagsListedtest was added.New unit tests are in
MatroskaSeekHeadFallbackTests.cs:PositionTryGrowgrowing and shrinking, including a stale caller CRCTryGrowwith a missing elementNew in round 1 (
MatroskaShiftWidthTests.cs):Position== offset and a kept non-Seek SeekHead child (F5)TryGrowacross a SeekPosition width boundary (65534 → 65537) and a CueClusterPosition boundary (65533 → 65536), both checked withAssertSeeksPreserved, which fails if any Seek that landed before is missing after (feat: Move later Matroska elements when a track flag needs room #148 F1/F2)The first six fail at round-0 head 8769001 and pass now. The reworked second-SeekHead test fails at 8769001 too.
I reverted each guard and confirmed a test goes red:
PositionpatchType of Change
Checklist
dotnet test)Testing
dotnet build -c Release: 0 warnings, 0 errorsdotnet test -c Release(rebased on feat: Write Matroska pictures as image attachments #142 e7b7d9d): net8.0 4541 passed / 14 skipped / 0 failed; net10.0 the same. The reviewer's 115-cell grid gives the same answers before and after the rebase.dotnet format --verify-no-changes: cleanTAGLIBSHARP2_TEST_MATROSKA=<file> dotnet test --filter "FullyQualifiedName~MatroskaIntegrationTests", run locally:Round 1: before/after (round-0 head 8769001 vs this head)
I ran the reviewer's grid: 22 inputs × noop, artist, 200-character title, 247 B cover and 67 KB cover. Each output went through the same
verify.py(every Seek, Cue, CueRelativePosition, Position, PrevSize, CRC, and the cluster hash), ffprobe, mediainfo andffmpeg -f null.8 of 115 cells changed, all intended. The 67 KB cover on test1, test3, test7, test8, genfull, manyfull, live2shfull and test6-2shmin was refused with "no room", and now saves. In every one:
-ss 0/3.3/7.7/12.1/20.5, and a full decode, are identical to the inputThe other 107 cells are unchanged.
A 70,000-character title on test1 was saved at 8769001 with the Tags Seek dropped (ffprobe and mediainfo showed no title). Now it is listed, and ffprobe and mediainfo read it. test3 and test7 are unchanged.
In test3/7/8 the first cluster's 2-byte
Positioncannot hold its new 3-byte offset, so that optional element is voided (46 of 47 Positions remain, all correct).Real files: main build vs this branch
Inputs:
TaglibSharpSamples/matroska/test1..8.mkv, taglib-sharpTurning Lime.mkv, and ffmpeg 9.0.2gen.mkv,gen.mkaandgen.webm.Operations:
After every save I checked:
ffprobeformat tags (TITLE, ARTIST)ffmpeg -v error -i out -f null -Positionand CRC-32) compared to the inputPositionequals its offsetmediainfo agrees with ffprobe in every row, including Cover = Yes after cover saves.
Round 2
Commits
e984cdaand39c4b3f(head39c4b3f):F1, linear work. This was the cascade where each widened Cues pushes the next over a width boundary. Now:
Mapuses a binary search over prefix sums;The reviewer's 6,400-Cues, 132 KB file with 3-byte values now saves in about 70 ms of CPU (it was 140 s). At 1,600 two-byte Cues it is 27 ms, against 2,746 ms at 22f84e7.
Pin:
TryGrow_CascadingCueWidths_SettleInLinearWorkcompares allocated bytes for 150 against 300 cascading Cues, and must come in under 3x. At 22f84e7 it fails: 18 MB vs 72 MB. Now it is 0.7 MB vs 1.4 MB.TryGrow_CascadingCueWidths_EveryCueFollowsTheClusterchecks every value.F2:
TryGrow_ClusterPositionThatCannotWiden_IsVoided. A 2-byte Position at 0xFFFE is voided, the Cluster keeps its length, the cue lands and the CRCs stay valid. The reviewer's V1 (leave it stale) and V2 (fail the save) reverts both turn it red. The real-file large-cover test now also asserts that every remaining Position equals its Cluster's offset; V1 fails it on test3.F3: the CHANGELOG, the invariant and the test summary name the positions that are moved, say a Position that cannot widen is voided, and say ReferenceVirtual is left as it is.
F4:
RenderSeekHeadrefuses a moved position that would wrap. The move is then refused and the first plan is used, and the garbage Seek is left as it was. Pin:Save_Move_SeekPositionThatWouldWrap_IsNotWritten, which fails at 22f84e7 ("wrapped to 38").Before/after: the reviewer's 115-cell grid gives identical answers at 22f84e7 and 39c4b3f. Gates (on #142 2afe3b2): net8.0 and net10.0 4585 passed / 14 skipped, 0 warnings, format clean. (Corrected in round 3: this line used to claim 100% patch coverage on the round's lines. The reviewer measured 69/73;
MakeSeek's 8-octet branch never ran.)Round 3
Commits
108397b,2677552and84fdb03(head84fdb03):F1, stack overflow on nested CuePoints. A 90 KB Cues of 10,000 nested CuePoints overflowed the stack of a title-edit save run on the thread pool and killed the process; base 2afe3b2 saved it. Both Cues walkers,
TryPatchCueValues(in place) andRenderCueMaster(rendered), now follow only the RFC 9559 §5.1.5 paths: Cues > CuePoint > CueTrackPositions > CueReference. A position is read only where the spec puts it: CueClusterPosition and CueCodecState in CueTrackPositions, and CueRefCluster and CueRefCodecState in CueReference. Any other nesting is copied as it is, so the recursion is at most four levels deep.Save_Move_DeeplyNestedCuePoints_SavesOnASmallStack(title-edit save) andTryGrow_DeeplyNestedCuePoints_RendersOnASmallStack(render path). Both run on a thread with a 256 KiB stack. At 04d5de3 both crash the test host with a stack overflow.TryGrow_CuePositionOffTheSpecPaths_IsCopiedAsItIs, in place and rendered. It fails at 04d5de3.ReadSimpleTagandSimpleTag.Render. It is pre-existing on main and unchanged here, so it is listed as a follow-up below.F2, the linear-work pin.
MatroskaRewrite.SettleCallsandSettleStepsare thread-static counters with no allocation, for values placed and growth entries examined.TryGrow_CascadingCueWidths_SettleInLinearWorknow also requires:The reviewer's M1 (a linear scan over
Growth) fails it whether or not the scan counts its steps.F3, the 8-octet SeekPosition branch.
TryGrow_CascadingSeekPositions_GoWideAndEverySeekLandsbuilds twelve SeekHeads of five Seeks, each for its own empty Chapters element at 0xFFFF − 5k. It asserts:M5 (rendered SeekHeads ignore
WideValues) turns it red. The round-2 coverage claim above is corrected.F4: the
TrySettlesummary, the CHANGELOG and the round-2 line above now say the rounds are capped and a file that reaches the cap is refused.Before/after, 04d5de3 vs 84fdb03:
Gates:
dotnet build -c Release: 0 warnings.dotnet test -c Release: net8.0 and net10.0 4589 passed / 14 skipped.dotnet format --verify-no-changes: clean.MatroskaRewrite.cs(VS code coverage, net10.0): 26/26.MakeSeek's 8-octet branch now runs.Follow-up, pre-existing on main and not changed here: nested SimpleTags (RFC 9559 makes SimpleTag recursive) drive
MatroskaFile.ReadSimpleTaginto unbounded recursion, and 10,000 levels overflow a thread-poolRead.Round 4
Commit
52bf607(head52bf607), test-only:MatroskaIntegrationTests.CollectCues, the oracle behindLandingCues, walked the Cues at any depth. It counted off-path CueClusterPositions that the save rightly leaves alone, and had no depth bound. It now reads only the RFC 9559 §5.1.5 path, the same as production and the unit helperCollect. The same fix goes to its twinMatroskaSaveTests.TryFindCuePosition, which is pre-existing.TAGLIBSHARP2_TEST_MATROSKAresults:mf-*.mkv:mf-nestandmf-flatfailed 42 vs 0 before; all nine now pass 4/4;Restack onto main ebd6138 (#140, #132, #135 and #143 merged; #148 merged into this branch)
This branch was rebuilt on #142
f3a6078as two commits:3c4bdf9fix: Keep a moved or added Matroska element listed in the SeekHead. It holds the SeekHead fallback and the position engine (rounds 1-4), with fix: Update Matroska cluster positions and disc numbers #132 folded in.fbce9f2feat: Move later elements when a Matroska track flag needs room. This is the former feat: Move later Matroska elements when a track flag needs room #148, as a change against main's feat: Honor and save the Matroska track enabled flag in place #140.Why two commits instead of the earlier 16:
clusterslist throughTryBuild/TryPatchand patched ClusterPositionandCueCodecStatein place.How #132 is folded in. Main's in-place
Deltapatching on this path (TryPatchClusterPosition,TryAddDelta,TryAddDeltaOrVoid,UpdatePieceCrc) is replaced by this PR's shared map:Positionand CueCodecState followPlan.Mapwith every other Segment Position.MatroskaIds.Position,TryVoidElementandOffsetSteps.Save_ShiftedCluster_UpdatesInClusterPositionAndRecomputesItsCrcandSave_AddedTags_KeepEachClusterPositionAtItsClusterfail, along with the new track test below.Deliberate change from #132: CueCodecState is widened, not voided. RFC 8794 §7.2 lets an unsigned integer use 0 to 8 octets, so widening keeps the value. A missing CueCodecState reads as 0, "the codec state is in the TrackEntry" (RFC 9559 §5.1.5.1.2.6). Voiding it would therefore change its meaning.
Save_CueCodecStatePastOneByte_WidensAndFollowsTheCluster. It now asserts that the value read back equals the Cluster's new offset. That assertion fails at 304bc06, where the element is voided.genfull.mkvI turned a 1-octet CueRelativePosition into a 1-octet CueCodecState naming Info (161). After a title edit it is 631 in 2 octets; after an artist edit, 483. Both still name Info, every CRC-32 matches, ffprobe and mediainfo read the new tags, andffmpeg -v error -f nulldecodes cleanly.Cluster Position is unchanged from #132's rule: a value that cannot widen in place is voided, because it is optional and a wrong value is worse than none.
Cues walker. #132's
TryPatchCueValueswalked the Cues at any depth.Save_InsertBeforeLiveCluster_DeeplyNestedCuePoints_SavesOnASmallStackruns that save on a 256 KiB stack and passes.CueClusterPositionshad the same any-depth walk; feat: Write Matroska pictures as image attachments #142 now walks it on the spec path itself.Track flag and Cluster Position. The new
Save_InsertWithoutAVoid_EveryClusterPositionFollowsItsClustercovers three Clusters with Position, the second under a CRC-32, moved by an added FlagEnabled. It checks that every Position equals its Cluster's new offset, the blocks are unchanged, the Cues follow, and every CRC-32 matches.Real files, track-flag toggle with
verify.py:test1, test5, manyclusters and Turning Lime also save. Their payloads are unchanged, apart from the one cue already broken in Lime's source.
ffmpeg -v errordecodes cleanly, except test7's "Invalid track number 87", which the original file also gives.Test reconciliation with main and #142:
MatroskaIntegrationTestsand theSavehelper inMatroskaTrackEnabledSaveTests, so the shift versions were folded in there. The separateMatroskaTrackIntegrationTestsis gone.Save_RealMatroska_CoverAndTrackFlag_AreBothWrittenused to compare raw Cluster bytes. A file without a Void after Tracks now saves instead of refusing, and the move rightly changes Position and CRC-32. The test now compares payloads and checks that every Seek and Cue still lands. On test2/3/7/8 that save was checked with verify.py, ffprobe, mediainfo and a decode.Gates at
fbce9f2(superseded by Round 5 below):dotnet build -c Release: 0 warnings, 0 errors.dotnet test -c Release: net8.0 and net10.0 4934 passed / 23 skipped.dotnet format --verify-no-changes: clean.TAGLIBSHARP2_TEST_MATROSKA: all 23 real samples and the ninemf-*.mkvfiles pass 8/8 (gen.webm: 5 passed, 3 skipped).3c4bdf9alone: 4925 passed / 23 skipped.Before/after: the reviewer's grid (25 inputs × 6 ops), 336ed70 against the
07d9906-based tree, whose Matroska code is the same as this head's.TargetTypeValueis no longer written as 50.Follow-up, PR #151: when it merges, #142 and this PR rebase onto it. This PR's spec-path walker then replaces #151's loops; it also walks CueReference and widens instead of voiding.
Round 5
Commits
65a9189,dd51322,16b39a6,498c1e2,d913c38,6f43934,ef530c7andfb58a98(headfb58a98):TryMoveCueValue, which both Cues walkers use, now reads an empty value as 0. It stays as it is when 0 does not move, and is written wider when it does.Save_InsertBeforeLiveCluster_EmptyCueValues_AreKept(live insert, in place) andTryGrow_EmptyCueValues_AreKeptWhenTheCuesAreWrittenAgain(rendered). Both fail at fbce9f2.kl-ref-empty.mkvnow saves an artist edit and a 200-character title.k-ref-empty.mkvnow saves cover, bigcover, flag and flagtitle; all were refused at fbce9f2.Save_NewAttachments_MoveThatCannotUpdateTheCues_NamesTheCues, plus a matrix,Save_NewAttachments_ThatMustMove_SucceedOrNameTheirCause. The matrix has one success row and three refusals, each naming its own cause and leaving the file unchanged: malformed Cues → "Cues", unreadable SeekHead → "SeekHead", WebM → "WebM". The Cues rows fail at fbce9f2.TryReadSeek, used by in-place and rendered SeekHeads) already read an empty SeekPosition as 0.Position(ef530c7): an empty Position is 0. It follows only when its Cluster was at offset 0; it cannot widen in place, so it is voided. Pinned bySave_InsertAtOffsetZero_EmptyValuesThatNameIt_Move, which also covers an empty CueClusterPosition that must move and be written wider. fix: Update Matroska cluster positions and disc numbers #132'sSave_EmptyClusterPosition_KeepsThePayloadWhenTheClusterGrows(empty, not at 0) still keeps it.MatroskaTag.Picturesremarks now say that new Attachments go right after a full first SeekHead, or before the first Cluster when there is no SeekHead. They also list the remaining refusals.ClusterPayloadsdoes.Save_InsertedFlagWhoseLaterElementsCannotMove_FailsAndWritesNothing. A missing FlagEnabled, no Void after Tracks, and a 9-octet CueClusterPosition: the save fails, the file is unchanged,Renderis empty, and the error names the Cues. Reverting M9 turns it red.Before/after, on the reviewer's 384-cell grid, fbce9f2 against 6f43934 (
ef530c7changes only an empty Position at offset 0):k-ref-empty: 4 cells refused → saved, as intended.verify.py.Gates at
fb58a98:dotnet build -c Release: 0 warnings, 0 errors.dotnet test -c Release: net8.0 and net10.0 4944 passed / 23 skipped.dotnet format --verify-no-changes: clean.TAGLIBSHARP2_TEST_MATROSKA: 51 files pass. They are the 8 TaglibSharpSamples Matroska files, Turning Lime, 13 generated files (gen.webm: 5 passed, 3 skipped), the 9mf-*files, the reviewer's 18 crafted files, and 2 new crafted files with empty values.PR #151: this PR's
MatroskaRewrite.csreplaces #151's Cues loops when both merge. #151's SimpleTag depth cap and tests are kept.Round 6
Commit
cf7efc9(headcf7efc9), docs only:TryMoveCueValuecomment and the Round 5 bullet now say that CueCodecState defaults to 0 (RFC 9559 §5.1.5.1.2.6), while the other three Cues positions have no default. The CHANGELOG says an empty Cues position is kept, or written wider when the offset 0 it names moves.dotnet build -c Release, 0 warnings, 0 errors;dotnet format --verify-no-changes, clean. No code changed.