Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c

Issue 1179093003: Reland "Upconvert various types to int.", misc. codecs portion. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 18 matching lines...) Expand all
29 int16_t dec_order; 29 int16_t dec_order;
30 int16_t dec_target_scale_factor; /* Q29 */ 30 int16_t dec_target_scale_factor; /* Q29 */
31 int16_t dec_used_scale_factor; /* Q29 */ 31 int16_t dec_used_scale_factor; /* Q29 */
32 int16_t target_scale_factor; /* Q13 */ 32 int16_t target_scale_factor; /* Q13 */
33 int16_t errorcode; 33 int16_t errorcode;
34 int16_t initflag; 34 int16_t initflag;
35 } WebRtcCngDecoder; 35 } WebRtcCngDecoder;
36 36
37 typedef struct WebRtcCngEncoder_ { 37 typedef struct WebRtcCngEncoder_ {
38 int16_t enc_nrOfCoefs; 38 int16_t enc_nrOfCoefs;
39 uint16_t enc_sampfreq; 39 int enc_sampfreq;
40 int16_t enc_interval; 40 int16_t enc_interval;
41 int16_t enc_msSinceSID; 41 int16_t enc_msSinceSID;
42 int32_t enc_Energy; 42 int32_t enc_Energy;
43 int16_t enc_reflCoefs[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 43 int16_t enc_reflCoefs[WEBRTC_CNG_MAX_LPC_ORDER + 1];
44 int32_t enc_corrVector[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 44 int32_t enc_corrVector[WEBRTC_CNG_MAX_LPC_ORDER + 1];
45 uint32_t enc_seed; 45 uint32_t enc_seed;
46 int16_t errorcode; 46 int16_t errorcode;
47 int16_t initflag; 47 int16_t initflag;
48 } WebRtcCngEncoder; 48 } WebRtcCngEncoder;
49 49
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 * - fs : 8000 for narrowband and 16000 for wideband 135 * - fs : 8000 for narrowband and 16000 for wideband
136 * - interval : generate SID data every interval ms 136 * - interval : generate SID data every interval ms
137 * - quality : TBD 137 * - quality : TBD
138 * 138 *
139 * Output: 139 * Output:
140 * - cng_inst : Initialized instance 140 * - cng_inst : Initialized instance
141 * 141 *
142 * Return value : 0 - Ok 142 * Return value : 0 - Ok
143 * -1 - Error 143 * -1 - Error
144 */ 144 */
145 int16_t WebRtcCng_InitEnc(CNG_enc_inst* cng_inst, uint16_t fs, int16_t interval, 145 int WebRtcCng_InitEnc(CNG_enc_inst* cng_inst, int fs, int16_t interval,
146 int16_t quality) { 146 int16_t quality) {
147 int i; 147 int i;
148 WebRtcCngEncoder* inst = (WebRtcCngEncoder*) cng_inst; 148 WebRtcCngEncoder* inst = (WebRtcCngEncoder*) cng_inst;
149 memset(inst, 0, sizeof(WebRtcCngEncoder)); 149 memset(inst, 0, sizeof(WebRtcCngEncoder));
150 150
151 /* Check LPC order */ 151 /* Check LPC order */
152 if (quality > WEBRTC_CNG_MAX_LPC_ORDER || quality <= 0) { 152 if (quality > WEBRTC_CNG_MAX_LPC_ORDER || quality <= 0) {
153 inst->errorcode = CNG_DISALLOWED_LPC_ORDER; 153 inst->errorcode = CNG_DISALLOWED_LPC_ORDER;
154 return -1; 154 return -1;
155 } 155 }
156 156
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 * 220 *
221 * Input: 221 * Input:
222 * - cng_inst : Pointer to created instance 222 * - cng_inst : Pointer to created instance
223 * - speech : Signal (noise) to be analyzed 223 * - speech : Signal (noise) to be analyzed
224 * - nrOfSamples : Size of speech vector 224 * - nrOfSamples : Size of speech vector
225 * - bytesOut : Nr of bytes to transmit, might be 0 225 * - bytesOut : Nr of bytes to transmit, might be 0
226 * 226 *
227 * Return value : 0 - Ok 227 * Return value : 0 - Ok
228 * -1 - Error 228 * -1 - Error
229 */ 229 */
230 int16_t WebRtcCng_Encode(CNG_enc_inst* cng_inst, int16_t* speech, 230 int WebRtcCng_Encode(CNG_enc_inst* cng_inst, int16_t* speech,
231 int16_t nrOfSamples, uint8_t* SIDdata, 231 int16_t nrOfSamples, uint8_t* SIDdata,
232 int16_t* bytesOut, int16_t forceSID) { 232 int16_t* bytesOut, int16_t forceSID) {
233 WebRtcCngEncoder* inst = (WebRtcCngEncoder*) cng_inst; 233 WebRtcCngEncoder* inst = (WebRtcCngEncoder*) cng_inst;
234 234
235 int16_t arCoefs[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 235 int16_t arCoefs[WEBRTC_CNG_MAX_LPC_ORDER + 1];
236 int32_t corrVector[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 236 int32_t corrVector[WEBRTC_CNG_MAX_LPC_ORDER + 1];
237 int16_t refCs[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 237 int16_t refCs[WEBRTC_CNG_MAX_LPC_ORDER + 1];
238 int16_t hanningW[WEBRTC_CNG_MAX_OUTSIZE_ORDER]; 238 int16_t hanningW[WEBRTC_CNG_MAX_OUTSIZE_ORDER];
239 int16_t ReflBeta = 19661; /* 0.6 in q15. */ 239 int16_t ReflBeta = 19661; /* 0.6 in q15. */
240 int16_t ReflBetaComp = 13107; /* 0.4 in q15. */ 240 int16_t ReflBetaComp = 13107; /* 0.4 in q15. */
241 int32_t outEnergy; 241 int32_t outEnergy;
242 int outShifts; 242 int outShifts;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } else { 381 } else {
382 for (i = 0; i < inst->enc_nrOfCoefs; i++) { 382 for (i = 0; i < inst->enc_nrOfCoefs; i++) {
383 /* Q15 to Q7 with rounding. */ 383 /* Q15 to Q7 with rounding. */
384 SIDdata[i + 1] = (127 + ((inst->enc_reflCoefs[i] + 128) >> 8)); 384 SIDdata[i + 1] = (127 + ((inst->enc_reflCoefs[i] + 128) >> 8));
385 } 385 }
386 } 386 }
387 387
388 inst->enc_msSinceSID = 0; 388 inst->enc_msSinceSID = 0;
389 *bytesOut = inst->enc_nrOfCoefs + 1; 389 *bytesOut = inst->enc_nrOfCoefs + 1;
390 390
391 inst->enc_msSinceSID += (1000 * nrOfSamples) / inst->enc_sampfreq; 391 inst->enc_msSinceSID +=
392 (int16_t)((1000 * nrOfSamples) / inst->enc_sampfreq);
392 return inst->enc_nrOfCoefs + 1; 393 return inst->enc_nrOfCoefs + 1;
393 } else { 394 } else {
394 inst->enc_msSinceSID += (1000 * nrOfSamples) / inst->enc_sampfreq; 395 inst->enc_msSinceSID +=
396 (int16_t)((1000 * nrOfSamples) / inst->enc_sampfreq);
395 *bytesOut = 0; 397 *bytesOut = 0;
396 return 0; 398 return 0;
397 } 399 }
398 } 400 }
399 401
400 /**************************************************************************** 402 /****************************************************************************
401 * WebRtcCng_UpdateSid(...) 403 * WebRtcCng_UpdateSid(...)
402 * 404 *
403 * These functions updates the CN state, when a new SID packet arrives 405 * These functions updates the CN state, when a new SID packet arrives
404 * 406 *
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 /* Typecast pointer to real structure. */ 595 /* Typecast pointer to real structure. */
594 WebRtcCngEncoder* inst = (WebRtcCngEncoder*) cng_inst; 596 WebRtcCngEncoder* inst = (WebRtcCngEncoder*) cng_inst;
595 return inst->errorcode; 597 return inst->errorcode;
596 } 598 }
597 599
598 int16_t WebRtcCng_GetErrorCodeDec(CNG_dec_inst* cng_inst) { 600 int16_t WebRtcCng_GetErrorCodeDec(CNG_dec_inst* cng_inst) {
599 /* Typecast pointer to real structure. */ 601 /* Typecast pointer to real structure. */
600 WebRtcCngDecoder* inst = (WebRtcCngDecoder*) cng_inst; 602 WebRtcCngDecoder* inst = (WebRtcCngDecoder*) cng_inst;
601 return inst->errorcode; 603 return inst->errorcode;
602 } 604 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h ('k') | webrtc/modules/audio_coding/codecs/g722/g722_interface.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698