1
1
mirror of https://github.com/wader/fq.git synced 2024-12-29 00:22:38 +03:00

Merge pull request #176 from wader/mp4-colr

mp4: Add colr box support
This commit is contained in:
Mattias Wadman 2022-03-01 11:54:31 +01:00 committed by GitHub
commit 2a252f9591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 1 deletions

View File

@ -1281,5 +1281,23 @@ func init() {
d.FieldFP16("balance")
d.FieldU16("reserved")
},
}
"colr": func(_ *decodeContext, d *decode.D) {
parameterType := d.FieldUTF8("parameter_type", 4)
switch parameterType {
case "nclx", "nclc":
d.FieldU16("primaries_index", format.ISO_23091_2_ColourPrimariesMap)
d.FieldU16("transfer_function_index", format.ISO_23091_2_TransferCharacteristicMap)
d.FieldU16("matrix_index", format.ISO_23091_2_MatrixCoefficients)
switch parameterType {
case "nclx":
d.FieldU8("color_range")
}
case "prof":
d.FieldFormat("profile", iccProfileFormat, nil)
default:
d.FieldRawLen("data", d.BitsLeft())
}
}}
}

View File

@ -49,6 +49,7 @@ var psshPlayreadyFormat decode.Group
var vorbisPacketFormat decode.Group
var vp9FrameFormat decode.Group
var vpxCCRFormat decode.Group
var iccProfileFormat decode.Group
func init() {
registry.MustRegister(decode.Format{
@ -81,6 +82,7 @@ func init() {
{Names: []string{format.VORBIS_PACKET}, Group: &vorbisPacketFormat},
{Names: []string{format.VP9_FRAME}, Group: &vp9FrameFormat},
{Names: []string{format.VPX_CCR}, Group: &vpxCCRFormat},
{Names: []string{format.ICC_PROFILE}, Group: &iccProfileFormat},
},
Files: mp4FS,
})

18
format/mp4/testdata/colr_box.fqtest vendored Normal file
View File

@ -0,0 +1,18 @@
$ fq -n '"000000106674797069736f6d0000020000000013636f6c726e636c7800010001000100" | hex | mp4 | d'
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (mp4)
| | | boxes[0:2]:
| | | [0]{}:
0x00|00 00 00 10 |.... | size: 16
0x00| 66 74 79 70 | ftyp | type: "ftyp" (File type and compatibility)
0x00| 69 73 6f 6d | isom | major_brand: "isom"
0x00| 00 00 02 00| ....| minor_version: 512
| | | brands[0:0]:
| | | [1]{}:
0x10|00 00 00 13 |.... | size: 19
0x10| 63 6f 6c 72 | colr | type: "colr" (Specifies the colourspace of the image)
0x10| 6e 63 6c 78 | nclx | parameter_type: "nclx"
0x10| 00 01 | .. | primaries_index: "bt709" (1) (ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B)
0x10| 00 01| ..| transfer_function_index: "bt709" (1) (ITU-R BT1361)
0x20|00 01 |.. | matrix_index: "bt709" (1) (ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B)
0x20| 00| | .| | color_range: 0
| | | tracks[0:0]: