mirror of
https://github.com/xiph/opus.git
synced 2025-05-30 07:07:42 +00:00
Make the code C90-compliant
This commit is contained in:
parent
ebbf5721a2
commit
580614f062
7 changed files with 16 additions and 10 deletions
|
@ -25,6 +25,10 @@
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "freq.h"
|
#include "freq.h"
|
||||||
|
@ -40,6 +44,10 @@ int main(void) {
|
||||||
|
|
||||||
file=fopen("lpcnet_tables.c", "wb");
|
file=fopen("lpcnet_tables.c", "wb");
|
||||||
fprintf(file, "/* The contents of this file was automatically generated by dump_lpcnet_tables.c*/\n\n");
|
fprintf(file, "/* The contents of this file was automatically generated by dump_lpcnet_tables.c*/\n\n");
|
||||||
|
fprintf(file, "#ifdef HAVE_CONFIG_H\n");
|
||||||
|
fprintf(file, "#include \"config.h\"\n");
|
||||||
|
fprintf(file, "#endif\n");
|
||||||
|
|
||||||
fprintf(file, "#include \"kiss_fft.h\"\n\n");
|
fprintf(file, "#include \"kiss_fft.h\"\n\n");
|
||||||
|
|
||||||
kfft = opus_fft_alloc_twiddles(WINDOW_SIZE, NULL, NULL, NULL, 0);
|
kfft = opus_fft_alloc_twiddles(WINDOW_SIZE, NULL, NULL, NULL, 0);
|
||||||
|
@ -93,4 +101,4 @@ int main(void) {
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,20 +162,19 @@ void compute_burg_cepstrum(const float *pcm, float *burg_cepstrum, int len, int
|
||||||
float g;
|
float g;
|
||||||
kiss_fft_cpx LPC[FREQ_SIZE];
|
kiss_fft_cpx LPC[FREQ_SIZE];
|
||||||
float Ly[NB_BANDS];
|
float Ly[NB_BANDS];
|
||||||
|
float logMax = -2;
|
||||||
|
float follow = -2;
|
||||||
assert(order <= LPC_ORDER);
|
assert(order <= LPC_ORDER);
|
||||||
assert(len <= FRAME_SIZE);
|
assert(len <= FRAME_SIZE);
|
||||||
for (i=0;i<len-1;i++) burg_in[i] = pcm[i+1] - PREEMPHASIS*pcm[i];
|
for (i=0;i<len-1;i++) burg_in[i] = pcm[i+1] - PREEMPHASIS*pcm[i];
|
||||||
g = silk_burg_analysis(burg_lpc, burg_in, 1e-3, len-1, 1, order);
|
g = silk_burg_analysis(burg_lpc, burg_in, 1e-3, len-1, 1, order);
|
||||||
g /= len - 2*(order-1);
|
g /= len - 2*(order-1);
|
||||||
//printf("%g\n", g);
|
|
||||||
RNN_CLEAR(x, WINDOW_SIZE);
|
RNN_CLEAR(x, WINDOW_SIZE);
|
||||||
x[0] = 1;
|
x[0] = 1;
|
||||||
for (i=0;i<order;i++) x[i+1] = -burg_lpc[i]*pow(.995, i+1);
|
for (i=0;i<order;i++) x[i+1] = -burg_lpc[i]*pow(.995, i+1);
|
||||||
forward_transform(LPC, x);
|
forward_transform(LPC, x);
|
||||||
compute_band_energy_inverse(Eburg, LPC);
|
compute_band_energy_inverse(Eburg, LPC);
|
||||||
for (i=0;i<NB_BANDS;i++) Eburg[i] *= .45*g*(1.f/((float)WINDOW_SIZE*WINDOW_SIZE*WINDOW_SIZE));
|
for (i=0;i<NB_BANDS;i++) Eburg[i] *= .45*g*(1.f/((float)WINDOW_SIZE*WINDOW_SIZE*WINDOW_SIZE));
|
||||||
float logMax = -2;
|
|
||||||
float follow = -2;
|
|
||||||
for (i=0;i<NB_BANDS;i++) {
|
for (i=0;i<NB_BANDS;i++) {
|
||||||
Ly[i] = log10(1e-2+Eburg[i]);
|
Ly[i] = log10(1e-2+Eburg[i]);
|
||||||
Ly[i] = MAX16(logMax-8, MAX16(follow-2.5, Ly[i]));
|
Ly[i] = MAX16(logMax-8, MAX16(follow-2.5, Ly[i]));
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define lpcnet_alloc(x) malloc(x)
|
#define lpcnet_alloc(x) malloc(x)
|
||||||
//#define opus_free(x) free(x)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -89,8 +89,6 @@ void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b
|
||||||
float dense1_out[FEATURE_DENSE1_OUT_SIZE];
|
float dense1_out[FEATURE_DENSE1_OUT_SIZE];
|
||||||
int pitch;
|
int pitch;
|
||||||
float rc[LPC_ORDER];
|
float rc[LPC_ORDER];
|
||||||
//static float features[NB_FEATURES];
|
|
||||||
//RNN_COPY(features, lpcnet->last_features, NB_FEATURES);
|
|
||||||
/* Matches the Python code -- the 0.1 avoids rounding issues. */
|
/* Matches the Python code -- the 0.1 avoids rounding issues. */
|
||||||
pitch = (int)floor(.1 + 50*features[NB_BANDS]+100);
|
pitch = (int)floor(.1 + 50*features[NB_BANDS]+100);
|
||||||
pitch = IMIN(255, IMAX(33, pitch));
|
pitch = IMIN(255, IMAX(33, pitch));
|
||||||
|
@ -118,7 +116,6 @@ void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b
|
||||||
#ifdef LPC_GAMMA
|
#ifdef LPC_GAMMA
|
||||||
lpc_weighting(lpc, LPC_GAMMA);
|
lpc_weighting(lpc, LPC_GAMMA);
|
||||||
#endif
|
#endif
|
||||||
//RNN_COPY(lpcnet->last_features, _features, NB_FEATURES);
|
|
||||||
if (lpcnet->frame_count < 1000) lpcnet->frame_count++;
|
if (lpcnet->frame_count < 1000) lpcnet->frame_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,8 +169,8 @@ int main(int argc, char **argv) {
|
||||||
int count=0;
|
int count=0;
|
||||||
int loss=0;
|
int loss=0;
|
||||||
int skip=0, extra=0;
|
int skip=0, extra=0;
|
||||||
if ((plc_flags&0x3) == LPCNET_PLC_NONCAUSAL) skip=extra=80;
|
|
||||||
LPCNetPLCState *net;
|
LPCNetPLCState *net;
|
||||||
|
if ((plc_flags&0x3) == LPCNET_PLC_NONCAUSAL) skip=extra=80;
|
||||||
net = lpcnet_plc_create(plc_flags);
|
net = lpcnet_plc_create(plc_flags);
|
||||||
while (1) {
|
while (1) {
|
||||||
size_t ret;
|
size_t ret;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/* The contents of this file was automatically generated by dump_lpcnet_tables.c*/
|
/* The contents of this file was automatically generated by dump_lpcnet_tables.c*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
#include "kiss_fft.h"
|
#include "kiss_fft.h"
|
||||||
|
|
||||||
static const arch_fft_state arch_fft = {0, NULL};
|
static const arch_fft_state arch_fft = {0, NULL};
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
extern const WeightArray lpcnet_arrays[];
|
extern const WeightArray lpcnet_arrays[];
|
||||||
|
|
||||||
int parse_record(const unsigned char **data, int *len, WeightArray *array) {
|
int parse_record(const unsigned char **data, int *len, WeightArray *array) {
|
||||||
if (*len < WEIGHT_BLOCK_SIZE) return -1;
|
|
||||||
WeightHead *h = (WeightHead *)*data;
|
WeightHead *h = (WeightHead *)*data;
|
||||||
|
if (*len < WEIGHT_BLOCK_SIZE) return -1;
|
||||||
if (h->block_size < h->size) return -1;
|
if (h->block_size < h->size) return -1;
|
||||||
if (*len < h->block_size+WEIGHT_BLOCK_SIZE) return -1;
|
if (*len < h->block_size+WEIGHT_BLOCK_SIZE) return -1;
|
||||||
if (h->name[sizeof(h->name)-1] != 0) return -1;
|
if (h->name[sizeof(h->name)-1] != 0) return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue