Skip to content

Commit

Permalink
Merge pull request #581 from wader/matroska-unknown-size-test
Browse files Browse the repository at this point in the history
matroska: Add unknown size test and add description to ebml header
  • Loading branch information
wader authored Feb 10, 2023
2 parents 4579c7e + 9aaf2dd commit 9bad378
Show file tree
Hide file tree
Showing 16 changed files with 450 additions and 92 deletions.
14 changes: 7 additions & 7 deletions format/matroska/ebml/ebml.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ var Header = &Master{
Name: "ebml",
},
Master: map[ID]Element{
EBMLVersionID: &Uinteger{ElementType: ElementType{Name: "ebml_version"}},
EBMLReadVersionID: &Uinteger{ElementType: ElementType{Name: "ebml_read_version"}},
EBMLMaxIDLengthID: &Uinteger{ElementType: ElementType{Name: "ebml_max_id_length"}},
EBMLMaxSizeLengthID: &Uinteger{ElementType: ElementType{Name: "ebml_max_size_length"}},
DocTypeID: &String{ElementType: ElementType{Name: "doc_type"}},
DocTypeVersionID: &Uinteger{ElementType: ElementType{Name: "doc_type_version"}},
DocTypeReadVersionID: &Uinteger{ElementType: ElementType{Name: "doc_type_read_version"}},
EBMLVersionID: &Uinteger{ElementType: ElementType{Name: "ebml_version", Definition: "EBML Version"}},
EBMLReadVersionID: &Uinteger{ElementType: ElementType{Name: "ebml_read_version", Definition: "Minimum EBML reader version"}},
EBMLMaxIDLengthID: &Uinteger{ElementType: ElementType{Name: "ebml_max_id_length", Definition: "Maximum id length"}},
EBMLMaxSizeLengthID: &Uinteger{ElementType: ElementType{Name: "ebml_max_size_length", Definition: "Maximum body length"}},
DocTypeID: &String{ElementType: ElementType{Name: "doc_type", Definition: "Document content type"}},
DocTypeVersionID: &Uinteger{ElementType: ElementType{Name: "doc_type_version", Definition: "Document type version"}},
DocTypeReadVersionID: &Uinteger{ElementType: ElementType{Name: "doc_type_read_version", Definition: "Minimum document reader version"}},
},
}

