/************************************************************************* * * Function: gain_adapt_init * Purpose: Allocates state memory and initializes state memory * ************************************************************************** */ int gain_adapt_init (GainAdaptState *st) { if (st == (GainAdaptState *) NULL){ fprintf(stderr, "gain_adapt_init: invalid parameter\n"); return -1; } gain_adapt_reset(st); return 0; }
/************************************************************************* * * Function: gain_adapt_init * Purpose: Allocates state memory and initializes state memory * ************************************************************************** */ int gain_adapt_init (GainAdaptState **st) { GainAdaptState* s; if (st == (GainAdaptState **) NULL){ fprintf(stderr, "gain_adapt_init: invalid parameter\n"); return -1; } *st = NULL; /* allocate memory */ if ((s= (GainAdaptState *) malloc(sizeof(GainAdaptState))) == NULL){ fprintf(stderr, "gain_adapt_init: can't malloc state structure\n"); return -1; } gain_adapt_reset(s); *st = s; return 0; }
/************************************************************************* * * Function: gainQuant_reset * Purpose: Initializes state memory to zero * ************************************************************************** */ int gainQuant_reset (gainQuantState *state) { if (state == (gainQuantState *) NULL){ fprintf(stderr, "gainQuant_reset: invalid parameter\n"); return -1; } state->sf0_exp_gcode0 = 0; state->sf0_frac_gcode0 = 0; state->sf0_exp_target_en = 0; state->sf0_frac_target_en = 0; Set_zero (state->sf0_exp_coeff, 5); Set_zero (state->sf0_frac_coeff, 5); state->gain_idx_ptr = NULL; gc_pred_reset(state->gc_predSt); gc_pred_reset(state->gc_predUnqSt); gain_adapt_reset(state->adaptSt); return 0; }