| OLD | NEW |
| 1 /* Copyright (c) 2007-2008 CSIRO | 1 /* Copyright (c) 2007-2008 CSIRO |
| 2 Copyright (c) 2007-2010 Xiph.Org Foundation | 2 Copyright (c) 2007-2010 Xiph.Org Foundation |
| 3 Copyright (c) 2008 Gregory Maxwell | 3 Copyright (c) 2008 Gregory Maxwell |
| 4 Written by Jean-Marc Valin and Gregory Maxwell */ | 4 Written by Jean-Marc Valin and Gregory Maxwell */ |
| 5 /* | 5 /* |
| 6 Redistribution and use in source and binary forms, with or without | 6 Redistribution and use in source and binary forms, with or without |
| 7 modification, are permitted provided that the following conditions | 7 modification, are permitted provided that the following conditions |
| 8 are met: | 8 are met: |
| 9 | 9 |
| 10 - Redistributions of source code must retain the above copyright | 10 - Redistributions of source code must retain the above copyright |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "mathops.h" | 47 #include "mathops.h" |
| 48 #include "float_cast.h" | 48 #include "float_cast.h" |
| 49 #include <stdarg.h> | 49 #include <stdarg.h> |
| 50 #include "celt_lpc.h" | 50 #include "celt_lpc.h" |
| 51 #include "vq.h" | 51 #include "vq.h" |
| 52 | 52 |
| 53 #ifndef PACKAGE_VERSION | 53 #ifndef PACKAGE_VERSION |
| 54 #define PACKAGE_VERSION "unknown" | 54 #define PACKAGE_VERSION "unknown" |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 #if defined(MIPSr1_ASM) |
| 58 #include "mips/celt_mipsr1.h" |
| 59 #endif |
| 60 |
| 57 | 61 |
| 58 int resampling_factor(opus_int32 rate) | 62 int resampling_factor(opus_int32 rate) |
| 59 { | 63 { |
| 60 int ret; | 64 int ret; |
| 61 switch (rate) | 65 switch (rate) |
| 62 { | 66 { |
| 63 case 48000: | 67 case 48000: |
| 64 ret = 1; | 68 ret = 1; |
| 65 break; | 69 break; |
| 66 case 24000: | 70 case 24000: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 79 #ifndef CUSTOM_MODES | 83 #ifndef CUSTOM_MODES |
| 80 celt_assert(0); | 84 celt_assert(0); |
| 81 #endif | 85 #endif |
| 82 ret = 0; | 86 ret = 0; |
| 83 break; | 87 break; |
| 84 } | 88 } |
| 85 return ret; | 89 return ret; |
| 86 } | 90 } |
| 87 | 91 |
| 88 #ifndef OVERRIDE_COMB_FILTER_CONST | 92 #ifndef OVERRIDE_COMB_FILTER_CONST |
| 93 /* This version should be faster on ARM */ |
| 94 #ifdef OPUS_ARM_ASM |
| 89 static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | 95 static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, |
| 90 opus_val16 g10, opus_val16 g11, opus_val16 g12) | 96 opus_val16 g10, opus_val16 g11, opus_val16 g12) |
| 91 { | 97 { |
| 98 opus_val32 x0, x1, x2, x3, x4; |
| 99 int i; |
| 100 x4 = SHL32(x[-T-2], 1); |
| 101 x3 = SHL32(x[-T-1], 1); |
| 102 x2 = SHL32(x[-T], 1); |
| 103 x1 = SHL32(x[-T+1], 1); |
| 104 for (i=0;i<N-4;i+=5) |
| 105 { |
| 106 opus_val32 t; |
| 107 x0=SHL32(x[i-T+2],1); |
| 108 t = MAC16_32_Q16(x[i], g10, x2); |
| 109 t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); |
| 110 t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); |
| 111 y[i] = t; |
| 112 x4=SHL32(x[i-T+3],1); |
| 113 t = MAC16_32_Q16(x[i+1], g10, x1); |
| 114 t = MAC16_32_Q16(t, g11, ADD32(x0,x2)); |
| 115 t = MAC16_32_Q16(t, g12, ADD32(x4,x3)); |
| 116 y[i+1] = t; |
| 117 x3=SHL32(x[i-T+4],1); |
| 118 t = MAC16_32_Q16(x[i+2], g10, x0); |
| 119 t = MAC16_32_Q16(t, g11, ADD32(x4,x1)); |
| 120 t = MAC16_32_Q16(t, g12, ADD32(x3,x2)); |
| 121 y[i+2] = t; |
| 122 x2=SHL32(x[i-T+5],1); |
| 123 t = MAC16_32_Q16(x[i+3], g10, x4); |
| 124 t = MAC16_32_Q16(t, g11, ADD32(x3,x0)); |
| 125 t = MAC16_32_Q16(t, g12, ADD32(x2,x1)); |
| 126 y[i+3] = t; |
| 127 x1=SHL32(x[i-T+6],1); |
| 128 t = MAC16_32_Q16(x[i+4], g10, x3); |
| 129 t = MAC16_32_Q16(t, g11, ADD32(x2,x4)); |
| 130 t = MAC16_32_Q16(t, g12, ADD32(x1,x0)); |
| 131 y[i+4] = t; |
| 132 } |
| 133 #ifdef CUSTOM_MODES |
| 134 for (;i<N;i++) |
| 135 { |
| 136 opus_val32 t; |
| 137 x0=SHL32(x[i-T+2],1); |
| 138 t = MAC16_32_Q16(x[i], g10, x2); |
| 139 t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); |
| 140 t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); |
| 141 y[i] = t; |
| 142 x4=x3; |
| 143 x3=x2; |
| 144 x2=x1; |
| 145 x1=x0; |
| 146 } |
| 147 #endif |
| 148 } |
| 149 #else |
| 150 static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, |
| 151 opus_val16 g10, opus_val16 g11, opus_val16 g12) |
| 152 { |
| 92 opus_val32 x0, x1, x2, x3, x4; | 153 opus_val32 x0, x1, x2, x3, x4; |
| 93 int i; | 154 int i; |
| 94 x4 = x[-T-2]; | 155 x4 = x[-T-2]; |
| 95 x3 = x[-T-1]; | 156 x3 = x[-T-1]; |
| 96 x2 = x[-T]; | 157 x2 = x[-T]; |
| 97 x1 = x[-T+1]; | 158 x1 = x[-T+1]; |
| 98 for (i=0;i<N;i++) | 159 for (i=0;i<N;i++) |
| 99 { | 160 { |
| 100 x0=x[i-T+2]; | 161 x0=x[i-T+2]; |
| 101 y[i] = x[i] | 162 y[i] = x[i] |
| 102 + MULT16_32_Q15(g10,x2) | 163 + MULT16_32_Q15(g10,x2) |
| 103 + MULT16_32_Q15(g11,ADD32(x1,x3)) | 164 + MULT16_32_Q15(g11,ADD32(x1,x3)) |
| 104 + MULT16_32_Q15(g12,ADD32(x0,x4)); | 165 + MULT16_32_Q15(g12,ADD32(x0,x4)); |
| 105 x4=x3; | 166 x4=x3; |
| 106 x3=x2; | 167 x3=x2; |
| 107 x2=x1; | 168 x2=x1; |
| 108 x1=x0; | 169 x1=x0; |
| 109 } | 170 } |
| 110 | 171 |
| 111 } | 172 } |
| 112 #endif | 173 #endif |
| 174 #endif |
| 113 | 175 |
| 176 #ifndef OVERRIDE_comb_filter |
| 114 void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, | 177 void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, |
| 115 opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, | 178 opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, |
| 116 const opus_val16 *window, int overlap) | 179 const opus_val16 *window, int overlap) |
| 117 { | 180 { |
| 118 int i; | 181 int i; |
| 119 /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ | 182 /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ |
| 120 opus_val16 g00, g01, g02, g10, g11, g12; | 183 opus_val16 g00, g01, g02, g10, g11, g12; |
| 121 opus_val32 x0, x1, x2, x3, x4; | 184 opus_val32 x0, x1, x2, x3, x4; |
| 122 static const opus_val16 gains[3][3] = { | 185 static const opus_val16 gains[3][3] = { |
| 123 {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1
296386719f, 15)}, | 186 {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1
296386719f, 15)}, |
| 124 {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f
, 15)}, | 187 {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f
, 15)}, |
| 125 {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f
, 15)}}; | 188 {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f
, 15)}}; |
| 126 | 189 |
| 127 if (g0==0 && g1==0) | 190 if (g0==0 && g1==0) |
| 128 { | 191 { |
| 129 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr
ent encoder already copies x to y */ | 192 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr
ent encoder already copies x to y */ |
| 130 if (x!=y) | 193 if (x!=y) |
| 131 OPUS_MOVE(y, x, N); | 194 OPUS_MOVE(y, x, N); |
| 132 return; | 195 return; |
| 133 } | 196 } |
| 134 g00 = MULT16_16_Q15(g0, gains[tapset0][0]); | 197 g00 = MULT16_16_P15(g0, gains[tapset0][0]); |
| 135 g01 = MULT16_16_Q15(g0, gains[tapset0][1]); | 198 g01 = MULT16_16_P15(g0, gains[tapset0][1]); |
| 136 g02 = MULT16_16_Q15(g0, gains[tapset0][2]); | 199 g02 = MULT16_16_P15(g0, gains[tapset0][2]); |
| 137 g10 = MULT16_16_Q15(g1, gains[tapset1][0]); | 200 g10 = MULT16_16_P15(g1, gains[tapset1][0]); |
| 138 g11 = MULT16_16_Q15(g1, gains[tapset1][1]); | 201 g11 = MULT16_16_P15(g1, gains[tapset1][1]); |
| 139 g12 = MULT16_16_Q15(g1, gains[tapset1][2]); | 202 g12 = MULT16_16_P15(g1, gains[tapset1][2]); |
| 140 x1 = x[-T1+1]; | 203 x1 = x[-T1+1]; |
| 141 x2 = x[-T1 ]; | 204 x2 = x[-T1 ]; |
| 142 x3 = x[-T1-1]; | 205 x3 = x[-T1-1]; |
| 143 x4 = x[-T1-2]; | 206 x4 = x[-T1-2]; |
| 207 /* If the filter didn't change, we don't need the overlap */ |
| 208 if (g0==g1 && T0==T1 && tapset0==tapset1) |
| 209 overlap=0; |
| 144 for (i=0;i<overlap;i++) | 210 for (i=0;i<overlap;i++) |
| 145 { | 211 { |
| 146 opus_val16 f; | 212 opus_val16 f; |
| 147 x0=x[i-T1+2]; | 213 x0=x[i-T1+2]; |
| 148 f = MULT16_16_Q15(window[i],window[i]); | 214 f = MULT16_16_Q15(window[i],window[i]); |
| 149 y[i] = x[i] | 215 y[i] = x[i] |
| 150 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g00),x[i-T0]) | 216 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g00),x[i-T0]) |
| 151 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g01),ADD32(x[i-T0+1],x[i
-T0-1])) | 217 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g01),ADD32(x[i-T0+1],x[i
-T0-1])) |
| 152 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g02),ADD32(x[i-T0+2],x[i
-T0-2])) | 218 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g02),ADD32(x[i-T0+2],x[i
-T0-2])) |
| 153 + MULT16_32_Q15(MULT16_16_Q15(f,g10),x2) | 219 + MULT16_32_Q15(MULT16_16_Q15(f,g10),x2) |
| 154 + MULT16_32_Q15(MULT16_16_Q15(f,g11),ADD32(x1,x3)) | 220 + MULT16_32_Q15(MULT16_16_Q15(f,g11),ADD32(x1,x3)) |
| 155 + MULT16_32_Q15(MULT16_16_Q15(f,g12),ADD32(x0,x4)); | 221 + MULT16_32_Q15(MULT16_16_Q15(f,g12),ADD32(x0,x4)); |
| 156 x4=x3; | 222 x4=x3; |
| 157 x3=x2; | 223 x3=x2; |
| 158 x2=x1; | 224 x2=x1; |
| 159 x1=x0; | 225 x1=x0; |
| 160 | 226 |
| 161 } | 227 } |
| 162 if (g1==0) | 228 if (g1==0) |
| 163 { | 229 { |
| 164 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr
ent encoder already copies x to y */ | 230 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr
ent encoder already copies x to y */ |
| 165 if (x!=y) | 231 if (x!=y) |
| 166 OPUS_MOVE(y+overlap, x+overlap, N-overlap); | 232 OPUS_MOVE(y+overlap, x+overlap, N-overlap); |
| 167 return; | 233 return; |
| 168 } | 234 } |
| 169 | 235 |
| 170 /* Compute the part with the constant filter. */ | 236 /* Compute the part with the constant filter. */ |
| 171 comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12); | 237 comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12); |
| 172 } | 238 } |
| 239 #endif /* OVERRIDE_comb_filter */ |
| 173 | 240 |
| 174 const signed char tf_select_table[4][8] = { | 241 const signed char tf_select_table[4][8] = { |
| 175 {0, -1, 0, -1, 0,-1, 0,-1}, | 242 {0, -1, 0, -1, 0,-1, 0,-1}, |
| 176 {0, -1, 0, -2, 1, 0, 1,-1}, | 243 {0, -1, 0, -2, 1, 0, 1,-1}, |
| 177 {0, -2, 0, -3, 2, 0, 1,-1}, | 244 {0, -2, 0, -3, 2, 0, 1,-1}, |
| 178 {0, -2, 0, -3, 3, 0, 1,-1}, | 245 {0, -2, 0, -3, 3, 0, 1,-1}, |
| 179 }; | 246 }; |
| 180 | 247 |
| 181 | 248 |
| 182 void init_caps(const CELTMode *m,int *cap,int LM,int C) | 249 void init_caps(const CELTMode *m,int *cap,int LM,int C) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 { | 281 { |
| 215 return "libopus " PACKAGE_VERSION | 282 return "libopus " PACKAGE_VERSION |
| 216 #ifdef FIXED_POINT | 283 #ifdef FIXED_POINT |
| 217 "-fixed" | 284 "-fixed" |
| 218 #endif | 285 #endif |
| 219 #ifdef FUZZING | 286 #ifdef FUZZING |
| 220 "-fuzzing" | 287 "-fuzzing" |
| 221 #endif | 288 #endif |
| 222 ; | 289 ; |
| 223 } | 290 } |
| OLD | NEW |