Browse code

Merge commit 'c93ccf5a4cca722b39f05e9f5660b4cb75bc1740'

* commit 'c93ccf5a4cca722b39f05e9f5660b4cb75bc1740':
lpc: use levinson for the first pass of multipass cholesky

Conflicts:
libavcodec/lpc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/06/30 19:20:12
Showing 1 changed files
... ...
@@ -177,7 +177,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
177 177
     double autoc[MAX_LPC_ORDER+1];
178 178
     double ref[MAX_LPC_ORDER];
179 179
     double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
180
-    int i, j, pass;
180
+    int i, j, pass = 0;
181 181
     int opt_order;
182 182
 
183 183
     av_assert2(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&
... ...
@@ -190,7 +190,10 @@ int ff_lpc_calc_coefs(LPCContext *s,
190 190
         ff_lpc_init(s, blocksize, max_order, lpc_type);
191 191
     }
192 192
 
193
-    if (lpc_type == FF_LPC_TYPE_LEVINSON) {
193
+    if(lpc_passes <= 0)
194
+        lpc_passes = 2;
195
+
196
+    if (lpc_type == FF_LPC_TYPE_LEVINSON || (lpc_type == FF_LPC_TYPE_CHOLESKY && lpc_passes > 1)) {
194 197
         s->lpc_apply_welch_window(samples, blocksize, s->windowed_samples);
195 198
 
196 199
         s->lpc_compute_autocorr(s->windowed_samples, blocksize, max_order, autoc);
... ...
@@ -199,16 +202,20 @@ int ff_lpc_calc_coefs(LPCContext *s,
199 199
 
200 200
         for(i=0; i<max_order; i++)
201 201
             ref[i] = fabs(lpc[i][i]);
202
-    } else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
202
+
203
+        pass++;
204
+    }
205
+
206
+    if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
203 207
         LLSModel m[2];
204 208
         LOCAL_ALIGNED(32, double, var, [FFALIGN(MAX_LPC_ORDER+1,4)]);
205 209
         double av_uninit(weight);
206 210
         memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var));
207 211
 
208
-        if(lpc_passes <= 0)
209
-            lpc_passes = 2;
212
+        for(j=0; j<max_order; j++)
213
+            m[0].coeff[max_order-1][j] = -lpc[max_order-1][j];
210 214
 
211
-        for(pass=0; pass<lpc_passes; pass++){
215
+        for(; pass<lpc_passes; pass++){
212 216
             avpriv_init_lls(&m[pass&1], max_order);
213 217
 
214 218
             weight=0;
... ...
@@ -240,8 +247,8 @@ int ff_lpc_calc_coefs(LPCContext *s,
240 240
         }
241 241
         for(i=max_order-1; i>0; i--)
242 242
             ref[i] = ref[i-1] - ref[i];
243
-    } else
244
-        av_assert0(0);
243
+    }
244
+
245 245
     opt_order = max_order;
246 246
 
247 247
     if(omethod == ORDER_METHOD_EST) {
... ...
@@ -264,15 +271,11 @@ av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
264 264
     s->max_order = max_order;
265 265
     s->lpc_type  = lpc_type;
266 266
 
267
-    if (lpc_type == FF_LPC_TYPE_LEVINSON) {
268
-        s->windowed_buffer = av_mallocz((blocksize + 2 + FFALIGN(max_order, 4)) *
269
-                                        sizeof(*s->windowed_samples));
270
-        if (!s->windowed_buffer)
271
-            return AVERROR(ENOMEM);
272
-        s->windowed_samples = s->windowed_buffer + FFALIGN(max_order, 4);
273
-    } else {
274
-        s->windowed_samples = NULL;
275
-    }
267
+    s->windowed_buffer = av_mallocz((blocksize + 2 + FFALIGN(max_order, 4)) *
268
+                                    sizeof(*s->windowed_samples));
269
+    if (!s->windowed_buffer)
270
+        return AVERROR(ENOMEM);
271
+    s->windowed_samples = s->windowed_buffer + FFALIGN(max_order, 4);
276 272
 
277 273
     s->lpc_apply_welch_window = lpc_apply_welch_window_c;
278 274
     s->lpc_compute_autocorr   = lpc_compute_autocorr_c;