void kiss_fft_free(const kiss_fft_state *cfg) { celt_free((celt_int16*)cfg->bitrev); if (cfg->shift < 0) celt_free((kiss_twiddle_cpx*)cfg->twiddles); celt_free((kiss_fft_state*)cfg); }
void celt_encoder_destroy(CELTEncoder *st) { if (st == NULL) { celt_warning("NULL passed to celt_encoder_destroy"); return; } if (st->marker == ENCODERFREED) { celt_warning("Freeing an encoder which has already been freed"); return; } if (st->marker != ENCODERVALID && st->marker != ENCODERPARTIAL) { celt_warning("This is not a valid CELT encoder structure"); return; } /*Check_mode is non-fatal here because we can still free the encoder memory even if the mode is bad, although calling the free functions in this order is a violation of the API.*/ check_mode(st->mode); celt_free(st->in_mem); celt_free(st->out_mem); celt_free(st->oldBandE); celt_free(st->preemph_memE); celt_free(st->preemph_memD); #ifdef EXP_PSY celt_free (st->psy_mem); psydecay_clear(&st->psy); #endif st->marker = ENCODERFREED; celt_free(st); }
void psydecay_clear(struct PsyDecay *decay) { celt_free((celt_word16 *)decay->decayR); /*celt_free(decay->decayL);*/ }
void clt_mdct_clear(mdct_lookup *l) { cpx32_fft_free(l->kfft); celt_free(l->trig); }
void ec_byte_writeclear(ec_byte_buffer *_b){ celt_free(_b->buf); }
CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int *error) { int i; #ifdef STDIN_TUNING scanf("%d ", &MIN_BINS); scanf("%d ", &BITALLOC_SIZE); band_allocation = celt_alloc(sizeof(int)*BARK_BANDS*BITALLOC_SIZE); for (i=0;i<BARK_BANDS*BITALLOC_SIZE;i++) { scanf("%d ", band_allocation+i); } #endif #ifdef STATIC_MODES const CELTMode *m = NULL; CELTMode *mode=NULL; ALLOC_STACK; #if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA) if (global_stack==NULL) { celt_free(global_stack); goto failure; } #endif for (i=0;i<TOTAL_MODES;i++) { if (Fs == static_mode_list[i]->Fs && channels == static_mode_list[i]->nbChannels && frame_size == static_mode_list[i]->mdctSize) { m = static_mode_list[i]; break; } } if (m == NULL) { celt_warning("Mode not included as part of the static modes"); if (error) *error = CELT_BAD_ARG; return NULL; } mode = (CELTMode*)celt_alloc(sizeof(CELTMode)); if (mode==NULL) goto failure; CELT_COPY(mode, m, 1); mode->marker_start = MODEPARTIAL; #else int res; CELTMode *mode=NULL; celt_word16_t *window; ALLOC_STACK; #if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA) if (global_stack==NULL) { celt_free(global_stack); goto failure; } #endif /* The good thing here is that permutation of the arguments will automatically be invalid */ if (Fs < 32000 || Fs > 96000) { celt_warning("Sampling rate must be between 32 kHz and 96 kHz"); if (error) *error = CELT_BAD_ARG; return NULL; } if (channels < 0 || channels > 2) { celt_warning("Only mono and stereo supported"); if (error) *error = CELT_BAD_ARG; return NULL; } if (frame_size < 64 || frame_size > 1024 || frame_size%2!=0) { celt_warning("Only even frame sizes from 64 to 1024 are supported"); if (error) *error = CELT_BAD_ARG; return NULL; } res = (Fs+frame_size)/(2*frame_size); mode = celt_alloc(sizeof(CELTMode)); if (mode==NULL) goto failure; mode->marker_start = MODEPARTIAL; mode->Fs = Fs; mode->mdctSize = frame_size; mode->nbChannels = channels; mode->eBands = compute_ebands(Fs, frame_size, &mode->nbEBands); if (mode->eBands==NULL) goto failure; compute_pbands(mode, res); if (mode->pBands==NULL) goto failure; mode->ePredCoef = QCONST16(.8f,15); if (frame_size > 640 && (frame_size%16)==0) { mode->nbShortMdcts = 8; } else if (frame_size > 384 && (frame_size%8)==0) { mode->nbShortMdcts = 4; } else if (frame_size > 384 && (frame_size%10)==0) { mode->nbShortMdcts = 5; } else if (frame_size > 256 && (frame_size%6)==0) { mode->nbShortMdcts = 3; } else if (frame_size > 256 && (frame_size%8)==0) { mode->nbShortMdcts = 4; } else if (frame_size > 64 && (frame_size%4)==0) { mode->nbShortMdcts = 2; } else if (frame_size > 128 && (frame_size%6)==0) { mode->nbShortMdcts = 3; } else { mode->nbShortMdcts = 1; } /* Overlap must be divisible by 4 */ if (mode->nbShortMdcts > 1) mode->overlap = ((frame_size/mode->nbShortMdcts)>>2)<<2; else