ref: 90c1db18ed80da5949fb69106f4324dce6e4e842
parent: 4430ea0b032e95615a58969589a8bf5ecd8ccfbc
author: Gregory Maxwell <greg@xiph.org>
date: Thu Jul 12 08:26:54 EDT 2012
Clean up some but not all C99isms.
--- a/src/audio-in.c
+++ b/src/audio-in.c
@@ -38,16 +38,11 @@
#include <sys/types.h>
#include <math.h>
+#include "stack_alloc.h"
+
#ifdef WIN32
-# include <malloc.h>
# include <windows.h> /*GetFileType()*/
# include <io.h> /*_get_osfhandle()*/
-#else
-# ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# include <stdlib.h>
-# endif
#endif
#ifdef ENABLE_NLS
--- a/src/opusdec.c
+++ b/src/opusdec.c
@@ -92,6 +92,7 @@
#include "opus_header.h"
#include "diag_range.h"
#include "speex_resampler.h"
+#include "stack_alloc.h"
#define MINI(_a,_b) ((_a)<(_b)?(_a):(_b))
#define MAXI(_a,_b) ((_a)>(_b)?(_a):(_b))
@@ -488,9 +489,11 @@
opus_int64 sampout=0;
int i,ret,tmp_skip;
unsigned out_len;
- short out[MAX_FRAME_SIZE*channels];
- float buf[MAX_FRAME_SIZE*channels];
+ short *out;
+ float *buf;
float *output;
+ out=alloca(sizeof(short)*MAX_FRAME_SIZE*channels);
+ buf=alloca(sizeof(float)*MAX_FRAME_SIZE*channels);
maxout=maxout<0?0:maxout;
do {
if (skip){
@@ -500,8 +503,8 @@
tmp_skip = 0;
}
if (resampler){
- output=buf;
unsigned in_len;
+ output=buf;
in_len = frame_size-tmp_skip;
out_len = 1024<maxout?1024:maxout;
speex_resampler_process_interleaved_float(resampler, pcm+channels*tmp_skip, &in_len, buf, &out_len);
@@ -765,7 +768,9 @@
if (!quiet)
print_comments((char*)op.packet, op.bytes);
} else {
+ int ret;
opus_int64 maxout;
+ opus_int64 outsamp;
int lost=0;
if (loss_percent>0 && 100*((float)rand())/RAND_MAX<loss_percent)
lost=1;
@@ -773,8 +778,6 @@
/*End of stream condition*/
if (op.e_o_s && os.serialno == opus_serialno)eos=1; /* don't care for anything except opus eos */
- int ret;
- opus_int64 outsamp;
/*Decode frame*/
if (!lost)
ret = opus_multistream_decode_float(st, (unsigned char*)op.packet, op.bytes, output, MAX_FRAME_SIZE, 0);
@@ -790,7 +793,7 @@
if(frange!=NULL){
OpusDecoder *od;
- opus_uint32 rngs[streams];
+ opus_uint32 rngs[256];
for(i=0;i<streams;i++){
ret=opus_multistream_decoder_ctl(st,OPUS_MULTISTREAM_GET_DECODER_STATE(i,&od));
ret=opus_decoder_ctl(od,OPUS_GET_FINAL_RANGE(&rngs[i]));
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -788,8 +788,8 @@
min_bytes=IMIN(nbBytes,min_bytes);
if(frange!=NULL){
+ opus_uint32 rngs[256];
OpusEncoder *oe;
- opus_uint32 rngs[header.nb_streams];
for(i=0;i<header.nb_streams;i++){
ret=opus_multistream_encoder_ctl(st,OPUS_MULTISTREAM_GET_ENCODER_STATE(i,&oe));
ret=opus_encoder_ctl(oe,OPUS_GET_FINAL_RANGE(&rngs[i]));
--- a/src/stack_alloc.h
+++ b/src/stack_alloc.h
@@ -35,6 +35,8 @@
#ifndef STACK_ALLOC_H
#define STACK_ALLOC_H
+#include <alloca.h>
+
#ifdef USE_ALLOCA
# ifdef WIN32
# include <malloc.h>