⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modes.cpp

📁 KphoneSI (kpsi) is a SIP (Session Initiation Protocol) user agent for Linux, with which you can in
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* Default mode for narrowband */SpeexMode speex_nb_mode = {   &nb_mode,   nb_mode_query,   "narrowband",   0,   4,   &nb_encoder_init,   &nb_encoder_destroy,   &nb_encode,   &nb_decoder_init,   &nb_decoder_destroy,   &nb_decode,   &nb_encoder_ctl,   &nb_decoder_ctl,};/* Wideband part */static SpeexSubmode wb_submode1 = {   0,   0,   1,   0,   /*LSP quantization*/   lsp_quant_high,   lsp_unquant_high,   /*Pitch quantization*/   NULL,   NULL,   NULL,   /*No innovation quantization*/   NULL,   NULL,   NULL,   .75, .75, -1,   36};static SpeexSubmode wb_submode2 = {   0,   0,   1,   0,   /*LSP quantization*/   lsp_quant_high,   lsp_unquant_high,   /*Pitch quantization*/   NULL,   NULL,   NULL,   /*Innovation quantization*/   split_cb_search_shape_sign,   split_cb_shape_sign_unquant,   &split_cb_high_lbr,   .85, .6, -1,   112};static SpeexSubmode wb_submode3 = {   0,   0,   1,   0,   /*LSP quantization*/   lsp_quant_high,   lsp_unquant_high,   /*Pitch quantization*/   NULL,   NULL,   NULL,   /*Innovation quantization*/   split_cb_search_shape_sign,   split_cb_shape_sign_unquant,   &split_cb_high,   .75, .7, -1,   192};static SpeexSubmode wb_submode4 = {   0,   0,   1,   1,   /*LSP quantization*/   lsp_quant_high,   lsp_unquant_high,   /*Pitch quantization*/   NULL,   NULL,   NULL,   /*Innovation quantization*/   split_cb_search_shape_sign,   split_cb_shape_sign_unquant,   &split_cb_high,   .75, .75, -1,   352};/* Split-band wideband CELP mode*/static SpeexSBMode sb_wb_mode = {   &speex_nb_mode,   160,    /*frameSize*/   40,     /*subframeSize*/   8,     /*lpcSize*/   640,    /*bufSize*/   .9,    /*gamma1*/   0.6,    /*gamma2*/   .002,   /*lag_factor*/   1.0001, /*lpc_floor*/   0.0,    /*preemph*/   0.9,   {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},   3,   {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},   {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},   vbr_hb_thresh,   5};SpeexMode speex_wb_mode = {   &sb_wb_mode,   wb_mode_query,   "wideband (sub-band CELP)",   1,   4,   &sb_encoder_init,   &sb_encoder_destroy,   &sb_encode,   &sb_decoder_init,   &sb_decoder_destroy,   &sb_decode,   &sb_encoder_ctl,   &sb_decoder_ctl,};/* "Ultra-wideband" mode stuff *//* Split-band "ultra-wideband" (32 kbps) CELP mode*/static SpeexSBMode sb_uwb_mode = {   &speex_wb_mode,   320,    /*frameSize*/   80,     /*subframeSize*/   8,     /*lpcSize*/   1280,    /*bufSize*/   .9,    /*gamma1*/   0.6,    /*gamma2*/   .002,   /*lag_factor*/   1.0001, /*lpc_floor*/   0.0,    /*preemph*/   0.7,   {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},   1,   {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},   {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},   vbr_uhb_thresh,   2};SpeexMode speex_uwb_mode = {   &sb_uwb_mode,   wb_mode_query,   "ultra-wideband (sub-band CELP)",   2,   4,   &sb_encoder_init,   &sb_encoder_destroy,   &sb_encode,   &sb_decoder_init,   &sb_decoder_destroy,   &sb_decode,   &sb_encoder_ctl,   &sb_decoder_ctl,};void *speex_encoder_init(SpeexMode *mode){   return mode->enc_init(mode);}void *speex_decoder_init(SpeexMode *mode){   return mode->dec_init(mode);}void speex_encoder_destroy(void *state){   (*((SpeexMode**)state))->enc_destroy(state);}int speex_encode(void *state, float *in, SpeexBits *bits){   return (*((SpeexMode**)state))->enc(state, in, bits);}int speex_encode_int(void *state, short *in, SpeexBits *bits){   int i;   int N;   /* FIXME: Do some dynamic allocation here */   float float_in[MAX_IN_SAMPLES];   speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);   for (i=0;i<N;i++)      float_in[i] = in[i];   return (*((SpeexMode**)state))->enc(state, float_in, bits);}void speex_decoder_destroy(void *state){   (*((SpeexMode**)state))->dec_destroy(state);}int speex_decode(void *state, SpeexBits *bits, float *out){   return (*((SpeexMode**)state))->dec(state, bits, out);}int speex_decode_int(void *state, SpeexBits *bits, short *out){   int i;   int N;   /* FIXME: Do some dynamic allocation here */   float float_out[MAX_IN_SAMPLES];   int ret;   speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);   ret = (*((SpeexMode**)state))->dec(state, bits, float_out);   for (i=0;i<N;i++)   {      if (float_out[i]>32767.f)         out[i] = 32767;      else if (float_out[i]<-32768.f)         out[i] = -32768;      else         out[i] = (short)floor(.5+float_out[i]);   }   return ret;}int speex_encoder_ctl(void *state, int request, void *ptr){   return (*((SpeexMode**)state))->enc_ctl(state, request, ptr);}int speex_decoder_ctl(void *state, int request, void *ptr){   return (*((SpeexMode**)state))->dec_ctl(state, request, ptr);}static int nb_mode_query(void *mode, int request, void *ptr){   SpeexNBMode *m = (SpeexNBMode*)mode;      switch (request)   {   case SPEEX_MODE_FRAME_SIZE:      *((int*)ptr)=m->frameSize;      break;   case SPEEX_SUBMODE_BITS_PER_FRAME:      if (*((int*)ptr)==0)         *((int*)ptr) = NB_SUBMODE_BITS+1;      else if (m->submodes[*((int*)ptr)]==NULL)         *((int*)ptr) = -1;      else         *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;      break;   default:      speex_warning_int("Unknown nb_mode_query request: ", request);      return -1;   }   return 0;}static int wb_mode_query(void *mode, int request, void *ptr){   SpeexSBMode *m = (SpeexSBMode*)mode;   switch (request)   {   case SPEEX_MODE_FRAME_SIZE:      *((int*)ptr)=2*m->frameSize;      break;   case SPEEX_SUBMODE_BITS_PER_FRAME:      if (*((int*)ptr)==0)         *((int*)ptr) = SB_SUBMODE_BITS+1;      else if (m->submodes[*((int*)ptr)]==NULL)         *((int*)ptr) = -1;      else         *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;      break;   default:      speex_warning_int("Unknown wb_mode_query request: ", request);      return -1;   }   return 0;}int speex_mode_query(SpeexMode *mode, int request, void *ptr){   return mode->query(mode->mode, request, ptr);}int speex_lib_ctl(int request, void *ptr){   switch (request)   {      case SPEEX_LIB_GET_MAJOR_VERSION:         *((int*)ptr) = SPEEX_MAJOR_VERSION;         break;      case SPEEX_LIB_GET_MINOR_VERSION:         *((int*)ptr) = SPEEX_MINOR_VERSION;         break;      case SPEEX_LIB_GET_MICRO_VERSION:         *((int*)ptr) = SPEEX_MICRO_VERSION;         break;      case SPEEX_LIB_GET_EXTRA_VERSION:         *((char**)ptr) = SPEEX_EXTRA_VERSION;         break;      case SPEEX_LIB_GET_VERSION_STRING:         *((char**)ptr) = SPEEX_VERSION;         break;      /*case SPEEX_LIB_SET_ALLOC_FUNC:         break;      case SPEEX_LIB_GET_ALLOC_FUNC:         break;      case SPEEX_LIB_SET_FREE_FUNC:         break;      case SPEEX_LIB_GET_FREE_FUNC:         break;*/      default:         speex_warning_int("Unknown wb_mode_query request: ", request);         return -1;         break;   }   return 0;}SpeexMode *speex_lib_get_mode (int mode){  if (mode < 0 || mode > SPEEX_NB_MODES) return NULL;  return speex_mode_list[mode];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -