diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-09-18 11:14:21 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-09-18 11:14:21 +0000 |
commit | fd64f65109f5cc5ce611cd5ec842c08796566a05 (patch) | |
tree | e9a0d6b6c8841b38513d3e74f1d01b1fc7c064c1 /pjmedia/include | |
parent | 5059cf00692fdb889344d9839fad80773e58deb8 (diff) |
Large reorganization of the tonegen for ticket #619:
- Deprecate the automatic selection of algorithm
- Introduced various constants for tonegen backends
- Allow user to specify/override the algorithm by setting
- Fix the floating-point approximation backend
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2292 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia/include')
-rw-r--r-- | pjmedia/include/pjmedia/config.h | 95 |
1 files changed, 65 insertions, 30 deletions
diff --git a/pjmedia/include/pjmedia/config.h b/pjmedia/include/pjmedia/config.h index 70354ee7..86a408e9 100644 --- a/pjmedia/include/pjmedia/config.h +++ b/pjmedia/include/pjmedia/config.h @@ -541,47 +541,82 @@ #endif +/* + * Below specifies the various tone generator backend algorithm. + */ + +/** + * The math's sine(), floating point. This has very good precision + * but it's the slowest and requires floating point support and + * linking with the math library. + */ +#define PJMEDIA_TONEGEN_SINE 1 + /** - * Enable high quality of tone generation, the better quality will cost - * more CPU load. This is only applied to floating point enabled machines. + * Floating point approximation of sine(). This has relatively good + * precision and much faster than plain sine(), but it requires floating- + * point support and linking with the math library. + */ +#define PJMEDIA_TONEGEN_FLOATING_POINT 2 + +/** + * Fixed point using sine signal generated by Cordic algorithm. This + * algorithm can be tuned to provide balance between precision and + * performance by tuning the PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP + * setting, and may be suitable for platforms that lack floating-point + * support. + */ +#define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC 3 + +/** + * Fast fixed point using some approximation to generate sine waves. + * The tone generated by this algorithm is not very precise, however + * the algorithm is very fast. + */ +#define PJMEDIA_TONEGEN_FAST_FIXED_POINT 4 + + +/** + * Specify the tone generator algorithm to be used. * - * By default it is enabled when PJ_HAS_FLOATING_POINT is set. + * Default value: + * - PJMEDIA_TONEGEN_FLOATING_POINT when PJ_HAS_FLOATING_POINT is set + * - PJMEDIA_TONEGEN_FIXED_POINT_CORDIC when PJ_HAS_FLOATING_POINT is not set + */ +#ifndef PJMEDIA_TONEGEN_ALG +# if defined(PJ_HAS_FLOATING_POINT) && PJ_HAS_FLOATING_POINT +# define PJMEDIA_TONEGEN_ALG PJMEDIA_TONEGEN_FLOATING_POINT +# else +# define PJMEDIA_TONEGEN_ALG PJMEDIA_TONEGEN_FIXED_POINT_CORDIC +# endif +#endif + + +/** + * Specify the number of calculation loops to generate the tone, when + * PJMEDIA_TONEGEN_FIXED_POINT_CORDIC algorithm is used. With more calculation + * loops, the tone signal gets more precise, but this will add more + * processing. + * + * Valid values are 1 to 28. * - * @see PJMEDIA_TONEGEN_FORCE_FLOAT + * Default value: 7 */ -#ifndef PJMEDIA_USE_HIGH_QUALITY_TONEGEN -# define PJMEDIA_USE_HIGH_QUALITY_TONEGEN PJ_HAS_FLOATING_POINT +#ifndef PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP +# define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP 7 #endif /** - * Force the tone generation to use floating point computation, even when - * PJ_HAS_FLOATING_POINT is disabled. This may be necessary if the tone - * generator is used to produce DTMF to be sent inband, since the fixed - * point algorithm may not have the correct frequency accuracy. + * Enable high quality of tone generation, the better quality will cost + * more CPU load. This is only applied to floating point enabled machines. * - * This option, combined with PJ_HAS_FLOATING_POINT will produce the - * following selection of tone generator algorithm: - * - if both PJ_HAS_FLOATING_POINT and PJMEDIA_USE_HIGH_QUALITY_TONEGEN - * are set, the standard sin() function will be used. This will produce - * the highest quality tones, at the expense of more processing power. - * - if PJ_HAS_FLOATING_POINT is not set: - * - if both PJMEDIA_USE_HIGH_QUALITY_TONEGEN and - * PJMEDIA_TONEGEN_FORCE_FLOAT are set, sin() based algorithm will - * be used (similar as above). - * - if PJMEDIA_USE_HIGH_QUALITY_TONEGEN is not set but the - * PJMEDIA_TONEGEN_FORCE_FLOAT is set, a floating point approximation - * algorithm will be used. This should produce good enough tone - * for most uses, and the performance is faster than using pure - * sin() based algorithm. Note that linking to math library may - * still be needed. - * - if both are not set, the fixed point approximation algorithm - * will be used. + * By default it is enabled when PJ_HAS_FLOATING_POINT is set. * - * Default: 1 + * This macro has been deprecated in version 1.0-rc3. */ -#ifndef PJMEDIA_TONEGEN_FORCE_FLOAT -# define PJMEDIA_TONEGEN_FORCE_FLOAT 1 +#ifdef PJMEDIA_USE_HIGH_QUALITY_TONEGEN +# error "The PJMEDIA_USE_HIGH_QUALITY_TONEGEN macro is obsolete" #endif |