2020-06-08 03:29:51 +03:00
|
|
|
package mpeg
|
|
|
|
|
|
|
|
// ISO/IEC 14496-15, 5.3.3.1.2 Syntax
|
|
|
|
|
|
|
|
import (
|
2021-08-17 13:06:32 +03:00
|
|
|
"github.com/wader/fq/format"
|
|
|
|
"github.com/wader/fq/format/registry"
|
|
|
|
"github.com/wader/fq/pkg/decode"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
|
2021-11-17 18:46:10 +03:00
|
|
|
var avcNALUFormat decode.Group
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
func init() {
|
2021-11-17 18:46:10 +03:00
|
|
|
registry.MustRegister(decode.Format{
|
2020-06-08 03:29:51 +03:00
|
|
|
Name: format.AVC_AU,
|
|
|
|
Description: "H.264/AVC Access Unit",
|
|
|
|
DecodeFn: avcAUDecode,
|
2021-12-09 19:15:21 +03:00
|
|
|
DecodeInArg: format.AvcAuIn{
|
|
|
|
LengthSize: 4,
|
|
|
|
},
|
|
|
|
RootArray: true,
|
|
|
|
RootName: "access_unit",
|
2020-06-08 03:29:51 +03:00
|
|
|
Dependencies: []decode.Dependency{
|
2021-11-17 18:46:10 +03:00
|
|
|
{Names: []string{format.AVC_NALU}, Group: &avcNALUFormat},
|
2020-06-08 03:29:51 +03:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func avcAUDecode(d *decode.D, in interface{}) interface{} {
|
2021-12-09 19:15:21 +03:00
|
|
|
avcIn, ok := in.(format.AvcAuIn)
|
2020-06-08 03:29:51 +03:00
|
|
|
if !ok {
|
2021-11-17 18:26:13 +03:00
|
|
|
d.Fatalf("avcIn required")
|
2020-06-08 03:29:51 +03:00
|
|
|
}
|
|
|
|
|
2021-09-16 17:26:31 +03:00
|
|
|
for d.NotEnd() {
|
2021-11-05 17:04:26 +03:00
|
|
|
d.FieldStruct("nalu", func(d *decode.D) {
|
2021-09-16 17:26:31 +03:00
|
|
|
l := d.FieldU("length", int(avcIn.LengthSize)*8)
|
|
|
|
d.FieldFormatLen("nalu", int64(l)*8, avcNALUFormat, nil)
|
|
|
|
})
|
|
|
|
}
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|