diff options
Diffstat (limited to 'apps/metadata')
-rw-r--r-- | apps/metadata/asf.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/metadata/asf.c b/apps/metadata/asf.c index bcba3f0f79..f5532fa628 100644 --- a/apps/metadata/asf.c +++ b/apps/metadata/asf.c | |||
@@ -462,6 +462,53 @@ static int asf_parse_header(int fd, struct mp3entry* id3, | |||
462 | } else if (!strcmp("MusicBrainz/Track Id", utf8buf)) { | 462 | } else if (!strcmp("MusicBrainz/Track Id", utf8buf)) { |
463 | id3->mb_track_id = id3buf; | 463 | id3->mb_track_id = id3buf; |
464 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); | 464 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); |
465 | #ifdef HAVE_ALBUMART | ||
466 | } else if (!strcmp("WM/Picture", utf8buf)) { | ||
467 | uint32_t datalength, strlength; | ||
468 | /* Expected is either "01 00 xx xx 03 yy yy yy yy" or | ||
469 | * "03 yy yy yy yy". xx is the size of the WM/Picture | ||
470 | * container in bytes. yy equals the raw data length of | ||
471 | * the embedded image. */ | ||
472 | lseek(fd, -4, SEEK_CUR); | ||
473 | read(fd, &type, 1); | ||
474 | if (type == 1) { | ||
475 | lseek(fd, 3, SEEK_CUR); | ||
476 | read(fd, &type, 1); | ||
477 | /* In case the parsing will fail in the next step we | ||
478 | * might at least be able to skip the whole section. */ | ||
479 | datalength = length - 1; | ||
480 | } | ||
481 | if (type == 3) { | ||
482 | /* Read the raw data length of the embedded image. */ | ||
483 | read_uint32le(fd, &datalength); | ||
484 | |||
485 | /* Reset utf8 buffer */ | ||
486 | utf8 = utf8buf; | ||
487 | utf8length = 512; | ||
488 | |||
489 | /* Gather the album art format, this string has a | ||
490 | * double zero-termination. */ | ||
491 | asf_utf16LEdecode(fd, 32, &utf8, &utf8length); | ||
492 | strlength = (strlen(utf8buf) + 2) * 2; | ||
493 | lseek(fd, strlength-32, SEEK_CUR); | ||
494 | if (!strcmp("image/jpeg", utf8buf)) { | ||
495 | id3->albumart.type = AA_TYPE_JPG; | ||
496 | } else if (!strcmp("image/png", utf8buf)) { | ||
497 | id3->albumart.type = AA_TYPE_PNG; | ||
498 | } else { | ||
499 | id3->albumart.type = AA_TYPE_UNKNOWN; | ||
500 | } | ||
501 | |||
502 | /* Set the album art size and position. */ | ||
503 | if (id3->albumart.type != AA_TYPE_UNKNOWN) { | ||
504 | id3->albumart.pos = lseek(fd, 0, SEEK_CUR); | ||
505 | id3->albumart.size = datalength; | ||
506 | id3->embed_albumart = true; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | lseek(fd, datalength, SEEK_CUR); | ||
511 | #endif | ||
465 | } else { | 512 | } else { |
466 | lseek(fd, length, SEEK_CUR); | 513 | lseek(fd, length, SEEK_CUR); |
467 | } | 514 | } |