diff --git a/src/opus_dec.c b/src/opus_dec.c index 9bf8476d..b57bfb46 100644 --- a/src/opus_dec.c +++ b/src/opus_dec.c @@ -62,20 +62,19 @@ int main(int argc, char *argv[]) short *in, *out; int mode=MODE_HYBRID; double bits=0; - if (argc != 6 && argc != 7) + if (argc != 5 && argc != 6) { - fprintf (stderr, "Usage: test_opus " - " [] [] " + fprintf (stderr, "Usage: test_opus " + "[] " " \n"); return 1; } rate = atoi(argv[1]); channels = atoi(argv[2]); - frame_size = atoi(argv[3]); if (argc >= 7) - loss = atoi(argv[4]); + loss = atoi(argv[3]); inFile = argv[argc-2]; fin = fopen(inFile, "rb"); @@ -94,7 +93,7 @@ int main(int argc, char *argv[]) dec = opus_decoder_create(rate, channels); - out = (short*)malloc(frame_size*channels*sizeof(short)); + out = (short*)malloc(960*channels*sizeof(short)); while (!stop) { len = ((fgetc(fin)<<8)&0xFF00) | (fgetc(fin)&0xFF); @@ -102,11 +101,11 @@ int main(int argc, char *argv[]) break; bits += len*8; err = fread(data, 1, len, fin); - opus_decode(dec, rand()%100 frame_size) + { + fprintf(stderr, "PCM buffer too small"); + return -1; + } else { + frame_size = audiosize; + } + if (st->mode != MODE_CELT_ONLY) { DecControl.API_sampleRate = st->Fs; @@ -188,7 +196,7 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, for (i=0;ichannels;i++) pcm[i] += pcm_celt[i]; } - return celt_ret; + return celt_ret<0 ? celt_ret : audiosize; }