intended for use by RealAudio 2.0 (28.8k) and G.728 decoders.
Unified · Split
| @@ -0,0 +1,65 @@ | |||
| 1 | /* | ||
| 2 | * G.728 / RealAudio 2.0 (28.8K) decoder | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | static void convolve(float *tgt, const float *src, int len, int n) | ||
| 22 | { | ||
| 23 | for (; n >= 0; n--) | ||
| 24 | tgt[n] = ff_scalarproduct_float_c(src, src - n, len); | ||
| 25 | |||
| 26 | } | ||
| 27 | |||
| 28 | /** | ||
| 29 | * Hybrid window filtering, see blocks 36 and 49 of the G.728 specification. | ||
| 30 | * | ||
| 31 | * @param order filter order | ||
| 32 | * @param n input length | ||
| 33 | * @param non_rec number of non-recursive samples | ||
| 34 | * @param out filter output | ||
| 35 | * @param hist pointer to the input history of the filter | ||
| 36 | * @param out pointer to the non-recursive part of the output | ||
| 37 | * @param out2 pointer to the recursive part of the output | ||
| 38 | * @param window pointer to the windowing function table | ||
| 39 | */ | ||
| 40 | static void do_hybrid_window(void (*vector_fmul)(float *dst, const float *src0, const float *src1, int len), | ||
| 41 | int order, int n, int non_rec, float *out, | ||
| 42 | float *hist, float *out2, const float *window) | ||
| 43 | { | ||
| 44 | int i; | ||
| 45 | float buffer1[MAX_BACKWARD_FILTER_ORDER + 1]; | ||
| 46 | float buffer2[MAX_BACKWARD_FILTER_ORDER + 1]; | ||
| 47 | LOCAL_ALIGNED(32, float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER + | ||
| 48 | MAX_BACKWARD_FILTER_LEN + | ||
| 49 | MAX_BACKWARD_FILTER_NONREC, 16)]); | ||
| 50 | |||
| 51 | av_assert2(order>=0); | ||
| 52 | |||
| 53 | vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16)); | ||
| 54 | |||
| 55 | convolve(buffer1, work + order , n , order); | ||
| 56 | convolve(buffer2, work + order + n, non_rec, order); | ||
| 57 | |||
| 58 | for (i=0; i <= order; i++) { | ||
| 59 | out2[i] = out2[i] * ATTEN + buffer1[i]; | ||
| 60 | out [i] = out2[i] + buffer2[i]; | ||
| 61 | } | ||
| 62 | |||
| 63 | /* Multiply by the white noise correcting factor (WNCF). */ | ||
| 64 | *out *= 257.0 / 256.0; | ||
| 65 | } | ||
| @@ -37,6 +37,8 @@ · 36 unmodified lines | |||
| 37 | #define MAX_BACKWARD_FILTER_ORDER 36 | 37 | #define MAX_BACKWARD_FILTER_ORDER 36 |
| 38 | #define MAX_BACKWARD_FILTER_LEN 40 | 38 | #define MAX_BACKWARD_FILTER_LEN 40 |
| 39 | #define MAX_BACKWARD_FILTER_NONREC 35 | 39 | #define MAX_BACKWARD_FILTER_NONREC 35 |
| 40 | #define ATTEN 0.5625 | ||
| 41 | #include "g728_template.c" | ||
| 40 | 42 | ||
| 41 | #define RA288_BLOCK_SIZE 5 | 43 | #define RA288_BLOCK_SIZE 5 |
| 42 | #define RA288_BLOCKS_PER_FRAME 32 | 44 | #define RA288_BLOCKS_PER_FRAME 32 |
| @@ -87,13 +89,6 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx) · 44 unmodified lines | |||
| 87 | return 0; | 89 | return 0; |
| 88 | } | 90 | } |
| 89 | 91 | ||
| 90 | static void convolve(float *tgt, const float *src, int len, int n) | ||
| 91 | { | ||
| 92 | for (; n >= 0; n--) | ||
| 93 | tgt[n] = ff_scalarproduct_float_c(src, src - n, len); | ||
| 94 | |||
| 95 | } | ||
| 96 | |||
| 97 | static void decode(RA288Context *ractx, float gain, int cb_coef) | 92 | static void decode(RA288Context *ractx, float gain, int cb_coef) |
| 98 | { | 93 | { |
| 99 | int i; | 94 | int i; |
| @@ -131,45 +126,6 @@ static void decode(RA288Context *ractx, float gain, int cb_coef) · 31 unmodified lines | |||
| 131 | ff_celp_lp_synthesis_filterf(block, ractx->sp_lpc, buffer, 5, 36); | 126 | ff_celp_lp_synthesis_filterf(block, ractx->sp_lpc, buffer, 5, 36); |
| 132 | } | 127 | } |
| 133 | 128 | ||
| 134 | /** | ||
| 135 | * Hybrid window filtering, see blocks 36 and 49 of the G.728 specification. | ||
| 136 | * | ||
| 137 | * @param order filter order | ||
| 138 | * @param n input length | ||
| 139 | * @param non_rec number of non-recursive samples | ||
| 140 | * @param out filter output | ||
| 141 | * @param hist pointer to the input history of the filter | ||
| 142 | * @param out pointer to the non-recursive part of the output | ||
| 143 | * @param out2 pointer to the recursive part of the output | ||
| 144 | * @param window pointer to the windowing function table | ||
| 145 | */ | ||
| 146 | static void do_hybrid_window(RA288Context *ractx, | ||
| 147 | int order, int n, int non_rec, float *out, | ||
| 148 | float *hist, float *out2, const float *window) | ||
| 149 | { | ||
| 150 | int i; | ||
| 151 | float buffer1[MAX_BACKWARD_FILTER_ORDER + 1]; | ||
| 152 | float buffer2[MAX_BACKWARD_FILTER_ORDER + 1]; | ||
| 153 | LOCAL_ALIGNED(32, float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER + | ||
| 154 | MAX_BACKWARD_FILTER_LEN + | ||
| 155 | MAX_BACKWARD_FILTER_NONREC, 16)]); | ||
| 156 | |||
| 157 | av_assert2(order>=0); | ||
| 158 | |||
| 159 | ractx->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16)); | ||
| 160 | |||
| 161 | convolve(buffer1, work + order , n , order); | ||
| 162 | convolve(buffer2, work + order + n, non_rec, order); | ||
| 163 | |||
| 164 | for (i=0; i <= order; i++) { | ||
| 165 | out2[i] = out2[i] * 0.5625 + buffer1[i]; | ||
| 166 | out [i] = out2[i] + buffer2[i]; | ||
| 167 | } | ||
| 168 | |||
| 169 | /* Multiply by the white noise correcting factor (WNCF). */ | ||
| 170 | *out *= 257.0 / 256.0; | ||
| 171 | } | ||
| 172 | |||
| 173 | /** | 129 | /** |
| 174 | * Backward synthesis filter, find the LPC coefficients from past speech data. | 130 | * Backward synthesis filter, find the LPC coefficients from past speech data. |
| 175 | */ | 131 | */ |
| @@ -180,7 +136,7 @@ static void backward_filter(RA288Context *ractx, · 4 unmodified lines | |||
| 180 | { | 136 | { |
| 181 | float temp[MAX_BACKWARD_FILTER_ORDER+1]; | 137 | float temp[MAX_BACKWARD_FILTER_ORDER+1]; |
| 182 | 138 | ||
| 183 | do_hybrid_window(ractx, order, n, non_rec, temp, hist, rec, window); | 139 | do_hybrid_window(ractx->vector_fmul, order, n, non_rec, temp, hist, rec, window); |
| 184 | 140 | ||
| 185 | if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1)) | 141 | if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1)) |
| 186 | ractx->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16)); | 142 | ractx->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16)); |