1
1
mirror of https://github.com/wader/fq.git synced 2024-12-26 23:15:04 +03:00
fq/format/mpeg/avc_au.go

41 lines
808 B
Go
Raw Normal View History

2020-06-08 03:29:51 +03:00
package mpeg
// ISO/IEC 14496-15, 5.3.3.1.2 Syntax
import (
"fq/format"
"fq/format/registry"
"fq/pkg/decode"
)
2021-08-09 16:45:59 +03:00
var avcNALUFormat []*decode.Format
2020-06-08 03:29:51 +03:00
func init() {
registry.MustRegister(&decode.Format{
Name: format.AVC_AU,
Description: "H.264/AVC Access Unit",
DecodeFn: avcAUDecode,
Dependencies: []decode.Dependency{
2021-08-09 16:45:59 +03:00
{Names: []string{format.AVC_NALU}, Formats: &avcNALUFormat},
2020-06-08 03:29:51 +03:00
},
})
}
func avcAUDecode(d *decode.D, in interface{}) interface{} {
avcIn, ok := in.(format.AvcIn)
if !ok {
d.Invalid("avcIn required")
}
d.FieldArrayFn("access_unit", func(d *decode.D) {
for d.NotEnd() {
d.FieldStructFn("nalu", func(d *decode.D) {
l := d.FieldU("length", int(avcIn.LengthSize)*8)
2021-08-09 16:45:59 +03:00
d.FieldDecodeLen("nalu", int64(l)*8, avcNALUFormat)
2020-06-08 03:29:51 +03:00
})
}
})
return nil
}