[xiph-commits] r11195 - branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex

illiminable at svn.xiph.org illiminable at svn.xiph.org
Thu Apr 20 16:36:06 PDT 2006


Author: illiminable
Date: 2006-04-20 16:35:56 -0700 (Thu, 20 Apr 2006)
New Revision: 11195

Added:
   branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.cpp
   branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.h
Modified:
   branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp
   branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h
   branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj
Log:
* Add decoder settings to oospeex

Added: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.cpp	2006-04-20 22:50:21 UTC (rev 11194)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.cpp	2006-04-20 23:35:56 UTC (rev 11195)
@@ -0,0 +1,31 @@
+#include "StdAfx.h"
+#include "SpeexDecodeSettings.h"
+
+SpeexDecodeSettings::SpeexDecodeSettings(void)
+	:	mForceSampleRate(0)
+	,	mForceChannels(SPEEX_CHANNEL_LEAVE_ALONE)
+	,	mForceBand(SPEEX_BAND_LEAVE_ALONE)
+	,	mPerceptualEnhancement(true)
+{
+}
+
+SpeexDecodeSettings::~SpeexDecodeSettings(void)
+{
+}
+
+bool SpeexDecodeSettings::set(		int inSampleRate
+								,	eChannelForce inChannels
+								,	eBandForce inBand
+								,	bool inPercEnh)
+{
+	if ((inSampleRate >= 0) && (inChannels == SPEEX_BAND_LEAVE_ALONE)) {
+		mForceSampleRate = inSampleRate;
+	}
+
+	mForceChannels = inChannels;
+	mForceBand = inBand;
+	mPerceptualEnhancement = inPercEnh;
+
+	return true;
+
+}
\ No newline at end of file

Added: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.h	2006-04-20 22:50:21 UTC (rev 11194)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecodeSettings.h	2006-04-20 23:35:56 UTC (rev 11195)
@@ -0,0 +1,34 @@
+#pragma once
+
+
+
+class SpeexDecodeSettings
+{
+public:
+
+	enum eChannelForce {
+		SPEEX_CHANNEL_LEAVE_ALONE = 0,
+		SPEEX_CHANNEL_FORCE_MONO,
+		SPEEX_CHANNEL_FORCE_STEREO
+
+	};
+
+	enum eBandForce {
+		SPEEX_BAND_LEAVE_ALONE = 0,
+		SPEEX_BAND_FORCE_NARROWBAND,
+		SPEEX_BAND_FORCE_WIDEBAND,
+		SPEEX_BAND_FORCE_ULTRAWIDEBAND
+	};
+
+	friend class SpeexDecoder;
+	SpeexDecodeSettings(void);
+	~SpeexDecodeSettings(void);
+
+	bool set(int inSampleRate, eChannelForce inChannels, eBandForce inBand, bool inPercEnh);
+private:
+	int mForceSampleRate;
+	eChannelForce mForceChannels;
+	eBandForce mForceBand;
+	bool mPerceptualEnhancement;
+
+};

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp	2006-04-20 22:50:21 UTC (rev 11194)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp	2006-04-20 23:35:56 UTC (rev 11195)
@@ -8,6 +8,7 @@
 	,	mSampleRate(0)
 	,	mNumFrames(0)
 	,	mNumExtraHeaders(0)
+	,	mIsVBR(false)
 	,	mSpeexState(NULL)
 	,	mStereoState(NULL)
 {
@@ -17,6 +18,15 @@
 {
 }
 
+bool SpeexDecoder::setDecodeParams(SpeexDecodeSettings inSettings)
+{
+	if (mPacketCount == 0) {
+		mDecoderSettings = inSettings;
+		return true;
+	}
+	return false;
+}
+
 bool SpeexDecoder::decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize)
 {
 	if (mPacketCount == 0) {
@@ -96,24 +106,30 @@
 		return false;
 	}
 
-	//speex_decoder_ctl(locState, SPEEX_SET_ENH, &mEnableEnhance);
+	speex_decoder_ctl(locState, SPEEX_SET_ENH, &mDecoderSettings.mPerceptualEnhancement);
 	speex_decoder_ctl(locState, SPEEX_GET_FRAME_SIZE, &mFrameSize);
 
 
-	if (mNumChannels == 1) {
+	if (mDecoderSettings.mForceChannels == SpeexDecodeSettings::SPEEX_CHANNEL_FORCE_STEREO) {
 		locCallback.callback_id = SPEEX_INBAND_STEREO;
 		locCallback.func = speex_std_stereo_request_handler;
 		locCallback.data = mStereoState;
 		speex_decoder_ctl(locState, SPEEX_SET_HANDLER, &locCallback);
 	}
 
+	//TODO::: Apply rate forces
 	mSampleRate = locSpeexHeader->rate;
 
 	speex_decoder_ctl(locState, SPEEX_SET_SAMPLING_RATE, &mSampleRate);
 
 	mNumFrames = locSpeexHeader->frames_per_packet;
-	mNumChannels = locSpeexHeader->nb_channels;
 
+	if (mDecoderSettings.mForceChannels == SpeexDecodeSettings::SPEEX_CHANNEL_LEAVE_ALONE) {
+		mNumChannels = locSpeexHeader->nb_channels;
+	}
+
+	mIsVBR = (locSpeexHeader->vbr != 0);
+
 	mNumExtraHeaders = locSpeexHeader->extra_headers;
 
 	free(locSpeexHeader);

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h	2006-04-20 22:50:21 UTC (rev 11194)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h	2006-04-20 23:35:56 UTC (rev 11195)
@@ -1,5 +1,6 @@
 #pragma once
 
+#include "SpeexDecodeSettings.h"
 #include <libOOOgg/dllstuff.h>
 #include <libOOOgg/StampedOggPacket.h>
 extern "C" {
@@ -15,6 +16,7 @@
 	SpeexDecoder(void);
 	~SpeexDecoder(void);
 
+	bool setDecodeParams(SpeexDecodeSettings inSettings);
 	bool decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize); 
 
 	int frameSize()	{	return mFrameSize;	}
@@ -28,9 +30,12 @@
 	int mSampleRate;
 	int mNumFrames;
 	int mNumExtraHeaders;
+	bool mIsVBR;
 
 	SpeexStereoState* mStereoState;
 	SpeexBits mSpeexBits;
 	void* mSpeexState;
 
+	SpeexDecodeSettings mDecoderSettings;
+
 };

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj	2006-04-20 22:50:21 UTC (rev 11194)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj	2006-04-20 23:35:56 UTC (rev 11195)
@@ -153,6 +153,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\SpeexDecodeSettings.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\stdafx.cpp"
 				>
 				<FileConfiguration
@@ -183,6 +187,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\SpeexDecodeSettings.h"
+				>
+			</File>
+			<File
 				RelativePath=".\stdafx.h"
 				>
 			</File>



More information about the commits mailing list