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

42 lines
854 B
Go
Raw Normal View History

2020-06-08 03:29:51 +03:00
package mpeg
import (
"github.com/wader/fq/format"
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/interp"
2020-06-08 03:29:51 +03:00
)
var hevcAUNALFormat decode.Group
2020-06-08 03:29:51 +03:00
func init() {
interp.RegisterFormat(decode.Format{
2020-06-08 03:29:51 +03:00
Name: format.HEVC_AU,
Description: "H.265/HEVC Access Unit",
DecodeFn: hevcAUDecode,
DecodeInArg: format.HevcAuIn{
LengthSize: 4,
},
RootArray: true,
RootName: "access_unit",
2020-06-08 03:29:51 +03:00
Dependencies: []decode.Dependency{
{Names: []string{format.HEVC_NALU}, Group: &hevcAUNALFormat},
2020-06-08 03:29:51 +03:00
},
})
}
func hevcAUDecode(d *decode.D, in any) any {
hevcIn, ok := in.(format.HevcAuIn)
2020-06-08 03:29:51 +03:00
if !ok {
d.Errorf("HevcAuIn required")
2020-06-08 03:29:51 +03:00
}
2021-09-16 17:26:31 +03:00
for d.NotEnd() {
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
}