Ignore:
Timestamp:
Sep 18, 2008 11:14:21 AM (16 years ago)
Author:
bennylp
Message:

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/config.h

    r2290 r2292  
    542542 
    543543 
     544/*  
     545 * Below specifies the various tone generator backend algorithm. 
     546 */ 
     547 
     548/**  
     549 * The math's sine(), floating point. This has very good precision  
     550 * but it's the slowest and requires floating point support and 
     551 * linking with the math library. 
     552 */ 
     553#define PJMEDIA_TONEGEN_SINE                        1 
     554 
     555/** 
     556 * Floating point approximation of sine(). This has relatively good 
     557 * precision and much faster than plain sine(), but it requires floating- 
     558 * point support and linking with the math library. 
     559 */ 
     560#define PJMEDIA_TONEGEN_FLOATING_POINT              2 
     561 
     562/** 
     563 * Fixed point using sine signal generated by Cordic algorithm. This 
     564 * algorithm can be tuned to provide balance between precision and 
     565 * performance by tuning the PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP  
     566 * setting, and may be suitable for platforms that lack floating-point 
     567 * support. 
     568 */ 
     569#define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC          3 
     570 
     571/** 
     572 * Fast fixed point using some approximation to generate sine waves. 
     573 * The tone generated by this algorithm is not very precise, however 
     574 * the algorithm is very fast. 
     575 */ 
     576#define PJMEDIA_TONEGEN_FAST_FIXED_POINT            4 
     577 
     578 
     579/** 
     580 * Specify the tone generator algorithm to be used. 
     581 * 
     582 * Default value: 
     583 *  - PJMEDIA_TONEGEN_FLOATING_POINT when PJ_HAS_FLOATING_POINT is set 
     584 *  - PJMEDIA_TONEGEN_FIXED_POINT_CORDIC when PJ_HAS_FLOATING_POINT is not set 
     585 */ 
     586#ifndef PJMEDIA_TONEGEN_ALG 
     587#   if defined(PJ_HAS_FLOATING_POINT) && PJ_HAS_FLOATING_POINT 
     588#       define PJMEDIA_TONEGEN_ALG      PJMEDIA_TONEGEN_FLOATING_POINT 
     589#   else 
     590#       define PJMEDIA_TONEGEN_ALG      PJMEDIA_TONEGEN_FIXED_POINT_CORDIC 
     591#   endif 
     592#endif 
     593 
     594 
     595/** 
     596 * Specify the number of calculation loops to generate the tone, when 
     597 * PJMEDIA_TONEGEN_FIXED_POINT_CORDIC algorithm is used. With more calculation 
     598 * loops, the tone signal gets more precise, but this will add more  
     599 * processing. 
     600 * 
     601 * Valid values are 1 to 28. 
     602 * 
     603 * Default value: 7 
     604 */ 
     605#ifndef PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP 
     606#   define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP  7 
     607#endif 
     608 
     609 
    544610/** 
    545611 * Enable high quality of tone generation, the better quality will cost 
     
    548614 * By default it is enabled when PJ_HAS_FLOATING_POINT is set. 
    549615 * 
    550  * @see PJMEDIA_TONEGEN_FORCE_FLOAT 
    551  */ 
    552 #ifndef PJMEDIA_USE_HIGH_QUALITY_TONEGEN 
    553 #   define PJMEDIA_USE_HIGH_QUALITY_TONEGEN         PJ_HAS_FLOATING_POINT 
    554 #endif 
    555  
    556  
    557 /** 
    558  * Force the tone generation to use floating point computation, even when 
    559  * PJ_HAS_FLOATING_POINT is disabled. This may be necessary if the tone 
    560  * generator is used to produce DTMF to be sent inband, since the fixed 
    561  * point algorithm may not have the correct frequency accuracy. 
    562  * 
    563  * This option, combined with PJ_HAS_FLOATING_POINT will produce the  
    564  * following selection of tone generator algorithm: 
    565  *  - if both PJ_HAS_FLOATING_POINT and PJMEDIA_USE_HIGH_QUALITY_TONEGEN  
    566  *    are set, the standard sin() function will be used. This will produce 
    567  *    the highest quality tones, at the expense of more processing power. 
    568  *  - if PJ_HAS_FLOATING_POINT is not set: 
    569  *      - if both PJMEDIA_USE_HIGH_QUALITY_TONEGEN and  
    570  *        PJMEDIA_TONEGEN_FORCE_FLOAT are set, sin() based algorithm will 
    571  *        be used (similar as above). 
    572  *      - if PJMEDIA_USE_HIGH_QUALITY_TONEGEN is not set but the 
    573  *        PJMEDIA_TONEGEN_FORCE_FLOAT is set, a floating point approximation 
    574  *        algorithm will be used. This should produce good enough tone 
    575  *        for most uses, and the performance is faster than using pure 
    576  *        sin() based algorithm. Note that linking to math library may 
    577  *        still be needed. 
    578  *      - if both are not set, the fixed point approximation algorithm 
    579  *        will be used. 
    580  * 
    581  * Default: 1 
    582  */ 
    583 #ifndef PJMEDIA_TONEGEN_FORCE_FLOAT 
    584 #   define PJMEDIA_TONEGEN_FORCE_FLOAT              1 
     616 * This macro has been deprecated in version 1.0-rc3. 
     617 */ 
     618#ifdef PJMEDIA_USE_HIGH_QUALITY_TONEGEN 
     619#   error   "The PJMEDIA_USE_HIGH_QUALITY_TONEGEN macro is obsolete" 
    585620#endif 
    586621 
Note: See TracChangeset for help on using the changeset viewer.