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
|
|
|
|
}
|