Skip to content

Commit

Permalink
flac_picture: Add picture_type names
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Oct 13, 2021
1 parent 15d85e1 commit 509b8f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion format/flac/flac_picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ import (

var images []*decode.Format

var pictureTypeNames = map[uint64]string{
0: "Other",
1: "32x32 pixels 'file icon' (PNG only)",
2: "Other file icon",
3: "Cover (front)",
4: "Cover (back)",
5: "Leaflet page",
6: "Media (e.g. label side of CD)",
7: "Lead artist/lead performer/soloist",
8: "Artist/performer",
9: "Conductor",
10: "Band/Orchestra",
11: "Composer",
12: "Lyricist/text writer",
13: "Recording Location",
14: "During recording",
15: "During performance",
16: "Movie/video screen capture",
17: "A bright colored fish",
18: "Illustration",
19: "Band/artist logotype",
20: "Publisher/Studio logotype",
}

func init() {
registry.MustRegister(&decode.Format{
Name: format.FLAC_PICTURE,
Expand All @@ -24,7 +48,7 @@ func pictureDecode(d *decode.D, in interface{}) interface{} {
l := d.FieldU32(name + "_length")
return d.FieldUTF8(name, int(l))
}
d.FieldU32("picture_type")
d.FieldStringMapFn("picture_type", pictureTypeNames, "Unknown", d.U32, decode.NumberDecimal)
lenStr("mime")
lenStr("description")
d.FieldU32("width")
Expand Down
2 changes: 1 addition & 1 deletion format/flac/testdata/picture_seek_gain.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ $ fq -d flac verbose /picture_seek_gain.flac
0x0120| 06| .| type: Picture (6) 0x12f.1-0x12f.7 (0.7)
0x0130|00 01 2c |.., | length: 300 0x130-0x132.7 (3)
| | | picture: {} (flac_picture) 0x133-0x25e.7 (300)
0x0130| 00 00 00 03 | .... | picture_type: 3 0x133-0x136.7 (4)
0x0130| 00 00 00 03 | .... | picture_type: Cover (front) (3) 0x133-0x136.7 (4)
0x0130| 00 00 00 09 | .... | mime_length: 9 0x137-0x13a.7 (4)
0x0130| 69 6d 61 67 65| image| mime: "image/png" 0x13b-0x143.7 (9)
0x0140|2f 70 6e 67 |/png |
Expand Down

0 comments on commit 509b8f8

Please sign in to comment.