2020-06-08 03:29:51 +03:00
|
|
|
package av1
|
|
|
|
|
|
|
|
// https://aomediacodec.github.io/av1-spec/av1-spec.pdf
|
|
|
|
// https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec/av1.md
|
|
|
|
// https://cdn.rawgit.com/AOMediaCodec/av1-isobmff/v1.0.0/
|
|
|
|
|
|
|
|
import (
|
2021-08-17 13:06:32 +03:00
|
|
|
"github.com/wader/fq/format"
|
|
|
|
"github.com/wader/fq/pkg/decode"
|
2022-07-16 19:39:57 +03:00
|
|
|
"github.com/wader/fq/pkg/interp"
|
2021-12-02 00:48:25 +03:00
|
|
|
"github.com/wader/fq/pkg/scalar"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2022-07-16 19:39:57 +03:00
|
|
|
interp.RegisterFormat(decode.Format{
|
2020-06-08 03:29:51 +03:00
|
|
|
Name: format.AV1_CCR,
|
|
|
|
Description: "AV1 Codec Configuration Record",
|
|
|
|
DecodeFn: ccrDecode,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-07-19 19:33:50 +03:00
|
|
|
func ccrDecode(d *decode.D, _ any) any {
|
2020-06-08 03:29:51 +03:00
|
|
|
d.FieldU1("marker")
|
|
|
|
d.FieldU7("version")
|
|
|
|
d.FieldU3("seq_profile")
|
|
|
|
d.FieldU5("seq_level_idx_0")
|
|
|
|
d.FieldU1("seq_tier_0")
|
|
|
|
d.FieldU1("high_bitdepth")
|
|
|
|
d.FieldU1("twelve_bit")
|
|
|
|
d.FieldU1("monochrome")
|
|
|
|
d.FieldU1("chroma_subsampling_x")
|
|
|
|
d.FieldU1("chroma_subsampling_y")
|
|
|
|
d.FieldU2("chroma_sample_position")
|
|
|
|
d.FieldU3("reserved = 0")
|
|
|
|
initalPreDelay := d.FieldBool("initial_presentation_delay_present")
|
|
|
|
if initalPreDelay {
|
2022-05-07 13:46:34 +03:00
|
|
|
d.FieldU4("initial_presentation_delay", scalar.ActualUAdd(1))
|
2020-06-08 03:29:51 +03:00
|
|
|
} else {
|
|
|
|
d.FieldU4("reserved")
|
|
|
|
}
|
|
|
|
if d.BitsLeft() > 0 {
|
2021-11-05 17:04:26 +03:00
|
|
|
d.FieldRawLen("config_obus", d.BitsLeft())
|
2020-06-08 03:29:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|