annotate lpc.h @ 11927:156f5d24e0a3 libavcodec

Remove beosthreads support Relevant BeOS variants support pthreads, so there is no need to maintain the beos-native threads interface.
author mru
date Tue, 22 Jun 2010 23:18:13 +0000
parents 84963c795459
children fdafbcef52f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
1 /**
7589
8b695a99e8df flacenc, lpc: Move LPC code from flacenc.c to new lpc.[ch] files.
ramiro
parents: 7588
diff changeset
2 * LPC utility code
7594
cd6217c9ce92 update my email address to one which does not depend on my service provider
jbr
parents: 7592
diff changeset
3 * Copyright (c) 2006 Justin Ruggles <justin.ruggles@gmail.com>
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3481
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3481
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3481
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3481
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3481
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
15 * Lesser General Public License for more details.
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
16 *
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3481
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
20 */
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
21
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7602
diff changeset
22 #ifndef AVCODEC_LPC_H
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7602
diff changeset
23 #define AVCODEC_LPC_H
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
24
7602
a8a999207b1a Add missing header includes to fix 'make checkheaders'.
diego
parents: 7594
diff changeset
25 #include <stdint.h>
a8a999207b1a Add missing header includes to fix 'make checkheaders'.
diego
parents: 7594
diff changeset
26 #include "dsputil.h"
3353
5b901881d6ed first rudimentary version of (Justin Ruggles jruggle earthlink net) flac encoder
michael
parents:
diff changeset
27
3385
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
28 #define ORDER_METHOD_EST 0
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
29 #define ORDER_METHOD_2LEVEL 1
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
30 #define ORDER_METHOD_4LEVEL 2
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
31 #define ORDER_METHOD_8LEVEL 3
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
32 #define ORDER_METHOD_SEARCH 4
3478
5a71102c2770 log prediction order search method
michael
parents: 3477
diff changeset
33 #define ORDER_METHOD_LOG 5
3385
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
34
7590
d6126c8b57e9 lpc: cosmetics: vertically align declarations and definitions.
ramiro
parents: 7589
diff changeset
35 #define MIN_LPC_ORDER 1
d6126c8b57e9 lpc: cosmetics: vertically align declarations and definitions.
ramiro
parents: 7589
diff changeset
36 #define MAX_LPC_ORDER 32
3385
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
37
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
38
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
39 /**
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
40 * Calculate LPC coefficients for multiple orders
340e5d35b326 flac-lpc patch by (Justin Ruggles jruggle earthlink net)
michael
parents: 3384
diff changeset
41 */
7589
8b695a99e8df flacenc, lpc: Move LPC code from flacenc.c to new lpc.[ch] files.
ramiro
parents: 7588
diff changeset
42 int ff_lpc_calc_coefs(DSPContext *s,
7592
377fddcc6288 cosmetics: adjust line breaks and vertical alignment
jbr
parents: 7591
diff changeset
43 const int32_t *samples, int blocksize, int min_order,
377fddcc6288 cosmetics: adjust line breaks and vertical alignment
jbr
parents: 7591
diff changeset
44 int max_order, int precision,
377fddcc6288 cosmetics: adjust line breaks and vertical alignment
jbr
parents: 7591
diff changeset
45 int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
377fddcc6288 cosmetics: adjust line breaks and vertical alignment
jbr
parents: 7591
diff changeset
46 int omethod, int max_shift, int zero_shift);
3365
84f29207af3a flacenc - rice param search patch by (Justin Ruggles jruggle earthlink net
michael
parents: 3358
diff changeset
47
11375
84963c795459 Move some prototypes from dsputil.c to reasonable header files
mru
parents: 7791
diff changeset
48 void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
84963c795459 Move some prototypes from dsputil.c to reasonable header files
mru
parents: 7791
diff changeset
49 double *autoc);
84963c795459 Move some prototypes from dsputil.c to reasonable header files
mru
parents: 7791
diff changeset
50
7788
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
51 #ifdef LPC_USE_DOUBLE
7791
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
52 #define LPC_TYPE double
7788
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
53 #else
7791
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
54 #define LPC_TYPE float
7788
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
55 #endif
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
56
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
57 /**
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
58 * Levinson-Durbin recursion.
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
59 * Produces LPC coefficients from autocorrelation data.
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
60 */
7791
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
61 static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
62 LPC_TYPE *lpc, int lpc_stride, int fail,
7788
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
63 int normalize)
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
64 {
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
65 int i, j;
7791
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
66 LPC_TYPE err;
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
67 LPC_TYPE *lpc_last = lpc;
7788
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
68
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
69 if (normalize)
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
70 err = *autoc++;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
71
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
72 if (fail && (autoc[max_order - 1] == 0 || err <= 0))
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
73 return -1;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
74
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
75 for(i=0; i<max_order; i++) {
7791
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
76 LPC_TYPE r = -autoc[i];
7788
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
77
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
78 if (normalize) {
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
79 for(j=0; j<i; j++)
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
80 r -= lpc_last[j] * autoc[i-j-1];
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
81
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
82 r /= err;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
83 err *= 1.0 - (r * r);
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
84 }
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
85
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
86 lpc[i] = r;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
87
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
88 for(j=0; j < (i+1)>>1; j++) {
7791
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
89 LPC_TYPE f = lpc_last[ j];
da7996a575f3 Cosmetics: s/LPC_type/LPC_TYPE/
vitor
parents: 7788
diff changeset
90 LPC_TYPE b = lpc_last[i-1-j];
7788
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
91 lpc[ j] = f + r * b;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
92 lpc[i-1-j] = b + r * f;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
93 }
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
94
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
95 if (fail && err < 0)
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
96 return -1;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
97
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
98 lpc_last = lpc;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
99 lpc += lpc_stride;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
100 }
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
101
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
102 return 0;
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
103 }
ffd4b1364b62 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents: 7760
diff changeset
104
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 7602
diff changeset
105 #endif /* AVCODEC_LPC_H */