From 09385c612ea3a740e3e1c416d10c5eab703d2230 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Wed, 6 Apr 2022 13:19:50 +0200 Subject: [PATCH] id3v2: Add 2.0 PIC support --- format/id3/id3v2.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/format/id3/id3v2.go b/format/id3/id3v2.go index 34712414..497d1a70 100644 --- a/format/id3/id3v2.go +++ b/format/id3/id3v2.go @@ -417,6 +417,24 @@ func decodeFrame(d *decode.D, version int) uint64 { }) }, + // id3v2.0 + // Attached picture "PIC" + // Frame size $xx xx xx + // Text encoding $xx + // Image format $xx xx xx + // Picture type $xx + // Description $00 (00) + // Picture data + "PIC": func(d *decode.D) { + encoding := d.FieldU8("text_encoding", encodingNames) + d.FieldUTF8("image_format", 3) + d.FieldU8("picture_type") // TODO: table + d.FieldStrFn("description", textNullFn(int(encoding))) + if dv, _, _ := d.TryFieldFormatLen("picture", d.BitsLeft(), imageFormat, nil); dv == nil { + d.FieldRawLen("picture", d.BitsLeft()) + } + }, + //
// Text encoding $xx // MIME type $00 @@ -428,8 +446,7 @@ func decodeFrame(d *decode.D, version int) uint64 { d.FieldStrFn("mime_type", textNullFn(encodingUTF8)) d.FieldU8("picture_type") // TODO: table d.FieldStrFn("description", textNullFn(int(encoding))) - dv, _, _ := d.TryFieldFormatLen("picture", d.BitsLeft(), imageFormat, nil) - if dv == nil { + if dv, _, _ := d.TryFieldFormatLen("picture", d.BitsLeft(), imageFormat, nil); dv == nil { d.FieldRawLen("picture", d.BitsLeft()) } }, @@ -445,8 +462,7 @@ func decodeFrame(d *decode.D, version int) uint64 { d.FieldStrFn("mime_type", textNullFn(encodingUTF8)) d.FieldStrFn("filename", textNullFn(int(encoding))) d.FieldStrFn("description", textNullFn(int(encoding))) - dv, _, _ := d.TryFieldFormatLen("data", d.BitsLeft(), imageFormat, nil) - if dv == nil { + if dv, _, _ := d.TryFieldFormatLen("data", d.BitsLeft(), imageFormat, nil); dv == nil { d.FieldRawLen("data", d.BitsLeft()) } },