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
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2012-12-06 06:43:29 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-12-06 08:54:20 +0400
commit6f2ce267af5733b64677ce38d06daa04e93ea6fd (patch)
tree373af7ba7d6ac98fd594edd639ec919b8efbe9ef
parent23032b40da7824886809f93baffddd03525e0c19 (diff)
Add tests for GET_LAST_PACKET_DURATION.v1.0.2
Also remove a useless extern that crept into the tests from some optimization driven testcase generation.
-rw-r--r--tests/test_opus_decode.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_opus_decode.c b/tests/test_opus_decode.c
index be93df48..e2c04c2c 100644
--- a/tests/test_opus_decode.c
+++ b/tests/test_opus_decode.c
@@ -47,7 +47,6 @@
#define MAX_PACKET (1500)
#define MAX_FRAME_SAMP (5760)
-extern int jackpot;
int test_decoder_code0(int no_fuzz)
{
@@ -105,9 +104,12 @@ int test_decoder_code0(int no_fuzz)
int factor=48000/fsv[t>>1];
for(fec=0;fec<2;fec++)
{
+ int dur;
/*Test PLC on a fresh decoder*/
out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, fec);
if(out_samples!=120/factor)test_failed();
+ if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
+ if(dur!=120/factor)test_failed();
/*Test null pointer input*/
out_samples = opus_decode(dec[t], 0, -1, outbuf, 120/factor, fec);
@@ -118,6 +120,8 @@ int test_decoder_code0(int no_fuzz)
if(out_samples!=120/factor)test_failed();
out_samples = opus_decode(dec[t], 0, fast_rand(), outbuf, 120/factor, fec);
if(out_samples!=120/factor)test_failed();
+ if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
+ if(dur!=120/factor)test_failed();
/*Zero lengths*/
out_samples = opus_decode(dec[t], packet, 0, outbuf, 120/factor, fec);
@@ -152,6 +156,7 @@ int test_decoder_code0(int no_fuzz)
/*Count code 0 tests*/
for(i=0;i<64;i++)
{
+ int dur;
int j,expected[5*2];
packet[0]=i<<2;
packet[1]=255;
@@ -171,6 +176,8 @@ int test_decoder_code0(int no_fuzz)
{
out_samples = opus_decode(dec[t], packet, 3, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected[t])test_failed();
+ if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
+ if(dur!=out_samples)test_failed();
opus_decoder_ctl(dec[t], OPUS_GET_FINAL_RANGE(&dec_final_range1));
if(t==0)dec_final_range2=dec_final_range1;
else if(dec_final_range1!=dec_final_range2)test_failed();
@@ -184,6 +191,8 @@ int test_decoder_code0(int no_fuzz)
{
out_samples = opus_decode(dec[t], 0, 0, outbuf, expected[t], 0);
if(out_samples!=expected[t])test_failed();
+ if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
+ if(dur!=out_samples)test_failed();
}
/* Run the PLC once at 2.5ms, as a simulation of someone trying to
do small drift corrections. */
@@ -191,6 +200,8 @@ int test_decoder_code0(int no_fuzz)
{
out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, 0);
if(out_samples!=120/factor)test_failed();
+ if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
+ if(dur!=out_samples)test_failed();
}
out_samples = opus_decode(dec[t], packet, 2, outbuf, expected[t]-1, 0);
if(out_samples>0)test_failed();
@@ -299,10 +310,13 @@ int test_decoder_code0(int no_fuzz)
if(opus_decode(decbak, 0, 0, outbuf, MAX_FRAME_SAMP, 0)<20)test_failed();
for(t=0;t<5*2;t++)
{
+ int dur;
out_samples = opus_decode(dec[t], packet, plen+1, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected[t])test_failed();
if(t==0)dec_final_range2=dec_final_range1;
else if(dec_final_range1!=dec_final_range2)test_failed();
+ if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
+ if(dur!=out_samples)test_failed();
}
}
fprintf(stdout," dec[all] random packets, all mode pairs (4096), %d bytes/frame OK.\n",plen+1);