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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 tell, e_prob_model[LM][1], error_intra, enc, C, LM, 1, max_decay, lf
e); | 305 tell, e_prob_model[LM][1], error_intra, enc, C, LM, 1, max_decay, lf
e); |
306 } | 306 } |
307 | 307 |
308 if (!intra) | 308 if (!intra) |
309 { | 309 { |
310 unsigned char *intra_buf; | 310 unsigned char *intra_buf; |
311 ec_enc enc_intra_state; | 311 ec_enc enc_intra_state; |
312 opus_int32 tell_intra; | 312 opus_int32 tell_intra; |
313 opus_uint32 nstart_bytes; | 313 opus_uint32 nstart_bytes; |
314 opus_uint32 nintra_bytes; | 314 opus_uint32 nintra_bytes; |
| 315 opus_uint32 save_bytes; |
315 int badness2; | 316 int badness2; |
316 VARDECL(unsigned char, intra_bits); | 317 VARDECL(unsigned char, intra_bits); |
317 | 318 |
318 tell_intra = ec_tell_frac(enc); | 319 tell_intra = ec_tell_frac(enc); |
319 | 320 |
320 enc_intra_state = *enc; | 321 enc_intra_state = *enc; |
321 | 322 |
322 nstart_bytes = ec_range_bytes(&enc_start_state); | 323 nstart_bytes = ec_range_bytes(&enc_start_state); |
323 nintra_bytes = ec_range_bytes(&enc_intra_state); | 324 nintra_bytes = ec_range_bytes(&enc_intra_state); |
324 intra_buf = ec_get_buffer(&enc_intra_state) + nstart_bytes; | 325 intra_buf = ec_get_buffer(&enc_intra_state) + nstart_bytes; |
325 ALLOC(intra_bits, nintra_bytes-nstart_bytes, unsigned char); | 326 save_bytes = nintra_bytes-nstart_bytes; |
| 327 if (save_bytes == 0) |
| 328 save_bytes = ALLOC_NONE; |
| 329 ALLOC(intra_bits, save_bytes, unsigned char); |
326 /* Copy bits from intra bit-stream */ | 330 /* Copy bits from intra bit-stream */ |
327 OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); | 331 OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); |
328 | 332 |
329 *enc = enc_start_state; | 333 *enc = enc_start_state; |
330 | 334 |
331 badness2 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budg
et, | 335 badness2 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budg
et, |
332 tell, e_prob_model[LM][intra], error, enc, C, LM, 0, max_decay, lfe)
; | 336 tell, e_prob_model[LM][intra], error, enc, C, LM, 0, max_decay, lfe)
; |
333 | 337 |
334 if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ((opus_in
t32)ec_tell_frac(enc))+intra_bias > tell_intra))) | 338 if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ((opus_in
t32)ec_tell_frac(enc))+intra_bias > tell_intra))) |
335 { | 339 { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 c=0; | 547 c=0; |
544 do { | 548 do { |
545 for (i=0;i<effEnd;i++) | 549 for (i=0;i<effEnd;i++) |
546 bandLogE[i+c*m->nbEBands] = | 550 bandLogE[i+c*m->nbEBands] = |
547 celt_log2(SHL32(bandE[i+c*m->nbEBands],2)) | 551 celt_log2(SHL32(bandE[i+c*m->nbEBands],2)) |
548 - SHL16((opus_val16)eMeans[i],6); | 552 - SHL16((opus_val16)eMeans[i],6); |
549 for (i=effEnd;i<end;i++) | 553 for (i=effEnd;i<end;i++) |
550 bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT); | 554 bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT); |
551 } while (++c < C); | 555 } while (++c < C); |
552 } | 556 } |
OLD | NEW |