Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@octasic.com>2010-07-21 00:49:28 +0400
committerJean-Marc Valin <jean-marc.valin@octasic.com>2010-07-21 00:49:28 +0400
commit89e6950f62b0f5eadbc293168fe3da75a0231151 (patch)
tree8390672ea28c49d70abea9bdad1aceb8d86ddafd /src
parent769311f98c7fd0a7fa90af01fcae6eac323da8de (diff)
Getting test_hybrid to generate time-aligned signals of the right size
Diffstat (limited to 'src')
-rw-r--r--src/test_hybrid.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/test_hybrid.c b/src/test_hybrid.c
index 407c2d11..4f1abda1 100644
--- a/src/test_hybrid.c
+++ b/src/test_hybrid.c
@@ -58,6 +58,8 @@ int main(int argc, char *argv[])
int loss = 0;
int count = 0;
int skip;
+ int stop=0;
+ int tot_read=0, tot_written=0;
short *in, *out;
int mode=MODE_HYBRID;
if (argc != 9 && argc != 8 && argc != 7)
@@ -109,13 +111,20 @@ int main(int argc, char *argv[])
hybrid_decoder_ctl(dec, HYBRID_SET_BANDWIDTH(BANDWIDTH_FULLBAND));
hybrid_decoder_ctl(dec, HYBRID_SET_MODE(mode));
+ skip = 5*rate/1000 + 10;
+
in = (short*)malloc(frame_size*channels*sizeof(short));
out = (short*)malloc(frame_size*channels*sizeof(short));
- while (!feof(fin))
+ while (!stop)
{
err = fread(in, sizeof(short), frame_size*channels, fin);
- if (feof(fin))
- break;
+ tot_read += err;
+ if (err < frame_size*channels)
+ {
+ int i;
+ for (i=err;i<frame_size*channels;i++)
+ in[i] = 0;
+ }
len = hybrid_encode(enc, in, frame_size, data, bytes_per_packet);
if (len <= 0)
{
@@ -124,6 +133,12 @@ int main(int argc, char *argv[])
}
hybrid_decode(dec, rand()%100<loss ? NULL : data, len, out, frame_size);
count++;
+ tot_written += (frame_size-skip)*channels;
+ if (tot_written > tot_read && skip==0)
+ {
+ frame_size -= (tot_written-tot_read)/channels;
+ stop = 1;
+ }
fwrite(out+skip, sizeof(short), (frame_size-skip)*channels, fout);
skip = 0;
}