mirror of
https://github.com/wader/fq.git
synced 2024-12-23 05:13:30 +03:00
interp,format: Refactor registry usage and use function helpers
Move registry to interp and add support for functions and filesystems. This will be used later for allow formats to add own functions and fq code. Add gojqextra function helpers to have more comfortable API to add functions. Takes care of argument type casting and JQValue:s and some more things. Refactor interp package to use new function helper and registry. Probably fixes a bunch of JQValue bugs and other type errors. Refactor out some mpeg nal things to mpeg format. Refactor interp jq code into display.q and init.jq. Remove undocumented aes_ctr funciton, was a test. Hopefully will add more crypto things laster.
This commit is contained in:
parent
88dc847441
commit
1ddea1ada3
12
dev/tmpl.go
12
dev/tmpl.go
@ -43,7 +43,7 @@ func main() {
|
|||||||
min := toInt(args[0])
|
min := toInt(args[0])
|
||||||
max := toInt(args[1])
|
max := toInt(args[1])
|
||||||
var v []int
|
var v []int
|
||||||
for i := min; i <= max; i++ {
|
for i := min; i < max; i++ {
|
||||||
v = append(v, i)
|
v = append(v, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +60,16 @@ func main() {
|
|||||||
|
|
||||||
return strings.Replace(s, o, n, -1), nil
|
return strings.Replace(s, o, n, -1), nil
|
||||||
},
|
},
|
||||||
|
"slice": func(args ...any) []any {
|
||||||
|
return args
|
||||||
|
},
|
||||||
|
"map": func(args ...any) map[any]any {
|
||||||
|
m := map[any]any{}
|
||||||
|
for i := 0; i < len(args)/2; i++ {
|
||||||
|
m[args[i*2]] = args[i*2+1]
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
data := map[string]any{}
|
data := map[string]any{}
|
||||||
|
@ -4,14 +4,14 @@ package ape
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var imageFormat decode.Group
|
var imageFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.APEV2,
|
Name: format.APEV2,
|
||||||
Description: "APEv2 metadata tag",
|
Description: "APEv2 metadata tag",
|
||||||
DecodeFn: apev2Decode,
|
DecodeFn: apev2Decode,
|
||||||
|
@ -2,15 +2,15 @@ package ar
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var probeFormat decode.Group
|
var probeFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AR,
|
Name: format.AR,
|
||||||
Description: "Unix archive",
|
Description: "Unix archive",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -22,9 +22,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ import (
|
|||||||
var asn1FS embed.FS
|
var asn1FS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ASN1_BER,
|
Name: format.ASN1_BER,
|
||||||
Description: "ASN1 BER (basic encoding rules, also CER and DER)",
|
Description: "ASN1 BER (basic encoding rules, also CER and DER)",
|
||||||
DecodeFn: decodeASN1BER,
|
DecodeFn: decodeASN1BER,
|
||||||
|
@ -6,13 +6,13 @@ package av1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AV1_CCR,
|
Name: format.AV1_CCR,
|
||||||
Description: "AV1 Codec Configuration Record",
|
Description: "AV1 Codec Configuration Record",
|
||||||
DecodeFn: ccrDecode,
|
DecodeFn: ccrDecode,
|
||||||
|
@ -6,14 +6,14 @@ package av1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var obuFormat decode.Group
|
var obuFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AV1_FRAME,
|
Name: format.AV1_FRAME,
|
||||||
Description: "AV1 frame",
|
Description: "AV1 frame",
|
||||||
DecodeFn: frameDecode,
|
DecodeFn: frameDecode,
|
||||||
|
@ -2,13 +2,13 @@ package av1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AV1_OBU,
|
Name: format.AV1_OBU,
|
||||||
Description: "AV1 Open Bitstream Unit",
|
Description: "AV1 Open Bitstream Unit",
|
||||||
DecodeFn: obuDecode,
|
DecodeFn: obuDecode,
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/avro/decoders"
|
"github.com/wader/fq/format/avro/decoders"
|
||||||
"github.com/wader/fq/format/avro/schema"
|
"github.com/wader/fq/format/avro/schema"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ import (
|
|||||||
var avroOcfFS embed.FS
|
var avroOcfFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVRO_OCF,
|
Name: format.AVRO_OCF,
|
||||||
Description: "Avro object container file",
|
Description: "Avro object container file",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import (
|
|||||||
var bencodeFS embed.FS
|
var bencodeFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BENCODE,
|
Name: format.BENCODE,
|
||||||
Description: "BitTorrent bencoding",
|
Description: "BitTorrent bencoding",
|
||||||
DecodeFn: decodeBencode,
|
DecodeFn: decodeBencode,
|
||||||
|
@ -2,14 +2,14 @@ package bitcoin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bitcoinBlockFormat decode.Group
|
var bitcoinBlockFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BITCOIN_BLKDAT,
|
Name: format.BITCOIN_BLKDAT,
|
||||||
Description: "Bitcoin blk.dat",
|
Description: "Bitcoin blk.dat",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -6,15 +6,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bitcoinTranscationFormat decode.Group
|
var bitcoinTranscationFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BITCOIN_BLOCK,
|
Name: format.BITCOIN_BLOCK,
|
||||||
Description: "Bitcoin block",
|
Description: "Bitcoin block",
|
||||||
Dependencies: []decode.Dependency{
|
Dependencies: []decode.Dependency{
|
||||||
|
@ -2,8 +2,8 @@ package bitcoin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ func (ops opcodeEntries) MapScalar(s scalar.S) (scalar.S, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BITCOIN_SCRIPT,
|
Name: format.BITCOIN_SCRIPT,
|
||||||
Description: "Bitcoin script",
|
Description: "Bitcoin script",
|
||||||
DecodeFn: decodeBitcoinScript,
|
DecodeFn: decodeBitcoinScript,
|
||||||
|
@ -6,15 +6,15 @@ package bitcoin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bitcoinScriptFormat decode.Group
|
var bitcoinScriptFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BITCOIN_TRANSACTION,
|
Name: format.BITCOIN_TRANSACTION,
|
||||||
Description: "Bitcoin transaction",
|
Description: "Bitcoin transaction",
|
||||||
Dependencies: []decode.Dependency{
|
Dependencies: []decode.Dependency{
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import (
|
|||||||
var bsonFS embed.FS
|
var bsonFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BSON,
|
Name: format.BSON,
|
||||||
Description: "Binary JSON",
|
Description: "Binary JSON",
|
||||||
DecodeFn: decodeBSON,
|
DecodeFn: decodeBSON,
|
||||||
|
@ -13,16 +13,16 @@ import (
|
|||||||
"math/bits"
|
"math/bits"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var probeGroup decode.Group
|
var probeGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BZIP2,
|
Name: format.BZIP2,
|
||||||
Description: "bzip2 compression",
|
Description: "bzip2 compression",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -13,10 +13,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/internal/mathextra"
|
"github.com/wader/fq/internal/mathextra"
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ import (
|
|||||||
var cborFS embed.FS
|
var cborFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.CBOR,
|
Name: format.CBOR,
|
||||||
Description: "Concise Binary Object Representation",
|
Description: "Concise Binary Object Representation",
|
||||||
DecodeFn: decodeCBOR,
|
DecodeFn: decodeCBOR,
|
||||||
|
@ -8,13 +8,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.DNS,
|
Name: format.DNS,
|
||||||
Description: "DNS packet",
|
Description: "DNS packet",
|
||||||
Groups: []string{
|
Groups: []string{
|
||||||
|
@ -2,12 +2,12 @@ package dns
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.DNS_TCP,
|
Name: format.DNS_TCP,
|
||||||
Description: "DNS packet (TCP)",
|
Description: "DNS packet (TCP)",
|
||||||
DecodeFn: dnsTCPDecode,
|
DecodeFn: dnsTCPDecode,
|
||||||
|
@ -11,13 +11,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ELF,
|
Name: format.ELF,
|
||||||
Description: "Executable and Linkable Format",
|
Description: "Executable and Linkable Format",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -4,12 +4,12 @@ package fairplay
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.FAIRPLAY_SPC,
|
Name: format.FAIRPLAY_SPC,
|
||||||
Description: "FairPlay Server Playback Context",
|
Description: "FairPlay Server Playback Context",
|
||||||
DecodeFn: fairPlaySPCDecode,
|
DecodeFn: fairPlaySPCDecode,
|
||||||
|
@ -12,10 +12,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/internal/mathextra"
|
"github.com/wader/fq/internal/mathextra"
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ var flacMetadatablocksFormat decode.Group
|
|||||||
var flacFrameFormat decode.Group
|
var flacFrameFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.FLAC,
|
Name: format.FLAC,
|
||||||
Description: "Free Lossless Audio Codec file",
|
Description: "Free Lossless Audio Codec file",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -5,15 +5,15 @@ import (
|
|||||||
"math/bits"
|
"math/bits"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/internal/mathextra"
|
"github.com/wader/fq/internal/mathextra"
|
||||||
"github.com/wader/fq/pkg/checksum"
|
"github.com/wader/fq/pkg/checksum"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.FLAC_FRAME,
|
Name: format.FLAC_FRAME,
|
||||||
Description: "FLAC frame",
|
Description: "FLAC frame",
|
||||||
DecodeFn: frameDecode,
|
DecodeFn: frameDecode,
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ var flacPicture decode.Group
|
|||||||
var vorbisCommentFormat decode.Group
|
var vorbisCommentFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.FLAC_METADATABLOCK,
|
Name: format.FLAC_METADATABLOCK,
|
||||||
Description: "FLAC metadatablock",
|
Description: "FLAC metadatablock",
|
||||||
DecodeFn: metadatablockDecode,
|
DecodeFn: metadatablockDecode,
|
||||||
|
@ -4,14 +4,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var flacMetadatablockFormat decode.Group
|
var flacMetadatablockFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.FLAC_METADATABLOCKS,
|
Name: format.FLAC_METADATABLOCKS,
|
||||||
Description: "FLAC metadatablocks",
|
Description: "FLAC metadatablocks",
|
||||||
DecodeFn: metadatablocksDecode,
|
DecodeFn: metadatablocksDecode,
|
||||||
|
@ -2,8 +2,8 @@ package flac
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ var pictureTypeNames = scalar.UToSymStr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.FLAC_PICTURE,
|
Name: format.FLAC_PICTURE,
|
||||||
Description: "FLAC metadatablock picture",
|
Description: "FLAC metadatablock picture",
|
||||||
DecodeFn: pictureDecode,
|
DecodeFn: pictureDecode,
|
||||||
|
@ -2,13 +2,13 @@ package flac
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.FLAC_STREAMINFO,
|
Name: format.FLAC_STREAMINFO,
|
||||||
Description: "FLAC streaminfo",
|
Description: "FLAC streaminfo",
|
||||||
DecodeFn: streaminfoDecode,
|
DecodeFn: streaminfoDecode,
|
||||||
|
@ -7,8 +7,8 @@ package flv
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/registry"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/wader/fq/format/all"
|
_ "github.com/wader/fq/format/all"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/fqtest"
|
"github.com/wader/fq/pkg/fqtest"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFQTests(t *testing.T) {
|
func TestFQTests(t *testing.T) {
|
||||||
fqtest.TestPath(t, registry.Default)
|
fqtest.TestPath(t, interp.DefaultRegister)
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/wader/fq/format/all"
|
_ "github.com/wader/fq/format/all"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
"github.com/wader/fq/pkg/interp"
|
"github.com/wader/fq/pkg/interp"
|
||||||
|
"github.com/wader/fq/pkg/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
type fuzzFS struct{}
|
type fuzzFS struct{}
|
||||||
@ -99,11 +99,11 @@ func FuzzFormats(f *testing.F) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
gi := 0
|
gi := 0
|
||||||
g := registry.Default.MustAll()
|
g := interp.DefaultRegister.MustAll()
|
||||||
|
|
||||||
f.Fuzz(func(t *testing.T, b []byte) {
|
f.Fuzz(func(t *testing.T, b []byte) {
|
||||||
fz := &fuzzTest{b: b, f: g[gi]}
|
fz := &fuzzTest{b: b, f: g[gi]}
|
||||||
q, err := interp.New(fz, registry.Default)
|
q, err := interp.New(fz, interp.DefaultRegister)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.GIF,
|
Name: format.GIF,
|
||||||
Description: "Graphics Interchange Format",
|
Description: "Graphics Interchange Format",
|
||||||
Groups: []string{format.PROBE, format.IMAGE},
|
Groups: []string{format.PROBE, format.IMAGE},
|
||||||
|
@ -10,15 +10,15 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var probeFormat decode.Group
|
var probeFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.GZIP,
|
Name: format.GZIP,
|
||||||
Description: "gzip compression",
|
Description: "gzip compression",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -5,13 +5,13 @@ package icc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/internal/mathextra"
|
"github.com/wader/fq/internal/mathextra"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ICC_PROFILE,
|
Name: format.ICC_PROFILE,
|
||||||
Description: "International Color Consortium profile",
|
Description: "International Color Consortium profile",
|
||||||
DecodeFn: iccProfileDecode,
|
DecodeFn: iccProfileDecode,
|
||||||
|
@ -2,15 +2,15 @@ package id3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: comment 28 long, zero byte, track number
|
// TODO: comment 28 long, zero byte, track number
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ID3V1,
|
Name: format.ID3V1,
|
||||||
Description: "ID3v1 metadata",
|
Description: "ID3v1 metadata",
|
||||||
DecodeFn: id3v1Decode,
|
DecodeFn: id3v1Decode,
|
||||||
|
@ -2,13 +2,13 @@ package id3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ID3V11,
|
Name: format.ID3V11,
|
||||||
Description: "ID3v1.1 metadata",
|
Description: "ID3v1.1 metadata",
|
||||||
DecodeFn: id3v11Decode,
|
DecodeFn: id3v11Decode,
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
"golang.org/x/text/encoding"
|
"golang.org/x/text/encoding"
|
||||||
"golang.org/x/text/encoding/charmap"
|
"golang.org/x/text/encoding/charmap"
|
||||||
@ -22,7 +22,7 @@ import (
|
|||||||
var imageFormat decode.Group
|
var imageFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ID3V2,
|
Name: format.ID3V2,
|
||||||
Description: "ID3v2 metadata",
|
Description: "ID3v2 metadata",
|
||||||
DecodeFn: id3v2Decode,
|
DecodeFn: id3v2Decode,
|
||||||
|
@ -4,15 +4,15 @@ package inet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bsdLoopbackFrameInetPacketGroup decode.Group
|
var bsdLoopbackFrameInetPacketGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.BSD_LOOPBACK_FRAME,
|
Name: format.BSD_LOOPBACK_FRAME,
|
||||||
Description: "BSD loopback frame",
|
Description: "BSD loopback frame",
|
||||||
Groups: []string{format.LINK_FRAME},
|
Groups: []string{format.LINK_FRAME},
|
||||||
|
@ -7,15 +7,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ether8023FrameInetPacketGroup decode.Group
|
var ether8023FrameInetPacketGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ETHER8023_FRAME,
|
Name: format.ETHER8023_FRAME,
|
||||||
Description: "Ethernet 802.3 frame",
|
Description: "Ethernet 802.3 frame",
|
||||||
Groups: []string{format.LINK_FRAME},
|
Groups: []string{format.LINK_FRAME},
|
||||||
|
@ -2,13 +2,13 @@ package inet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ICMP,
|
Name: format.ICMP,
|
||||||
Description: "Internet Control Message Protocol",
|
Description: "Internet Control Message Protocol",
|
||||||
Groups: []string{format.IP_PACKET},
|
Groups: []string{format.IP_PACKET},
|
||||||
|
@ -2,13 +2,13 @@ package inet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ICMPV6,
|
Name: format.ICMPV6,
|
||||||
Description: "Internet Control Message Protocol v6",
|
Description: "Internet Control Message Protocol v6",
|
||||||
Groups: []string{format.IP_PACKET},
|
Groups: []string{format.IP_PACKET},
|
||||||
|
@ -5,17 +5,17 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/checksum"
|
"github.com/wader/fq/pkg/checksum"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ipv4IpPacketGroup decode.Group
|
var ipv4IpPacketGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.IPV4_PACKET,
|
Name: format.IPV4_PACKET,
|
||||||
Description: "Internet protocol v4 packet",
|
Description: "Internet protocol v4 packet",
|
||||||
Groups: []string{format.INET_PACKET},
|
Groups: []string{format.INET_PACKET},
|
||||||
|
@ -5,16 +5,16 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/internal/bitioextra"
|
"github.com/wader/fq/internal/bitioextra"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ipv6IpPacketGroup decode.Group
|
var ipv6IpPacketGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.IPV6_PACKET,
|
Name: format.IPV6_PACKET,
|
||||||
Description: "Internet protocol v6 packet",
|
Description: "Internet protocol v6 packet",
|
||||||
Groups: []string{format.INET_PACKET},
|
Groups: []string{format.INET_PACKET},
|
||||||
|
@ -5,15 +5,15 @@ package inet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var sllPacket2InetPacketGroup decode.Group
|
var sllPacket2InetPacketGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.SLL2_PACKET,
|
Name: format.SLL2_PACKET,
|
||||||
Description: "Linux cooked capture encapsulation v2",
|
Description: "Linux cooked capture encapsulation v2",
|
||||||
Groups: []string{format.LINK_FRAME},
|
Groups: []string{format.LINK_FRAME},
|
||||||
|
@ -5,15 +5,15 @@ package inet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var sllPacketInetPacketGroup decode.Group
|
var sllPacketInetPacketGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.SLL_PACKET,
|
Name: format.SLL_PACKET,
|
||||||
Description: "Linux cooked capture encapsulation",
|
Description: "Linux cooked capture encapsulation",
|
||||||
Groups: []string{format.LINK_FRAME},
|
Groups: []string{format.LINK_FRAME},
|
||||||
|
@ -4,13 +4,13 @@ package inet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.TCP_SEGMENT,
|
Name: format.TCP_SEGMENT,
|
||||||
Description: "Transmission control protocol segment",
|
Description: "Transmission control protocol segment",
|
||||||
Groups: []string{format.IP_PACKET},
|
Groups: []string{format.IP_PACKET},
|
||||||
|
@ -2,15 +2,15 @@ package inet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var udpPayloadGroup decode.Group
|
var udpPayloadGroup decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.UDP_DATAGRAM,
|
Name: format.UDP_DATAGRAM,
|
||||||
Description: "User datagram protocol",
|
Description: "User datagram protocol",
|
||||||
Groups: []string{format.IP_PACKET},
|
Groups: []string{format.IP_PACKET},
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ var exifFormat decode.Group
|
|||||||
var iccProfileFormat decode.Group
|
var iccProfileFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.JPEG,
|
Name: format.JPEG,
|
||||||
Description: "Joint Photographic Experts Group file",
|
Description: "Joint Photographic Experts Group file",
|
||||||
Groups: []string{format.PROBE, format.IMAGE},
|
Groups: []string{format.PROBE, format.IMAGE},
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
stdjson "encoding/json"
|
stdjson "encoding/json"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import (
|
|||||||
// TODO: use jd.InputOffset() * 8?
|
// TODO: use jd.InputOffset() * 8?
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.JSON,
|
Name: format.JSON,
|
||||||
Description: "JSON",
|
Description: "JSON",
|
||||||
ProbeOrder: 100, // last
|
ProbeOrder: 100, // last
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ import (
|
|||||||
var machoFS embed.FS
|
var machoFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MACHO,
|
Name: format.MACHO,
|
||||||
Description: "Mach-O macOS executable",
|
Description: "Mach-O macOS executable",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/matroska/ebml"
|
"github.com/wader/fq/format/matroska/ebml"
|
||||||
"github.com/wader/fq/format/matroska/ebml_matroska"
|
"github.com/wader/fq/format/matroska/ebml_matroska"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/ranges"
|
"github.com/wader/fq/pkg/ranges"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
@ -52,7 +52,7 @@ var vp9FrameFormat decode.Group
|
|||||||
var codecToFormat map[string]*decode.Group
|
var codecToFormat map[string]*decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MATROSKA,
|
Name: format.MATROSKA,
|
||||||
Description: "Matroska file",
|
Description: "Matroska file",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
@ -153,7 +153,9 @@ func decodeMaster(d *decode.D, bitsLimit int64, tag ebml.Tag, dc *decodeContext)
|
|||||||
|
|
||||||
for d.Pos() < tagEndBit && d.NotEnd() {
|
for d.Pos() < tagEndBit && d.NotEnd() {
|
||||||
d.FieldStruct("element", func(d *decode.D) {
|
d.FieldStruct("element", func(d *decode.D) {
|
||||||
var a ebml.Attribute
|
a := ebml.Attribute{
|
||||||
|
Type: ebml.Unknown,
|
||||||
|
}
|
||||||
|
|
||||||
tagID := d.FieldUFn("id", decodeRawVint, scalar.Fn(func(s scalar.S) (scalar.S, error) {
|
tagID := d.FieldUFn("id", decodeRawVint, scalar.Fn(func(s scalar.S) (scalar.S, error) {
|
||||||
n := s.ActualU()
|
n := s.ActualU()
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var headerFormat decode.Group
|
var headerFormat decode.Group
|
||||||
@ -15,7 +15,7 @@ var footerFormat decode.Group
|
|||||||
var mp3Frame decode.Group
|
var mp3Frame decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MP3,
|
Name: format.MP3,
|
||||||
ProbeOrder: 20, // after most others (silent samples and jpeg header can look like mp3 sync)
|
ProbeOrder: 20, // after most others (silent samples and jpeg header can look like mp3 sync)
|
||||||
Description: "MP3 file",
|
Description: "MP3 file",
|
||||||
|
@ -4,12 +4,12 @@ package mp3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.XING,
|
Name: format.XING,
|
||||||
Description: "Xing header",
|
Description: "Xing header",
|
||||||
DecodeFn: xingDecode,
|
DecodeFn: xingDecode,
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed mp4.jq
|
//go:embed mp4.jq
|
||||||
@ -52,7 +52,7 @@ var vpxCCRFormat decode.Group
|
|||||||
var iccProfileFormat decode.Group
|
var iccProfileFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MP4,
|
Name: format.MP4,
|
||||||
Description: "ISOBMFF MPEG-4 part 12 and similar",
|
Description: "ISOBMFF MPEG-4 part 12 and similar",
|
||||||
Groups: []string{
|
Groups: []string{
|
||||||
|
@ -2,13 +2,13 @@ package mp4
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.PSSH_PLAYREADY,
|
Name: format.PSSH_PLAYREADY,
|
||||||
Description: "PlayReady PSSH",
|
Description: "PlayReady PSSH",
|
||||||
DecodeFn: playreadyPsshDecode,
|
DecodeFn: playreadyPsshDecode,
|
||||||
|
@ -8,13 +8,13 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AAC_FRAME,
|
Name: format.AAC_FRAME,
|
||||||
Description: "Advanced Audio Coding frame",
|
Description: "Advanced Audio Coding frame",
|
||||||
DecodeFn: aacDecode,
|
DecodeFn: aacDecode,
|
||||||
|
@ -2,14 +2,14 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var adtsFrame decode.Group
|
var adtsFrame decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ADTS,
|
Name: format.ADTS,
|
||||||
Description: "Audio Data Transport Stream",
|
Description: "Audio Data Transport Stream",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -6,15 +6,15 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var aacFrameFormat decode.Group
|
var aacFrameFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.ADTS_FRAME,
|
Name: format.ADTS_FRAME,
|
||||||
Description: "Audio Data Transport Stream frame",
|
Description: "Audio Data Transport Stream frame",
|
||||||
DecodeFn: adtsFrameDecoder,
|
DecodeFn: adtsFrameDecoder,
|
||||||
|
@ -2,14 +2,14 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var annexBAVCNALUFormat decode.Group
|
var annexBAVCNALUFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVC_ANNEXB,
|
Name: format.AVC_ANNEXB,
|
||||||
Description: "H.264/AVC Annex B",
|
Description: "H.264/AVC Annex B",
|
||||||
DecodeFn: func(d *decode.D, in any) any {
|
DecodeFn: func(d *decode.D, in any) any {
|
||||||
|
@ -4,14 +4,14 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var avcNALUFormat decode.Group
|
var avcNALUFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVC_AU,
|
Name: format.AVC_AU,
|
||||||
Description: "H.264/AVC Access Unit",
|
Description: "H.264/AVC Access Unit",
|
||||||
DecodeFn: avcAUDecode,
|
DecodeFn: avcAUDecode,
|
||||||
|
@ -7,15 +7,15 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var avcDCRNALFormat decode.Group
|
var avcDCRNALFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVC_DCR,
|
Name: format.AVC_DCR,
|
||||||
Description: "H.264/AVC Decoder Configuration Record",
|
Description: "H.264/AVC Decoder Configuration Record",
|
||||||
DecodeFn: avcDcrDecode,
|
DecodeFn: avcDcrDecode,
|
||||||
|
@ -4,10 +4,10 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/internal/mathextra"
|
"github.com/wader/fq/internal/mathextra"
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ var avcPPSFormat decode.Group
|
|||||||
var avcSEIFormat decode.Group
|
var avcSEIFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVC_NALU,
|
Name: format.AVC_NALU,
|
||||||
Description: "H.264/AVC Network Access Layer Unit",
|
Description: "H.264/AVC Network Access Layer Unit",
|
||||||
DecodeFn: avcNALUDecode,
|
DecodeFn: avcNALUDecode,
|
||||||
@ -102,7 +102,7 @@ func avcNALUDecode(d *decode.D, in any) any {
|
|||||||
d.FieldBool("forbidden_zero_bit")
|
d.FieldBool("forbidden_zero_bit")
|
||||||
d.FieldU2("nal_ref_idc")
|
d.FieldU2("nal_ref_idc")
|
||||||
nalType := d.FieldU5("nal_unit_type", avcNALNames)
|
nalType := d.FieldU5("nal_unit_type", avcNALNames)
|
||||||
unescapedBR := d.NewBitBufFromReader(decode.NALUnescapeReader{Reader: bitio.NewIOReader(d.BitBufRange(d.Pos(), d.BitsLeft()))})
|
unescapedBR := d.NewBitBufFromReader(nalUnescapeReader{Reader: bitio.NewIOReader(d.BitBufRange(d.Pos(), d.BitsLeft()))})
|
||||||
|
|
||||||
switch nalType {
|
switch nalType {
|
||||||
case avcNALCodedSliceNonIDR,
|
case avcNALCodedSliceNonIDR,
|
||||||
|
@ -2,13 +2,13 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVC_PPS,
|
Name: format.AVC_PPS,
|
||||||
Description: "H.264/AVC Picture Parameter Set",
|
Description: "H.264/AVC Picture Parameter Set",
|
||||||
DecodeFn: avcPPSDecode,
|
DecodeFn: avcPPSDecode,
|
||||||
|
@ -2,13 +2,13 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVC_SEI,
|
Name: format.AVC_SEI,
|
||||||
Description: "H.264/AVC Supplemental Enhancement Information",
|
Description: "H.264/AVC Supplemental Enhancement Information",
|
||||||
DecodeFn: avcSEIDecode,
|
DecodeFn: avcSEIDecode,
|
||||||
|
@ -2,13 +2,13 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AVC_SPS,
|
Name: format.AVC_SPS,
|
||||||
Description: "H.264/AVC Sequence Parameter Set",
|
Description: "H.264/AVC Sequence Parameter Set",
|
||||||
DecodeFn: avcSPSDecode,
|
DecodeFn: avcSPSDecode,
|
||||||
|
@ -2,14 +2,14 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var annexBHEVCNALUFormat decode.Group
|
var annexBHEVCNALUFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.HEVC_ANNEXB,
|
Name: format.HEVC_ANNEXB,
|
||||||
Description: "H.265/HEVC Annex B",
|
Description: "H.265/HEVC Annex B",
|
||||||
DecodeFn: func(d *decode.D, in any) any {
|
DecodeFn: func(d *decode.D, in any) any {
|
||||||
|
@ -2,14 +2,14 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var hevcAUNALFormat decode.Group
|
var hevcAUNALFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.HEVC_AU,
|
Name: format.HEVC_AU,
|
||||||
Description: "H.265/HEVC Access Unit",
|
Description: "H.265/HEVC Access Unit",
|
||||||
DecodeFn: hevcAUDecode,
|
DecodeFn: hevcAUDecode,
|
||||||
|
@ -2,15 +2,15 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var hevcDCRNALFormat decode.Group
|
var hevcDCRNALFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.HEVC_DCR,
|
Name: format.HEVC_DCR,
|
||||||
Description: "H.265/HEVC Decoder Configuration Record",
|
Description: "H.265/HEVC Decoder Configuration Record",
|
||||||
DecodeFn: hevcDcrDecode,
|
DecodeFn: hevcDcrDecode,
|
||||||
|
@ -2,9 +2,9 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ var hevcPPSFormat decode.Group
|
|||||||
var hevcSPSFormat decode.Group
|
var hevcSPSFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.HEVC_NALU,
|
Name: format.HEVC_NALU,
|
||||||
Description: "H.265/HEVC Network Access Layer Unit",
|
Description: "H.265/HEVC Network Access Layer Unit",
|
||||||
DecodeFn: hevcNALUDecode,
|
DecodeFn: hevcNALUDecode,
|
||||||
@ -87,7 +87,7 @@ func hevcNALUDecode(d *decode.D, in any) any {
|
|||||||
nalType := d.FieldU6("nal_unit_type", hevcNALNames)
|
nalType := d.FieldU6("nal_unit_type", hevcNALNames)
|
||||||
d.FieldU6("nuh_layer_id")
|
d.FieldU6("nuh_layer_id")
|
||||||
d.FieldU3("nuh_temporal_id_plus1")
|
d.FieldU3("nuh_temporal_id_plus1")
|
||||||
unescapedBR := d.NewBitBufFromReader(decode.NALUnescapeReader{Reader: bitio.NewIOReader(d.BitBufRange(d.Pos(), d.BitsLeft()))})
|
unescapedBR := d.NewBitBufFromReader(nalUnescapeReader{Reader: bitio.NewIOReader(d.BitBufRange(d.Pos(), d.BitsLeft()))})
|
||||||
|
|
||||||
switch nalType {
|
switch nalType {
|
||||||
case hevcNALNUTVPS:
|
case hevcNALNUTVPS:
|
||||||
|
@ -4,12 +4,12 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.HEVC_PPS,
|
Name: format.HEVC_PPS,
|
||||||
Description: "H.265/HEVC Picture Parameter Set",
|
Description: "H.265/HEVC Picture Parameter Set",
|
||||||
DecodeFn: hevcPPSDecode,
|
DecodeFn: hevcPPSDecode,
|
||||||
|
@ -4,12 +4,12 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.HEVC_SPS,
|
Name: format.HEVC_SPS,
|
||||||
Description: "H.265/HEVC Sequence Parameter Set",
|
Description: "H.265/HEVC Sequence Parameter Set",
|
||||||
DecodeFn: hevcSPSDecode,
|
DecodeFn: hevcSPSDecode,
|
||||||
|
@ -4,12 +4,12 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.HEVC_VPS,
|
Name: format.HEVC_VPS,
|
||||||
Description: "H.265/HEVC Video Parameter Set",
|
Description: "H.265/HEVC Video Parameter Set",
|
||||||
DecodeFn: hevcVPSDecode,
|
DecodeFn: hevcVPSDecode,
|
||||||
|
@ -14,16 +14,16 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/checksum"
|
"github.com/wader/fq/pkg/checksum"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var xingHeader decode.Group
|
var xingHeader decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MP3_FRAME,
|
Name: format.MP3_FRAME,
|
||||||
Description: "MPEG audio layer 3 frame",
|
Description: "MPEG audio layer 3 frame",
|
||||||
DecodeFn: frameDecode,
|
DecodeFn: frameDecode,
|
||||||
|
@ -4,13 +4,13 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MPEG_ASC,
|
Name: format.MPEG_ASC,
|
||||||
Description: "MPEG-4 Audio Specific Config",
|
Description: "MPEG-4 Audio Specific Config",
|
||||||
DecodeFn: ascDecoder,
|
DecodeFn: ascDecoder,
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ var mpegASCFormat decode.Group
|
|||||||
var vorbisPacketFormat decode.Group
|
var vorbisPacketFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MPEG_ES,
|
Name: format.MPEG_ES,
|
||||||
Description: "MPEG Elementary Stream",
|
Description: "MPEG Elementary Stream",
|
||||||
DecodeFn: esDecode,
|
DecodeFn: esDecode,
|
||||||
|
@ -6,16 +6,16 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pesPacketFormat decode.Group
|
var pesPacketFormat decode.Group
|
||||||
var spuFormat decode.Group
|
var spuFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MPEG_PES,
|
Name: format.MPEG_PES,
|
||||||
Description: "MPEG Packetized elementary stream",
|
Description: "MPEG Packetized elementary stream",
|
||||||
DecodeFn: pesDecode,
|
DecodeFn: pesDecode,
|
||||||
|
@ -5,13 +5,13 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MPEG_PES_PACKET,
|
Name: format.MPEG_PES_PACKET,
|
||||||
Description: "MPEG Packetized elementary stream packet",
|
Description: "MPEG Packetized elementary stream packet",
|
||||||
DecodeFn: pesPacketDecode,
|
DecodeFn: pesPacketDecode,
|
||||||
|
@ -9,13 +9,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MPEG_SPU,
|
Name: format.MPEG_SPU,
|
||||||
Description: "Sub Picture Unit (DVD subtitle)",
|
Description: "Sub Picture Unit (DVD subtitle)",
|
||||||
DecodeFn: spuDecode,
|
DecodeFn: spuDecode,
|
||||||
|
@ -2,13 +2,13 @@ package mpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MPEG_TS,
|
Name: format.MPEG_TS,
|
||||||
ProbeOrder: 10, // make sure to be after gif, both start with 0x47
|
ProbeOrder: 10, // make sure to be after gif, both start with 0x47
|
||||||
Description: "MPEG Transport Stream",
|
Description: "MPEG Transport Stream",
|
||||||
|
@ -1,9 +1,48 @@
|
|||||||
package mpeg
|
package mpeg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
interp.RegisterFunc0("nal_unescape", makeBinaryTransformFn(func(r io.Reader) (io.Reader, error) {
|
||||||
|
return &nalUnescapeReader{Reader: r}, nil
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// transform to binary using fn
|
||||||
|
func makeBinaryTransformFn(fn func(r io.Reader) (io.Reader, error)) func(i *interp.Interp, c any) any {
|
||||||
|
return func(i *interp.Interp, c any) any {
|
||||||
|
inBR, err := interp.ToBitReader(c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err := fn(bitio.NewIOReader(inBR))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
outBuf := &bytes.Buffer{}
|
||||||
|
if _, err := io.Copy(outBuf, r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
outBR := bitio.NewBitReader(outBuf.Bytes(), -1)
|
||||||
|
|
||||||
|
bb, err := interp.NewBinaryFromBitReader(outBR, 8, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return bb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func decodeEscapeValueFn(add int, b1 int, b2 int, b3 int) func(d *decode.D) uint64 {
|
func decodeEscapeValueFn(add int, b1 int, b2 int, b3 int) func(d *decode.D) uint64 {
|
||||||
return func(d *decode.D) uint64 {
|
return func(d *decode.D) uint64 {
|
||||||
n1 := d.U(b1)
|
n1 := d.U(b1)
|
||||||
@ -43,3 +82,31 @@ func decodeEscapeValueAddFn(b1 int, b2 int, b3 int) func(d *decode.D) uint64 {
|
|||||||
func decodeEscapeValueCarryFn(b1 int, b2 int, b3 int) func(d *decode.D) uint64 {
|
func decodeEscapeValueCarryFn(b1 int, b2 int, b3 int) func(d *decode.D) uint64 {
|
||||||
return decodeEscapeValueFn(1, b1, b2, b3)
|
return decodeEscapeValueFn(1, b1, b2, b3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move?
|
||||||
|
// TODO: make generic replace reader? share with id3v2 unsync?
|
||||||
|
type nalUnescapeReader struct {
|
||||||
|
io.Reader
|
||||||
|
lastTwoZeros [2]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r nalUnescapeReader) Read(p []byte) (n int, err error) {
|
||||||
|
n, err = r.Reader.Read(p)
|
||||||
|
|
||||||
|
ni := 0
|
||||||
|
for i, b := range p[0:n] {
|
||||||
|
if r.lastTwoZeros[0] && r.lastTwoZeros[1] && b == 0x03 {
|
||||||
|
n--
|
||||||
|
r.lastTwoZeros[0] = false
|
||||||
|
r.lastTwoZeros[1] = false
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
r.lastTwoZeros[1] = r.lastTwoZeros[0]
|
||||||
|
r.lastTwoZeros[0] = b == 0
|
||||||
|
}
|
||||||
|
p[ni] = p[i]
|
||||||
|
ni++
|
||||||
|
}
|
||||||
|
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ import (
|
|||||||
var msgPackFS embed.FS
|
var msgPackFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.MSGPACK,
|
Name: format.MSGPACK,
|
||||||
Description: "MessagePack",
|
Description: "MessagePack",
|
||||||
DecodeFn: decodeMsgPack,
|
DecodeFn: decodeMsgPack,
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var oggPageFormat decode.Group
|
var oggPageFormat decode.Group
|
||||||
@ -19,7 +19,7 @@ var flacMetadatablockFormat decode.Group
|
|||||||
var flacFrameFormat decode.Group
|
var flacFrameFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.OGG,
|
Name: format.OGG,
|
||||||
Description: "OGG file",
|
Description: "OGG file",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -4,15 +4,15 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/checksum"
|
"github.com/wader/fq/pkg/checksum"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.OGG_PAGE,
|
Name: format.OGG_PAGE,
|
||||||
Description: "OGG page",
|
Description: "OGG page",
|
||||||
DecodeFn: pageDecode,
|
DecodeFn: pageDecode,
|
||||||
|
@ -6,14 +6,14 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var vorbisComment decode.Group
|
var vorbisComment decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.OPUS_PACKET,
|
Name: format.OPUS_PACKET,
|
||||||
Description: "Opus packet",
|
Description: "Opus packet",
|
||||||
DecodeFn: opusDecode,
|
DecodeFn: opusDecode,
|
||||||
|
@ -6,8 +6,8 @@ package pcap
|
|||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/inet/flowsdecoder"
|
"github.com/wader/fq/format/inet/flowsdecoder"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ var endianMap = scalar.UToSymStr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.PCAP,
|
Name: format.PCAP,
|
||||||
Description: "PCAP packet capture",
|
Description: "PCAP packet capture",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/inet/flowsdecoder"
|
"github.com/wader/fq/format/inet/flowsdecoder"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ var pcapngTCPStreamFormat decode.Group
|
|||||||
var pcapngIPvPacket4Format decode.Group
|
var pcapngIPvPacket4Format decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.PCAPNG,
|
Name: format.PCAPNG,
|
||||||
Description: "PCAPNG packet capture",
|
Description: "PCAPNG packet capture",
|
||||||
RootArray: true,
|
RootArray: true,
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ var iccProfileFormat decode.Group
|
|||||||
var exifFormat decode.Group
|
var exifFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.PNG,
|
Name: format.PNG,
|
||||||
Description: "Portable Network Graphics file",
|
Description: "Portable Network Graphics file",
|
||||||
Groups: []string{format.PROBE, format.IMAGE},
|
Groups: []string{format.PROBE, format.IMAGE},
|
||||||
|
@ -6,9 +6,9 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/internal/mathextra"
|
"github.com/wader/fq/internal/mathextra"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import (
|
|||||||
var protobufFS embed.FS
|
var protobufFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.PROTOBUF,
|
Name: format.PROTOBUF,
|
||||||
Description: "Protobuf",
|
Description: "Protobuf",
|
||||||
DecodeFn: protobufDecode,
|
DecodeFn: protobufDecode,
|
||||||
|
@ -4,15 +4,15 @@ package protobuf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var widevineProtoBufFormat decode.Group
|
var widevineProtoBufFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.PROTOBUF_WIDEVINE,
|
Name: format.PROTOBUF_WIDEVINE,
|
||||||
Description: "Widevine protobuf",
|
Description: "Widevine protobuf",
|
||||||
DecodeFn: widevineDecode,
|
DecodeFn: widevineDecode,
|
||||||
|
@ -2,12 +2,12 @@ package raw
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.RAW,
|
Name: format.RAW,
|
||||||
Description: "Raw bits",
|
Description: "Raw bits",
|
||||||
DecodeFn: func(d *decode.D, in any) any { return nil },
|
DecodeFn: func(d *decode.D, in any) any { return nil },
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package registry
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
|
||||||
"github.com/wader/fq/pkg/registry"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Default global registry that all builtin formats register with
|
|
||||||
var Default = registry.New()
|
|
||||||
|
|
||||||
func MustRegister(format decode.Format) {
|
|
||||||
Default.MustRegister(format)
|
|
||||||
}
|
|
@ -4,13 +4,13 @@ package rtmp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.AMF0,
|
Name: format.AMF0,
|
||||||
Description: "Action Message Format 0",
|
Description: "Action Message Format 0",
|
||||||
DecodeFn: amf0Decode,
|
DecodeFn: amf0Decode,
|
||||||
|
@ -12,9 +12,9 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/bitio"
|
"github.com/wader/fq/pkg/bitio"
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ var rtmpMpegASCFormat decode.Group
|
|||||||
var rtmpFS embed.FS
|
var rtmpFS embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.RTMP,
|
Name: format.RTMP,
|
||||||
Description: "Real-Time Messaging Protocol",
|
Description: "Real-Time Messaging Protocol",
|
||||||
Groups: []string{
|
Groups: []string{
|
||||||
|
@ -7,15 +7,15 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var probeFormat decode.Group
|
var probeFormat decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.TAR,
|
Name: format.TAR,
|
||||||
Description: "Tar archive",
|
Description: "Tar archive",
|
||||||
Groups: []string{format.PROBE},
|
Groups: []string{format.PROBE},
|
||||||
|
@ -5,14 +5,14 @@ package tiff
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// currently just a alias for tiff
|
// currently just a alias for tiff
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.EXIF,
|
Name: format.EXIF,
|
||||||
Description: "Exchangeable Image File Format",
|
Description: "Exchangeable Image File Format",
|
||||||
Groups: []string{},
|
Groups: []string{},
|
||||||
|
@ -4,15 +4,15 @@ package tiff
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tiffIccProfile decode.Group
|
var tiffIccProfile decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.TIFF,
|
Name: format.TIFF,
|
||||||
Description: "Tag Image File Format",
|
Description: "Tag Image File Format",
|
||||||
Groups: []string{format.PROBE, format.IMAGE},
|
Groups: []string{format.PROBE, format.IMAGE},
|
||||||
|
@ -6,14 +6,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var flacPicture decode.Group
|
var flacPicture decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.VORBIS_COMMENT,
|
Name: format.VORBIS_COMMENT,
|
||||||
Description: "Vorbis comment",
|
Description: "Vorbis comment",
|
||||||
DecodeFn: commentDecode,
|
DecodeFn: commentDecode,
|
||||||
|
@ -6,15 +6,15 @@ package vorbis
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
var vorbisComment decode.Group
|
var vorbisComment decode.Group
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.VORBIS_PACKET,
|
Name: format.VORBIS_PACKET,
|
||||||
Description: "Vorbis packet",
|
Description: "Vorbis packet",
|
||||||
DecodeFn: vorbisDecode,
|
DecodeFn: vorbisDecode,
|
||||||
|
@ -4,15 +4,15 @@ package vpx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: vpx frame?
|
// TODO: vpx frame?
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.VP8_FRAME,
|
Name: format.VP8_FRAME,
|
||||||
Description: "VP8 frame",
|
Description: "VP8 frame",
|
||||||
DecodeFn: vp8Decode,
|
DecodeFn: vp8Decode,
|
||||||
|
@ -4,12 +4,12 @@ package vpx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.VP9_CFM,
|
Name: format.VP9_CFM,
|
||||||
Description: "VP9 Codec Feature Metadata",
|
Description: "VP9 Codec Feature Metadata",
|
||||||
DecodeFn: vp9CFMDecode,
|
DecodeFn: vp9CFMDecode,
|
||||||
|
@ -4,8 +4,8 @@ package vpx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
"github.com/wader/fq/pkg/scalar"
|
"github.com/wader/fq/pkg/scalar"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ var vp9ProfilesMap = scalar.UToDescription{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.VP9_FRAME,
|
Name: format.VP9_FRAME,
|
||||||
Description: "VP9 frame",
|
Description: "VP9 frame",
|
||||||
DecodeFn: vp9Decode,
|
DecodeFn: vp9Decode,
|
||||||
|
@ -4,12 +4,12 @@ package vpx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wader/fq/format"
|
"github.com/wader/fq/format"
|
||||||
"github.com/wader/fq/format/registry"
|
|
||||||
"github.com/wader/fq/pkg/decode"
|
"github.com/wader/fq/pkg/decode"
|
||||||
|
"github.com/wader/fq/pkg/interp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.MustRegister(decode.Format{
|
interp.RegisterFormat(decode.Format{
|
||||||
Name: format.VPX_CCR,
|
Name: format.VPX_CCR,
|
||||||
Description: "VPX Codec Configuration Record",
|
Description: "VPX Codec Configuration Record",
|
||||||
DecodeFn: vpxCCRDecode,
|
DecodeFn: vpxCCRDecode,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user