ref: 19239ea3a29d726bf6192afce174ae81ed37c0c1
parent: a0737d1fcfcc099ae72d23c127d11bfa0a0b8879
author: Gregory Maxwell <[email protected]>
date: Wed Dec 5 16:43:29 EST 2012
Add tests for GET_LAST_PACKET_DURATION. Also remove a useless extern that crept into the tests from some optimization driven testcase generation.
--- 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 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 @@
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 @@
/*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 @@
{
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 @@
{
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 @@
{
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 @@
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);