From 1caf198b62ac211e7ed60b64dc9304e409f74a6e Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 23 Apr 2008 16:07:37 +0000 Subject: More ticket #497: added configuration to disable WSOLA and set default to disabled on WinCE and Symbian git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1941 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/include/pj/config_site_sample.h | 2 + pjmedia/include/pjmedia/config.h | 36 ++++++++++++ pjmedia/src/pjmedia/wsola.c | 103 +++++++++++++++++++++++++++++++++- 3 files changed, 140 insertions(+), 1 deletion(-) diff --git a/pjlib/include/pj/config_site_sample.h b/pjlib/include/pj/config_site_sample.h index e830a772..6be85943 100644 --- a/pjlib/include/pj/config_site_sample.h +++ b/pjlib/include/pj/config_site_sample.h @@ -26,6 +26,7 @@ # define PJMEDIA_HAS_SPEEX_AEC 0 # undef PJMEDIA_RESAMPLE_IMP # define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE +# define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_NULL #endif @@ -49,6 +50,7 @@ /* Disable these */ # define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE # define PJMEDIA_HAS_SPEEX_AEC 0 +# define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_NULL /* Disable all codecs but G.711 and GSM, for now */ # define PJMEDIA_HAS_GSM_CODEC 1 diff --git a/pjmedia/include/pjmedia/config.h b/pjmedia/include/pjmedia/config.h index 38dd872c..240432eb 100644 --- a/pjmedia/include/pjmedia/config.h +++ b/pjmedia/include/pjmedia/config.h @@ -106,6 +106,42 @@ #endif +/* + * Types of WSOLA backend algorithm. + */ + +/** + * This denotes implementation of WSOLA using null algorithm. Expansion + * will generate zero frames, and compression will just discard some + * samples from the input. + * + * This type of implementation may be used as it requires the least + * processing power. + */ +#define PJMEDIA_WSOLA_IMP_NULL 0 + +/** + * This denotes implementation of WSOLA using fixed or floating point WSOLA + * algorithm. This implementation provides the best quality of the result, + * at the expense of one frame delay and intensive processing power + * requirement. + */ +#define PJMEDIA_WSOLA_IMP_WSOLA 1 + + +/** + * Specify type of Waveform based Similarity Overlap and Add (WSOLA) backend + * implementation to be used. WSOLA is an algorithm to expand and/or compress + * audio frames without changing the pitch, and used by the delaybuf and as PLC + * backend algorithm. + * + * Default is PJMEDIA_WSOLA_IMP_WSOLA + */ +#ifndef PJMEDIA_WSOLA_IMP +# define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA +#endif + + /** * Specify number of sound buffers. Larger number is better for sound * stability and to accommodate sound devices that are unable to send frames diff --git a/pjmedia/src/pjmedia/wsola.c b/pjmedia/src/pjmedia/wsola.c index 73cb479b..85c0f25c 100644 --- a/pjmedia/src/pjmedia/wsola.c +++ b/pjmedia/src/pjmedia/wsola.c @@ -22,9 +22,17 @@ #include #include +/* + * This file contains implementation of WSOLA using PJMEDIA_WSOLA_IMP_WSOLA + * or PJMEDIA_WSOLA_IMP_NULL + */ #define THIS_FILE "wsola.c" -//#undef PJ_HAS_FLOATING_POINT + +#if PJMEDIA_WSOLA_IMP==PJMEDIA_WSOLA_IMP_WSOLA +/* + * WSOLA implementation using WSOLA + */ /* History size, in percentage of samples_per_frame */ #define HISTSZ (1.5) @@ -720,3 +728,96 @@ PJ_DEF(pj_status_t) pjmedia_wsola_discard( pjmedia_wsola *wsola, } +#elif PJMEDIA_WSOLA_IMP==PJMEDIA_WSOLA_IMP_NULL +/* + * WSOLA implementation using NULL + */ + +struct pjmedia_wsola +{ + unsigned samples_per_frame; +}; + + +PJ_DEF(pj_status_t) pjmedia_wsola_create( pj_pool_t *pool, + unsigned clock_rate, + unsigned samples_per_frame, + unsigned channel_count, + unsigned options, + pjmedia_wsola **p_wsola) +{ + pjmedia_wsola *wsola; + + wsola = PJ_POOL_ZALLOC_T(pool, struct pjmedia_wsola); + wsola->samples_per_frame = samples_per_frame; + + PJ_UNUSED_ARG(clock_rate); + PJ_UNUSED_ARG(channel_count); + PJ_UNUSED_ARG(options); + + *p_wsola = wsola; + + return PJ_SUCCESS; +} + + +PJ_DEF(pj_status_t) pjmedia_wsola_destroy(pjmedia_wsola *wsola) +{ + PJ_UNUSED_ARG(wsola); + return PJ_SUCCESS; +} + + +PJ_DEF(pj_status_t) pjmedia_wsola_reset( pjmedia_wsola *wsola, + unsigned options) +{ + PJ_UNUSED_ARG(wsola); + PJ_UNUSED_ARG(options); + + return PJ_SUCCESS; +} + + +PJ_DEF(pj_status_t) pjmedia_wsola_save( pjmedia_wsola *wsola, + short frm[], + pj_bool_t prev_lost) +{ + PJ_UNUSED_ARG(wsola); + PJ_UNUSED_ARG(frm); + PJ_UNUSED_ARG(prev_lost); + + return PJ_SUCCESS; +} + + +PJ_DEF(pj_status_t) pjmedia_wsola_generate( pjmedia_wsola *wsola, + short frm[]) +{ + pjmedia_zero_samples(frm, wsola->samples_per_frame); + return PJ_SUCCESS; +} + + +PJ_DEF(pj_status_t) pjmedia_wsola_discard( pjmedia_wsola *wsola, + short buf1[], + unsigned buf1_cnt, + short buf2[], + unsigned buf2_cnt, + unsigned *del_cnt) +{ + pj_assert(buf1_cnt + buf2_cnt >= wsola->samples_per_frame); + + PJ_UNUSED_ARG(buf1); + PJ_UNUSED_ARG(buf1_cnt); + PJ_UNUSED_ARG(buf2); + PJ_UNUSED_ARG(buf2_cnt); + + *del_cnt = wsola->samples_per_frame; + + return PJ_SUCCESS; +} + + +#endif /* #if PJMEDIA_WSOLA_IMP.. */ + + -- cgit v1.2.3