Ignore:
Timestamp:
Sep 6, 2019 5:20:32 AM (5 years ago)
Author:
nanang
Message:

Re #2228: Also updated PCM shifting in G722.1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/g7221.c

    r5060 r6065  
    168168    pj_uint16_t          frame_size_bits;   /**< Coded frame size in bits.  */ 
    169169    pj_uint16_t          number_of_regions; /**< Number of regions.         */ 
    170     int                  pcm_shift;         /**< Adjustment for PCM in/out  */ 
     170    pj_int16_t           pcm_shift_val;     /**< Adjustment for PCM in/out  */ 
    171171     
    172172    /* Encoder specific state */ 
     
    700700                                    (attr->info.clock_rate <= WB_SAMPLE_RATE? 
    701701                                     NUMBER_OF_REGIONS:MAX_NUMBER_OF_REGIONS); 
    702     codec_data->pcm_shift = codec_factory.pcm_shift; 
     702    codec_data->pcm_shift_val =  1 << (pj_int16_t)codec_factory.pcm_shift; 
    703703 
    704704    /* Initialize encoder state */ 
     
    845845 
    846846        /* Encoder adjust the input signal level */ 
    847         if (codec_data->pcm_shift) { 
     847        if (codec_data->pcm_shift_val > 1) { 
    848848            unsigned i; 
    849849            for (i=0; i<codec_data->samples_per_frame; ++i) { 
    850850                codec_data->enc_frame[i] =  
    851                         (Word16)(pcm_input[i] >> codec_data->pcm_shift); 
     851                        (Word16)(pcm_input[i] / codec_data->pcm_shift_val); 
    852852            } 
    853853            pcm_input = codec_data->enc_frame; 
     
    944944 
    945945    /* Decoder adjust PCM signal */ 
    946     if (codec_data->pcm_shift) { 
     946    if (codec_data->pcm_shift_val > 1) { 
    947947        unsigned i; 
    948948        pj_int16_t *buf = (Word16*)output->buf; 
    949949 
    950950        for (i=0; i<codec_data->samples_per_frame; ++i) { 
    951             buf[i] <<= codec_data->pcm_shift; 
     951            buf[i] = buf[i] * codec_data->pcm_shift_val; 
    952952        } 
    953953    } 
Note: See TracChangeset for help on using the changeset viewer.