diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2023-04-04 21:35:51 +0200 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2023-04-13 02:31:32 +0200 |
commit | 6ca57ec389e9dd2141f9c9e73063c7193526dbbd (patch) | |
tree | 2cedbe36f75467fe9fb266c985c477983fa66629 /apps/plugins/lib/mul_id3.c | |
parent | 78c92c5ca85d275e43bacf0d9948ce9b94605f6e (diff) | |
download | rockbox-6ca57ec389e9dd2141f9c9e73063c7193526dbbd.tar.gz rockbox-6ca57ec389e9dd2141f9c9e73063c7193526dbbd.zip |
Track Info: Display larger file size and length values
When displaying Track Info for multiple tracks,
the value for combined file sizes or length was
capped at 2 GiB / ~596h.
Limit has been raised by a factor of 1000.
Change-Id: I942c64e81864cba3f719c83a24912883fafeb70e
Diffstat (limited to 'apps/plugins/lib/mul_id3.c')
-rw-r--r-- | apps/plugins/lib/mul_id3.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/apps/plugins/lib/mul_id3.c b/apps/plugins/lib/mul_id3.c index 5c8f4d9d9c..c40a495ecd 100644 --- a/apps/plugins/lib/mul_id3.c +++ b/apps/plugins/lib/mul_id3.c | |||
@@ -22,8 +22,8 @@ | |||
22 | #include "mul_id3.h" | 22 | #include "mul_id3.h" |
23 | 23 | ||
24 | struct multiple_tracks_id3 { | 24 | struct multiple_tracks_id3 { |
25 | unsigned long length; | 25 | unsigned long long filesize; |
26 | unsigned long filesize; | 26 | unsigned long long length; |
27 | unsigned long frequency; | 27 | unsigned long frequency; |
28 | unsigned int artist_hash; | 28 | unsigned int artist_hash; |
29 | unsigned int composer_hash; | 29 | unsigned int composer_hash; |
@@ -35,8 +35,6 @@ struct multiple_tracks_id3 { | |||
35 | unsigned int codectype; | 35 | unsigned int codectype; |
36 | unsigned int bitrate; | 36 | unsigned int bitrate; |
37 | int year; | 37 | int year; |
38 | bool filesize_ovf; | ||
39 | bool length_ovf; | ||
40 | bool vbr; | 38 | bool vbr; |
41 | }; | 39 | }; |
42 | 40 | ||
@@ -64,7 +62,7 @@ static unsigned int mfnv(char *str) | |||
64 | return hash; | 62 | return hash; |
65 | } | 63 | } |
66 | 64 | ||
67 | void init_mul_id3(void) | 65 | static void init_mul_id3(void) |
68 | { | 66 | { |
69 | mul_id3.artist_hash = 0; | 67 | mul_id3.artist_hash = 0; |
70 | mul_id3.album_hash = 0; | 68 | mul_id3.album_hash = 0; |
@@ -80,14 +78,13 @@ void init_mul_id3(void) | |||
80 | mul_id3.length = 0; | 78 | mul_id3.length = 0; |
81 | mul_id3.filesize = 0; | 79 | mul_id3.filesize = 0; |
82 | mul_id3.year = 0; | 80 | mul_id3.year = 0; |
83 | mul_id3.length_ovf = false; | ||
84 | mul_id3.filesize_ovf = false; | ||
85 | } | 81 | } |
86 | 82 | ||
87 | void collect_id3(struct mp3entry *id3, bool is_first_track) | 83 | void collect_id3(struct mp3entry *id3, bool is_first_track) |
88 | { | 84 | { |
89 | if (is_first_track) | 85 | if (is_first_track) |
90 | { | 86 | { |
87 | init_mul_id3(); | ||
91 | mul_id3.artist_hash = mfnv(id3->artist); | 88 | mul_id3.artist_hash = mfnv(id3->artist); |
92 | mul_id3.album_hash = mfnv(id3->album); | 89 | mul_id3.album_hash = mfnv(id3->album); |
93 | mul_id3.genre_hash = mfnv(id3->genre_string); | 90 | mul_id3.genre_hash = mfnv(id3->genre_string); |
@@ -129,25 +126,18 @@ void collect_id3(struct mp3entry *id3, bool is_first_track) | |||
129 | if (mul_id3.year && (id3->year != mul_id3.year)) | 126 | if (mul_id3.year && (id3->year != mul_id3.year)) |
130 | mul_id3.year = 0; | 127 | mul_id3.year = 0; |
131 | } | 128 | } |
132 | 129 | mul_id3.length += id3->length; | |
133 | if (ULONG_MAX - mul_id3.length < id3->length) | 130 | mul_id3.filesize += id3->filesize; |
134 | { | ||
135 | mul_id3.length_ovf = true; | ||
136 | mul_id3.length = 0; | ||
137 | } | ||
138 | else if (!mul_id3.length_ovf) | ||
139 | mul_id3.length += id3->length; | ||
140 | |||
141 | if (INT_MAX - mul_id3.filesize < id3->filesize) /* output_dyn_value expects int */ | ||
142 | { | ||
143 | mul_id3.filesize_ovf = true; | ||
144 | mul_id3.filesize = 0; | ||
145 | } | ||
146 | else if (!mul_id3.filesize_ovf) | ||
147 | mul_id3.filesize += id3->filesize; | ||
148 | } | 131 | } |
149 | 132 | ||
150 | void write_id3_mul_tracks(struct mp3entry *id3) | 133 | /* (!) Note scale factor applied to returned metadata: |
134 | * - Unit for filesize will be KiB instead of Bytes | ||
135 | * - Unit for length will be s instead of ms | ||
136 | * | ||
137 | * Use result only as input for browse_id3, | ||
138 | * and set multiple_tracks parameter to true. | ||
139 | */ | ||
140 | void finalize_id3(struct mp3entry *id3) | ||
151 | { | 141 | { |
152 | id3->path[0] = '\0'; | 142 | id3->path[0] = '\0'; |
153 | id3->title = NULL; | 143 | id3->title = NULL; |
@@ -169,8 +159,10 @@ void write_id3_mul_tracks(struct mp3entry *id3) | |||
169 | id3->track_string = NULL; | 159 | id3->track_string = NULL; |
170 | id3->year_string = NULL; | 160 | id3->year_string = NULL; |
171 | id3->year = mul_id3.year; | 161 | id3->year = mul_id3.year; |
172 | id3->length = mul_id3.length; | 162 | mul_id3.length /= 1000; |
173 | id3->filesize = mul_id3.filesize; | 163 | mul_id3.filesize >>= 10; |
164 | id3->length = mul_id3.length > ULONG_MAX ? 0 : mul_id3.length; | ||
165 | id3->filesize = mul_id3.filesize > INT_MAX ? 0 : mul_id3.filesize; | ||
174 | id3->frequency = mul_id3.frequency; | 166 | id3->frequency = mul_id3.frequency; |
175 | id3->bitrate = mul_id3.bitrate; | 167 | id3->bitrate = mul_id3.bitrate; |
176 | id3->codectype = mul_id3.codectype; | 168 | id3->codectype = mul_id3.codectype; |