提交 70f58aa3 authored 作者: Anthony Minessale's avatar Anthony Minessale

rm svn dif

上级 726842cb
K 25
svn:wc:ra_dav:version-url
V 73
/svn/!svn/ver/1323/trunk/src/modules/audio_coding/codecs/iSAC/main/source
END
pitch_estimator.c
K 25
svn:wc:ra_dav:version-url
V 90
/svn/!svn/ver/270/trunk/src/modules/audio_coding/codecs/iSAC/main/source/pitch_estimator.c
END
spectrum_ar_model_tables.c
K 25
svn:wc:ra_dav:version-url
V 99
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/spectrum_ar_model_tables.c
END
pitch_estimator.h
K 25
svn:wc:ra_dav:version-url
V 90
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/pitch_estimator.h
END
spectrum_ar_model_tables.h
K 25
svn:wc:ra_dav:version-url
V 99
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/spectrum_ar_model_tables.h
END
filterbanks.c
K 25
svn:wc:ra_dav:version-url
V 87
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/filterbanks.c
END
crc.c
K 25
svn:wc:ra_dav:version-url
V 79
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/crc.c
END
filterbank_tables.c
K 25
svn:wc:ra_dav:version-url
V 93
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/filterbank_tables.c
END
structs.h
K 25
svn:wc:ra_dav:version-url
V 82
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/structs.h
END
crc.h
K 25
svn:wc:ra_dav:version-url
V 78
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/crc.h
END
fft.c
K 25
svn:wc:ra_dav:version-url
V 78
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/fft.c
END
arith_routines_logist.c
K 25
svn:wc:ra_dav:version-url
V 96
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/arith_routines_logist.c
END
filterbank_tables.h
K 25
svn:wc:ra_dav:version-url
V 93
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/filterbank_tables.h
END
lpc_gain_swb_tables.c
K 25
svn:wc:ra_dav:version-url
V 94
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_gain_swb_tables.c
END
codec.h
K 25
svn:wc:ra_dav:version-url
V 80
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/codec.h
END
decode.c
K 25
svn:wc:ra_dav:version-url
V 81
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/decode.c
END
pitch_lag_tables.c
K 25
svn:wc:ra_dav:version-url
V 91
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/pitch_lag_tables.c
END
fft.h
K 25
svn:wc:ra_dav:version-url
V 78
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/fft.h
END
lpc_gain_swb_tables.h
K 25
svn:wc:ra_dav:version-url
V 94
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_gain_swb_tables.h
END
arith_routines_hist.c
K 25
svn:wc:ra_dav:version-url
V 94
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/arith_routines_hist.c
END
os_specific_inline.h
K 25
svn:wc:ra_dav:version-url
V 94
/svn/!svn/ver/1323/trunk/src/modules/audio_coding/codecs/iSAC/main/source/os_specific_inline.h
END
pitch_lag_tables.h
K 25
svn:wc:ra_dav:version-url
V 91
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/pitch_lag_tables.h
END
bandwidth_estimator.c
K 25
svn:wc:ra_dav:version-url
V 95
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/bandwidth_estimator.c
END
pitch_gain_tables.c
K 25
svn:wc:ra_dav:version-url
V 92
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/pitch_gain_tables.c
END
arith_routines.c
K 25
svn:wc:ra_dav:version-url
V 89
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/arith_routines.c
END
bandwidth_estimator.h
K 25
svn:wc:ra_dav:version-url
V 95
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/bandwidth_estimator.h
END
pitch_gain_tables.h
K 25
svn:wc:ra_dav:version-url
V 92
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/pitch_gain_tables.h
END
arith_routines.h
K 25
svn:wc:ra_dav:version-url
V 89
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/arith_routines.h
END
settings.h
K 25
svn:wc:ra_dav:version-url
V 83
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/settings.h
END
isac.gypi
K 25
svn:wc:ra_dav:version-url
V 83
/svn/!svn/ver/1323/trunk/src/modules/audio_coding/codecs/iSAC/main/source/isac.gypi
END
Android.mk
K 25
svn:wc:ra_dav:version-url
V 83
/svn/!svn/ver/959/trunk/src/modules/audio_coding/codecs/iSAC/main/source/Android.mk
END
lpc_shape_swb12_tables.c
K 25
svn:wc:ra_dav:version-url
V 97
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_shape_swb12_tables.c
END
encode_lpc_swb.c
K 25
svn:wc:ra_dav:version-url
V 90
/svn/!svn/ver/1286/trunk/src/modules/audio_coding/codecs/iSAC/main/source/encode_lpc_swb.c
END
lpc_tables.c
K 25
svn:wc:ra_dav:version-url
V 85
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_tables.c
END
lpc_shape_swb16_tables.c
K 25
svn:wc:ra_dav:version-url
V 98
/svn/!svn/ver/1286/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_shape_swb16_tables.c
END
transform.c
K 25
svn:wc:ra_dav:version-url
V 85
/svn/!svn/ver/1323/trunk/src/modules/audio_coding/codecs/iSAC/main/source/transform.c
END
lpc_shape_swb12_tables.h
K 25
svn:wc:ra_dav:version-url
V 97
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_shape_swb12_tables.h
END
encode_lpc_swb.h
K 25
svn:wc:ra_dav:version-url
V 89
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/encode_lpc_swb.h
END
pitch_filter.c
K 25
svn:wc:ra_dav:version-url
V 88
/svn/!svn/ver/1323/trunk/src/modules/audio_coding/codecs/iSAC/main/source/pitch_filter.c
END
filter_functions.c
K 25
svn:wc:ra_dav:version-url
V 91
/svn/!svn/ver/270/trunk/src/modules/audio_coding/codecs/iSAC/main/source/filter_functions.c
END
lpc_tables.h
K 25
svn:wc:ra_dav:version-url
V 85
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_tables.h
END
isac.c
K 25
svn:wc:ra_dav:version-url
V 80
/svn/!svn/ver/1323/trunk/src/modules/audio_coding/codecs/iSAC/main/source/isac.c
END
lpc_shape_swb16_tables.h
K 25
svn:wc:ra_dav:version-url
V 98
/svn/!svn/ver/1286/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_shape_swb16_tables.h
END
decode_bwe.c
K 25
svn:wc:ra_dav:version-url
V 85
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/decode_bwe.c
END
lpc_analysis.c
K 25
svn:wc:ra_dav:version-url
V 88
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_analysis.c
END
entropy_coding.c
K 25
svn:wc:ra_dav:version-url
V 90
/svn/!svn/ver/1323/trunk/src/modules/audio_coding/codecs/iSAC/main/source/entropy_coding.c
END
lattice.c
K 25
svn:wc:ra_dav:version-url
V 82
/svn/!svn/ver/270/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lattice.c
END
lpc_analysis.h
K 25
svn:wc:ra_dav:version-url
V 88
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/lpc_analysis.h
END
intialize.c
K 25
svn:wc:ra_dav:version-url
V 84
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/intialize.c
END
entropy_coding.h
K 25
svn:wc:ra_dav:version-url
V 89
/svn/!svn/ver/156/trunk/src/modules/audio_coding/codecs/iSAC/main/source/entropy_coding.h
END
encode.c
K 25
svn:wc:ra_dav:version-url
V 82
/svn/!svn/ver/1073/trunk/src/modules/audio_coding/codecs/iSAC/main/source/encode.c
END
差异被折叠。
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../../../../../../../android-webrtc.mk
LOCAL_ARM_MODE := arm
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE := libwebrtc_isac
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
arith_routines.c \
arith_routines_hist.c \
arith_routines_logist.c \
bandwidth_estimator.c \
crc.c \
decode.c \
decode_bwe.c \
encode.c \
encode_lpc_swb.c \
entropy_coding.c \
fft.c \
filter_functions.c \
filterbank_tables.c \
intialize.c \
isac.c \
filterbanks.c \
pitch_lag_tables.c \
lattice.c \
lpc_gain_swb_tables.c \
lpc_analysis.c \
lpc_shape_swb12_tables.c \
lpc_shape_swb16_tables.c \
lpc_tables.c \
pitch_estimator.c \
pitch_filter.c \
pitch_gain_tables.c \
spectrum_ar_model_tables.c \
transform.c
# Flags passed to both C and C++ files.
LOCAL_CFLAGS := \
$(MY_WEBRTC_COMMON_DEFS)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../interface \
$(LOCAL_PATH)/../../../../../.. \
$(LOCAL_PATH)/../../../../../../common_audio/signal_processing/include
LOCAL_SHARED_LIBRARIES := \
libcutils \
libdl \
libstlport
ifndef NDK_ROOT
include external/stlport/libstlport.mk
endif
include $(BUILD_STATIC_LIBRARY)
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "arith_routines.h"
#include "settings.h"
/*
* terminate and return byte stream;
* returns the number of bytes in the stream
*/
int WebRtcIsac_EncTerminate(Bitstr *streamdata) /* in-/output struct containing bitstream */
{
WebRtc_UWord8 *stream_ptr;
/* point to the right place in the stream buffer */
stream_ptr = streamdata->stream + streamdata->stream_index;
/* find minimum length (determined by current interval width) */
if ( streamdata->W_upper > 0x01FFFFFF )
{
streamdata->streamval += 0x01000000;
/* add carry to buffer */
if (streamdata->streamval < 0x01000000)
{
/* propagate carry */
while ( !(++(*--stream_ptr)) );
/* put pointer back to the old value */
stream_ptr = streamdata->stream + streamdata->stream_index;
}
/* write remaining data to bitstream */
*stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24);
}
else
{
streamdata->streamval += 0x00010000;
/* add carry to buffer */
if (streamdata->streamval < 0x00010000)
{
/* propagate carry */
while ( !(++(*--stream_ptr)) );
/* put pointer back to the old value */
stream_ptr = streamdata->stream + streamdata->stream_index;
}
/* write remaining data to bitstream */
*stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24);
*stream_ptr++ = (WebRtc_UWord8) ((streamdata->streamval >> 16) & 0x00FF);
}
/* calculate stream length */
return (int)(stream_ptr - streamdata->stream);
}
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* arith_routines.h
*
* Functions for arithmetic coding.
*
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_
#include "structs.h"
int WebRtcIsac_EncLogisticMulti2(
Bitstr *streamdata, /* in-/output struct containing bitstream */
WebRtc_Word16 *dataQ7, /* input: data vector */
const WebRtc_UWord16 *env, /* input: side info vector defining the width of the pdf */
const int N, /* input: data vector length */
const WebRtc_Word16 isSWB12kHz); /* if the codec is working in 12kHz bandwidth */
/* returns the number of bytes in the stream */
int WebRtcIsac_EncTerminate(Bitstr *streamdata); /* in-/output struct containing bitstream */
/* returns the number of bytes in the stream so far */
int WebRtcIsac_DecLogisticMulti2(
WebRtc_Word16 *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const WebRtc_UWord16 *env, /* input: side info vector defining the width of the pdf */
const WebRtc_Word16 *dither, /* input: dither vector */
const int N, /* input: data vector length */
const WebRtc_Word16 isSWB12kHz); /* if the codec is working in 12kHz bandwidth */
void WebRtcIsac_EncHistMulti(
Bitstr *streamdata, /* in-/output struct containing bitstream */
const int *data, /* input: data vector */
const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */
const int N); /* input: data vector length */
int WebRtcIsac_DecHistBisectMulti(
int *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */
const WebRtc_UWord16 *cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */
const int N); /* input: data vector length */
int WebRtcIsac_DecHistOneStepMulti(
int *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */
const WebRtc_UWord16 *init_index,/* input: vector of initial cdf table search entries */
const int N); /* input: data vector length */
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_ */
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "settings.h"
#include "arith_routines.h"
/*
* code symbols into arithmetic bytestream
*/
void WebRtcIsac_EncHistMulti(Bitstr *streamdata, /* in-/output struct containing bitstream */
const int *data, /* input: data vector */
const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */
const int N) /* input: data vector length */
{
WebRtc_UWord32 W_lower, W_upper;
WebRtc_UWord32 W_upper_LSB, W_upper_MSB;
WebRtc_UWord8 *stream_ptr;
WebRtc_UWord8 *stream_ptr_carry;
WebRtc_UWord32 cdf_lo, cdf_hi;
int k;
/* point to beginning of stream buffer */
stream_ptr = streamdata->stream + streamdata->stream_index;
W_upper = streamdata->W_upper;
for (k=N; k>0; k--)
{
/* fetch cdf_lower and cdf_upper from cdf tables */
cdf_lo = (WebRtc_UWord32) *(*cdf + *data);
cdf_hi = (WebRtc_UWord32) *(*cdf++ + *data++ + 1);
/* update interval */
W_upper_LSB = W_upper & 0x0000FFFF;
W_upper_MSB = W_upper >> 16;
W_lower = W_upper_MSB * cdf_lo;
W_lower += (W_upper_LSB * cdf_lo) >> 16;
W_upper = W_upper_MSB * cdf_hi;
W_upper += (W_upper_LSB * cdf_hi) >> 16;
/* shift interval such that it begins at zero */
W_upper -= ++W_lower;
/* add integer to bitstream */
streamdata->streamval += W_lower;
/* handle carry */
if (streamdata->streamval < W_lower)
{
/* propagate carry */
stream_ptr_carry = stream_ptr;
while (!(++(*--stream_ptr_carry)));
}
/* renormalize interval, store most significant byte of streamval and update streamval */
while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */
{
W_upper <<= 8;
*stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24);
streamdata->streamval <<= 8;
}
}
/* calculate new stream_index */
streamdata->stream_index = (int)(stream_ptr - streamdata->stream);
streamdata->W_upper = W_upper;
return;
}
/*
* function to decode more symbols from the arithmetic bytestream, using method of bisection
* cdf tables should be of size 2^k-1 (which corresponds to an alphabet size of 2^k-2)
*/
int WebRtcIsac_DecHistBisectMulti(int *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */
const WebRtc_UWord16 *cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */
const int N) /* input: data vector length */
{
WebRtc_UWord32 W_lower, W_upper;
WebRtc_UWord32 W_tmp;
WebRtc_UWord32 W_upper_LSB, W_upper_MSB;
WebRtc_UWord32 streamval;
const WebRtc_UWord8 *stream_ptr;
const WebRtc_UWord16 *cdf_ptr;
int size_tmp;
int k;
W_lower = 0; //to remove warning -DH
stream_ptr = streamdata->stream + streamdata->stream_index;
W_upper = streamdata->W_upper;
if (W_upper == 0)
/* Should not be possible in normal operation */
return -2;
if (streamdata->stream_index == 0) /* first time decoder is called for this stream */
{
/* read first word from bytestream */
streamval = *stream_ptr << 24;
streamval |= *++stream_ptr << 16;
streamval |= *++stream_ptr << 8;
streamval |= *++stream_ptr;
} else {
streamval = streamdata->streamval;
}
for (k=N; k>0; k--)
{
/* find the integer *data for which streamval lies in [W_lower+1, W_upper] */
W_upper_LSB = W_upper & 0x0000FFFF;
W_upper_MSB = W_upper >> 16;
/* start halfway the cdf range */
size_tmp = *cdf_size++ >> 1;
cdf_ptr = *cdf + (size_tmp - 1);
/* method of bisection */
for ( ;; )
{
W_tmp = W_upper_MSB * *cdf_ptr;
W_tmp += (W_upper_LSB * *cdf_ptr) >> 16;
size_tmp >>= 1;
if (size_tmp == 0) break;
if (streamval > W_tmp)
{
W_lower = W_tmp;
cdf_ptr += size_tmp;
} else {
W_upper = W_tmp;
cdf_ptr -= size_tmp;
}
}
if (streamval > W_tmp)
{
W_lower = W_tmp;
*data++ = (int)(cdf_ptr - *cdf++);
} else {
W_upper = W_tmp;
*data++ = (int)(cdf_ptr - *cdf++ - 1);
}
/* shift interval to start at zero */
W_upper -= ++W_lower;
/* add integer to bitstream */
streamval -= W_lower;
/* renormalize interval and update streamval */
while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */
{
/* read next byte from stream */
streamval = (streamval << 8) | *++stream_ptr;
W_upper <<= 8;
}
if (W_upper == 0)
/* Should not be possible in normal operation */
return -2;
}
streamdata->stream_index = (int)(stream_ptr - streamdata->stream);
streamdata->W_upper = W_upper;
streamdata->streamval = streamval;
/* find number of bytes in original stream (determined by current interval width) */
if ( W_upper > 0x01FFFFFF )
return streamdata->stream_index - 2;
else
return streamdata->stream_index - 1;
}
/*
* function to decode more symbols from the arithmetic bytestream, taking single step up or
* down at a time
* cdf tables can be of arbitrary size, but large tables may take a lot of iterations
*/
int WebRtcIsac_DecHistOneStepMulti(int *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */
const WebRtc_UWord16 *init_index, /* input: vector of initial cdf table search entries */
const int N) /* input: data vector length */
{
WebRtc_UWord32 W_lower, W_upper;
WebRtc_UWord32 W_tmp;
WebRtc_UWord32 W_upper_LSB, W_upper_MSB;
WebRtc_UWord32 streamval;
const WebRtc_UWord8 *stream_ptr;
const WebRtc_UWord16 *cdf_ptr;
int k;
stream_ptr = streamdata->stream + streamdata->stream_index;
W_upper = streamdata->W_upper;
if (W_upper == 0)
/* Should not be possible in normal operation */
return -2;
if (streamdata->stream_index == 0) /* first time decoder is called for this stream */
{
/* read first word from bytestream */
streamval = *stream_ptr << 24;
streamval |= *++stream_ptr << 16;
streamval |= *++stream_ptr << 8;
streamval |= *++stream_ptr;
} else {
streamval = streamdata->streamval;
}
for (k=N; k>0; k--)
{
/* find the integer *data for which streamval lies in [W_lower+1, W_upper] */
W_upper_LSB = W_upper & 0x0000FFFF;
W_upper_MSB = W_upper >> 16;
/* start at the specified table entry */
cdf_ptr = *cdf + (*init_index++);
W_tmp = W_upper_MSB * *cdf_ptr;
W_tmp += (W_upper_LSB * *cdf_ptr) >> 16;
if (streamval > W_tmp)
{
for ( ;; )
{
W_lower = W_tmp;
if (cdf_ptr[0]==65535)
/* range check */
return -3;
W_tmp = W_upper_MSB * *++cdf_ptr;
W_tmp += (W_upper_LSB * *cdf_ptr) >> 16;
if (streamval <= W_tmp) break;
}
W_upper = W_tmp;
*data++ = (int)(cdf_ptr - *cdf++ - 1);
} else {
for ( ;; )
{
W_upper = W_tmp;
--cdf_ptr;
if (cdf_ptr<*cdf) {
/* range check */
return -3;
}
W_tmp = W_upper_MSB * *cdf_ptr;
W_tmp += (W_upper_LSB * *cdf_ptr) >> 16;
if (streamval > W_tmp) break;
}
W_lower = W_tmp;
*data++ = (int)(cdf_ptr - *cdf++);
}
/* shift interval to start at zero */
W_upper -= ++W_lower;
/* add integer to bitstream */
streamval -= W_lower;
/* renormalize interval and update streamval */
while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */
{
/* read next byte from stream */
streamval = (streamval << 8) | *++stream_ptr;
W_upper <<= 8;
}
}
streamdata->stream_index = (int)(stream_ptr - streamdata->stream);
streamdata->W_upper = W_upper;
streamdata->streamval = streamval;
/* find number of bytes in original stream (determined by current interval width) */
if ( W_upper > 0x01FFFFFF )
return streamdata->stream_index - 2;
else
return streamdata->stream_index - 1;
}
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* arith_routines.h
*
* This file contains functions for arithmatically encoding and
* decoding DFT coefficients.
*
*/
#include "arith_routines.h"
static const WebRtc_Word32 kHistEdgesQ15[51] = {
-327680, -314573, -301466, -288359, -275252, -262144, -249037, -235930, -222823, -209716,
-196608, -183501, -170394, -157287, -144180, -131072, -117965, -104858, -91751, -78644,
-65536, -52429, -39322, -26215, -13108, 0, 13107, 26214, 39321, 52428,
65536, 78643, 91750, 104857, 117964, 131072, 144179, 157286, 170393, 183500,
196608, 209715, 222822, 235929, 249036, 262144, 275251, 288358, 301465, 314572,
327680};
static const int kCdfSlopeQ0[51] = { /* Q0 */
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 13, 23, 47, 87, 154, 315, 700, 1088,
2471, 6064, 14221, 21463, 36634, 36924, 19750, 13270, 5806, 2312,
1095, 660, 316, 145, 86, 41, 32, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 0};
static const int kCdfQ16[51] = { /* Q16 */
0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
20, 22, 24, 29, 38, 57, 92, 153, 279, 559,
994, 1983, 4408, 10097, 18682, 33336, 48105, 56005, 61313, 63636,
64560, 64998, 65262, 65389, 65447, 65481, 65497, 65510, 65512, 65514,
65516, 65518, 65520, 65522, 65524, 65526, 65528, 65530, 65532, 65534,
65535};
/* function to be converted to fixed point */
static __inline WebRtc_UWord32 piecewise(WebRtc_Word32 xinQ15) {
WebRtc_Word32 ind, qtmp1, qtmp2, qtmp3;
WebRtc_UWord32 tmpUW32;
qtmp2 = xinQ15;
if (qtmp2 < kHistEdgesQ15[0]) {
qtmp2 = kHistEdgesQ15[0];
}
if (qtmp2 > kHistEdgesQ15[50]) {
qtmp2 = kHistEdgesQ15[50];
}
qtmp1 = qtmp2 - kHistEdgesQ15[0]; /* Q15 - Q15 = Q15 */
ind = (qtmp1 * 5) >> 16; /* 2^16 / 5 = 0.4 in Q15 */
/* Q15 -> Q0 */
qtmp1 = qtmp2 - kHistEdgesQ15[ind]; /* Q15 - Q15 = Q15 */
qtmp2 = kCdfSlopeQ0[ind] * qtmp1; /* Q0 * Q15 = Q15 */
qtmp3 = qtmp2>>15; /* Q15 -> Q0 */
tmpUW32 = kCdfQ16[ind] + qtmp3; /* Q0 + Q0 = Q0 */
return tmpUW32;
}
int WebRtcIsac_EncLogisticMulti2(
Bitstr *streamdata, /* in-/output struct containing bitstream */
WebRtc_Word16 *dataQ7, /* input: data vector */
const WebRtc_UWord16 *envQ8, /* input: side info vector defining the width of the pdf */
const int N, /* input: data vector length / 2 */
const WebRtc_Word16 isSWB12kHz)
{
WebRtc_UWord32 W_lower, W_upper;
WebRtc_UWord32 W_upper_LSB, W_upper_MSB;
WebRtc_UWord8 *stream_ptr;
WebRtc_UWord8 *maxStreamPtr;
WebRtc_UWord8 *stream_ptr_carry;
WebRtc_UWord32 cdf_lo, cdf_hi;
int k;
/* point to beginning of stream buffer */
stream_ptr = streamdata->stream + streamdata->stream_index;
W_upper = streamdata->W_upper;
maxStreamPtr = streamdata->stream + STREAM_SIZE_MAX_60 - 1;
for (k = 0; k < N; k++)
{
/* compute cdf_lower and cdf_upper by evaluating the piecewise linear cdf */
cdf_lo = piecewise((*dataQ7 - 64) * *envQ8);
cdf_hi = piecewise((*dataQ7 + 64) * *envQ8);
/* test and clip if probability gets too small */
while (cdf_lo+1 >= cdf_hi) {
/* clip */
if (*dataQ7 > 0) {
*dataQ7 -= 128;
cdf_hi = cdf_lo;
cdf_lo = piecewise((*dataQ7 - 64) * *envQ8);
} else {
*dataQ7 += 128;
cdf_lo = cdf_hi;
cdf_hi = piecewise((*dataQ7 + 64) * *envQ8);
}
}
dataQ7++;
// increment only once per 4 iterations for SWB-16kHz or WB
// increment only once per 2 iterations for SWB-12kHz
envQ8 += (isSWB12kHz)? (k & 1):((k & 1) & (k >> 1));
/* update interval */
W_upper_LSB = W_upper & 0x0000FFFF;
W_upper_MSB = W_upper >> 16;
W_lower = W_upper_MSB * cdf_lo;
W_lower += (W_upper_LSB * cdf_lo) >> 16;
W_upper = W_upper_MSB * cdf_hi;
W_upper += (W_upper_LSB * cdf_hi) >> 16;
/* shift interval such that it begins at zero */
W_upper -= ++W_lower;
/* add integer to bitstream */
streamdata->streamval += W_lower;
/* handle carry */
if (streamdata->streamval < W_lower)
{
/* propagate carry */
stream_ptr_carry = stream_ptr;
while (!(++(*--stream_ptr_carry)));
}
/* renormalize interval, store most significant byte of streamval and update streamval */
while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */
{
W_upper <<= 8;
*stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24);
if(stream_ptr > maxStreamPtr)
{
return -ISAC_DISALLOWED_BITSTREAM_LENGTH;
}
streamdata->streamval <<= 8;
}
}
/* calculate new stream_index */
streamdata->stream_index = (int)(stream_ptr - streamdata->stream);
streamdata->W_upper = W_upper;
return 0;
}
int WebRtcIsac_DecLogisticMulti2(
WebRtc_Word16 *dataQ7, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const WebRtc_UWord16 *envQ8, /* input: side info vector defining the width of the pdf */
const WebRtc_Word16 *ditherQ7,/* input: dither vector */
const int N, /* input: data vector length */
const WebRtc_Word16 isSWB12kHz)
{
WebRtc_UWord32 W_lower, W_upper;
WebRtc_UWord32 W_tmp;
WebRtc_UWord32 W_upper_LSB, W_upper_MSB;
WebRtc_UWord32 streamval;
const WebRtc_UWord8 *stream_ptr;
WebRtc_UWord32 cdf_tmp;
WebRtc_Word16 candQ7;
int k;
stream_ptr = streamdata->stream + streamdata->stream_index;
W_upper = streamdata->W_upper;
if (streamdata->stream_index == 0) /* first time decoder is called for this stream */
{
/* read first word from bytestream */
streamval = *stream_ptr << 24;
streamval |= *++stream_ptr << 16;
streamval |= *++stream_ptr << 8;
streamval |= *++stream_ptr;
} else {
streamval = streamdata->streamval;
}
for (k = 0; k < N; k++)
{
/* find the integer *data for which streamval lies in [W_lower+1, W_upper] */
W_upper_LSB = W_upper & 0x0000FFFF;
W_upper_MSB = W_upper >> 16;
/* find first candidate by inverting the logistic cdf */
candQ7 = - *ditherQ7 + 64;
cdf_tmp = piecewise(candQ7 * *envQ8);
W_tmp = W_upper_MSB * cdf_tmp;
W_tmp += (W_upper_LSB * cdf_tmp) >> 16;
if (streamval > W_tmp)
{
W_lower = W_tmp;
candQ7 += 128;
cdf_tmp = piecewise(candQ7 * *envQ8);
W_tmp = W_upper_MSB * cdf_tmp;
W_tmp += (W_upper_LSB * cdf_tmp) >> 16;
while (streamval > W_tmp)
{
W_lower = W_tmp;
candQ7 += 128;
cdf_tmp = piecewise(candQ7 * *envQ8);
W_tmp = W_upper_MSB * cdf_tmp;
W_tmp += (W_upper_LSB * cdf_tmp) >> 16;
/* error check */
if (W_lower == W_tmp) return -1;
}
W_upper = W_tmp;
/* another sample decoded */
*dataQ7 = candQ7 - 64;
}
else
{
W_upper = W_tmp;
candQ7 -= 128;
cdf_tmp = piecewise(candQ7 * *envQ8);
W_tmp = W_upper_MSB * cdf_tmp;
W_tmp += (W_upper_LSB * cdf_tmp) >> 16;
while ( !(streamval > W_tmp) )
{
W_upper = W_tmp;
candQ7 -= 128;
cdf_tmp = piecewise(candQ7 * *envQ8);
W_tmp = W_upper_MSB * cdf_tmp;
W_tmp += (W_upper_LSB * cdf_tmp) >> 16;
/* error check */
if (W_upper == W_tmp) return -1;
}
W_lower = W_tmp;
/* another sample decoded */
*dataQ7 = candQ7 + 64;
}
ditherQ7++;
dataQ7++;
// increment only once per 4 iterations for SWB-16kHz or WB
// increment only once per 2 iterations for SWB-12kHz
envQ8 += (isSWB12kHz)? (k & 1):((k & 1) & (k >> 1));
/* shift interval to start at zero */
W_upper -= ++W_lower;
/* add integer to bitstream */
streamval -= W_lower;
/* renormalize interval and update streamval */
while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */
{
/* read next byte from stream */
streamval = (streamval << 8) | *++stream_ptr;
W_upper <<= 8;
}
}
streamdata->stream_index = (int)(stream_ptr - streamdata->stream);
streamdata->W_upper = W_upper;
streamdata->streamval = streamval;
/* find number of bytes in original stream (determined by current interval width) */
if ( W_upper > 0x01FFFFFF )
return streamdata->stream_index - 2;
else
return streamdata->stream_index - 1;
}
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* bandwidth_estimator.h
*
* This header file contains the API for the Bandwidth Estimator
* designed for iSAC.
*
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_
#include "structs.h"
#include "settings.h"
#define MIN_ISAC_BW 10000
#define MIN_ISAC_BW_LB 10000
#define MIN_ISAC_BW_UB 25000
#define MAX_ISAC_BW 56000
#define MAX_ISAC_BW_UB 32000
#define MAX_ISAC_BW_LB 32000
#define MIN_ISAC_MD 5
#define MAX_ISAC_MD 25
// assumed header size, in bytes; we don't know the exact number
// (header compression may be used)
#define HEADER_SIZE 35
// Initial Frame-Size, in ms, for Wideband & Super-Wideband Mode
#define INIT_FRAME_LEN_WB 60
#define INIT_FRAME_LEN_SWB 30
// Initial Bottleneck Estimate, in bits/sec, for
// Wideband & Super-wideband mode
#define INIT_BN_EST_WB 20e3f
#define INIT_BN_EST_SWB 56e3f
// Initial Header rate (header rate depends on frame-size),
// in bits/sec, for Wideband & Super-Wideband mode.
#define INIT_HDR_RATE_WB \
((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_WB)
#define INIT_HDR_RATE_SWB \
((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_SWB)
// number of packets in a row for a high rate burst
#define BURST_LEN 3
// ms, max time between two full bursts
#define BURST_INTERVAL 500
// number of packets in a row for initial high rate burst
#define INIT_BURST_LEN 5
// bits/s, rate for the first BURST_LEN packets
#define INIT_RATE_WB INIT_BN_EST_WB
#define INIT_RATE_SWB INIT_BN_EST_SWB
#if defined(__cplusplus)
extern "C" {
#endif
/* This function initializes the struct */
/* to be called before using the struct for anything else */
/* returns 0 if everything went fine, -1 otherwise */
WebRtc_Word32 WebRtcIsac_InitBandwidthEstimator(
BwEstimatorstr* bwest_str,
enum IsacSamplingRate encoderSampRate,
enum IsacSamplingRate decoderSampRate);
/* This function updates the receiving estimate */
/* Parameters: */
/* rtp_number - value from RTP packet, from NetEq */
/* frame length - length of signal frame in ms, from iSAC decoder */
/* send_ts - value in RTP header giving send time in samples */
/* arr_ts - value given by timeGetTime() time of arrival in samples of packet from NetEq */
/* pksize - size of packet in bytes, from NetEq */
/* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */
/* returns 0 if everything went fine, -1 otherwise */
WebRtc_Word16 WebRtcIsac_UpdateBandwidthEstimator(
BwEstimatorstr* bwest_str,
const WebRtc_UWord16 rtp_number,
const WebRtc_Word32 frame_length,
const WebRtc_UWord32 send_ts,
const WebRtc_UWord32 arr_ts,
const WebRtc_Word32 pksize);
/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */
WebRtc_Word16 WebRtcIsac_UpdateUplinkBwImpl(
BwEstimatorstr* bwest_str,
WebRtc_Word16 Index,
enum IsacSamplingRate encoderSamplingFreq);
/* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the sending iSAC payload */
WebRtc_UWord16 WebRtcIsac_GetDownlinkBwJitIndexImpl(
BwEstimatorstr* bwest_str,
WebRtc_Word16* bottleneckIndex,
WebRtc_Word16* jitterInfo,
enum IsacSamplingRate decoderSamplingFreq);
/* Returns the bandwidth estimation (in bps) */
WebRtc_Word32 WebRtcIsac_GetDownlinkBandwidth(
const BwEstimatorstr *bwest_str);
/* Returns the max delay (in ms) */
WebRtc_Word32 WebRtcIsac_GetDownlinkMaxDelay(
const BwEstimatorstr *bwest_str);
/* Returns the bandwidth that iSAC should send with in bps */
void WebRtcIsac_GetUplinkBandwidth(
const BwEstimatorstr* bwest_str,
WebRtc_Word32* bitRate);
/* Returns the max delay value from the other side in ms */
WebRtc_Word32 WebRtcIsac_GetUplinkMaxDelay(
const BwEstimatorstr *bwest_str);
/*
* update amount of data in bottle neck buffer and burst handling
* returns minimum payload size (bytes)
*/
int WebRtcIsac_GetMinBytes(
RateModel* State,
int StreamSize, /* bytes in bitstream */
const int FrameLen, /* ms per frame */
const double BottleNeck, /* bottle neck rate; excl headers (bps) */
const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */
enum ISACBandwidth bandwidth
/*,WebRtc_Word16 frequentLargePackets*/);
/*
* update long-term average bitrate and amount of data in buffer
*/
void WebRtcIsac_UpdateRateModel(
RateModel* State,
int StreamSize, /* bytes in bitstream */
const int FrameSamples, /* samples per frame */
const double BottleNeck); /* bottle neck rate; excl headers (bps) */
void WebRtcIsac_InitRateModel(
RateModel *State);
/* Returns the new framelength value (input argument: bottle_neck) */
int WebRtcIsac_GetNewFrameLength(
double bottle_neck,
int current_framelength);
/* Returns the new SNR value (input argument: bottle_neck) */
double WebRtcIsac_GetSnr(
double bottle_neck,
int new_framelength);
WebRtc_Word16 WebRtcIsac_UpdateUplinkJitter(
BwEstimatorstr* bwest_str,
WebRtc_Word32 index);
#if defined(__cplusplus)
}
#endif
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ */
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "crc.h"
#include <stdlib.h>
#include "signal_processing_library.h"
#define POLYNOMIAL 0x04c11db7L
static const WebRtc_UWord32 kCrcTable[256] = {
0, 0x4c11db7, 0x9823b6e, 0xd4326d9, 0x130476dc, 0x17c56b6b,
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef,
0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb,
0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x18aeb13, 0x54bf6a4,
0x808d07d, 0xcc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08,
0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc,
0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050,
0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1,
0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5,
0x3f9b762c, 0x3b5a6b9b, 0x315d626, 0x7d4cb91, 0xa97ed48, 0xe56f0ff,
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9,
0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd,
0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2,
0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
0x18197087, 0x1cd86d30, 0x29f3d35, 0x65e2082, 0xb1d065b, 0xfdc1bec,
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a,
0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676,
0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
/****************************************************************************
* WebRtcIsac_GetCrc(...)
*
* This function returns a 32 bit CRC checksum of a bit stream
*
* Input:
* - bitstream : payload bitstream
* - len_bitstream_in_bytes : number of 8-bit words in the bit stream
*
* Output:
* - crc : checksum
*
* Return value : 0 - Ok
* -1 - Error
*/
WebRtc_Word16 WebRtcIsac_GetCrc(const WebRtc_Word16* bitstream,
WebRtc_Word16 len_bitstream_in_bytes,
WebRtc_UWord32* crc)
{
WebRtc_UWord8* bitstream_ptr_uw8;
WebRtc_UWord32 crc_state;
int byte_cntr;
int crc_tbl_indx;
/* Sanity Check. */
if (bitstream == NULL) {
return -1;
}
/* cast to UWord8 pointer */
bitstream_ptr_uw8 = (WebRtc_UWord8 *)bitstream;
/* initialize */
crc_state = 0xFFFFFFFF;
for (byte_cntr = 0; byte_cntr < len_bitstream_in_bytes; byte_cntr++) {
crc_tbl_indx = (WEBRTC_SPL_RSHIFT_U32(crc_state, 24) ^
bitstream_ptr_uw8[byte_cntr]) & 0xFF;
crc_state = WEBRTC_SPL_LSHIFT_U32(crc_state, 8) ^ kCrcTable[crc_tbl_indx];
}
*crc = ~crc_state;
return 0;
}
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* crc.h
*
* Checksum functions
*
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_
#include "typedefs.h"
/****************************************************************************
* WebRtcIsac_GetCrc(...)
*
* This function returns a 32 bit CRC checksum of a bit stream
*
* Input:
* - encoded : payload bit stream
* - no_of_word8s : number of 8-bit words in the bit stream
*
* Output:
* - crc : checksum
*
* Return value : 0 - Ok
* -1 - Error
*/
WebRtc_Word16 WebRtcIsac_GetCrc(
const WebRtc_Word16* encoded,
WebRtc_Word16 no_of_word8s,
WebRtc_UWord32* crc);
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ */
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "structs.h"
#include "bandwidth_estimator.h"
#include "entropy_coding.h"
#include "codec.h"
int
WebRtcIsac_EstimateBandwidth(
BwEstimatorstr* bwest_str,
Bitstr* streamdata,
WebRtc_Word32 packet_size,
WebRtc_UWord16 rtp_seq_number,
WebRtc_UWord32 send_ts,
WebRtc_UWord32 arr_ts,
enum IsacSamplingRate encoderSampRate,
enum IsacSamplingRate decoderSampRate)
{
WebRtc_Word16 index;
WebRtc_Word16 frame_samples;
WebRtc_UWord32 sendTimestampIn16kHz;
WebRtc_UWord32 arrivalTimestampIn16kHz;
WebRtc_UWord32 diffSendTime;
WebRtc_UWord32 diffArrivalTime;
int err;
/* decode framelength and BW estimation */
err = WebRtcIsac_DecodeFrameLen(streamdata, &frame_samples);
if(err < 0) // error check
{
return err;
}
err = WebRtcIsac_DecodeSendBW(streamdata, &index);
if(err < 0) // error check
{
return err;
}
/* UPDATE ESTIMATES FROM OTHER SIDE */
err = WebRtcIsac_UpdateUplinkBwImpl(bwest_str, index, encoderSampRate);
if(err < 0)
{
return err;
}
// We like BWE to work at 16 kHz sampling rate,
// therefore, we have to change the timestamps accordingly.
// translate the send timestamp if required
diffSendTime = (WebRtc_UWord32)((WebRtc_UWord32)send_ts -
(WebRtc_UWord32)bwest_str->senderTimestamp);
bwest_str->senderTimestamp = send_ts;
diffArrivalTime = (WebRtc_UWord32)((WebRtc_UWord32)arr_ts -
(WebRtc_UWord32)bwest_str->receiverTimestamp);
bwest_str->receiverTimestamp = arr_ts;
if(decoderSampRate == kIsacSuperWideband)
{
diffArrivalTime = (WebRtc_UWord32)diffArrivalTime >> 1;
diffSendTime = (WebRtc_UWord32)diffSendTime >> 1;
}
// arrival timestamp in 16 kHz
arrivalTimestampIn16kHz = (WebRtc_UWord32)((WebRtc_UWord32)
bwest_str->prev_rec_arr_ts + (WebRtc_UWord32)diffArrivalTime);
// send timestamp in 16 kHz
sendTimestampIn16kHz = (WebRtc_UWord32)((WebRtc_UWord32)
bwest_str->prev_rec_send_ts + (WebRtc_UWord32)diffSendTime);
err = WebRtcIsac_UpdateBandwidthEstimator(bwest_str, rtp_seq_number,
(frame_samples * 1000) / FS, sendTimestampIn16kHz,
arrivalTimestampIn16kHz, packet_size);
// error check
if(err < 0)
{
return err;
}
return 0;
}
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*--------------------------------*-C-*---------------------------------*
* File:
* fftn.h
* ---------------------------------------------------------------------*
* Re[]: real value array
* Im[]: imaginary value array
* nTotal: total number of complex values
* nPass: number of elements involved in this pass of transform
* nSpan: nspan/nPass = number of bytes to increment pointer
* in Re[] and Im[]
* isign: exponent: +1 = forward -1 = reverse
* scaling: normalizing constant by which the final result is *divided*
* scaling == -1, normalize by total dimension of the transform
* scaling < -1, normalize by the square-root of the total dimension
*
* ----------------------------------------------------------------------
* See the comments in the code for correct usage!
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_
#include "structs.h"
/* double precision routine */
int WebRtcIsac_Fftns (unsigned int ndim, const int dims[], double Re[], double Im[],
int isign, double scaling, FFTstr *fftstate);
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_ */
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* filterbank_tables.c*/
/* This file contains variables that are used in filterbanks.c*/
#include "filterbank_tables.h"
#include "settings.h"
/* The composite all-pass filter factors */
const float WebRtcIsac_kCompositeApFactorsFloat[4] = {
0.03470000000000f, 0.15440000000000f, 0.38260000000000f, 0.74400000000000f};
/* The upper channel all-pass filter factors */
const float WebRtcIsac_kUpperApFactorsFloat[2] = {
0.03470000000000f, 0.38260000000000f};
/* The lower channel all-pass filter factors */
const float WebRtcIsac_kLowerApFactorsFloat[2] = {
0.15440000000000f, 0.74400000000000f};
/* The matrix for transforming the backward composite state to upper channel state */
const float WebRtcIsac_kTransform1Float[8] = {
-0.00158678506084f, 0.00127157815343f, -0.00104805672709f, 0.00084837248079f,
0.00134467983258f, -0.00107756549387f, 0.00088814793277f, -0.00071893072525f};
/* The matrix for transforming the backward composite state to lower channel state */
const float WebRtcIsac_kTransform2Float[8] = {
-0.00170686041697f, 0.00136780109829f, -0.00112736532350f, 0.00091257055385f,
0.00103094281812f, -0.00082615076557f, 0.00068092756088f, -0.00055119165484f};
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* filterbank_tables.h
*
* Header file for variables that are defined in
* filterbank_tables.c.
*
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTERBANK_TABLES_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTERBANK_TABLES_H_
#include "structs.h"
/********************* Coefficient Tables ************************/
/* The number of composite all-pass filter factors */
#define NUMBEROFCOMPOSITEAPSECTIONS 4
/* The number of all-pass filter factors in an upper or lower channel*/
#define NUMBEROFCHANNELAPSECTIONS 2
/* The composite all-pass filter factors */
extern const float WebRtcIsac_kCompositeApFactorsFloat[4];
/* The upper channel all-pass filter factors */
extern const float WebRtcIsac_kUpperApFactorsFloat[2];
/* The lower channel all-pass filter factors */
extern const float WebRtcIsac_kLowerApFactorsFloat[2];
/* The matrix for transforming the backward composite state to upper channel state */
extern const float WebRtcIsac_kTransform1Float[8];
/* The matrix for transforming the backward composite state to lower channel state */
extern const float WebRtcIsac_kTransform2Float[8];
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FILTERBANK_TABLES_H_ */
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* lpc_analysis.h
*
* LPC functions
*
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYSIS_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYSIS_H_
#include "settings.h"
#include "structs.h"
double WebRtcIsac_LevDurb(double *a, double *k, double *r, int order);
void WebRtcIsac_GetVars(const double *input, const WebRtc_Word16 *pitchGains_Q12,
double *oldEnergy, double *varscale);
void WebRtcIsac_GetLpcCoefLb(double *inLo, double *inHi, MaskFiltstr *maskdata,
double signal_noise_ratio, const WebRtc_Word16 *pitchGains_Q12,
double *lo_coeff, double *hi_coeff);
void WebRtcIsac_GetLpcGain(
double signal_noise_ratio,
const double* filtCoeffVecs,
int numVecs,
double* gain,
double corrLo[][UB_LPC_ORDER + 1],
const double* varscale);
void WebRtcIsac_GetLpcCoefUb(
double* inSignal,
MaskFiltstr* maskdata,
double* lpCoeff,
double corr[][UB_LPC_ORDER + 1],
double* varscale,
WebRtc_Word16 bandwidth);
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYIS_H_ */
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论