~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/lpc.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
 
1
/*
2
2
 * LPC utility code
3
3
 * Copyright (c) 2006  Justin Ruggles <justin.ruggles@gmail.com>
4
4
 *
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
 
 
22
#include "libavutil/common.h"
22
23
#include "libavutil/lls.h"
23
24
 
24
25
#define LPC_USE_DOUBLE
147
148
    return est;
148
149
}
149
150
 
 
151
int ff_lpc_calc_ref_coefs(LPCContext *s,
 
152
                          const int32_t *samples, int order, double *ref)
 
153
{
 
154
    double autoc[MAX_LPC_ORDER + 1];
 
155
 
 
156
    s->lpc_apply_welch_window(samples, s->blocksize, s->windowed_samples);
 
157
    s->lpc_compute_autocorr(s->windowed_samples, s->blocksize, order, autoc);
 
158
    compute_ref_coefs(autoc, order, ref, NULL);
 
159
 
 
160
    return order;
 
161
}
 
162
 
150
163
/**
151
164
 * Calculate LPC coefficients for multiple orders
152
165
 *
177
190
    }
178
191
 
179
192
    if (lpc_type == FF_LPC_TYPE_LEVINSON) {
180
 
        double *windowed_samples = s->windowed_samples + max_order;
181
 
 
182
 
        s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
183
 
 
184
 
        s->lpc_compute_autocorr(windowed_samples, blocksize, max_order, autoc);
 
193
        s->lpc_apply_welch_window(samples, blocksize, s->windowed_samples);
 
194
 
 
195
        s->lpc_compute_autocorr(s->windowed_samples, blocksize, max_order, autoc);
185
196
 
186
197
        compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
187
198
 
247
258
    s->lpc_type  = lpc_type;
248
259
 
249
260
    if (lpc_type == FF_LPC_TYPE_LEVINSON) {
250
 
        s->windowed_samples = av_mallocz((blocksize + max_order + 2) *
251
 
                                         sizeof(*s->windowed_samples));
252
 
        if (!s->windowed_samples)
 
261
        s->windowed_buffer = av_mallocz((blocksize + 2 + FFALIGN(max_order, 4)) *
 
262
                                        sizeof(*s->windowed_samples));
 
263
        if (!s->windowed_buffer)
253
264
            return AVERROR(ENOMEM);
 
265
        s->windowed_samples = s->windowed_buffer + FFALIGN(max_order, 4);
254
266
    } else {
255
267
        s->windowed_samples = NULL;
256
268
    }
258
270
    s->lpc_apply_welch_window = lpc_apply_welch_window_c;
259
271
    s->lpc_compute_autocorr   = lpc_compute_autocorr_c;
260
272
 
261
 
    if (HAVE_MMX)
 
273
    if (ARCH_X86)
262
274
        ff_lpc_init_x86(s);
263
275
 
264
276
    return 0;
266
278
 
267
279
av_cold void ff_lpc_end(LPCContext *s)
268
280
{
269
 
    av_freep(&s->windowed_samples);
 
281
    av_freep(&s->windowed_buffer);
270
282
}