2020-06-08 03:29:51 +03:00
|
|
|
package mpeg
|
|
|
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
|
|
|
var hevcAUNALFormat []*decode.Format
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
registry.MustRegister(&decode.Format{
|
|
|
|
Name: format.HEVC_AU,
|
|
|
|
Description: "H.265/HEVC Access Unit",
|
|
|
|
DecodeFn: hevcAUDecode,
|
2021-11-03 19:19:33 +03:00
|
|
|
RootArray: true,
|
2021-09-16 17:26:31 +03:00
|
|
|
RootName: "access_unit",
|
2020-06-08 03:29:51 +03:00
|
|
|
Dependencies: []decode.Dependency{
|
|
|
|
{Names: []string{format.HEVC_NALU}, Formats: &hevcAUNALFormat},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func hevcAUDecode(d *decode.D, in interface{}) interface{} {
|
|
|
|
hevcIn, ok := in.(format.HevcIn)
|
|
|
|
if !ok {
|
|
|
|
d.Invalid("hevcIn required")
|
|
|
|
}
|
|
|
|
|
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(hevcIn.LengthSize)*8)
|
|
|
|
d.FieldFormatLen("nalu", int64(l)*8, hevcAUNALFormat, nil)
|
|
|
|
})
|
|
|
|
}
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|