summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/frame.c
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/frame.c') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/frame.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/libmad/frame.c b/core/multimedia/opieplayer/libmad/frame.c
index bf15e7f..3aacb56 100644
--- a/core/multimedia/opieplayer/libmad/frame.c
+++ b/core/multimedia/opieplayer/libmad/frame.c
@@ -1,9 +1,9 @@
1/* 1/*
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 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
@@ -207,16 +207,23 @@ int decode_header(struct mad_header *header, struct mad_stream *stream)
207 if (mad_bit_read(&stream->ptr, 1)) 207 if (mad_bit_read(&stream->ptr, 1))
208 header->flags |= MAD_FLAG_ORIGINAL; 208 header->flags |= MAD_FLAG_ORIGINAL;
209 209
210 /* emphasis */ 210 /* emphasis */
211 header->emphasis = mad_bit_read(&stream->ptr, 2); 211 header->emphasis = mad_bit_read(&stream->ptr, 2);
212 212
213 if (header->emphasis == 2) { 213# if defined(OPT_STRICT)
214 /*
215 * ISO/IEC 11172-3 says this is a reserved emphasis value, but
216 * streams exist which use it anyway. Since the value is not important
217 * to the decoder proper, we allow it unless OPT_STRICT is defined.
218 */
219 if (header->emphasis == MAD_EMPHASIS_RESERVED) {
214 stream->error = MAD_ERROR_BADEMPHASIS; 220 stream->error = MAD_ERROR_BADEMPHASIS;
215 return -1; 221 return -1;
216 } 222 }
223# endif
217 224
218 /* error_check() */ 225 /* error_check() */
219 226
220 /* crc_check */ 227 /* crc_check */
221 if (header->flags & MAD_FLAG_PROTECTION) 228 if (header->flags & MAD_FLAG_PROTECTION)
222 header->crc_target = mad_bit_read(&stream->ptr, 16); 229 header->crc_target = mad_bit_read(&stream->ptr, 16);
@@ -280,16 +287,12 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
280 stream->error = MAD_ERROR_LOSTSYNC; 287 stream->error = MAD_ERROR_LOSTSYNC;
281 return -1; 288 return -1;
282 } 289 }
283 290
284 stream->freerate = rate * 1000; 291 stream->freerate = rate * 1000;
285 292
286# if 0 && defined(DEBUG)
287 fprintf(stderr, "free bitrate == %lu\n", stream->freerate);
288# endif
289
290 return 0; 293 return 0;
291} 294}
292 295
293/* 296/*
294 * NAME:header->decode() 297 * NAME:header->decode()
295 * DESCRIPTION:read the next frame header from the stream 298 * DESCRIPTION:read the next frame header from the stream
@@ -370,13 +373,14 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
370 /* calculate frame duration */ 373 /* calculate frame duration */
371 mad_timer_set(&header->duration, 0, 374 mad_timer_set(&header->duration, 0,
372 32 * MAD_NSBSAMPLES(header), header->samplerate); 375 32 * MAD_NSBSAMPLES(header), header->samplerate);
373 376
374 /* calculate free bit rate */ 377 /* calculate free bit rate */
375 if (header->bitrate == 0) { 378 if (header->bitrate == 0) {
376 if ((stream->freerate == 0 || !stream->sync) && 379 if ((stream->freerate == 0 || !stream->sync ||
380 (header->layer == MAD_LAYER_III && stream->freerate > 640000)) &&
377 free_bitrate(stream, header) == -1) 381 free_bitrate(stream, header) == -1)
378 goto fail; 382 goto fail;
379 383
380 header->bitrate = stream->freerate; 384 header->bitrate = stream->freerate;
381 header->flags |= MAD_FLAG_FREEFORMAT; 385 header->flags |= MAD_FLAG_FREEFORMAT;
382 } 386 }