[Scummvm-cvs-logs] CVS: tools compress_san.cpp,NONE,1.1 compress_san.vcproj,NONE,1.1 Makefile,1.29,1.30 Makefile.mingw,1.14,1.15 tools.sln,1.3,1.4

Pawel Kolodziejski aquadran at users.sourceforge.net
Tue Apr 13 12:40:01 CEST 2004


Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12239

Modified Files:
	Makefile Makefile.mingw tools.sln 
Added Files:
	compress_san.cpp compress_san.vcproj 
Log Message:
added compression tool for FOBJ chunks in smush movie files.
the *.san files from 'data' dir in FT can NOT be compressed !

--- NEW FILE: compress_san.cpp ---
/* compress_san - zlib compressor for FOBJ chunks in smush san files
 * Copyright (C) 2004  The ScummVM Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/tools/compress_san.cpp,v 1.1 2004/04/13 19:25:02 aquadran Exp $
 *
 */

#include "util.h"
#include "zlib.h"

const char *tag2str(uint32 tag) {
	static char str[5];
	str[0] = (char)(tag >> 24);
	str[1] = (char)(tag >> 16);
	str[2] = (char)(tag >> 8);
	str[3] = (char)tag;
	str[4] = '\0';
	return str;
}

void showhelp(char *exename) {
	printf("\nUsage: %s <inputfile>.san <outputfile>.san\n", exename);
//	printf("\nParams:\n");
//	printf("\n --help     this help message\n");
	exit(2);
}

struct FrameInfo {
	int32 frameSize;
	int32 offsetOutput;
	int32 fobjDecompressedSize;
	int32 fobjCompressedSize;
};

int main(int argc, char *argv[]) {
	int i;
	if (argc < 3)
		showhelp(argv[0]);

	i = argc - 2;
	FILE *input = fopen(argv[i], "rb");
	if (!input) {
		printf("Cannot open file: %s\n", argv[i]);
		exit(-1);
	}

	i = argc - 1;

	FILE *output = fopen(argv[i], "wb");
	if (!output) {
		printf("Cannot open file: %s\n", argv[i]);
		exit(-1);
	}

	uint32 tag;
	int32 l, size;

	writeUint32BE(output, readUint32BE(input)); // ANIM
	int32 animChunkSize = readUint32BE(input); // ANIM size
	writeUint32BE(output, animChunkSize);

	writeUint32BE(output, readUint32BE(input)); // AHDR
	size = readUint32BE(input);
	writeUint32BE(output, size); // AHDR size
	writeUint16BE(output, readUint16BE(input)); // version
	int32 nbframes = readUint16LE(input); // number frames
	writeUint16LE(output, nbframes);
	writeUint16BE(output, readUint16BE(input)); // unk
	for (l = 0; l < size - 6; l++) {
		writeByte(output, readByte(input)); // 0x300 palette + some bytes
	}

	FrameInfo *frameInfo = (FrameInfo *)malloc(sizeof(FrameInfo) * nbframes);

	for (l = 0; l < nbframes; l++) {
		printf("frame: %d\n", l);
		tag = readUint32BE(input); // chunk tag
		writeUint32BE(output, tag); // FRME
		int32 frameSize = readUint32BE(input); // FRME size
		frameInfo[l].frameSize = frameSize;
		frameInfo[l].offsetOutput = ftell(output);
		writeUint32BE(output, frameSize);
		for (;;) {
			tag = readUint32BE(input); // chunk tag
			if (feof(input))
				break;
			if (tag == 'FRME') {
				fseek(input, -4, SEEK_CUR);
				break;
			} else if (tag != 'FOBJ') {
				size = readUint32BE(input); // chunk size
				writeUint32BE(output, tag);
				writeUint32BE(output, size);
				if ((size & 1) != 0)
					size++;
				for (int k = 0; k < size; k++) {
					writeByte(output, readByte(input)); // chunk datas
				}
			} else if (tag == 'FOBJ') {
				size = readUint32BE(input); // FOBJ size
				if ((size & 1) != 0)
					size++;
				unsigned long outputSize = size + (size / 9);
				byte *zlibInputBuffer = (byte *)malloc(size);
				byte *zlibOutputBuffer = (byte *)malloc(outputSize);
				for (int k = 0; k < size; k++) {
					*(zlibInputBuffer + k) = readByte(input); // FOBJ datas
				}
				int result = compress2(zlibOutputBuffer, &outputSize, zlibInputBuffer, size, 9);
				if (result != Z_OK) {
					error("compression error");
				}
				if ((outputSize & 1) != 0)
					outputSize++;
				frameInfo[l].fobjDecompressedSize = size;
				frameInfo[l].fobjCompressedSize = outputSize;
				writeUint32BE(output, 'ZFOB');
				writeUint32BE(output, outputSize + 4);
				writeUint32BE(output, size);
				for (int k = 0; k < outputSize; k++) {
					writeByte(output, *(zlibOutputBuffer + k)); // compressed FOBJ datas
				}
				free(zlibInputBuffer);
				free(zlibOutputBuffer);
			}
		}
	}

	fclose(input);

	int32 sumDiff = 0;
	for (l = 0; l < nbframes; l++) {
		fseek(output, frameInfo[l].offsetOutput, SEEK_SET);
		int32 diff = frameInfo[l].fobjDecompressedSize - (frameInfo[l].fobjCompressedSize + 4);
		sumDiff += diff;
		writeUint32BE(output, frameInfo[l].frameSize - diff);
	}

	fseek(output, 4, SEEK_SET);
	writeUint32BE(output, animChunkSize - sumDiff);

	free(frameInfo);
	
	fclose(output);
		
	return 0;
}

