2020-06-08 03:29:51 +03:00
|
|
|
package vpx
|
|
|
|
|
|
|
|
// https://www.webmproject.org/docs/container/#vp9-codec-feature-metadata-codecprivate
|
|
|
|
|
|
|
|
import (
|
2021-08-17 13:06:32 +03:00
|
|
|
"github.com/wader/fq/format"
|
|
|
|
"github.com/wader/fq/format/registry"
|
|
|
|
"github.com/wader/fq/pkg/decode"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-11-17 18:46:10 +03:00
|
|
|
registry.MustRegister(decode.Format{
|
2020-06-08 03:29:51 +03:00
|
|
|
Name: format.VP9_CFM,
|
|
|
|
Description: "VP9 Codec Feature Metadata",
|
|
|
|
DecodeFn: vp9CFMDecode,
|
2021-11-03 19:19:33 +03:00
|
|
|
RootArray: true,
|
2021-09-16 17:26:31 +03:00
|
|
|
RootName: "features",
|
2020-06-08 03:29:51 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func vp9CFMDecode(d *decode.D, in interface{}) interface{} {
|
2021-09-16 17:26:31 +03:00
|
|
|
for d.NotEnd() {
|
2021-11-05 17:04:26 +03:00
|
|
|
d.FieldStruct("feature", func(d *decode.D) {
|
2021-11-17 18:13:10 +03:00
|
|
|
id := d.FieldU8("id", d.MapUToStrSym(vp9FeatureIDNames))
|
2021-09-16 17:26:31 +03:00
|
|
|
l := d.FieldU8("length")
|
2021-11-05 17:04:26 +03:00
|
|
|
d.LenFn(int64(l)*8, func(d *decode.D) {
|
2021-09-16 17:26:31 +03:00
|
|
|
switch id {
|
|
|
|
case vp9FeatureProfile:
|
|
|
|
d.FieldU8("profile")
|
|
|
|
case vp9FeatureLevel:
|
2021-11-17 18:13:10 +03:00
|
|
|
d.FieldU8("level", d.MapUToStrSym(vpxLevelNames))
|
2021-09-16 17:26:31 +03:00
|
|
|
case vp9FeatureBitDepth:
|
|
|
|
d.FieldU8("bit_depth")
|
|
|
|
case vp9FeatureChromaSubsampling:
|
2021-11-17 18:13:10 +03:00
|
|
|
d.FieldU8("chroma_subsampling", d.MapUToStrSym(vpxChromeSubsamplingNames))
|
2021-09-16 17:26:31 +03:00
|
|
|
default:
|
2021-11-05 17:04:26 +03:00
|
|
|
d.FieldRawLen("data", d.BitsLeft())
|
2021-09-16 17:26:31 +03:00
|
|
|
}
|
2020-06-08 03:29:51 +03:00
|
|
|
})
|
2021-09-16 17:26:31 +03:00
|
|
|
})
|
|
|
|
}
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|