[xiph-commits] r11890 - in trunk/oggdsf/src/lib/codecs:
speex/libs/libOOSpeex vorbis/filters/dsfVorbisEncoder
vorbis/libs/libOOVorbis
illiminable at svn.xiph.org
illiminable at svn.xiph.org
Sun Oct 8 06:04:24 PDT 2006
Author: illiminable
Date: 2006-10-08 06:04:12 -0700 (Sun, 08 Oct 2006)
New Revision: 11890
Added:
trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.cpp
trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.h
trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.cpp
trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.h
trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_preprocess_cdecl.h
Modified:
trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj
trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_cdecl.h
trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisEncoder/PropsVorbisEncoder.cpp
trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.cpp
trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.h
Log:
* Most of a new speex encoder abstraction
* Fix unititalised pointer in vorbis encoder property page
Added: trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.cpp 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.cpp 2006-10-08 13:04:12 UTC (rev 11890)
@@ -0,0 +1,120 @@
+#include "StdAfx.h"
+#include "SpeexEncodeSettings.h"
+
+SpeexEncodeSettings::SpeexEncodeSettings(void)
+ : mSampleRate(0)
+ , mNumChannels(0)
+ , mComplexity(3)
+ , mQuality(8)
+ , mBitrate(-1)
+ , mVBRMaxBitrate(-1)
+ , mFramesPerPacket(1)
+ , mBitrateControlMode(SPEEX_BITRATE_VBR_QUALITY)
+ , mEncodingMode(SPEEX_ENCODE_NO_MODE_SET)
+{
+}
+
+SpeexEncodeSettings::~SpeexEncodeSettings(void)
+{
+}
+
+bool SpeexEncodeSettings::setAudioParameters(unsigned long inSampleRate, unsigned long inNumChannels)
+{
+ if ( (inSampleRate >= 6000)
+ && (inSampleRate <= 48000)
+ && (inNumChannels > 0)
+ && (inNumChannels <= 2)) {
+
+ mSampleRate = inSampleRate;
+ mNumChannels = inNumChannels;
+ return true;
+ }
+ return false;
+
+}
+bool SpeexEncodeSettings::setMode(eSpeexEncodeMode inMode)
+{
+ if (inMode == SPEEX_ENCODE_NO_MODE_SET) {
+ if ((mSampleRate < 6000) || (mSampleRate > 48000)) {
+ return false;
+ } else if (mSampleRate > 25000) {
+ mEncodingMode = SPEEX_ENCODE_ULTRA_WIDEBAND;
+ } else if (mSampleRate > 12500) {
+ mEncodingMode = SPEEX_ENCODE_WIDEBAND;
+ } else {
+ mEncodingMode = SPEEX_ENCODE_NARROWBAND;
+ }
+ return true;
+ } else {
+ mEncodingMode = inMode;
+ return true;
+ }
+
+}
+bool SpeexEncodeSettings::setComplexity(long inComplexity)
+{
+ if ((inComplexity >= 0) && (inComplexity <= 10)) {
+ mComplexity = inComplexity;
+ return true;
+ }
+ return false;
+}
+
+bool SpeexEncodeSettings::setupVBRQualityMode(long inQuality, long inVBRMaxBitrate)
+{
+ if ( (inQuality >= 0)
+ && (inQuality <= 10)) {
+ mQuality = inQuality;
+ mVBRMaxBitrate = inVBRMaxBitrate;
+ mBitrateControlMode = SPEEX_BITRATE_VBR_QUALITY;
+ return true;
+ }
+ return false;
+}
+bool SpeexEncodeSettings::setupVBRBitrateMode(long inBitrate, long inVBRMaxBitrate)
+{
+ if (inBitrate > 0) {
+ mBitrate = inBitrate;
+ mVBRMaxBitrate = inVBRMaxBitrate;
+ mBitrateControlMode = SPEEX_BITRATE_VBR_BITRATE;
+ return true;
+ }
+ return false;
+}
+bool SpeexEncodeSettings::setupABR(long inABRBitrate)
+{
+ if (inABRBitrate > 0) {
+ mBitrate = inABRBitrate;
+ mBitrateControlMode = SPEEX_BITRATE_ABR;
+ return true;
+ }
+ return false;
+}
+bool SpeexEncodeSettings::setupCBRBitrateMode(long inCBRBitrate)
+{
+
+ if (inCBRBitrate > 0) {
+ mBitrate = inCBRBitrate;
+ mBitrateControlMode = SPEEX_BITRATE_CBR_BITRATE;
+ return true;
+ }
+ return false;
+}
+bool SpeexEncodeSettings::setupCBRQualityMode(long inQuality)
+{
+ if (inQuality > 0) {
+ mQuality = inQuality;
+ mBitrateControlMode = SPEEX_BITRATE_CBR_QUALITY;
+ return true;
+ }
+ return false;
+}
+
+bool SpeexEncodeSettings::setEncodingFlags(bool inUseDTX, bool inUseVAD, bool inUseAGC, bool inUseDenoise)
+{
+ mUsingDTX = inUseDTX;
+ mUsingVAD = inUseVAD;
+ mUsingAGC = inUseAGC;
+ mUsingDenoise = inUseDenoise;
+ return true;
+}
\ No newline at end of file
Added: trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.h 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncodeSettings.h 2006-10-08 13:04:12 UTC (rev 11890)
@@ -0,0 +1,73 @@
+#pragma once
+
+class SpeexEncodeSettings
+{
+public:
+ SpeexEncodeSettings(void);
+ ~SpeexEncodeSettings(void);
+
+ enum eSpeexEncodeMode {
+ SPEEX_ENCODE_NO_MODE_SET,
+ SPEEX_ENCODE_NARROWBAND,
+ SPEEX_ENCODE_WIDEBAND,
+ SPEEX_ENCODE_ULTRA_WIDEBAND,
+
+ };
+
+ enum eSpeexEncodeBitrateControl {
+ SPEEX_BITRATE_NO_BITRATE_CONTROL_SET,
+ SPEEX_BITRATE_VBR_QUALITY,
+ SPEEX_BITRATE_VBR_BITRATE,
+ SPEEX_BITRATE_ABR,
+ SPEEX_BITRATE_CBR_QUALITY,
+ SPEEX_BITRATE_CBR_BITRATE,
+ };
+
+ bool setAudioParameters(unsigned long inSampleRate, unsigned long inNumChannels);
+ bool setMode(eSpeexEncodeMode inMode);
+ bool setComplexity(long inComplexity);
+
+ bool setupVBRQualityMode(long inQuality, long inVBRMaxBitrate);
+ bool setupVBRBitrateMode(long inBitrate, long inVBRMaxBitrate);
+ bool setupABR(long inABRBitrate);
+ bool setupCBRBitrateMode(long inCBRBitrate);
+ bool setupCBRQualityMode(long inQuality);
+
+ bool setEncodingFlags(bool inUseDTX, bool inUseVAD, bool inUseAGC, bool inUseDenoise);
+
+ unsigned long sampleRate() { return mSampleRate; }
+ unsigned long numChannels() { return mNumChannels; }
+
+ long encodingComplexity() { return mComplexity; }
+ long quality() { return mQuality; }
+ long targetBitrate() { return mBitrate; }
+ long maxVBRBitrate() { return mVBRMaxBitrate; }
+ long framesPerPacket() { return mFramesPerPacket;}
+
+ eSpeexEncodeBitrateControl bitrateControlMode() { return mBitrateControlMode; }
+ eSpeexEncodeMode encodingMode() { return mEncodingMode; }
+
+ bool isUsingDTX() { return mUsingDTX; }
+ bool isUsingVAD() { return mUsingVAD; }
+ bool isUsingAGC() { return mUsingAGC; }
+ bool isUsingDenoise() { return mUsingDenoise; }
+
+private:
+ unsigned long mSampleRate;
+ unsigned long mNumChannels;
+
+ long mComplexity;
+ long mQuality;
+ long mBitrate;
+ long mVBRMaxBitrate;
+ long mFramesPerPacket; //??Meaningful?
+
+ eSpeexEncodeBitrateControl mBitrateControlMode;
+ eSpeexEncodeMode mEncodingMode;
+
+ bool mUsingDTX;
+ bool mUsingVAD;
+ bool mUsingAGC;
+ bool mUsingDenoise;
+
+};
Added: trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.cpp 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.cpp 2006-10-08 13:04:12 UTC (rev 11890)
@@ -0,0 +1,218 @@
+#include "StdAfx.h"
+#include "SpeexEncoder.h"
+
+SpeexEncoder::SpeexEncoder(void)
+ : mSpeexFrameSize(-1)
+ , mSpeexLookAhead(-1)
+ , mSampleWidth(16)
+ , mSpeexFrameCount(0)
+ , mLastGranulePos(0)
+ , mSpeexWorkingFrameBuffer(NULL)
+ , mSpeexWorkingFrameBufferUpto(0)
+ , mSpeexState(NULL)
+ , mSpeexPreprocessState(NULL)
+{
+}
+
+SpeexEncoder::~SpeexEncoder(void)
+{
+}
+
+string SpeexEncoder::getVendorString()
+{
+ char* locVersionBuf = NULL;
+ speex_encoder_ctl(mSpeexState, SPEEX_LIB_GET_VERSION_STRING, &locVersionBuf);
+ string locVersionString(locVersionBuf);
+ string retString = string("Encoded with Speex ") + locVersionString;
+ return retString;
+}
+vector<StampedOggPacket*> SpeexEncoder::setupCodec(SpeexEncodeSettings inSettings)
+{
+
+ if (inSettings.encodingMode() == SpeexEncodeSettings::SPEEX_ENCODE_NO_MODE_SET) {
+ return vector<StampedOggPacket*>();
+ }
+ const SpeexMode* locLibSpeexMode = speex_lib_get_mode(inSettings.encodingMode() - 1);
+ SpeexHeader locLibSpeexHeader;
+
+
+ speex_init_header(&locLibSpeexHeader, inSettings.sampleRate(), inSettings.numChannels(), locLibSpeexMode);
+ locLibSpeexHeader.frames_per_packet = inSettings.framesPerPacket();
+
+ if ( (inSettings.encodingMode() == SpeexEncodeSettings::SPEEX_BITRATE_VBR_BITRATE)
+ || (inSettings.encodingMode() == SpeexEncodeSettings::SPEEX_BITRATE_VBR_QUALITY)) {
+ locLibSpeexHeader.vbr = 1;
+ }
+
+ mSpeexState = speex_encoder_init(locLibSpeexMode);
+
+
+ long temp = inSettings.encodingComplexity();
+ speex_encoder_ctl(mSpeexState, SPEEX_GET_FRAME_SIZE, &mSpeexFrameSize);
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_COMPLEXITY, &temp);
+ temp = inSettings.sampleRate();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_SAMPLING_RATE, &temp);
+
+ long SPEEX_TRUE = 1;
+ long SPEEX_FALSE = 1;
+ switch (inSettings.bitrateControlMode()) {
+ case SpeexEncodeSettings::SPEEX_BITRATE_ABR:
+ temp = inSettings.targetBitrate();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_ABR, &temp);
+
+ break;
+ case SpeexEncodeSettings::SPEEX_BITRATE_CBR_BITRATE:
+ temp = inSettings.targetBitrate();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_BITRATE, &temp);
+ break;
+ case SpeexEncodeSettings::SPEEX_BITRATE_CBR_QUALITY:
+ temp = inSettings.quality();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_QUALITY, &temp);
+ break;
+ case SpeexEncodeSettings::SPEEX_BITRATE_VBR_BITRATE:
+ temp = inSettings.maxVBRBitrate();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_VBR_MAX_BITRATE, &temp);
+ temp = inSettings.targetBitrate();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_BITRATE, &temp);
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_VBR, &SPEEX_TRUE);
+ break;
+ case SpeexEncodeSettings::SPEEX_BITRATE_VBR_QUALITY:
+ temp = inSettings.maxVBRBitrate();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_VBR_MAX_BITRATE, &temp);
+ temp = inSettings.quality();
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_QUALITY, &temp);
+ break;
+ default:
+ return vector<StampedOggPacket*>();
+ break;
+
+ };
+
+ if (inSettings.isUsingVAD()) {
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_VAD, &SPEEX_TRUE);
+ }
+
+ if (inSettings.isUsingDTX()) {
+ speex_encoder_ctl(mSpeexState, SPEEX_SET_DTX, &SPEEX_TRUE);
+ }
+
+ speex_encoder_ctl(mSpeexState, SPEEX_GET_LOOKAHEAD, &mSpeexLookAhead);
+
+ if (inSettings.isUsingAGC() || inSettings.isUsingDenoise()) {
+ //Using the speex pre-processor
+ mSpeexPreprocessState = speex_preprocess_state_init(mSpeexFrameSize, inSettings.sampleRate());
+
+ speex_encoder_ctl(mSpeexState, SPEEX_PREPROCESS_SET_AGC, inSettings.isUsingAGC() ? &SPEEX_TRUE
+ : &SPEEX_FALSE);
+ speex_encoder_ctl(mSpeexState, SPEEX_PREPROCESS_SET_DENOISE, inSettings.isUsingDenoise() ? &SPEEX_TRUE
+ : &SPEEX_FALSE);
+ mSpeexLookAhead += mSpeexFrameSize;
+ } else {
+ //Not using pre-processing
+ mSpeexPreprocessState = NULL;
+ }
+
+
+ mSpeexWorkingFrameBuffer = new unsigned char[mSpeexFrameSize * inSettings.numChannels() * (mSampleWidth >> 3)];
+ mSpeexWorkingFrameBufferUpto = 0;
+
+
+ mSettings = inSettings;
+
+ int locHeaderPacketSize = 0;
+
+ //Make the header packet
+ vector<StampedOggPacket*> retPacketList;
+ unsigned char* locSpeexHeaderBuffer = (unsigned char*)speex_header_to_packet(&locLibSpeexHeader, &locHeaderPacketSize);
+
+ //Put it ina new'd buffer so it can be deleted properly
+ unsigned char* locHeaderBuffer = new unsigned char[locHeaderPacketSize];
+ memcpy((void*)locHeaderBuffer, (const void*)locSpeexHeaderBuffer, locHeaderPacketSize);
+ free(locSpeexHeaderBuffer);
+ locSpeexHeaderBuffer = NULL;
+
+
+ StampedOggPacket* locHeaderPacket = new StampedOggPacket(locHeaderBuffer, locHeaderPacketSize, false, false, 0, 0, StampedOggPacket::OGG_BOTH);
+ retPacketList.push_back(locHeaderPacket);
+ locHeaderPacket = NULL;
+
+ //Comment packet
+ string locVendorString = getVendorString();
+ //8 is 4 for the length of the vendor string, and 4 for the number of user comments
+ // of which there will be zero.
+
+ long locCommentHeaderSize = locVendorString.size() + 8;
+ unsigned char* locCommentBuffer = new unsigned char[locCommentHeaderSize];
+ *((int*)locCommentBuffer) = locVendorString.size();
+ memcpy((void*)(locCommentBuffer + 4), (const void*)locVendorString.c_str(), locVendorString.size());
+ *((int*)(locCommentBuffer + 4 + locVendorString.size())) = 0;
+ StampedOggPacket* locCommentPacket = new StampedOggPacket(locCommentBuffer, locCommentHeaderSize, false, false, 0, 0, StampedOggPacket::OGG_BOTH);
+ retPacketList.push_back(locCommentPacket);
+
+
+ speex_bits_init(&mSpeexBits);
+ return retPacketList;
+
+}
+
+vector<StampedOggPacket*> SpeexEncoder::encode(const short* const inSampleBuffer, unsigned long inNumSamplesPerChannel)
+{
+ assert(mSampleWidth == 16);
+
+ vector<StampedOggPacket*> retPacketList;
+ const unsigned char* locUptoSamplePointer = (const unsigned char*)inSampleBuffer;
+ long locSamplesLeft = inNumSamplesPerChannel;
+ long locSamplesToCopy;
+ long locBytesToCopy;
+ long locBytesPerSample = mSettings.numChannels() * (mSampleWidth >> 3);
+
+ while (locSamplesLeft > 0) {
+
+ locSamplesToCopy = mSpeexFrameSize - mSpeexWorkingFrameBufferUpto;
+ locSamplesToCopy = (locSamplesToCopy > locSamplesLeft) ? locSamplesLeft : locSamplesToCopy;
+ locBytesToCopy = locSamplesToCopy * locBytesPerSample;
+ locSamplesLeft -= locSamplesToCopy;
+
+ memcpy((void*)(mSpeexWorkingFrameBuffer + (mSpeexWorkingFrameBufferUpto * locBytesPerSample)), (const void*)locUptoSamplePointer, locBytesToCopy);
+ locUptoSamplePointer += locBytesToCopy;
+ mSpeexWorkingFrameBufferUpto += locSamplesToCopy;
+
+ assert(mSpeexWorkingFrameBufferUpto <= mSpeexFrameSize);
+ if (mSpeexWorkingFrameBufferUpto == mSpeexFrameSize) {
+ //Got a full frame.
+
+ if (mSettings.numChannels() == 2) {
+ speex_encode_stereo_int((short*)mSpeexWorkingFrameBuffer, mSpeexFrameSize, &mSpeexBits);
+ }
+
+ if (mSpeexPreprocessState != NULL) {
+ speex_preprocess(mSpeexPreprocessState, (short*)mSpeexWorkingFrameBuffer, NULL);
+ }
+
+ speex_encode_int(mSpeexState, (short*)mSpeexWorkingFrameBuffer, &mSpeexBits);
+
+ mSpeexWorkingFrameBufferUpto = 0;
+
+ mSpeexFrameCount++;
+
+ if ((mSpeexFrameCount % mSettings.framesPerPacket()) != 0) {
+ //Put more in this packet
+ continue;
+ } else {
+ //This packet is ready to go
+ unsigned long locPacketSize = speex_bits_nbytes(&mSpeexBits);
+ unsigned char* locPacketBuffer = new unsigned char[locPacketSize];
+
+ speex_bits_write(&mSpeexBits, (char*)locPacketBuffer, MAX_FRAME_BYTES);
+ speex_bits_reset(&mSpeexBits);
+ LOOG_INT64 locGranulePos = (mSpeexFrameCount * mSpeexFrameSize) - mSpeexLookAhead;
+ StampedOggPacket* locPacket = new StampedOggPacket(locPacketBuffer, locPacketSize, false, false, mLastGranulePos, locGranulePos, StampedOggPacket::OGG_BOTH);
+ mLastGranulePos = locGranulePos;
+ retPacketList.push_back(locPacket);
+ }
+ }
+
+ }
+
+ return retPacketList;
+}
Added: trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.h 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/SpeexEncoder.h 2006-10-08 13:04:12 UTC (rev 11890)
@@ -0,0 +1,68 @@
+#pragma once
+
+#include <libOOOgg/dllstuff.h>
+#include <libOOOgg/StampedOggPacket.h>
+
+#include "SpeexEncodeSettings.h"
+
+
+extern "C" {
+//#include "speex/speex.h"
+#include "speex_cdecl.h"
+
+//#include "speex/speex_header.h"
+#include "speex_header_cdecl.h"
+
+//#include "speex/speex_callbacks.h"
+//#include "speex_callbacks_cdecl.h"
+
+//#include "speex/speex_stereo.h"
+#include "speex_stereo_cdecl.h"
+
+//#include "speex/speex_preprocess.h"
+#include "speex_preprocess_cdecl.h"
+
+
+
+}
+
+#include <vector>
+#include <string>
+
+#include <assert.h>
+
+using namespace std;
+
+class SpeexEncoder
+{
+public:
+ SpeexEncoder(void);
+ ~SpeexEncoder(void);
+
+ vector<StampedOggPacket*> setupCodec(SpeexEncodeSettings inSettings);
+ vector<StampedOggPacket*> encode(const short* const inSampleBuffer, unsigned long inNumSamplesPerChannel);
+ vector<StampedOggPacket*> flush(); //Needed?
+
+
+ string getVendorString();
+
+private:
+ static const unsigned long MAX_FRAME_BYTES = 2000;
+ SpeexEncodeSettings mSettings;
+
+
+ long mSpeexFrameSize;
+ long mSpeexLookAhead;
+ long mSampleWidth;
+ unsigned long mSpeexFrameCount;
+ LOOG_INT64 mLastGranulePos;
+
+ unsigned char* mSpeexWorkingFrameBuffer;
+ unsigned long mSpeexWorkingFrameBufferUpto;
+ void* mSpeexState;
+ SpeexPreprocessState* mSpeexPreprocessState;
+ SpeexBits mSpeexBits;
+
+
+
+};
Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj 2006-10-08 13:04:12 UTC (rev 11890)
@@ -209,11 +209,12 @@
/>
</Configuration>
<Configuration
- Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
- OutputDirectory="$(SolutionDir)Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
- IntermediateDirectory="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
+ Name="Release_WM5_PPC_ARM|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -229,19 +230,17 @@
/>
<Tool
Name="VCMIDLTool"
- TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\core\ogg;..\..\..\..\helper;..\libspeex\include"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
- MinimalRebuild="true"
- RuntimeLibrary="3"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="4"
- DebugInformationFormat="4"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -265,27 +264,18 @@
Name="VCBscMakeTool"
/>
<Tool
- Name="VCCodeSignTool"
+ Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
</Configuration>
<Configuration
- Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
OutputDirectory="$(SolutionDir)Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
IntermediateDirectory="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
- WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -306,12 +296,14 @@
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
+ Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\core\ogg;..\..\..\..\helper;..\libspeex\include"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
- RuntimeLibrary="2"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="4"
- DebugInformationFormat="3"
+ DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -350,11 +342,12 @@
/>
</Configuration>
<Configuration
- Name="Debug_WM5_PPC_ARM|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
OutputDirectory="$(SolutionDir)Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
IntermediateDirectory="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -375,14 +368,12 @@
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
- Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\core\ogg;..\..\..\..\helper;..\libspeex\include"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;$(ARCHFAM);$(_ARCHFAM_)"
- MinimalRebuild="true"
- RuntimeLibrary="3"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="4"
- DebugInformationFormat="0"
+ DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -421,12 +412,11 @@
/>
</Configuration>
<Configuration
- Name="Release_WM5_PPC_ARM|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Debug_WM5_PPC_ARM|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ OutputDirectory="$(SolutionDir)Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
+ IntermediateDirectory="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
- WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -442,17 +432,19 @@
/>
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
+ ExecutionBucket="7"
+ Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\core\ogg;..\..\..\..\helper;..\libspeex\include"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
- RuntimeLibrary="2"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;$(ARCHFAM);$(_ARCHFAM_)"
+ MinimalRebuild="true"
+ RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="4"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- CallingConvention="2"
+ DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -476,11 +468,19 @@
Name="VCBscMakeTool"
/>
<Tool
- Name="VCFxCopTool"
+ Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
</Configuration>
<Configuration
Name="Release_WM5_PPC_ARM|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
@@ -570,6 +570,14 @@
>
</File>
<File
+ RelativePath=".\SpeexEncoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\SpeexEncodeSettings.cpp"
+ >
+ </File>
+ <File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
@@ -597,7 +605,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ Name="Release_WM5_PPC_ARM|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -605,7 +613,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
>
<Tool
Name="VCCLCompilerTool"
@@ -613,7 +621,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug_WM5_PPC_ARM|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
>
<Tool
Name="VCCLCompilerTool"
@@ -621,7 +629,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release_WM5_PPC_ARM|Win32"
+ Name="Debug_WM5_PPC_ARM|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
>
<Tool
Name="VCCLCompilerTool"
@@ -660,6 +668,10 @@
>
</File>
<File
+ RelativePath=".\speex_preprocess_cdecl.h"
+ >
+ </File>
+ <File
RelativePath=".\speex_stereo_cdecl.h"
>
</File>
@@ -672,6 +684,14 @@
>
</File>
<File
+ RelativePath=".\SpeexEncoder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\SpeexEncodeSettings.h"
+ >
+ </File>
+ <File
RelativePath=".\stdafx.h"
>
</File>
Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_cdecl.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_cdecl.h 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_cdecl.h 2006-10-08 13:04:12 UTC (rev 11890)
@@ -158,7 +158,17 @@
/** Gets tuning for PLC */
#define SPEEX_GET_PLC_TUNING 41
-/* Used internally, not to be used in applications */
+/** Sets the max bit-rate allowed in VBR mode */
+#define SPEEX_SET_VBR_MAX_BITRATE 42
+/** Gets the max bit-rate allowed in VBR mode */
+#define SPEEX_GET_VBR_MAX_BITRATE 43
+
+/** Turn on/off input/output high-pass filtering */
+#define SPEEX_SET_HIGHPASS 44
+/** Get status of input/output high-pass filtering */
+#define SPEEX_GET_HIGHPASS 45
+
+/* Used internally, NOT TO BE USED in applications */
/** Used internally*/
#define SPEEX_GET_PI_GAIN 100
/** Used internally*/
@@ -169,6 +179,8 @@
#define SPEEX_GET_DTX_STATUS 103
/** Used internally*/
#define SPEEX_SET_INNOVATION_SAVE 104
+/** Used internally*/
+#define SPEEX_SET_WIDEBAND 105
/* Preserving compatibility:*/
Added: trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_preprocess_cdecl.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_preprocess_cdecl.h 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libOOSpeex/speex_preprocess_cdecl.h 2006-10-08 13:04:12 UTC (rev 11890)
@@ -0,0 +1,177 @@
+/* Copyright (C) 2003 Epic Games
+ Written by Jean-Marc Valin */
+/**
+ @file speex_preprocess.h
+ @brief Speex preprocessor
+*/
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef SPEEX_PREPROCESS_H
+#define SPEEX_PREPROCESS_H
+
+#ifdef WIN32
+#define CALL_CONV __cdecl
+#else
+#define CALL_CONV
+#endif
+
+#include "speex/speex_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct drft_lookup;
+
+/** Speex pre-processor state. */
+typedef struct SpeexPreprocessState {
+ int frame_size; /**< Number of samples processed each time */
+ int ps_size; /**< Number of points in the power spectrum */
+ int sampling_rate; /**< Sampling rate of the input/output */
+
+ /* parameters */
+ int denoise_enabled;
+ int agc_enabled;
+ float agc_level;
+ int vad_enabled;
+ int dereverb_enabled;
+ float reverb_decay;
+ float reverb_level;
+ float speech_prob_start;
+ float speech_prob_continue;
+
+ float *frame; /**< Processing frame (2*ps_size) */
+ float *ps; /**< Current power spectrum */
+ float *gain2; /**< Adjusted gains */
+ float *window; /**< Analysis/Synthesis window */
+ float *noise; /**< Noise estimate */
+ float *reverb_estimate; /**< Estimate of reverb energy */
+ float *old_ps; /**< Power spectrum for last frame */
+ float *gain; /**< Ephraim Malah gain */
+ float *prior; /**< A-priori SNR */
+ float *post; /**< A-posteriori SNR */
+
+ float *S; /**< Smoothed power spectrum */
+ float *Smin; /**< See Cohen paper */
+ float *Stmp; /**< See Cohen paper */
+ float *update_prob; /**< Propability of speech presence for noise update */
+
+ float *zeta; /**< Smoothed a priori SNR */
+ float Zpeak;
+ float Zlast;
+
+ float *loudness_weight; /**< Perceptual loudness curve */
+
+ float *echo_noise;
+
+ float *noise_bands;
+ float *noise_bands2;
+ int noise_bandsN;
+ float *speech_bands;
+ float *speech_bands2;
+ int speech_bandsN;
+
+ float *inbuf; /**< Input buffer (overlapped analysis) */
+ float *outbuf; /**< Output buffer (for overlap and add) */
+
+ float speech_prob;
+ int last_speech;
+ float loudness; /**< loudness estimate */
+ float loudness2; /**< loudness estimate */
+ int nb_adapt; /**< Number of frames used for adaptation so far */
+ int nb_loudness_adapt; /**< Number of frames used for loudness adaptation so far */
+ int consec_noise; /**< Number of consecutive noise frames */
+ int nb_preprocess; /**< Number of frames processed so far */
+ struct drft_lookup *fft_lookup; /**< Lookup table for the FFT */
+
+} SpeexPreprocessState;
+
+/** Creates a new preprocessing state */
+SpeexPreprocessState* CALL_CONV speex_preprocess_state_init(int frame_size, int sampling_rate);
+
+/** Destroys a denoising state */
+void CALL_CONV speex_preprocess_state_destroy(SpeexPreprocessState *st);
+
+/** Preprocess a frame */
+int CALL_CONV speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo);
+
+/** Preprocess a frame */
+void CALL_CONV speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo);
+
+/** Used like the ioctl function to control the preprocessor parameters */
+int CALL_CONV speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr);
+
+
+
+/** Set preprocessor denoiser state */
+#define SPEEX_PREPROCESS_SET_DENOISE 0
+/** Get preprocessor denoiser state */
+#define SPEEX_PREPROCESS_GET_DENOISE 1
+
+/** Set preprocessor Automatic Gain Control state */
+#define SPEEX_PREPROCESS_SET_AGC 2
+/** Get preprocessor Automatic Gain Control state */
+#define SPEEX_PREPROCESS_GET_AGC 3
+
+/** Set preprocessor Voice Activity Detection state */
+#define SPEEX_PREPROCESS_SET_VAD 4
+/** Get preprocessor Voice Activity Detection state */
+#define SPEEX_PREPROCESS_GET_VAD 5
+
+/** Set preprocessor Automatic Gain Control level */
+#define SPEEX_PREPROCESS_SET_AGC_LEVEL 6
+/** Get preprocessor Automatic Gain Control level */
+#define SPEEX_PREPROCESS_GET_AGC_LEVEL 7
+
+/** Set preprocessor dereverb state */
+#define SPEEX_PREPROCESS_SET_DEREVERB 8
+/** Get preprocessor dereverb state */
+#define SPEEX_PREPROCESS_GET_DEREVERB 9
+
+/** Set preprocessor dereverb level */
+#define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10
+/** Get preprocessor dereverb level */
+#define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11
+
+/** Set preprocessor dereverb decay */
+#define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12
+/** Get preprocessor dereverb decay */
+#define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13
+
+#define SPEEX_PREPROCESS_SET_PROB_START 14
+#define SPEEX_PREPROCESS_GET_PROB_START 15
+
+#define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16
+#define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Modified: trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisEncoder/PropsVorbisEncoder.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisEncoder/PropsVorbisEncoder.cpp 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/vorbis/filters/dsfVorbisEncoder/PropsVorbisEncoder.cpp 2006-10-08 13:04:12 UTC (rev 11890)
@@ -7,6 +7,7 @@
, inUnk
, IDD_VORBIS_ENCODE_SETTINGS
, IDS_VORBIS_ENC_PROPS_STRING)
+ , mVorbisEncodeSettings(NULL)
{
}
Modified: trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.cpp 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.cpp 2006-10-08 13:04:12 UTC (rev 11890)
@@ -49,13 +49,9 @@
vorbis_info_init(&mVorbisInfo);
vorbis_comment_init(&mVorbisComment);
//TODO::: Add version/encoder info here?
-
//TODO::: Allow max and min in unmanaged mode
//TODO::: Allow advanced bitrate management
-
-
-
if (mSettings.mIsQualitySet) {
ret = vorbis_encode_setup_vbr(&mVorbisInfo, mSettings.mNumChannels, mSettings.mSampleRate, (float)inSettings.mQuality / 100.0f);
if (ret != 0) {
@@ -68,8 +64,6 @@
vorbis_info_clear(&mVorbisInfo);
return retPackets;
}
-
-
}
if (!mSettings.mIsManaged) {
@@ -93,10 +87,6 @@
retPackets.push_back(oldToNewPacket(&locCodebookHeader));
return retPackets;
-
-
-
-
}
StampedOggPacket* VorbisEncoder::oldToNewPacket(ogg_packet* inOldPacket)
@@ -115,18 +105,12 @@
vector<StampedOggPacket*> VorbisEncoder::encodeVorbis(const short* const inSampleBuffer, unsigned long inNumSamplesPerChannel)
{
-
- //Check if active?
- //Is it worth breaking up incoming buffers? Probably not.
//TODO::: Handle 5 channel input
-
-
if (inNumSamplesPerChannel == 0) {
return vector<StampedOggPacket*>();
}
- //Check if this is correct with the last parameter, i think its samples per channel?
float** locBuffer = vorbis_analysis_buffer(&mVorbisDSPState, inNumSamplesPerChannel);
float* locOneOutputChannelBuffer = NULL;
@@ -134,6 +118,7 @@
for (unsigned long chan = 0; chan < mSettings.mNumChannels; chan++) {
locOneOutputChannelBuffer = locBuffer[chan];
locReadChannelBuffer = inSampleBuffer + chan;
+
for (unsigned long sam = 0; sam < inNumSamplesPerChannel; sam++) {
locOneOutputChannelBuffer[sam] = ((float)(*locReadChannelBuffer)) / 32768.0f;
locReadChannelBuffer += mSettings.mNumChannels;
@@ -148,9 +133,7 @@
vector<StampedOggPacket*> VorbisEncoder::flush()
{
vorbis_analysis_wrote(&mVorbisDSPState, 0);
-
return extractOutputPackets();
-
}
vector<StampedOggPacket*> VorbisEncoder::extractOutputPackets()
@@ -159,7 +142,6 @@
ogg_packet locWorkingPacket;
while (vorbis_analysis_blockout(&mVorbisDSPState, &mVorbisBlock) == 1) {
-
vorbis_analysis(&mVorbisBlock, NULL);
vorbis_bitrate_addblock(&mVorbisBlock);
Modified: trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.h 2006-10-06 13:29:12 UTC (rev 11889)
+++ trunk/oggdsf/src/lib/codecs/vorbis/libs/libOOVorbis/VorbisEncoder.h 2006-10-08 13:04:12 UTC (rev 11890)
@@ -52,7 +52,6 @@
static const unsigned long NUM_VORBIS_HEADERS = 3;
-
vector<StampedOggPacket*> setupCodec(VorbisEncodeSettings inSettings);
vector<StampedOggPacket*> encodeVorbis(const short* const inSampleBuffer, unsigned long inNumSamplesPerChannel);
vector<StampedOggPacket*> flush();
More information about the commits
mailing list