[xiph-commits] r11193 - in
branches/oggdsf_ce_port/src/lib/codecs/speex/libs: . libOOSpeex
illiminable at svn.xiph.org
illiminable at svn.xiph.org
Thu Apr 20 15:49:07 PDT 2006
Author: illiminable
Date: 2006-04-20 15:48:59 -0700 (Thu, 20 Apr 2006)
New Revision: 11193
Added:
branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/
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
branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.cpp
branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.h
Log:
* Experimental OO speex wrapper
Added: 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 21:12:28 UTC (rev 11192)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.cpp 2006-04-20 22:48:59 UTC (rev 11193)
@@ -0,0 +1,127 @@
+#include "StdAfx.h"
+#include "SpeexDecoder.h"
+
+SpeexDecoder::SpeexDecoder(void)
+ : mPacketCount(0)
+ , mFrameSize(0)
+ , mNumChannels(0)
+ , mSampleRate(0)
+ , mNumFrames(0)
+ , mNumExtraHeaders(0)
+ , mSpeexState(NULL)
+ , mStereoState(NULL)
+{
+}
+
+SpeexDecoder::~SpeexDecoder(void)
+{
+}
+
+bool SpeexDecoder::decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize)
+{
+ if (mPacketCount == 0) {
+ mPacketCount++;
+ return decodeHeader(inPacket);
+ } else if (mPacketCount == 1) {
+ //Comment
+ mPacketCount++;
+ return true;
+ } else if (mPacketCount < 2+mNumExtraHeaders) {
+ //Ignore
+ mPacketCount++;
+ return true;
+ } else {
+ mPacketCount++;
+
+ speex_bits_read_from(&mSpeexBits, (char*)inPacket->packetData(), inPacket->packetSize());
+
+ for (int frame = 0; frame < mNumFrames; frame++) {
+ int locRet = speex_decode_int(mSpeexState, &mSpeexBits, outSamples);
+
+ if (locRet == -1) {
+ break;
+ } else if (locRet == -2) {
+ //Corrupted
+ return false;
+ }
+
+ if (speex_bits_remaining(&mSpeexBits) < 0) {
+ //Corrupted
+ return false;
+ }
+
+
+ if (mNumChannels == 2) {
+ speex_decode_stereo_int(outSamples, mFrameSize, mStereoState);
+ }
+ }
+ return true;
+
+
+ }
+}
+
+bool SpeexDecoder::decodeHeader(StampedOggPacket* inPacket)
+{
+
+ SpeexHeader* locSpeexHeader = NULL;
+ int locModeID = 0;
+ const SpeexMode* locMode = NULL;
+ void* locState = NULL;
+ SpeexCallback locCallback;
+
+ locSpeexHeader = speex_packet_to_header((char*)inPacket->packetData(), inPacket->packetSize());
+
+ if (locSpeexHeader == NULL) {
+ //Can't read header
+ return false;
+ }
+
+ //Check modes?
+ locModeID = locSpeexHeader->mode;
+
+ locMode = speex_lib_get_mode(locModeID);
+
+ if (locSpeexHeader->speex_version_id > 1) {
+ //Invalid version
+ return false;
+ }
+
+ //TODO::: Other bitstream version checks
+
+ locState = speex_decoder_init(locMode);
+
+ if (locState == NULL) {
+ //Init failed
+ return false;
+ }
+
+ //speex_decoder_ctl(locState, SPEEX_SET_ENH, &mEnableEnhance);
+ speex_decoder_ctl(locState, SPEEX_GET_FRAME_SIZE, &mFrameSize);
+
+
+ if (mNumChannels == 1) {
+ locCallback.callback_id = SPEEX_INBAND_STEREO;
+ locCallback.func = speex_std_stereo_request_handler;
+ locCallback.data = mStereoState;
+ speex_decoder_ctl(locState, SPEEX_SET_HANDLER, &locCallback);
+ }
+
+ mSampleRate = locSpeexHeader->rate;
+
+ speex_decoder_ctl(locState, SPEEX_SET_SAMPLING_RATE, &mSampleRate);
+
+ mNumFrames = locSpeexHeader->frames_per_packet;
+ mNumChannels = locSpeexHeader->nb_channels;
+
+ mNumExtraHeaders = locSpeexHeader->extra_headers;
+
+ free(locSpeexHeader);
+ mSpeexState = locState;
+
+ speex_bits_init(&mSpeexBits);
+
+ return true;
+
+
+}
\ No newline at end of file
Added: 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 21:12:28 UTC (rev 11192)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/SpeexDecoder.h 2006-04-20 22:48:59 UTC (rev 11193)
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <libOOOgg/dllstuff.h>
+#include <libOOOgg/StampedOggPacket.h>
+extern "C" {
+#include "speex/speex.h"
+#include "speex/speex_header.h"
+#include "speex/speex_callbacks.h"
+#include "speex/speex_stereo.h"
+}
+
+class SpeexDecoder
+{
+public:
+ SpeexDecoder(void);
+ ~SpeexDecoder(void);
+
+ bool decodePacket(StampedOggPacket* inPacket, short* outSamples, unsigned long inBufferSize);
+
+ int frameSize() { return mFrameSize; }
+ int numChannels() { return mNumChannels; }
+protected:
+ bool decodeHeader(StampedOggPacket* inPacket);
+ unsigned long mPacketCount;
+
+ int mFrameSize;
+ int mNumChannels;
+ int mSampleRate;
+ int mNumFrames;
+ int mNumExtraHeaders;
+
+ SpeexStereoState* mStereoState;
+ SpeexBits mSpeexBits;
+ void* mSpeexState;
+
+};
Added: 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 21:12:28 UTC (rev 11192)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/libOOSpeex.vcproj 2006-04-20 22:48:59 UTC (rev 11193)
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="libOOSpeex"
+ ProjectGUID="{359DBC2D-2BF1-4A1A-BE81-248268F557CC}"
+ RootNamespace="libOOSpeex"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\..\core\ogg;..\..\..\..\helper;..\libspeex\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\..\core\ogg;..\..\..\..\helper;..\libspeex\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="2"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\SpeexDecoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\stdafx.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\SpeexDecoder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.cpp 2006-04-20 21:12:28 UTC (rev 11192)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.cpp 2006-04-20 22:48:59 UTC (rev 11193)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// libOOSpeex.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
Added: branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.h 2006-04-20 21:12:28 UTC (rev 11192)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/libs/libOOSpeex/stdafx.h 2006-04-20 22:48:59 UTC (rev 11193)
@@ -0,0 +1,13 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+
+
+// TODO: reference additional headers your program requires here
More information about the commits
mailing list