1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 09:56:07 +03:00

mp4: Add tapt, prof, enof and clap boxes

This commit is contained in:
Mattias Wadman 2021-11-19 15:24:53 +01:00
parent 9cba69e64d
commit 278e909a2f
4 changed files with 43 additions and 13 deletions

View File

@ -274,6 +274,7 @@ func init() {
d.FieldU24("flags")
d.FieldU16("graphicsmode")
d.FieldArray("opcolor", func(d *decode.D) {
// TODO: is FP16?
d.FieldU16("value")
d.FieldU16("value")
d.FieldU16("value")
@ -1205,5 +1206,34 @@ func init() {
d.FieldRawLen("data", d.BitsLeft())
}
},
"tapt": decodeBoxes,
"clef": func(_ *decodeContext, d *decode.D) {
d.FieldU8("version")
d.FieldU24("flags")
d.FieldFP32("width")
d.FieldFP32("height")
},
"prof": func(_ *decodeContext, d *decode.D) {
d.FieldU8("version")
d.FieldU24("flags")
d.FieldFP32("width")
d.FieldFP32("height")
},
"enof": func(_ *decodeContext, d *decode.D) {
d.FieldU8("version")
d.FieldU24("flags")
d.FieldFP32("width")
d.FieldFP32("height")
},
"clap": func(_ *decodeContext, d *decode.D) {
d.FieldU32("aperture_width_n")
d.FieldU32("aperture_width_d")
d.FieldU32("aperture_height_n")
d.FieldU32("aperture_height_d")
d.FieldU32("horiz_off_n")
d.FieldU32("horiz_off_d")
d.FieldU32("vert_off_n")
d.FieldU32("vert_off_d")
},
}
}

View File

