OLD | NEW |
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 Written by Jean-Marc Valin */ | 3 Written by Jean-Marc Valin */ |
4 /* | 4 /* |
5 Redistribution and use in source and binary forms, with or without | 5 Redistribution and use in source and binary forms, with or without |
6 modification, are permitted provided that the following conditions | 6 modification, are permitted provided that the following conditions |
7 are met: | 7 are met: |
8 | 8 |
9 - Redistributions of source code must retain the above copyright | 9 - Redistributions of source code must retain the above copyright |
10 notice, this list of conditions and the following disclaimer. | 10 notice, this list of conditions and the following disclaimer. |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 intra_bias = (opus_int32)((budget**delayedIntra*loss_rate)/(C*512)); | 276 intra_bias = (opus_int32)((budget**delayedIntra*loss_rate)/(C*512)); |
277 new_distortion = loss_distortion(eBands, oldEBands, start, effEnd, m->nbEBand
s, C); | 277 new_distortion = loss_distortion(eBands, oldEBands, start, effEnd, m->nbEBand
s, C); |
278 | 278 |
279 tell = ec_tell(enc); | 279 tell = ec_tell(enc); |
280 if (tell+3 > budget) | 280 if (tell+3 > budget) |
281 two_pass = intra = 0; | 281 two_pass = intra = 0; |
282 | 282 |
283 /* Encode the global flags using a simple probability model | 283 /* Encode the global flags using a simple probability model |
284 (first symbols in the stream) */ | 284 (first symbols in the stream) */ |
285 | 285 |
| 286 max_decay = QCONST16(16.f,DB_SHIFT); |
| 287 if (end-start>10) |
| 288 { |
286 #ifdef FIXED_POINT | 289 #ifdef FIXED_POINT |
287 max_decay = MIN32(QCONST16(16.f,DB_SHIFT), SHL32(EXTEND32(nbAvailableBytes
),DB_SHIFT-3)); | 290 max_decay = MIN32(max_decay, SHL32(EXTEND32(nbAvailableBytes),DB_SHIFT-3))
; |
288 #else | 291 #else |
289 max_decay = MIN32(16.f, .125f*nbAvailableBytes); | 292 max_decay = MIN32(max_decay, .125f*nbAvailableBytes); |
290 #endif | 293 #endif |
291 | 294 } |
292 enc_start_state = *enc; | 295 enc_start_state = *enc; |
293 | 296 |
294 ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16); | 297 ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16); |
295 ALLOC(error_intra, C*m->nbEBands, opus_val16); | 298 ALLOC(error_intra, C*m->nbEBands, opus_val16); |
296 OPUS_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); | 299 OPUS_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); |
297 | 300 |
298 if (two_pass || intra) | 301 if (two_pass || intra) |
299 { | 302 { |
300 badness1 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands_intra
, budget, | 303 badness1 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands_intra
, budget, |
301 tell, e_prob_model[LM][1], error_intra, enc, C, LM, 1, max_decay); | 304 tell, e_prob_model[LM][1], error_intra, enc, C, LM, 1, max_decay); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 c=0; | 561 c=0; |
559 do { | 562 do { |
560 for (i=0;i<effEnd;i++) | 563 for (i=0;i<effEnd;i++) |
561 bandLogE[i+c*m->nbEBands] = | 564 bandLogE[i+c*m->nbEBands] = |
562 celt_log2(SHL32(bandE[i+c*m->nbEBands],2)) | 565 celt_log2(SHL32(bandE[i+c*m->nbEBands],2)) |
563 - SHL16((opus_val16)eMeans[i],6); | 566 - SHL16((opus_val16)eMeans[i],6); |
564 for (i=effEnd;i<end;i++) | 567 for (i=effEnd;i<end;i++) |
565 bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT); | 568 bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT); |
566 } while (++c < C); | 569 } while (++c < C); |
567 } | 570 } |
OLD | NEW |