Changeset 347 for pjproject/trunk


Ignore:
Timestamp:
Mar 21, 2006 11:59:15 AM (19 years ago)
Author:
bennylp
Message:

Added macro to exclude filters in resample and added options to select resample algorithm in conference

Location:
pjproject/trunk
Files:
7 edited

Legend:

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

    r333 r347  
    6262                                     microphone device.                     */ 
    6363    PJMEDIA_CONF_NO_DEVICE = 2, /**< Do not create sound device.            */ 
     64    PJMEDIA_CONF_SMALL_FILTER=4,/**< Use small filter table when resampling */ 
     65    PJMEDIA_CONF_USE_LINEAR=8,  /**< Use linear resampling instead of filter 
     66                                     based.                                 */ 
    6467}; 
    6568 
  • pjproject/trunk/pjmedia/include/pjmedia/config.h

    r320 r347  
    4242/** 
    4343 * Unless specified otherwise, G711 codec is included by default. 
     44 * Note that there are parts of G711 codec (such as linear2ulaw) that are  
     45 * needed by other PJMEDIA components (e.g. silence detector, conference). 
     46 * Thus disabling G711 is generally not a good idea. 
    4447 */ 
    4548#ifndef PJMEDIA_HAS_G711_CODEC 
     
    4851 
    4952 
     53/** 
     54 * Include small filter table in resample. 
     55 * This adds about 9KB in rdata. 
     56 */ 
     57#ifndef PJMEDIA_HAS_SMALL_FILTER 
     58#   define PJMEDIA_HAS_SMALL_FILTER         1 
     59#endif 
     60 
     61 
     62/** 
     63 * Include large filter table in resample. 
     64 * This adds about 32KB in rdata. 
     65 */ 
     66#ifndef PJMEDIA_HAS_LARGE_FILTER 
     67#   define PJMEDIA_HAS_LARGE_FILTER         1 
     68#endif 
     69 
     70 
    5071#endif  /* __PJMEDIA_CONFIG_H__ */ 
     72 
  • pjproject/trunk/pjmedia/src/pjmedia/conference.c

    r333 r347  
    238238    if (conf_port->clock_rate != conf->clock_rate) { 
    239239 
    240         double factor; 
    241  
    242         factor = 1.0 * conf_port->clock_rate / conf->clock_rate; 
     240        pj_bool_t high_quality; 
     241        pj_bool_t large_filter; 
     242 
     243        high_quality = ((conf->options & PJMEDIA_CONF_USE_LINEAR)==0); 
     244        large_filter = ((conf->options & PJMEDIA_CONF_SMALL_FILTER)==0); 
    243245 
    244246        /* Create resample for rx buffer. */ 
    245247        status = pjmedia_resample_create( pool,  
    246                                           PJ_TRUE,  /* High quality */ 
    247                                           PJ_TRUE,  /* Large filter */ 
     248                                          high_quality, 
     249                                          large_filter, 
    248250                                          conf_port->clock_rate,/* Rate in */ 
    249251                                          conf->clock_rate, /* Rate out */ 
    250                                           (unsigned)(conf->samples_per_frame *  
    251                                                      factor), 
     252                                          conf->samples_per_frame *  
     253                                            conf_port->clock_rate / 
     254                                            conf->clock_rate, 
    252255                                          &conf_port->rx_resample); 
    253256        if (status != PJ_SUCCESS) 
     
    257260        /* Create resample for tx buffer. */ 
    258261        status = pjmedia_resample_create(pool, 
    259                                          PJ_TRUE,   /* High quality */ 
    260                                          PJ_TRUE,   /* Large filter */ 
     262                                         high_quality, 
     263                                         large_filter, 
    261264                                         conf->clock_rate,  /* Rate in */ 
    262265                                         conf_port->clock_rate, /* Rate out */ 
  • pjproject/trunk/pjmedia/src/pjmedia/largefilter.h

    r277 r347  
    33#define LARGE_FILTER_SCALE 14746 /* Unity-gain scale factor */ 
    44#define LARGE_FILTER_NWING 8192 /* Filter table length */ 
    5 static HWORD LARGE_FILTER_IMP[] /* Impulse response */ = { 
     5static const HWORD LARGE_FILTER_IMP[] /* Impulse response */ = { 
    6632767, 
    7732766, 
     
    819781970}; 
    81988198 
    8199 static HWORD LARGE_FILTER_IMPD[] /* Impulse response differences */ = { 
     8199static const HWORD LARGE_FILTER_IMPD[] /* Impulse response differences */ = { 
    82008200-1, 
    82018201-2, 
  • pjproject/trunk/pjmedia/src/pjmedia/resample.c

    r323 r347  
    6666#include <pjmedia/errno.h> 
    6767#include <pj/assert.h> 
     68#include <pj/log.h> 
    6869#include <pj/pool.h> 
    6970 
     71 
     72#define THIS_FILE   "resample.c" 
    7073 
    7174 
     
    192195#endif 
    193196 
    194 #include "smallfilter.h" 
    195 #include "largefilter.h" 
     197#if defined(PJMEDIA_HAS_SMALL_FILTER) && PJMEDIA_HAS_SMALL_FILTER!=0 
     198#   include "smallfilter.h" 
     199#else 
     200#   define SMALL_FILTER_NMULT   0 
     201#   define SMALL_FILTER_SCALE   0 
     202#   define SMALL_FILTER_NWING   0 
     203#   define SMALL_FILTER_IMP     NULL 
     204#   define SMALL_FILTER_IMPD    NULL 
     205#endif 
     206 
     207#if defined(PJMEDIA_HAS_LARGE_FILTER) && PJMEDIA_HAS_LARGE_FILTER!=0 
     208#   include "largefilter.h" 
     209#else 
     210#   define LARGE_FILTER_NMULT   0 
     211#   define LARGE_FILTER_SCALE   0 
     212#   define LARGE_FILTER_NWING   0 
     213#   define LARGE_FILTER_IMP     NULL 
     214#   define LARGE_FILTER_IMPD    NULL 
     215#endif 
     216 
    196217 
    197218#undef INLINE 
     
    481502    } 
    482503 
     504#if !defined(PJMEDIA_HAS_LARGE_FILTER) || PJMEDIA_HAS_LARGE_FILTER==0 
     505    /* 
     506     * If large filter is excluded in the build, then prevent application 
     507     * from using it. 
     508     */ 
     509    if (high_quality && large_filter) { 
     510        large_filter = PJ_FALSE; 
     511        PJ_LOG(5,(THIS_FILE,  
     512                  "Resample uses small filter because large filter is " 
     513                  "disabled")); 
     514    } 
     515#endif 
     516 
     517#if !defined(PJMEDIA_HAS_SMALL_FILTER) || PJMEDIA_HAS_SMALL_FILTER==0 
     518    /* 
     519     * If small filter is excluded in the build and application wants to 
     520     * use it, then drop to linear conversion. 
     521     */ 
     522    if (high_quality && large_filter == 0) { 
     523        high_quality = PJ_FALSE; 
     524        PJ_LOG(4,(THIS_FILE,  
     525                  "Resample uses linear because small filter is disabled")); 
     526    } 
     527#endif 
     528 
    483529    resample->factor = rate_out * 1.0 / rate_in; 
    484530    resample->large_filter = large_filter; 
  • pjproject/trunk/pjmedia/src/pjmedia/smallfilter.h

    r277 r347  
    33#define SMALL_FILTER_SCALE 13128 /* Unity-gain scale factor */ 
    44#define SMALL_FILTER_NWING 1536 /* Filter table length */ 
    5 static HWORD SMALL_FILTER_IMP[] /* Impulse response */ = { 
     5static const HWORD SMALL_FILTER_IMP[] /* Impulse response */ = { 
    6632767, 
    7732766, 
     
    15421542}; 
    15431543 
    1544 static HWORD SMALL_FILTER_IMPD[] = { 
     1544static const HWORD SMALL_FILTER_IMPD[] = { 
    15451545-1, 
    15461546-2, 
  • pjproject/trunk/pjsip-apps/build/samples.dsp

    r336 r347  
    9191# Begin Source File 
    9292 
     93SOURCE=..\src\samples\level.c 
     94# End Source File 
     95# Begin Source File 
     96 
    9397SOURCE=..\src\samples\playfile.c 
    9498# End Source File 
     
    100104 
    101105SOURCE=..\src\samples\simpleua.c 
     106# End Source File 
     107# Begin Source File 
     108 
     109SOURCE=..\src\samples\sndinfo.c 
    102110# End Source File 
    103111# End Group 
Note: See TracChangeset for help on using the changeset viewer.