vbr.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright (C) 2002 Jean-Marc Valin */
  2. /**
  3. @file vbr.h
  4. @brief Variable Bit-Rate (VBR) related routines
  5. */
  6. /*
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions
  9. are met:
  10. - Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. - Redistributions in binary form must reproduce the above copyright
  13. notice, this list of conditions and the following disclaimer in the
  14. documentation and/or other materials provided with the distribution.
  15. - Neither the name of the Xiph.org Foundation nor the names of its
  16. contributors may be used to endorse or promote products derived from
  17. this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  22. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef VBR_H
  31. #define VBR_H
  32. #include "arch.h"
  33. #define VBR_MEMORY_SIZE 5
  34. extern const float vbr_nb_thresh[9][11];
  35. extern const float vbr_hb_thresh[5][11];
  36. extern const float vbr_uhb_thresh[2][11];
  37. /** VBR state. */
  38. typedef struct VBRState {
  39. float average_energy;
  40. float last_energy;
  41. float last_log_energy[VBR_MEMORY_SIZE];
  42. float accum_sum;
  43. float last_pitch_coef;
  44. float soft_pitch;
  45. float last_quality;
  46. float noise_level;
  47. float noise_accum;
  48. float noise_accum_count;
  49. int consec_noise;
  50. } VBRState;
  51. void vbr_init(VBRState *vbr);
  52. float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef);
  53. void vbr_destroy(VBRState *vbr);
  54. #endif