ref: 713d7a4ce99abd7db50ee3b0af0ba8316a353ca3
parent: b35807d75a77f0a27fa8d459ce79a5ff9103b569
author: Jean-Marc Valin <[email protected]>
date: Mon Jan 31 08:41:01 EST 2011
Fix sample type conversion when resampling
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1564,7 +1564,7 @@
#ifndef DISABLE_FLOAT_API
int celt_encode_with_ec_float(CELTEncoder * restrict st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
{
- int j, ret, C, N, LM, M;
+ int j, ret, C, N;
VARDECL(celt_int16, in);
SAVE_STACK;
@@ -1571,15 +1571,8 @@
if (pcm==NULL)
return CELT_BAD_ARG;
- for (LM=0;LM<4;LM++)
- if (st->mode->shortMdctSize<<LM==frame_size)
- break;
- if (LM>=MAX_CONFIG_SIZES)
- return CELT_BAD_ARG;
- M=1<<LM;
-
C = CHANNELS(st->channels);
- N = M*st->mode->shortMdctSize;
+ N = frame_size;
ALLOC(in, C*N, celt_int16);
for (j=0;j<C*N;j++)
@@ -1598,7 +1591,7 @@
#else
int celt_encode_with_ec(CELTEncoder * restrict st, const celt_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
{
- int j, ret, C, N, LM, M;
+ int j, ret, C, N;
VARDECL(celt_sig, in);
SAVE_STACK;
@@ -1605,15 +1598,8 @@
if (pcm==NULL)
return CELT_BAD_ARG;
- for (LM=0;LM<4;LM++)
- if (st->mode->shortMdctSize<<LM==frame_size)
- break;
- if (LM>=MAX_CONFIG_SIZES)
- return CELT_BAD_ARG;
- M=1<<LM;
-
C=CHANNELS(st->channels);
- N=M*st->mode->shortMdctSize;
+ N=frame_size;
ALLOC(in, C*N, celt_sig);
for (j=0;j<C*N;j++) {
in[j] = SCALEOUT(pcm[j]);
@@ -2464,7 +2450,7 @@
#ifndef DISABLE_FLOAT_API
int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *data, int len, float * restrict pcm, int frame_size, ec_dec *dec)
{
- int j, ret, C, N, LM, M;
+ int j, ret, C, N;
VARDECL(celt_int16, out);
SAVE_STACK;
@@ -2471,15 +2457,8 @@
if (pcm==NULL)
return CELT_BAD_ARG;
- for (LM=0;LM<4;LM++)
- if (st->mode->shortMdctSize<<LM==frame_size)
- break;
- if (LM>=MAX_CONFIG_SIZES)
- return CELT_BAD_ARG;
- M=1<<LM;
-
C = CHANNELS(st->channels);
- N = M*st->mode->shortMdctSize;
+ N = frame_size;
ALLOC(out, C*N, celt_int16);
ret=celt_decode_with_ec(st, data, len, out, frame_size, dec);
@@ -2494,7 +2473,7 @@
#else
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm, int frame_size, ec_dec *dec)
{
- int j, ret, C, N, LM, M;
+ int j, ret, C, N;
VARDECL(celt_sig, out);
SAVE_STACK;
@@ -2501,15 +2480,8 @@
if (pcm==NULL)
return CELT_BAD_ARG;
- for (LM=0;LM<4;LM++)
- if (st->mode->shortMdctSize<<LM==frame_size)
- break;
- if (LM>=MAX_CONFIG_SIZES)
- return CELT_BAD_ARG;
- M=1<<LM;
-
C = CHANNELS(st->channels);
- N = M*st->mode->shortMdctSize;
+ N = frame_size;
ALLOC(out, C*N, celt_sig);
ret=celt_decode_with_ec_float(st, data, len, out, frame_size, dec);
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -194,7 +194,7 @@
celt_mode_destroy(mode);
free(in);
free(out);
-#ifdef RESYNTH
+#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES))
if (rmsd > 0)
{
rmsd = sqrt(rmsd/(1.0*frame_size*channels*count));