Skip to content
Snippets Groups Projects
Commit c8e37280 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Created tester based on testcelt.c

parent 24af3037
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,10 @@ int hybrid_encode(HybridEncoder *st, short *pcm, int frame_size,
{
int celt_ret;
ec_enc enc;
ec_byte_buffer buf;
ec_byte_writeinit_buffer(&buf, data, bytes_per_packet);
ec_enc_init(&enc,&buf);
/* FIXME: Call SILK encoder for the low band */
......@@ -68,7 +71,7 @@ int hybrid_encode(HybridEncoder *st, short *pcm, int frame_size,
celt_encoder_ctl(st->celt_enc, CELT_SET_START_BAND(13));
/* Encode high band with CELT */
celt_ret = celt_encode(st->celt_enc, pcm, frame_size, data, bytes_per_packet);
celt_ret = celt_encode_with_ec(st->celt_enc, pcm, NULL, frame_size, data, bytes_per_packet, &enc);
return celt_ret;
}
......
/* Copyright (c) 2010 Xiph.Org Foundation
/* Copyright (c) 2007-2008 CSIRO
Copyright (c) 2007-2009 Xiph.Org Foundation
Written by Jean-Marc Valin */
/*
Redistribution and use in source and binary forms, with or without
......@@ -29,13 +30,96 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "hybrid.h"
int main(int argc, char **argv)
#define MAX_PACKET 1024
int main(int argc, char *argv[])
{
HybridEncoder *enc;
int err;
char *inFile, *outFile;
FILE *fin, *fout;
HybridEncoder *enc;
int len;
int frame_size, channels;
int bytes_per_packet;
unsigned char data[MAX_PACKET];
int rate;
int count = 0;
int skip;
short *in, *out;
if (argc != 9 && argc != 8 && argc != 7)
{
fprintf (stderr, "Usage: test_hybrid <rate> <channels> <frame size> "
" <bytes per packet> "
"<input> <output>\n");
return 1;
}
rate = atoi(argv[1]);
channels = atoi(argv[2]);
frame_size = atoi(argv[3]);
bytes_per_packet = atoi(argv[4]);
if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)
{
fprintf (stderr, "bytes per packet must be between 0 and %d\n",
MAX_PACKET);
return 1;
}
inFile = argv[argc-2];
fin = fopen(inFile, "rb");
if (!fin)
{
fprintf (stderr, "Could not open input file %s\n", argv[argc-2]);
return 1;
}
outFile = argv[argc-1];
fout = fopen(outFile, "wb+");
if (!fout)
{
fprintf (stderr, "Could not open output file %s\n", argv[argc-1]);
return 1;
}
enc = hybrid_encoder_create();
/*dec = hybrid_decoder_create();*/
in = (short*)malloc(frame_size*channels*sizeof(short));
out = (short*)malloc(frame_size*channels*sizeof(short));
while (!feof(fin))
{
err = fread(in, sizeof(short), frame_size*channels, fin);
if (feof(fin))
break;
len = hybrid_encode(enc, in, frame_size, data, bytes_per_packet);
if (len <= 0)
{
fprintf (stderr, "hybrid_encode() returned %d\n", len);
return 1;
}
/* This is for simulating bit errors */
/*hybrid_decode(dec, data, len, out, frame_size);*/
count++;
fwrite(out+skip, sizeof(short), (frame_size-skip)*channels, fout);
skip = 0;
}
enc = hybrid_encoder_create();
return 0;
hybrid_encoder_destroy(enc);
/*hybrid_decoder_destroy(dec);*/
fclose(fin);
fclose(fout);
free(in);
free(out);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment