Changeset 2620 for pjproject/trunk
- Timestamp:
- Apr 20, 2009 2:19:11 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia-codec/config.h
r2563 r2620 238 238 */ 239 239 #ifndef PJMEDIA_HAS_G7221_CODEC 240 # define PJMEDIA_HAS_G7221_CODEC 0 241 #endif 240 # define PJMEDIA_HAS_G7221_CODEC 0 241 #endif 242 243 /** 244 * Default G.722.1 codec encoder and decoder level adjustment. 245 * If the value is non-zero, then PCM input samples to the encoder will 246 * be shifted right by this value, and similarly PCM output samples from 247 * the decoder will be shifted left by this value. 248 * 249 * This can be changed at run-time after initialization by calling 250 * #pjmedia_codec_g7221_set_pcm_shift(). 251 */ 252 #ifndef PJMEDIA_G7221_DEFAULT_PCM_SHIFT 253 # define PJMEDIA_G7221_DEFAULT_PCM_SHIFT 1 254 #endif 255 242 256 243 257 -
pjproject/trunk/pjmedia/include/pjmedia-codec/g7221.h
r2563 r2620 94 94 pj_bool_t enabled); 95 95 96 /** 97 * Set the G.722.1 codec encoder and decoder level adjustment. 98 * If the value is non-zero, then PCM input samples to the encoder will 99 * be shifted right by this value, and similarly PCM output samples from 100 * the decoder will be shifted left by this value. 101 * 102 * Default value is PJMEDIA_G7221_DEFAULT_PCM_SHIFT. 103 * 104 * @param val The value 105 * 106 * @return PJ_SUCCESS on success. 107 */ 108 PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val); 109 110 96 111 97 112 /** -
pjproject/trunk/pjmedia/src/pjmedia-codec/g7221.c
r2616 r2620 138 138 pj_mutex_t *mutex; /**< Codec factory mutex. */ 139 139 140 int pcm_shift; /**< Level adjustment */ 140 141 unsigned mode_count; /**< Number of G722.1 modes. */ 141 142 codec_mode modes[MAX_CODEC_MODES]; /**< The G722.1 modes. */ … … 165 166 pj_uint16_t frame_size_bits; /**< Coded frame size in bits. */ 166 167 pj_uint16_t number_of_regions; /**< Number of regions. */ 168 int pcm_shift; /**< Adjustment for PCM in/out */ 167 169 168 170 /* Encoder specific state */ 171 Word16 *enc_frame; /**< 16bit to 14bit buffer */ 169 172 Word16 *enc_old_frame; 170 173 … … 252 255 /* Initialize codec modes, by default all standard bitrates are enabled */ 253 256 codec_factory.mode_count = 0; 257 codec_factory.pcm_shift = PJMEDIA_G7221_DEFAULT_PCM_SHIFT; 254 258 255 259 mode = &codec_factory.modes[codec_factory.mode_count++]; … … 409 413 410 414 /* 415 * Set level adjustment. 416 */ 417 PJ_DEF(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val) 418 { 419 codec_factory.pcm_shift = val; 420 return PJ_SUCCESS; 421 } 422 423 /* 411 424 * Unregister G722.1 codec factory from pjmedia endpoint. 412 425 */ … … 645 658 (attr->info.clock_rate <= WB_SAMPLE_RATE? 646 659 NUMBER_OF_REGIONS:MAX_NUMBER_OF_REGIONS); 660 codec_data->pcm_shift = codec_factory.pcm_shift; 647 661 648 662 /* Initialize encoder state */ 649 663 tmp = codec_data->samples_per_frame << 1; 650 664 codec_data->enc_old_frame = (Word16*)pj_pool_zalloc(pool, tmp); 665 codec_data->enc_frame = (Word16*)pj_pool_alloc(pool, tmp); 651 666 652 667 /* Initialize decoder state */ … … 734 749 { 735 750 codec_private_t *codec_data = (codec_private_t*) codec->codec_data; 751 const Word16 *pcm_input; 736 752 Word16 mlt_coefs[MAX_SAMPLES_PER_FRAME]; 737 753 Word16 mag_shift; … … 773 789 } 774 790 791 /* Encoder adjust the input signal level */ 792 if (codec_data->pcm_shift) { 793 unsigned i; 794 pcm_input = (const Word16*)input->buf; 795 for (i=0; i<codec_data->samples_per_frame; ++i) { 796 codec_data->enc_frame[i] = 797 (pj_int16_t)(pcm_input[i] >> codec_data->pcm_shift); 798 } 799 pcm_input = codec_data->enc_frame; 800 } else { 801 pcm_input = (const Word16*)input->buf; 802 } 803 775 804 /* Convert input samples to rmlt coefs */ 776 mag_shift = samples_to_rmlt_coefs( (Word16*)input->buf,805 mag_shift = samples_to_rmlt_coefs(pcm_input, 777 806 codec_data->enc_old_frame, 778 807 mlt_coefs, … … 856 885 mag_shift); 857 886 887 /* Decoder adjust PCM signal */ 888 if (codec_data->pcm_shift) { 889 unsigned i; 890 pj_int16_t *buf = (Word16*)output->buf; 891 892 for (i=0; i<codec_data->samples_per_frame; ++i) { 893 buf[i] <<= codec_data->pcm_shift; 894 } 895 } 896 858 897 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 859 898 output->size = codec_data->samples_per_frame << 1; -
pjproject/trunk/pjmedia/src/test/codec_vectors.c
r2615 r2620 573 573 return -7; 574 574 } 575 576 /* Set shift value to zero for the test vectors */ 577 pjmedia_codec_g7221_set_pcm_shift(0); 575 578 #endif 576 579 -
pjproject/trunk/third_party/g7221/common/defs.h
r2563 r2620 141 141 Word16 frame_error_flag); 142 142 143 Word16 samples_to_rmlt_coefs( Word16 *new_samples,Word16 *history,Word16 *coefs,Word16 dct_length);143 Word16 samples_to_rmlt_coefs(const Word16 *new_samples,Word16 *history,Word16 *coefs,Word16 dct_length); 144 144 void rmlt_coefs_to_samples(Word16 *coefs, 145 145 Word16 *old_samples, -
pjproject/trunk/third_party/g7221/encode/sam2coef.c
r2616 r2620 66 66 ***************************************************************************/ 67 67 68 Word16 samples_to_rmlt_coefs( Word16 *new_samples,Word16 *old_samples,Word16 *coefs,Word16 dct_length)68 Word16 samples_to_rmlt_coefs(const Word16 *new_samples,Word16 *old_samples,Word16 *coefs,Word16 dct_length) 69 69 { 70 70 71 71 Word16 index, vals_left,mag_shift,n; 72 72 Word16 windowed_data[MAX_DCT_LENGTH]; 73 Word16 *new_ptr, *old_ptr, *sam_low, *sam_high; 73 Word16 *old_ptr; 74 const Word16 *new_ptr, *sam_low, *sam_high; 74 75 Word16 *win_low, *win_high; 75 76 Word16 *dst_ptr;
Note: See TracChangeset
for help on using the changeset viewer.