From f2d5aed8a58992d1084040d0ee0dfd68e7bc14bc Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Tue, 19 Feb 2008 16:45:37 +1100 Subject: [PATCH] Allowing to choose the frame size and rate from testcelt --- libcelt/match-test.sh | 4 ++-- libcelt/testcelt.c | 31 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libcelt/match-test.sh b/libcelt/match-test.sh index 965c44ed..d2f18a71 100755 --- a/libcelt/match-test.sh +++ b/libcelt/match-test.sh @@ -9,7 +9,7 @@ outfile=/dev/null if [ -f mono_test_file.sw ]; then echo -n "mono test... " - ./testcelt -mono 32 mono_test_file.sw $outfile + ./testcelt 44100 1 256 128 32 mono_test_file.sw $outfile if [ $? != 0 ]; then exit 1 fi @@ -19,7 +19,7 @@ fi if [ -f stereo_test_file.sw ]; then echo -n "stereo test... " - ./testcelt -stereo 92 stereo_test_file.sw $outfile + ./testcelt 44100 2 256 128 92 stereo_test_file.sw $outfile if [ $? != 0 ]; then exit 1 fi diff --git a/libcelt/testcelt.c b/libcelt/testcelt.c index 3806e8dc..c0a6dd84 100644 --- a/libcelt/testcelt.c +++ b/libcelt/testcelt.c @@ -48,48 +48,47 @@ int main(int argc, char *argv[]) celt_int32_t frame_size, channels; int bytes_per_packet; unsigned char data[1024]; - + int rate, overlap; double rmsd = 0; int count = 0; - if (argc != 5) + if (argc != 8) { - fprintf (stderr, "Usage: testcelt - \n"); - return 1; - } - if (strcmp(argv[1], "-mono")==0) - mode = celt_mono; - else if (strcmp(argv[1], "-stereo")==0) - mode = celt_stereo; - else { - fprintf (stderr, "mode must be -mono or -stereo\n"); + fprintf (stderr, "Usage: testcelt \n"); return 1; } + rate = atoi(argv[1]); + channels = atoi(argv[2]); + frame_size = atoi(argv[3]); + overlap = atoi(argv[4]); + + mode = celt_mode_create(rate, channels, frame_size, overlap, NULL); + if (mode == NULL) { fprintf(stderr, "failed to create a mode\n"); return 1; } - bytes_per_packet = atoi(argv[2]); + bytes_per_packet = atoi(argv[5]); if (bytes_per_packet < 0 || bytes_per_packet > 120) { fprintf (stderr, "bytes per packet must be between 10 and 120\n"); return 1; } - inFile = argv[3]; + inFile = argv[6]; fin = fopen(inFile, "rb"); if (!fin) { - fprintf (stderr, "Could not open input file %s\n", argv[3]); + fprintf (stderr, "Could not open input file %s\n", argv[6]); return 1; } - outFile = argv[4]; + outFile = argv[7]; fout = fopen(outFile, "wb+"); if (!fout) { - fprintf (stderr, "Could not open output file %s\n", argv[4]); + fprintf (stderr, "Could not open output file %s\n", argv[7]); return 1; }