AudRecordLib
Namespaces | Defines | Functions
convert.cpp File Reference

Implements the SSE sample conversion functions and the other non template conversion related functions. This file has the stack checking switch (/GS) turned off, as for some reason VS wants to include one in all the SSE functions, none of which use any stack space. More...

#include "stdafx.h"
#include "convert.h"
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <mmreg.h>

Namespaces

namespace  detail
namespace  detail::SSE

Defines

#define X_TO_Y_CHANNEL_Z_HELPER(X, Y, Z)
#define DEFINE_DETERMINE_PCM_CHANNEL_X_HELPER(X)
#define DEFINE_DETERMINE_FLOAT_CHANNEL_X_HELPER(X)

Functions

FORCEINLINE void detail::SSE::StoreConvertedSamples (short *pDstSamples, const __m128 &samples)
FORCEINLINE void detail::SSE::StoreConvertedSamples (long *pDstSamples, const __m128 &samples)
FORCEINLINE __m128i detail::SSE::LongShortToShorts (__m128 &samples)
FORCEINLINE void detail::SSE::StoreConvertedSamples (short *&pDstSamples, __m128 samples[4])
FORCEINLINE void detail::SSE::StoreConvertedSamples (long *&pDstSamples, __m128 samples[4])
FORCEINLINE void detail::SSE::Get16ConvertedSamples (const float *&pSrcSamples, __m128 samplePacks[4], const __m128 &scaleFactors)
DWORD detail::ConvertCopy (LPCVOID pSrcArray, DWORD numFrames, PVOID pDstArray, WORD sampleSize, WORD numChannels)
 detail::DEFINE_DETERMINE_PCM_CHANNEL_X_HELPER (Up)
 detail::DEFINE_DETERMINE_PCM_CHANNEL_X_HELPER (Down)
 detail::DEFINE_DETERMINE_PCM_CHANNEL_X_HELPER (Equal)
 detail::DEFINE_DETERMINE_FLOAT_CHANNEL_X_HELPER (Up)
 detail::DEFINE_DETERMINE_FLOAT_CHANNEL_X_HELPER (Down)
 detail::DEFINE_DETERMINE_FLOAT_CHANNEL_X_HELPER (Equal)
void DetermineSampleConverter (const tWAVEFORMATEX &inp, const tWAVEFORMATEX &out, ConverterFnPtr &converter)

Detailed Description

Implements the SSE sample conversion functions and the other non template conversion related functions. This file has the stack checking switch (/GS) turned off, as for some reason VS wants to include one in all the SSE functions, none of which use any stack space.


Define Documentation

#define DEFINE_DETERMINE_FLOAT_CHANNEL_X_HELPER (   X)
Value:
static void DetermineFloatChannel##X##Helper(const WAVEFORMATEX& inp, const WAVEFORMATEX& out, ConverterFnPtr& converter) \
        { \
                ASSERT(inp.wBitsPerSample == 32); \
                if(out.wBitsPerSample == 32) \
                { \
                        X_TO_Y_CHANNEL_Z_HELPER(float, long, X); \
                } \
                else if(out.wBitsPerSample == 16) \
                { \
                        X_TO_Y_CHANNEL_Z_HELPER(float, short, X); \
                } \
                else \
                { \
                        ASSERT(out.wBitsPerSample == 8); \
                        X_TO_Y_CHANNEL_Z_HELPER(float, char, X); \
                } \
        }

Defines the implementation of the determination function for float->integer conversions. X is the channel conversion type, (either Up, Down, or Equal). This parameter is passed unchanged to X_TO_Y_CHANNEL_Z_HELPER as the Z parameter.

#define DEFINE_DETERMINE_PCM_CHANNEL_X_HELPER (   X)

Defines the implementation of the determination function for integer->integer conversions. X is the channel conversion type, (either Up, Down, or Equal). This parameter is passed unchanged to X_TO_Y_CHANNEL_Z_HELPER as the Z parameter.

#define X_TO_Y_CHANNEL_Z_HELPER (   X,
  Y,
 
)
Value:
converter = boost::bind( \
                &detail::ConvertChannel##Z##<X, Y>, \
                _1, \
                _2, \
                _3, \
                inp.nChannels, \
                out.nChannels \
        );

Defines a three argument function object to assign as the sample conversion function. X and Y are the source and destination C++ sample types respectively. Z can be Up, Down, or Equal to select the desired channel conversion function from source to dest


Function Documentation

void DetermineSampleConverter ( const tWAVEFORMATEX &  inp,
const tWAVEFORMATEX &  out,
ConverterFnPtr converter 
)

Determines the correct function that'll convert between the sample types

Picks a suitable function and template parameters that'll change samples from the input wave format to the output wave format.

Parameters:
inpThe input wave format, that from the audio mixing device
outThe output wave format, that to feed to the codec
[out]converterOn output, the function object that'll call the actual Convert* function when called
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Defines