oops, unb0rked testcelt output
[opus.git] / libcelt / testcelt.c
index 4ed8a67..50d7243 100644 (file)
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "celt.h"
+#include "arch.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -93,15 +97,18 @@ int main(int argc, char *argv[])
    }
    
    /* Use mode4 for stereo and don't forget to change the value of CHANNEL above */
-   enc = celt_encoder_new(mode);
-   dec = celt_decoder_new(mode);
+   enc = celt_encoder_create(mode);
+   dec = celt_decoder_create(mode);
    
    celt_mode_info(mode, CELT_GET_FRAME_SIZE, &frame_size);
    celt_mode_info(mode, CELT_GET_NB_CHANNELS, &channels);
    while (!feof(fin))
    {
-      celt_int16_t in[frame_size*channels];
-      celt_int16_t out[frame_size*channels];
+      VARDECL(celt_int16_t *in);
+      VARDECL(celt_int16_t *out);
+      SAVE_STACK;
+      ALLOC(in, frame_size*channels, celt_int16_t);
+      ALLOC(out, frame_size*channels, celt_int16_t);
       fread(in, sizeof(short), frame_size*channels, fin);
       if (feof(fin))
          break;
@@ -109,6 +116,7 @@ int main(int argc, char *argv[])
       if (len <= 0)
       {
          fprintf (stderr, "celt_encode() returned %d\n", len);
+         RESTORE_STACK;
          return 1;
       }
       /* This is to simulate packet loss */
@@ -122,10 +130,14 @@ int main(int argc, char *argv[])
          out[i] = in[i];
 #endif
       for (i=0;i<frame_size*channels;i++)
+      {
          rmsd += (in[i]-out[i])*1.0*(in[i]-out[i]);
+         /*out[i] -= in[i];*/
+      }
       count++;
       fwrite(out, sizeof(short), (frame_size-skip)*channels, fout);
       skip = 0;
+      RESTORE_STACK;
    }
    celt_encoder_destroy(enc);
    celt_decoder_destroy(dec);