replaygain_synthesis.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* replaygain_synthesis - Routines for applying ReplayGain to a signal
  2. * Copyright (C) 2002-2009 Josh Coalson
  3. * Copyright (C) 2011-2023 Xiph.Org Foundation
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
  20. #define FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
  21. #include <stdlib.h> /* for size_t */
  22. #include "FLAC/format.h"
  23. #define FLAC_SHARE__MAX_SUPPORTED_CHANNELS FLAC__MAX_CHANNELS
  24. typedef enum {
  25. NOISE_SHAPING_NONE = 0,
  26. NOISE_SHAPING_LOW = 1,
  27. NOISE_SHAPING_MEDIUM = 2,
  28. NOISE_SHAPING_HIGH = 3
  29. } NoiseShaping;
  30. typedef struct {
  31. const float* FilterCoeff;
  32. FLAC__uint64 Mask;
  33. double Add;
  34. float Dither;
  35. float ErrorHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; /* 16th order Noise shaping */
  36. float DitherHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16];
  37. int LastRandomNumber [FLAC_SHARE__MAX_SUPPORTED_CHANNELS];
  38. unsigned LastHistoryIndex;
  39. NoiseShaping ShapingType;
  40. } DitherContext;
  41. void FLAC__replaygain_synthesis__init_dither_context(DitherContext *dither, int bits, int shapingtype);
  42. /* scale = (float) pow(10., (double)replaygain * 0.05); */
  43. size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, const uint32_t source_bps, const uint32_t target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context);
  44. #endif