Mercurial > libavcodec.hg
annotate lpc.h @ 11352:6e0af2cfdcfe libavcodec
Do MC and IDCT in coding (hilbert) order
This increases the slice size to 64 pixels, due to having to decode an
entire chroma superblock row per slice.
This can be up to 6% slower depending on clip and CPU, but is necessary
for future optimizations that gain significantly more than was lost.
author | conrad |
---|---|
date | Wed, 03 Mar 2010 23:27:40 +0000 |
parents | da7996a575f3 |
children | 84963c795459 |
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 | 22 #ifndef AVCODEC_LPC_H |
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 | 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 | 43 const int32_t *samples, int blocksize, int min_order, |
44 int max_order, int precision, | |
45 int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc, | |
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 |
7788
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
48 #ifdef LPC_USE_DOUBLE |
7791 | 49 #define LPC_TYPE double |
7788
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
50 #else |
7791 | 51 #define LPC_TYPE float |
7788
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
52 #endif |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
53 |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
54 /** |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
55 * Levinson-Durbin recursion. |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
56 * 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
|
57 */ |
7791 | 58 static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, |
59 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
|
60 int normalize) |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
61 { |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
62 int i, j; |
7791 | 63 LPC_TYPE err; |
64 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
|
65 |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
66 if (normalize) |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
67 err = *autoc++; |
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 (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
|
70 return -1; |
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 for(i=0; i<max_order; i++) { |
7791 | 73 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
|
74 |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
75 if (normalize) { |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
76 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
|
77 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
|
78 |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
79 r /= err; |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
80 err *= 1.0 - (r * r); |
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 |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
83 lpc[i] = 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 for(j=0; j < (i+1)>>1; j++) { |
7791 | 86 LPC_TYPE f = lpc_last[ j]; |
87 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
|
88 lpc[ j] = f + r * b; |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
89 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
|
90 } |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
91 |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
92 if (fail && err < 0) |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
93 return -1; |
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 lpc_last = lpc; |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
96 lpc += lpc_stride; |
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 |
ffd4b1364b62
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
vitor
parents:
7760
diff
changeset
|
99 return 0; |
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 |
7760 | 102 #endif /* AVCODEC_LPC_H */ |