--- NEW FILE: compress_san.vcproj ---
<?xml version="1.0" encoding = "windows-1250"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="7.00"
	Name="compress_san"
	ProjectGUID="{BB433621-30FA-43B0-BB31-CE97E1A5C456}"
	SccProjectName=""
	SccLocalPath="">
	<Platforms>
		<Platform
			Name="Win32"/>
	</Platforms>
	<Configurations>
		<Configuration
			Name="Release|Win32"
			OutputDirectory=".\compress_san___Win32_Release"
			IntermediateDirectory=".\compress_san___Win32_Release"
			ConfigurationType="1"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				InlineFunctionExpansion="1"
				PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
				StringPooling="TRUE"
				RuntimeLibrary="4"
				EnableFunctionLevelLinking="TRUE"
				UsePrecompiledHeader="2"
				PrecompiledHeaderFile=".\compress_san___Win32_Release/rescumm.pch"
				AssemblerListingLocation=".\compress_san___Win32_Release/"
				ObjectFile=".\compress_san___Win32_Release/"
				ProgramDataBaseFileName=".\compress_san___Win32_Release/"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				AdditionalOptions="/MACHINE:I386"
				AdditionalDependencies="odbc32.lib odbccp32.lib libz.lib"
				OutputFile=".\compress_san___Win32_Release/rescumm.exe"
				LinkIncremental="1"
				SuppressStartupBanner="TRUE"
				ProgramDatabaseFile=".\compress_san___Win32_Release/rescumm.pdb"
				SubSystem="1"/>
			<Tool
				Name="VCMIDLTool"
				TypeLibraryName=".\compress_san___Win32_Release/rescumm.tlb"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="NDEBUG"
				Culture="1045"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
		</Configuration>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory=".\compress_san___Win32_Debug"
			IntermediateDirectory=".\compress_san___Win32_Debug"
			ConfigurationType="1"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE"
				BasicRuntimeChecks="3"
				RuntimeLibrary="5"
				UsePrecompiledHeader="2"
				PrecompiledHeaderFile=".\compress_san___Win32_Debug/rescumm.pch"
				AssemblerListingLocation=".\compress_san___Win32_Debug/"
				ObjectFile=".\compress_san___Win32_Debug/"
				ProgramDataBaseFileName=".\compress_san___Win32_Debug/"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"
				DebugInformationFormat="4"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				AdditionalOptions="/MACHINE:I386"
				AdditionalDependencies="odbc32.lib odbccp32.lib libz.lib"
				OutputFile=".\compress_san___Win32_Debug/rescumm.exe"
				LinkIncremental="2"
				SuppressStartupBanner="TRUE"
				GenerateDebugInformation="TRUE"
				ProgramDatabaseFile=".\compress_san___Win32_Debug/rescumm.pdb"
				SubSystem="1"/>
			<Tool
				Name="VCMIDLTool"
				TypeLibraryName=".\compress_san___Win32_Debug/rescumm.tlb"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_DEBUG"
				Culture="1045"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
		</Configuration>
	</Configurations>
	<Files>
		<File
			RelativePath="compress_san.cpp">
		</File>
		<File
			RelativePath="util.c">
		</File>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>

Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/tools/Makefile,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- Makefile	30 Dec 2003 16:33:45 -0000	1.29
+++ Makefile	13 Apr 2004 19:25:01 -0000	1.30
@@ -16,6 +16,7 @@
 # CFLAGS += -DSCUMM_BIG_ENDIAN
 
 TARGETS := \
