Subject: Re: [Cellar] Position References vs Linked Segments

From: Dave Rice <[email-masked]>
Date: Tue, 13 Dec 2016 19:38:07 -0500

> On Jul 4, 2016, at 11:03 AM, Steve Lhomme <[email-masked]> wrote:
> 
> 2016-07-04 12:57 GMT+02:00 Moritz Bunkus <[email-masked]>:
>> Hey,
>> 
>>> Although this section is linked to the documentation the term Position
>>> Reference is never used outside the definition. I propose changing the
>>> term from Position Reference to Segment Offset, if I properly
>>> understand that the term refers to the offset within from the Segment
>>> or from the first Segment of a Linked Segment.
>> 
>> +1
> +1
> 
>>> Also, I'm curious if this part of the documentation is correct: "For
>>> example to reference a position in the third segment, the position
>>> will be: the first segment total size + second segment total size +
>>> offset of the element in the third segment."
>> 
>> I'm almost certain that it should be the segment's data sizes that are
>> added excluding their element ID and size field size.
>> 
>>> But are you sure that it is not
>>> 
>>> Segment1:Data + Segment2:TotalSize + Segment3:ElementID + Segment3:DataSize + Segment3:OffsetToElement =
>>> 100 + 211 + 4 + 8 + 300 = 623
>> 
>> Meaning I agree that this should be correct. It was probably an
>> oversight, or we simply weren't careful enough with our wording.
> 
> Yes, offsets should exclude the EBML header and the Segment header (ID
> + length).
> 
> Moritz, when splitting a file with tags or chapters, do you put them
> in each segment or refer to them with an offset in one of the segments
> ?
> Do we have a real life case where we reference an element outside of
> its own Segment ?

This discussion continued a bit in a pull request, notably:
https://github.com/Matroska-Org/matroska-specification/pull/26#issuecomment-230740374
https://github.com/Matroska-Org/matroska-specification/pull/26#issuecomment-232136509

Based on Moritz's comments it seems that the Position Reference refers to the encapsulating Segment and not the first Segment (as in a Linked Segment). If this is the case, then it conflicts with the earlier draft of the Matroska specifications at https://matroska.org/technical/specs/notes.html where it says:

> When data is spanned over mutiple "linked Segments" (in the same file or in different files), the position represents the accumulated offset of each Segment. For example to reference a position in the third segment, the position will be: the first segment total size + second segment total size + offset of the element in the third segment. 

I can adjust the pull request to define Position Reference (or the proposal rename to Segment Position) as only relative to the encapsulating Segment regardless of Segment Linking, but since this partly contradicts historical Matroska documentation I wanted to seek any objections or opinions on the matter.

Best Regards,
Dave Rice