~ubuntu-branches/ubuntu/precise/flac/precise-updates

« back to all changes in this revision

Viewing changes to src/libFLAC/fixed.c

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Kwan
  • Date: 2007-05-29 22:56:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529225636-ljeff8xxip09qaap
Tags: 1.1.4-1
* New upstream release. closes: #405167, #411311
  - libOggFLAC and libOggFLAC++ have been merged into libFLAC, so
    remove their corresponding packages.
  - Because of the API changes required to effect the above, there has
    been yet another soname bump. libflac7 -> libflac8 and
    libflac++5 -> libflac++6. Emails have been dispatched to the
    maintainers of dependent packages.
* Some notes on patches that were removed:
  - 02_stdin_stdout, 06_manpage_mention_utf8_convert: merged upstream
  - 08_manpage_warnings: Upstream has changed the manpage so it defintely
    can't fit in in 80 cols, so just forget about it. We'll live.
  - 05_eof_warnings_are_errors: Upstream decided to add a -w option to
    flac to treat all warnings as errors. I am going to defer to that
    for now, but if people think it's stupid let me know and I'll port
    the patch forward.
  - 04_stack_smasher: was a backport from 1.1.3, so it's obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* libFLAC - Free Lossless Audio Codec library
2
 
 * Copyright (C) 2000,2001,2002,2003,2004,2005  Josh Coalson
 
2
 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007  Josh Coalson
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions
29
29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
30
 */
31
31
 
 
32
#if HAVE_CONFIG_H
 
33
#  include <config.h>
 
34
#endif
 
35
 
32
36
#include <math.h>
 
37
#include <string.h>
33
38
#include "private/bitmath.h"
34
39
#include "private/fixed.h"
35
40
#include "FLAC/assert.h"
351
356
 
352
357
        switch(order) {
353
358
                case 0:
354
 
                        for(i = 0; i < idata_len; i++) {
355
 
                                residual[i] = data[i];
356
 
                        }
 
359
                        FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
 
360
                        memcpy(residual, data, sizeof(residual[0])*data_len);
357
361
                        break;
358
362
                case 1:
359
 
                        for(i = 0; i < idata_len; i++) {
 
363
                        for(i = 0; i < idata_len; i++)
360
364
                                residual[i] = data[i] - data[i-1];
361
 
                        }
362
365
                        break;
363
366
                case 2:
364
 
                        for(i = 0; i < idata_len; i++) {
365
 
                                /* == data[i] - 2*data[i-1] + data[i-2] */
 
367
                        for(i = 0; i < idata_len; i++)
 
368
#if 1 /* OPT: may be faster with some compilers on some systems */
366
369
                                residual[i] = data[i] - (data[i-1] << 1) + data[i-2];
367
 
                        }
 
370
#else
 
371
                                residual[i] = data[i] - 2*data[i-1] + data[i-2];
 
372
#endif
368
373
                        break;
369
374
                case 3:
370
 
                        for(i = 0; i < idata_len; i++) {
371
 
                                /* == data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3] */
 
375
                        for(i = 0; i < idata_len; i++)
 
376
#if 1 /* OPT: may be faster with some compilers on some systems */
372
377
                                residual[i] = data[i] - (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) - data[i-3];
373
 
                        }
 
378
#else
 
379
                                residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3];
 
380
#endif
374
381
                        break;
375
382
                case 4:
376
 
                        for(i = 0; i < idata_len; i++) {
377
 
                                /* == data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4] */
 
383
                        for(i = 0; i < idata_len; i++)
 
384
#if 1 /* OPT: may be faster with some compilers on some systems */
378
385
                                residual[i] = data[i] - ((data[i-1]+data[i-3])<<2) + ((data[i-2]<<2) + (data[i-2]<<1)) + data[i-4];
379
 
                        }
 
386
#else
 
387
                                residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4];
 
388
#endif
380
389
                        break;
381
390
                default:
382
391
                        FLAC__ASSERT(0);
389
398
 
390
399
        switch(order) {
391
400
                case 0:
392
 
                        for(i = 0; i < idata_len; i++) {
393
 
                                data[i] = residual[i];
394
 
                        }
 
401
                        FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
 
402
                        memcpy(data, residual, sizeof(residual[0])*data_len);
395
403
                        break;
396
404
                case 1:
397
 
                        for(i = 0; i < idata_len; i++) {
 
405
                        for(i = 0; i < idata_len; i++)
398
406
                                data[i] = residual[i] + data[i-1];
399
 
                        }
400
407
                        break;
401
408
                case 2:
402
 
                        for(i = 0; i < idata_len; i++) {
403
 
                                /* == residual[i] + 2*data[i-1] - data[i-2] */
 
409
                        for(i = 0; i < idata_len; i++)
 
410
#if 1 /* OPT: may be faster with some compilers on some systems */
404
411
                                data[i] = residual[i] + (data[i-1]<<1) - data[i-2];
405
 
                        }
 
412
#else
 
413
                                data[i] = residual[i] + 2*data[i-1] - data[i-2];
 
414
#endif
406
415
                        break;
407
416
                case 3:
408
 
                        for(i = 0; i < idata_len; i++) {
409
 
                                /* residual[i] + 3*data[i-1] - 3*data[i-2]) + data[i-3] */
 
417
                        for(i = 0; i < idata_len; i++)
 
418
#if 1 /* OPT: may be faster with some compilers on some systems */
410
419
                                data[i] = residual[i] + (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) + data[i-3];
411
 
                        }
 
420
#else
 
421
                                data[i] = residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3];
 
422
#endif
412
423
                        break;
413
424
                case 4:
414
 
                        for(i = 0; i < idata_len; i++) {
415
 
                                /* == residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4] */
 
425
                        for(i = 0; i < idata_len; i++)
 
426
#if 1 /* OPT: may be faster with some compilers on some systems */
416
427
                                data[i] = residual[i] + ((data[i-1]+data[i-3])<<2) - ((data[i-2]<<2) + (data[i-2]<<1)) - data[i-4];
417
 
                        }
 
428
#else
 
429
                                data[i] = residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4];
 
430
#endif
418
431
                        break;
419
432
                default:
420
433
                        FLAC__ASSERT(0);