Mercurial > audlegacy-plugins
comparison src/madplug/plugin.c @ 897:44a922a4a591 trunk
[svn] - fix validation of mpeg2 files, by ccr.
author | nenolod |
---|---|
date | Sat, 24 Mar 2007 17:31:14 -0700 |
parents | 0f9c8d4d3ac4 |
children | a8494c2a87eb |
comparison
equal
deleted
inserted
replaced
896:f0846bdd9de6 | 897:44a922a4a591 |
---|---|
196 | 196 |
197 /* check if layer bits (17-18) are good */ | 197 /* check if layer bits (17-18) are good */ |
198 layer = (head >> 17) & 0x3; | 198 layer = (head >> 17) & 0x3; |
199 if (!layer) | 199 if (!layer) |
200 return FALSE; /* 00 = reserved */ | 200 return FALSE; /* 00 = reserved */ |
201 layer = 3 - layer; | 201 layer = 4 - layer; |
202 | 202 |
203 /* check if bitrate index bits (12-15) are acceptable */ | 203 /* check if bitrate index bits (12-15) are acceptable */ |
204 bitIndex = (head >> 12) & 0xf; | 204 bitIndex = (head >> 12) & 0xf; |
205 | 205 |
206 /* 1111 and 0000 are reserved values for all layers */ | 206 /* 1111 and 0000 are reserved values for all layers */ |
241 if (chanMode == 0x3) { | 241 if (chanMode == 0x3) { |
242 /* single channel with bitrate > 192 */ | 242 /* single channel with bitrate > 192 */ |
243 if (bitRate > 192) | 243 if (bitRate > 192) |
244 return FALSE; | 244 return FALSE; |
245 } else { | 245 } else { |
246 /* any other mode with bitrates 32-56 and 80 */ | 246 /* any other mode with bitrates 32-56 and 80. |
247 * NOTICE! this check is not entirely correct, but I think | |
248 * it is sufficient in most cases. | |
249 */ | |
247 if (((bitRate >= 32 && bitRate <= 56) || bitRate == 80)) | 250 if (((bitRate >= 32 && bitRate <= 56) || bitRate == 80)) |
248 return FALSE; | 251 return FALSE; |
249 } | 252 } |
250 } | 253 } |
251 | 254 |
252 /* calculate approx. frame size */ | 255 /* calculate approx. frame size */ |
253 padding = (head >> 9) & 1; | 256 padding = (head >> 9) & 1; |
254 sampleRate = mp3_samplerate_table[version][sampleIndex]; | 257 sampleRate = mp3_samplerate_table[version][sampleIndex]; |
255 *frameSize = (144 * bitRate * 1000) / (sampleRate + padding); | 258 if (layer == 1) |
256 | 259 *frameSize = ((12 * bitRate * 1000 / sampleRate) + padding) * 4; |
260 else | |
261 *frameSize = (144 * bitRate * 1000) / (sampleRate + padding); | |
262 | |
257 /* check if bits 16 - 19 are all set (MPEG 1 Layer I, not protected?) */ | 263 /* check if bits 16 - 19 are all set (MPEG 1 Layer I, not protected?) */ |
258 if (((head >> 19) & 1) == 1 && | 264 if (((head >> 19) & 1) == 1 && |
259 ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1) | 265 ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1) |
260 return FALSE; | 266 return FALSE; |
261 | 267 |