ref: 8fcfe02bc0f5f751c8ea2f6dd2027577331b1deb
parent: fa3ef8dcda2aa607865edf61e2b024cd5377abc2
author: Gregory Maxwell <[email protected]>
date: Fri Oct 28 18:47:20 EDT 2011
Update test_opus_encode / test_opus_decode for better LBRR/PLC testing and to reduce stack usage.
--- a/tests/test_opus_decode.c
+++ b/tests/test_opus_decode.c
@@ -41,7 +41,7 @@
#include "test_opus_common.h"
#define MAX_PACKET (1500)
-#define MAX_FRAME_SAMP (288000)
+#define MAX_FRAME_SAMP (5760)
extern int jackpot;
int test_decoder_code0(void)
@@ -52,6 +52,8 @@
int t;
opus_int32 i;
OpusDecoder *dec[5*2];
+ opus_int32 decsize;
+ OpusDecoder *decbak;
opus_uint32 dec_final_range1,dec_final_range2,dec_final_acc;
unsigned char *packet;
unsigned char modes[4096];
@@ -89,6 +91,10 @@
}
}
+ decsize=opus_decoder_get_size(2);
+ decbak=(OpusDecoder *)malloc(decsize);
+ if(decbak==NULL)test_failed();
+
for(t=0;t<5*2;t++)
{
int factor=48000/fsv[t>>1];
@@ -263,6 +269,12 @@
packet[0]=modes[i]<<2;
for(t=0;t<5*2;t++)expected[t]=opus_decoder_get_nb_samples(dec[t],packet,plen);
for(j=0;j<plen;j++)packet[j+1]=(fast_rand()|fast_rand())&255;
+ memcpy(decbak,dec[0],decsize);
+ if(opus_decode(decbak, packet, plen+1, outbuf, MAX_FRAME_SAMP, 1)!=expected[0])test_failed();
+ memcpy(decbak,dec[0],decsize);
+ if(opus_decode(decbak, 0, 0, outbuf, MAX_FRAME_SAMP, 1)<20)test_failed();
+ memcpy(decbak,dec[0],decsize);
+ if(opus_decode(decbak, 0, 0, outbuf, MAX_FRAME_SAMP, 0)<20)test_failed();
for(t=0;t<5*2;t++)
{
out_samples = opus_decode(dec[t], packet, plen+1, outbuf, MAX_FRAME_SAMP, 0);
--- a/tests/test_opus_encode.c
+++ b/tests/test_opus_encode.c
@@ -44,7 +44,7 @@
#define MAX_PACKET (1500)
#define SAMPLES (48000*30)
#define SSAMPLES (SAMPLES/3)
-#define MAX_FRAME_SAMP (288000)
+#define MAX_FRAME_SAMP (5760)
#define PI (3.141592653589793238462643f)
@@ -215,6 +215,11 @@
if(out_samples!=frame_size)test_failed();
if(opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range))!=OPUS_OK)test_failed();
if(enc_final_range!=dec_final_range)test_failed();
+ /*LBRR decode*/
+ out_samples = opus_decode(dec_err[0], packet, len, out2buf, MAX_FRAME_SAMP, (fast_rand()&3)!=0);
+ if(out_samples!=frame_size)test_failed();
+ out_samples = opus_decode(dec_err[1], packet, (fast_rand()&3)==0?0:len, out2buf, MAX_FRAME_SAMP, (fast_rand()&7)!=0);
+ if(out_samples<120)test_failed();
i+=frame_size;
count++;
}while(i<(SSAMPLES-MAX_FRAME_SAMP));
@@ -258,6 +263,11 @@
if(out_samples!=frame_size*6)test_failed();
if(opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range))!=OPUS_OK)test_failed();
if(enc_final_range!=dec_final_range)test_failed();
+ /*LBRR decode*/
+ out_samples = opus_decode(dec_err[8], packet, len, out2buf, MAX_FRAME_SAMP, (fast_rand()&3)!=0);
+ if(out_samples!=frame_size)test_failed();
+ out_samples = opus_decode(dec_err[9], packet, (fast_rand()&3)==0?0:len, out2buf, MAX_FRAME_SAMP, (fast_rand()&7)!=0);
+ if(out_samples<20)test_failed();
i+=frame_size;
count++;
}while(i<(SSAMPLES/6-MAX_FRAME_SAMP));