videoeditorengine/audioeditorengine/resampler/inc/resampler_sinc_conv_44_to_48_int16.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/videoeditorengine/audioeditorengine/resampler/inc/resampler_sinc_conv_44_to_48_int16.h Fri Jan 29 14:08:33 2010 +0200
@@ -0,0 +1,327 @@
+#ifndef __RESAMPLER_SINC_CONV_44_TO_48_INT16_H__
+#define __RESAMPLER_SINC_CONV_44_TO_48_INT16_H__
+/*
+* Copyright (c) 2010 Ixonos Plc.
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - Initial contribution
+*
+* Contributors:
+* Ixonos Plc
+*
+* Description:
+*
+*/
+
+
+#include "resampler_rate_conversion_input_driven_int16.h"
+#include "resampler_rate_conversion_output_driven_int16.h"
+
+/** @ingroup rate_conversion
+
+ Class for upsampling 16-bit audio from 44.1 kHz to 48kHz
+
+*/
+
+class RESAMPLER_SincConv44To48Int16 : public RESAMPLER_RateConversionInputDrivenInt16,
+ public RESAMPLER_RateConversionOutputDrivenInt16
+{
+ friend class RESAMPLER_RateConversionInputDrivenInt16;
+ friend class RESAMPLER_RateConversionOutputDrivenInt16;
+
+public:
+
+ /** @name Destruction */
+
+ //@{
+
+ /** Destructor
+ */
+
+ virtual ~RESAMPLER_SincConv44To48Int16();
+
+ //@}
+
+ /** @name Query methods */
+
+ //@{
+
+ static bool RateSupported(float inRate, float outRate)
+ { return (160 * inRate == 147 * outRate); }
+
+ //@}
+
+ /** @name Object lifetime methods */
+
+ //@{
+
+ /** Initializes the converter.
+
+ This method initializes the sampling rate converter for input-driven
+ operation.
+
+ @return true if successful false otherwise
+ */
+
+ virtual bool InitInputDriven();
+
+ /** Initializes the converter.
+
+ This method initializes the sampling rate converter. The
+ initialization will be successful only if 3*inRate == outRate.
+
+ @return true if successful false otherwise
+ */
+
+ virtual bool InitOutputDriven();
+
+ //@}
+
+ /** @name Output-driven operation */
+
+ //@{
+
+ /** Set the quality mode for the subsequent operations */
+
+ virtual bool SetQualityOutputDriven(int mode);
+
+ /** Set the quality mode for the subsequent operations */
+
+ virtual bool SetQualityInputDriven(int mode);
+
+ /** Enable one of the channels.
+
+ This method is used to (re-)enable a rate conversion channel after it's
+ been disabled. (All channels start in the enabled mode.) This is used to
+ tell the algorithm that the channel must be properly processed, if the
+ algorithm wants to take advantage of the optimization possibilities
+ provided by the DisableInputDriven() method.
+
+ @note The channel index MUST be valid, i.e., it has to be smaller than
+ @c numChannels given at initialization time.
+
+ @param[in] channel The index of the channel to be enabled.
+ */
+
+ virtual void EnableChannelInputDriven(int channel);
+
+ /** Disable one of the channels.
+
+ This method can be used to tell the algorithm that the output from a
+ specific channel will not be used in subsequent operations, and the
+ implementation may choose to optimize and leave the disabled channel
+ unprocessed. However, the caller must always provide valid pointers for
+ the actual processing methods for the case where it's difficult to
+ actually disable memory access for the specific channel in an
+ implementation.
+
+ @note The channel index MUST be valid, i.e., it has to be smaller than
+ @c numChannels given at initialization time.
+
+ @param[in] channel The index of the channel to be enabled.
+ */
+
+ virtual void DisableChannelInputDriven(int channel);
+
+ /** Enable one of the channels.
+
+ This method is used to (re-)enable a rate conversion channel after it's
+ been disabled. (All channels start in the enabled mode.) This is used to
+ tell the algorithm that the channel must be properly processed, if the
+ algorithm wants to take advantage of the optimization possibilities
+ provided by the DisableInputDriven() method.
+
+ @note The channel index MUST be valid, i.e., it has to be smaller than
+ @c numChannels given at initialization time.
+
+ @param[in] channel The index of the channel to be enabled.
+ */
+
+ virtual void EnableChannelOutputDriven(int channel);
+
+ /** Disable one of the channels.
+
+ This method can be used to tell the algorithm that the output from a
+ specific channel will not be used in subsequent operations, and the
+ implementation may choose to optimize and leave the disabled channel
+ unprocessed. However, the caller must always provide valid pointers for
+ the actual processing methods for the case where it's difficult to
+ actually disable memory access for the specific channel in an
+ implementation.
+
+ @note The channel index MUST be valid, i.e., it has to be smaller than
+ @c numChannels given at initialization time.
+
+ @param[in] channel The index of the channel to be enabled.
+ */
+
+ virtual void DisableChannelOutputDriven(int channel);
+
+ /** Query the scratch memory need of the converter.
+
+ This method queries the amount of scratch memory the input driven converter
+ needs to be able to handle in a single call to the processing functions.
+
+ @param[in] maxInputBlockSize Maximum input blocksize
+ @return memory need in bytes
+ */
+
+ virtual size_t ScratchMemoryNeedInputDriven(int maxInputBlockSize) const;
+
+ /** Set scratch buffer for the converter
+
+ This method sets scratch buffer needed by the converter when the converter is
+ used in output driven mode. . The caller of this function is responsible of
+ allocating enough memory.
+
+ @param[in] *buffer pointer to the allocated buffer
+ */
+
+ virtual void SetScratchBufferInputDriven(char *buffer);
+
+ /** Query the scratch memory need of the converter.
+
+ This method queries the amount of scratch memory the output driven converter
+ needs to be able to handle in a single call to the processing functions.
+
+ @param[in] maxOutputBlockSize Maximum output blocksize
+ @return memory need in bytes
+ */
+
+ virtual size_t ScratchMemoryNeedOutputDriven(int maxOutputBlockSize) const;
+
+ /** Set scratch buffer for the converter
+
+ This method sets scratch buffer needed by the converter when then converter is
+ used in output driven mode. The caller of this function is responsible of
+ allocating enough memory.
+
+ @param[in] *buffer pointer to the allocated buffer
+ */
+
+ virtual void SetScratchBufferOutputDriven(char *buffer);
+
+ /** Get the maximum number of input samples needed.
+
+ This method returns the maximum number of input samples needed
+ for a given output sample count.
+
+ @param[in] outSamples Number of output samples
+ @return Maximum number of input samples
+ */
+
+ virtual int MaxInputSampleCount(int outSamples) const;
+
+ /** Get the amount of samples needed for input.
+
+ This method returns the amount of samples needed for converter input
+ given the number of output samples. This method must be called before
+ each call to the processing methods. It is a serious error to have
+ \a outSamples greater than the value set with ScratchMemoryNeedOutputDriven().
+
+ @param[in] outSamples Amount of samples the converter produces
+ @return number of input samples needed
+ */
+
+ virtual int InSamplesNeeded(int outSamples);
+
+ /** Get the maximum number of output samples for a given input sample count
+
+ This method returns the maximum number of output samples the converter
+ can ever produce from a given number of input samples. The method assumes
+ that the converter be used either input-driven or output-driven; the
+ two modes should not be mixed.
+
+ @param[in] inSamples Number of input samples
+ @return Maximum number of output samples
+ */
+
+ virtual int MaxOutputSampleCount(int inSamples) const;
+
+ /** Run the sampling rate conversion for a block of samples
+
+ This method runs the actual sampling rate conversion. The pointer arrays
+ have to contain valid pointers for numChannels channel data buffers. The
+ output buffers must have space for MaxOutputSampleCount(inSamples) audio
+ samples.
+
+ @param[out] outputBuffers Pointer to output buffer array
+ @param[in] inputBuffers Pointer to input buffer array
+ @param[in] inSamples The number of input samples to process
+ @return Number of output samples
+ */
+
+ virtual int ProcessFromInput(int16 *outputBuffers[],
+ int16 *inputBuffers[],
+ int inSamples);
+
+ /** Run the sampling rate conversion for a block of samples
+
+ This method does the sampling rate conversion. The pointer arrays
+ have to contain valid pointers for numChannels channel data buffers.
+ The input buffers MUST contain the amount of samples returned by
+ a previous call to InSamplesNeeded. Output buffers must have space
+ for \a outSamples audio samples.
+
+ @param[out] outputBuffers Pointer to output buffer array
+ @param[in] inputBuffers Pointer to input buffer array
+ @param[in] outSamples The number of samples the converter produces
+ @return Number of output samples
+ */
+
+ virtual int ProcessToOutput(int16 *outputBuffers[],
+ int16 *inputBuffers[],
+ int outSamples);
+
+ //@}
+
+private:
+
+ /** Constructor
+ */
+
+ RESAMPLER_SincConv44To48Int16(int channelCount);
+
+ /** Disabled copy contructor
+ */
+ RESAMPLER_SincConv44To48Int16(const RESAMPLER_SincConv44To48Int16 &);
+
+ /** Initializes the converter.
+
+ This method initializes the sampling rate converter. The
+ initialization will be successful only if 3*inRate == outRate.
+
+ @return true if successful false otherwise
+ */
+
+ bool Init();
+
+ /** Deallocate all the allocated memory
+
+ This methods deallocates all memory previously allocated by
+ InitOutputDriven(). Can be used both for recovering from a memory
+ allocation error and in destructor.
+ */
+ void DeInit();
+
+ int16 **m_memBuffers;
+ int16 *m_scratchBuffer;
+ int m_channelCount;
+ int m_blockSize;
+ bool *m_channelEnabled;
+
+ int m_inputSamples;
+
+ int m_index1;
+ int m_index2;
+
+ int m_zeroCrossings;
+ const int16 *m_filterMatrix;
+};
+
+#endif // __RESAMPLER_SINC_CONV_44_TO_48_INT16_H__