Update a ton of audio code to use size_t more correctly and in general reduce

use of int16_t/uint16_t.

This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.

This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002

The change is being landed as TBR to all the folks who reviewed the above.

BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher

Review URL: https://codereview.webrtc.org/1230503003 .

Cr-Commit-Position: refs/heads/master@{#9768}
This commit is contained in:
Peter Kasting
2015-08-24 14:52:23 -07:00
parent b594041ec8
commit dce40cf804
471 changed files with 3716 additions and 3499 deletions

View File

@ -55,8 +55,8 @@ class AudioEncoderIsacT final : public AudioEncoder {
int SampleRateHz() const override;
int NumChannels() const override;
size_t MaxEncodedBytes() const override;
int Num10MsFramesInNextPacket() const override;
int Max10MsFramesInAPacket() const override;
size_t Num10MsFramesInNextPacket() const override;
size_t Max10MsFramesInAPacket() const override;
int GetTargetBitrate() const override;
EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
const int16_t* audio,
@ -94,7 +94,7 @@ class AudioDecoderIsacT final : public AudioDecoder {
~AudioDecoderIsacT() override;
bool HasDecodePlc() const override;
int DecodePlc(int num_frames, int16_t* decoded) override;
size_t DecodePlc(size_t num_frames, int16_t* decoded) override;
int Init() override;
int IncomingPacket(const uint8_t* payload,
size_t payload_len,

View File

@ -123,14 +123,15 @@ size_t AudioEncoderIsacT<T>::MaxEncodedBytes() const {
}
template <typename T>
int AudioEncoderIsacT<T>::Num10MsFramesInNextPacket() const {
size_t AudioEncoderIsacT<T>::Num10MsFramesInNextPacket() const {
const int samples_in_next_packet = T::GetNewFrameLen(isac_state_);
return rtc::CheckedDivExact(samples_in_next_packet,
rtc::CheckedDivExact(SampleRateHz(), 100));
return static_cast<size_t>(
rtc::CheckedDivExact(samples_in_next_packet,
rtc::CheckedDivExact(SampleRateHz(), 100)));
}
template <typename T>
int AudioEncoderIsacT<T>::Max10MsFramesInAPacket() const {
size_t AudioEncoderIsacT<T>::Max10MsFramesInAPacket() const {
return 6; // iSAC puts at most 60 ms in a packet.
}
@ -215,8 +216,7 @@ int AudioDecoderIsacT<T>::DecodeInternal(const uint8_t* encoded,
}
int16_t temp_type = 1; // Default is speech.
int ret =
T::DecodeInternal(isac_state_, encoded, static_cast<int16_t>(encoded_len),
decoded, &temp_type);
T::DecodeInternal(isac_state_, encoded, encoded_len, decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
return ret;
}
@ -227,7 +227,7 @@ bool AudioDecoderIsacT<T>::HasDecodePlc() const {
}
template <typename T>
int AudioDecoderIsacT<T>::DecodePlc(int num_frames, int16_t* decoded) {
size_t AudioDecoderIsacT<T>::DecodePlc(size_t num_frames, int16_t* decoded) {
return T::DecodePlc(isac_state_, decoded, num_frames);
}
@ -243,7 +243,7 @@ int AudioDecoderIsacT<T>::IncomingPacket(const uint8_t* payload,
uint32_t rtp_timestamp,
uint32_t arrival_timestamp) {
int ret = T::UpdateBwEstimate(
isac_state_, payload, static_cast<int32_t>(payload_len),
isac_state_, payload, payload_len,
rtp_sequence_number, rtp_timestamp, arrival_timestamp);
if (bwinfo_) {
IsacBandwidthInfo bwinfo;

View File

@ -40,14 +40,14 @@ struct IsacFix {
}
static inline int DecodeInternal(instance_type* inst,
const uint8_t* encoded,
int16_t len,
size_t len,
int16_t* decoded,
int16_t* speech_type) {
return WebRtcIsacfix_Decode(inst, encoded, len, decoded, speech_type);
}
static inline int16_t DecodePlc(instance_type* inst,
int16_t* decoded,
int16_t num_lost_frames) {
static inline size_t DecodePlc(instance_type* inst,
int16_t* decoded,
size_t num_lost_frames) {
return WebRtcIsacfix_DecodePlc(inst, decoded, num_lost_frames);
}
static inline int16_t DecoderInit(instance_type* inst) {
@ -104,7 +104,7 @@ struct IsacFix {
}
static inline int16_t UpdateBwEstimate(instance_type* inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts) {

View File

@ -11,6 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_INTERFACE_ISACFIX_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_INTERFACE_ISACFIX_H_
#include <stddef.h>
#include "webrtc/modules/audio_coding/codecs/isac/bandwidth_info.h"
#include "webrtc/typedefs.h"
@ -189,7 +191,7 @@ extern "C" {
* Input:
* - ISAC_main_inst : ISAC instance.
* - encoded : encoded ISAC frame(s).
* - packet_size : size of the packet.
* - packet_size : size of the packet in bytes.
* - rtp_seq_number : the RTP number of the packet.
* - arr_ts : the arrival time of the packet (from NetEq)
* in samples.
@ -200,7 +202,7 @@ extern "C" {
int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t arr_ts);
@ -212,7 +214,7 @@ extern "C" {
* Input:
* - ISAC_main_inst : ISAC instance.
* - encoded : encoded ISAC frame(s).
* - packet_size : size of the packet.
* - packet_size : size of the packet in bytes.
* - rtp_seq_number : the RTP number of the packet.
* - send_ts : the send time of the packet from RTP header,
* in samples.
@ -225,7 +227,7 @@ extern "C" {
int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts);
@ -251,7 +253,7 @@ extern "C" {
int WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded,
int16_t len,
size_t len,
int16_t *decoded,
int16_t *speechType);
@ -280,7 +282,7 @@ extern "C" {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded,
int16_t len,
size_t len,
int16_t *decoded,
int16_t *speechType);
#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
@ -303,14 +305,13 @@ extern "C" {
* Output:
* - decoded : The decoded vector
*
* Return value : >0 - number of samples in decoded PLC vector
* -1 - Error
* Return value : Number of samples in decoded PLC vector
*/
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
int16_t *decoded,
int16_t noOfLostFrames);
size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
int16_t *decoded,
size_t noOfLostFrames);
#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
@ -332,13 +333,12 @@ extern "C" {
* Output:
* - decoded : The decoded vector
*
* Return value : >0 - number of samples in decoded PLC vector
* -1 - Error
* Return value : Number of samples in decoded PLC vector
*/
int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst,
int16_t *decoded,
int16_t noOfLostFrames );
size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst,
int16_t *decoded,
size_t noOfLostFrames );
/****************************************************************************
@ -356,8 +356,8 @@ extern "C" {
*/
int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
int encoded_len_bytes,
int16_t* frameLength);
size_t encoded_len_bytes,
size_t* frameLength);
/****************************************************************************
* WebRtcIsacfix_Control(...)
@ -608,7 +608,7 @@ extern "C" {
*/
int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
int encoded_len_bytes,
size_t encoded_len_bytes,
int16_t* rateIndex);

View File

@ -148,7 +148,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
const int16_t frameSize,
const uint32_t sendTime,
const uint32_t arrivalTime,
const int16_t pksize,
const size_t pksize,
const uint16_t Index)
{
uint16_t weight = 0;
@ -379,7 +379,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
/* compute inverse receiving rate for last packet, in Q19 */
numBytesInv = (uint16_t) WebRtcSpl_DivW32W16(
524288 + ((pksize + HEADER_SIZE) >> 1),
(int32_t)(524288 + ((pksize + HEADER_SIZE) >> 1)),
(int16_t)(pksize + HEADER_SIZE));
/* 8389 is ~ 1/128000 in Q30 */

View File

@ -62,7 +62,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bwest_str,
const int16_t frameSize,
const uint32_t send_ts,
const uint32_t arr_ts,
const int16_t pksize,
const size_t pksize,
const uint16_t Index);
/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */

View File

@ -27,18 +27,18 @@ extern "C" {
int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr* bwest_str,
Bitstr_dec* streamdata,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts);
int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16,
IsacFixDecoderInstance* ISACdec_obj,
int16_t* current_framesamples);
size_t* current_framesamples);
void WebRtcIsacfix_DecodePlcImpl(int16_t* decoded,
IsacFixDecoderInstance* ISACdec_obj,
int16_t* current_framesample );
size_t* current_framesample );
int WebRtcIsacfix_EncodeImpl(int16_t* in,
IsacFixEncoderInstance* ISACenc_obj,
@ -141,7 +141,7 @@ void WebRtcIsacfix_FilterAndCombine2(int16_t* tempin_ch1,
/* normalized lattice filters */
void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
void WebRtcIsacfix_NormLatticeFilterMa(size_t orderCoef,
int32_t* stateGQ15,
int16_t* lat_inQ0,
int16_t* filt_coefQ15,
@ -149,7 +149,7 @@ void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
int16_t lo_hi,
int16_t* lat_outQ9);
void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef,
void WebRtcIsacfix_NormLatticeFilterAr(size_t orderCoef,
int16_t* stateGQ0,
int32_t* lat_inQ25,
int16_t* filt_coefQ15,

View File

@ -29,7 +29,7 @@
int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16,
IsacFixDecoderInstance* ISACdec_obj,
int16_t* current_framesamples)
size_t* current_framesamples)
{
int k;
int err;
@ -58,9 +58,9 @@ int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16,
int16_t gainQ13;
int16_t frame_nb; /* counter */
int16_t frame_mode; /* 0 for 30ms, 1 for 60ms */
static const int16_t kProcessedSamples = 480; /* 480 (for both 30, 60 ms) */
size_t frame_nb; /* counter */
size_t frame_mode; /* 0 for 30ms, 1 for 60ms */
static const size_t kProcessedSamples = 480; /* 480 (for both 30, 60 ms) */
/* PLC */
int16_t overlapWin[ 240 ];

View File

@ -26,13 +26,13 @@
int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr *bwest_str,
Bitstr_dec *streamdata,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts)
{
int16_t index;
int16_t frame_samples;
size_t frame_samples;
int err;
/* decode framelength */
@ -53,10 +53,10 @@ int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr *bwest_str,
err = WebRtcIsacfix_UpdateUplinkBwImpl(
bwest_str,
rtp_seq_number,
frame_samples * 1000 / FS,
(int16_t)(frame_samples * 1000 / FS),
send_ts,
arr_ts,
(int16_t) packet_size, /* in bytes */
packet_size, /* in bytes */
index);
/* error check */

View File

@ -177,11 +177,12 @@ static void MemshipValQ15( int16_t in, int16_t *A, int16_t *B )
static void LinearResampler(int16_t* in,
int16_t* out,
int16_t lenIn,
int16_t lenOut)
size_t lenIn,
size_t lenOut)
{
int32_t n = (lenIn - 1) * RESAMP_RES;
int16_t resOut, i, j, relativePos, diff; /* */
size_t n = (lenIn - 1) * RESAMP_RES;
int16_t resOut, relativePos, diff; /* */
size_t i, j;
uint16_t udiff;
if( lenIn == lenOut )
@ -190,7 +191,7 @@ static void LinearResampler(int16_t* in,
return;
}
resOut = WebRtcSpl_DivW32W16ResW16( n, (int16_t)(lenOut-1) );
resOut = WebRtcSpl_DivW32W16ResW16( (int32_t)n, (int16_t)(lenOut-1) );
out[0] = in[0];
for( i = 1, j = 0, relativePos = 0; i < lenOut; i++ )
@ -235,7 +236,7 @@ static void LinearResampler(int16_t* in,
void WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16,
IsacFixDecoderInstance *ISACdec_obj,
int16_t *current_framesamples )
size_t *current_framesamples )
{
int subframecnt;
@ -260,12 +261,14 @@ void WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16,
int16_t myDecayRate;
/* ---------- PLC variables ------------ */
int16_t lag0, i, k, noiseIndex;
size_t lag0, i, k;
int16_t noiseIndex;
int16_t stretchPitchLP[PITCH_MAX_LAG + 10], stretchPitchLP1[PITCH_MAX_LAG + 10];
int32_t gain_lo_hiQ17[2*SUBFRAMES];
int16_t nLP, pLP, wNoisyLP, wPriodicLP, tmp16, minIdx;
int16_t nLP, pLP, wNoisyLP, wPriodicLP, tmp16;
size_t minIdx;
int32_t nHP, pHP, wNoisyHP, wPriodicHP, corr, minCorr, maxCoeff;
int16_t noise1, rshift;
@ -300,7 +303,7 @@ void WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16,
lag0 = ((ISACdec_obj->plcstr_obj.lastPitchLag_Q7 + 64) >> 7) + 1;
lag0 = (size_t)(((ISACdec_obj->plcstr_obj.lastPitchLag_Q7 + 64) >> 7) + 1);
if( (ISACdec_obj->plcstr_obj).used != PLC_WAS_USED )

View File

@ -1870,7 +1870,7 @@ const uint16_t kFrameLenInitIndex[1] = {1};
int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata,
int16_t *framesamples)
size_t *framesamples)
{
int err;

View File

@ -92,7 +92,7 @@ int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata,
int16_t *PitchLagQ7);
int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata,
int16_t *framelength);
size_t *framelength);
int WebRtcIsacfix_EncodeFrameLen(int16_t framelength,

View File

@ -38,7 +38,7 @@ MatrixProduct2 WebRtcIsacfix_MatrixProduct2;
/* This method assumes that |stream_size_bytes| is in valid range,
* i.e. >= 0 && <= STREAM_MAXW16_60MS
*/
static void InitializeDecoderBitstream(int stream_size_bytes,
static void InitializeDecoderBitstream(size_t stream_size_bytes,
Bitstr_dec* bitstream) {
bitstream->W_upper = 0xFFFFFFFF;
bitstream->streamval = 0;
@ -621,20 +621,20 @@ int16_t WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst)
int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t arr_ts)
{
ISACFIX_SubStruct *ISAC_inst;
Bitstr_dec streamdata;
int16_t err;
const int kRequiredEncodedLenBytes = 10;
const size_t kRequiredEncodedLenBytes = 10;
/* typecast pointer to real structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
/* Sanity check of packet length */
if (packet_size <= 0) {
if (packet_size == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@ -693,7 +693,7 @@ int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts)
@ -701,13 +701,13 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
ISACFIX_SubStruct *ISAC_inst;
Bitstr_dec streamdata;
int16_t err;
const int kRequiredEncodedLenBytes = 10;
const size_t kRequiredEncodedLenBytes = 10;
/* typecast pointer to real structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
/* Sanity check of packet length */
if (packet_size <= 0) {
if (packet_size == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@ -770,15 +770,16 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
const uint8_t* encoded,
int16_t len,
size_t len,
int16_t* decoded,
int16_t* speechType)
{
ISACFIX_SubStruct *ISAC_inst;
/* number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */
int16_t number_of_samples;
int declen = 0;
size_t number_of_samples;
int declen_int = 0;
size_t declen;
/* typecast pointer to real structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
@ -790,7 +791,7 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
}
/* Sanity check of packet length */
if (len <= 0) {
if (len == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@ -807,14 +808,15 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
/* added for NetEq purposes (VAD/DTX related) */
*speechType=1;
declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
&number_of_samples);
if (declen < 0) {
declen_int = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
&number_of_samples);
if (declen_int < 0) {
/* Some error inside the decoder */
ISAC_inst->errorcode = -(int16_t)declen;
ISAC_inst->errorcode = -(int16_t)declen_int;
memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES);
return -1;
}
declen = (size_t)declen_int;
/* error check */
@ -836,7 +838,7 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
}
}
return number_of_samples;
return (int)number_of_samples;
}
@ -865,17 +867,18 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
*/
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded,
int16_t len,
int16_t *decoded,
int16_t *speechType)
int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct* ISAC_main_inst,
const uint16_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType)
{
ISACFIX_SubStruct *ISAC_inst;
/* twice the number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */
int16_t number_of_samples;
int declen = 0;
size_t number_of_samples;
int declen_int = 0;
size_t declen;
int16_t dummy[FRAMESAMPLES/2];
@ -888,7 +891,7 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
return (-1);
}
if (len <= 0) {
if (len == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@ -905,14 +908,15 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
/* added for NetEq purposes (VAD/DTX related) */
*speechType=1;
declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
&number_of_samples);
if (declen < 0) {
declen_int = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
&number_of_samples);
if (declen_int < 0) {
/* Some error inside the decoder */
ISAC_inst->errorcode = -(int16_t)declen;
ISAC_inst->errorcode = -(int16_t)declen_int;
memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES);
return -1;
}
declen = (size_t)declen_int;
/* error check */
@ -941,7 +945,7 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj);
}
return number_of_samples/2;
return (int)(number_of_samples / 2);
}
#endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */
@ -962,16 +966,15 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
* Output:
* - decoded : The decoded vector
*
* Return value : >0 - number of samples in decoded PLC vector
* -1 - Error
* Return value : Number of samples in decoded PLC vector
*/
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
int16_t *decoded,
int16_t noOfLostFrames )
size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct* ISAC_main_inst,
int16_t* decoded,
size_t noOfLostFrames )
{
int16_t no_of_samples, declen, k, ok;
size_t no_of_samples, declen, k;
int16_t outframeNB[FRAMESAMPLES];
int16_t outframeWB[FRAMESAMPLES];
int16_t dummy[FRAMESAMPLES/2];
@ -1028,16 +1031,15 @@ int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
* Output:
* - decoded : The decoded vector
*
* Return value : >0 - number of samples in decoded PLC vector
* -1 - Error
* Return value : Number of samples in decoded PLC vector
*/
int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst,
int16_t *decoded,
int16_t noOfLostFrames)
size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct* ISAC_main_inst,
int16_t* decoded,
size_t noOfLostFrames)
{
int16_t no_of_samples, declen, k;
size_t no_of_samples, declen, k;
int16_t outframe16[MAX_FRAMESAMPLES];
ISACFIX_SubStruct *ISAC_inst;
@ -1272,12 +1274,12 @@ int16_t WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst,
*/
int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
int encoded_len_bytes,
int16_t* frameLength)
size_t encoded_len_bytes,
size_t* frameLength)
{
Bitstr_dec streamdata;
int16_t err;
const int kRequiredEncodedLenBytes = 10;
const size_t kRequiredEncodedLenBytes = 10;
if (encoded_len_bytes < kRequiredEncodedLenBytes) {
return -1;
@ -1311,12 +1313,12 @@ int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
*/
int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
int encoded_len_bytes,
size_t encoded_len_bytes,
int16_t* rateIndex)
{
Bitstr_dec streamdata;
int16_t err;
const int kRequiredEncodedLenBytes = 10;
const size_t kRequiredEncodedLenBytes = 10;
if (encoded_len_bytes < kRequiredEncodedLenBytes) {
return -1;
@ -1327,7 +1329,7 @@ int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
/* decode frame length, needed to get to the rateIndex in the bitstream */
int16_t frameLength;
size_t frameLength;
err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &frameLength);
if (err<0) // error check
return err;

View File

@ -43,7 +43,7 @@ void WebRtcIsacfix_FilterArLoop(int16_t* ar_g_Q0,
int16_t* ar_f_Q0,
int16_t* cth_Q15,
int16_t* sth_Q15,
int16_t order_coef);
size_t order_coef);
/* Inner loop used for function WebRtcIsacfix_NormLatticeFilterMa(). It does:
for 0 <= n < HALF_SUBFRAMELEN - 1:
@ -86,7 +86,7 @@ void WebRtcIsacfix_FilterMaLoopC(int16_t input0, // Filter coefficient
/* filter the signal using normalized lattice filter */
/* MA filter */
void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
void WebRtcIsacfix_NormLatticeFilterMa(size_t orderCoef,
int32_t *stateGQ15,
int16_t *lat_inQ0,
int16_t *filt_coefQ15,
@ -97,9 +97,10 @@ void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
int16_t sthQ15[MAX_AR_MODEL_ORDER];
int16_t cthQ15[MAX_AR_MODEL_ORDER];
int u, i, k, n;
int u, n;
size_t i, k;
int16_t temp2,temp3;
int16_t ord_1 = orderCoef+1;
size_t ord_1 = orderCoef+1;
int32_t inv_cthQ16[MAX_AR_MODEL_ORDER];
int32_t gain32, fQtmp;
@ -210,7 +211,7 @@ void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
/* ----------------AR filter-------------------------*/
/* filter the signal using normalized lattice filter */
void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef,
void WebRtcIsacfix_NormLatticeFilterAr(size_t orderCoef,
int16_t *stateGQ0,
int32_t *lat_inQ25,
int16_t *filt_coefQ15,
@ -218,7 +219,8 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef,
int16_t lo_hi,
int16_t *lat_outQ0)
{
int ii, n, k, i, u;
size_t ii, k, i;
int n, u;
int16_t sthQ15[MAX_AR_MODEL_ORDER];
int16_t cthQ15[MAX_AR_MODEL_ORDER];
int32_t tmp32;
@ -234,7 +236,7 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef,
int16_t sh;
int16_t temp2,temp3;
int16_t ord_1 = orderCoef+1;
size_t ord_1 = orderCoef+1;
for (u=0;u<SUBFRAMES;u++)
{

View File

@ -25,11 +25,11 @@ void WebRtcIsacfix_FilterArLoop(int16_t* ar_g_Q0, // Input samples
int16_t* ar_f_Q0, // Input samples
int16_t* cth_Q15, // Filter coefficients
int16_t* sth_Q15, // Filter coefficients
int16_t order_coef) { // order of the filter
size_t order_coef) { // order of the filter
int n = 0;
for (n = 0; n < HALF_SUBFRAMELEN - 1; n++) {
int k = 0;
size_t k = 0;
int16_t tmpAR = 0;
int32_t tmp32 = 0;
int32_t tmp32_2 = 0;

View File

@ -17,11 +17,11 @@ void WebRtcIsacfix_FilterArLoop(int16_t* ar_g_Q0, // Input samples
int16_t* ar_f_Q0, // Input samples
int16_t* cth_Q15, // Filter coefficients
int16_t* sth_Q15, // Filter coefficients
int16_t order_coef) { // order of the filter
size_t order_coef) { // order of the filter
int n = 0;
for (n = 0; n < HALF_SUBFRAMELEN - 1; n++) {
int count = order_coef - 1;
int count = (int)(order_coef - 1);
int offset;
#if !defined(MIPS_DSP_R1_LE)
int16_t* tmp_cth;

View File

@ -39,7 +39,7 @@ void WebRtcIsacfix_PitchFilter(int16_t *indatFix,
void WebRtcIsacfix_PitchFilterCore(int loopNumber,
int16_t gain,
int index,
size_t index,
int16_t sign,
int16_t* inputState,
int16_t* outputBuff2,

View File

@ -34,8 +34,8 @@ static const int16_t kIntrpCoef[PITCH_FRACS][PITCH_FRACORDER] = {
{ 271, -743, 1570, -3320, 12963, 7301, -2292, 953, -325}
};
static __inline int32_t CalcLrIntQ(int32_t fixVal,
int16_t qDomain) {
static __inline size_t CalcLrIntQ(int16_t fixVal,
int16_t qDomain) {
int32_t roundVal = 1 << (qDomain - 1);
return (fixVal + roundVal) >> qDomain;
@ -55,7 +55,7 @@ void WebRtcIsacfix_PitchFilter(int16_t* indatQQ, // Q10 if type is 1 or 4,
const int16_t Gain = 21299; // 1.3 in Q14
int16_t oldLagQ7;
int16_t oldGainQ12, lagdeltaQ7, curLagQ7, gaindeltaQ12, curGainQ12;
int indW32 = 0, frcQQ = 0;
size_t indW32 = 0, frcQQ = 0;
const int16_t* fracoeffQQ = NULL;
// Assumptions in ARM assembly for WebRtcIsacfix_PitchFilterCoreARM().
@ -141,13 +141,15 @@ void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
PitchFiltstr* pfp,
int16_t* lagsQ7,
int16_t* gainsQ12) {
int k, n, m, ind, pos, pos3QQ;
int k, n, m;
size_t ind, pos, pos3QQ;
int16_t ubufQQ[PITCH_INTBUFFSIZE];
int16_t oldLagQ7, lagdeltaQ7, curLagQ7;
const int16_t* fracoeffQQ = NULL;
int16_t scale;
int16_t cnt = 0, frcQQ, indW16 = 0, tmpW16;
int16_t cnt = 0, tmpW16;
size_t frcQQ, indW16 = 0;
int32_t tmpW32, tmp2W32, csum1QQ, esumxQQ;
// Set up buffer and states.
@ -179,7 +181,7 @@ void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
for (cnt = 0; cnt < kSegments; cnt++) {
// Update parameters for each segment.
curLagQ7 += lagdeltaQ7;
indW16 = (int16_t)CalcLrIntQ(curLagQ7, 7);
indW16 = CalcLrIntQ(curLagQ7, 7);
frcQQ = ((indW16 << 7) + 64 - curLagQ7) >> 4;
if (frcQQ == PITCH_FRACS) {
@ -202,7 +204,7 @@ void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
tmp2W32 = WEBRTC_SPL_MUL_16_32_RSFT14(indatQ0[ind], tmpW32);
tmpW32 += 8192;
tmpW16 = (int16_t)(tmpW32 >> 14);
tmpW16 = tmpW32 >> 14;
tmpW32 = tmpW16 * tmpW16;
if ((tmp2W32 > 1073700000) || (csum1QQ > 1073700000) ||

View File

@ -21,7 +21,7 @@ GLOBAL_FUNCTION WebRtcIsacfix_PitchFilterCore
@ void WebRtcIsacfix_PitchFilterCore(int loopNumber,
@ int16_t gain,
@ int index,
@ size_t index,
@ int16_t sign,
@ int16_t* inputState,
@ int16_t* outputBuf2,

View File

@ -18,7 +18,7 @@ static const int16_t kDampFilter[PITCH_DAMPORDER] = {
void WebRtcIsacfix_PitchFilterCore(int loopNumber,
int16_t gain,
int index,
size_t index,
int16_t sign,
int16_t* inputState,
int16_t* outputBuf2,

View File

@ -12,7 +12,7 @@
void WebRtcIsacfix_PitchFilterCore(int loopNumber,
int16_t gain,
int index,
size_t index,
int16_t sign,
int16_t* inputState,
int16_t* outputBuf2,

View File

@ -34,7 +34,7 @@ typedef struct Bitstreamstruct_dec {
int16_t full; /* 0 - first byte in memory filled, second empty*/
/* 1 - both bytes are empty (we just filled the previous memory */
int stream_size; /* The size of stream. */
size_t stream_size; /* The size of stream in bytes. */
} Bitstr_dec;
/* Bitstream struct for encoder */
@ -178,8 +178,8 @@ typedef struct {
int16_t pitchCycles;
int16_t A;
int16_t B;
int16_t pitchIndex;
int16_t stretchLag;
size_t pitchIndex;
size_t stretchLag;
int16_t *prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240
int16_t seed;

View File

@ -26,8 +26,8 @@ class IsacSpeedTest : public AudioCodecSpeedTest {
void SetUp() override;
void TearDown() override;
virtual float EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
int max_bytes, int* encoded_bytes);
virtual float DecodeABlock(const uint8_t* bit_stream, int encoded_bytes,
size_t max_bytes, size_t* encoded_bytes);
virtual float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes,
int16_t* out_data);
ISACFIX_MainStruct *ISACFIX_main_inst_;
};
@ -43,7 +43,7 @@ void IsacSpeedTest::SetUp() {
AudioCodecSpeedTest::SetUp();
// Check whether the allocated buffer for the bit stream is large enough.
EXPECT_GE(max_bytes_, STREAM_MAXW16_60MS);
EXPECT_GE(max_bytes_, static_cast<size_t>(STREAM_MAXW16_60MS));
// Create encoder memory.
EXPECT_EQ(0, WebRtcIsacfix_Create(&ISACFIX_main_inst_));
@ -61,7 +61,7 @@ void IsacSpeedTest::TearDown() {
}
float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
int max_bytes, int* encoded_bytes) {
size_t max_bytes, size_t* encoded_bytes) {
// ISAC takes 10 ms everycall
const int subblocks = block_duration_ms_ / 10;
const int subblock_length = 10 * input_sampling_khz_;
@ -78,13 +78,13 @@ float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
EXPECT_EQ(0, value);
}
clocks = clock() - clocks;
*encoded_bytes = value;
*encoded_bytes = static_cast<size_t>(value);
assert(*encoded_bytes <= max_bytes);
return 1000.0 * clocks / CLOCKS_PER_SEC;
}
float IsacSpeedTest::DecodeABlock(const uint8_t* bit_stream,
int encoded_bytes,
size_t encoded_bytes,
int16_t* out_data) {
int value;
int16_t audio_type;

View File

@ -50,7 +50,7 @@ typedef struct {
} BottleNeckModel;
void get_arrival_time(int current_framesamples, /* samples */
int packet_size, /* bytes */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel *BN_data)
{
@ -99,7 +99,8 @@ int main(int argc, char* argv[])
FILE *inp, *outp, *f_bn, *outbits;
int endfile;
int i, errtype, h = 0, k, packetLossPercent = 0;
size_t i;
int errtype, h = 0, k, packetLossPercent = 0;
int16_t CodingMode;
int16_t bottleneck;
int framesize = 30; /* ms */
@ -108,14 +109,15 @@ int main(int argc, char* argv[])
/* Runtime statistics */
double starttime, runtime, length_file;
int16_t stream_len = 0;
int stream_len_int = 0;
size_t stream_len = 0;
int16_t framecnt;
int declen = 0;
int16_t shortdata[FRAMESAMPLES_10ms];
int16_t decoded[MAX_FRAMESAMPLES];
uint16_t streamdata[500];
int16_t speechType[1];
int16_t prevFrameSize = 1;
size_t prevFrameSize = 1;
int16_t rateBPS = 0;
int16_t fixedFL = 0;
int16_t payloadSize = 0;
@ -233,7 +235,7 @@ int main(int argc, char* argv[])
CodingMode = 0;
testNum = 0;
testCE = 0;
for (i = 1; i + 2 < argc; i++) {
for (i = 1; i + 2 < static_cast<size_t>(argc); i++) {
/* Instantaneous mode */
if (!strcmp ("-I", argv[i])) {
printf("\nInstantaneous BottleNeck\n");
@ -565,19 +567,19 @@ int main(int argc, char* argv[])
short bwe;
/* Encode */
stream_len = WebRtcIsacfix_Encode(ISAC_main_inst,
shortdata,
(uint8_t*)streamdata);
stream_len_int = WebRtcIsacfix_Encode(ISAC_main_inst,
shortdata,
(uint8_t*)streamdata);
/* If packet is ready, and CE testing, call the different API
functions from the internal API. */
if (stream_len>0) {
if (stream_len_int>0) {
if (testCE == 1) {
err = WebRtcIsacfix_ReadBwIndex(
reinterpret_cast<const uint8_t*>(streamdata),
stream_len,
static_cast<size_t>(stream_len_int),
&bwe);
stream_len = WebRtcIsacfix_GetNewBitStream(
stream_len_int = WebRtcIsacfix_GetNewBitStream(
ISAC_main_inst,
bwe,
scale,
@ -606,11 +608,11 @@ int main(int argc, char* argv[])
}
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
stream_len = WebRtcIsacfix_EncodeNb(ISAC_main_inst,
shortdata,
streamdata);
stream_len_int = WebRtcIsacfix_EncodeNb(ISAC_main_inst,
shortdata,
streamdata);
#else
stream_len = -1;
stream_len_int = -1;
#endif
}
}
@ -619,13 +621,14 @@ int main(int argc, char* argv[])
break;
}
if (stream_len < 0 || err < 0) {
if (stream_len_int < 0 || err < 0) {
/* exit if returned with error */
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in encoder: %d.\n", errtype);
} else {
stream_len = static_cast<size_t>(stream_len_int);
if (fwrite(streamdata, sizeof(char), stream_len, outbits) !=
(size_t)stream_len) {
stream_len) {
return -1;
}
}
@ -731,12 +734,12 @@ int main(int argc, char* argv[])
/* iSAC decoding */
if( lostFrame && framecnt > 0) {
if (nbTest !=2) {
declen =
WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize);
declen = static_cast<int>(
WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize));
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
declen = WebRtcIsacfix_DecodePlcNb(
ISAC_main_inst, decoded, prevFrameSize);
declen = static_cast<int>(WebRtcIsacfix_DecodePlcNb(
ISAC_main_inst, decoded, prevFrameSize));
#else
declen = -1;
#endif
@ -744,7 +747,7 @@ int main(int argc, char* argv[])
lostPackets++;
} else {
if (nbTest !=2 ) {
short FL;
size_t FL;
/* Call getFramelen, only used here for function test */
err = WebRtcIsacfix_ReadFrameLen(
reinterpret_cast<const uint8_t*>(streamdata), stream_len, &FL);
@ -755,11 +758,11 @@ int main(int argc, char* argv[])
decoded,
speechType);
/* Error check */
if (err < 0 || declen < 0 || FL != declen) {
if (err < 0 || declen < 0 || FL != static_cast<size_t>(declen)) {
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in decode_B/or getFrameLen: %d.\n", errtype);
}
prevFrameSize = declen/480;
prevFrameSize = static_cast<size_t>(declen/480);
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
@ -768,7 +771,7 @@ int main(int argc, char* argv[])
#else
declen = -1;
#endif
prevFrameSize = static_cast<int16_t>(declen / 240);
prevFrameSize = static_cast<size_t>(declen / 240);
}
}
@ -791,7 +794,7 @@ int main(int argc, char* argv[])
framecnt++;
totalsmpls += declen;
totalbits += 8 * stream_len;
totalbits += static_cast<int>(8 * stream_len);
/* Error test number 10, garbage data */
if (testNum == 10) {

View File

@ -21,6 +21,7 @@
/* include API */
#include "isac.h"
#include "isacfix.h"
#include "webrtc/base/format_macros.h"
/* max number of samples per frame (= 60 ms frame) */
#define MAX_FRAMESAMPLES 960
@ -57,7 +58,7 @@ typedef struct {
} BottleNeckModel;
void get_arrival_time(int current_framesamples, /* samples */
int packet_size, /* bytes */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel* BN_data) {
const int HeaderSize = 35;
@ -98,7 +99,7 @@ int main(int argc, char* argv[]) {
double runtime;
double length_file;
int16_t stream_len = 0;
size_t stream_len = 0;
int declen;
int16_t shortdata[FRAMESAMPLES_10ms];
@ -114,7 +115,7 @@ int main(int argc, char* argv[]) {
#ifdef _DEBUG
FILE* fy;
double kbps;
int totalbits = 0;
size_t totalbits = 0;
int totalsmpls = 0;
#endif /* _DEBUG */
@ -392,6 +393,8 @@ int main(int argc, char* argv[]) {
while (endfile == 0) {
cur_framesmpls = 0;
while (1) {
int stream_len_int;
/* Read 10 ms speech block */
if (nbTest != 1)
endfile = readframe(shortdata, inp, FRAMESAMPLES_10ms);
@ -401,9 +404,9 @@ int main(int argc, char* argv[]) {
/* iSAC encoding */
if (mode == 0 || mode == 1) {
stream_len =
stream_len_int =
WebRtcIsac_Encode(ISAC_main_inst, shortdata, (uint8_t*)streamdata);
if (stream_len < 0) {
if (stream_len_int < 0) {
/* exit if returned with error */
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
printf("\n\nError in encoder: %d.\n\n", errtype);
@ -412,20 +415,21 @@ int main(int argc, char* argv[]) {
} else if (mode == 2 || mode == 3) {
/* iSAC encoding */
if (nbTest != 1) {
stream_len = WebRtcIsacfix_Encode(ISACFIX_main_inst, shortdata,
(uint8_t*)streamdata);
stream_len_int = WebRtcIsacfix_Encode(ISACFIX_main_inst, shortdata,
(uint8_t*)streamdata);
} else {
stream_len =
stream_len_int =
WebRtcIsacfix_EncodeNb(ISACFIX_main_inst, shortdata, streamdata);
}
if (stream_len < 0) {
if (stream_len_int < 0) {
/* exit if returned with error */
errtype = WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst);
printf("\n\nError in encoder: %d.\n\n", errtype);
// exit(EXIT_FAILURE);
}
}
stream_len = (size_t)stream_len_int;
cur_framesmpls += FRAMESAMPLES_10ms;
@ -494,10 +498,13 @@ int main(int argc, char* argv[]) {
/* iSAC decoding */
if (plc && (framecnt + 1) % 10 == 0) {
if (nbTest != 2)
declen = WebRtcIsacfix_DecodePlc(ISACFIX_main_inst, decoded, 1);
else
declen = WebRtcIsacfix_DecodePlcNb(ISACFIX_main_inst, decoded, 1);
if (nbTest != 2) {
declen =
(int)WebRtcIsacfix_DecodePlc(ISACFIX_main_inst, decoded, 1);
} else {
declen =
(int)WebRtcIsacfix_DecodePlcNb(ISACFIX_main_inst, decoded, 1);
}
} else {
if (nbTest != 2)
declen = WebRtcIsacfix_Decode(ISACFIX_main_inst, streamdata,
@ -551,10 +558,13 @@ int main(int argc, char* argv[]) {
/* iSAC decoding */
if (plc && (framecnt + 1) % 10 == 0) {
if (nbTest != 2)
declen = WebRtcIsacfix_DecodePlc(ISACFIX_main_inst, decoded, 1);
else
declen = WebRtcIsacfix_DecodePlcNb(ISACFIX_main_inst, decoded, 1);
if (nbTest != 2) {
declen =
(int)WebRtcIsacfix_DecodePlc(ISACFIX_main_inst, decoded, 1);
} else {
declen =
(int)WebRtcIsacfix_DecodePlcNb(ISACFIX_main_inst, decoded, 1);
}
} else {
if (nbTest != 2) {
declen = WebRtcIsacfix_Decode(ISACFIX_main_inst, streamdata,
@ -592,7 +602,7 @@ int main(int argc, char* argv[]) {
}
#ifdef _DEBUG
printf("\n\ntotal bits = %d bits", totalbits);
printf("\n\ntotal bits = %" PRIuS " bits", totalbits);
printf("\nmeasured average bitrate = %0.3f kbits/s",
(double)totalbits * (FS / 1000) / totalsmpls);
printf("\n");

View File

@ -39,14 +39,14 @@ struct IsacFloat {
}
static inline int DecodeInternal(instance_type* inst,
const uint8_t* encoded,
int16_t len,
size_t len,
int16_t* decoded,
int16_t* speech_type) {
return WebRtcIsac_Decode(inst, encoded, len, decoded, speech_type);
}
static inline int16_t DecodePlc(instance_type* inst,
int16_t* decoded,
int16_t num_lost_frames) {
static inline size_t DecodePlc(instance_type* inst,
int16_t* decoded,
size_t num_lost_frames) {
return WebRtcIsac_DecodePlc(inst, decoded, num_lost_frames);
}
@ -102,7 +102,7 @@ struct IsacFloat {
}
static inline int16_t UpdateBwEstimate(instance_type* inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts) {

View File

@ -11,6 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_
#include <stddef.h>
#include "webrtc/modules/audio_coding/codecs/isac/bandwidth_info.h"
#include "webrtc/typedefs.h"
@ -186,7 +188,7 @@ extern "C" {
int16_t WebRtcIsac_UpdateBwEstimate(
ISACStruct* ISAC_main_inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts);
@ -215,7 +217,7 @@ extern "C" {
int WebRtcIsac_Decode(
ISACStruct* ISAC_main_inst,
const uint8_t* encoded,
int16_t len,
size_t len,
int16_t* decoded,
int16_t* speechType);
@ -235,14 +237,13 @@ extern "C" {
* Output:
* - decoded : The decoded vector.
*
* Return value : >0 - number of samples in decoded PLC vector
* -1 - Error
* Return value : Number of samples in decoded PLC vector
*/
int16_t WebRtcIsac_DecodePlc(
size_t WebRtcIsac_DecodePlc(
ISACStruct* ISAC_main_inst,
int16_t* decoded,
int16_t noOfLostFrames);
size_t noOfLostFrames);
/******************************************************************************
@ -704,7 +705,7 @@ extern "C" {
int WebRtcIsac_DecodeRcu(
ISACStruct* ISAC_main_inst,
const uint8_t* encoded,
int16_t len,
size_t len,
int16_t* decoded,
int16_t* speechType);

View File

@ -142,7 +142,7 @@ int16_t WebRtcIsac_UpdateBandwidthEstimator(
const int32_t frame_length,
const uint32_t send_ts,
const uint32_t arr_ts,
const int32_t pksize
const size_t pksize
/*, const uint16_t Index*/)
{
float weight = 0.0f;

View File

@ -95,7 +95,7 @@ extern "C" {
const int32_t frame_length,
const uint32_t send_ts,
const uint32_t arr_ts,
const int32_t pksize);
const size_t pksize);
/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */
int16_t WebRtcIsac_UpdateUplinkBwImpl(

View File

@ -25,7 +25,7 @@
void WebRtcIsac_ResetBitstream(Bitstr* bit_stream);
int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str, Bitstr* streamdata,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts, uint32_t arr_ts,
enum IsacSamplingRate encoderSampRate,
@ -195,14 +195,14 @@ void WebRtcIsac_Spec2time(const TransformTables* tables,
/******************************* filter functions ****************************/
void WebRtcIsac_AllPoleFilter(double* InOut, double* Coef, int lengthInOut,
void WebRtcIsac_AllPoleFilter(double* InOut, double* Coef, size_t lengthInOut,
int orderCoef);
void WebRtcIsac_AllZeroFilter(double* In, double* Coef, int lengthInOut,
void WebRtcIsac_AllZeroFilter(double* In, double* Coef, size_t lengthInOut,
int orderCoef, double* Out);
void WebRtcIsac_ZeroPoleFilter(double* In, double* ZeroCoef, double* PoleCoef,
int lengthInOut, int orderCoef, double* Out);
size_t lengthInOut, int orderCoef, double* Out);
/***************************** filterbank functions **************************/
@ -228,6 +228,6 @@ void WebRtcIsac_NormLatticeFilterAr(int orderCoef, float* stateF, float* stateG,
void WebRtcIsac_Dir2Lat(double* a, int orderCoef, float* sth, float* cth);
void WebRtcIsac_AutoCorr(double* r, const double* x, int N, int order);
void WebRtcIsac_AutoCorr(double* r, const double* x, size_t N, size_t order);
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CODEC_H_ */

View File

@ -18,7 +18,7 @@ int
WebRtcIsac_EstimateBandwidth(
BwEstimatorstr* bwest_str,
Bitstr* streamdata,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts,

View File

@ -19,12 +19,15 @@
void WebRtcIsac_AllPoleFilter(double *InOut, double *Coef, int lengthInOut, int orderCoef){
void WebRtcIsac_AllPoleFilter(double* InOut,
double* Coef,
size_t lengthInOut,
int orderCoef) {
/* the state of filter is assumed to be in InOut[-1] to InOut[-orderCoef] */
double scal;
double sum;
int n,k;
size_t n;
int k;
//if (fabs(Coef[0]-1.0)<0.001) {
if ( (Coef[0] > 0.9999) && (Coef[0] < 1.0001) )
@ -53,11 +56,15 @@ void WebRtcIsac_AllPoleFilter(double *InOut, double *Coef, int lengthInOut, int
}
void WebRtcIsac_AllZeroFilter(double *In, double *Coef, int lengthInOut, int orderCoef, double *Out){
void WebRtcIsac_AllZeroFilter(double* In,
double* Coef,
size_t lengthInOut,
int orderCoef,
double* Out) {
/* the state of filter is assumed to be in In[-1] to In[-orderCoef] */
int n, k;
size_t n;
int k;
double tmp;
for(n = 0; n < lengthInOut; n++)
@ -74,9 +81,12 @@ void WebRtcIsac_AllZeroFilter(double *In, double *Coef, int lengthInOut, int ord
}
void WebRtcIsac_ZeroPoleFilter(double *In, double *ZeroCoef, double *PoleCoef, int lengthInOut, int orderCoef, double *Out){
void WebRtcIsac_ZeroPoleFilter(double* In,
double* ZeroCoef,
double* PoleCoef,
size_t lengthInOut,
int orderCoef,
double* Out) {
/* the state of the zero section is assumed to be in In[-1] to In[-orderCoef] */
/* the state of the pole section is assumed to be in Out[-1] to Out[-orderCoef] */
@ -85,14 +95,8 @@ void WebRtcIsac_ZeroPoleFilter(double *In, double *ZeroCoef, double *PoleCoef, i
}
void WebRtcIsac_AutoCorr(
double *r,
const double *x,
int N,
int order
)
{
int lag, n;
void WebRtcIsac_AutoCorr(double* r, const double* x, size_t N, size_t order) {
size_t lag, n;
double sum, prod;
const double *x_lag;
@ -112,8 +116,8 @@ void WebRtcIsac_AutoCorr(
}
void WebRtcIsac_BwExpand(double *out, double *in, double coef, short length) {
int i;
void WebRtcIsac_BwExpand(double* out, double* in, double coef, size_t length) {
size_t i;
double chirp;
chirp = coef;
@ -125,8 +129,10 @@ void WebRtcIsac_BwExpand(double *out, double *in, double coef, short length) {
}
}
void WebRtcIsac_WeightingFilter(const double *in, double *weiout, double *whiout, WeightFiltstr *wfdata) {
void WebRtcIsac_WeightingFilter(const double* in,
double* weiout,
double* whiout,
WeightFiltstr* wfdata) {
double tmpbuffer[PITCH_FRAME_LEN + PITCH_WLPCBUFLEN];
double corr[PITCH_WLPCORDER+1], rc[PITCH_WLPCORDER+1];
double apol[PITCH_WLPCORDER+1], apolr[PITCH_WLPCORDER+1];
@ -195,15 +201,13 @@ static const double APupper[ALLPASSSECTIONS] = {0.0347, 0.3826};
static const double APlower[ALLPASSSECTIONS] = {0.1544, 0.744};
void WebRtcIsac_AllpassFilterForDec(double *InOut,
const double *APSectionFactors,
int lengthInOut,
double *FilterState)
{
void WebRtcIsac_AllpassFilterForDec(double* InOut,
const double* APSectionFactors,
size_t lengthInOut,
double* FilterState) {
//This performs all-pass filtering--a series of first order all-pass sections are used
//to filter the input in a cascade manner.
int n,j;
size_t n,j;
double temp;
for (j=0; j<ALLPASSSECTIONS; j++){
for (n=0;n<lengthInOut;n+=2){
@ -214,12 +218,11 @@ void WebRtcIsac_AllpassFilterForDec(double *InOut,
}
}
void WebRtcIsac_DecimateAllpass(const double *in,
double *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */
int N, /* number of input samples */
double *out) /* array of size N/2 */
{
int n;
void WebRtcIsac_DecimateAllpass(const double* in,
double* state_in,
size_t N,
double* out) {
size_t n;
double data_vec[PITCH_FRAME_LEN];
/* copy input */
@ -237,7 +240,6 @@ void WebRtcIsac_DecimateAllpass(const double *in,
}
/* create high-pass filter ocefficients
* z = 0.998 * exp(j*2*pi*35/8000);
* p = 0.94 * exp(j*2*pi*140/8000);
@ -247,9 +249,11 @@ static const double a_coef[2] = { 1.86864659625574, -0.88360000000000};
static const double b_coef[2] = {-1.99524591718270, 0.99600400000000};
/* second order high-pass filter */
void WebRtcIsac_Highpass(const double *in, double *out, double *state, int N)
{
int k;
void WebRtcIsac_Highpass(const double* in,
double* out,
double* state,
size_t N) {
size_t k;
for (k=0; k<N; k++) {
*out = *in + state[1];

View File

@ -507,7 +507,7 @@ int WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
int streamLenLB = 0;
int streamLenUB = 0;
int streamLen = 0;
int16_t k = 0;
size_t k = 0;
uint8_t garbageLen = 0;
int32_t bottleneck = 0;
int16_t bottleneckIdx = 0;
@ -528,12 +528,12 @@ int WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
if (instISAC->in_sample_rate_hz == 48000) {
/* Samples in 10 ms @ 48 kHz. */
const int kNumInputSamples = FRAMESAMPLES_10ms * 3;
const size_t kNumInputSamples = FRAMESAMPLES_10ms * 3;
/* Samples 10 ms @ 32 kHz. */
const int kNumOutputSamples = FRAMESAMPLES_10ms * 2;
const size_t kNumOutputSamples = FRAMESAMPLES_10ms * 2;
/* Resampler divide the input into blocks of 3 samples, i.e.
* kNumInputSamples / 3. */
const int kNumResamplerBlocks = FRAMESAMPLES_10ms;
const size_t kNumResamplerBlocks = FRAMESAMPLES_10ms;
int32_t buffer32[FRAMESAMPLES_10ms * 3 + SIZE_RESAMPLER_STATE];
/* Restore last samples from the past to the beginning of the buffer
@ -1006,7 +1006,7 @@ int16_t WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst) {
*/
int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst,
const uint8_t* encoded,
int32_t packet_size,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts) {
@ -1056,7 +1056,7 @@ int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst,
static int Decode(ISACStruct* ISAC_main_inst,
const uint8_t* encoded,
int16_t lenEncodedBytes,
size_t lenEncodedBytes,
int16_t* decoded,
int16_t* speechType,
int16_t isRCUPayload) {
@ -1069,13 +1069,14 @@ static int Decode(ISACStruct* ISAC_main_inst,
float outFrame[MAX_FRAMESAMPLES];
int16_t outFrameLB[MAX_FRAMESAMPLES];
int16_t outFrameUB[MAX_FRAMESAMPLES];
int numDecodedBytesLB;
int numDecodedBytesLBint;
size_t numDecodedBytesLB;
int numDecodedBytesUB;
int16_t lenEncodedLBBytes;
size_t lenEncodedLBBytes;
int16_t validChecksum = 1;
int16_t k;
uint16_t numLayer;
int16_t totSizeBytes;
size_t totSizeBytes;
int16_t err;
ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst;
@ -1089,7 +1090,7 @@ static int Decode(ISACStruct* ISAC_main_inst,
return -1;
}
if (lenEncodedBytes <= 0) {
if (lenEncodedBytes == 0) {
/* return error code if the packet length is null. */
instISAC->errorCode = ISAC_EMPTY_PACKET;
return -1;
@ -1115,11 +1116,12 @@ static int Decode(ISACStruct* ISAC_main_inst,
/* Regardless of that the current codec is setup to work in
* wideband or super-wideband, the decoding of the lower-band
* has to be performed. */
numDecodedBytesLB = WebRtcIsac_DecodeLb(&instISAC->transform_tables,
outFrame, decInstLB,
&numSamplesLB, isRCUPayload);
if ((numDecodedBytesLB < 0) || (numDecodedBytesLB > lenEncodedLBBytes) ||
numDecodedBytesLBint = WebRtcIsac_DecodeLb(&instISAC->transform_tables,
outFrame, decInstLB,
&numSamplesLB, isRCUPayload);
numDecodedBytesLB = (size_t)numDecodedBytesLBint;
if ((numDecodedBytesLBint < 0) ||
(numDecodedBytesLB > lenEncodedLBBytes) ||
(numSamplesLB > MAX_FRAMESAMPLES)) {
instISAC->errorCode = ISAC_LENGTH_MISMATCH;
return -1;
@ -1362,7 +1364,7 @@ static int Decode(ISACStruct* ISAC_main_inst,
int WebRtcIsac_Decode(ISACStruct* ISAC_main_inst,
const uint8_t* encoded,
int16_t lenEncodedBytes,
size_t lenEncodedBytes,
int16_t* decoded,
int16_t* speechType) {
int16_t isRCUPayload = 0;
@ -1394,7 +1396,7 @@ int WebRtcIsac_Decode(ISACStruct* ISAC_main_inst,
int WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst,
const uint8_t* encoded,
int16_t lenEncodedBytes,
size_t lenEncodedBytes,
int16_t* decoded,
int16_t* speechType) {
int16_t isRCUPayload = 1;
@ -1417,13 +1419,12 @@ int WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst,
* Output:
* - decoded : The decoded vector
*
* Return value : >0 - number of samples in decoded PLC vector
* -1 - Error
* Return value : Number of samples in decoded PLC vector
*/
int16_t WebRtcIsac_DecodePlc(ISACStruct* ISAC_main_inst,
int16_t* decoded,
int16_t noOfLostFrames) {
int16_t numSamples = 0;
size_t WebRtcIsac_DecodePlc(ISACStruct* ISAC_main_inst,
int16_t* decoded,
size_t noOfLostFrames) {
size_t numSamples = 0;
ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst;
/* Limit number of frames to two = 60 millisecond.

View File

@ -97,10 +97,12 @@ TEST_F(IsacTest, IsacUpdateBWE) {
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_GT(encoded_bytes, 0);
// Call to update bandwidth estimator with real data.
EXPECT_EQ(0, WebRtcIsac_UpdateBwEstimate(isac_codec_, bitstream_,
encoded_bytes, 1, 12345, 56789));
static_cast<size_t>(encoded_bytes),
1, 12345, 56789));
// Free memory.
EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));

View File

@ -75,11 +75,11 @@ static const double kLpcCorrWindow[WINLEN] = {
0.00155690, 0.00124918, 0.00094895, 0.00066112, 0.00039320, 0.00015881
};
double WebRtcIsac_LevDurb(double *a, double *k, double *r, int order)
double WebRtcIsac_LevDurb(double *a, double *k, double *r, size_t order)
{
double sum, alpha;
int m, m_h, i;
size_t m, m_h, i;
alpha = 0; //warning -DH
a[0] = 1.0;
if (r[0] < LEVINSON_EPS) { /* if r[0] <= 0, set LPC coeff. to zero */

View File

@ -21,7 +21,7 @@
#include "settings.h"
#include "structs.h"
double WebRtcIsac_LevDurb(double *a, double *k, double *r, int order);
double WebRtcIsac_LevDurb(double *a, double *k, double *r, size_t order);
void WebRtcIsac_GetVars(const double *input, const int16_t *pitchGains_Q12,
double *oldEnergy, double *varscale);

View File

@ -61,11 +61,15 @@ void WebRtcIsac_PitchfilterPre_gains(double *indat,
void WebRtcIsac_WeightingFilter(const double *in, double *weiout, double *whiout, WeightFiltstr *wfdata);
void WebRtcIsac_Highpass(const double *in, double *out, double *state, int N);
void WebRtcIsac_Highpass(const double *in,
double *out,
double *state,
size_t N);
void WebRtcIsac_DecimateAllpass(const double *in,
double *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */
int N, /* number of input samples */
double *out); /* array of size N/2 */
double *state_in, /* array of size:
* 2*ALLPASSSECTIONS+1 */
size_t N, /* number of input samples */
double *out); /* array of size N/2 */
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ */

View File

@ -21,6 +21,7 @@
/* include API */
#include "isac.h"
#include "utility.h"
#include "webrtc/base/format_macros.h"
/* Defines */
#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */
@ -42,7 +43,8 @@ int main(int argc, char* argv[]) {
FILE* inp, *outp, * f_bn = NULL, * vadp = NULL, *bandwidthp;
int framecnt, endfile;
int i, errtype, VADusage = 0, packetLossPercent = 0;
size_t i;
int errtype, VADusage = 0, packetLossPercent = 0;
int16_t CodingMode;
int32_t bottleneck = 0;
int framesize = 30; /* ms */
@ -51,7 +53,7 @@ int main(int argc, char* argv[]) {
/* Runtime statistics */
double starttime, runtime, length_file;
int16_t stream_len = 0;
size_t stream_len = 0;
int declen = 0, declenTC = 0;
bool lostFrame = false;
@ -75,14 +77,14 @@ int main(int argc, char* argv[]) {
FILE* fy;
double kbps;
#endif /* _DEBUG */
int totalbits = 0;
size_t totalbits = 0;
int totalsmpls = 0;
/* If use GNS file */
FILE* fp_gns = NULL;
char gns_file[100];
short maxStreamLen30 = 0;
short maxStreamLen60 = 0;
size_t maxStreamLen30 = 0;
size_t maxStreamLen60 = 0;
short sampFreqKHz = 32;
short samplesIn10Ms;
short useAssign = 0;
@ -90,10 +92,10 @@ int main(int argc, char* argv[]) {
bool doTransCoding = false;
int32_t rateTransCoding = 0;
uint8_t streamDataTransCoding[1200];
int16_t streamLenTransCoding = 0;
size_t streamLenTransCoding = 0;
FILE* transCodingFile = NULL;
FILE* transcodingBitstream = NULL;
uint32_t numTransCodingBytes = 0;
size_t numTransCodingBytes = 0;
/* only one structure used for ISAC encoder */
ISACStruct* ISAC_main_inst = NULL;
@ -185,7 +187,7 @@ int main(int argc, char* argv[]) {
char transCodingFileName[500];
int16_t totFileLoop = 0;
int16_t numFileLoop = 0;
for (i = 1; i + 2 < argc; i++) {
for (i = 1; i + 2 < static_cast<size_t>(argc); i++) {
if (!strcmp("-LOOP", argv[i])) {
i++;
totFileLoop = (int16_t)atol(argv[i]);
@ -579,6 +581,8 @@ int main(int argc, char* argv[]) {
cur_framesmpls = 0;
while (1) {
int stream_len_int = 0;
/* Read 10 ms speech block */
endfile = readframe(shortdata, inp, samplesIn10Ms);
@ -598,21 +602,21 @@ int main(int argc, char* argv[]) {
/* iSAC encoding */
if (!(testNum == 3 && framecnt == 0)) {
stream_len =
stream_len_int =
WebRtcIsac_Encode(ISAC_main_inst, shortdata, (uint8_t*)streamdata);
if ((payloadSize != 0) && (stream_len > payloadSize)) {
if ((payloadSize != 0) && (stream_len_int > payloadSize)) {
if (testNum == 0) {
printf("\n\n");
}
printf("\nError: Streamsize out of range %d\n",
stream_len - payloadSize);
stream_len_int - payloadSize);
cout << flush;
}
WebRtcIsac_GetUplinkBw(ISAC_main_inst, &sendBN);
if (stream_len > 0) {
if (stream_len_int > 0) {
if (doTransCoding) {
int16_t indexStream;
uint8_t auxUW8;
@ -620,13 +624,15 @@ int main(int argc, char* argv[]) {
/******************** Main Transcoding stream ********************/
WebRtcIsac_GetDownLinkBwIndex(ISAC_main_inst, &bnIdxTC,
&jitterInfoTC);
streamLenTransCoding = WebRtcIsac_GetNewBitStream(
int streamLenTransCoding_int = WebRtcIsac_GetNewBitStream(
ISAC_main_inst, bnIdxTC, jitterInfoTC, rateTransCoding,
streamDataTransCoding, false);
if (streamLenTransCoding < 0) {
if (streamLenTransCoding_int < 0) {
fprintf(stderr, "Error in trans-coding\n");
exit(0);
}
streamLenTransCoding =
static_cast<size_t>(streamLenTransCoding_int);
auxUW8 = (uint8_t)(((streamLenTransCoding & 0xFF00) >> 8) & 0x00FF);
if (fwrite(&auxUW8, sizeof(uint8_t), 1, transcodingBitstream) !=
1) {
@ -641,7 +647,7 @@ int main(int argc, char* argv[]) {
if (fwrite(streamDataTransCoding, sizeof(uint8_t),
streamLenTransCoding, transcodingBitstream) !=
static_cast<size_t>(streamLenTransCoding)) {
streamLenTransCoding) {
return -1;
}
@ -659,13 +665,15 @@ int main(int argc, char* argv[]) {
break;
}
if (stream_len < 0) {
if (stream_len_int < 0) {
/* exit if returned with error */
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
fprintf(stderr, "Error in encoder: %d.\n", errtype);
cout << flush;
exit(0);
}
stream_len = static_cast<size_t>(stream_len_int);
cur_framesmpls += samplesIn10Ms;
/* exit encoder loop if the encoder returned a bitstream */
if (stream_len != 0)
@ -703,17 +711,24 @@ int main(int argc, char* argv[]) {
// RED.
if (lostFrame) {
stream_len = WebRtcIsac_GetRedPayload(
int stream_len_int = WebRtcIsac_GetRedPayload(
ISAC_main_inst, reinterpret_cast<uint8_t*>(streamdata));
if (stream_len_int < 0) {
fprintf(stderr, "Error getting RED payload\n");
exit(0);
}
stream_len = static_cast<size_t>(stream_len_int);
if (doTransCoding) {
streamLenTransCoding = WebRtcIsac_GetNewBitStream(
int streamLenTransCoding_int = WebRtcIsac_GetNewBitStream(
ISAC_main_inst, bnIdxTC, jitterInfoTC, rateTransCoding,
streamDataTransCoding, true);
if (streamLenTransCoding < 0) {
if (streamLenTransCoding_int < 0) {
fprintf(stderr, "Error in RED trans-coding\n");
exit(0);
}
streamLenTransCoding =
static_cast<size_t>(streamLenTransCoding_int);
}
}
@ -891,7 +906,7 @@ int main(int argc, char* argv[]) {
#endif /* _DEBUG */
}
printf("\n");
printf("total bits = %d bits\n", totalbits);
printf("total bits = %" PRIuS " bits\n", totalbits);
printf("measured average bitrate = %0.3f kbits/s\n",
(double)totalbits * (sampFreqKHz) / totalsmpls);
if (doTransCoding) {
@ -910,11 +925,11 @@ int main(int argc, char* argv[]) {
(100 * runtime / length_file));
if (maxStreamLen30 != 0) {
printf("Maximum payload size 30ms Frames %d bytes (%0.3f kbps)\n",
printf("Maximum payload size 30ms Frames %" PRIuS " bytes (%0.3f kbps)\n",
maxStreamLen30, maxStreamLen30 * 8 / 30.);
}
if (maxStreamLen60 != 0) {
printf("Maximum payload size 60ms Frames %d bytes (%0.3f kbps)\n",
printf("Maximum payload size 60ms Frames %" PRIuS " bytes (%0.3f kbps)\n",
maxStreamLen60, maxStreamLen60 * 8 / 60.);
}
// fprintf(stderr, "\n");
@ -923,12 +938,12 @@ int main(int argc, char* argv[]) {
fprintf(stderr, " %0.1f kbps",
(double)totalbits * (sampFreqKHz) / totalsmpls);
if (maxStreamLen30 != 0) {
fprintf(stderr, " plmax-30ms %d bytes (%0.0f kbps)", maxStreamLen30,
maxStreamLen30 * 8 / 30.);
fprintf(stderr, " plmax-30ms %" PRIuS " bytes (%0.0f kbps)",
maxStreamLen30, maxStreamLen30 * 8 / 30.);
}
if (maxStreamLen60 != 0) {
fprintf(stderr, " plmax-60ms %d bytes (%0.0f kbps)", maxStreamLen60,
maxStreamLen60 * 8 / 60.);
fprintf(stderr, " plmax-60ms %" PRIuS " bytes (%0.0f kbps)",
maxStreamLen60, maxStreamLen60 * 8 / 60.);
}
if (doTransCoding) {
fprintf(stderr, " transcoding rate %.0f kbps",

View File

@ -51,9 +51,9 @@ int main(int argc, char* argv[])
short clientCntr;
unsigned int lenEncodedInBytes[MAX_NUM_CLIENTS];
size_t lenEncodedInBytes[MAX_NUM_CLIENTS];
unsigned int lenAudioIn10ms[MAX_NUM_CLIENTS];
unsigned int lenEncodedInBytesTmp[MAX_NUM_CLIENTS];
size_t lenEncodedInBytesTmp[MAX_NUM_CLIENTS];
unsigned int lenAudioIn10msTmp[MAX_NUM_CLIENTS];
BottleNeckModel* packetData[MAX_NUM_CLIENTS];
@ -189,9 +189,9 @@ int main(int argc, char* argv[])
}
short streamLen;
size_t streamLen;
short numSamplesRead;
int lenDecodedAudio;
size_t lenDecodedAudio;
short senderIdx;
short receiverIdx;
@ -282,11 +282,11 @@ int main(int argc, char* argv[])
// Encode
streamLen = WebRtcIsac_Encode(codecInstance[senderIdx],
audioBuff10ms,
(uint8_t*)bitStream);
int streamLen_int = WebRtcIsac_Encode(codecInstance[senderIdx],
audioBuff10ms,
(uint8_t*)bitStream);
int16_t ggg;
if (streamLen > 0) {
if (streamLen_int > 0) {
if ((WebRtcIsac_ReadFrameLen(
codecInstance[receiverIdx],
reinterpret_cast<const uint8_t*>(bitStream),
@ -295,11 +295,12 @@ int main(int argc, char* argv[])
}
// Sanity check
if(streamLen < 0)
if(streamLen_int < 0)
{
printf(" Encoder error in client %d \n", senderIdx + 1);
return -1;
}
streamLen = static_cast<size_t>(streamLen_int);
if(streamLen > 0)
@ -423,18 +424,18 @@ int main(int argc, char* argv[])
}
/**/
// Decode
lenDecodedAudio = WebRtcIsac_Decode(
int lenDecodedAudio_int = WebRtcIsac_Decode(
codecInstance[receiverIdx],
reinterpret_cast<const uint8_t*>(bitStream),
streamLen,
audioBuff60ms,
speechType);
if(lenDecodedAudio < 0)
if(lenDecodedAudio_int < 0)
{
printf(" Decoder error in client %d \n", receiverIdx + 1);
return -1;
}
lenDecodedAudio = static_cast<size_t>(lenDecodedAudio_int);
if(encoderSampRate[senderIdx] == 16000)
{
@ -442,7 +443,7 @@ int main(int argc, char* argv[])
resamplerState[receiverIdx]);
if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1,
outFile[receiverIdx]) !=
static_cast<size_t>(lenDecodedAudio << 1)) {
lenDecodedAudio << 1) {
return -1;
}
}
@ -450,7 +451,7 @@ int main(int argc, char* argv[])
{
if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio,
outFile[receiverIdx]) !=
static_cast<size_t>(lenDecodedAudio)) {
lenDecodedAudio) {
return -1;
}
}

View File

@ -26,6 +26,7 @@
/* include API */
#include "isac.h"
#include "utility.h"
#include "webrtc/base/format_macros.h"
//#include "commonDefs.h"
/* max number of samples per frame (= 60 ms frame) */
@ -57,7 +58,7 @@ int main(int argc, char* argv[]) {
/* Runtime statistics */
double rate;
double rateRCU;
unsigned long totalbits = 0;
size_t totalbits = 0;
unsigned long totalBitsRCU = 0;
unsigned long totalsmpls = 0;
@ -72,7 +73,7 @@ int main(int argc, char* argv[]) {
int32_t rateLimit;
ISACStruct* ISAC_main_inst;
int16_t stream_len = 0;
size_t stream_len = 0;
int declen = 0;
int16_t err;
int cur_framesmpls;
@ -94,7 +95,7 @@ int main(int argc, char* argv[]) {
FILE* averageFile;
int sampFreqKHz;
int samplesIn10Ms;
int16_t maxStreamLen = 0;
size_t maxStreamLen = 0;
char histFileName[500];
char averageFileName[500];
unsigned int hist[600];
@ -310,22 +311,22 @@ int main(int argc, char* argv[]) {
if (onlyDecode) {
uint8_t auxUW8;
size_t auxSizet;
if (fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1) {
break;
}
stream_len = ((uint8_t)auxUW8) << 8;
stream_len = auxUW8 << 8;
if (fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1) {
break;
}
stream_len |= (uint16_t)auxUW8;
auxSizet = (size_t)stream_len;
if (fread(payload, 1, auxSizet, inp) < auxSizet) {
stream_len |= auxUW8;
if (fread(payload, 1, stream_len, inp) < stream_len) {
printf("last payload is corrupted\n");
break;
}
} else {
while (stream_len == 0) {
int stream_len_int;
// Read 10 ms speech block
endfile = readframe(shortdata, inp, samplesIn10Ms);
if (endfile) {
@ -334,15 +335,16 @@ int main(int argc, char* argv[]) {
cur_framesmpls += samplesIn10Ms;
//-------- iSAC encoding ---------
stream_len = WebRtcIsac_Encode(ISAC_main_inst, shortdata, payload);
stream_len_int = WebRtcIsac_Encode(ISAC_main_inst, shortdata, payload);
if (stream_len < 0) {
if (stream_len_int < 0) {
// exit if returned with error
// errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
fprintf(stderr, "\nError in encoder\n");
getc(stdin);
exit(EXIT_FAILURE);
}
stream_len = (size_t)stream_len_int;
}
//===================================================================
if (endfile) {
@ -396,15 +398,16 @@ int main(int argc, char* argv[]) {
if (fwrite(&auxUW8, sizeof(uint8_t), 1, outp) != 1) {
return -1;
}
if (fwrite(payload, 1, stream_len, outp) != (size_t)stream_len) {
if (fwrite(payload, 1, stream_len, outp) != stream_len) {
return -1;
}
} else {
//======================= iSAC decoding ===========================
if ((rand() % 100) < packetLossPercent) {
declen = WebRtcIsac_DecodeRcu(ISAC_main_inst, payloadRCU, rcuStreamLen,
decoded, speechType);
declen = WebRtcIsac_DecodeRcu(ISAC_main_inst, payloadRCU,
(size_t)rcuStreamLen, decoded,
speechType);
lostPacketCntr++;
} else {
declen = WebRtcIsac_Decode(ISAC_main_inst, payload, stream_len, decoded,
@ -458,7 +461,7 @@ int main(int argc, char* argv[]) {
printf("\n");
printf("Measured bit-rate........... %0.3f kbps\n", rate);
printf("Measured RCU bit-ratre...... %0.3f kbps\n", rateRCU);
printf("Maximum bit-rate/payloadsize %0.3f / %d\n",
printf("Maximum bit-rate/payloadsize %0.3f / %" PRIuS "\n",
maxStreamLen * 8 / 0.03, maxStreamLen);
printf("Measured packet-loss........ %0.1f%% \n",
100.0f * (float)lostPacketCntr / (float)packetCntr);

View File

@ -135,7 +135,7 @@ readParamString(
void
get_arrival_time(
int current_framesamples, /* samples */
int packet_size, /* bytes */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel* BN_data,
short senderSampFreqHz,

View File

@ -99,7 +99,7 @@ extern "C" {
void get_arrival_time(
int current_framesamples, /* samples */
int packet_size, /* bytes */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel* BN_data,
short senderSampFreqHz,