Changeset 2894:70f3e75119e6 in roaraudio


Ignore:
Timestamp:
10/10/09 03:07:04 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

make it possible to set q, complexity, dtx and max_cc option for speex

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroardsp/transcode_speex.h

    r2304 r2894  
    5050 int frame_size; 
    5151 char       cc[ROAR_SPEEX_MAX_CC]; /* buffer for read() and write() */ 
     52 struct roar_libroar_config_codec * codec_config; 
     53 int    max_cc; 
    5254}; 
    5355 
  • libroardsp/transcode_speex.c

    r2315 r2894  
    2929#define _16BIT (16/8) 
    3030#define _SIZE_LEN 2 
     31 
     32#define _HAVE_CCFG(x) (self->codec_config != NULL && (self->codec_config->para_set & (x))) 
    3133 
    3234int roar_xcoder_speex_init       (struct roar_xcoder * state) { 
     
    6264 
    6365 if (state->encode) { 
     66  self->codec_config = roar_libroar_config_codec_get(ROAR_CODEC_ROAR_SPEEX, 0); 
     67  self->max_cc = ROAR_SPEEX_MAX_CC; 
     68 
     69  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_MAX_CC) ) { 
     70   self->max_cc = self->codec_config->max_cc; 
     71  } 
     72 
    6473  switch (self->mode) { 
    6574   case ROAR_SPEEX_MODE_NB:  self->xcoder = speex_encoder_init(&speex_nb_mode);  break; 
     
    6776   case ROAR_SPEEX_MODE_UWB: self->xcoder = speex_encoder_init(&speex_uwb_mode); break; 
    6877  } 
    69   tmp = 8; 
     78 
     79  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_COMPLEXITY) ) { 
     80   tmp = self->codec_config->complexity / 256; 
     81  } else { 
     82   tmp = 8; 
     83  } 
    7084  speex_encoder_ctl(self->xcoder, SPEEX_SET_QUALITY,       &tmp); 
     85 
     86  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_Q) ) { 
     87   tmp = self->codec_config->q / 256; 
     88   speex_encoder_ctl(self->xcoder, SPEEX_SET_QUALITY,       &tmp); 
     89  } 
     90 
     91  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_DTX) ) { 
     92   tmp = self->codec_config->dtx ? 1 : 0; 
     93   speex_encoder_ctl(self->xcoder, SPEEX_SET_DTX,       &tmp); 
     94  } 
     95 
    7196  tmp = info->rate; 
    7297  speex_encoder_ctl(self->xcoder, SPEEX_SET_SAMPLING_RATE, &tmp); 
     
    141166 speex_encode_int(self->xcoder, (spx_int16_t *) buf, &(self->bits)); 
    142167 
    143  pkg_len = speex_bits_write(&(self->bits), self->cc, ROAR_SPEEX_MAX_CC); 
     168 pkg_len = speex_bits_write(&(self->bits), self->cc, self->max_cc); 
    144169 
    145170 tmp_net = ROAR_HOST2NET16(pkg_len); 
Note: See TracChangeset for help on using the changeset viewer.