+	compress_san$(EXEEXT) \
 	convbdf$(EXEEXT) \
 	descumm$(EXEEXT) \
 	desword2$(EXEEXT) \
@@ -29,6 +30,9 @@
 
 all: $(TARGETS)
 
+compress_san$(EXEEXT): compress_san.o uti.o
+	$(CXX) $(LFLAGS) -o $@ $+
+
 convbdf$(EXEEXT): convbdf.o util.o
 	$(CXX) $(LFLAGS) -o $@ $+
 

Index: Makefile.mingw
===================================================================
RCS file: /cvsroot/scummvm/tools/Makefile.mingw,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Makefile.mingw	31 Dec 2003 01:29:09 -0000	1.14
+++ Makefile.mingw	13 Apr 2004 19:25:02 -0000	1.15
@@ -8,6 +8,7 @@
 install:   all
 	mkdir -p $(SCUMMVMPATH)
 	mkdir -p $(SCUMMVMPATH)/tools
+	strip compress_san.exe -o $(SCUMMVMPATH)/tools/compress_san.exe
 	strip convbdf.exe -o $(SCUMMVMPATH)/tools/convbdf.exe
 	strip descumm.exe -o $(SCUMMVMPATH)/tools/descumm.exe
 	strip desword2.exe -o $(SCUMMVMPATH)/tools/desword2.exe

Index: tools.sln
===================================================================
RCS file: /cvsroot/scummvm/tools/tools.sln,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tools.sln	28 Oct 2003 18:34:02 -0000	1.3
+++ tools.sln	13 Apr 2004 19:25:02 -0000	1.4
@@ -13,6 +13,8 @@
 EndProject

 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "queenrebuild", "queenrebuild.vcproj", "{3DA13694-4F7A-43FA-A622-F073A57C6DC3}"

 EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compress_san", "compress_san.vcproj", "{BB433621-30FA-43B0-BB31-CE97E1A5C456}"

+EndProject

 Global

 	GlobalSection(SolutionConfiguration) = preSolution

 		ConfigName.0 = Debug

@@ -49,6 +51,10 @@
 		{3DA13694-4F7A-43FA-A622-F073A57C6DC3}.Debug.Build.0 = Debug|Win32

 		{3DA13694-4F7A-43FA-A622-F073A57C6DC3}.Release.ActiveCfg = Release|Win32

 		{3DA13694-4F7A-43FA-A622-F073A57C6DC3}.Release.Build.0 = Release|Win32

+		{BB433621-30FA-43B0-BB31-CE97E1A5C456}.Debug.ActiveCfg = Debug|Win32

+		{BB433621-30FA-43B0-BB31-CE97E1A5C456}.Debug.Build.0 = Debug|Win32

+		{BB433621-30FA-43B0-BB31-CE97E1A5C456}.Release.ActiveCfg = Release|Win32

+		{BB433621-30FA-43B0-BB31-CE97E1A5C456}.Release.Build.0 = Release|Win32

 	EndGlobalSection

 	GlobalSection(ExtensibilityGlobals) = postSolution

 	EndGlobalSection






More information about the Scummvm-git-logs mailing list