123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- #include "lpc.h"
- const char lpc_id[] = "@(#)$Id $" lpc_h;
- #include <stdio.h>
- #include <stdlib.h>
- #include "typedef.h"
- #include "basic_op.h"
- #include "oper_32b.h"
- #include "autocorr.h"
- #include "lag_wind.h"
- #include "levinson.h"
- #include "cnst.h"
- #include "mode.h"
- #include "count.h"
- #include "window.tab"
- int lpc_init (lpcState **state)
- {
- lpcState* s;
-
- if (state == (lpcState **) NULL){
- wfprintf(stderr, "lpc_init: invalid parameter\n");
- return -1;
- }
- *state = NULL;
-
-
- if ((s= (lpcState *) wmalloc(sizeof(lpcState))) == NULL){
- wfprintf(stderr, "lpc_init: can not malloc state structure\n");
- return -1;
- }
-
- s->levinsonSt = NULL;
-
-
- if (Levinson_init(&s->levinsonSt)) {
- lpc_exit(&s);
- return -1;
- }
- lpc_reset(s);
- *state = s;
-
- return 0;
- }
-
- int lpc_reset (lpcState *state)
- {
-
- if (state == (lpcState *) NULL){
- wfprintf(stderr, "lpc_reset: invalid parameter\n");
- return -1;
- }
-
- Levinson_reset(state->levinsonSt);
- return 0;
- }
- void lpc_exit (lpcState **state)
- {
- if (state == NULL || *state == NULL)
- return;
- Levinson_exit(&(*state)->levinsonSt);
-
- wfree(*state);
- *state = NULL;
-
- return;
- }
- int lpc(
- lpcState *st,
- enum Mode mode,
- Word16 x[],
- Word16 x_12k2[],
- Word16 a[]
- )
- {
- Word16 rc[4];
- Word16 rLow[MP1], rHigh[MP1];
-
-
-
- test ();
- if ( sub_ex (mode, MR122) == 0)
- {
-
- Autocorr(x_12k2, M, rHigh, rLow, window_160_80);
-
- Lag_window(M, rHigh, rLow);
-
- Levinson(st->levinsonSt, rHigh, rLow, &a[MP1], rc);
-
- Autocorr(x_12k2, M, rHigh, rLow, window_232_8);
-
- Lag_window(M, rHigh, rLow);
-
- Levinson(st->levinsonSt, rHigh, rLow, &a[MP1 * 3], rc);
- }
- else
- {
-
- Autocorr(x, M, rHigh, rLow, window_200_40);
-
- Lag_window(M, rHigh, rLow);
-
- Levinson(st->levinsonSt, rHigh, rLow, &a[MP1 * 3], rc);
- }
-
- return 0;
- }
|