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

Side by Side Diff: celt/cwrs.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 | « celt/cpu_support.h ('k') | celt/ecintrin.h » ('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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 /*N=12, K=12...18:*/ 403 /*N=12, K=12...18:*/
404 45046719, 103274625, 224298231, 464387817, 921406335, 1759885185, 404 45046719, 103274625, 224298231, 464387817, 921406335, 1759885185,
405 3248227095U, 405 3248227095U,
406 /*N=13, K=13...16:*/ 406 /*N=13, K=13...16:*/
407 251595969, 579168825, 1267854873, 2653649025U, 407 251595969, 579168825, 1267854873, 2653649025U,
408 /*N=14, K=14:*/ 408 /*N=14, K=14:*/
409 1409933619 409 1409933619
410 }; 410 };
411 411
412 #if defined(CUSTOM_MODES) 412 #if defined(CUSTOM_MODES)
413 const opus_uint32 *const CELT_PVQ_U_ROW[15]={ 413 static const opus_uint32 *const CELT_PVQ_U_ROW[15]={
414 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 208,CELT_PVQ_U_DATA+ 415, 414 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 208,CELT_PVQ_U_DATA+ 415,
415 CELT_PVQ_U_DATA+ 621,CELT_PVQ_U_DATA+ 826,CELT_PVQ_U_DATA+1030, 415 CELT_PVQ_U_DATA+ 621,CELT_PVQ_U_DATA+ 826,CELT_PVQ_U_DATA+1030,
416 CELT_PVQ_U_DATA+1233,CELT_PVQ_U_DATA+1336,CELT_PVQ_U_DATA+1389, 416 CELT_PVQ_U_DATA+1233,CELT_PVQ_U_DATA+1336,CELT_PVQ_U_DATA+1389,
417 CELT_PVQ_U_DATA+1421,CELT_PVQ_U_DATA+1441,CELT_PVQ_U_DATA+1455, 417 CELT_PVQ_U_DATA+1421,CELT_PVQ_U_DATA+1441,CELT_PVQ_U_DATA+1455,
418 CELT_PVQ_U_DATA+1464,CELT_PVQ_U_DATA+1470,CELT_PVQ_U_DATA+1473 418 CELT_PVQ_U_DATA+1464,CELT_PVQ_U_DATA+1470,CELT_PVQ_U_DATA+1473
419 }; 419 };
420 #else 420 #else
421 const opus_uint32 *const CELT_PVQ_U_ROW[15]={ 421 static const opus_uint32 *const CELT_PVQ_U_ROW[15]={
422 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 176,CELT_PVQ_U_DATA+ 351, 422 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 176,CELT_PVQ_U_DATA+ 351,
423 CELT_PVQ_U_DATA+ 525,CELT_PVQ_U_DATA+ 698,CELT_PVQ_U_DATA+ 870, 423 CELT_PVQ_U_DATA+ 525,CELT_PVQ_U_DATA+ 698,CELT_PVQ_U_DATA+ 870,
424 CELT_PVQ_U_DATA+1041,CELT_PVQ_U_DATA+1131,CELT_PVQ_U_DATA+1178, 424 CELT_PVQ_U_DATA+1041,CELT_PVQ_U_DATA+1131,CELT_PVQ_U_DATA+1178,
425 CELT_PVQ_U_DATA+1207,CELT_PVQ_U_DATA+1226,CELT_PVQ_U_DATA+1240, 425 CELT_PVQ_U_DATA+1207,CELT_PVQ_U_DATA+1226,CELT_PVQ_U_DATA+1240,
426 CELT_PVQ_U_DATA+1248,CELT_PVQ_U_DATA+1254,CELT_PVQ_U_DATA+1257 426 CELT_PVQ_U_DATA+1248,CELT_PVQ_U_DATA+1254,CELT_PVQ_U_DATA+1257
427 }; 427 };
428 #endif 428 #endif
429 429
430 #if defined(CUSTOM_MODES) 430 #if defined(CUSTOM_MODES)
431 void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ 431 void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 527
528 void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ 528 void 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); 529 cwrsi(_n,_k,ec_dec_uint(_dec,CELT_PVQ_V(_n,_k)),_y);
530 } 530 }
531 531
532 #else /* SMALL_FOOTPRINT */ 532 #else /* SMALL_FOOTPRINT */
533 533
534 /*Computes the next row/column of any recurrence that obeys the relation 534 /*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]. 535 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.*/ 536 _ui0 is the base case for the new row/column.*/
537 static inline void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){ 537 static OPUS_INLINE void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){
538 opus_uint32 ui1; 538 opus_uint32 ui1;
539 unsigned j; 539 unsigned j;
540 /*This do-while will overrun the array if we don't have storage for at least 540 /*This do-while will overrun the array if we don't have storage for at least
541 2 values.*/ 541 2 values.*/
542 j=1; do { 542 j=1; do {
543 ui1=UADD32(UADD32(_ui[j],_ui[j-1]),_ui0); 543 ui1=UADD32(UADD32(_ui[j],_ui[j-1]),_ui0);
544 _ui[j-1]=_ui0; 544 _ui[j-1]=_ui0;
545 _ui0=ui1; 545 _ui0=ui1;
546 } while (++j<_len); 546 } while (++j<_len);
547 _ui[j-1]=_ui0; 547 _ui[j-1]=_ui0;
548 } 548 }
549 549
550 /*Computes the previous row/column of any recurrence that obeys the relation 550 /*Computes the previous row/column of any recurrence that obeys the relation
551 u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1]. 551 u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1].
552 _ui0 is the base case for the new row/column.*/ 552 _ui0 is the base case for the new row/column.*/
553 static inline void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){ 553 static OPUS_INLINE void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){
554 opus_uint32 ui1; 554 opus_uint32 ui1;
555 unsigned j; 555 unsigned j;
556 /*This do-while will overrun the array if we don't have storage for at least 556 /*This do-while will overrun the array if we don't have storage for at least
557 2 values.*/ 557 2 values.*/
558 j=1; do { 558 j=1; do {
559 ui1=USUB32(USUB32(_ui[j],_ui[j-1]),_ui0); 559 ui1=USUB32(USUB32(_ui[j],_ui[j-1]),_ui0);
560 _ui[j-1]=_ui0; 560 _ui[j-1]=_ui0;
561 _ui0=ui1; 561 _ui0=ui1;
562 } while (++j<_n); 562 } while (++j<_n);
563 _ui[j-1]=_ui0; 563 _ui[j-1]=_ui0;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 _y[j]=(yj+s)^s; 610 _y[j]=(yj+s)^s;
611 uprev(_u,_k+2,0); 611 uprev(_u,_k+2,0);
612 } 612 }
613 while(++j<_n); 613 while(++j<_n);
614 } 614 }
615 615
616 /*Returns the index of the given combination of K elements chosen from a set 616 /*Returns the index of the given combination of K elements chosen from a set
617 of size 1 with associated sign bits. 617 of size 1 with associated sign bits.
618 _y: The vector of pulses, whose sum of absolute values is K. 618 _y: The vector of pulses, whose sum of absolute values is K.
619 _k: Returns K.*/ 619 _k: Returns K.*/
620 static inline opus_uint32 icwrs1(const int *_y,int *_k){ 620 static OPUS_INLINE opus_uint32 icwrs1(const int *_y,int *_k){
621 *_k=abs(_y[0]); 621 *_k=abs(_y[0]);
622 return _y[0]<0; 622 return _y[0]<0;
623 } 623 }
624 624
625 /*Returns the index of the given combination of K elements chosen from a set 625 /*Returns the index of the given combination of K elements chosen from a set
626 of size _n with associated sign bits. 626 of size _n with associated sign bits.
627 _y: The vector of pulses, whose sum of absolute values must be _k. 627 _y: The vector of pulses, whose sum of absolute values must be _k.
628 _nc: Returns V(_n,_k).*/ 628 _nc: Returns V(_n,_k).*/
629 static inline opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y, 629 static OPUS_INLINE opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_ y,
630 opus_uint32 *_u){ 630 opus_uint32 *_u){
631 opus_uint32 i; 631 opus_uint32 i;
632 int j; 632 int j;
633 int k; 633 int k;
634 /*We can't unroll the first two iterations of the loop unless _n>=2.*/ 634 /*We can't unroll the first two iterations of the loop unless _n>=2.*/
635 celt_assert(_n>=2); 635 celt_assert(_n>=2);
636 _u[0]=0; 636 _u[0]=0;
637 for(k=1;k<=_k+1;k++)_u[k]=(k<<1)-1; 637 for(k=1;k<=_k+1;k++)_u[k]=(k<<1)-1;
638 i=icwrs1(_y+_n-1,&k); 638 i=icwrs1(_y+_n-1,&k);
639 j=_n-2; 639 j=_n-2;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ 688 void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){
689 VARDECL(opus_uint32,u); 689 VARDECL(opus_uint32,u);
690 SAVE_STACK; 690 SAVE_STACK;
691 celt_assert(_k>0); 691 celt_assert(_k>0);
692 ALLOC(u,_k+2U,opus_uint32); 692 ALLOC(u,_k+2U,opus_uint32);
693 cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u); 693 cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u);
694 RESTORE_STACK; 694 RESTORE_STACK;
695 } 695 }
696 696
697 #endif /* SMALL_FOOTPRINT */ 697 #endif /* SMALL_FOOTPRINT */
OLDNEW
« no previous file with comments | « celt/cpu_support.h ('k') | celt/ecintrin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698