Changed Speex defaults: complexity=-1, vad=off. Tested with EyeBeam

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@291 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2006-03-06 13:32:57 +00:00
parent 8f0e8dc03b
commit 7bd1513fbc
1 changed files with 28 additions and 26 deletions

View File

@ -28,8 +28,8 @@
#include <pj/string.h> #include <pj/string.h>
#include <pj/os.h> #include <pj/os.h>
#define DEFAULT_QUALITY 8 #define DEFAULT_QUALITY 4
#define DEFAULT_COMPLEXITY 8 #define DEFAULT_COMPLEXITY -1
/* Prototypes for Speex factory */ /* Prototypes for Speex factory */
@ -102,15 +102,15 @@ enum
/* Speex default parameter */ /* Speex default parameter */
struct speex_param struct speex_param
{ {
int enabled; /* Is this mode enabled? */ int enabled; /* Is this mode enabled? */
const SpeexMode *mode; /* Speex mode. */ const SpeexMode *mode; /* Speex mode. */
int pt; /* Payload type. */ int pt; /* Payload type. */
unsigned clock_rate;/* Default sampling rate to be used. */ unsigned clock_rate; /* Default sampling rate to be used.*/
int quality; /* Default encoder quality to be used. */ int quality; /* Default encoder quality. */
int complexity; /* Default encoder complexity. */ int complexity; /* Default encoder complexity. */
int samples_per_frame; /* Samples per frame. */ int samples_per_frame; /* Samples per frame. */
int framesize; /* Frame size for current mode. */ int framesize; /* Frame size for current mode. */
int bitrate; /* Bit rate for current mode. */ int bitrate; /* Bit rate for current mode. */
}; };
/* Speex factory */ /* Speex factory */
@ -128,8 +128,6 @@ static struct spx_factory
/* Speex codec private data. */ /* Speex codec private data. */
struct spx_private struct spx_private
{ {
//pjmedia_codec_info info; /**< Codec info. */
int param_id; /**< Index to speex param. */ int param_id; /**< Index to speex param. */
void *enc; /**< Encoder state. */ void *enc; /**< Encoder state. */
@ -153,17 +151,19 @@ static pj_status_t get_speex_info( struct speex_param *p )
return PJMEDIA_CODEC_EFAILED; return PJMEDIA_CODEC_EFAILED;
/* Set the quality */ /* Set the quality */
speex_encoder_ctl(state, SPEEX_SET_QUALITY, &p->quality); if (p->quality != -1)
speex_encoder_ctl(state, SPEEX_SET_QUALITY, &p->quality);
/* Sampling rate. */ /* Sampling rate. */
speex_encoder_ctl(state, SPEEX_SET_SAMPLING_RATE, &p->clock_rate); speex_encoder_ctl(state, SPEEX_SET_SAMPLING_RATE, &p->clock_rate);
/* VAD */ /* VAD off to have max bitrate */
tmp = 1; tmp = 0;
speex_encoder_ctl(state, SPEEX_SET_VAD, &tmp); speex_encoder_ctl(state, SPEEX_SET_VAD, &tmp);
/* Complexity. */ /* Complexity. */
speex_encoder_ctl(state, SPEEX_SET_COMPLEXITY, &p->complexity); if (p->complexity != -1)
speex_encoder_ctl(state, SPEEX_SET_COMPLEXITY, &p->complexity);
/* Now get the frame size */ /* Now get the frame size */
speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &p->samples_per_frame); speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &p->samples_per_frame);
@ -392,7 +392,9 @@ static pj_status_t spx_default_attr (pjmedia_codec_factory *factory,
attr->hpf_enabled = 1; attr->hpf_enabled = 1;
attr->lpf_enabled =1 ; attr->lpf_enabled =1 ;
attr->penh_enabled =1 ; attr->penh_enabled =1 ;
attr->vad_enabled = 1;
/* Default, set VAD off as it caused voice chip off */
attr->vad_enabled = 0;
return PJ_SUCCESS; return PJ_SUCCESS;
} }
@ -557,8 +559,10 @@ static pj_status_t spx_codec_open( pjmedia_codec *codec,
speex_bits_init(&spx->enc_bits); speex_bits_init(&spx->enc_bits);
/* Set the quality*/ /* Set the quality*/
speex_encoder_ctl(spx->enc, SPEEX_SET_QUALITY, if (spx_factory.speex_param[id].quality != -1) {
&spx_factory.speex_param[id].quality); speex_encoder_ctl(spx->enc, SPEEX_SET_QUALITY,
&spx_factory.speex_param[id].quality);
}
/* Sampling rate. */ /* Sampling rate. */
tmp = attr->sample_rate; tmp = attr->sample_rate;
@ -570,12 +574,10 @@ static pj_status_t spx_codec_open( pjmedia_codec *codec,
speex_encoder_ctl(spx->enc, SPEEX_SET_VAD, &tmp); speex_encoder_ctl(spx->enc, SPEEX_SET_VAD, &tmp);
/* Complexity */ /* Complexity */
speex_encoder_ctl(spx->enc, SPEEX_SET_BITRATE, if (spx_factory.speex_param[id].complexity != -1) {
&spx_factory.speex_param[id].complexity); speex_encoder_ctl(spx->enc, SPEEX_SET_COMPLEXITY,
&spx_factory.speex_param[id].complexity);
/* Bitrate */ }
speex_encoder_ctl(spx->enc, SPEEX_SET_BITRATE,
&spx_factory.speex_param[id].bitrate);
/* /*
* Create and initialize decoder. * Create and initialize decoder.