2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
14 * This C file contains the functions for the ISAC API
18 #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h"
23 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h"
24 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
25 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h"
26 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h"
27 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h"
28 #include "webrtc/modules/audio_coding/codecs/isac/fix/source/structs.h"
29 #include "webrtc/system_wrappers/interface/cpu_features_wrapper.h"
31 // Declare function pointers.
32 FilterMaLoopFix WebRtcIsacfix_FilterMaLoopFix;
33 Spec2Time WebRtcIsacfix_Spec2Time;
34 Time2Spec WebRtcIsacfix_Time2Spec;
35 MatrixProduct1 WebRtcIsacfix_MatrixProduct1;
36 MatrixProduct2 WebRtcIsacfix_MatrixProduct2;
38 /* This method assumes that |stream_size_bytes| is in valid range,
39 * i.e. >= 0 && <= STREAM_MAXW16_60MS
41 static void InitializeDecoderBitstream(int stream_size_bytes,
42 Bitstr_dec* bitstream) {
43 bitstream->W_upper = 0xFFFFFFFF;
44 bitstream->streamval = 0;
45 bitstream->stream_index = 0;
47 bitstream->stream_size = (stream_size_bytes + 1) >> 1;
48 memset(bitstream->stream, 0, sizeof(bitstream->stream));
51 /**************************************************************************
52 * WebRtcIsacfix_AssignSize(...)
54 * Functions used when malloc is not allowed
55 * Returns number of bytes needed to allocate for iSAC struct.
59 int16_t WebRtcIsacfix_AssignSize(int *sizeinbytes) {
60 *sizeinbytes=sizeof(ISACFIX_SubStruct)*2/sizeof(int16_t);
64 /***************************************************************************
65 * WebRtcIsacfix_Assign(...)
67 * Functions used when malloc is not allowed
68 * Place struct at given address
70 * If successful, Return 0, else Return -1
73 int16_t WebRtcIsacfix_Assign(ISACFIX_MainStruct **inst, void *ISACFIX_inst_Addr) {
74 if (ISACFIX_inst_Addr!=NULL) {
75 *inst = (ISACFIX_MainStruct*)ISACFIX_inst_Addr;
76 (*(ISACFIX_SubStruct**)inst)->errorcode = 0;
77 (*(ISACFIX_SubStruct**)inst)->initflag = 0;
78 (*(ISACFIX_SubStruct**)inst)->ISACenc_obj.SaveEnc_ptr = NULL;
86 #ifndef ISACFIX_NO_DYNAMIC_MEM
88 /****************************************************************************
89 * WebRtcIsacfix_Create(...)
91 * This function creates a ISAC instance, which will contain the state
92 * information for one coding/decoding channel.
95 * - *ISAC_main_inst : a pointer to the coder instance.
97 * Return value : 0 - Ok
101 int16_t WebRtcIsacfix_Create(ISACFIX_MainStruct **ISAC_main_inst)
103 ISACFIX_SubStruct *tempo;
104 tempo = malloc(1 * sizeof(ISACFIX_SubStruct));
105 *ISAC_main_inst = (ISACFIX_MainStruct *)tempo;
106 if (*ISAC_main_inst!=NULL) {
107 (*(ISACFIX_SubStruct**)ISAC_main_inst)->errorcode = 0;
108 (*(ISACFIX_SubStruct**)ISAC_main_inst)->initflag = 0;
109 (*(ISACFIX_SubStruct**)ISAC_main_inst)->ISACenc_obj.SaveEnc_ptr = NULL;
118 /****************************************************************************
119 * WebRtcIsacfix_CreateInternal(...)
121 * This function creates the memory that is used to store data in the encoder
124 * - *ISAC_main_inst : a pointer to the coder instance.
126 * Return value : 0 - Ok
130 int16_t WebRtcIsacfix_CreateInternal(ISACFIX_MainStruct *ISAC_main_inst)
132 ISACFIX_SubStruct *ISAC_inst;
134 /* typecast pointer to real structure */
135 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
137 /* Allocate memory for storing encoder data */
138 ISAC_inst->ISACenc_obj.SaveEnc_ptr = malloc(1 * sizeof(ISAC_SaveEncData_t));
140 if (ISAC_inst->ISACenc_obj.SaveEnc_ptr!=NULL) {
152 /****************************************************************************
153 * WebRtcIsacfix_Free(...)
155 * This function frees the ISAC instance created at the beginning.
158 * - ISAC_main_inst : a ISAC instance.
160 * Return value : 0 - Ok
164 int16_t WebRtcIsacfix_Free(ISACFIX_MainStruct *ISAC_main_inst)
166 free(ISAC_main_inst);
170 /****************************************************************************
171 * WebRtcIsacfix_FreeInternal(...)
173 * This function frees the internal memory for storing encoder data.
176 * - ISAC_main_inst : a ISAC instance.
178 * Return value : 0 - Ok
182 int16_t WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct *ISAC_main_inst)
184 ISACFIX_SubStruct *ISAC_inst;
186 /* typecast pointer to real structure */
187 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
190 free(ISAC_inst->ISACenc_obj.SaveEnc_ptr);
195 /****************************************************************************
196 * WebRtcIsacfix_InitNeon(...)
198 * This function initializes function pointers for ARM Neon platform.
201 #if (defined WEBRTC_DETECT_ARM_NEON || defined WEBRTC_ARCH_ARM_NEON)
202 static void WebRtcIsacfix_InitNeon(void) {
203 WebRtcIsacfix_AutocorrFix = WebRtcIsacfix_AutocorrNeon;
204 WebRtcIsacfix_FilterMaLoopFix = WebRtcIsacfix_FilterMaLoopNeon;
205 WebRtcIsacfix_Spec2Time = WebRtcIsacfix_Spec2TimeNeon;
206 WebRtcIsacfix_Time2Spec = WebRtcIsacfix_Time2SpecNeon;
207 WebRtcIsacfix_CalculateResidualEnergy =
208 WebRtcIsacfix_CalculateResidualEnergyNeon;
209 WebRtcIsacfix_AllpassFilter2FixDec16 =
210 WebRtcIsacfix_AllpassFilter2FixDec16Neon;
211 WebRtcIsacfix_MatrixProduct1 = WebRtcIsacfix_MatrixProduct1Neon;
212 WebRtcIsacfix_MatrixProduct2 = WebRtcIsacfix_MatrixProduct2Neon;
216 /****************************************************************************
217 * WebRtcIsacfix_InitMIPS(...)
219 * This function initializes function pointers for MIPS platform.
222 #if defined(MIPS32_LE)
223 static void WebRtcIsacfix_InitMIPS(void) {
224 WebRtcIsacfix_AutocorrFix = WebRtcIsacfix_AutocorrMIPS;
225 WebRtcIsacfix_FilterMaLoopFix = WebRtcIsacfix_FilterMaLoopMIPS;
226 WebRtcIsacfix_Spec2Time = WebRtcIsacfix_Spec2TimeMIPS;
227 WebRtcIsacfix_Time2Spec = WebRtcIsacfix_Time2SpecMIPS;
228 WebRtcIsacfix_MatrixProduct1 = WebRtcIsacfix_MatrixProduct1MIPS;
229 WebRtcIsacfix_MatrixProduct2 = WebRtcIsacfix_MatrixProduct2MIPS;
230 #if defined(MIPS_DSP_R1_LE)
231 WebRtcIsacfix_AllpassFilter2FixDec16 =
232 WebRtcIsacfix_AllpassFilter2FixDec16MIPS;
233 WebRtcIsacfix_HighpassFilterFixDec32 =
234 WebRtcIsacfix_HighpassFilterFixDec32MIPS;
236 #if defined(MIPS_DSP_R2_LE)
237 WebRtcIsacfix_CalculateResidualEnergy =
238 WebRtcIsacfix_CalculateResidualEnergyMIPS;
243 /****************************************************************************
244 * WebRtcIsacfix_EncoderInit(...)
246 * This function initializes a ISAC instance prior to the encoder calls.
249 * - ISAC_main_inst : ISAC instance.
250 * - CodingMode : 0 -> Bit rate and frame length are automatically
251 * adjusted to available bandwidth on
252 * transmission channel.
253 * 1 -> User sets a frame length and a target bit
254 * rate which is taken as the maximum short-term
257 * Return value : 0 - Ok
261 int16_t WebRtcIsacfix_EncoderInit(ISACFIX_MainStruct *ISAC_main_inst,
266 ISACFIX_SubStruct *ISAC_inst;
269 /* typecast pointer to rela structure */
270 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
272 /* flag encoder init */
273 ISAC_inst->initflag |= 2;
277 ISAC_inst->ISACenc_obj.new_framelength = INITIAL_FRAMESAMPLES;
278 else if (CodingMode == 1)
279 /* Instantaneous mode */
280 ISAC_inst->ISACenc_obj.new_framelength = 480; /* default for I-mode */
282 ISAC_inst->errorcode = ISAC_DISALLOWED_CODING_MODE;
286 ISAC_inst->CodingMode = CodingMode;
288 WebRtcIsacfix_InitMaskingEnc(&ISAC_inst->ISACenc_obj.maskfiltstr_obj);
289 WebRtcIsacfix_InitPreFilterbank(&ISAC_inst->ISACenc_obj.prefiltbankstr_obj);
290 WebRtcIsacfix_InitPitchFilter(&ISAC_inst->ISACenc_obj.pitchfiltstr_obj);
291 WebRtcIsacfix_InitPitchAnalysis(&ISAC_inst->ISACenc_obj.pitchanalysisstr_obj);
294 WebRtcIsacfix_InitBandwidthEstimator(&ISAC_inst->bwestimator_obj);
295 WebRtcIsacfix_InitRateModel(&ISAC_inst->ISACenc_obj.rate_data_obj);
298 ISAC_inst->ISACenc_obj.buffer_index = 0;
299 ISAC_inst->ISACenc_obj.frame_nb = 0;
300 ISAC_inst->ISACenc_obj.BottleNeck = 32000; /* default for I-mode */
301 ISAC_inst->ISACenc_obj.MaxDelay = 10; /* default for I-mode */
302 ISAC_inst->ISACenc_obj.current_framesamples = 0;
303 ISAC_inst->ISACenc_obj.s2nr = 0;
304 ISAC_inst->ISACenc_obj.MaxBits = 0;
305 ISAC_inst->ISACenc_obj.bitstr_seed = 4447;
306 ISAC_inst->ISACenc_obj.payloadLimitBytes30 = STREAM_MAXW16_30MS << 1;
307 ISAC_inst->ISACenc_obj.payloadLimitBytes60 = STREAM_MAXW16_60MS << 1;
308 ISAC_inst->ISACenc_obj.maxPayloadBytes = STREAM_MAXW16_60MS << 1;
309 ISAC_inst->ISACenc_obj.maxRateInBytes = STREAM_MAXW16_30MS << 1;
310 ISAC_inst->ISACenc_obj.enforceFrameSize = 0;
312 /* Init the bistream data area to zero */
313 for (k=0; k<STREAM_MAXW16_60MS; k++){
314 ISAC_inst->ISACenc_obj.bitstr_obj.stream[k] = 0;
317 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
318 WebRtcIsacfix_InitPostFilterbank(&ISAC_inst->ISACenc_obj.interpolatorstr_obj);
321 // Initiaze function pointers.
322 WebRtcIsacfix_AutocorrFix = WebRtcIsacfix_AutocorrC;
323 WebRtcIsacfix_FilterMaLoopFix = WebRtcIsacfix_FilterMaLoopC;
324 WebRtcIsacfix_CalculateResidualEnergy =
325 WebRtcIsacfix_CalculateResidualEnergyC;
326 WebRtcIsacfix_AllpassFilter2FixDec16 = WebRtcIsacfix_AllpassFilter2FixDec16C;
327 WebRtcIsacfix_HighpassFilterFixDec32 = WebRtcIsacfix_HighpassFilterFixDec32C;
328 WebRtcIsacfix_Time2Spec = WebRtcIsacfix_Time2SpecC;
329 WebRtcIsacfix_Spec2Time = WebRtcIsacfix_Spec2TimeC;
330 WebRtcIsacfix_MatrixProduct1 = WebRtcIsacfix_MatrixProduct1C;
331 WebRtcIsacfix_MatrixProduct2 = WebRtcIsacfix_MatrixProduct2C;
333 #ifdef WEBRTC_DETECT_ARM_NEON
334 if ((WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) != 0) {
335 WebRtcIsacfix_InitNeon();
337 #elif defined(WEBRTC_ARCH_ARM_NEON)
338 WebRtcIsacfix_InitNeon();
341 #if defined(MIPS32_LE)
342 WebRtcIsacfix_InitMIPS();
348 /* Read the given number of bytes of big-endian 16-bit integers from |src| and
349 write them to |dest| in host endian. If |nbytes| is odd, the number of
350 output elements is rounded up, and the least significant byte of the last
351 element is set to 0. */
352 static void read_be16(const uint8_t* src, size_t nbytes, uint16_t* dest) {
354 for (i = 0; i < nbytes / 2; ++i)
355 dest[i] = src[2 * i] << 8 | src[2 * i + 1];
357 dest[nbytes / 2] = src[nbytes - 1] << 8;
360 /* Read the given number of bytes of host-endian 16-bit integers from |src| and
361 write them to |dest| in big endian. If |nbytes| is odd, the number of source
362 elements is rounded up (but only the most significant byte of the last
363 element is used), and the number of output bytes written will be
365 static void write_be16(const uint16_t* src, size_t nbytes, uint8_t* dest) {
367 for (i = 0; i < nbytes / 2; ++i) {
368 dest[2 * i] = src[i] >> 8;
369 dest[2 * i + 1] = src[i];
371 if (nbytes % 2 == 1) {
372 dest[nbytes - 1] = src[nbytes / 2] >> 8;
377 /****************************************************************************
378 * WebRtcIsacfix_Encode(...)
380 * This function encodes 10ms frame(s) and inserts it into a package.
381 * Input speech length has to be 160 samples (10ms). The encoder buffers those
382 * 10ms frames until it reaches the chosen Framesize (480 or 960 samples
383 * corresponding to 30 or 60 ms frames), and then proceeds to the encoding.
386 * - ISAC_main_inst : ISAC instance.
387 * - speechIn : input speech vector.
390 * - encoded : the encoded data vector
393 * : >0 - Length (in bytes) of coded data
394 * : 0 - The buffer didn't reach the chosen framesize
395 * so it keeps buffering speech samples.
399 int16_t WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst,
400 const int16_t *speechIn,
403 ISACFIX_SubStruct *ISAC_inst;
406 /* typecast pointer to rela structure */
407 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
410 /* check if encoder initiated */
411 if ((ISAC_inst->initflag & 2) != 2) {
412 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED;
416 stream_len = WebRtcIsacfix_EncodeImpl((int16_t*)speechIn,
417 &ISAC_inst->ISACenc_obj,
418 &ISAC_inst->bwestimator_obj,
419 ISAC_inst->CodingMode);
421 ISAC_inst->errorcode = - stream_len;
425 write_be16(ISAC_inst->ISACenc_obj.bitstr_obj.stream, stream_len, encoded);
433 /****************************************************************************
434 * WebRtcIsacfix_EncodeNb(...)
436 * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts
437 * it into a package. Input speech length has to be 80 samples (10ms). The encoder
438 * interpolates into wide-band (16 kHz sampling) buffers those
439 * 10ms frames until it reaches the chosen Framesize (480 or 960 wide-band samples
440 * corresponding to 30 or 60 ms frames), and then proceeds to the encoding.
442 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
445 * - ISAC_main_inst : ISAC instance.
446 * - speechIn : input speech vector.
449 * - encoded : the encoded data vector
452 * : >0 - Length (in bytes) of coded data
453 * : 0 - The buffer didn't reach the chosen framesize
454 * so it keeps buffering speech samples.
457 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
458 int16_t WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct *ISAC_main_inst,
459 const int16_t *speechIn,
462 ISACFIX_SubStruct *ISAC_inst;
464 int16_t speechInWB[FRAMESAMPLES_10ms];
465 int16_t Vector_Word16_1[FRAMESAMPLES_10ms/2];
466 int16_t Vector_Word16_2[FRAMESAMPLES_10ms/2];
471 /* typecast pointer to rela structure */
472 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
475 /* check if encoder initiated */
476 if ((ISAC_inst->initflag & 2) != 2) {
477 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED;
482 /* Oversample to WB */
484 /* Form polyphase signals, and compensate for DC offset */
485 for (k=0;k<FRAMESAMPLES_10ms/2;k++) {
486 Vector_Word16_1[k] = speechIn[k] + 1;
487 Vector_Word16_2[k] = speechIn[k];
489 WebRtcIsacfix_FilterAndCombine2(Vector_Word16_1, Vector_Word16_2, speechInWB, &ISAC_inst->ISACenc_obj.interpolatorstr_obj, FRAMESAMPLES_10ms);
492 /* Encode WB signal */
493 stream_len = WebRtcIsacfix_EncodeImpl((int16_t*)speechInWB,
494 &ISAC_inst->ISACenc_obj,
495 &ISAC_inst->bwestimator_obj,
496 ISAC_inst->CodingMode);
498 ISAC_inst->errorcode = - stream_len;
502 write_be16(ISAC_inst->ISACenc_obj.bitstr_obj.stream,
507 #endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */
510 /****************************************************************************
511 * WebRtcIsacfix_GetNewBitStream(...)
513 * This function returns encoded data, with the recieved bwe-index in the
514 * stream. It should always return a complete packet, i.e. only called once
515 * even for 60 msec frames
518 * - ISAC_main_inst : ISAC instance.
519 * - bweIndex : index of bandwidth estimate to put in new bitstream
522 * - encoded : the encoded data vector
525 * : >0 - Length (in bytes) of coded data
529 int16_t WebRtcIsacfix_GetNewBitStream(ISACFIX_MainStruct *ISAC_main_inst,
534 ISACFIX_SubStruct *ISAC_inst;
537 /* typecast pointer to rela structure */
538 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
541 /* check if encoder initiated */
542 if ((ISAC_inst->initflag & 2) != 2) {
543 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED;
547 stream_len = WebRtcIsacfix_EncodeStoredData(&ISAC_inst->ISACenc_obj,
551 ISAC_inst->errorcode = - stream_len;
555 write_be16(ISAC_inst->ISACenc_obj.bitstr_obj.stream, stream_len, encoded);
561 /****************************************************************************
562 * WebRtcIsacfix_DecoderInit(...)
564 * This function initializes a ISAC instance prior to the decoder calls.
567 * - ISAC_main_inst : ISAC instance.
574 int16_t WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst)
576 ISACFIX_SubStruct *ISAC_inst;
578 /* typecast pointer to real structure */
579 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
581 /* flag decoder init */
582 ISAC_inst->initflag |= 1;
584 WebRtcIsacfix_InitMaskingDec(&ISAC_inst->ISACdec_obj.maskfiltstr_obj);
585 WebRtcIsacfix_InitPostFilterbank(&ISAC_inst->ISACdec_obj.postfiltbankstr_obj);
586 WebRtcIsacfix_InitPitchFilter(&ISAC_inst->ISACdec_obj.pitchfiltstr_obj);
589 WebRtcIsacfix_InitPlc( &ISAC_inst->ISACdec_obj.plcstr_obj );
592 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
593 WebRtcIsacfix_InitPreFilterbank(&ISAC_inst->ISACdec_obj.decimatorstr_obj);
600 /****************************************************************************
601 * WebRtcIsacfix_UpdateBwEstimate1(...)
603 * This function updates the estimate of the bandwidth.
606 * - ISAC_main_inst : ISAC instance.
607 * - encoded : encoded ISAC frame(s).
608 * - packet_size : size of the packet.
609 * - rtp_seq_number : the RTP number of the packet.
610 * - arr_ts : the arrival time of the packet (from NetEq)
613 * Return value : 0 - Ok
617 int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
618 const uint8_t* encoded,
620 uint16_t rtp_seq_number,
623 ISACFIX_SubStruct *ISAC_inst;
624 Bitstr_dec streamdata;
626 const int kRequiredEncodedLenBytes = 10;
628 /* typecast pointer to real structure */
629 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
631 /* Sanity check of packet length */
632 if (packet_size <= 0) {
633 /* return error code if the packet length is null or less */
634 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
636 } else if (packet_size > (STREAM_MAXW16<<1)) {
637 /* return error code if length of stream is too long */
638 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
642 /* check if decoder initiated */
643 if ((ISAC_inst->initflag & 1) != 1) {
644 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
648 InitializeDecoderBitstream(packet_size, &streamdata);
650 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
652 err = WebRtcIsacfix_EstimateBandwidth(&ISAC_inst->bwestimator_obj,
662 /* return error code if something went wrong */
663 ISAC_inst->errorcode = -err;
671 /****************************************************************************
672 * WebRtcIsacfix_UpdateBwEstimate(...)
674 * This function updates the estimate of the bandwidth.
677 * - ISAC_main_inst : ISAC instance.
678 * - encoded : encoded ISAC frame(s).
679 * - packet_size : size of the packet.
680 * - rtp_seq_number : the RTP number of the packet.
681 * - send_ts : Send Time Stamp from RTP header
682 * - arr_ts : the arrival time of the packet (from NetEq)
685 * Return value : 0 - Ok
689 int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
690 const uint8_t* encoded,
692 uint16_t rtp_seq_number,
696 ISACFIX_SubStruct *ISAC_inst;
697 Bitstr_dec streamdata;
699 const int kRequiredEncodedLenBytes = 10;
701 /* typecast pointer to real structure */
702 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
704 /* Sanity check of packet length */
705 if (packet_size <= 0) {
706 /* return error code if the packet length is null or less */
707 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
709 } else if (packet_size < kRequiredEncodedLenBytes) {
710 ISAC_inst->errorcode = ISAC_PACKET_TOO_SHORT;
712 } else if (packet_size > (STREAM_MAXW16<<1)) {
713 /* return error code if length of stream is too long */
714 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
718 /* check if decoder initiated */
719 if ((ISAC_inst->initflag & 1) != 1) {
720 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
724 InitializeDecoderBitstream(packet_size, &streamdata);
726 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
728 err = WebRtcIsacfix_EstimateBandwidth(&ISAC_inst->bwestimator_obj,
737 /* return error code if something went wrong */
738 ISAC_inst->errorcode = -err;
746 /****************************************************************************
747 * WebRtcIsacfix_Decode(...)
749 * This function decodes a ISAC frame. Output speech length
750 * will be a multiple of 480 samples: 480 or 960 samples,
751 * depending on the framesize (30 or 60 ms).
754 * - ISAC_main_inst : ISAC instance.
755 * - encoded : encoded ISAC frame(s)
756 * - len : bytes in encoded vector
759 * - decoded : The decoded vector
761 * Return value : >0 - number of samples in decoded vector
766 int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst,
767 const uint8_t* encoded,
772 ISACFIX_SubStruct *ISAC_inst;
773 /* number of samples (480 or 960), output from decoder */
774 /* that were actually used in the encoder/decoder (determined on the fly) */
775 int16_t number_of_samples;
778 /* typecast pointer to real structure */
779 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
781 /* check if decoder initiated */
782 if ((ISAC_inst->initflag & 1) != 1) {
783 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
787 /* Sanity check of packet length */
789 /* return error code if the packet length is null or less */
790 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
792 } else if (len > (STREAM_MAXW16<<1)) {
793 /* return error code if length of stream is too long */
794 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
798 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj);
800 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream);
802 /* added for NetEq purposes (VAD/DTX related) */
805 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_samples);
808 /* Some error inside the decoder */
809 ISAC_inst->errorcode = -declen;
810 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES);
816 if (declen & 0x0001) {
817 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) & 0x00FF) ) {
818 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
819 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
823 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) >> 8) ) {
824 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
825 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
830 return number_of_samples;
837 /****************************************************************************
838 * WebRtcIsacfix_DecodeNb(...)
840 * This function decodes a ISAC frame in narrow-band (8 kHz sampling).
841 * Output speech length will be a multiple of 240 samples: 240 or 480 samples,
842 * depending on the framesize (30 or 60 ms).
844 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
847 * - ISAC_main_inst : ISAC instance.
848 * - encoded : encoded ISAC frame(s)
849 * - len : bytes in encoded vector
852 * - decoded : The decoded vector
854 * Return value : >0 - number of samples in decoded vector
858 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
859 int16_t WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
860 const uint16_t *encoded,
865 ISACFIX_SubStruct *ISAC_inst;
866 /* twice the number of samples (480 or 960), output from decoder */
867 /* that were actually used in the encoder/decoder (determined on the fly) */
868 int16_t number_of_samples;
870 int16_t dummy[FRAMESAMPLES/2];
873 /* typecast pointer to real structure */
874 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
876 /* check if decoder initiated */
877 if ((ISAC_inst->initflag & 1) != 1) {
878 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
883 /* return error code if the packet length is null or less */
884 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
886 } else if (len > (STREAM_MAXW16<<1)) {
887 /* return error code if length of stream is too long */
888 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
892 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj);
894 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream);
896 /* added for NetEq purposes (VAD/DTX related) */
899 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_samples);
902 /* Some error inside the decoder */
903 ISAC_inst->errorcode = -declen;
904 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES);
910 if (declen & 0x0001) {
911 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) & 0x00FF) ) {
912 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
913 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
917 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) >> 8) ) {
918 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
919 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
924 WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj);
926 if (number_of_samples>FRAMESAMPLES) {
927 WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES/2,
928 dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj);
931 return number_of_samples/2;
933 #endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */
936 /****************************************************************************
937 * WebRtcIsacfix_DecodePlcNb(...)
939 * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling).
940 * Output speech length will be "240*noOfLostFrames" samples
941 * that is equevalent of "30*noOfLostFrames" millisecond.
943 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
946 * - ISAC_main_inst : ISAC instance.
947 * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce
950 * - decoded : The decoded vector
952 * Return value : >0 - number of samples in decoded PLC vector
956 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
957 int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
959 int16_t noOfLostFrames )
961 int16_t no_of_samples, declen, k, ok;
962 int16_t outframeNB[FRAMESAMPLES];
963 int16_t outframeWB[FRAMESAMPLES];
964 int16_t dummy[FRAMESAMPLES/2];
967 ISACFIX_SubStruct *ISAC_inst;
968 /* typecast pointer to real structure */
969 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
971 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors */
972 if (noOfLostFrames > 2){
978 while( noOfLostFrames > 0 )
980 ok = WebRtcIsacfix_DecodePlcImpl( outframeWB, &ISAC_inst->ISACdec_obj, &no_of_samples );
984 WebRtcIsacfix_SplitAndFilter2(outframeWB, &(outframeNB[k*240]), dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj);
986 declen += no_of_samples;
993 for (k=0;k<declen;k++) {
994 decoded[k] = outframeNB[k];
999 #endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */
1004 /****************************************************************************
1005 * WebRtcIsacfix_DecodePlc(...)
1007 * This function conducts PLC for ISAC frame(s) in wide-band (16kHz sampling).
1008 * Output speech length will be "480*noOfLostFrames" samples
1009 * that is equevalent of "30*noOfLostFrames" millisecond.
1012 * - ISAC_main_inst : ISAC instance.
1013 * - noOfLostFrames : Number of PLC frames (480sample = 30ms)
1017 * - decoded : The decoded vector
1019 * Return value : >0 - number of samples in decoded PLC vector
1023 int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst,
1025 int16_t noOfLostFrames)
1028 int16_t no_of_samples, declen, k, ok;
1029 int16_t outframe16[MAX_FRAMESAMPLES];
1031 ISACFIX_SubStruct *ISAC_inst;
1032 /* typecast pointer to real structure */
1033 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1035 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors */
1036 if (noOfLostFrames > 2) {
1041 while( noOfLostFrames > 0 )
1043 ok = WebRtcIsacfix_DecodePlcImpl( &(outframe16[k*480]), &ISAC_inst->ISACdec_obj, &no_of_samples );
1046 declen += no_of_samples;
1051 for (k=0;k<declen;k++) {
1052 decoded[k] = outframe16[k];
1059 /****************************************************************************
1060 * WebRtcIsacfix_Control(...)
1062 * This function sets the limit on the short-term average bit rate and the
1063 * frame length. Should be used only in Instantaneous mode.
1066 * - ISAC_main_inst : ISAC instance.
1067 * - rate : limit on the short-term average bit rate,
1068 * in bits/second (between 10000 and 32000)
1069 * - framesize : number of milliseconds per frame (30 or 60)
1071 * Return value : 0 - ok
1075 int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
1079 ISACFIX_SubStruct *ISAC_inst;
1080 /* typecast pointer to real structure */
1081 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1083 if (ISAC_inst->CodingMode == 0)
1085 /* in adaptive mode */
1086 ISAC_inst->errorcode = ISAC_MODE_MISMATCH;
1091 if (rate >= 10000 && rate <= 32000)
1092 ISAC_inst->ISACenc_obj.BottleNeck = rate;
1094 ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK;
1100 if (framesize == 30 || framesize == 60)
1101 ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * framesize;
1103 ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH;
1111 /****************************************************************************
1112 * WebRtcIsacfix_ControlBwe(...)
1114 * This function sets the initial values of bottleneck and frame-size if
1115 * iSAC is used in channel-adaptive mode. Through this API, users can
1116 * enforce a frame-size for all values of bottleneck. Then iSAC will not
1117 * automatically change the frame-size.
1121 * - ISAC_main_inst : ISAC instance.
1122 * - rateBPS : initial value of bottleneck in bits/second
1123 * 10000 <= rateBPS <= 32000 is accepted
1124 * For default bottleneck set rateBPS = 0
1125 * - frameSizeMs : number of milliseconds per frame (30 or 60)
1126 * - enforceFrameSize : 1 to enforce the given frame-size through out
1127 * the adaptation process, 0 to let iSAC change
1128 * the frame-size if required.
1130 * Return value : 0 - ok
1134 int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst,
1136 int16_t frameSizeMs,
1137 int16_t enforceFrameSize)
1139 ISACFIX_SubStruct *ISAC_inst;
1140 /* Typecast pointer to real structure */
1141 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1143 /* check if encoder initiated */
1144 if ((ISAC_inst->initflag & 2) != 2) {
1145 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED;
1149 /* Check that we are in channel-adaptive mode, otherwise, return -1 */
1150 if (ISAC_inst->CodingMode != 0) {
1151 ISAC_inst->errorcode = ISAC_MODE_MISMATCH;
1155 /* Set struct variable if enforceFrameSize is set. ISAC will then keep the */
1156 /* chosen frame size. */
1157 ISAC_inst->ISACenc_obj.enforceFrameSize = (enforceFrameSize != 0)? 1:0;
1159 /* Set initial rate, if value between 10000 and 32000, */
1160 /* if rateBPS is 0, keep the default initial bottleneck value (15000) */
1161 if ((rateBPS >= 10000) && (rateBPS <= 32000)) {
1162 ISAC_inst->bwestimator_obj.sendBwAvg = (((uint32_t)rateBPS) << 7);
1163 } else if (rateBPS != 0) {
1164 ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK;
1168 /* Set initial framesize. If enforceFrameSize is set the frame size will not change */
1169 if ((frameSizeMs == 30) || (frameSizeMs == 60)) {
1170 ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * frameSizeMs;
1172 ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH;
1183 /****************************************************************************
1184 * WebRtcIsacfix_GetDownLinkBwIndex(...)
1186 * This function returns index representing the Bandwidth estimate from
1187 * other side to this side.
1190 * - ISAC_main_inst: iSAC struct
1193 * - rateIndex : Bandwidth estimate to transmit to other side.
1197 int16_t WebRtcIsacfix_GetDownLinkBwIndex(ISACFIX_MainStruct* ISAC_main_inst,
1200 ISACFIX_SubStruct *ISAC_inst;
1202 /* typecast pointer to real structure */
1203 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1205 /* Call function to get Bandwidth Estimate */
1206 *rateIndex = WebRtcIsacfix_GetDownlinkBwIndexImpl(&ISAC_inst->bwestimator_obj);
1212 /****************************************************************************
1213 * WebRtcIsacfix_UpdateUplinkBw(...)
1215 * This function takes an index representing the Bandwidth estimate from
1216 * this side to other side and updates BWE.
1219 * - ISAC_main_inst: iSAC struct
1220 * - rateIndex : Bandwidth estimate from other side.
1224 int16_t WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst,
1228 ISACFIX_SubStruct *ISAC_inst;
1230 /* typecast pointer to real structure */
1231 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1233 /* Call function to update BWE with received Bandwidth Estimate */
1234 err = WebRtcIsacfix_UpdateUplinkBwRec(&ISAC_inst->bwestimator_obj, rateIndex);
1236 ISAC_inst->errorcode = -err;
1243 /****************************************************************************
1244 * WebRtcIsacfix_ReadFrameLen(...)
1246 * This function returns the length of the frame represented in the packet.
1249 * - encoded : Encoded bitstream
1252 * - frameLength : Length of frame in packet (in samples)
1256 int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
1257 int encoded_len_bytes,
1258 int16_t* frameLength)
1260 Bitstr_dec streamdata;
1262 const int kRequiredEncodedLenBytes = 10;
1264 if (encoded_len_bytes < kRequiredEncodedLenBytes) {
1268 InitializeDecoderBitstream(encoded_len_bytes, &streamdata);
1270 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
1272 /* decode frame length */
1273 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, frameLength);
1274 if (err<0) // error check
1281 /****************************************************************************
1282 * WebRtcIsacfix_ReadBwIndex(...)
1284 * This function returns the index of the Bandwidth estimate from the bitstream.
1287 * - encoded : Encoded bitstream
1290 * - frameLength : Length of frame in packet (in samples)
1291 * - rateIndex : Bandwidth estimate in bitstream
1295 int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
1296 int encoded_len_bytes,
1299 Bitstr_dec streamdata;
1301 const int kRequiredEncodedLenBytes = 10;
1303 if (encoded_len_bytes < kRequiredEncodedLenBytes) {
1307 InitializeDecoderBitstream(encoded_len_bytes, &streamdata);
1309 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
1311 /* decode frame length, needed to get to the rateIndex in the bitstream */
1312 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, rateIndex);
1313 if (err<0) // error check
1316 /* decode BW estimation */
1317 err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex);
1318 if (err<0) // error check
1327 /****************************************************************************
1328 * WebRtcIsacfix_GetErrorCode(...)
1330 * This function can be used to check the error code of an iSAC instance. When
1331 * a function returns -1 a error code will be set for that instance. The
1332 * function below extract the code of the last error that occured in the
1333 * specified instance.
1336 * - ISAC_main_inst : ISAC instance
1338 * Return value : Error code
1341 int16_t WebRtcIsacfix_GetErrorCode(ISACFIX_MainStruct *ISAC_main_inst)
1343 ISACFIX_SubStruct *ISAC_inst;
1344 /* typecast pointer to real structure */
1345 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1347 return ISAC_inst->errorcode;
1352 /****************************************************************************
1353 * WebRtcIsacfix_GetUplinkBw(...)
1355 * This function returns the inst quantized iSAC send bitrate
1358 * - ISAC_main_inst : iSAC instance
1360 * Return value : bitrate
1363 int32_t WebRtcIsacfix_GetUplinkBw(ISACFIX_MainStruct *ISAC_main_inst)
1365 ISACFIX_SubStruct *ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1366 BwEstimatorstr * bw = (BwEstimatorstr*)&(ISAC_inst->bwestimator_obj);
1368 return (int32_t) WebRtcIsacfix_GetUplinkBandwidth(bw);
1371 /****************************************************************************
1372 * WebRtcIsacfix_GetNewFrameLen(...)
1374 * This function return the next frame length (in samples) of iSAC.
1377 * - ISAC_main_inst : iSAC instance
1379 * Return value : frame lenght in samples
1382 int16_t WebRtcIsacfix_GetNewFrameLen(ISACFIX_MainStruct *ISAC_main_inst)
1384 ISACFIX_SubStruct *ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1385 return ISAC_inst->ISACenc_obj.new_framelength;
1389 /****************************************************************************
1390 * WebRtcIsacfix_SetMaxPayloadSize(...)
1392 * This function sets a limit for the maximum payload size of iSAC. The same
1393 * value is used both for 30 and 60 msec packets.
1394 * The absolute max will be valid until next time the function is called.
1395 * NOTE! This function may override the function WebRtcIsacfix_SetMaxRate()
1398 * - ISAC_main_inst : iSAC instance
1399 * - maxPayloadBytes : maximum size of the payload in bytes
1400 * valid values are between 100 and 400 bytes
1403 * Return value : 0 if sucessful
1404 * -1 if error happens
1407 int16_t WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_MainStruct *ISAC_main_inst,
1408 int16_t maxPayloadBytes)
1410 ISACFIX_SubStruct *ISAC_inst;
1412 /* typecast pointer to real structure */
1413 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1415 if((maxPayloadBytes < 100) || (maxPayloadBytes > 400))
1417 /* maxPayloadBytes is out of valid range */
1422 /* Set new absolute max, which will not change unless this function
1423 is called again with a new value */
1424 ISAC_inst->ISACenc_obj.maxPayloadBytes = maxPayloadBytes;
1426 /* Set new maximum values for 30 and 60 msec packets */
1427 if (maxPayloadBytes < ISAC_inst->ISACenc_obj.maxRateInBytes) {
1428 ISAC_inst->ISACenc_obj.payloadLimitBytes30 = maxPayloadBytes;
1430 ISAC_inst->ISACenc_obj.payloadLimitBytes30 = ISAC_inst->ISACenc_obj.maxRateInBytes;
1433 if ( maxPayloadBytes < (ISAC_inst->ISACenc_obj.maxRateInBytes << 1)) {
1434 ISAC_inst->ISACenc_obj.payloadLimitBytes60 = maxPayloadBytes;
1436 ISAC_inst->ISACenc_obj.payloadLimitBytes60 = (ISAC_inst->ISACenc_obj.maxRateInBytes << 1);
1443 /****************************************************************************
1444 * WebRtcIsacfix_SetMaxRate(...)
1446 * This function sets the maximum rate which the codec may not exceed for a
1447 * singel packet. The maximum rate is set in bits per second.
1448 * The codec has an absolute maximum rate of 53400 bits per second (200 bytes
1450 * It is possible to set a maximum rate between 32000 and 53400 bits per second.
1452 * The rate limit is valid until next time the function is called.
1454 * NOTE! Packet size will never go above the value set if calling
1455 * WebRtcIsacfix_SetMaxPayloadSize() (default max packet size is 400 bytes).
1458 * - ISAC_main_inst : iSAC instance
1459 * - maxRateInBytes : maximum rate in bits per second,
1460 * valid values are 32000 to 53400 bits
1462 * Return value : 0 if sucessful
1463 * -1 if error happens
1466 int16_t WebRtcIsacfix_SetMaxRate(ISACFIX_MainStruct *ISAC_main_inst,
1469 ISACFIX_SubStruct *ISAC_inst;
1470 int16_t maxRateInBytes;
1472 /* typecast pointer to real structure */
1473 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1475 if((maxRate < 32000) || (maxRate > 53400))
1477 /* maxRate is out of valid range */
1482 /* Calculate maximum number of bytes per 30 msec packets for the given
1483 maximum rate. Multiply with 30/1000 to get number of bits per 30 msec,
1484 divide by 8 to get number of bytes per 30 msec:
1485 maxRateInBytes = floor((maxRate * 30/1000) / 8); */
1486 maxRateInBytes = (int16_t)( WebRtcSpl_DivW32W16ResW16(WEBRTC_SPL_MUL(maxRate, 3), 800) );
1488 /* Store the value for usage in the WebRtcIsacfix_SetMaxPayloadSize-function */
1489 ISAC_inst->ISACenc_obj.maxRateInBytes = maxRateInBytes;
1491 /* For 30 msec packets: if the new limit is below the maximum
1492 payload size, set a new limit */
1493 if (maxRateInBytes < ISAC_inst->ISACenc_obj.maxPayloadBytes) {
1494 ISAC_inst->ISACenc_obj.payloadLimitBytes30 = maxRateInBytes;
1496 ISAC_inst->ISACenc_obj.payloadLimitBytes30 = ISAC_inst->ISACenc_obj.maxPayloadBytes;
1499 /* For 60 msec packets: if the new limit (times 2) is below the
1500 maximum payload size, set a new limit */
1501 if ( (maxRateInBytes << 1) < ISAC_inst->ISACenc_obj.maxPayloadBytes) {
1502 ISAC_inst->ISACenc_obj.payloadLimitBytes60 = (maxRateInBytes << 1);
1504 ISAC_inst->ISACenc_obj.payloadLimitBytes60 = ISAC_inst->ISACenc_obj.maxPayloadBytes;
1513 /****************************************************************************
1514 * WebRtcIsacfix_version(...)
1516 * This function returns the version number.
1519 * - version : Pointer to character string
1523 void WebRtcIsacfix_version(char *version)
1525 strcpy(version, "3.6.0");