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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 /*Only code a skip decision if we're above the threshold for this band. | 341 /*Only code a skip decision if we're above the threshold for this band. |
342 Otherwise it is force-skipped. | 342 Otherwise it is force-skipped. |
343 This ensures that we have enough bits to code the skip flag.*/ | 343 This ensures that we have enough bits to code the skip flag.*/ |
344 if (band_bits >= IMAX(thresh[j], alloc_floor+(1<<BITRES))) | 344 if (band_bits >= IMAX(thresh[j], alloc_floor+(1<<BITRES))) |
345 { | 345 { |
346 if (encode) | 346 if (encode) |
347 { | 347 { |
348 /*This if() block is the only part of the allocation function that | 348 /*This if() block is the only part of the allocation function that |
349 is not a mandatory part of the bitstream: any bands we choose to | 349 is not a mandatory part of the bitstream: any bands we choose to |
350 skip here must be explicitly signaled.*/ | 350 skip here must be explicitly signaled.*/ |
351 /*Choose a threshold with some hysteresis to keep bands from | 351 int depth_threshold; |
352 fluctuating in and out.*/ | 352 /*We choose a threshold with some hysteresis to keep bands from |
| 353 fluctuating in and out, but we try not to fold below a certain po
int. */ |
| 354 if (codedBands > 17) |
| 355 depth_threshold = j<prev ? 7 : 9; |
| 356 else |
| 357 depth_threshold = 0; |
353 #ifdef FUZZING | 358 #ifdef FUZZING |
354 if ((rand()&0x1) == 0) | 359 if ((rand()&0x1) == 0) |
355 #else | 360 #else |
356 if (codedBands<=start+2 || (band_bits > ((j<prev?7:9)*band_width<<LM
<<BITRES)>>4 && j<=signalBandwidth)) | 361 if (codedBands<=start+2 || (band_bits > (depth_threshold*band_width<
<LM<<BITRES)>>4 && j<=signalBandwidth)) |
357 #endif | 362 #endif |
358 { | 363 { |
359 ec_enc_bit_logp(ec, 1, 1); | 364 ec_enc_bit_logp(ec, 1, 1); |
360 break; | 365 break; |
361 } | 366 } |
362 ec_enc_bit_logp(ec, 0, 1); | 367 ec_enc_bit_logp(ec, 0, 1); |
363 } else if (ec_dec_bit_logp(ec, 1)) { | 368 } else if (ec_dec_bit_logp(ec, 1)) { |
364 break; | 369 break; |
365 } | 370 } |
366 /*We used a bit to skip this band.*/ | 371 /*We used a bit to skip this band.*/ |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 bits1[j] = bits1j; | 635 bits1[j] = bits1j; |
631 bits2[j] = bits2j; | 636 bits2[j] = bits2j; |
632 } | 637 } |
633 codedBands = interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thre
sh, cap, | 638 codedBands = interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thre
sh, cap, |
634 total, balance, skip_rsv, intensity, intensity_rsv, dual_stereo, dual_s
tereo_rsv, | 639 total, balance, skip_rsv, intensity, intensity_rsv, dual_stereo, dual_s
tereo_rsv, |
635 pulses, ebits, fine_priority, C, LM, ec, encode, prev, signalBandwidth)
; | 640 pulses, ebits, fine_priority, C, LM, ec, encode, prev, signalBandwidth)
; |
636 RESTORE_STACK; | 641 RESTORE_STACK; |
637 return codedBands; | 642 return codedBands; |
638 } | 643 } |
639 | 644 |
OLD | NEW |