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

Side by Side Diff: celt/cwrs.c

Issue 882843002: Update to opus-HEAD-66611f1. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/opus.git@master
Patch Set: Add the contents of Makefile.mips back. Created 5 years, 10 months 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
« no previous file with comments | « celt/cwrs.h ('k') | celt/dump_modes/Makefile » ('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) 2007-2008 CSIRO 1 /* Copyright (c) 2007-2008 CSIRO
2 Copyright (c) 2007-2009 Xiph.Org Foundation 2 Copyright (c) 2007-2009 Xiph.Org Foundation
3 Copyright (c) 2007-2009 Timothy B. Terriberry 3 Copyright (c) 2007-2009 Timothy B. Terriberry
4 Written by Timothy B. Terriberry and Jean-Marc Valin */ 4 Written by Timothy B. Terriberry and Jean-Marc Valin */
5 /* 5 /*
6 Redistribution and use in source and binary forms, with or without 6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions 7 modification, are permitted provided that the following conditions
8 are met: 8 are met:
9 9
10 - Redistributions of source code must retain the above copyright 10 - Redistributions of source code must retain the above copyright
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 453 }
454 while(j>0); 454 while(j>0);
455 return i; 455 return i;
456 } 456 }
457 457
458 void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ 458 void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){
459 celt_assert(_k>0); 459 celt_assert(_k>0);
460 ec_enc_uint(_enc,icwrs(_n,_y),CELT_PVQ_V(_n,_k)); 460 ec_enc_uint(_enc,icwrs(_n,_y),CELT_PVQ_V(_n,_k));
461 } 461 }
462 462
463 static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ 463 static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y){
464 opus_uint32 p; 464 opus_uint32 p;
465 int s; 465 int s;
466 int k0; 466 int k0;
467 opus_int16 val;
468 opus_val32 yy=0;
467 celt_assert(_k>0); 469 celt_assert(_k>0);
468 celt_assert(_n>1); 470 celt_assert(_n>1);
469 while(_n>2){ 471 while(_n>2){
470 opus_uint32 q; 472 opus_uint32 q;
471 /*Lots of pulses case:*/ 473 /*Lots of pulses case:*/
472 if(_k>=_n){ 474 if(_k>=_n){
473 const opus_uint32 *row; 475 const opus_uint32 *row;
474 row=CELT_PVQ_U_ROW[_n]; 476 row=CELT_PVQ_U_ROW[_n];
475 /*Are the pulses in this dimension negative?*/ 477 /*Are the pulses in this dimension negative?*/
476 p=row[_k+1]; 478 p=row[_k+1];
477 s=-(_i>=p); 479 s=-(_i>=p);
478 _i-=p&s; 480 _i-=p&s;
479 /*Count how many pulses were placed in this dimension.*/ 481 /*Count how many pulses were placed in this dimension.*/
480 k0=_k; 482 k0=_k;
481 q=row[_n]; 483 q=row[_n];
482 if(q>_i){ 484 if(q>_i){
483 celt_assert(p>q); 485 celt_assert(p>q);
484 _k=_n; 486 _k=_n;
485 do p=CELT_PVQ_U_ROW[--_k][_n]; 487 do p=CELT_PVQ_U_ROW[--_k][_n];
486 while(p>_i); 488 while(p>_i);
487 } 489 }
488 else for(p=row[_k];p>_i;p=row[_k])_k--; 490 else for(p=row[_k];p>_i;p=row[_k])_k--;
489 _i-=p; 491 _i-=p;
490 *_y++=(k0-_k+s)^s; 492 val=(k0-_k+s)^s;
493 *_y++=val;
494 yy=MAC16_16(yy,val,val);
491 } 495 }
492 /*Lots of dimensions case:*/ 496 /*Lots of dimensions case:*/
493 else{ 497 else{
494 /*Are there any pulses in this dimension at all?*/ 498 /*Are there any pulses in this dimension at all?*/
495 p=CELT_PVQ_U_ROW[_k][_n]; 499 p=CELT_PVQ_U_ROW[_k][_n];
496 q=CELT_PVQ_U_ROW[_k+1][_n]; 500 q=CELT_PVQ_U_ROW[_k+1][_n];
497 if(p<=_i&&_i<q){ 501 if(p<=_i&&_i<q){
498 _i-=p; 502 _i-=p;
499 *_y++=0; 503 *_y++=0;
500 } 504 }
501 else{ 505 else{
502 /*Are the pulses in this dimension negative?*/ 506 /*Are the pulses in this dimension negative?*/
503 s=-(_i>=q); 507 s=-(_i>=q);
504 _i-=q&s; 508 _i-=q&s;
505 /*Count how many pulses were placed in this dimension.*/ 509 /*Count how many pulses were placed in this dimension.*/
506 k0=_k; 510 k0=_k;
507 do p=CELT_PVQ_U_ROW[--_k][_n]; 511 do p=CELT_PVQ_U_ROW[--_k][_n];
508 while(p>_i); 512 while(p>_i);
509 _i-=p; 513 _i-=p;
510 *_y++=(k0-_k+s)^s; 514 val=(k0-_k+s)^s;
515 *_y++=val;
516 yy=MAC16_16(yy,val,val);
511 } 517 }
512 } 518 }
513 _n--; 519 _n--;
514 } 520 }
515 /*_n==2*/ 521 /*_n==2*/
516 p=2*_k+1; 522 p=2*_k+1;
517 s=-(_i>=p); 523 s=-(_i>=p);
518 _i-=p&s; 524 _i-=p&s;
519 k0=_k; 525 k0=_k;
520 _k=(_i+1)>>1; 526 _k=(_i+1)>>1;
521 if(_k)_i-=2*_k-1; 527 if(_k)_i-=2*_k-1;
522 *_y++=(k0-_k+s)^s; 528 val=(k0-_k+s)^s;
529 *_y++=val;
530 yy=MAC16_16(yy,val,val);
523 /*_n==1*/ 531 /*_n==1*/
524 s=-(int)_i; 532 s=-(int)_i;
525 *_y=(_k+s)^s; 533 val=(_k+s)^s;
534 *_y=val;
535 yy=MAC16_16(yy,val,val);
536 return yy;
526 } 537 }
527 538
528 void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ 539 opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){
529 cwrsi(_n,_k,ec_dec_uint(_dec,CELT_PVQ_V(_n,_k)),_y); 540 return cwrsi(_n,_k,ec_dec_uint(_dec,CELT_PVQ_V(_n,_k)),_y);
530 } 541 }
531 542
532 #else /* SMALL_FOOTPRINT */ 543 #else /* SMALL_FOOTPRINT */
533 544
534 /*Computes the next row/column of any recurrence that obeys the relation 545 /*Computes the next row/column of any recurrence that obeys the relation
535 u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1]. 546 u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1].
536 _ui0 is the base case for the new row/column.*/ 547 _ui0 is the base case for the new row/column.*/
537 static OPUS_INLINE void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){ 548 static OPUS_INLINE void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){
538 opus_uint32 ui1; 549 opus_uint32 ui1;
539 unsigned j; 550 unsigned j;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 while(++k<len); 595 while(++k<len);
585 for(k=2;k<_n;k++)unext(_u+1,_k+1,1); 596 for(k=2;k<_n;k++)unext(_u+1,_k+1,1);
586 return _u[_k]+_u[_k+1]; 597 return _u[_k]+_u[_k+1];
587 } 598 }
588 599
589 /*Returns the _i'th combination of _k elements chosen from a set of size _n 600 /*Returns the _i'th combination of _k elements chosen from a set of size _n
590 with associated sign bits. 601 with associated sign bits.
591 _y: Returns the vector of pulses. 602 _y: Returns the vector of pulses.
592 _u: Must contain entries [0..._k+1] of row _n of U() on input. 603 _u: Must contain entries [0..._k+1] of row _n of U() on input.
593 Its contents will be destructively modified.*/ 604 Its contents will be destructively modified.*/
594 static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ 605 static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){
595 int j; 606 int j;
607 opus_int16 val;
608 opus_val32 yy=0;
596 celt_assert(_n>0); 609 celt_assert(_n>0);
597 j=0; 610 j=0;
598 do{ 611 do{
599 opus_uint32 p; 612 opus_uint32 p;
600 int s; 613 int s;
601 int yj; 614 int yj;
602 p=_u[_k+1]; 615 p=_u[_k+1];
603 s=-(_i>=p); 616 s=-(_i>=p);
604 _i-=p&s; 617 _i-=p&s;
605 yj=_k; 618 yj=_k;
606 p=_u[_k]; 619 p=_u[_k];
607 while(p>_i)p=_u[--_k]; 620 while(p>_i)p=_u[--_k];
608 _i-=p; 621 _i-=p;
609 yj-=_k; 622 yj-=_k;
610 _y[j]=(yj+s)^s; 623 val=(yj+s)^s;
624 _y[j]=val;
625 yy=MAC16_16(yy,val,val);
611 uprev(_u,_k+2,0); 626 uprev(_u,_k+2,0);
612 } 627 }
613 while(++j<_n); 628 while(++j<_n);
629 return yy;
614 } 630 }
615 631
616 /*Returns the index of the given combination of K elements chosen from a set 632 /*Returns the index of the given combination of K elements chosen from a set
617 of size 1 with associated sign bits. 633 of size 1 with associated sign bits.
618 _y: The vector of pulses, whose sum of absolute values is K. 634 _y: The vector of pulses, whose sum of absolute values is K.
619 _k: Returns K.*/ 635 _k: Returns K.*/
620 static OPUS_INLINE opus_uint32 icwrs1(const int *_y,int *_k){ 636 static OPUS_INLINE opus_uint32 icwrs1(const int *_y,int *_k){
621 *_k=abs(_y[0]); 637 *_k=abs(_y[0]);
622 return _y[0]<0; 638 return _y[0]<0;
623 } 639 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 VARDECL(opus_uint32,u); 694 VARDECL(opus_uint32,u);
679 opus_uint32 nc; 695 opus_uint32 nc;
680 SAVE_STACK; 696 SAVE_STACK;
681 celt_assert(_k>0); 697 celt_assert(_k>0);
682 ALLOC(u,_k+2U,opus_uint32); 698 ALLOC(u,_k+2U,opus_uint32);
683 i=icwrs(_n,_k,&nc,_y,u); 699 i=icwrs(_n,_k,&nc,_y,u);
684 ec_enc_uint(_enc,i,nc); 700 ec_enc_uint(_enc,i,nc);
685 RESTORE_STACK; 701 RESTORE_STACK;
686 } 702 }
687 703
688 void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ 704 opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){
689 VARDECL(opus_uint32,u); 705 VARDECL(opus_uint32,u);
706 int ret;
690 SAVE_STACK; 707 SAVE_STACK;
691 celt_assert(_k>0); 708 celt_assert(_k>0);
692 ALLOC(u,_k+2U,opus_uint32); 709 ALLOC(u,_k+2U,opus_uint32);
693 cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u); 710 ret = cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u);
694 RESTORE_STACK; 711 RESTORE_STACK;
712 return ret;
695 } 713 }
696 714
697 #endif /* SMALL_FOOTPRINT */ 715 #endif /* SMALL_FOOTPRINT */
OLDNEW
« no previous file with comments | « celt/cwrs.h ('k') | celt/dump_modes/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698