aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/mp3_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/mp3_extractor.c')
-rw-r--r--src/plugins/mp3_extractor.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/plugins/mp3_extractor.c b/src/plugins/mp3_extractor.c
index 778c892..3d8d48d 100644
--- a/src/plugins/mp3_extractor.c
+++ b/src/plugins/mp3_extractor.c
@@ -207,6 +207,21 @@ EXTRACTOR_mp3_extract (const unsigned char *data,
207 frame_size = 207 frame_size =
208 144 * bitrate / (sample_rate ? sample_rate : 1) + 208 144 * bitrate / (sample_rate ? sample_rate : 1) +
209 ((header >> MPA_PADDING_SHIFT) & 0x1); 209 ((header >> MPA_PADDING_SHIFT) & 0x1);
210 if (frame_size <= 0)
211 {
212 /* Technically, bitrate can be 0. However, but this particular
213 * extractor is incapable of correctly processing 0-bitrate files
214 * anyway. And bitrate == 0 might also mean that this is just a
215 * random binary sequence, which is far more likely to be true.
216 *
217 * amatus suggests to use a different algorithm and parse significant
218 * part of the file, then count the number of correct mpeg frames.
219 * If the the percentage of correct frames is below a threshold,
220 * then this is not an mpeg file at all.
221 */
222 frames -= 1;
223 break;
224 }
210 avg_bps += bitrate / 1000; 225 avg_bps += bitrate / 1000;
211 226
212 pos += frame_size - 4; 227 pos += frame_size - 4;
@@ -221,7 +236,7 @@ EXTRACTOR_mp3_extract (const unsigned char *data,
221 } 236 }
222 while ((header & MPA_SYNC_MASK) == MPA_SYNC_MASK); 237 while ((header & MPA_SYNC_MASK) == MPA_SYNC_MASK);
223 238
224 if (!frames) 239 if (frames < 2)
225 return 0; /*no valid frames */ 240 return 0; /*no valid frames */
226 ADDR ("audio/mpeg", EXTRACTOR_METATYPE_MIMETYPE); 241 ADDR ("audio/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
227 avg_bps = avg_bps / frames; 242 avg_bps = avg_bps / frames;