123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- /*
- *****************************************************************************
- *
- * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
- * R99 Version 3.3.0
- * REL-4 Version 4.1.0
- *
- *****************************************************************************
- *
- * File : d_plsf.c
- * Purpose : common part (init, exit, reset) of LSF decoder
- * module (rest in d_plsf_3.c and d_plsf_5.c)
- *
- *****************************************************************************
- */
-
-
- /*
- *****************************************************************************
- * MODULE INCLUDE FILE AND VERSION ID
- *****************************************************************************
- */
- #include "d_plsf.h"
- const char d_plsf_id[] = "@(#)$Id $" d_plsf_h;
-
- /*
- *****************************************************************************
- * INCLUDE FILES
- *****************************************************************************
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include "typedef.h"
- #include "basic_op.h"
- #include "count.h"
- #include "cnst.h"
- #include "copy.h"
- #include "q_plsf_5.tab"
- /*
- *--------------------------------------------------*
- * Constants (defined in cnst.h) *
- *--------------------------------------------------*
- * M : LPC order
- *--------------------------------------------------*
- */
-
- /*
- *****************************************************************************
- * PUBLIC PROGRAM CODE
- *****************************************************************************
- */
- /*
- **************************************************************************
- *
- * Function : D_plsf_init
- * Purpose : Allocates and initializes state memory
- *
- **************************************************************************
- */
- int D_plsf_init (D_plsfState **state)
- {
- D_plsfState* s;
-
- if (state == (D_plsfState **) NULL){
- wfprintf(stderr, "D_plsf_init: invalid parameter\n");
- return -1;
- }
- *state = NULL;
-
- /* allocate memory */
- if ((s= (D_plsfState *) wmalloc(sizeof(D_plsfState))) == NULL){
- wfprintf(stderr, "D_plsf_init: can not malloc state structure\n");
- return -1;
- }
-
- D_plsf_reset(s);
- *state = s;
-
- return 0;
- }
-
- /*
- **************************************************************************
- *
- * Function : D_plsf_reset
- * Purpose : Resets state memory
- *
- **************************************************************************
- */
- int D_plsf_reset (D_plsfState *state)
- {
- Word16 i;
-
- if (state == (D_plsfState *) NULL){
- wfprintf(stderr, "D_plsf_reset: invalid parameter\n");
- return -1;
- }
-
- for (i = 0; i < M; i++){
- state->past_r_q[i] = 0; /* Past quantized prediction error */
- }
-
- /* Past dequantized lsfs */
- Copy(mean_lsf, &state->past_lsf_q[0], M);
- return 0;
- }
-
- /*
- **************************************************************************
- *
- * Function : D_plsf_exit
- * Purpose : The memory used for state memory is freed
- *
- **************************************************************************
- */
- void D_plsf_exit (D_plsfState **state)
- {
- if (state == NULL || *state == NULL)
- return;
-
- /* deallocate memory */
- wfree(*state);
- *state = NULL;
-
- return;
- }
|