2020-06-08 03:29:51 +03:00
|
|
|
package flac
|
|
|
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
|
|
|
var images []*decode.Format
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
registry.MustRegister(&decode.Format{
|
|
|
|
Name: format.FLAC_PICTURE,
|
|
|
|
Description: "FLAC metadatablock picture",
|
|
|
|
DecodeFn: pictureDecode,
|
|
|
|
Dependencies: []decode.Dependency{
|
|
|
|
{Names: []string{format.IMAGE}, Formats: &images},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func pictureDecode(d *decode.D, in interface{}) interface{} {
|
|
|
|
lenStr := func(name string) string { //nolint:unparam
|
|
|
|
l := d.FieldU32(name + "_length")
|
|
|
|
return d.FieldUTF8(name, int(l))
|
|
|
|
}
|
|
|
|
d.FieldU32("picture_type")
|
|
|
|
lenStr("mime")
|
|
|
|
lenStr("description")
|
|
|
|
d.FieldU32("width")
|
|
|
|
d.FieldU32("height")
|
|
|
|
d.FieldU32("color_depth")
|
|
|
|
d.FieldU32("number_of_index_colors")
|
|
|
|
pictureLen := d.FieldU32("picture_length")
|
2021-09-16 16:29:11 +03:00
|
|
|
d.FieldFormatLen("picture_data", int64(pictureLen)*8, images, nil)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|