Diffstat (limited to 'core/multimedia/opieplayer/libmad/layer12.c') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/layer12.c | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/core/multimedia/opieplayer/libmad/layer12.c b/core/multimedia/opieplayer/libmad/layer12.c index d291174..512b6a5 100644 --- a/core/multimedia/opieplayer/libmad/layer12.c +++ b/core/multimedia/opieplayer/libmad/layer12.c | |||
@@ -2,3 +2,3 @@ | |||
2 | * libmad - MPEG audio decoder library | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. |
4 | * | 4 | * |
@@ -44,3 +44,3 @@ | |||
44 | static | 44 | static |
45 | mad_fixed_t const sf_table[63] = { | 45 | mad_fixed_t const sf_table[64] = { |
46 | # include "sf_table.dat" | 46 | # include "sf_table.dat" |
@@ -165,2 +165,8 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) | |||
165 | 165 | ||
166 | # if defined(OPT_STRICT) | ||
167 | /* | ||
168 | * Scalefactor index 63 does not appear in Table B.1 of | ||
169 | * ISO/IEC 11172-3. Nonetheless, other implementations accept it, | ||
170 | * so we only reject it if OPT_STRICT is defined. | ||
171 | */ | ||
166 | if (scalefactor[ch][sb] == 63) { | 172 | if (scalefactor[ch][sb] == 63) { |
@@ -169,2 +175,3 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) | |||
169 | } | 175 | } |
176 | # endif | ||
170 | } | 177 | } |
@@ -336,16 +343,40 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) | |||
336 | index = 4; | 343 | index = 4; |
344 | else if (header->flags & MAD_FLAG_FREEFORMAT) | ||
345 | goto freeformat; | ||
337 | else { | 346 | else { |
338 | switch (nch == 2 ? header->bitrate / 2 : header->bitrate) { | 347 | unsigned long bitrate_per_channel; |
339 | case 32000: | ||
340 | case 48000: | ||
341 | index = (header->samplerate == 32000) ? 3 : 2; | ||
342 | break; | ||
343 | 348 | ||
344 | case 56000: | 349 | bitrate_per_channel = header->bitrate; |
345 | case 64000: | 350 | if (nch == 2) { |
346 | case 80000: | 351 | bitrate_per_channel /= 2; |
347 | index = 0; | ||
348 | break; | ||
349 | 352 | ||
350 | default: | 353 | # if defined(OPT_STRICT) |
354 | /* | ||
355 | * ISO/IEC 11172-3 allows only single channel mode for 32, 48, 56, and | ||
356 | * 80 kbps bitrates in Layer II, but some encoders ignore this | ||
357 | * restriction. We enforce it if OPT_STRICT is defined. | ||
358 | */ | ||
359 | if (bitrate_per_channel <= 28000 || bitrate_per_channel == 40000) { | ||
360 | stream->error = MAD_ERROR_BADMODE; | ||
361 | return -1; | ||
362 | } | ||
363 | # endif | ||
364 | } | ||
365 | else { /* nch == 1 */ | ||
366 | if (bitrate_per_channel > 192000) { | ||
367 | /* | ||
368 | * ISO/IEC 11172-3 does not allow single channel mode for 224, 256, | ||
369 | * 320, or 384 kbps bitrates in Layer II. | ||
370 | */ | ||
371 | stream->error = MAD_ERROR_BADMODE; | ||
372 | return -1; | ||
373 | } | ||
374 | } | ||
375 | |||
376 | if (bitrate_per_channel <= 48000) | ||
377 | index = (header->samplerate == 32000) ? 3 : 2; | ||
378 | else if (bitrate_per_channel <= 80000) | ||
379 | index = 0; | ||
380 | else { | ||
381 | freeformat: | ||
351 | index = (header->samplerate == 48000) ? 0 : 1; | 382 | index = (header->samplerate == 48000) ? 0 : 1; |
@@ -433,2 +464,8 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) | |||
433 | 464 | ||
465 | # if defined(OPT_STRICT) | ||
466 | /* | ||
467 | * Scalefactor index 63 does not appear in Table B.1 of | ||
468 | * ISO/IEC 11172-3. Nonetheless, other implementations accept it, | ||
469 | * so we only reject it if OPT_STRICT is defined. | ||
470 | */ | ||
434 | if (scalefactor[ch][sb][0] == 63 || | 471 | if (scalefactor[ch][sb][0] == 63 || |
@@ -439,2 +476,3 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) | |||
439 | } | 476 | } |
477 | # endif | ||
440 | } | 478 | } |