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

Side by Side Diff: celt/entenc.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/entdec.c ('k') | celt/fixed_c5x.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) 2001-2011 Timothy B. Terriberry 1 /* Copyright (c) 2001-2011 Timothy B. Terriberry
2 Copyright (c) 2008-2009 Xiph.Org Foundation */ 2 Copyright (c) 2008-2009 Xiph.Org Foundation */
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
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 unsigned sym; 91 unsigned sym;
92 sym=(EC_SYM_MAX+carry)&EC_SYM_MAX; 92 sym=(EC_SYM_MAX+carry)&EC_SYM_MAX;
93 do _this->error|=ec_write_byte(_this,sym); 93 do _this->error|=ec_write_byte(_this,sym);
94 while(--(_this->ext)>0); 94 while(--(_this->ext)>0);
95 } 95 }
96 _this->rem=_c&EC_SYM_MAX; 96 _this->rem=_c&EC_SYM_MAX;
97 } 97 }
98 else _this->ext++; 98 else _this->ext++;
99 } 99 }
100 100
101 static void ec_enc_normalize(ec_enc *_this){ 101 static OPUS_INLINE void ec_enc_normalize(ec_enc *_this){
102 /*If the range is too small, output some bits and rescale it.*/ 102 /*If the range is too small, output some bits and rescale it.*/
103 while(_this->rng<=EC_CODE_BOT){ 103 while(_this->rng<=EC_CODE_BOT){
104 ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT)); 104 ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT));
105 /*Move the next-to-high-order symbol into the high-order position.*/ 105 /*Move the next-to-high-order symbol into the high-order position.*/
106 _this->val=(_this->val<<EC_SYM_BITS)&(EC_CODE_TOP-1); 106 _this->val=(_this->val<<EC_SYM_BITS)&(EC_CODE_TOP-1);
107 _this->rng<<=EC_SYM_BITS; 107 _this->rng<<=EC_SYM_BITS;
108 _this->nbits_total+=EC_SYM_BITS; 108 _this->nbits_total+=EC_SYM_BITS;
109 } 109 }
110 } 110 }
111 111
112 void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){ 112 void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){
113 _this->buf=_buf; 113 _this->buf=_buf;
114 _this->end_offs=0; 114 _this->end_offs=0;
115 _this->end_window=0; 115 _this->end_window=0;
116 _this->nend_bits=0; 116 _this->nend_bits=0;
117 /*This is the offset from which ec_tell() will subtract partial bits.*/ 117 /*This is the offset from which ec_tell() will subtract partial bits.*/
118 _this->nbits_total=EC_CODE_BITS+1; 118 _this->nbits_total=EC_CODE_BITS+1;
119 _this->offs=0; 119 _this->offs=0;
120 _this->rng=EC_CODE_TOP; 120 _this->rng=EC_CODE_TOP;
121 _this->rem=-1; 121 _this->rem=-1;
122 _this->val=0; 122 _this->val=0;
123 _this->ext=0; 123 _this->ext=0;
124 _this->storage=_size; 124 _this->storage=_size;
125 _this->error=0; 125 _this->error=0;
126 } 126 }
127 127
128 void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ 128 void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){
129 opus_uint32 r; 129 opus_uint32 r;
130 r=_this->rng/_ft; 130 r=celt_udiv(_this->rng,_ft);
131 if(_fl>0){ 131 if(_fl>0){
132 _this->val+=_this->rng-IMUL32(r,(_ft-_fl)); 132 _this->val+=_this->rng-IMUL32(r,(_ft-_fl));
133 _this->rng=IMUL32(r,(_fh-_fl)); 133 _this->rng=IMUL32(r,(_fh-_fl));
134 } 134 }
135 else _this->rng-=IMUL32(r,(_ft-_fh)); 135 else _this->rng-=IMUL32(r,(_ft-_fh));
136 ec_enc_normalize(_this); 136 ec_enc_normalize(_this);
137 } 137 }
138 138
139 void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ 139 void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){
140 opus_uint32 r; 140 opus_uint32 r;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 would corrupt the range coder data, and that's more important.*/ 285 would corrupt the range coder data, and that's more important.*/
286 if(_this->offs+_this->end_offs>=_this->storage&&l<used){ 286 if(_this->offs+_this->end_offs>=_this->storage&&l<used){
287 window&=(1<<l)-1; 287 window&=(1<<l)-1;
288 _this->error=-1; 288 _this->error=-1;
289 } 289 }
290 _this->buf[_this->storage-_this->end_offs-1]|=(unsigned char)window; 290 _this->buf[_this->storage-_this->end_offs-1]|=(unsigned char)window;
291 } 291 }
292 } 292 }
293 } 293 }
294 } 294 }
OLDNEW
« no previous file with comments | « celt/entdec.c ('k') | celt/fixed_c5x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698