[xiph-commits] r10812 - in trunk/oggdsf/src/tools: . UnTransmoggrify
illiminable at svn.xiph.org
illiminable at svn.xiph.org
Sun Feb 12 14:07:05 PST 2006
Author: illiminable
Date: 2006-02-12 14:06:51 -0800 (Sun, 12 Feb 2006)
New Revision: 10812
Added:
trunk/oggdsf/src/tools/UnTransmoggrify/
trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.cpp
trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.h
trunk/oggdsf/src/tools/UnTransmoggrify/ReadMe.txt
trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.cpp
trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.vcproj
trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.cpp
trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.h
Log:
* Merge untransmoggrify
Added: trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.cpp
===================================================================
--- trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.cpp 2006-02-12 22:05:01 UTC (rev 10811)
+++ trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.cpp 2006-02-12 22:06:51 UTC (rev 10812)
@@ -0,0 +1,24 @@
+#include "StdAfx.h"
+#include ".\oggfilewriter.h"
+
+OggFileWriter::OggFileWriter(string inFilename)
+{
+ mFileOut.open(inFilename.c_str(), ios_base::out|ios_base::binary);
+}
+
+OggFileWriter::~OggFileWriter(void)
+{
+ mFileOut.close();
+}
+
+bool OggFileWriter::acceptOggPage(OggPage* inOggPage)
+{
+ unsigned char* locData = inOggPage->createRawPageData();
+ mFileOut.write((char*)locData, inOggPage->pageSize());
+ delete[] locData;
+ return true;
+}
+void OggFileWriter::NotifyComplete()
+{
+ mFileOut.close();
+}
Added: trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.h
===================================================================
--- trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.h 2006-02-12 22:05:01 UTC (rev 10811)
+++ trunk/oggdsf/src/tools/UnTransmoggrify/OggFileWriter.h 2006-02-12 22:06:51 UTC (rev 10812)
@@ -0,0 +1,23 @@
+#pragma once
+
+
+
+#include <libOOOgg/libOOOgg.h>
+#include <libOOOgg/dllstuff.h>
+
+#include <iostream>
+#include <fstream>
+class OggFileWriter
+ : public IOggCallback
+ , public INotifyComplete
+{
+public:
+ OggFileWriter(string inFilename);
+ virtual ~OggFileWriter(void);
+
+ virtual bool acceptOggPage(OggPage* inOggPage);
+ virtual void NotifyComplete();
+
+private:
+ fstream mFileOut;
+};
Added: trunk/oggdsf/src/tools/UnTransmoggrify/ReadMe.txt
===================================================================
--- trunk/oggdsf/src/tools/UnTransmoggrify/ReadMe.txt 2006-02-12 22:05:01 UTC (rev 10811)
+++ trunk/oggdsf/src/tools/UnTransmoggrify/ReadMe.txt 2006-02-12 22:06:51 UTC (rev 10812)
@@ -0,0 +1,32 @@
+========================================================================
+ CONSOLE APPLICATION : UnTransmoggrify Project Overview
+========================================================================
+
+AppWizard has created this UnTransmoggrify application for you.
+This file contains a summary of what you will find in each of the files that
+make up your UnTransmoggrify application.
+
+
+UnTransmoggrify.vcproj
+ This is the main project file for VC++ projects generated using an Application Wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+UnTransmoggrify.cpp
+ This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+ These files are used to build a precompiled header (PCH) file
+ named UnTransmoggrify.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
Added: trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.cpp
===================================================================
--- trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.cpp 2006-02-12 22:05:01 UTC (rev 10811)
+++ trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.cpp 2006-02-12 22:06:51 UTC (rev 10812)
@@ -0,0 +1,255 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+//- 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.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``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 ORGANISATION OR
+//CONTRIBUTORS 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.
+//===========================================================================
+
+// OggDump.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include <libOOOgg/libOOOgg.h>
+#include <libOOOgg/dllstuff.h>
+#include <libilliCore/iBE_Math.h>
+#include <libilliCore/iLE_Math.h>
+
+#include "OggFileWriter.h"
+#include <iostream>
+#include <fstream>
+
+unsigned long bytePos;
+
+OggPageInterleaver* interleaver;
+
+OggFileWriter* fileWriter;
+
+OggPage* pendingPage = NULL;
+OggMuxStream* pendingStream = NULL;
+bool isFirstPage = true;
+bool hasPageWaiting = false;
+
+unsigned long granFixCount = 0;
+
+struct sStreamInfo {
+ unsigned long mSerialNo;
+ unsigned long mUptoSeqNo;
+ OggMuxStream* mMuxStream;
+
+};
+
+vector<sStreamInfo*> streamList;
+
+
+bool fixifyPage(OggPage* inOggPage, sStreamInfo* inStreamInfo)
+{
+ //Fix the granule pos bug
+ if (inOggPage->numPackets() == 1) {
+ if ((inOggPage->getPacket(0)->isTruncated()) && (inStreamInfo->mUptoSeqNo < inStreamInfo->mMuxStream->numHeaders())) {
+
+ inOggPage->header()->setGranulePos(-1);
+ }
+ }
+
+ //Fix sequence number bug
+ inOggPage->header()->setPageSequenceNo(inStreamInfo->mUptoSeqNo++);
+
+ //Recompute checksum
+ inOggPage->computeAndSetCRCChecksum();
+
+ return true;
+}
+
+
+bool setMuxState(OggPage* inOggPage, OggMuxStream* inMuxStream)
+{
+ if (strncmp((const char*)inOggPage->getPacket(0)->packetData(), "\001vorbis", 7) == 0) {
+ inMuxStream->setConversionParams(iLE_Math::charArrToULong(inOggPage->getPacket(0)->packetData() + 12), 1, 10000000);
+ inMuxStream->setNumHeaders(3);
+ return true;
+ } else if ((strncmp((char*)inOggPage->getPacket(0)->packetData(), "\200theora", 7)) == 0){
+ //mGranulePosShift = (((inOggPage->getPacket(0)->packetData()[40]) % 4) << 3) + ((inOggPage->getPacket(0)->packetData()[41]) >> 5);
+ inMuxStream->setConversionParams(
+ iBE_Math::charArrToULong(inOggPage->getPacket(0)->packetData() + 22)
+ , iBE_Math::charArrToULong(inOggPage->getPacket(0)->packetData() + 26)
+ , 10000000
+ , (((inOggPage->getPacket(0)->packetData()[40]) % 4) << 3) + ((inOggPage->getPacket(0)->packetData()[41]) >> 5));
+ inMuxStream->setNumHeaders(3);
+ return true;
+ } else {
+ return false;
+ }
+
+}
+
+//This will be called by the callback
+bool pageCB(OggPage* inOggPage, void* /* inUserData ignored */)
+{
+ sStreamInfo* locCurrentInfo = NULL;
+ if (inOggPage->header()->isBOS()) {
+ sStreamInfo* locStreamInfo = new sStreamInfo;
+ locStreamInfo->mSerialNo = inOggPage->header()->StreamSerialNo();
+ locStreamInfo->mUptoSeqNo = 0;
+ locStreamInfo->mMuxStream = interleaver->newStream();
+ locStreamInfo->mMuxStream->setIsActive(true);
+ streamList.push_back(locStreamInfo);
+
+ if (!setMuxState(inOggPage, locStreamInfo->mMuxStream)) {
+ cout<<"Only handles theora and vorbis... ABORT ABORT ABORT!!"<<endl;
+ throw 0;
+ }
+
+ locCurrentInfo = locStreamInfo;
+
+
+ } else {
+ for (size_t i = 0; i < streamList.size(); i++) {
+ if (streamList[i]->mSerialNo == inOggPage->header()->StreamSerialNo()) {
+ locCurrentInfo = streamList[i];
+ break;
+ }
+ }
+ }
+
+ if (locCurrentInfo == NULL) {
+ throw 0;
+ }
+
+ fixifyPage(inOggPage, locCurrentInfo);
+
+
+
+ if (isFirstPage) {
+ if (strncmp((const char*)inOggPage->getPacket(0)->packetData(), "\001vorbis", 7) == 0) {
+ //First page is vorbis.
+
+ //Hold it for later.
+ pendingPage = inOggPage;
+ pendingStream = locCurrentInfo->mMuxStream;
+ isFirstPage = false;
+ hasPageWaiting = true;
+ }
+ } else {
+ if (hasPageWaiting) {
+ if ((strncmp((char*)inOggPage->getPacket(0)->packetData(), "\200theora", 7)) == 0) {
+ //Was vorbis, then theora... need to send the theora first, then the vorbis... then carry on
+ locCurrentInfo->mMuxStream->acceptOggPage(inOggPage);
+ pendingStream->acceptOggPage(pendingPage);
+ } else {
+ //Was vorbis... but no theora followed, send the pending page... and carry on as normal
+ pendingStream->acceptOggPage(pendingPage);
+ locCurrentInfo->mMuxStream->acceptOggPage(inOggPage);
+ }
+
+ hasPageWaiting = false;
+ pendingPage = NULL;
+ } else {
+ locCurrentInfo->mMuxStream->acceptOggPage(inOggPage);
+ }
+ }
+
+
+
+
+
+
+ //cout<<"Page Location : "<<bytePos;
+ //bytePos += inOggPage->pageSize();
+ //cout<<" to "<<bytePos<<endl;
+ //OggPacket* locPack = NULL;
+ //cout << inOggPage->header()->toString();
+ //cout << "Num Packets : " << inOggPage->numPackets() << endl;;
+ //for (unsigned long i = 0; i < inOggPage->numPackets(); i++) {
+ // locPack = inOggPage->getPacket(i);
+ // cout << "------ Packet " << i << " (" << locPack->packetSize() << " bytes) -------";
+ //
+ // if (locPack->isContinuation()) {
+ // cout<<" ** CONT **";
+ // }
+ // if (locPack->isTruncated()) {
+ // cout<<" ** TRUNC **";
+ // }
+ // cout<<endl;
+ // cout << locPack->toPackDumpString();
+ //}
+
+ return true;
+}
+
+
+#ifdef WIN32
+int __cdecl _tmain(int argc, _TCHAR* argv[])
+#else
+int main (int argc, char * argv[])
+#endif
+{
+ //This program just dumps the pages out of a file in ogg format.
+ // Currently does not error checking. Check your command line carefully !
+ // USAGE :: OggDump <OggFile>
+ //
+
+
+ bytePos = 0;
+
+ if (argc < 3) {
+ cout<<"Usage : OOOggDump <filename>"<<endl;
+ } else {
+
+ int x;
+ cin>>x;
+
+ string locOutFilename = argv[2];
+ fileWriter = new OggFileWriter(locOutFilename);
+ interleaver = new OggPageInterleaver(fileWriter, fileWriter);
+
+ OggDataBuffer testOggBuff;
+
+
+
+ testOggBuff.registerStaticCallback(&pageCB, NULL);
+
+ fstream testFile;
+ testFile.open(argv[1], ios_base::in | ios_base::binary);
+
+ const unsigned short BUFF_SIZE = 8092;
+ char* locBuff = new char[BUFF_SIZE];
+ while (!testFile.eof()) {
+ testFile.read(locBuff, BUFF_SIZE);
+ unsigned long locBytesRead = testFile.gcount();
+ testOggBuff.feed((const unsigned char*)locBuff, locBytesRead);
+ }
+
+ delete[] locBuff;
+
+ delete interleaver;
+ delete fileWriter;
+
+ }
+
+ return 0;
+}
+
Added: trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.vcproj
===================================================================
--- trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.vcproj 2006-02-12 22:05:01 UTC (rev 10811)
+++ trunk/oggdsf/src/tools/UnTransmoggrify/UnTransmoggrify.vcproj 2006-02-12 22:06:51 UTC (rev 10812)
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="UnTransmoggrify"
+ ProjectGUID="{FC1E2E69-3FE9-4DC6-9897-4F0329EB24D7}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\lib\core\ogg;.;..\..\lib\helper"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="3"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"
+ CallingConvention="2"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/UnTransmoggrify.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/UnTransmoggrify.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\lib\core\ogg;.;..\..\lib\helper"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="3"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"
+ CallingConvention="2"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/UnTransmoggrify.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\OggFileWriter.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>
+ <File
+ RelativePath=".\UnTransmoggrify.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath=".\OggFileWriter.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"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.cpp
===================================================================
--- trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.cpp 2006-02-12 22:05:01 UTC (rev 10811)
+++ trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.cpp 2006-02-12 22:06:51 UTC (rev 10812)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// UnTransmoggrify.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: trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.h
===================================================================
--- trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.h 2006-02-12 22:05:01 UTC (rev 10811)
+++ trunk/oggdsf/src/tools/UnTransmoggrify/stdafx.h 2006-02-12 22:06:51 UTC (rev 10812)
@@ -0,0 +1,12 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#include <iostream>
+#include <tchar.h>
+
+// TODO: reference additional headers your program requires here
More information about the commits
mailing list