Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: tests/test_opus_decode.c

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/test_opus_common.h ('k') | tests/test_opus_encode.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 Xiph.Org Foundation 1 /* Copyright (c) 2011-2013 Xiph.Org Foundation
2 Written by Gregory Maxwell */ 2 Written by Gregory Maxwell */
3 /* 3 /*
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions 5 modification, are permitted provided that the following conditions
6 are met: 6 are met:
7 7
8 - Redistributions of source code must retain the above copyright 8 - Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer. 9 notice, this list of conditions and the following disclaimer.
10 10
11 - Redistributions in binary form must reproduce the above copyright 11 - Redistributions in binary form must reproduce the above copyright
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 err=0; 366 err=0;
367 for(i=0;i<8*2;i++)err|=outbuf_int[i]!=32749; 367 for(i=0;i<8*2;i++)err|=outbuf_int[i]!=32749;
368 for(i=MAX_FRAME_SAMP*2;i<(MAX_FRAME_SAMP+8)*2;i++)err|=outbuf[i]!=32749; 368 for(i=MAX_FRAME_SAMP*2;i<(MAX_FRAME_SAMP+8)*2;i++)err|=outbuf[i]!=32749;
369 if(err)test_failed(); 369 if(err)test_failed();
370 370
371 free(outbuf_int); 371 free(outbuf_int);
372 free(packet); 372 free(packet);
373 return 0; 373 return 0;
374 } 374 }
375 375
376 #ifndef DISABLE_FLOAT_API
377 void test_soft_clip(void)
378 {
379 int i,j;
380 float x[1024];
381 float s[8] = {0, 0, 0, 0, 0, 0, 0, 0};
382 fprintf(stdout," Testing opus_pcm_soft_clip... ");
383 for(i=0;i<1024;i++)
384 {
385 for (j=0;j<1024;j++)
386 {
387 x[j]=(i&255)*(1/32.f)-4.f;
388 }
389 opus_pcm_soft_clip(&x[i],1024-i,1,s);
390 for (j=i;j<1024;j++)
391 {
392 if(x[i]>1.f)test_failed();
393 if(x[i]<-1.f)test_failed();
394 }
395 }
396 for(i=1;i<9;i++)
397 {
398 for (j=0;j<1024;j++)
399 {
400 x[j]=(i&255)*(1/32.f)-4.f;
401 }
402 opus_pcm_soft_clip(x,1024/i,i,s);
403 for (j=0;j<(1024/i)*i;j++)
404 {
405 if(x[i]>1.f)test_failed();
406 if(x[i]<-1.f)test_failed();
407 }
408 }
409 opus_pcm_soft_clip(x,0,1,s);
410 opus_pcm_soft_clip(x,1,0,s);
411 opus_pcm_soft_clip(x,1,1,0);
412 opus_pcm_soft_clip(x,1,-1,s);
413 opus_pcm_soft_clip(x,-1,1,s);
414 opus_pcm_soft_clip(0,1,1,s);
415 printf("OK.\n");
416 }
417 #endif
418
376 int main(int _argc, char **_argv) 419 int main(int _argc, char **_argv)
377 { 420 {
378 const char * oversion; 421 const char * oversion;
379 const char * env_seed; 422 const char * env_seed;
380 int env_used; 423 int env_used;
381 424
382 if(_argc>2) 425 if(_argc>2)
383 { 426 {
384 fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]); 427 fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]);
385 return 1; 428 return 1;
(...skipping 12 matching lines...) Expand all
398 441
399 oversion=opus_get_version_string(); 442 oversion=opus_get_version_string();
400 if(!oversion)test_failed(); 443 if(!oversion)test_failed();
401 fprintf(stderr,"Testing %s decoder. Random seed: %u (%.4X)\n", oversion, isee d, fast_rand() % 65535); 444 fprintf(stderr,"Testing %s decoder. Random seed: %u (%.4X)\n", oversion, isee d, fast_rand() % 65535);
402 if(env_used)fprintf(stderr," Random seed set from the environment (SEED=%s). \n", env_seed); 445 if(env_used)fprintf(stderr," Random seed set from the environment (SEED=%s). \n", env_seed);
403 446
404 /*Setting TEST_OPUS_NOFUZZ tells the tool not to send garbage data 447 /*Setting TEST_OPUS_NOFUZZ tells the tool not to send garbage data
405 into the decoders. This is helpful because garbage data 448 into the decoders. This is helpful because garbage data
406 may cause the decoders to clip, which angers CLANG IOC.*/ 449 may cause the decoders to clip, which angers CLANG IOC.*/
407 test_decoder_code0(getenv("TEST_OPUS_NOFUZZ")!=NULL); 450 test_decoder_code0(getenv("TEST_OPUS_NOFUZZ")!=NULL);
451 #ifndef DISABLE_FLOAT_API
452 test_soft_clip();
453 #endif
408 454
409 return 0; 455 return 0;
410 } 456 }
OLDNEW
« no previous file with comments | « tests/test_opus_common.h ('k') | tests/test_opus_encode.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698