@ -358,7 +358,7 @@ func (d *D) tryFE(nBits int, endian Endian) (float64, error) {
}
}
func (d *D) tryFPE(nBits int, fBits int64, endian Endian) (float64, error) {
func (d *D) tryFPE(nBits int, fBits int, endian Endian) (float64, error) {
n, err := d.bits(nBits)
if err != nil {
return 0, err

View File

@ -12798,9 +12798,9 @@ func (d *D) FieldF64BE(name string, sfns ...ScalarFn) float64 {
// Reader FP
// TryFP tries to read nBits fixed-point number in current endian
func (d *D) TryFP(nBits int, fBits int64) (float64, error) { return d.tryFPE(nBits, fBits, d.Endian) }
func (d *D) TryFP(nBits int, fBits int) (float64, error) { return d.tryFPE(nBits, fBits, d.Endian) }
func (d *D) ScalarFP(nBits int, fBits int64) func(Scalar) (Scalar, error) {
func (d *D) ScalarFP(nBits int, fBits int) func(Scalar) (Scalar, error) {
return func(s Scalar) (Scalar, error) {
v, err := d.tryFPE(nBits, fBits, d.Endian)
s.Actual = v
@ -12809,7 +12809,7 @@ func (d *D) ScalarFP(nBits int, fBits int64) func(Scalar) (Scalar, error) {
}
// FP reads nBits fixed-point number in current endian
func (d *D) FP(nBits int, fBits int64) float64 {
func (d *D) FP(nBits int, fBits int) float64 {
v, err := d.tryFPE(nBits, fBits, d.Endian)
if err != nil {
panic(IOError{Err: err, Op: "FP", Pos: d.Pos()})
@ -12818,7 +12818,7 @@ func (d *D) FP(nBits int, fBits int64) float64 {
}
// TryFieldFP tries to add a field and read nBits fixed-point number in current endian
func (d *D) TryFieldFP(name string, nBits int, fBits int64, sfns ...ScalarFn) (float64, error) {
func (d *D) TryFieldFP(name string, nBits int, fBits int, sfns ...ScalarFn) (float64, error) {
v, err := d.TryFieldScalar(name, d.ScalarFP(nBits, fBits), sfns...)
if err != nil {
return 0, err
@ -12827,7 +12827,7 @@ func (d *D) TryFieldFP(name string, nBits int, fBits int64, sfns ...ScalarFn) (f
}
// FieldFP adds a field and reads nBits fixed-point number in current endian
func (d *D) FieldFP(name string, nBits int, fBits int64, sfns ...ScalarFn) float64 {
func (d *D) FieldFP(name string, nBits int, fBits int, sfns ...ScalarFn) float64 {
v, err := d.TryFieldFP(name, nBits, fBits, sfns...)
if err != nil {
panic(IOError{Err: err, Name: name, Op: "FP", Pos: d.Pos()})
@ -12838,11 +12838,11 @@ func (d *D) FieldFP(name string, nBits int, fBits int64, sfns ...ScalarFn) float
// Reader FPE
// TryFPE tries to read nBits fixed-point number in specified endian
func (d *D) TryFPE(nBits int, fBits int64, endian Endian) (float64, error) {
func (d *D) TryFPE(nBits int, fBits int, endian Endian) (float64, error) {
return d.tryFPE(nBits, fBits, endian)
}
func (d *D) ScalarFPE(nBits int, fBits int64, endian Endian) func(Scalar) (Scalar, error) {
func (d *D) ScalarFPE(nBits int, fBits int, endian Endian) func(Scalar) (Scalar, error) {
return func(s Scalar) (Scalar, error) {
v, err := d.tryFPE(nBits, fBits, endian)
s.Actual = v
@ -12851,7 +12851,7 @@ func (d *D) ScalarFPE(nBits int, fBits int64, endian Endian) func(Scalar) (Scala
}
// FPE reads nBits fixed-point number in specified endian
func (d *D) FPE(nBits int, fBits int64, endian Endian) float64 {
func (d *D) FPE(nBits int, fBits int, endian Endian) float64 {
v, err := d.tryFPE(nBits, fBits, endian)
if err != nil {
panic(IOError{Err: err, Op: "FPE", Pos: d.Pos()})
@ -12860,7 +12860,7 @@ func (d *D) FPE(nBits int, fBits int64, endian Endian) float64 {
}
// TryFieldFPE tries to add a field and read nBits fixed-point number in specified endian
func (d *D) TryFieldFPE(name string, nBits int, fBits int64, endian Endian, sfns ...ScalarFn) (float64, error) {
func (d *D) TryFieldFPE(name string, nBits int, fBits int, endian Endian, sfns ...ScalarFn) (float64, error) {
v, err := d.TryFieldScalar(name, d.ScalarFPE(nBits, fBits, endian), sfns...)
if err != nil {
return 0, err
@ -12869,7 +12869,7 @@ func (d *D) TryFieldFPE(name string, nBits int, fBits int64, endian Endian, sfns
}
// FieldFPE adds a field and reads nBits fixed-point number in specified endian
func (d *D) FieldFPE(name string, nBits int, fBits int64, endian Endian, sfns ...ScalarFn) float64 {
func (d *D) FieldFPE(name string, nBits int, fBits int, endian Endian, sfns ...ScalarFn) float64 {
v, err := d.TryFieldFPE(name, nBits, fBits, endian, sfns...)
if err != nil {
panic(IOError{Err: err, Name: name, Op: "FPE", Pos: d.Pos()})

View File

@ -76,14 +76,14 @@
{
"name": "",
"args": "nBits, fBits",
"params": "nBits int, fBits int64",
"params": "nBits int, fBits int",
"call": "d.tryFPE(nBits, fBits, d.Endian)",
"doc": "nBits fixed-point number in current endian"
},
{
"name": "E",
"args": "nBits, fBits, endian",
"params": "nBits int, fBits int64, endian Endian",
"params": "nBits int, fBits int, endian Endian",
"call": "d.tryFPE(nBits, fBits, endian)",
"doc": "nBits fixed-point number in specified endian"
},