mirror of
https://github.com/wader/fq.git
synced 2024-12-23 13:22:58 +03:00
8e0dde03d0
This will allow passing both cli options and format options to sub decoder. Ex: pass keylog option to a tls decoder when decoding a pcap. Ex: pass decode options to a format inside a http body inside a pcap. Add ArgAs method to lookup argument based on type. This also makes the format decode function have same signature as sub decoders in the decode API. This change decode.Format a bit: DecodeFn is now just func(d *D) any DecodeInArg renamed to DefaultInArg
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package vpx
|
|
|
|
// https://www.webmproject.org/docs/container/#vp9-codec-feature-metadata-codecprivate
|
|
|
|
import (
|
|
"github.com/wader/fq/format"
|
|
"github.com/wader/fq/pkg/decode"
|
|
"github.com/wader/fq/pkg/interp"
|
|
)
|
|
|
|
func init() {
|
|
interp.RegisterFormat(decode.Format{
|
|
Name: format.VP9_CFM,
|
|
Description: "VP9 Codec Feature Metadata",
|
|
DecodeFn: vp9CFMDecode,
|
|
RootArray: true,
|
|
RootName: "features",
|
|
})
|
|
}
|
|
|
|
func vp9CFMDecode(d *decode.D) any {
|
|
for d.NotEnd() {
|
|
d.FieldStruct("feature", func(d *decode.D) {
|
|
id := d.FieldU8("id", vp9FeatureIDNames)
|
|
l := d.FieldU8("length")
|
|
d.FramedFn(int64(l)*8, func(d *decode.D) {
|
|
switch id {
|
|
case vp9FeatureProfile:
|
|
d.FieldU8("profile")
|
|
case vp9FeatureLevel:
|
|
d.FieldU8("level", vpxLevelNames)
|
|
case vp9FeatureBitDepth:
|
|
d.FieldU8("bit_depth")
|
|
case vp9FeatureChromaSubsampling:
|
|
d.FieldU8("chroma_subsampling", vpxChromeSubsamplingNames)
|
|
default:
|
|
d.FieldRawLen("data", d.BitsLeft())
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
return nil
|
|
}
|