contentauth / c2patool

Command line tool for displaying and adding C2PA manifests
Apache License 2.0
107 stars 30 forks source link

JUMBF reassembly from JPEG packets fails if the packet sequence numbers start at 0 #104

Closed faceless2 closed 1 year ago

faceless2 commented 1 year ago

This file fails to parse in c2patool with a JUMBF error

out-startat0.jpg

The next file parses OK

out-startat1

Both files have two app11 segment - the only difference is the Packet Sequence Numbers (defined in ISO19566) for the two segments in the first file are [0, 1] and in the second file are [1, 2]. If there's only a single app11 segment, a value of 0 is accepted.

ISO19556 says:

The Packet Sequence Number is a 32-bit field that specifies the order in which payload data shall be merged. Concatenation proceeds in the order of increasing Packet Sequence Numbers.

and C2PA says:

Since a single marker segment in JPEG-1 cannot be larger than 64K bytes, it is likely that multiple APP11 segments will be required, and they shall be constructed as per the JPEG-1 standard and ISO 19566-5, D.2. When writing multiple segments, they shall be written in sequential order, and they shall be contiguous (i.e., one segment immediately following the next).

Contiguous and in order, but no word on starting values - and 0 is a reasonable place to start.

lrosenthol commented 1 year ago

ISO 18477, which is the original JPEG 1/JPEG-XT box specification standard, clearly states that the value of Z starts at 1

image
faceless2 commented 1 year ago

Doh. Thanks Leonard.