Subject: Re: [Cellar] Matroska Interlacement proposal draft (+ minver and webm in EBML Schemas)

From: Dave Rice <[email-masked]>
Date: Sun, 13 Mar 2016 13:58:37 -0400

> On Jan 26, 2016, at 6:53 AM, Steve Lhomme <[email-masked]> wrote:
> 
> 2016-01-22 6:29 GMT+01:00 Dave Rice <[email-masked]>:
>> 
>>> On Jan 14, 2016, at 7:13 AM, Steve Lhomme <[email-masked]> wrote:
>>> 
>>> 2016-01-11 21:42 GMT+01:00 Dave Rice <[email-masked]>:
>>>> 
>>>>> On Jan 11, 2016, at 1:21 PM, Sebastian G. <bastik> wrote:
>>>>> 
>>>>> 11.01.2016, 18:08 Dave Rice:
>>>>>> Update FlagInterlaced  version 3
>>>>>> =============
>>>>>> Element Name: FlagInterlaced
>>>>>> Level:        4
>>>>>> ID:           [9A]
>>>>>> Mandatory:    mand.
>>>>>> Multiple:     -
>>>>>> Range:  0-2
>>>>>> Default:      0
>>>>>> Type:         u
>>>>>> Description:         A flag to declare is the video is known to be progressive or interlaced and if applicable to declare details about the interlacement.
>>>>>>                    0: undetermined
>>>>>>                    1: interlacement (unknown field ordering)
>>>>> 
>>>>> '(unknown field order)' is not required if it is split into to elements.
>>>>> I have no preference for or against splitting it up.
>>>>> 
>>>>>>                    2: progressive
>>>>>> 
>>>>>> Element Name: FieldOrdering
>>>>>> Level:        4
>>>>>> ID:           [9D]
>>>>>> Mandatory:    mand.
>>>>>> Multiple:     -
>>>>>> Range:  0-2
>>>>>> Default:      0
>>>>>> Type:         u
>>>>>> Description:  Declare the field ordering of the video. If FlagInterlaced is not set to 1, this Element MUST be ignored.
>>>>>> 
>>>>>> 0       undetermined
>>>>>> 1       interlaced (bottom field first)
>>>>>> 2       interlaced (top field first)
>>>>> 
>>>>> I think that using '0' as no statement is a good decision.
>>>> 
>>>> […]
>>>> 
>>>> Based on comments, I made the following patch. I also renamed the proposed “FieldOrdering” element to “Field Order” and change the meaning of FlagInterlaced=1 to simply “interlaced”.
>>>> 
>>>> Creating the patch for specdata.xml brought up two new issues:
>>>> 
>>>> The format of specdata.xml includes an attribute called ‘minver’ to refer to which version of Matroska began supporting the element. According to matroska.org "Version 4 is currently work in progress. There may be further additions to v4.”; however there has been no distinction within specdata.xml between ‘in progress’ and official. Perhaps Matroska should mark version 4 as official as-is and the ongoing work within CELLAR would work towards a release of version 5. In the patch below I used minver=“5RC” as (version 5 release candidate) in infer that it is not official (yet).
>>>> 
>>>> Also specdata.xml includes a boolean attribute to say if the element is supported by webm. FlagInterlaced is supported by webm (as correlates to http://www.webmproject.org/docs/container/), but I’m leaving webm=“1” off of the new element “FieldOrder” (as I’m not on that team).
>>>> 
>>>> From 5d7f7b8122232c20a3e39de70d587f684b48cd2f Mon Sep 17 00:00:00 2001
>>>> From: dericed <[email-masked]>
>>>> Date: Mon, 11 Jan 2016 15:11:26 -0500
>>>> Subject: [PATCH] clarify FlagInterlaced and add FieldOrder element
>>>> 
>>>> ---
>>>> spectool/specdata.xml | 3 ++-
>>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>> 
>>>> diff --git a/spectool/specdata.xml b/spectool/specdata.xml
>>>> index 57abb97..2167e15 100644
>>>> --- a/spectool/specdata.xml
>>>> +++ b/spectool/specdata.xml
>>>> @@ -109,7 +109,8 @@ between two successive fields at the output of the decoding process (see <a href
>>>>  <element name="TrackTranslateCodec" level="4" id="0x66BF" type="uinteger" mandatory="1" minver="1" webm="0">The <a href="http://www.matroska.org/technical/specs/index.html#ChapProcessCodecID">chapter codec</a> using this ID (0: Matroska Script, 1: DVD-menu).</element>
>>>>  <element name="TrackTranslateTrackID" level="4" id="0x66A5" type="binary" mandatory="1" minver="1" webm="0">The binary value used to represent this track in the chapter codec data. The format depends on the <a href="http://www.matroska.org/technical/specs/index.html#ChapProcessCodecID">ChapProcessCodecID</a> used.</element>
>>>>  <element name="Video" cppname="TrackVideo" level="3" id="0xE0" type="master" minver="1">Video settings.</element>
>>>> -  <element name="FlagInterlaced" cppname="VideoFlagInterlaced" level="4" id="0x9A" type="uinteger" mandatory="1" minver="2" webm="1" default="0" range="0-1">Set if the video is interlaced. (1 bit)</element>
>>>> +  <element name="FlagInterlaced" cppname="VideoFlagInterlaced" level="4" id="0x9A" type="uinteger" mandatory="1" minver="2" webm="1" default="0" range="0-2">A flag to declare is the video is known to be progressive or interlaced and if applicable to declare details about the interlacement. (0: undetermined, 1: interlaced, 2: progressive)</element>
>>>> +  <element name="FieldOrder" cppname="VideoFieldOrder" level="4" id="0x9D" type="uinteger" mandatory="1" minver="5RC" default="0" range="0-2">Declare the field ordering of the video. If FlagInterlaced is not set to 1, this Element MUST be ignored. (0: undetermined, 1: interlaced with bottom field first, 2: interlaced with top field first)</element>
>>> 
>>> I'll have to check if the spec generating tools supports minver as a
>>> non integer before merging this.
>> 
>> So perhaps we should have a separate xml for drafting while the work on the version is underway. Such as:
>> 
>> - specdata.xml (as the official version 4 EBML Schema)
>> - specdata_v5_draft.xml as a working document to patch to until Matroska version 5 is deemed official
> 
> Sounds like a good plan.
> 
>>>>  <element name="StereoMode" cppname="VideoStereoMode" level="4" id="0x53B8" type="uinteger" minver="3" webm="1" default="0">Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on <a href="http://www.matroska.org/technical/specs/notes.html#3D">3D support in the Specification Notes</a>.</element>
>>>>  <element name="AlphaMode" cppname="VideoAlphaMode" level="4" id="0x53C0" type="uinteger" minver="3" webm="1" default="0">Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data.</element>  <element name="OldStereoMode" level="4" id="0x53B9" type="uinteger" maxver="0" webm="0" divx="0">DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes).</element>
>>>>  <element name="PixelWidth" cppname="VideoPixelWidth" level="4" id="0xB0" type="uinteger" mandatory="1" minver="1" range="not 0">Width of the encoded video frames in pixels.</element>
>>>> —
>>>> 2.6.4

I’ve updated this proposal for interlacement fields. The FieldOrder element now reflects the same options as used in the second byte of the fiel atom of the QuickTime spec (https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-124374). See also: https://github.com/FFmpeg/FFmpeg/blob/fb9036b3142e06631a70810c3d779f8e2d9f180c/libavformat/mov.c#L1324-L1336.

A difference between that FieldOrder list provided here and the QuickTime version, is that I added 2 to represent an undefined order (presently any Matroska field with FlagInterlaced and no FieldOrder is technically of an undetermined order, so I think it is necessary to add a value to indicate so).

Note that the list for FlagInterlaced differs from the QuickTime spec. In QuickTime 1=prog and 2=int but this is reversed in Matroska. Too late to change this, but I think it’s sensible to draw from QuickTime for the fieldOrder list.

The definitions are like this:

name: FlagInterlaced
level: 4
id: 0x9A
type: uinteger
mandatory: 1
minver: 2
webm: 1
default: 0
range: 0-2
documentation: A flag to declare is the video is known to be progressive or interlaced and if applicable to declare details about the interlacement. (0: undetermined, 1: interlaced, 2: progressive)

name: FieldOrder
level: 4
id: 0x9D
type: uinteger
mandatory: 1
minver: 4
default: 2
range: 0-14
documentation: Declare the field ordering of the video. If FlagInterlaced is not set to 1, this Element MUST be ignored. (0: Progressive, 1: Interlaced with top field display first and top field stored first, 2: Undetermined field order, 6: Interlaced with bottom field displayed first and bottom field stored first, 9: Interlaced with bottom field displayed first and top field stored first, 14: Interlaced with top field displayed first and bottom field stored first)

I left the minver as 4, but should this be set to 5. I suppose this question applies to the Colour Format proposal as well.

A draft pull request is updated and available at: https://github.com/Matroska-Org/foundation-source/pull/13

Best Regards,
Dave Rice