mirror of
https://github.com/wader/fq.git
synced 2024-12-03 13:46:37 +03:00
40 lines
753 B
Go
40 lines
753 B
Go
package mpeg
|
|
|
|
import (
|
|
"github.com/wader/fq/format"
|
|
"github.com/wader/fq/pkg/decode"
|
|
"github.com/wader/fq/pkg/interp"
|
|
)
|
|
|
|
var adtsFrame decode.Group
|
|
|
|
func init() {
|
|
interp.RegisterFormat(decode.Format{
|
|
Name: format.ADTS,
|
|
Description: "Audio Data Transport Stream",
|
|
Groups: []string{format.PROBE},
|
|
DecodeFn: adtsDecoder,
|
|
RootArray: true,
|
|
RootName: "frames",
|
|
Dependencies: []decode.Dependency{
|
|
{Names: []string{format.ADTS_FRAME}, Group: &adtsFrame},
|
|
},
|
|
})
|
|
}
|
|
|
|
func adtsDecoder(d *decode.D, _ any) any {
|
|
validFrames := 0
|
|
for !d.End() {
|
|
if dv, _, _ := d.TryFieldFormat("frame", adtsFrame, nil); dv == nil {
|
|
break
|
|
}
|
|
validFrames++
|
|
}
|
|
|
|
if validFrames == 0 {
|
|
d.Fatalf("no valid frames")
|
|
}
|
|
|
|
return nil
|
|
}
|