Skip to content

Commit

Permalink
Merge pull request #99 from TrustNXT/bugfix/bmff-extents
Browse files Browse the repository at this point in the history
BMFF: Fix shifting of extents
  • Loading branch information
cyraxx authored Sep 9, 2024
2 parents 2b3f44b + 3464be0 commit dc77867
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-crews-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@trustnxt/c2pa-ts': patch
---

BMFF: Fix adjustment of extents in iloc box
6 changes: 3 additions & 3 deletions src/asset/BMFF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class ItemLocationBox extends FullBox<ItemLocationBoxPayload> {

for (const item of this.payload.items) {
pos += this.payload.version === 2 ? 4 : 2; // item_ID
if (this.payload.version > 0) pos++; // reserved, construction_method
if (this.payload.version > 0) pos += 2; // reserved, construction_method
pos += 2; // data_reference_index
if (this.payload.baseOffsetSize === 8) {
item.baseOffset = (item.baseOffset as bigint) + BigInt(amount);
Expand All @@ -543,8 +543,8 @@ class ItemLocationBox extends FullBox<ItemLocationBoxPayload> {
for (const extent of item.extents) {
if (this.payload.indexSize) pos += this.payload.indexSize;
if (
(item.constructionMethod ??
ItemLocationConstructionMethod.file === ItemLocationConstructionMethod.file) &&
(item.constructionMethod ?? ItemLocationConstructionMethod.file) ===
ItemLocationConstructionMethod.file &&
item.baseOffset === 0 &&
extent.offset !== 0
) {
Expand Down

0 comments on commit dc77867

Please sign in to comment.