Expand Down
2 changes: 1 addition & 1 deletion format/matroska/matroska.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func decodeMaster(d *decode.D, bitsLimit int64, elm *ebml.Master, unknownSize bo

const maxStringTagSize = 100 * 1024 * 1024
tagSize := d.FieldUintFn("size", decodeVint, scalar.UintMapDescription{
0xffffffffffffff: "unknown",
0xffffffffffffff: "Unknown size",
})
unknownSize := tagSize == tagSizeUnknown
if unknownSize {
Expand Down
14 changes: 7 additions & 7 deletions format/matroska/testdata/aac.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ $ fq -d matroska dv aac.mkv
0x000| a3 | . | size: 35 0x4-0x4.7 (1)
| | | elements[0:7]: 0x5-0x27.7 (35)
| | | [0]{}: element 0x5-0x8.7 (4)
0x000| 42 86 | B. | id: "ebml_version" (0x4286) 0x5-0x6.7 (2)
0x000| 42 86 | B. | id: "ebml_version" (0x4286) (EBML Version) 0x5-0x6.7 (2)
| | | type: "uinteger" 0x7-NA (0)
0x000| 81 | . | size: 1 0x7-0x7.7 (1)
0x000| 01 | . | value: 1 0x8-0x8.7 (1)
| | | [1]{}: element 0x9-0xc.7 (4)
0x000| 42 f7 | B. | id: "ebml_read_version" (0x42f7) 0x9-0xa.7 (2)
0x000| 42 f7 | B. | id: "ebml_read_version" (0x42f7) (Minimum EBML reader version) 0x9-0xa.7 (2)
| | | type: "uinteger" 0xb-NA (0)
0x000| 81 | . | size: 1 0xb-0xb.7 (1)
0x000| 01 | . | value: 1 0xc-0xc.7 (1)
| | | [2]{}: element 0xd-0x10.7 (4)
0x000| 42 f2 | B. | id: "ebml_max_id_length" (0x42f2) 0xd-0xe.7 (2)
0x000| 42 f2 | B. | id: "ebml_max_id_length" (0x42f2) (Maximum id length) 0xd-0xe.7 (2)
| | | type: "uinteger" 0xf-NA (0)
0x000| 81| .| size: 1 0xf-0xf.7 (1)
0x010|04 |. | value: 4 0x10-0x10.7 (1)
| | | [3]{}: element 0x11-0x14.7 (4)
0x010| 42 f3 | B. | id: "ebml_max_size_length" (0x42f3) 0x11-0x12.7 (2)
0x010| 42 f3 | B. | id: "ebml_max_size_length" (0x42f3) (Maximum body length) 0x11-0x12.7 (2)
| | | type: "uinteger" 0x13-NA (0)
0x010| 81 | . | size: 1 0x13-0x13.7 (1)
0x010| 08 | . | value: 8 0x14-0x14.7 (1)
| | | [4]{}: element 0x15-0x1f.7 (11)
0x010| 42 82 | B. | id: "doc_type" (0x4282) 0x15-0x16.7 (2)
0x010| 42 82 | B. | id: "doc_type" (0x4282) (Document content type) 0x15-0x16.7 (2)
| | | type: "string" 0x17-NA (0)
0x010| 88 | . | size: 8 0x17-0x17.7 (1)
0x010| 6d 61 74 72 6f 73 6b 61| matroska| value: "matroska" 0x18-0x1f.7 (8)
| | | [5]{}: element 0x20-0x23.7 (4)
0x020|42 87 |B. | id: "doc_type_version" (0x4287) 0x20-0x21.7 (2)
0x020|42 87 |B. | id: "doc_type_version" (0x4287) (Document type version) 0x20-0x21.7 (2)
| | | type: "uinteger" 0x22-NA (0)
0x020| 81 | . | size: 1 0x22-0x22.7 (1)
0x020| 04 | . | value: 4 0x23-0x23.7 (1)
| | | [6]{}: element 0x24-0x27.7 (4)
0x020| 42 85 | B. | id: "doc_type_read_version" (0x4285) 0x24-0x25.7 (2)
0x020| 42 85 | B. | id: "doc_type_read_version" (0x4285) (Minimum document reader version) 0x24-0x25.7 (2)
| | | type: "uinteger" 0x26-NA (0)
0x020| 81 | . | size: 1 0x26-0x26.7 (1)
0x020| 02 | . | value: 2 0x27-0x27.7 (1)
Expand Down
14 changes: 7 additions & 7 deletions format/matroska/testdata/av1.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ $ fq -d matroska dv av1.mkv
0x0000| a3 | . | size: 35 0x4-0x4.7 (1)
| | | elements[0:7]: 0x5-0x27.7 (35)
| | | [0]{}: element 0x5-0x8.7 (4)
0x0000| 42 86 | B. | id: "ebml_version" (0x4286) 0x5-0x6.7 (2)
0x0000| 42 86 | B. | id: "ebml_version" (0x4286) (EBML Version) 0x5-0x6.7 (2)
| | | type: "uinteger" 0x7-NA (0)
0x0000| 81 | . | size: 1 0x7-0x7.7 (1)
0x0000| 01 | . | value: 1 0x8-0x8.7 (1)
| | | [1]{}: element 0x9-0xc.7 (4)
0x0000| 42 f7 | B. | id: "ebml_read_version" (0x42f7) 0x9-0xa.7 (2)
0x0000| 42 f7 | B. | id: "ebml_read_version" (0x42f7) (Minimum EBML reader version) 0x9-0xa.7 (2)
| | | type: "uinteger" 0xb-NA (0)
0x0000| 81 | . | size: 1 0xb-0xb.7 (1)
0x0000| 01 | . | value: 1 0xc-0xc.7 (1)
| | | [2]{}: element 0xd-0x10.7 (4)
0x0000| 42 f2 | B. | id: "ebml_max_id_length" (0x42f2) 0xd-0xe.7 (2)
0x0000| 42 f2 | B. | id: "ebml_max_id_length" (0x42f2) (Maximum id length) 0xd-0xe.7 (2)
| | | type: "uinteger" 0xf-NA (0)
0x0000| 81| .| size: 1 0xf-0xf.7 (1)
0x0010|04 |. | value: 4 0x10-0x10.7 (1)
| | | [3]{}: element 0x11-0x14.7 (4)
0x0010| 42 f3 | B. | id: "ebml_max_size_length" (0x42f3) 0x11-0x12.7 (2)
0x0010| 42 f3 | B. | id: "ebml_max_size_length" (0x42f3) (Maximum body length) 0x11-0x12.7 (2)
| | | type: "uinteger" 0x13-NA (0)
0x0010| 81 | . | size: 1 0x13-0x13.7 (1)
0x0010| 08 | . | value: 8 0x14-0x14.7 (1)
| | | [4]{}: element 0x15-0x1f.7 (11)
0x0010| 42 82 | B. | id: "doc_type" (0x4282) 0x15-0x16.7 (2)
0x0010| 42 82 | B. | id: "doc_type" (0x4282) (Document content type) 0x15-0x16.7 (2)
| | | type: "string" 0x17-NA (0)
0x0010| 88 | . | size: 8 0x17-0x17.7 (1)
0x0010| 6d 61 74 72 6f 73 6b 61| matroska| value: "matroska" 0x18-0x1f.7 (8)
| | | [5]{}: element 0x20-0x23.7 (4)
0x0020|42 87 |B. | id: "doc_type_version" (0x4287) 0x20-0x21.7 (2)
0x0020|42 87 |B. | id: "doc_type_version" (0x4287) (Document type version) 0x20-0x21.7 (2)
| | | type: "uinteger" 0x22-NA (0)
0x0020| 81 | . | size: 1 0x22-0x22.7 (1)
0x0020| 04 | . | value: 4 0x23-0x23.7 (1)
| | | [6]{}: element 0x24-0x27.7 (4)
0x0020| 42 85 | B. | id: "doc_type_read_version" (0x4285) 0x24-0x25.7 (2)
0x0020| 42 85 | B. | id: "doc_type_read_version" (0x4285) (Minimum document reader version) 0x24-0x25.7 (2)
| | | type: "uinteger" 0x26-NA (0)
0x0020| 81 | . | size: 1 0x26-0x26.7 (1)
0x0020| 02 | . | value: 2 0x27-0x27.7 (1)
Expand Down
14 changes: 7 additions & 7 deletions format/matroska/testdata/avc.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ $ fq -d matroska dv avc.mkv
0x00000| a3 | . | size: 35 0x4-0x4.7 (1)
| | | elements[0:7]: 0x5-0x27.7 (35)
| | | [0]{}: element 0x5-0x8.7 (4)
0x00000| 42 86 | B. | id: "ebml_version" (0x4286) 0x5-0x6.7 (2)
0x00000| 42 86 | B. | id: "ebml_version" (0x4286) (EBML Version) 0x5-0x6.7 (2)
| | | type: "uinteger" 0x7-NA (0)
0x00000| 81 | . | size: 1 0x7-0x7.7 (1)
0x00000| 01 | . | value: 1 0x8-0x8.7 (1)
| | | [1]{}: element 0x9-0xc.7 (4)
0x00000| 42 f7 | B. | id: "ebml_read_version" (0x42f7) 0x9-0xa.7 (2)
0x00000| 42 f7 | B. | id: "ebml_read_version" (0x42f7) (Minimum EBML reader version) 0x9-0xa.7 (2)
| | | type: "uinteger" 0xb-NA (0)
0x00000| 81 | . | size: 1 0xb-0xb.7 (1)
0x00000| 01 | . | value: 1 0xc-0xc.7 (1)
| | | [2]{}: element 0xd-0x10.7 (4)
0x00000| 42 f2 | B. | id: "ebml_max_id_length" (0x42f2) 0xd-0xe.7 (2)
0x00000| 42 f2 | B. | id: "ebml_max_id_length" (0x42f2) (Maximum id length) 0xd-0xe.7 (2)
| | | type: "uinteger" 0xf-NA (0)
0x00000| 81| .| size: 1 0xf-0xf.7 (1)
0x00010|04 |. | value: 4 0x10-0x10.7 (1)
| | | [3]{}: element 0x11-0x14.7 (4)
0x00010| 42 f3 | B. | id: "ebml_max_size_length" (0x42f3) 0x11-0x12.7 (2)
0x00010| 42 f3 | B. | id: "ebml_max_size_length" (0x42f3) (Maximum body length) 0x11-0x12.7 (2)
| | | type: "uinteger" 0x13-NA (0)
0x00010| 81 | . | size: 1 0x13-0x13.7 (1)
0x00010| 08 | . | value: 8 0x14-0x14.7 (1)
| | | [4]{}: element 0x15-0x1f.7 (11)
0x00010| 42 82 | B. | id: "doc_type" (0x4282) 0x15-0x16.7 (2)
0x00010| 42 82 | B. | id: "doc_type" (0x4282) (Document content type) 0x15-0x16.7 (2)
| | | type: "string" 0x17-NA (0)
0x00010| 88 | . | size: 8 0x17-0x17.7 (1)
0x00010| 6d 61 74 72 6f 73 6b 61| matroska| value: "matroska" 0x18-0x1f.7 (8)
| | | [5]{}: element 0x20-0x23.7 (4)
0x00020|42 87 |B. | id: "doc_type_version" (0x4287) 0x20-0x21.7 (2)
0x00020|42 87 |B. | id: "doc_type_version" (0x4287) (Document type version) 0x20-0x21.7 (2)
| | | type: "uinteger" 0x22-NA (0)
0x00020| 81 | . | size: 1 0x22-0x22.7 (1)
0x00020| 04 | . | value: 4 0x23-0x23.7 (1)
| | | [6]{}: element 0x24-0x27.7 (4)
0x00020| 42 85 | B. | id: "doc_type_read_version" (0x4285) 0x24-0x25.7 (2)
0x00020| 42 85 | B. | id: "doc_type_read_version" (0x4285) (Minimum document reader version) 0x24-0x25.7 (2)
| | | type: "uinteger" 0x26-NA (0)
0x00020| 81 | . | size: 1 0x26-0x26.7 (1)
0x00020| 02 | . | value: 2 0x27-0x27.7 (1)
Expand Down
Loading

0 comments on commit 9bad378

Please sign in to comment.