*** empty log message ***
[platform/upstream/flac.git] / src / plugin_common / replaygain_synthesis.h
1 /* plugin_common - Routines common to several plugins
2  * Copyright (C) 2002  Josh Coalson
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #ifndef FLAC__PLUGIN_COMMON__REPLAYGAIN_SYNTHESIS_H
20 #define FLAC__PLUGIN_COMMON__REPLAYGAIN_SYNTHESIS_H
21
22 #include "export.h"
23
24 #include "defs.h"
25 #include "FLAC/ordinals.h"
26
27 typedef struct {
28         const float*  FilterCoeff;
29         FLAC__uint64  Mask;
30         double        Add;
31         float         Dither;
32         float         ErrorHistory     [FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS] [16];  /* 16th order Noise shaping */
33         float         DitherHistory    [FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS] [16];
34         int           LastRandomNumber [FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS];
35 } DitherContext;
36
37 typedef enum {
38         NOISE_SHAPING_NONE = 0,
39         NOISE_SHAPING_LOW = 1,
40         NOISE_SHAPING_MEDUIM = 2,
41         NOISE_SHAPING_HIGH = 3
42 } NoiseShaping;
43
44 PLUGIN_COMMON_API void FLAC__plugin_common__init_dither_context(DitherContext *dither, int bits, int shapingtype);
45
46 /* scale = (float) pow(10., (double)replaygain * 0.05); */
47 PLUGIN_COMMON_API int FLAC__plugin_common_apply_gain(FLAC__byte *data_out, FLAC__int32 *input, unsigned wide_samples, unsigned channels, const unsigned source_bps, const unsigned target_bps, const float scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, NoiseShaping noise_shaping, DitherContext *dither_context);
48
49 #endif