/* ************************************************************************** * * Function : cod_amr_exit * Purpose : The memory used for state memory is freed * ************************************************************************** */ void cod_amr_exit (cod_amrState **state) { if (state == NULL || *state == NULL) return; /* dealloc members */ lpc_exit(&(*state)->lpcSt); lsp_exit(&(*state)->lspSt); gainQuant_exit(&(*state)->gainQuantSt); cl_ltp_exit(&(*state)->clLtpSt); p_ol_wgh_exit(&(*state)->pitchOLWghtSt); ton_stab_exit(&(*state)->tonStabSt); #ifndef VAD2 vad1_exit(&(*state)->vadSt); #else vad2_exit(&(*state)->vadSt); #endif dtx_enc_exit(&(*state)->dtx_encSt); /* deallocate memory */ free(*state); *state = NULL; return; }
/************************************************************************* * * Function: lpc_init * ************************************************************************** */ int lpc_init (lpcState **state) { lpcState* s; if (state == (lpcState **) NULL){ fprintf(stderr, "lpc_init: invalid parameter\n"); return -1; } *state = NULL; /* allocate memory */ if ((s= (lpcState *) malloc(sizeof(lpcState))) == NULL){ fprintf(stderr, "lpc_init: can not malloc state structure\n"); return -1; } s->levinsonSt = NULL; /* Init sub states */ if (Levinson_init(&s->levinsonSt)) { lpc_exit(&s); return -1; } lpc_reset(s); *state = s; return 0; }