Skip to content

Commit

Permalink
Fix colr for unknown colour type
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfish-shogi committed Nov 8, 2020
1 parent c04bd51 commit 55702ef
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
29 changes: 17 additions & 12 deletions box_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,27 @@ type Colr struct {
FullRangeFlag bool `mp4:"size=1,opt=dynamic"`
Reserved uint8 `mp4:"size=7,opt=dynamic"`
Profile []byte `mp4:"size=8,opt=dynamic"`
Unknown []byte `mp4:"size=8,opt=dynamic"`
}

func (colr *Colr) IsOptFieldEnabled(name string) bool {
switch name {
case "ColourType",
"ColourPrimaries",
"TransferCharacteristics",
"MatrixCoefficients",
"FullRangeFlag",
"Reserved":
return colr.ColourType == [4]byte{'n', 'c', 'l', 'x'}
case "Profile":
return colr.ColourType == [4]byte{'r', 'I', 'C', 'C'} ||
colr.ColourType == [4]byte{'p', 'r', 'o', 'f'}
switch colr.ColourType {
case [4]byte{'n', 'c', 'l', 'x'}:
switch name {
case "ColourType",
"ColourPrimaries",
"TransferCharacteristics",
"MatrixCoefficients",
"FullRangeFlag",
"Reserved":
return true
default:
return false
}
case [4]byte{'r', 'I', 'C', 'C'}, [4]byte{'p', 'r', 'o', 'f'}:
return name == "Profile"
default:
return false
return name == "Unknown"
}
}

Expand Down
13 changes: 13 additions & 0 deletions box_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ func TestBoxTypes(t *testing.T) {
},
str: `ColourType="rICC" Profile=[0x12, 0x34, 0x56, 0x78, 0xab]`,
},
{
name: "colr: nclc",
src: &Colr{
ColourType: [4]byte{'n', 'c', 'l', 'c'},
Unknown: []byte{0x01, 0x23, 0x45},
},
dst: &Colr{},
bin: []byte{
'n', 'c', 'l', 'c',
0x01, 0x23, 0x45,
},
str: `ColourType="nclc" Unknown=[0x1, 0x23, 0x45]`,
},
{
name: "ctts: version 0",
src: &Ctts{
Expand Down

0 comments on commit 55702ef

Please sign in to comment.