1 #ifndef __RESAMPLER_RATE_CONVERSION_INPUT_DRIVEN_INT16_H__ |
|
2 #define __RESAMPLER_RATE_CONVERSION_INPUT_DRIVEN_INT16_H__ |
|
3 /* |
|
4 * Copyright (c) 2010 Ixonos Plc. |
|
5 * All rights reserved. |
|
6 * This component and the accompanying materials are made available |
|
7 * under the terms of the "Eclipse Public License v1.0" |
|
8 * which accompanies this distribution, and is available |
|
9 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
10 * |
|
11 * Initial Contributors: |
|
12 * Nokia Corporation - Initial contribution |
|
13 * |
|
14 * Contributors: |
|
15 * Ixonos Plc |
|
16 * |
|
17 * Description: |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 /** @ingroup rate_conversion |
|
23 |
|
24 Base class for input-driven sampling rate conversion. |
|
25 |
|
26 */ |
|
27 |
|
28 #include "resampler_data_types.h" |
|
29 #include "resampler_rate_conversion_quality.h" |
|
30 |
|
31 class RESAMPLER_RateConversionInputDrivenInt16 |
|
32 { |
|
33 |
|
34 public: |
|
35 |
|
36 /** @name Construction & Destruction */ |
|
37 |
|
38 //@{ |
|
39 |
|
40 /** This method checks if the desired conversion is available. |
|
41 |
|
42 @param[in] inRate Input sampling rate |
|
43 @param[in] outRate Output sampling rate |
|
44 @param[in] channelCount Number of audio channels |
|
45 */ |
|
46 static bool RateSupported(float inRate, |
|
47 float outRate, |
|
48 int channelCount); |
|
49 |
|
50 /** This method creates a sampling rate converter for input-driven |
|
51 operation. |
|
52 |
|
53 @param[in] inRate Input sampling rate |
|
54 @param[in] outRate Output sampling rate |
|
55 @param[in] channelCount Number of audio channels |
|
56 */ |
|
57 static RESAMPLER_RateConversionInputDrivenInt16 * New(float inRate, |
|
58 float outRate, |
|
59 int channelCount); |
|
60 |
|
61 /** Constructor |
|
62 */ |
|
63 |
|
64 RESAMPLER_RateConversionInputDrivenInt16() { ; } |
|
65 |
|
66 /** Destructor |
|
67 */ |
|
68 |
|
69 virtual ~RESAMPLER_RateConversionInputDrivenInt16() { ; } |
|
70 |
|
71 //@} |
|
72 |
|
73 |
|
74 /** @name Object lifetime methods */ |
|
75 |
|
76 //@{ |
|
77 |
|
78 /** Initializes the converter. |
|
79 |
|
80 This method initializes the sampling rate converter for input-driven |
|
81 operation. Calling this method twice for the same converter instance |
|
82 is considered a programming error, and behaviour in that case is |
|
83 undefined. |
|
84 |
|
85 @return true if successful false otherwise |
|
86 */ |
|
87 |
|
88 virtual bool InitInputDriven() = 0; |
|
89 |
|
90 //@} |
|
91 |
|
92 /** @name Operation */ |
|
93 |
|
94 //@{ |
|
95 |
|
96 /** Set the quality mode for the subsequent operations */ |
|
97 |
|
98 virtual bool SetQualityInputDriven(int mode); |
|
99 |
|
100 /** Enable one of the channels. |
|
101 |
|
102 This method is used to (re-)enable a rate conversion channel after it's |
|
103 been disabled. (All channels start in the enabled mode.) This is used to |
|
104 tell the algorithm that the channel must be properly processed, if the |
|
105 algorithm wants to take advantage of the optimization possibilities |
|
106 provided by the DisableInputDriven() method. |
|
107 |
|
108 @note The channel index MUST be valid, i.e., it has to be smaller than |
|
109 @c numChannels given at initialization time. |
|
110 |
|
111 @param[in] channel The index of the channel to be enabled. |
|
112 */ |
|
113 |
|
114 virtual void EnableChannelInputDriven(int channel); |
|
115 |
|
116 /** Disable one of the channels. |
|
117 |
|
118 This method can be used to tell the algorithm that the output from a |
|
119 specific channel will not be used in subsequent operations, and the |
|
120 implementation may choose to optimize and leave the disabled channel |
|
121 unprocessed. However, the caller must always provide valid pointers for |
|
122 the actual processing methods for the case where it's difficult to |
|
123 actually disable memory access for the specific channel in an |
|
124 implementation. |
|
125 |
|
126 @note The channel index MUST be valid, i.e., it has to be smaller than |
|
127 @c numChannels given at initialization time. |
|
128 |
|
129 @param[in] channel The index of the channel to be enabled. |
|
130 */ |
|
131 |
|
132 virtual void DisableChannelInputDriven(int channel); |
|
133 |
|
134 /** Query the scratch memory need of the converter. |
|
135 |
|
136 This method queries the amount of scratch memory the converter needs to be |
|
137 able to handle in a single call to the processing functions. |
|
138 |
|
139 @param[in] maxInputBlockSize Maximum input blocksize |
|
140 @return memory need in bytes |
|
141 */ |
|
142 |
|
143 virtual size_t ScratchMemoryNeedInputDriven(int maxInputBlockSize) const = 0; |
|
144 |
|
145 /** Set scratch buffer for the converter |
|
146 |
|
147 This method sets scratch buffer needed by the converter. The caller of this |
|
148 function is responsible of allocating enough memory. |
|
149 |
|
150 @param[in] *buffer pointer to the allocated buffer |
|
151 */ |
|
152 |
|
153 virtual void SetScratchBufferInputDriven(char *buffer) = 0; |
|
154 |
|
155 /** Get the maximum number of output samples for a given input sample count |
|
156 |
|
157 This method returns the maximum number of output samples the converter |
|
158 can ever produce from a given number of input samples. |
|
159 |
|
160 @param[in] inSamples Number of input samples |
|
161 @return Maximum number of output samples |
|
162 */ |
|
163 |
|
164 virtual int MaxOutputSampleCount(int inSamples) const = 0; |
|
165 |
|
166 /** Run the sampling rate conversion for a block of samples |
|
167 |
|
168 This method runs the actual sampling rate conversion. The pointer arrays |
|
169 have to contain valid pointers for numChannels channel data buffers. The |
|
170 output buffers must have space for MaxOutputSampleCount(inSamples) audio |
|
171 samples. |
|
172 |
|
173 @param[out] outputBuffers Pointer to output buffer array |
|
174 @param[in] inputBuffers Pointer to input buffer array |
|
175 @param[in] inSamples The number of input samples to process |
|
176 @return Number of output samples |
|
177 */ |
|
178 |
|
179 virtual int ProcessFromInput(int16 *outputBuffers[], |
|
180 int16 *inputBuffers[], |
|
181 int inSamples) = 0; |
|
182 |
|
183 //@} |
|
184 |
|
185 }; |
|
186 |
|
187 #endif // __RESAMPLER_RATE_CONVERSION_INPUT_DRIVEN_INT16_H__ |
|