Skip to content

Commit 9b499b1

Browse files
committed
metadata: mp4: Fill discs/tracks count
Change-Id: If6b2a73ad0fecc27aaee371f8c860031eacca796
1 parent 96185f4 commit 9b499b1

File tree

1 file changed

+24
-12
lines changed
  • lib/rbcodec/metadata

1 file changed

+24
-12
lines changed

lib/rbcodec/metadata/mp4.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,28 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
367367
return sbr;
368368
}
369369

370+
static void read_mp4_tag_i_from_n(int fd, int *i, char** i_from_n_string, uint32_t size, unsigned int *buffer_left, char **buffer)
371+
{
372+
uint16_t x[3];
373+
*i = 0;
374+
*i_from_n_string = NULL;
375+
if (read_mp4_tag(fd, size, (char*) &x, sizeof(x)) == sizeof(x))
376+
{
377+
*i = betoh16(x[1]);
378+
int n = betoh16(x[2]);
379+
if (n > 0)
380+
{
381+
int string_length = snprintf(*buffer, *buffer_left,"%d/%d", *i, n) + 1;
382+
if (string_length <= *buffer_left)
383+
{
384+
*i_from_n_string = *buffer;
385+
*buffer += string_length;
386+
*buffer_left -= string_length;
387+
}
388+
}
389+
}
390+
}
391+
370392
static bool read_mp4_tags(int fd, struct mp3entry* id3,
371393
uint32_t size_left)
372394
{
@@ -456,21 +478,11 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3,
456478
break;
457479

458480
case MP4_disk:
459-
{
460-
unsigned short n[2];
461-
id3->discnum = 0;
462-
if (read_mp4_tag(fd, size, (char*) &n, sizeof(n)) == sizeof(n))
463-
id3->discnum = betoh16(n[1]);
464-
}
481+
read_mp4_tag_i_from_n(fd, &id3->discnum, &id3->disc_string, size, &buffer_left, &buffer);
465482
break;
466483

467484
case MP4_trkn:
468-
{
469-
unsigned short n[2];
470-
id3->tracknum = 0;
471-
if (read_mp4_tag(fd, size, (char*) &n, sizeof(n)) == sizeof(n))
472-
id3->tracknum = betoh16(n[1]);
473-
}
485+
read_mp4_tag_i_from_n(fd, &id3->tracknum, &id3->track_string, size, &buffer_left, &buffer);
474486
break;
475487

476488
#ifdef HAVE_ALBUMART

0 commit comments

Comments
 (0)