Mercurial > libavcodec.hg
annotate ra288.c @ 7424:69766900be2d libavcodec
Initialize outputed_poc to INT_MIN at decoder initialization.
Fixes issue 560
author | heydowns |
---|---|
date | Sun, 27 Jul 2008 13:49:04 +0000 |
parents | 175c2c4d6887 |
children | ed615bbf4f8d |
rev | line source |
---|---|
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
1 /* |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
2 * RealAudio 2.0 (28.8K) |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
3 * Copyright (c) 2003 the ffmpeg project |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
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:
3036
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
16 * |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
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:
3036
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
20 */ |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
21 |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
22 #include "avcodec.h" |
7171 | 23 #define ALT_BITSTREAM_READER_LE |
24 #include "bitstream.h" | |
1335
b4a72edb3a71
moved the tables into header files (and applied the 'static' patch). Nick: why do you like mergeing tables and code into one file, so making it unusable big?
al3x
parents:
1316
diff
changeset
|
25 #include "ra288.h" |
2967 | 26 |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
27 typedef struct { |
7167 | 28 float history[8]; |
29 float output[40]; | |
30 float pr1[36]; | |
31 float pr2[10]; | |
7213 | 32 int phase; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
33 |
7418
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
34 float sp_hist[111]; ///< Speech data history (spec: SB) |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
35 |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
36 /** Speech part of the gain autocorrelation (spec: REXP) */ |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
37 float sp_rec[37]; |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
38 |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
39 float gain_hist[38]; ///< Log-gain history (spec: SBLG) |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
40 |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
41 /** Recursive part of the gain autocorrelation (spec: REXPLG) */ |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
42 float gain_rec[11]; |
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
43 |
7167 | 44 float sb[41]; |
45 float lhist[10]; | |
7411
d41948bf80a1
Give the context structure of ra288 a better name: s/Real288_internal/RA288Context/
vitor
parents:
7375
diff
changeset
|
46 } RA288Context; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
47 |
7294 | 48 static inline float scalar_product_float(const float * v1, const float * v2, |
49 int size) | |
7201
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
50 { |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
51 float res = 0.; |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
52 |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
53 while (size--) |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
54 res += *v1++ * *v2++; |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
55 |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
56 return res; |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
57 } |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
58 |
7415
649496faa1d2
Move colmult() function to the beginning of file to group DSP-related functions.
vitor
parents:
7414
diff
changeset
|
59 static void colmult(float *tgt, const float *m1, const float *m2, int n) |
649496faa1d2
Move colmult() function to the beginning of file to group DSP-related functions.
vitor
parents:
7414
diff
changeset
|
60 { |
649496faa1d2
Move colmult() function to the beginning of file to group DSP-related functions.
vitor
parents:
7414
diff
changeset
|
61 while (n--) |
7416 | 62 *tgt++ = *m1++ * *m2++; |
7415
649496faa1d2
Move colmult() function to the beginning of file to group DSP-related functions.
vitor
parents:
7414
diff
changeset
|
63 } |
649496faa1d2
Move colmult() function to the beginning of file to group DSP-related functions.
vitor
parents:
7414
diff
changeset
|
64 |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
65 /* Decode and produce output */ |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
66 static void decode(RA288Context *ractx, float gain, int cb_coef) |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
67 { |
7195
5e5c1178ae9a
Write for loops in a more standard way. In my opinion, they are much more readable now.
vitor
parents:
7193
diff
changeset
|
68 int x, y; |
7268
7e51fc7805ac
Do not declare as double a var that only stores a float
vitor
parents:
7267
diff
changeset
|
69 double sumsum; |
7e51fc7805ac
Do not declare as double a var that only stores a float
vitor
parents:
7267
diff
changeset
|
70 float sum, buffer[5]; |
7167 | 71 |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
72 memmove(ractx->sb + 5, ractx->sb, 36 * sizeof(*ractx->sb)); |
7167 | 73 |
7202 | 74 for (x=4; x >= 0; x--) |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
75 ractx->sb[x] = -scalar_product_float(ractx->sb + x + 1, ractx->pr1, 36); |
7167 | 76 |
77 /* convert log and do rms */ | |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
78 sum = 32. - scalar_product_float(ractx->pr2, ractx->lhist, 10); |
7167 | 79 |
7269 | 80 sum = av_clipf(sum, 0, 60); |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
81 |
7192 | 82 sumsum = exp(sum * 0.1151292546497) * gain; /* pow(10.0,sum/20)*f */ |
7167 | 83 |
7210 | 84 for (x=0; x < 5; x++) |
7191 | 85 buffer[x] = codetable[cb_coef][x] * sumsum; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
86 |
7275 | 87 sum = scalar_product_float(buffer, buffer, 5) / 5; |
88 | |
89 sum = FFMAX(sum, 1); | |
7167 | 90 |
91 /* shift and store */ | |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
92 memmove(ractx->lhist, ractx->lhist - 1, 10 * sizeof(*ractx->lhist)); |
7167 | 93 |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
94 *ractx->lhist = ractx->history[ractx->phase] = 10 * log10(sum) - 32; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
95 |
7167 | 96 for (x=1; x < 5; x++) |
7195
5e5c1178ae9a
Write for loops in a more standard way. In my opinion, they are much more readable now.
vitor
parents:
7193
diff
changeset
|
97 for (y=x-1; y >= 0; y--) |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
98 buffer[x] -= ractx->pr1[x-y-1] * buffer[y]; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
99 |
7167 | 100 /* output */ |
101 for (x=0; x < 5; x++) { | |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
102 ractx->output[ractx->phase*5+x] = ractx->sb[4-x] = |
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
103 av_clipf(ractx->sb[4-x] + buffer[x], -4095, 4095); |
7167 | 104 } |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
105 } |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
106 |
7369
b0d8a3985f96
Rename pred() to eval_lpc_coeffs() and add a doxy comment
vitor
parents:
7368
diff
changeset
|
107 /** |
b0d8a3985f96
Rename pred() to eval_lpc_coeffs() and add a doxy comment
vitor
parents:
7368
diff
changeset
|
108 * Converts autocorrelation coefficients to LPC coefficients using the |
b0d8a3985f96
Rename pred() to eval_lpc_coeffs() and add a doxy comment
vitor
parents:
7368
diff
changeset
|
109 * Levinson-Durbin algorithm. See blocks 37 and 50 of the G.728 specification. |
b0d8a3985f96
Rename pred() to eval_lpc_coeffs() and add a doxy comment
vitor
parents:
7368
diff
changeset
|
110 * |
7370
61df1ddb1001
Follow FFmpeg convention of returning negative values on error in eval_lpc_coeffs()
vitor
parents:
7369
diff
changeset
|
111 * @return 0 if success, -1 if fail |
7369
b0d8a3985f96
Rename pred() to eval_lpc_coeffs() and add a doxy comment
vitor
parents:
7368
diff
changeset
|
112 */ |
b0d8a3985f96
Rename pred() to eval_lpc_coeffs() and add a doxy comment
vitor
parents:
7368
diff
changeset
|
113 static int eval_lpc_coeffs(const float *in, float *tgt, int n) |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
114 { |
7167 | 115 int x, y; |
116 double f0, f1, f2; | |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
117 |
7167 | 118 if (in[n] == 0) |
7370
61df1ddb1001
Follow FFmpeg convention of returning negative values on error in eval_lpc_coeffs()
vitor
parents:
7369
diff
changeset
|
119 return -1; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
120 |
7167 | 121 if ((f0 = *in) <= 0) |
7370
61df1ddb1001
Follow FFmpeg convention of returning negative values on error in eval_lpc_coeffs()
vitor
parents:
7369
diff
changeset
|
122 return -1; |
7167 | 123 |
7296 | 124 in--; // To avoid a -1 subtraction in the inner loop |
125 | |
7295 | 126 for (x=1; x <= n; x++) { |
7296 | 127 f1 = in[x+1]; |
7195
5e5c1178ae9a
Write for loops in a more standard way. In my opinion, they are much more readable now.
vitor
parents:
7193
diff
changeset
|
128 |
5e5c1178ae9a
Write for loops in a more standard way. In my opinion, they are much more readable now.
vitor
parents:
7193
diff
changeset
|
129 for (y=0; y < x - 1; y++) |
7296 | 130 f1 += in[x-y]*tgt[y]; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
131 |
7299 | 132 tgt[x-1] = f2 = -f1/f0; |
133 for (y=0; y < x >> 1; y++) { | |
134 float temp = tgt[y] + tgt[x-y-2]*f2; | |
135 tgt[x-y-2] += tgt[y]*f2; | |
136 tgt[y] = temp; | |
7167 | 137 } |
138 if ((f0 += f1*f2) < 0) | |
7370
61df1ddb1001
Follow FFmpeg convention of returning negative values on error in eval_lpc_coeffs()
vitor
parents:
7369
diff
changeset
|
139 return -1; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
140 } |
7295 | 141 |
7370
61df1ddb1001
Follow FFmpeg convention of returning negative values on error in eval_lpc_coeffs()
vitor
parents:
7369
diff
changeset
|
142 return 0; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
143 } |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
144 |
7294 | 145 static void prodsum(float *tgt, const float *src, int len, int n) |
7169 | 146 { |
7201
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
147 for (; n >= 0; n--) |
4d441356fa23
Create a function for float dot product instead of duplicating all over the file
vitor
parents:
7195
diff
changeset
|
148 tgt[n] = scalar_product_float(src, src - n, len); |
7169 | 149 |
150 } | |
151 | |
7367 | 152 /** |
153 * Hybrid window filtering. See blocks 36 and 49 of the G.728 specification. | |
154 * | |
155 * @param order the order of the filter | |
156 * @param n the length of the input | |
7375 | 157 * @param non_rec the number of non-recursive samples |
7367 | 158 * @param out the filter output |
159 * @param in pointer to the input of the filter | |
160 * @param hist pointer to the input history of the filter. It is updated by | |
161 * this function. | |
7375 | 162 * @param out pointer to the non-recursive part of the output |
7367 | 163 * @param out2 pointer to the recursive part of the output |
164 * @param window pointer to the windowing function table | |
165 */ | |
7366
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
166 static void do_hybrid_window(int order, int n, int non_rec, const float *in, |
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
167 float *out, float *hist, float *out2, |
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
168 const float *window) |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
169 { |
7167 | 170 unsigned int x; |
171 float buffer1[37]; | |
172 float buffer2[37]; | |
173 float work[111]; | |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
174 |
7367 | 175 /* update history */ |
7366
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
176 memmove(hist , hist + n, (order + non_rec)*sizeof(*hist)); |
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
177 memcpy (hist + order + non_rec, in , n *sizeof(*hist)); |
7363
d346c4da00bd
Simplify co(), use memcpy/memmove and colmult() when useful.
vitor
parents:
7322
diff
changeset
|
178 |
7366
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
179 colmult(work, window, hist, order + n + non_rec); |
2967 | 180 |
7366
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
181 prodsum(buffer1, work + order , n , order); |
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
182 prodsum(buffer2, work + order + n, non_rec, order); |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
183 |
7366
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
184 for (x=0; x <= order; x++) { |
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
185 out2[x] = out2[x] * 0.5625 + buffer1[x]; |
d74804a3a18b
Give parameters of do_hybrid_window() more meaningful names
vitor
parents:
7365
diff
changeset
|
186 out [x] = out2[x] + buffer2[x]; |
7167 | 187 } |
7365
031d4866b192
Rename co() function to the much more descriptive name of
vitor
parents:
7364
diff
changeset
|
188 |
031d4866b192
Rename co() function to the much more descriptive name of
vitor
parents:
7364
diff
changeset
|
189 /* Multiply by the white noise correcting factor (WNCF) */ |
031d4866b192
Rename co() function to the much more descriptive name of
vitor
parents:
7364
diff
changeset
|
190 *out *= 257./256.; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
191 } |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
192 |
7372
e97d0795ee70
Rename update() function to backward_filter() and add a doxy comment
vitor
parents:
7371
diff
changeset
|
193 /** |
e97d0795ee70
Rename update() function to backward_filter() and add a doxy comment
vitor
parents:
7371
diff
changeset
|
194 * Backward synthesis filter. Find the LPC coefficients from past speech data. |
e97d0795ee70
Rename update() function to backward_filter() and add a doxy comment
vitor
parents:
7371
diff
changeset
|
195 */ |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
196 static void backward_filter(RA288Context *ractx) |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
197 { |
7169 | 198 float buffer1[40], temp1[37]; |
199 float buffer2[8], temp2[11]; | |
7419
175c2c4d6887
Remove st1 and st2 variables from context, since they could be just local vars
vitor
parents:
7418
diff
changeset
|
200 float st1[37]; |
175c2c4d6887
Remove st1 and st2 variables from context, since they could be just local vars
vitor
parents:
7418
diff
changeset
|
201 float st2[11]; |
7169 | 202 |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
203 memcpy(buffer1 , ractx->output + 20, 20*sizeof(*buffer1)); |
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
204 memcpy(buffer1 + 20, ractx->output , 20*sizeof(*buffer1)); |
7169 | 205 |
7418
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
206 do_hybrid_window(36, 40, 35, buffer1, temp1, ractx->sp_hist, ractx->sp_rec, |
7368 | 207 syn_window); |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
208 |
7419
175c2c4d6887
Remove st1 and st2 variables from context, since they could be just local vars
vitor
parents:
7418
diff
changeset
|
209 if (!eval_lpc_coeffs(temp1, st1, 36)) |
175c2c4d6887
Remove st1 and st2 variables from context, since they could be just local vars
vitor
parents:
7418
diff
changeset
|
210 colmult(ractx->pr1, st1, syn_bw_tab, 36); |
7169 | 211 |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
212 memcpy(buffer2 , ractx->history + 4, 4*sizeof(*buffer2)); |
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
213 memcpy(buffer2 + 4, ractx->history , 4*sizeof(*buffer2)); |
7169 | 214 |
7418
83d005a098b5
Rename st{1,2}{a,b} context variables to more meaningful names: {sp,gain}_{rec,hist}
vitor
parents:
7416
diff
changeset
|
215 do_hybrid_window(10, 8, 20, buffer2, temp2, ractx->gain_hist, ractx->gain_rec, |
7368 | 216 gain_window); |
7169 | 217 |
7419
175c2c4d6887
Remove st1 and st2 variables from context, since they could be just local vars
vitor
parents:
7418
diff
changeset
|
218 if (!eval_lpc_coeffs(temp2, st2, 10)) |
175c2c4d6887
Remove st1 and st2 variables from context, since they could be just local vars
vitor
parents:
7418
diff
changeset
|
219 colmult(ractx->pr2, st2, gain_bw_tab, 10); |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
220 } |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
221 |
7174 | 222 /* Decode a block (celp) */ |
223 static int ra288_decode_frame(AVCodecContext * avctx, void *data, | |
224 int *data_size, const uint8_t * buf, | |
225 int buf_size) | |
1313 | 226 { |
7174 | 227 int16_t *out = data; |
7167 | 228 int x, y; |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
229 RA288Context *ractx = avctx->priv_data; |
7173
bc2fd265f52b
Remove unpack() function, read the bitstream as needed
vitor
parents:
7172
diff
changeset
|
230 GetBitContext gb; |
7167 | 231 |
7174 | 232 if (buf_size < avctx->block_align) { |
233 av_log(avctx, AV_LOG_ERROR, | |
234 "Error! Input buffer is too small [%d<%d]\n", | |
235 buf_size, avctx->block_align); | |
236 return 0; | |
237 } | |
238 | |
239 init_get_bits(&gb, buf, avctx->block_align * 8); | |
1313 | 240 |
7167 | 241 for (x=0; x < 32; x++) { |
7192 | 242 float gain = amptable[get_bits(&gb, 3)]; |
7173
bc2fd265f52b
Remove unpack() function, read the bitstream as needed
vitor
parents:
7172
diff
changeset
|
243 int cb_coef = get_bits(&gb, 6 + (x&1)); |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
244 ractx->phase = x & 7; |
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
245 decode(ractx, gain, cb_coef); |
7167 | 246 |
7195
5e5c1178ae9a
Write for loops in a more standard way. In my opinion, they are much more readable now.
vitor
parents:
7193
diff
changeset
|
247 for (y=0; y < 5; y++) |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
248 *(out++) = 8 * ractx->output[ractx->phase*5 + y]; |
7167 | 249 |
7412
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
250 if (ractx->phase == 3) |
51da3d8200d0
Give the context variables of ra288 a better name: s/glob/ractx/
vitor
parents:
7411
diff
changeset
|
251 backward_filter(ractx); |
7167 | 252 } |
253 | |
7174 | 254 *data_size = (char *)out - (char *)data; |
2956
5f51b1e0bed6
Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents:
2288
diff
changeset
|
255 return avctx->block_align; |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
256 } |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
257 |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
258 AVCodec ra_288_decoder = |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
259 { |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
260 "real_288", |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
261 CODEC_TYPE_AUDIO, |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
262 CODEC_ID_RA_288, |
7411
d41948bf80a1
Give the context structure of ra288 a better name: s/Real288_internal/RA288Context/
vitor
parents:
7375
diff
changeset
|
263 sizeof(RA288Context), |
7168 | 264 NULL, |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
265 NULL, |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
266 NULL, |
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
267 ra288_decode_frame, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6712
diff
changeset
|
268 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"), |
1304
e8543aab0cc9
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq (originally from public domain player for Amiga
nickols_k
parents:
diff
changeset
|
269 }; |