Changeset 3261 for pjproject


Ignore:
Timestamp:
Aug 10, 2010 3:06:40 PM (14 years ago)
Author:
nanang
Message:

Fix #1106:

  • Added PCM signal adjustment in IPP G722.1 implementation. The default setting is configurable via (the existing compile-time config) PJMEDIA_G7221_DEFAULT_PCM_SHIFT.
  • Added new APIs to get and set IPP codecs settings: pjmedia_codec_ipp_set/get_config(). At run-time, the G722.1 PCM signal adjustment setting can be set using these functions.
Location:
pjproject/trunk/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia-codec/ipp_codecs.h

    r3083 r3261  
    292292PJ_BEGIN_DECL 
    293293 
     294/**  
     295 * IPP codecs configuration settings. 
     296 */ 
     297typedef struct pjmedia_codec_ipp_config 
     298{ 
     299    /** 
     300     * Specifies the G.722.1 codec encoder and decoder level adjustment.  
     301     * If the value is non-zero, then PCM input samples to the encoder will  
     302     * be shifted right by this value, and similarly PCM output samples from 
     303     * the decoder will be shifted left by this value. 
     304     * 
     305     * Default value is PJMEDIA_G7221_DEFAULT_PCM_SHIFT. 
     306     */ 
     307    unsigned             g7221_pcm_shift; 
     308 
     309} pjmedia_codec_ipp_config; 
     310 
     311 
    294312/** 
    295313 * Initialize and register IPP codecs factory to pjmedia endpoint. 
     
    301319PJ_DECL(pj_status_t) pjmedia_codec_ipp_init( pjmedia_endpt *endpt ); 
    302320 
     321 
     322/** 
     323 * Get current IPP codecs configuration settings. 
     324 * 
     325 * @param cfg       The IPP codecs configuration settings buffer. 
     326 * 
     327 * @return          PJ_SUCCESS on success. 
     328 */ 
     329PJ_DECL(pj_status_t) pjmedia_codec_ipp_get_config( 
     330                                pjmedia_codec_ipp_config *cfg); 
     331 
     332 
     333/** 
     334 * Set IPP codecs configuration settings. 
     335 * 
     336 * @param setting   The IPP codecs configuration settings to be applied. 
     337 * 
     338 * @return          PJ_SUCCESS on success. 
     339 */ 
     340PJ_DECL(pj_status_t) pjmedia_codec_ipp_set_config( 
     341                                const pjmedia_codec_ipp_config *cfg); 
    303342 
    304343 
  • pjproject/trunk/pjmedia/src/pjmedia-codec/ipp_codecs.c

    r3199 r3261  
    113113    pj_pool_t               *pool; 
    114114    pj_mutex_t              *mutex; 
     115    unsigned                 g7221_pcm_shift; 
    115116} ipp_factory; 
    116117 
     
    134135                                                 codec has internal VAD.    */ 
    135136    pj_timestamp         last_tx;           /**< Timestamp of last transmit.*/ 
     137 
     138    unsigned             g7221_pcm_shift;   /**< G722.1 PCM level adjustment*/ 
    136139} ipp_private_t; 
    137140 
     
    661664    ipp_factory.base.factory_data = NULL; 
    662665    ipp_factory.endpt = endpt; 
     666    ipp_factory.g7221_pcm_shift = PJMEDIA_G7221_DEFAULT_PCM_SHIFT; 
    663667 
    664668    ipp_factory.pool = pjmedia_endpt_create_pool(endpt, "IPP codecs", 4000, 4000); 
     
    730734    return status; 
    731735} 
     736 
     737/* 
     738 * Get current IPP codecs configuration settings. 
     739 */ 
     740PJ_DEF(pj_status_t) pjmedia_codec_ipp_get_config( 
     741                                pjmedia_codec_ipp_config *cfg) 
     742{ 
     743    PJ_ASSERT_RETURN(cfg, PJ_EINVAL); 
     744 
     745    pj_bzero(cfg, sizeof(*cfg)); 
     746    cfg->g7221_pcm_shift = ipp_factory.g7221_pcm_shift; 
     747 
     748    return PJ_SUCCESS; 
     749} 
     750 
     751 
     752/* 
     753 * Set IPP codecs configuration settings. 
     754 */ 
     755PJ_DECL(pj_status_t) pjmedia_codec_ipp_set_config( 
     756                                const pjmedia_codec_ipp_config *cfg) 
     757{ 
     758    PJ_ASSERT_RETURN(cfg, PJ_EINVAL); 
     759 
     760    ipp_factory.g7221_pcm_shift = cfg->g7221_pcm_shift; 
     761     
     762    return PJ_SUCCESS; 
     763} 
     764 
    732765 
    733766/*  
     
    12091242#endif 
    12101243 
     1244#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 
     1245    if (ippc->pt >= PJMEDIA_RTP_PT_G722_1_16 &&  
     1246        ippc->pt <= PJMEDIA_RTP_PT_G7221_RSV2) 
     1247    { 
     1248        codec_data->g7221_pcm_shift = ipp_factory.g7221_pcm_shift; 
     1249    } 
     1250#endif 
     1251 
    12111252    return PJ_SUCCESS; 
    12121253 
     
    13621403        if (pt == PJMEDIA_RTP_PT_AMR || pt == PJMEDIA_RTP_PT_AMRWB) { 
    13631404            out.pBuffer += 2; 
     1405        } 
     1406#endif 
     1407 
     1408#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 
     1409        /* For G722.1: adjust the encoder input signal level */ 
     1410        if (pt >= PJMEDIA_RTP_PT_G722_1_16 &&  
     1411            pt <= PJMEDIA_RTP_PT_G7221_RSV2 && 
     1412            codec_data->g7221_pcm_shift) 
     1413        { 
     1414            unsigned i; 
     1415            for (i = 0; i < samples_per_frame; ++i) 
     1416                pcm_in[i] >>= codec_data->g7221_pcm_shift; 
    13641417        } 
    13651418#endif 
     
    15151568#endif 
    15161569 
     1570#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 
     1571    /* For G722.1: adjust the decoder output signal level */ 
     1572    if (pt >= PJMEDIA_RTP_PT_G722_1_16 &&  
     1573        pt <= PJMEDIA_RTP_PT_G7221_RSV2 && 
     1574        codec_data->g7221_pcm_shift) 
     1575    { 
     1576        unsigned i; 
     1577        pj_int16_t *s = (pj_int16_t*)output->buf; 
     1578 
     1579        for (i = 0; i < samples_per_frame; ++i) 
     1580            s[i] <<= codec_data->g7221_pcm_shift; 
     1581    } 
     1582#endif 
     1583 
    15171584    output->type = PJMEDIA_FRAME_TYPE_AUDIO; 
    15181585    output->size = samples_per_frame << 1; 
Note: See TracChangeset for help on using the changeset viewer.