summaryrefslogtreecommitdiffstats
path: root/libAACenc/src/metadata_compressor.h
blob: 1d53f8136e32d4130d9feb4756eabb60e73f5859 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/**********************  Fraunhofer IIS FDK AAC Encoder lib  ******************

                        (C) Copyright Fraunhofer IIS (2011)
                               All Rights Reserved

    Please be advised that this software and/or program delivery is
    Confidential Information of Fraunhofer and subject to and covered by the

    Fraunhofer IIS Software Evaluation Agreement
    between Google Inc. and  Fraunhofer
    effective and in full force since March 1, 2012.

    You may use this software and/or program only under the terms and
    conditions described in the above mentioned Fraunhofer IIS Software
    Evaluation Agreement. Any other and/or further use requires a separate agreement.


   $Id$
   Author(s): M. Neusinger
   Description: Compressor for AAC Metadata Generator

   This software and/or program is protected by copyright law and international
   treaties. Any reproduction or distribution of this software and/or program,
   or any portion of it, may result in severe civil and criminal penalties, and
   will be prosecuted to the maximum extent possible under law.

******************************************************************************/

#ifndef _METADATA_COMPRESSOR_H
#define _METADATA_COMPRESSOR_H


#include "FDK_audio.h"
#include "common_fix.h"

#include "aacenc.h"


/**
 *  DRC compression profiles.
 */
typedef enum DRC_PROFILE {
  DRC_NONE          = 0,
  DRC_FILMSTANDARD  = 1,
  DRC_FILMLIGHT     = 2,
  DRC_MUSICSTANDARD = 3,
  DRC_MUSICLIGHT    = 4,
  DRC_SPEECH        = 5,
  DRC_DELAY_TEST    = 6

} DRC_PROFILE;


/**
 *  DRC Compressor handle.
 */
typedef struct DRC_COMP  DRC_COMP, *HDRC_COMP;

/**
 * \brief  Open a DRC Compressor instance.
 *
 * Allocate memory for a compressor instance.
 *
 * \param phDrcComp             A pointer to a compressor handle. Initialized on return.
 *
 * \return
 *          - 0, on succes.
 *          - unequal 0, on failure.
 */
INT FDK_DRC_Generator_Open(
        HDRC_COMP                      *phDrcComp
        );


/**
 * \brief  Close the DRC Compressor instance.
 *
 * Deallocate instance and free whole memory.
 *
 * \param phDrcComp             Pointer to the compressor handle to be deallocated.
 *
 * \return
 *          - 0, on succes.
 *          - unequal 0, on failure.
 */
INT FDK_DRC_Generator_Close(
        HDRC_COMP                      *phDrcComp
        );

/**
 * \brief  Configure DRC Compressor.
 *
 * \param drcComp               Compressor handle.
 * \param profileLine           DRC profile for line mode.
 * \param profileRF             DRC profile for RF mode.
 * \param blockLength           Length of processing block in samples per channel.
 * \param sampleRate            Sampling rate in Hz.
 * \param channelMode           Channel configuration.
 * \param channelOrder          Channel order, MPEG or WAV.
 * \param useWeighting          Use weighting filter for loudness calculation
 *
 * \return
 *          - 0, on success,
 *          - unequal 0, on failure
 */
INT FDK_DRC_Generator_Initialize(
        HDRC_COMP                       drcComp,
        const DRC_PROFILE               profileLine,
        const DRC_PROFILE               profileRF,
        const INT                       blockLength,
        const UINT                      sampleRate,
        const CHANNEL_MODE              channelMode,
        const CHANNEL_ORDER             channelOrder,
        const UCHAR                     useWeighting
        );

/**
 * \brief  Calculate DRC Compressor Gain.
 *
 * \param drcComp               Compressor handle.
 * \param inSamples             Pointer to interleaved input audio samples.
 * \param dialnorm              Dialog Level in dB (typically -31...-1).
 * \param drc_TargetRefLevel
 * \param comp_TargetRefLevel
 * \param clev                  Downmix center mix factor (typically 0.707, 0.595 or 0.5)
 * \param slev                  Downmix surround mix factor (typically 0.707, 0.5, or 0)
 * \param dynrng                Pointer to variable receiving line mode DRC gain in dB
 * \param compr                 Pointer to variable receiving RF mode DRC gain in dB
 *
 * \return
 *          - 0, on success,
 *          - unequal 0, on failure
 */
INT FDK_DRC_Generator_Calc(
        HDRC_COMP                       drcComp,
        const INT_PCM * const           inSamples,
        const INT                       dialnorm,
        const INT                       drc_TargetRefLevel,
        const INT                       comp_TargetRefLevel,
        FIXP_DBL                        clev,
        FIXP_DBL                        slev,
        INT * const                     dynrng,
        INT * const                     compr
        );


/**
 * \brief  Configure DRC Compressor Profile.
 *
 * \param drcComp               Compressor handle.
 * \param profileLine           DRC profile for line mode.
 * \param profileRF             DRC profile for RF mode.
 *
 * \return
 *          - 0, on success,
 *          - unequal 0, on failure
 */
INT FDK_DRC_Generator_setDrcProfile(
        HDRC_COMP                       drcComp,
        const DRC_PROFILE               profileLine,
        const DRC_PROFILE               profileRF
        );


/**
 * \brief  Get DRC profile for line mode.
 *
 * \param drcComp               Compressor handle.
 *
 * \return  Current Profile.
 */
DRC_PROFILE FDK_DRC_Generator_getDrcProfile(
        const HDRC_COMP                 drcComp
        );


/**
 * \brief  Get DRC profile for RF mode.
 *
 * \param drcComp               Compressor handle.
 *
 * \return  Current Profile.
 */
DRC_PROFILE FDK_DRC_Generator_getCompProfile(
        const HDRC_COMP                 drcComp
        );


#endif /* _METADATA_COMPRESSOR_H */