videoeditorengine/audioeditorengine/inc/RateConverter.h
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __CRateConverter_H__
       
    22 #define __CRateConverter_H__
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "resampler_rate_conversion_input_driven_int16.h"
       
    27 
       
    28 class CRateConverter : public CBase
       
    29     {
       
    30 
       
    31 public:
       
    32     
       
    33     /*
       
    34     * Symbian constructors
       
    35     *
       
    36     */
       
    37     static CRateConverter* NewL(TInt aFromSampleRate, TInt aToSampleRate, TInt aFromChannels, TInt aToChannels);
       
    38                                         
       
    39     static CRateConverter* NewLC(TInt aFromSampleRate, TInt aToSampleRate, TInt aFromChannels, TInt aToChannels);
       
    40 
       
    41     /*
       
    42     * Destructor
       
    43     */
       
    44     ~CRateConverter();
       
    45     
       
    46     /*
       
    47     * Initialize the rate converter
       
    48     *
       
    49     * @param aInputBufferSize Max size of the input buffer in number of samples
       
    50     * @return ETrue if successful
       
    51     *
       
    52     */
       
    53     TBool InitL(TInt aInputBufferSize);
       
    54 
       
    55     /*
       
    56     * Does rate and channel conversion for given buffer
       
    57     *
       
    58     * @param aInput Pointer to input buffer (16-bit samples)
       
    59     * @param aOutput Pointer to output buffer (16-bit samples)
       
    60     * @param aInputSampleCount Number of samples in the input buffer
       
    61     * @return Number of samples in the output buffer
       
    62     */
       
    63     TInt ConvertBufferL(TInt16* aInput, TInt16* aOutput, TInt aInputSampleCount);  
       
    64     
       
    65     /*
       
    66     * Returns the size of the output buffer
       
    67     *
       
    68     */
       
    69     TInt GetOutputBufferSize() { return iOuputBlockSize; }
       
    70     
       
    71 
       
    72 protected:
       
    73     
       
    74     // constructL    
       
    75     void ConstructL();
       
    76     
       
    77     // C++ constructor
       
    78     CRateConverter(TInt aFromSampleRate, TInt aToSampleRate, TInt aFromChannels, TInt aToChannels);
       
    79     
       
    80 private:
       
    81     
       
    82     /*
       
    83     * Does internal initialization
       
    84     *
       
    85     */
       
    86     TBool DoInitL(TInt aInputBufferSize);
       
    87     
       
    88     /*
       
    89     * Does the actual conversion
       
    90     *
       
    91     */
       
    92     TInt DoConvertL(TInt16** aInput, TInt aInputSampleCount);
       
    93     
       
    94     /*
       
    95     * Returns pointer to the output buffer
       
    96     *
       
    97     */
       
    98     TInt16** GetOutputBuffer() { return iOutBuffer; }
       
    99           
       
   100 private:
       
   101 
       
   102     // Another converter incase two phase converting is needed
       
   103     CRateConverter* iChild;
       
   104 
       
   105     // The actual converter
       
   106     RESAMPLER_RateConversionInputDrivenInt16* iConverter;
       
   107     
       
   108     // Input data for rate converter
       
   109     TInt16** iInBuffer;
       
   110     
       
   111     // Output data from rate converter
       
   112     TInt16** iOutBuffer;
       
   113     
       
   114     // Temp buffer used by converter
       
   115     TInt8* iScratchBuffer;
       
   116 
       
   117     // Size of the input buffer
       
   118     TInt iInputBlockSize;
       
   119     
       
   120     // Size of the output buffer
       
   121     TInt iOuputBlockSize;
       
   122     
       
   123     // Number of channels used in converter
       
   124     TInt iChannels;
       
   125 
       
   126     // Samplerate to convert from
       
   127     TInt iFromSampleRate;
       
   128     
       
   129     // Samplerate to convert to
       
   130     TInt iToSampleRate;
       
   131     
       
   132     // Number of channels in input
       
   133     TInt iFromChannels;
       
   134     
       
   135     // Number of channels in output
       
   136     TInt iToChannels;
       
   137     };
       
   138 
       
   139 #endif