diff options
author | Roman Artiukhin <bahusdrive@gmail.com> | 2024-10-19 10:33:19 +0300 |
---|---|---|
committer | Roman Artiukhin <bahusdrive@gmail.com> | 2024-10-23 09:10:18 +0300 |
commit | 063b917f69c919362c328ee036ac1a28eb9cf25e (patch) | |
tree | 6ae20383fbc7c56e683bcf687dccd673857b75c5 /lib | |
parent | a232b1a98de719c3d3093141e928d37d30b9b574 (diff) | |
download | rockbox-063b917f69c919362c328ee036ac1a28eb9cf25e.tar.gz rockbox-063b917f69c919362c328ee036ac1a28eb9cf25e.zip |
Codecs: wma: fix parsing album art
We can't assume that album art file starts right after album art type (apparently it can contain also additional info like filename).
Related to FS#12576 (album art is now shown)
Change-Id: I68c7a1dc536ff13a47fb73ea84539b2f7a44265b
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbcodec/metadata/asf.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/rbcodec/metadata/asf.c b/lib/rbcodec/metadata/asf.c index f342a473ea..833dd62be6 100644 --- a/lib/rbcodec/metadata/asf.c +++ b/lib/rbcodec/metadata/asf.c | |||
@@ -510,8 +510,6 @@ static int asf_parse_header(int fd, struct mp3entry* id3, | |||
510 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); | 510 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); |
511 | #ifdef HAVE_ALBUMART | 511 | #ifdef HAVE_ALBUMART |
512 | } else if (itag == eWM_Picture) { | 512 | } else if (itag == eWM_Picture) { |
513 | uint32_t datalength = 0; | ||
514 | uint32_t strlength; | ||
515 | /* Expected is either "01 00 xx xx 03 yy yy yy yy" or | 513 | /* Expected is either "01 00 xx xx 03 yy yy yy yy" or |
516 | * "03 yy yy yy yy". xx is the size of the WM/Picture | 514 | * "03 yy yy yy yy". xx is the size of the WM/Picture |
517 | * container in bytes. yy equals the raw data length of | 515 | * container in bytes. yy equals the raw data length of |
@@ -528,8 +526,9 @@ static int asf_parse_header(int fd, struct mp3entry* id3, | |||
528 | read(fd, &type, 1); | 526 | read(fd, &type, 1); |
529 | } | 527 | } |
530 | if (type == 3) { | 528 | if (type == 3) { |
529 | uint32_t pic_size = 0; | ||
531 | /* Read the raw data length of the embedded image. */ | 530 | /* Read the raw data length of the embedded image. */ |
532 | read_uint32le(fd, &datalength); | 531 | read_uint32le(fd, &pic_size); |
533 | 532 | ||
534 | /* Reset utf8 buffer */ | 533 | /* Reset utf8 buffer */ |
535 | utf8 = utf8buf; | 534 | utf8 = utf8buf; |
@@ -538,8 +537,6 @@ static int asf_parse_header(int fd, struct mp3entry* id3, | |||
538 | /* Gather the album art format, this string has a | 537 | /* Gather the album art format, this string has a |
539 | * double zero-termination. */ | 538 | * double zero-termination. */ |
540 | asf_utf16LEdecode(fd, 32, &utf8, &utf8length); | 539 | asf_utf16LEdecode(fd, 32, &utf8, &utf8length); |
541 | strlength = (strlen(utf8buf) + 2) * 2; | ||
542 | lseek(fd, strlength-32, SEEK_CUR); | ||
543 | 540 | ||
544 | static const char *aa_options[] = {"image/jpeg", | 541 | static const char *aa_options[] = {"image/jpeg", |
545 | "image/jpg","image/png", NULL}; | 542 | "image/jpg","image/png", NULL}; |
@@ -564,8 +561,8 @@ static int asf_parse_header(int fd, struct mp3entry* id3, | |||
564 | 561 | ||
565 | /* Set the album art size and position. */ | 562 | /* Set the album art size and position. */ |
566 | if (id3->albumart.type != AA_TYPE_UNKNOWN) { | 563 | if (id3->albumart.type != AA_TYPE_UNKNOWN) { |
567 | id3->albumart.pos = lseek(fd, 0, SEEK_CUR); | 564 | id3->albumart.pos = after_pic_pos - pic_size; |
568 | id3->albumart.size = datalength; | 565 | id3->albumart.size = pic_size; |
569 | id3->has_embedded_albumart = true; | 566 | id3->has_embedded_albumart = true; |
570 | } | 567 | } |
571 | } | 568 | } |