[Scummvm-cvs-logs] SF.net SVN: scummvm: [27943] tools/branches/gsoc2007-decompiler
brixxie at users.sourceforge.net
brixxie at users.sourceforge.net
Fri Jul 6 19:58:45 CEST 2007
Revision: 27943
http://scummvm.svn.sourceforge.net/scummvm/?rev=27943&view=rev
Author: brixxie
Date: 2007-07-06 10:58:45 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
Removed unnecessary files and changed the Makefiles and README to reflect these changes.
Modified Paths:
--------------
tools/branches/gsoc2007-decompiler/Makefile
tools/branches/gsoc2007-decompiler/Makefile.mingw
tools/branches/gsoc2007-decompiler/README
tools/branches/gsoc2007-decompiler/antipasto.scm
Removed Paths:
-------------
tools/branches/gsoc2007-decompiler/compress.c
tools/branches/gsoc2007-decompiler/compress.h
tools/branches/gsoc2007-decompiler/compress_agos.c
tools/branches/gsoc2007-decompiler/compress_kyra.cpp
tools/branches/gsoc2007-decompiler/compress_queen.c
tools/branches/gsoc2007-decompiler/compress_saga.cpp
tools/branches/gsoc2007-decompiler/compress_scumm_bun.cpp
tools/branches/gsoc2007-decompiler/compress_scumm_san.cpp
tools/branches/gsoc2007-decompiler/compress_scumm_sou.c
tools/branches/gsoc2007-decompiler/compress_sword1.c
tools/branches/gsoc2007-decompiler/compress_sword2.c
tools/branches/gsoc2007-decompiler/compress_touche.c
tools/branches/gsoc2007-decompiler/convert_dxa.bat
tools/branches/gsoc2007-decompiler/convert_dxa.sh
tools/branches/gsoc2007-decompiler/convert_dxa_one.bat
tools/branches/gsoc2007-decompiler/dist/
tools/branches/gsoc2007-decompiler/encode_dxa.cpp
tools/branches/gsoc2007-decompiler/extract_agos.c
tools/branches/gsoc2007-decompiler/extract_kyra.cpp
tools/branches/gsoc2007-decompiler/extract_loom_tg16.c
tools/branches/gsoc2007-decompiler/extract_mm_apple.c
tools/branches/gsoc2007-decompiler/extract_mm_c64.c
tools/branches/gsoc2007-decompiler/extract_mm_nes.c
tools/branches/gsoc2007-decompiler/extract_scumm_mac.c
tools/branches/gsoc2007-decompiler/extract_zak_c64.c
tools/branches/gsoc2007-decompiler/kyra_pak.cpp
tools/branches/gsoc2007-decompiler/kyra_pak.h
tools/branches/gsoc2007-decompiler/sagagame.cpp
tools/branches/gsoc2007-decompiler/sagagame.h
tools/branches/gsoc2007-decompiler/sagaresnames.h
tools/branches/gsoc2007-decompiler/utils/
Property Changed:
----------------
tools/branches/gsoc2007-decompiler/
Property changes on: tools/branches/gsoc2007-decompiler
___________________________________________________________________
Name: svk:merge
- 489ca303-0d3d-4dc1-a57d-017c7912a06a:/local/gsoc2007-decompiler:30
+ 489ca303-0d3d-4dc1-a57d-017c7912a06a:/local/gsoc2007-decompiler:32
Modified: tools/branches/gsoc2007-decompiler/Makefile
===================================================================
--- tools/branches/gsoc2007-decompiler/Makefile 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/Makefile 2007-07-06 17:58:45 UTC (rev 27943)
@@ -16,69 +16,12 @@
CFLAGS+= -Wshadow -Wimplicit -Wundef -Wwrite-strings
TARGETS := \
- compress_agos$(EXEEXT) \
- compress_kyra$(EXEEXT) \
- compress_queen$(EXEEXT) \
- compress_saga$(EXEEXT) \
- compress_scumm_bun$(EXEEXT) \
- compress_scumm_san$(EXEEXT) \
- compress_scumm_sou$(EXEEXT) \
- compress_sword1$(EXEEXT) \
- compress_sword2$(EXEEXT) \
- compress_touche$(EXEEXT) \
dekyra$(EXEEXT) \
descumm$(EXEEXT) \
desword2$(EXEEXT) \
- encode_dxa$(EXEEXT) \
- extract_agos$(EXEEXT) \
- extract_kyra$(EXEEXT) \
- extract_loom_tg16$(EXEEXT) \
- extract_mm_apple$(EXEEXT) \
- extract_mm_c64$(EXEEXT) \
- extract_mm_nes$(EXEEXT) \
- extract_scumm_mac$(EXEEXT) \
- extract_zak_c64$(EXEEXT)
-UTILS := \
- utils/adpcm.o \
- utils/audiostream.o \
- utils/file.o \
- utils/md5.o \
- utils/voc.o \
- utils/wave.o
-
all: $(TARGETS)
-compress_agos$(EXEEXT): compress_agos.o compress.o util.o
- $(CC) $(LDFLAGS) -o $@ $+
-
-compress_kyra$(EXEEXT): compress_kyra.o kyra_pak.o compress.o util.o
- $(CXX) $(LDFLAGS) -o $@ $+
-
-compress_queen$(EXEEXT): compress_queen.o util.o
- $(CC) $(LDFLAGS) -o $@ $+
-
-compress_saga$(EXEEXT): compress_saga.o compress.o util.o $(UTILS)
- $(CXX) $(LDFLAGS) -o $@ $+
-
-compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o
- $(CXX) $(LDFLAGS) -o $@ $+
-
-compress_scumm_san$(EXEEXT): compress_scumm_san.o compress.o util.o
- $(CXX) $(LDFLAGS) -o $@ $+ -lz
-
-compress_scumm_sou$(EXEEXT): compress_scumm_sou.o compress.o util.o
- $(CC) $(LDFLAGS) -o $@ $+
-
-compress_sword1$(EXEEXT): compress_sword1.o compress.o util.o
- $(CC) $(LDFLAGS) -o $@ $+
-
-compress_sword2$(EXEEXT): compress_sword2.o compress.o util.o
- $(CC) $(LDFLAGS) -o $@ $+
-
-compress_touche$(EXEEXT): compress_touche.o compress.o util.o
- $(CC) $(LDFLAGS) -o $@ $+
-
dekyra$(EXEEXT): dekyra.o dekyra_v1.o util.o
$(CXX) $(LDFLAGS) -o $@ $+
@@ -115,37 +58,16 @@
extract_zak_c64$(EXEEXT): extract_zak_c64.o util.o
$(CC) $(LDFLAGS) -o $@ $+
-
descumm.o descumm6.o descumm-common.o descumm-tool.o: descumm.h
-# Most compress_* tools (except for compress_queen) use compress.h
-compress_agos.o compress_saga.o compress_scumm_sou.o \
-compress_scumm_bun.o compress_sword1.o compress_sword2.o \
-compress_kyra.o compress.o encode_dxa.o: compress.h
-
-# Virtually everything depends on util.h
-compress_agos.o compress_saga.o compress_scumm_sou.o \
-compress_scumm_bun.o compress_sword1.o compress_sword2.o \
-compress.o \
-compress_queen.o \
-compress_kyra.o \
descumm.o descumm6.o descumm-common.o descumm-tool.o \
dekyra.o \
dekyra_v1.o \
desword2.o \
-encode_dxa.o \
-extract_kyra.o \
-extract_loom_tg16.o \
-extract_mm_apple.o \
-extract_mm_c64.o \
-extract_mm_nes.o \
-extract_scumm_mac.o \
-extract_zak_c64.o \
-kyra_pak.o \
util.o: util.h
clean:
- rm -f *.o utils/*.o $(TARGETS)
+ rm -f *.o $(TARGETS)
.cpp.o:
$(CXX) $(CFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
Modified: tools/branches/gsoc2007-decompiler/Makefile.mingw
===================================================================
--- tools/branches/gsoc2007-decompiler/Makefile.mingw 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/Makefile.mingw 2007-07-06 17:58:45 UTC (rev 27943)
@@ -11,29 +11,9 @@
install: all
mkdir -p $(SCUMMVMPATH)
mkdir -p $(SCUMMVMPATH)/tools
- strip compress_agos.exe -o $(SCUMMVMPATH)/tools/compress_agos.exe
- strip compress_kyra.exe -o $(SCUMMVMPATH)/tools/compress_kyra.exe
- strip compress_queen.exe -o $(SCUMMVMPATH)/tools/compress_queen.exe
- strip compress_saga.exe -o $(SCUMMVMPATH)/tools/compress_saga.exe
- strip compress_scumm_bun.exe -o $(SCUMMVMPATH)/tools/compress_scumm_bun.exe
- strip compress_scumm_san.exe -o $(SCUMMVMPATH)/tools/compress_scumm_san.exe
- strip compress_scumm_sou.exe -o $(SCUMMVMPATH)/tools/compress_scumm_sou.exe
- strip compress_sword1.exe -o $(SCUMMVMPATH)/tools/compress_sword1.exe
- strip compress_sword2.exe -o $(SCUMMVMPATH)/tools/compress_sword2.exe
- strip compress_touche.exe -o $(SCUMMVMPATH)/tools/compress_touche.exe
strip dekyra.exe -o $(SCUMMVMPATH)/tools/dekyra.exe
strip descumm.exe -o $(SCUMMVMPATH)/tools/descumm.exe
strip desword2.exe -o $(SCUMMVMPATH)/tools/desword2.exe
- strip encode_dxa.exe -o $(SCUMMVMPATH)/tools/encode_dxa.exe
- strip extract_agos.exe -o $(SCUMMVMPATH)/tools/extract_agos.exe
- strip extract_kyra.exe -o $(SCUMMVMPATH)/tools/extract_kyra.exe
- strip extract_loom_tg16.exe -o $(SCUMMVMPATH)/tools/extract_loom_tg16.exe
- strip extract_mm_apple.exe -o $(SCUMMVMPATH)/tools/extract_mm_apple.exe
- strip extract_mm_c64.exe -o $(SCUMMVMPATH)/tools/extract_mm_c64.exe
- strip extract_mm_nes.exe -o $(SCUMMVMPATH)/tools/extract_mm_nes.exe
- strip extract_scumm_mac.exe -o $(SCUMMVMPATH)/tools/extract_scumm_mac.exe
- strip extract_zak_c64.exe -o $(SCUMMVMPATH)/tools/extract_zak_c64.exe
- cp *.bat $(SCUMMVMPATH)/tools
cp COPYING $(SCUMMVMPATH)/tools/COPYING.txt
cp README $(SCUMMVMPATH)/tools/README.txt
u2d $(SCUMMVMPATH)/tools/*.txt
Modified: tools/branches/gsoc2007-decompiler/README
===================================================================
--- tools/branches/gsoc2007-decompiler/README 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/README 2007-07-06 17:58:45 UTC (rev 27943)
@@ -6,122 +6,6 @@
ScummVM versions may not. ScummVM 0.6.x does not support FLAC audio, for
example.
-Extraction Tools:
- extract_agos
- Extracts the packed files used in the Amiga and AtariST
- versions of Elvira 1/2, Waxworks and Simon the Sorcerer 1.
-
- extract_kyra
- Unpacks .PAK files from Kyrandia games.
-
- extract_scumm_mac
- Extracts Macintosh "single file" SCUMM games into their
- component parts, for use with ScummVM.
- This is required for ScummVM up to version 0.6.x; all
- later versions directly support reading this file
- format.
-
- extract_loom_tg16
- Extracts data files from the PC-Engine version of Loom.
- Use the dumpcd utility at http://www.zeograd.com/misc_download.php
- to dump the code tracks on the CD.
-
- extract_mm_apple
- Extracts data files from the Apple II version of Maniac
- Mansion.
-
- extract_mm_c64
- Extracts data files from the Commodore 64 version of Maniac
- Mansion.
-
- extract_mm_nes
- Extracts data files from the NES version of Maniac Mansion.
-
- extract_zak_c64
- Extracts data files from the Commodore 64 version of Zak
- McKracken.
-
-Compression Tools:
- compress_scumm_sou
- Used to compress .sou files to .so3 (MP3), .sog (Vorbis),
- or .sof (FLAC).
-
- compress_agos
- Used to compress the Feeble Files or Simon 1/2 voc/wav files
- to MP3, Vorbis or FLAC.
-
- compress_queen
- Used to rebuild the datafile of Flight of the Amazon Queen,
- and allow optional MP3, Vorbis or FLAC compression.
-
- compress_saga
- Used to compress SAGA engine digital sound files to MP3 or
- Vorbis.
- There is currently no support for compressed sound files in
- ScummVM!
-
- compress_sword1
- Used to compress Broken Sword 1's music and speech files to
- MP3 or Vorbis.
-
- compress_sword2
- Used to compress Broken Sword 2's music and speech .clu
- files to .cl3 (MP3), .clg (Vorbis) or .clf (FLAC).
-
- Please note that FLAC compression will produce a larger file
- than the original! This is because the original files already
- use lossy compression.
-
- compress_touche
- Used to compress and pack Touche speech files ('Vxxx' and
- 'OBJ') to MP3, Vorbis or FLAC to a single file named
- TOUCHE.SO3/.SOG/.SOF depending on the sound compression. Once
- compressed, only TOUCHE.DAT and TOUCHE.SOx files are required
- to play the game under ScummVM.
-
- compress_scumm_san <inputfile> <inputdir> <outputdir> [--ogg]
- Compresses '.san' smush animation files. It uses lossless
- zlib for compressing FOBJ gfx chunks inside a san file.
- It also can create a separate Ogg file with the audio track.
-
- Example of usage:
- compress_scumm_san opening.san uncomp comp
-
- In order to use such compressed files, your ScummVM binary
- must have been built with zlib support enabled (you can find
- out whether that's the case by looking at the About dialog).
- For the Ogg or MP3 compression feature, your ScummVM binary
- naturally must have been built with Ogg or MP3 support enabled.
-
- NOTE: For some '.san' files there is a corresponding '.flu'
- file, which contains offsets into the '.san' file. Hence, the
- compress_scumm_san has to modify the '.flu' file. This happens
- automatically, if the '.san' and '.flu' files are in the
- same directory (which is normally the case). If you want to
- move the '.san' files before compressing them, make sure to
- move the '.flu' files, too!
-
- compress_scumm_bun <inputfile> <inputdir> <outputdir> [--ogg]
-
- Compresses '.bun' music/voice files.
-
- Example of usage:
- compress_scumm.bun digmusic.bun uncomp comp
-
- For the Ogg or MP3 compression feature, your ScummVM binary
- naturally must have been built with Ogg or MP3 support enabled.
-
- compress_kyra
- Used to compress The Legend of Kyrandia's speech files with
- MP3, Vorbis or FLAC.
-
- Example of usage:
- compress_kyra <flags here> input/GEMCUT.VRM output/GEMCUT.VRM
-
- Note: You have to keep the VRM extension, else it will NOT work.
- Use it like shown above, copy all *.VRM files to a directory
- and let the tool put the output file in another directory.
-
Script Tools:
descumm
Decompiles SCUMM scripts
@@ -131,53 +15,3 @@
dekyra
Basic script disassembler for Legend of Kyrandia games
-
-Encoder Tools:
- encode_dxa <filename>
-
- Creates DXA file out of extracted Smacker video.
-
- To extract a video use RAD Game Tools and perform 2 passes
- on it. For example, if your video is called 'intro.smk'.
-
- 1. Extract the video to PNG, 256 colors (choose PNG format
- and tick the checkbox). It will create bunch of files named
- 'introXXX.png', where XXX is frame number. Make sure you have
- extracted 256 colors PNGs, otherwise encode_dxa will complain.
-
- 2. Extract the audio to WAV format, you will get an
- 'intro.wav' file.
-
- 3. Put files 'intro.smk', 'intro.wav' and 'intro*.png' into a
- single directory.
-
- 4. Run `encode_dxa intro.smk` in that directory
-
- 5. You will get an intro.dxa file and intro.flac/mp3/ogg file
- in result.
-
- Additionally you may use batch processing mode of SMK files in
- RAD Game Tools. Just select more than one file and push the
- 'Convert' button. It will ask you either you want them
- processed in batch mode and will do this for you. All buttons
- and conversion options work the same.
-
- convert_dxa.bat
- convert_dxa_one.bat
-
- To ease your life we also provide batch files to autoconvert
- all files. It should work with any game version.
-
- 1. Copy *.smk files from all CDs to some directory
-
- 2. Edit paths in convert_dxa.bat file.
-
- 3. Run the batch. If you set everything correct, it will be
- almost unattended conversion, just for several files there
- are no audio, and RAD Game Tools converter will ask you to
- press OK
-
- convert_dxa.sh
-
- Same as above convert_dxa.bat, just for *nix-based systems.
- It uses Wine to run RAD Game Tools.
Modified: tools/branches/gsoc2007-decompiler/antipasto.scm
===================================================================
--- tools/branches/gsoc2007-decompiler/antipasto.scm 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/antipasto.scm 2007-07-06 17:58:45 UTC (rev 27943)
@@ -2,7 +2,7 @@
;;; Antipasto - Scumm Script Disassembler Prototype (version 5 scripts)
;;; Copyright (C) 2007 Andreas Scholta
-;;; Time-stamp: <2007-07-05 03:55:19 brx>
+;;; Time-stamp: <2007-07-05 19:06:17 brx>
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License
@@ -810,8 +810,8 @@
(define (test-run)
(set! current-script-file
;; "/home/brx/code/gsoc2007-decompiler/M1.scummV5/81.cu_bar_2.0092"
-;; "/home/brx/code/gsoc2007-decompiler/M2.scummV5/entry-4.dmp"
-"/home/brx/code/gsoc2007-decompiler/M2.scummV5/room-15-203.dmp";
+"/home/brx/code/gsoc2007-decompiler/M2.scummV5/entry-4.dmp"
+;; "/home/brx/code/gsoc2007-decompiler/M2.scummV5/room-15-203.dmp";
;; "/home/brx/code/gsoc2007-decompiler/M1.scummV5/01.beach.0201"
)
(set! current-script-port (open-input-file current-script-file))
Deleted: tools/branches/gsoc2007-decompiler/compress.c
===================================================================
--- tools/branches/gsoc2007-decompiler/compress.c 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress.c 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,409 +0,0 @@
-/* Scumm Tools
- * Copyright (C) 2003-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "compress.h"
-
-typedef struct {
- uint32 minBitr;
- uint32 maxBitr;
- bool abr;
- uint32 algqual;
- uint32 vbrqual;
- bool silent;
-} lameparams;
-
-typedef struct {
- int nominalBitr;
- int minBitr;
- int maxBitr;
- int quality;
- bool silent;
-} oggencparams;
-
-/* FIXME: This is an evil way to pass on the params to FLAC.
- It makes it near impossible to reliably pass default params to the
- encoder, which is why the ScummVM README has to tell the user to
- use this command:
- extract --best -b 1152 monster.sou
- If those are the best default options, then they should be *default*
- and the user shouldn't have to specify them.
-*/
-typedef struct {
- char * const* argv;
- int numArgs;
-} flaccparams;
-
-typedef struct {
- bool isLittleEndian, isStereo;
- uint8 bitsPerSample;
-} rawtype;
-
-lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0 };
-oggencparams oggparms = { -1, -1, -1, oggqualDef, 0 };
-flaccparams flacparms;
-rawtype rawAudioType = { false, false, 8 };
-
-const char *tempEncoded = TEMP_MP3;
-
-void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample) {
- rawAudioType.isLittleEndian = isLittleEndian;
- rawAudioType.isStereo = isStereo;
- rawAudioType.bitsPerSample = bitsPerSample;
-}
-
-int getSampleRateFromVOCRate(int vocSR) {
- if (vocSR == 0xa5 || vocSR == 0xa6 || vocSR == 0x83) {
- return 11025;
- } else if (vocSR == 0xd2 || vocSR == 0xd3) {
- return 22050;
- } else {
- int sr = 1000000L / (256L - vocSR);
- /* inexact sampling rates occur e.g. in the kitchen in Monkey
- * Island, very easy to reach right from the start of the game.
- * warning("inexact sample rate used: %i (0x%x)", sr, vocSR);
- */
- return sr;
- }
-}
-
-/* map frequency to a valid MP3 sample frequency
- *
- * Robert Hegemann 2000-07-01
- *
- * Copied from lame 3.96.1
- */
-static int map2MP3Frequency(int freq)
-{
- if (freq <= 8000) return 8000;
- if (freq <= 11025) return 11025;
- if (freq <= 12000) return 12000;
- if (freq <= 16000) return 16000;
- if (freq <= 22050) return 22050;
- if (freq <= 24000) return 24000;
- if (freq <= 32000) return 32000;
- if (freq <= 44100) return 44100;
-
- return 48000;
-}
-
-void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode) {
- char fbuf[2048];
- char *tmp = fbuf;
- int i;
- bool err = false;
-
- switch (compmode) {
- case kVorbisMode:
- tmp += sprintf(tmp, "oggenc ");
- if (rawInput) {
- tmp += sprintf(tmp, "--raw ");
- tmp += sprintf(tmp, "--raw-chan=%d ", (rawAudioType.isStereo ? 2 : 1));
- tmp += sprintf(tmp, "--raw-bits=%d ", rawAudioType.bitsPerSample);
- tmp += sprintf(tmp, "--raw-rate=%d ", rawSamplerate);
- tmp += sprintf(tmp, "--raw-endianness=%d ", (rawAudioType.isLittleEndian ? 0 : 1));
- }
-
- if (oggparms.nominalBitr != -1)
- tmp += sprintf(tmp, "--bitrate=%d ", oggparms.nominalBitr);
- if (oggparms.minBitr != -1)
- tmp += sprintf(tmp, "--min-bitrate=%d ", oggparms.minBitr);
- if (oggparms.maxBitr != -1)
- tmp += sprintf(tmp, "--max-bitrate=%d ", oggparms.maxBitr);
- if (oggparms.silent)
- tmp += sprintf(tmp, "--quiet ");
- tmp += sprintf(tmp, "--quality=%d ", oggparms.quality);
- tmp += sprintf(tmp, "--output=\"%s\" ", outname);
- tmp += sprintf(tmp, "\"%s\" ", inname);
- err = system(fbuf) != 0;
- break;
-
- case kMP3Mode:
- tmp += sprintf(tmp, "lame -t ");
- if (rawInput) {
- tmp += sprintf(tmp, "-r ");
- tmp += sprintf(tmp, "--bitwidth %d ", rawAudioType.bitsPerSample);
- if (rawAudioType.isLittleEndian)
- tmp += sprintf(tmp, "-x ");
- tmp += sprintf(tmp, (rawAudioType.isStereo ? "-m j " : "-m m "));
- tmp += sprintf(tmp, "-s %d ", rawSamplerate);
- }
-
- if (encparms.abr)
- tmp += sprintf(tmp, "--abr %d ", encparms.minBitr);
- else
- tmp += sprintf(tmp, "--vbr-new -b %d ", encparms.minBitr);
-
- /* Explicitly specify a target sample rate, to work around a bug (?)
- * in newer lame versions (>= 3.95) which causes it to malfunction
- * for odd sample rates when in VBR mode. See also bug #934026.
- * We essentially duplicate the old behaviour of lame (found in e.g.
- * version 3.93.1): we round the input sample rate up to the next
- * higher valid MP3 sample rate, with a margin of 3%.
- */
- if (rawSamplerate != -1)
- tmp += sprintf(tmp, "--resample %d ", map2MP3Frequency(97 * rawSamplerate / 100));
-
- if (encparms.silent)
- tmp += sprintf(tmp, " --silent ");
- tmp += sprintf(tmp, "-q %d ", encparms.algqual);
- tmp += sprintf(tmp, "-V %d ", encparms.vbrqual);
- tmp += sprintf(tmp, "-B %d ", encparms.maxBitr);
- tmp += sprintf(tmp, "\"%s\" \"%s\" ", inname, outname);
- err = system(fbuf) != 0;
- break;
-
- case kFlacMode:
- /* --lax is needed to allow 11kHz, we dont need place for meta-tags, and no seektable */
- /* -f is reqired to force override of unremoved temp file. See bug #1294648 */
- tmp += sprintf(tmp, "flac -f --lax --no-padding --no-seektable --no-ogg " );
-
- if (rawInput) {
- tmp += sprintf(tmp, "--force-raw-format --sign=unsigned ");
- tmp += sprintf(tmp, "--channels=%d ", (rawAudioType.isStereo ? 2 : 1));
- tmp += sprintf(tmp, "--bps=%d ", rawAudioType.bitsPerSample);
- tmp += sprintf(tmp, "--sample-rate=%d ", rawSamplerate);
- tmp += sprintf(tmp, "--endian=%s ", (rawAudioType.isLittleEndian ? "little" : "big"));
- }
-
- for (i = 0; i < flacparms.numArgs; i++) {
- /* Append optional encoder arguments */
- tmp += sprintf(tmp, "%s ", flacparms.argv[i]);
- }
-
- tmp += sprintf(tmp, "-o \"%s\" ", outname);
- tmp += sprintf(tmp, "\"%s\" ", inname);
-
- err = system(fbuf) != 0;
- break;
- }
-
- if (err) {
- printf("Got error from encoder. (check your parameters)\n");
- printf("Encoder Commandline: %s\n", fbuf );
- exit(-1);
- }
-}
-
-void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode) {
- int length;
- FILE *f;
- char fbuf[2048];
- size_t size;
-
- fseek(input, -4, SEEK_CUR);
- length = readUint32LE(input);
- length += 8;
- fseek(input, -8, SEEK_CUR);
-
- /* Copy the WAV data to a temporary file */
- f = fopen(outName, "wb");
- while (length > 0) {
- size = fread(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : length, input);
- if (size <= 0)
- break;
- length -= (int)size;
- fwrite(fbuf, 1, size, f);
- }
- fclose(f);
-
- /* Convert the WAV temp file to OGG/MP3 */
- encodeAudio(outName, false, -1, tempEncoded, compMode);
-}
-
-void extractAndEncodeVOC(const char *outName, FILE *input, CompressMode compMode) {
- FILE *f;
- int bits;
- int blocktype;
- int channels;
- int length;
- int sample_rate;
- int comp;
- char fbuf[2048];
- size_t size;
- int real_samplerate = -1;
-
- f = fopen(outName, "wb");
-
- while ((blocktype = fgetc(input))) {
- if (blocktype != 1 && blocktype != 9) {
- /*
- We only generate a warning, instead of erroring out, because
- at least the monster.sou file of Full Throttle contains VOCs
- with an invalid length field (value to small). So we encounter
- the "block types" 0x80, 0x82 etc.. Not sure if there is another
- (maybe even better) way to work around that... ?
- */
- warning("Unsupported VOC block type: %02x", blocktype);
- break;
- }
-
- /* Sound Data */
- printf(" Sound Data\n");
- length = fgetc(input);
- length |= fgetc(input) << 8;
- length |= fgetc(input) << 16;
- if (blocktype == 1) {
- length -= 2;
- sample_rate = fgetc(input);
- comp = fgetc(input);
- real_samplerate = getSampleRateFromVOCRate(sample_rate);
- } else { /* (blocktype == 9) */
- length -= 12;
- real_samplerate = sample_rate = readUint32LE(input);
- bits = fgetc(input);
- channels = fgetc(input);
- if (bits != 8 || channels != 1) {
- error("Unsupported VOC file format (%d bits per sample, %d channels)", bits, channels);
- }
- comp = readUint16LE(input);
- readUint32LE(input);
- }
-
- printf(" - length = %d\n", length);
- printf(" - sample rate = %d (%02x)\n", real_samplerate, sample_rate);
- printf(" - compression = %s (%02x)\n",
- (comp == 0 ? "8bits" :
- (comp == 1 ? "4bits" :
- (comp == 2 ? "2.6bits" :
- (comp == 3 ? "2bits" :
- "Multi")))), comp);
-
- if (comp != 0)
- error("Cannot handle compressed VOC data");
-
- /* Copy the raw data to a temporary file */
- while (length > 0) {
- size = fread(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : (uint32)length, input);
- if (size <= 0)
- break;
- length -= (int)size;
- fwrite(fbuf, 1, size, f);
- }
- }
-
- fclose(f);
-
- assert(real_samplerate != -1);
-
- setRawAudioType(false, false, 8);
-
- /* Convert the raw temp file to OGG/MP3 */
- encodeAudio(outName, true, real_samplerate, tempEncoded, compMode);
-}
-
-int process_mp3_parms(int argc, char *argv[], int i) {
- for (; i < argc; i++) {
- if (strcmp(argv[i], "--vbr") == 0) {
- encparms.abr=0;
- } else if (strcmp(argv[i], "--abr") == 0) {
- encparms.abr=1;
- } else if (strcmp(argv[i], "-b") == 0) {
- encparms.minBitr = atoi(argv[i + 1]);
- if ((encparms.minBitr % 8) != 0)
- encparms.minBitr -= encparms.minBitr % 8;
- if (encparms.minBitr >160)
- encparms.minBitr = 160;
- if (encparms.minBitr < 8)
- encparms.minBitr=8;
- i++;
- } else if (strcmp(argv[i], "-B") == 0) {
- encparms.maxBitr = atoi(argv[i + 1]);
- if ((encparms.maxBitr % 8) != 0)
- encparms.maxBitr -= encparms.maxBitr % 8;
- if (encparms.maxBitr > 160)
- encparms.maxBitr = 160;
- if (encparms.maxBitr < 8)
- encparms.maxBitr = 8;
- i++;
- } else if (strcmp(argv[i], "-V") == 0) {
- encparms.vbrqual = atoi(argv[i + 1]);
- if(encparms.vbrqual < 0)
- encparms.vbrqual = 0;
- if(encparms.vbrqual > 9)
- encparms.vbrqual = 9;
- i++;
- } else if (strcmp(argv[i], "-q") == 0) {
- encparms.algqual = atoi(argv[i + 1]);
- if (encparms.algqual < 0)
- encparms.algqual = 0;
- if (encparms.algqual > 9)
- encparms.algqual = 9;
- i++;
- } else if (strcmp(argv[i], "--silent") == 0) {
- encparms.silent = 1;
- } else if (strcmp(argv[i], "--help") == 0) {
- return 0;
- } else if (argv[i][0] == '-') {
- return 0;
- } else {
- break;
- }
- }
- if (i != (argc - 1)) {
- return 0;
- }
- return 1;
-}
-
-int process_ogg_parms(int argc, char *argv[], int i) {
- for (; i < argc; i++) {
- if (strcmp(argv[i], "-b") == 0) {
- oggparms.nominalBitr = atoi(argv[i + 1]);
- i++;
- }
- else if (strcmp(argv[i], "-m") == 0) {
- oggparms.minBitr = atoi(argv[i + 1]);
- i++;
- }
- else if (strcmp(argv[i], "-M") == 0) {
- oggparms.maxBitr = atoi(argv[i + 1]);
- i++;
- }
- else if (strcmp(argv[i], "-q") == 0) {
- oggparms.quality = atoi(argv[i + 1]);
- i++;
- }
- else if (strcmp(argv[i], "--silent") == 0) {
- oggparms.silent = 1;
- }
- else if (strcmp(argv[i], "--help") == 0) {
- return 0;
- }
- else if (argv[i][0] == '-') {
- return 0;
- }
- else
- break;
- }
- if (i != argc - 1)
- return 0;
- return 1;
-}
-
-int process_flac_parms(int argc, char *argv[], int i){
- flacparms.argv = &argv[i];
- flacparms.numArgs = argc - 1 - i;
-
- if (i >= argc)
- return 0;
- return 1;
-}
Deleted: tools/branches/gsoc2007-decompiler/compress.h
===================================================================
--- tools/branches/gsoc2007-decompiler/compress.h 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress.h 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,69 +0,0 @@
-/* Scumm Tools
- * Copyright (C) 2004-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef EXTRACT_H
-#define EXTRACT_H
-
-#include "util.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* These are the defaults parameters for the Lame invocation */
-#define minBitrDef 24
-#define maxBitrDef 64
-#define algqualDef 2
-#define vbrqualDef 4
-
-/* The default for oggenc invocation is to use the --quality option only */
-#define oggqualDef 3
-
-#define TEMP_WAV "tempfile.wav"
-#define TEMP_RAW "tempfile.raw"
-#define TEMP_MP3 "tempfile.mp3"
-#define TEMP_OGG "tempfile.ogg"
-#define TEMP_FLAC "tempfile.fla"
-
-typedef enum { kMP3Mode, kVorbisMode, kFlacMode } CompressMode;
-
-/*
- * Stuff which is in compress.c
- */
-
-const extern char *tempEncoded;
-
-extern int process_mp3_parms(int argc, char *argv[], int i);
-extern int process_ogg_parms(int argc, char *argv[], int i);
-extern int process_flac_parms(int argc, char *argv[], int i);
-
-extern void extractAndEncodeVOC(const char *outName, FILE *input, CompressMode compMode);
-extern void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode);
-
-extern void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode);
-extern void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample);
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif
Deleted: tools/branches/gsoc2007-decompiler/compress_agos.c
===================================================================
--- tools/branches/gsoc2007-decompiler/compress_agos.c 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress_agos.c 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,364 +0,0 @@
-/* compress_agos - Compress Simon the Sorcerer 1/2 digital sound files into MP3-format
- * Copyright (C) 2004-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "compress.h"
-
-#define TEMP_DAT "tempfile.dat"
-#define TEMP_IDX "tempfile.idx"
-
-static FILE *input, *output_idx, *output_snd;
-
-static CompressMode gCompMode = kMP3Mode;
-
-static char infile_base[256];
-
-static void end(void)
-{
- int size;
- char fbuf[2048];
- char tmp[256];
- const char *head;
-
- switch (gCompMode) {
- case kMP3Mode:
- head = "mp3"; break;
- case kVorbisMode:
- head = "ogg"; break;
- case kFlacMode:
- head = "fla"; break;
- default:
- error("Unknown compression mode");
- }
-
- fclose(output_snd);
- fclose(output_idx);
- fclose(input);
-
- sprintf(tmp, "%s.%s", infile_base, head);
- output_idx = fopen(tmp, "wb");
-
- input = fopen(TEMP_IDX, "rb");
- while ((size = fread(fbuf, 1, 2048, input)) > 0) {
- fwrite(fbuf, 1, size, output_idx);
- }
- fclose(input);
- input = fopen(TEMP_DAT, "rb");
- while ((size = fread(fbuf, 1, 2048, input)) > 0) {
- fwrite(fbuf, 1, size, output_idx);
- }
- fclose(input);
- fclose(output_idx);
-
- /* And some clean-up :-) */
- unlink(TEMP_IDX);
- unlink(TEMP_DAT);
- unlink(TEMP_RAW);
- unlink(tempEncoded);
- unlink(TEMP_WAV);
-
- exit(0);
-}
-
-
-static int get_offsets(uint32 filenums[], uint32 offsets[])
-{
- int i;
- char buf[8];
-
- for (i = 0;; i++) {
- fread(buf, 1, 8, input);
- if (!memcmp(buf, "Creative", 8) || !memcmp(buf, "RIFF", 4)) {
- return i;
- }
- fseek(input, -8, SEEK_CUR);
-
- offsets[i] = readUint32LE(input);
- }
-}
-
-static int get_offsets_mac(uint32 filenums[], uint32 offsets[])
-{
- int i, size;
- fseek(input, 0, SEEK_END);
- size = ftell(input);
- fseek(input, 0, SEEK_SET);
-
- for (i = 1; i <= size / 6; i++) {
- filenums[i] = readUint16BE(input);
- offsets[i] = readUint32BE(input);
- }
- return(size/6);
-}
-
-
-static uint32 get_sound(uint32 offset)
-{
- FILE *f;
- uint32 tot_size;
- char outname[256];
- int size;
- char fbuf[2048];
- char buf[8];
-
- fseek(input, offset, SEEK_SET);
-
- fread(buf, 1, 8, input);
- if (!memcmp(buf, "Creative", 8)) {
- printf("VOC found (pos = %d) :\n", offset);
- fseek(input, 18, SEEK_CUR);
- extractAndEncodeVOC(TEMP_RAW, input, gCompMode);
- } else if (!memcmp(buf, "RIFF", 4)) {
- printf("WAV found (pos = %d) :\n", offset);
- extractAndEncodeWAV(TEMP_WAV, input, gCompMode);
- } else {
- error("Unexpected data at offset: %d", offset);
- }
-
- /* Append the converted data to the master output file */
- sprintf(outname, tempEncoded);
- f = fopen(outname, "rb");
- tot_size = 0;
- while ((size = fread(fbuf, 1, 2048, f)) > 0) {
- tot_size += size;
- fwrite(fbuf, 1, size, output_snd);
- }
- fclose(f);
-
- return(tot_size);
-}
-
-void showhelp(char *exename)
-{
- printf("\nUsage: %s <params> [<file> | mac]\n", exename);
-
- printf("\nParams:\n");
- printf(" --mp3 encode to MP3 format (default)\n");
- printf(" --vorbis encode to Vorbis format\n");
- printf(" --flac encode to Flac format\n");
- printf("(If one of these is specified, it must be the first parameter.)\n");
-
- printf("\nMP3 mode params:\n");
- printf(" -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
- printf(" -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
- printf(" --vbr LAME uses the VBR mode (default)\n");
- printf(" --abr LAME uses the ABR mode\n");
- printf(" -V <value> specifies the value (0 - 9) of VBR quality (0=best) (default:%d)\n", vbrqualDef);
- printf(" -q <value> specifies the MPEG algorithm quality (0-9; 0=best) (default:%d)\n", algqualDef);
- printf(" --silent the output of LAME is hidden (default:disabled)\n");
-
- printf("\nVorbis mode params:\n");
- printf(" -b <rate> <rate> is the nominal bitrate (default:unset)\n");
- printf(" -m <rate> <rate> is the minimum bitrate (default:unset)\n");
- printf(" -M <rate> <rate> is the maximum bitrate (default:unset)\n");
- printf(" -q <value> specifies the value (0 - 10) of VBR quality (10=best) (default:%d)\n", oggqualDef);
- printf(" --silent the output of oggenc is hidden (default:disabled)\n");
-
- printf("\nFlac mode params:\n");
- printf(" [params] optional arguments passed directly to the encoder\n");
- printf(" recommended is: --best -b 1152\n");
-
- printf("\n --help this help message\n");
-
- printf("\n\nIf a parameter is not given the default value is used\n");
- printf("If using VBR mode for MP3 -b and -B must be multiples of 8; the maximum is 160!\n");
- printf("Use the `mac' option instead of a filename if converting simon2mac sounds\n");
- exit(2);
-}
-
-
-static void convert_pc(char *infile)
-{
- int i, size, num;
- uint32 filenums[32768];
- uint32 offsets[32768];
- char *p;
-
- p = strrchr(infile, '/');
- if (!p) {
- p = strrchr(infile, '\\');
- if (!p) {
- p = infile - 1;
- }
- }
- strcpy(infile_base, p + 1);
- p = strrchr(infile_base, '.');
- if (p) {
- *p = '\0';
- }
-
- input = fopen(infile, "rb");
- if (!input) {
- printf("Cannot open file: %s\n", infile);
- exit(-1);
- }
-
- output_idx = fopen(TEMP_IDX, "wb");
- if (!output_idx) {
- printf("Can't open file " TEMP_IDX " for write!\n" );
- exit(-1);
- }
-
- output_snd = fopen(TEMP_DAT, "wb");
- if (!output_snd) {
- printf("Can't open file " TEMP_DAT " for write!\n" );
- exit(-1);
- }
-
- num = get_offsets(filenums, offsets);
-
- if (!num) {
- printf("This does not seem to be a valid file\n");
- exit(-1);
- }
- size = num*4;
-
- writeUint32LE(output_idx, 0);
- writeUint32LE(output_idx, size);
-
- for (i = 1; i < num; i++) {
- if (offsets[i] == offsets[i+1]) {
- writeUint32LE(output_idx, size);
- continue;
- }
-
- if (offsets[i] != 0)
- size += get_sound(offsets[i]);
- if (i < num - 1)
- writeUint32LE(output_idx, size);
- }
-}
-
-static void convert_mac(void)
-{
- int i, size, num;
- char tmp[256];
- uint32 filenums[32768];
- uint32 offsets[32768];
-
- sprintf(infile_base, "simon2");
-
- input = fopen("voices.idx", "rb");
- if (!input) {
- printf("Cannot open file: %s\n", "voices.idx");
- exit(-1);
- }
-
- output_idx = fopen(TEMP_IDX, "wb");
- if (!output_idx) {
- printf("Can't open file " TEMP_IDX " for write!\n" );
- exit(-1);
- }
-
- output_snd = fopen(TEMP_DAT, "wb");
- if (!output_snd) {
- printf("Can't open file " TEMP_DAT " for write!\n" );
- exit(-1);
- }
-
- num = get_offsets_mac(filenums, offsets);
-
- if (!num) {
- printf("This does not seem to be a valid file\n");
- exit(-1);
- }
- size = num*4;
-
- writeUint32LE(output_idx, 0);
- writeUint32LE(output_idx, size);
-
- for (i = 1; i < num; i++) {
- if (filenums[i] == filenums[i+1] && offsets[i] == offsets[i+1]) {
- writeUint32LE(output_idx, size);
- continue;
- }
-
- if (filenums[i] != filenums[i-1]) {
- sprintf(tmp, "voices%d.dat", filenums[i]);
- if (input)
- fclose(input);
- input = fopen(tmp, "rb");
- if (!input) {
- printf("Cannot open file: %s\n", tmp);
- exit(-1);
- }
- }
-
- size += get_sound(offsets[i]);
- if (i < num - 1)
- writeUint32LE(output_idx, size);
- }
-}
-
-int main(int argc, char *argv[])
-{
- int i;
-
- if (argc < 2)
- showhelp(argv[0]);
-
- /* compression mode */
- gCompMode = kMP3Mode;
- i = 1;
- if (strcmp(argv[1], "--mp3") == 0) {
- gCompMode = kMP3Mode;
- i++;
- }
- else if (strcmp(argv[1], "--vorbis") == 0) {
- gCompMode = kVorbisMode;
- i++;
- }
- else if (strcmp(argv[1], "--flac") == 0) {
- gCompMode = kFlacMode;
- i++;
- }
-
- switch (gCompMode) {
- case kMP3Mode:
- tempEncoded = TEMP_MP3;
- if (!process_mp3_parms(argc, argv, i))
- showhelp(argv[0]);
- break;
- case kVorbisMode:
- tempEncoded = TEMP_OGG;
- if (!process_ogg_parms(argc, argv, i))
- showhelp(argv[0]);
- break;
- case kFlacMode:
- tempEncoded = TEMP_FLAC;
- if (!process_flac_parms(argc, argv, i))
- showhelp(argv[0]);
- break;
- }
-
- i = argc - 1;
-
- if (strcmp(argv[i], "mac") == 0) {
- convert_mac();
- } else {
- convert_pc(argv[i]);
- }
-
- end();
-
- return(0);
-}
-
Deleted: tools/branches/gsoc2007-decompiler/compress_kyra.cpp
===================================================================
--- tools/branches/gsoc2007-decompiler/compress_kyra.cpp 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress_kyra.cpp 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,174 +0,0 @@
-/* compress_kyra_bun - compressor for kyra sound file packages
- * Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "compress.h"
-#include "kyra_pak.h"
-
-static void showhelp(const char *exename);
-static void process(const char *infile, const char *output);
-
-#define OUTPUT_MP3 ".VO3"
-#define OUTPUT_OGG ".VOG"
-#define OUTPUT_FLAC ".VOF"
-
-#define TEMPFILE "TEMP.VOC"
-
-const char *outputExt = 0;
-static CompressMode gCompMode = kMP3Mode;
-
-int main(int argc, char *argv[]) {
- if (argc < 3)
- showhelp(argv[0]);
-
- int i = 0;
- /* Compression mode */
- gCompMode = kMP3Mode;
- i = 1;
- if (strcmp(argv[1], "--mp3") == 0) {
- gCompMode = kMP3Mode;
- i++;
- }
- else if (strcmp(argv[1], "--vorbis") == 0) {
- gCompMode = kVorbisMode;
- i++;
- }
- else if (strcmp(argv[1], "--flac") == 0) {
- gCompMode = kFlacMode;
- i++;
- }
-
- switch (gCompMode) {
- case kMP3Mode:
- outputExt = OUTPUT_MP3;
- tempEncoded = TEMP_MP3;
- if (!process_mp3_parms(argc - 1, argv, i))
- showhelp(argv[0]);
- break;
- case kVorbisMode:
- outputExt = OUTPUT_OGG;
- tempEncoded = TEMP_OGG;
- if (!process_ogg_parms(argc - 1, argv, i))
- showhelp(argv[0]);
- break;
- case kFlacMode:
- outputExt = OUTPUT_FLAC;
- tempEncoded = TEMP_FLAC;
- if (!process_flac_parms(argc - 1, argv, i))
- showhelp(argv[0]);
- break;
- }
-
- if (scumm_stricmp(argv[argc - 2], argv[argc - 1]) == 0)
- error("infile and outfile are the same file");
- process(argv[argc - 2], argv[argc - 1]);
- return 0;
-}
-
-static void showhelp(const char *exename) {
- printf("\nUsage: %s <params> infile outfile\n", exename);
-
- printf("\nParams:\n");
- printf(" --mp3 encode to MP3 format (default)\n");
- printf(" --vorbis encode to Vorbis format\n");
- printf(" --flac encode to Flac format\n");
- printf("(If one of these is specified, it must be the first parameter.)\n");
-
- printf("\nMP3 mode params:\n");
- printf(" -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
- printf(" -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
- printf(" --vbr LAME uses the VBR mode (default)\n");
- printf(" --abr LAME uses the ABR mode\n");
- printf(" -V <value> specifies the value (0 - 9) of VBR quality (0=best) (default:%d)\n", vbrqualDef);
- printf(" -q <value> specifies the MPEG algorithm quality (0-9; 0=best) (default:%d)\n", algqualDef);
- printf(" --silent the output of LAME is hidden (default:disabled)\n");
-
- printf("\nVorbis mode params:\n");
- printf(" -b <rate> <rate> is the nominal bitrate (default:unset)\n");
- printf(" -m <rate> <rate> is the minimum bitrate (default:unset)\n");
- printf(" -M <rate> <rate> is the maximum bitrate (default:unset)\n");
- printf(" -q <value> specifies the value (0 - 10) of VBR quality (10=best) (default:%d)\n", oggqualDef);
- printf(" --silent the output of oggenc is hidden (default:disabled)\n");
-
- printf("\nFlac mode params:\n");
- printf(" [params] optional arguments passed directly to the encoder\n");
- printf(" recommended is: --best -b 1152\n");
-
- printf("\n --help this help message\n");
-
- printf("\n\nIf a parameter is not given the default value is used\n");
- printf("If using VBR mode for MP3 -b and -B must be multiples of 8; the maximum is 160!\n");
-
- exit(2);
-}
-
-static bool hasSuffix(const char *str, const char *suf) {
- const int sufSize = strlen(suf);
- int off = strlen(str);
- if (off < sufSize)
- return false;
- off -= sufSize;
- printf("'%s'\n", &str[off]);
- return (scumm_stricmp(&str[off], suf) == 0);
-}
-
-static void process(const char *infile, const char *outfile) {
- PAKFile input, output;
- if (!input.loadFile(infile, false))
- return;
- if (!output.loadFile(0, false))
- return;
-
- PAKFile::cFileList *list = input.getFileList();
- char outputName[32];
- for (; list; list = list->next) {
- if (!hasSuffix(list->filename, ".VOC"))
- continue;
-
- if (list->data[26] != 1) {
- warning("broken VOC file '%s' skipping it...", list->filename);
- continue;
- }
-
- input.outputFileAs(list->filename, TEMPFILE);
- strncpy(outputName, list->filename, 32);
-
- FILE *tempFile = fopen(TEMPFILE, "rb");
- fseek(tempFile, 26, SEEK_CUR);
- extractAndEncodeVOC(TEMP_RAW, tempFile, gCompMode);
- fclose(tempFile);
-
- char *vocStart = strstr(outputName, ".VOC");
- for (unsigned int i = 0; i < strlen(outputExt); ++i)
- vocStart[i] = outputExt[i];
- output.addFile(outputName, tempEncoded);
-
- unlink(TEMPFILE);
- unlink(TEMP_RAW);
- unlink(tempEncoded);
- }
-
- if (output.getFileList()) {
- output.saveFile(outfile);
- } else {
- printf("file '%s' doesn't contain any .voc files\n", infile);
- }
-}
Deleted: tools/branches/gsoc2007-decompiler/compress_queen.c
===================================================================
--- tools/branches/gsoc2007-decompiler/compress_queen.c 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress_queen.c 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,402 +0,0 @@
-/* compress_queen - Rebuild QUEEN.1 file to contain Resource Table (and optionally compress sound & speech)
- * Copyright (C) 2003-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "util.h"
-
-static const uint32 QTBL = 'QTBL';
-
-#define INPUT_TBL "queen.tbl"
-#define FINAL_OUT "queen.1c"
-
-#define TEMP_DAT "tempfile.dat"
-#define TEMP_TBL "tempfile.tbl"
-#define TEMP_SB "tempfile.sb"
-
-#define TEMP_MP3 "tempfile.mp3"
-#define TEMP_OGG "tempfile.ogg"
-#define TEMP_FLAC "tempfile.fla"
-
-const char *tempEncoded;
-
-#define CURRENT_TBL_VERSION 2
-#define EXTRA_TBL_HEADER 8
-#define SB_HEADER_SIZE_V104 110
-#define SB_HEADER_SIZE_V110 122
-
-
-enum {
- COMPRESSION_NONE = 0,
- COMPRESSION_MP3 = 1,
- COMPRESSION_OGG = 2,
- COMPRESSION_FLAC = 3
-};
-
-enum {
- VER_ENG_FLOPPY = 0,
- VER_ENG_TALKIE = 1,
- VER_FRE_FLOPPY = 2,
- VER_FRE_TALKIE = 3,
- VER_GER_FLOPPY = 4,
- VER_GER_TALKIE = 5,
- VER_ITA_FLOPPY = 6,
- VER_ITA_TALKIE = 7,
- VER_SPA_TALKIE = 8,
- VER_HEB_TALKIE = 9,
- VER_DEMO_PCGAMES = 10,
- VER_DEMO = 11,
- VER_INTERVIEW = 12,
- VER_AMI_ENG_FLOPPY = 13,
- VER_AMI_DEMO = 14,
- VER_AMI_INTERVIEW = 15,
-
- VER_PC_COUNT = 13 /* PC versions */
-};
-
-struct GameVersion {
- char versionString[6];
- uint8 isFloppy;
- uint8 isDemo;
- uint32 tableOffset;
- uint32 dataFileSize;
-};
-
-struct {
- char filename[13];
- uint8 bundle;
- uint32 offset;
- uint32 size;
-} entry;
-
-struct {
- uint8 compression;
- uint16 entries;
-} versionExtra;
-
-struct PatchFile {
- const char *filename;
- char lang;
-};
-
-const struct GameVersion gameVersions[] = {
- { "PEM10", 1, 0, 0x00000008, 22677657 },
- { "CEM10", 0, 0, 0x0000584E, 190787021 },
- { "PFM10", 1, 0, 0x0002CD93, 22157304 },
- { "CFM10", 0, 0, 0x00032585, 186689095 },
- { "PGM10", 1, 0, 0x00059ACA, 22240013 },
- { "CGM10", 0, 0, 0x0005F2A7, 217648975 },
- { "PIM10", 1, 0, 0x000866B1, 22461366 },
- { "CIM10", 0, 0, 0x0008BEE2, 190795582 },
- { "CSM10", 0, 0, 0x000B343C, 190730602 },
- { "CHM10", 0, 0, 0x000DA981, 190705558 },
- { "PE100", 1, 1, 0x00101EC6, 3724538 },
- { "PE100", 1, 1, 0x00102B7F, 3732177 },
- { "PEint", 1, 1, 0x00103838, 1915913 },
- { "aEM10", 1, 0, 0x00103F1E, 351775 },
- { "CE101", 1, 1, 0x00107D8D, 563335 },
- { "PE100", 1, 1, 0x001086D4, 597032 }
-};
-
-const struct PatchFile patchFiles[] = {
- { "CHIEF1.DOG", 'F' },
- { "CHIEF2.DOG", 'F' },
- { "BUD1.DOG", 'I' }
-};
-
-const struct GameVersion *version;
-
-
-void showhelp(char *exename)
-{
- printf("\nUsage: %s [--mp3/--vorbis/--flac <args>] queen.1\n", exename);
- printf("\nParams:\n");
- printf(" --mp3 <args> encode to MP3 format\n");
- printf(" --vorbis <args> encode to Ogg Vorbis Format\n");
- printf(" --flac <args> encode to Flac Format\n");
- printf(" (Optional: <args> are passed on to the encoder)\n");
- printf("\nExample: %s --mp3 -q 5 queen.1\n", exename);
- exit(2);
-}
-
-const struct GameVersion *detectGameVersion(uint32 size) {
- const struct GameVersion *pgv = gameVersions;
- int i;
- /* Compressing/rebuiling an Amiga version is not supported */
- for (i = 0; i < VER_PC_COUNT; ++i, ++pgv) {
- if (pgv->dataFileSize == size) {
- return pgv;
- }
- }
- printf("Unknown/unsupported FOTAQ version!\n");
- exit(1);
- return NULL;
-}
-
-void checkOpen(FILE *fp, const char *filename) {
- if (!fp) {
- printf("Cannot open file: %s\n", filename);
- exit(-1);
- }
-}
-
-void fromFileToFile(FILE *in, FILE *out, uint32 amount) {
- char fBuf[2048];
- uint32 numRead;
- while (amount > 0) {
- numRead = fread(fBuf, 1, amount > 2048 ? 2048 : amount, in);
- if (numRead <= 0)
- break;
- amount -= numRead;
- fwrite(fBuf, 1, numRead, out);
- }
-}
-
-void createFinalFile(void) {
- FILE *inTbl, *inData, *outFinal;
- int i;
- uint32 dataStartOffset;
- uint32 dataSize;
-
- inTbl = fopen(TEMP_TBL, "rb");
- checkOpen(inTbl, TEMP_TBL);
- inData = fopen(TEMP_DAT, "rb");
- checkOpen(inData, TEMP_DAT);
- outFinal = fopen(FINAL_OUT, "wb");
- checkOpen(outFinal, FINAL_OUT);
-
- dataStartOffset = fileSize(inTbl) + EXTRA_TBL_HEADER;
- dataSize = fileSize(inData);
-
- fseek(inTbl, 7, SEEK_SET); /* Skip past header */
-
- /* Write new header */
- writeUint32BE(outFinal, QTBL);
- fwrite(version->versionString, 6, 1, outFinal);
- writeByte(outFinal, version->isFloppy);
- writeByte(outFinal, version->isDemo);
- writeByte(outFinal, versionExtra.compression);
- writeUint16BE(outFinal, versionExtra.entries);
-
- for (i = 0; i < versionExtra.entries; i++) {
- fromFileToFile(inTbl, outFinal, 12);
- writeByte(outFinal, readByte(inTbl));
- writeUint32BE(outFinal, dataStartOffset + readUint32BE(inTbl));
- writeUint32BE(outFinal, readUint32BE(inTbl));
- }
-
- /* Append contents of temporary datafile to final datafile */
- fromFileToFile(inData, outFinal, dataSize);
-
- fclose(inTbl);
- fclose(inData);
- fclose(outFinal);
-
- /* Cleanup */
- unlink(TEMP_TBL);
- unlink(TEMP_DAT);
-}
-
-int main(int argc, char *argv[])
-{
- FILE *inputData, *inputTbl, *outputTbl, *outputData, *tmpFile, *compFile;
- uint8 compressionType = COMPRESSION_NONE;
- char tmp[5];
- char sysBuf[1024];
- char *ptr = sysBuf;
- int size, i = 1;
- uint32 prevOffset;
-
-
- if (argc < 2)
- showhelp(argv[0]);
-
- if (strcmp(argv[1], "--mp3") == 0) {
- compressionType = COMPRESSION_MP3;
- tempEncoded = TEMP_MP3;
- i++;
- ptr += sprintf(ptr, "lame -r -h -s 11 --bitwidth 8 -m m ");
- for (; i < (argc - 1); i++) {
- /* Append optional encoder arguments */
- ptr += sprintf(ptr, "%s ", argv[i]);
- }
- ptr += sprintf(ptr, "%s %s", TEMP_SB, tempEncoded);
- } else if (strcmp(argv[1], "--vorbis") == 0) {
- compressionType = COMPRESSION_OGG;
- tempEncoded = TEMP_OGG;
- i++;
- ptr += sprintf(ptr, "oggenc -r -B 8 -C 1 -R 11025 %s -o %s ", TEMP_SB, tempEncoded);
- for (; i < (argc - 1); i++) {
- /* Append optional encoder arguments */
- ptr += sprintf(ptr, "%s ", argv[i]);
- }
- } else if (strcmp(argv[1], "--flac") == 0) {
- compressionType = COMPRESSION_FLAC;
- tempEncoded = TEMP_FLAC;
- i++;
- ptr += sprintf(ptr, "flac --force-raw-format --endian=little --sign=unsigned --bps=8 --channels=1 --sample-rate=11025 " );
- ptr += sprintf(ptr, "--no-padding --lax --no-seektable --no-ogg " );
- for (; i < (argc - 1); i++) {
- /* Append optional encoder arguments */
- ptr += sprintf(ptr, "%s ", argv[i]);
- }
-
- ptr += sprintf(ptr, "-o %s %s", tempEncoded, TEMP_SB );
- } else {
- showhelp(argv[0]);
- }
-
- /* Open input file (QUEEN.1) */
- inputData = fopen(argv[argc-1], "rb");
- checkOpen(inputData, argv[argc-1]);
-
- /* Open TBL file (QUEEN.TBL) */
- inputTbl = fopen(INPUT_TBL, "rb");
- checkOpen(inputTbl, INPUT_TBL);
-
- size = fileSize(inputData);
- fread(tmp, 1, 4, inputTbl);
- tmp[4] = '\0';
- if (memcmp(tmp, "QTBL", 4)) {
- printf("Invalid TBL file!\n");
- exit(-1);
- }
-
- if (readUint32BE(inputTbl) != CURRENT_TBL_VERSION) {
- printf("Error: You are using an incorrect (outdated?) version of the queen.tbl file\n");
- exit(1);
- }
- version = detectGameVersion(size);
- fseek(inputTbl, version->tableOffset, SEEK_SET);
-
- versionExtra.compression = compressionType;
- versionExtra.entries = readUint16BE(inputTbl);
-
- outputTbl = fopen(TEMP_TBL, "wb");
- checkOpen(outputTbl, TEMP_TBL);
-
- outputData = fopen(TEMP_DAT, "wb");
- checkOpen(outputData, TEMP_DAT);
-
- /* Write tablefile header */
- writeUint32BE(outputTbl, QTBL);
- writeByte(outputTbl, versionExtra.compression);
- writeUint16BE(outputTbl, versionExtra.entries);
-
- for (i = 0; i < versionExtra.entries; i++) {
- prevOffset = ftell(outputData);
-
- /* Read entry */
- fread(entry.filename, 1, 12, inputTbl);
- entry.filename[12] = '\0';
- entry.bundle = readByte(inputTbl);
- entry.offset = readUint32BE(inputTbl);
- entry.size = readUint32BE(inputTbl);
-
- printf("Processing entry: %s\n", entry.filename);
- fseek(inputData, entry.offset, SEEK_SET);
-
- if (versionExtra.compression && strstr(entry.filename, ".SB")) { /* Do we want to compress? */
- uint16 sbVersion;
- int headerSize;
-
- /* Read in .SB */
- tmpFile = fopen(TEMP_SB, "wb");
- fseek(inputData, entry.offset, SEEK_SET);
-
- fseek(inputData, 2, SEEK_CUR);
- sbVersion = readUint16LE(inputData);
- switch (sbVersion) {
- case 104:
- headerSize = SB_HEADER_SIZE_V104;
- break;
- case 110:
- headerSize = SB_HEADER_SIZE_V110;
- break;
- default:
- warning("Unhandled SB file version %d, defaulting to 104\n", sbVersion);
- headerSize = SB_HEADER_SIZE_V104;
- break;
- }
- fseek(inputData, headerSize - 4, SEEK_CUR);
- entry.size -= headerSize;
-
- fromFileToFile(inputData, tmpFile, entry.size);
- fclose(tmpFile);
-
- /* Invoke encoder */
- if (system(sysBuf)) {
- printf("Got error from encoder. (check your parameters)\n");
- unlink(TEMP_SB);
- exit(-1);
- }
-
- /* Append MP3/OGG to data file */
- compFile = fopen(tempEncoded, "rb");
- entry.size = fileSize(compFile);
- fromFileToFile(compFile, outputData, entry.size);
- fclose(compFile);
-
- /* Delete temporary files */
- unlink(TEMP_SB);
- unlink(tempEncoded);
- } else {
- /* Non .SB file */
- bool patched = false;
- /* Check for external files */
- uint8 j;
- for (j = 0; j < ARRAYSIZE(patchFiles); ++j) {
- const struct PatchFile *pf = &patchFiles[j];
- if (version->versionString[1] == pf->lang && strcmp(pf->filename, entry.filename) == 0) {
- /* XXX patched data files are supposed to be in cwd */
- FILE *fpPatch = fopen(pf->filename, "rb");
- if (fpPatch) {
- entry.size = fileSize(fpPatch);
- printf("Patching entry, new size = %d bytes\n", entry.size);
- fromFileToFile(fpPatch, outputData, entry.size);
- fclose(fpPatch);
- patched = true;
- }
- break;
- }
- }
- if (!patched) {
- fromFileToFile(inputData, outputData, entry.size);
- }
- }
-
- /* Write entry to table */
- fwrite(entry.filename, 12, 1, outputTbl);
- writeByte(outputTbl, entry.bundle);
- writeUint32BE(outputTbl, prevOffset);
- writeUint32BE(outputTbl, entry.size);
- }
-
- /* Close files */
- fclose(outputTbl);
- fclose(outputData);
- fclose(inputTbl);
- fclose(inputData);
-
- /* Merge the temporary table and temporary datafile to create final file */
- createFinalFile();
-
- return 0;
-}
Deleted: tools/branches/gsoc2007-decompiler/compress_saga.cpp
===================================================================
--- tools/branches/gsoc2007-decompiler/compress_saga.cpp 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress_saga.cpp 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,427 +0,0 @@
-/* compress_saga - Compress SAGA engine digital sound files into
- * MP3 and Ogg Vorbis format
- * Copyright (C) 2004, Marcoen Hirschberg
- * Copyright (C) 2004-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include <stdio.h>
-#include "compress.h"
-#include "utils/md5.h"
-#include "utils/util.h"
-#include "utils/audiostream.h"
-#include "utils/file.h"
-#include "utils/voc.h"
-#include "utils/wave.h"
-#include "utils/adpcm.h"
-
-
-#include "sagagame.h"
-#include "sagaresnames.h"
-#include "sagagame.cpp"
-
-typedef struct {
- uint32 offset;
- uint32 size;
-} Record;
-
-static CompressMode gCompMode = kMP3Mode;
-
-GameDescription *currentGameDescription = NULL;
-int currentFileIndex = -1;
-bool isBigEndian = false;
-
-bool detectFile(const char *inFileName) {
- int gamesCount = ARRAYSIZE(gameDescriptions);
- int j,i;
- uint8 md5sum[16];
- char md5str[32+1];
-
- Common::md5_file(inFileName, md5sum, FILE_MD5_BYTES);
- printf("Input file name: %s\n", inFileName);
- for (j = 0; j < 16; j++) {
- sprintf(md5str + j*2, "%02x", (int)md5sum[j]);
- }
- printf("md5: %s\n", md5str);
-
- for (i = 0; i < gamesCount; i++) {
- for (j = 0; j < gameDescriptions[i].filesCount; j++) {
- if (strcmp(gameDescriptions[i].filesDescriptions[j].md5, md5str) == 0) {
- if ((gameDescriptions[i].filesDescriptions[j].fileType & (GAME_VOICEFILE | GAME_SOUNDFILE | GAME_MUSICFILE)) != 0)
- {
- currentGameDescription = &gameDescriptions[i];
- currentFileIndex = j;
- printf("Matched game: %s %s\n", currentGameDescription->name, currentGameDescription->extra);
- return true;
- }
- }
- }
- }
- printf("unsupported file\n");
- return false;
-}
-
-uint32 copyFile(const char *fromFileName, FILE* outputFile) {
- uint32 size;
- char fbuf[2048];
- FILE * tempf;
-
- tempf = fopen(fromFileName, "rb");
- if (tempf == NULL)
- error("unable to open %s\n", fromFileName);
-
- while ((size = (uint32)fread(fbuf, 1, sizeof(fbuf), tempf)) > 0) {
- fwrite(fbuf, 1, size, outputFile);
- }
- size = ftell(tempf);
- fclose(tempf);
- return size;
-}
-
-void copyFile(FILE* inputFile, uint32 inputSize, const char* toFileName) {
- uint32 size;
- char fbuf[2048];
- FILE * tempf;
-
- tempf = fopen(toFileName, "wb");
- if (tempf == NULL)
- error("unable to open %s\n", toFileName);
- while (inputSize > 0) {
- size = (uint32)fread(fbuf, 1, inputSize > sizeof(fbuf) ? sizeof(fbuf) : inputSize, inputFile);
- if (size == 0) {
- error("unable to copy file");
- }
- fwrite(fbuf, 1, size, tempf);
- inputSize -= size;
- }
- fclose(tempf);
-}
-
-void writeBufferToFile(uint8* data, uint32 inputSize, const char* toFileName) {
- FILE * tempf;
-
- tempf = fopen(toFileName, "wb");
- if (tempf == NULL)
- error("unable to open %s\n", toFileName);
- fwrite(data, 1, inputSize, tempf);
- fclose(tempf);
-}
-
-#define HEADER_SIZE 9
-
-uint16 sampleRate;
-uint32 sampleSize;
-uint8 sampleBits;
-uint8 sampleStereo;
-
-void writeHeader(FILE* outputFile) {
- writeByte(outputFile, gCompMode);
- writeUint16LE(outputFile, sampleRate);
- writeUint32LE(outputFile, sampleSize);
- writeByte(outputFile, sampleBits);
- writeByte(outputFile, sampleStereo);
-}
-/*
-case kSoundVOX:
- buffer.frequency = soundInfo->frequency;
- buffer.isSigned = soundInfo->isSigned;
- buffer.sampleBits = soundInfo->sampleBits;
- buffer.stereo = soundInfo->stereo;
- buffer.size = soundResourceLength * 4;
- if (onlyHeader) {
- buffer.buffer = NULL;
- free(soundResource);
- } else {
- voxStream = Audio::makeADPCMStream(&readS, soundResourceLength, Audio::kADPCMOki);
- buffer.buffer = (byte *)malloc(buffer.size);
- voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
- if (voxSize != soundResourceLength * 2) {
- error("SndRes::load() wrong VOX output size");
- }
- delete voxStream;
- }
- result = true;
- break;
-*/
-uint32 encodeEntry(GameSoundInfo *soundInfo, FILE* inputFile, uint32 inputSize, FILE* outputFile) {
- Audio::AudioStream *inStream;
- uint8 *inputData;
- Common::File inputFileStream(inputFile);
- int rate, size;
- byte flags;
-
- if (soundInfo->resourceType == kSoundVOX) {
- sampleSize = inputSize * 4;
- sampleRate = (uint16)soundInfo->frequency;
- sampleBits = soundInfo->sampleBits;
- sampleStereo = soundInfo->stereo;
- writeHeader(outputFile);
-
- inStream = Audio::makeADPCMStream(&inputFileStream, inputSize, Audio::kADPCMOki);
- inputData = (byte *)malloc(sampleSize);
- inStream->readBuffer((int16*)inputData, inputSize * 2);
- delete inStream;
- writeBufferToFile(inputData, sampleSize, TEMP_RAW);
- free(inputData);
-
- setRawAudioType( true, sampleStereo != 0, sampleBits);
- encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
- return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
- }
- if (soundInfo->resourceType == kSoundVOC) {
- inputData = Audio::loadVOCFromStream(inputFileStream, size, rate);
- sampleSize = size;
- sampleRate = rate;
- sampleBits = 8;
- sampleStereo = 0;
- writeBufferToFile(inputData, sampleSize, TEMP_RAW);
- free(inputData);
- writeHeader(outputFile);
-
- setRawAudioType( true, false, 8);
- encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
- return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
- }
- if (soundInfo->resourceType == kSoundPCM) {
- copyFile(inputFile, inputSize, TEMP_RAW);
- sampleSize = inputSize;
- sampleRate = (uint16)soundInfo->frequency;
- sampleBits = soundInfo->sampleBits;
- sampleStereo = soundInfo->stereo;
- writeHeader(outputFile);
-
- setRawAudioType( !soundInfo->isBigEndian, soundInfo->stereo, soundInfo->sampleBits);
- encodeAudio(TEMP_RAW, true, soundInfo->frequency, tempEncoded, gCompMode);
- return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
- }
- if (soundInfo->resourceType == kSoundWAV) {
- if (!Audio::loadWAVFromStream(inputFileStream, size, rate, flags))
- error("Unable to read WAV");
-
- sampleSize = size;
- sampleRate = rate;
- sampleBits = ((flags & Audio::Mixer::FLAG_16BITS) != 0) ? 16 : 8;
- sampleStereo = ((flags & Audio::Mixer::FLAG_STEREO) != 0);
- writeHeader(outputFile);
-
- copyFile(inputFile, size, TEMP_RAW);
-
- setRawAudioType( true, sampleStereo != 0, sampleBits);
- encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
- return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
- }
-
- error("sorry - unsupported resourceType %ul\n", soundInfo->resourceType);
-}
-
-#define RSC_TABLEINFO_SIZE 8
-#define RSC_TABLEENTRY_SIZE 8
-
-void sagaEncode(const char *inputFileName) {
- FILE *inputFile;
- FILE *outputFile;
- uint32 inputFileSize;
- uint32 resTableOffset;
- uint32 resTableCount;
- uint32 i;
-
- Record *inputTable;
- Record *outputTable;
- GameFileDescription *currentFileDescription;
- GameSoundInfo *soundInfo;
-
- currentFileDescription = ¤tGameDescription->filesDescriptions[currentFileIndex];
-
- isBigEndian = ((currentGameDescription->features & GF_BIG_ENDIAN_DATA) != 0);
-
- if (currentFileDescription->fileType & GAME_SWAPENDIAN)
- isBigEndian = !isBigEndian;
- ///isBigEndian = false;
-
- inputFile = fopen(inputFileName, "rb");
- inputFileSize = fileSize(inputFile);
- printf("filesize: %ul\n", inputFileSize);
- /*
- * At the end of the resource file there are 2 values: one points to the
- * beginning of the resource table the other gives the number of
- * records in the table
- */
- fseek(inputFile, inputFileSize - RSC_TABLEINFO_SIZE, SEEK_SET);
-
- if (!isBigEndian) {
- resTableOffset = readUint32LE(inputFile);
- resTableCount = readUint32LE(inputFile);
- } else {
- resTableOffset = readUint32BE(inputFile);
- resTableCount = readUint32BE(inputFile);
- }
-
- printf("table offset: %ul\nnumber of records: %ul\n", resTableOffset, resTableCount);
- if (resTableOffset != inputFileSize - RSC_TABLEINFO_SIZE - RSC_TABLEENTRY_SIZE * resTableCount) {
- error("Something's wrong with your resource file..\n");
- }
-
- // Go to beginning of the table
- fseek(inputFile, resTableOffset, SEEK_SET);
-
- inputTable = (Record*)malloc(resTableCount * sizeof(Record));
-
- // Put offsets of all the records in a table
- for (i = 0; i < resTableCount; i++) {
-
- if (!isBigEndian) {
- inputTable[i].offset = readUint32LE(inputFile);
- inputTable[i].size = readUint32LE(inputFile);
- } else {
- inputTable[i].offset = readUint32BE(inputFile);
- inputTable[i].size = readUint32BE(inputFile);
- }
-
- printf("record: %ul, offset: %ul, size: %ul\n", i, inputTable[i].offset, inputTable[i].size);
-
- if ((inputTable[i].offset > inputFileSize) ||
- (inputTable[i].offset + inputTable[i].size > inputFileSize)) {
- error("The offset points outside the file!");
- }
-
- }
- outputTable = (Record*)malloc(resTableCount * sizeof(Record));
-
- outputFile = fopen("out.res", "wb");
-
- for (i = 0; i < resTableCount; i++) {
- fseek(inputFile, inputTable[i].offset, SEEK_SET);
- outputTable[i].offset = ftell(outputFile);
-
- if ((currentFileDescription->fileType & GAME_VOICEFILE) != 0) {
- soundInfo = currentGameDescription->voiceInfo;
- } else {
- if ((currentFileDescription->fileType & GAME_SOUNDFILE) != 0) {
- soundInfo = currentGameDescription->sfxInfo;
- } else {
- if ((currentFileDescription->fileType & GAME_MUSICFILE) != 0) {
- soundInfo = currentGameDescription->musicInfo;
- }
- }
- }
-
- outputTable[i].size = encodeEntry(soundInfo, inputFile, inputTable[i].size, outputFile);
- }
- fclose(inputFile);
-
- resTableOffset = ftell(outputFile);
- for (i = 0; i < resTableCount; i++) {
- writeUint32LE(outputFile, outputTable[i].offset);
- writeUint32LE(outputFile, outputTable[i].size);
- }
- writeUint32LE(outputFile, resTableOffset);
- writeUint32LE(outputFile, resTableCount); // Should be the same number of entries
-
- fclose(outputFile);
-
- free(inputTable);
- free(outputTable);
-
-
- printf("Done!\n");
-}
-
-void showhelp(char *exename) {
- printf("\nUsage: %s <params> [<file> | mac]\n", exename);
-
- printf("\nParams:\n");
-
- printf("--mp3 encode to MP3 format (default)\n");
- printf("--vorbis encode to Vorbis format\n");
- printf("--flac encode to Flac format\n");
- printf("(If one of these is specified, it must be the first parameter.)\n");
-
- printf("\nMP3 mode params:\n");
- printf("-b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
- printf("-B <rate> <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
- printf("--vbr LAME uses the VBR mode (default)\n");
- printf("--abr LAME uses the ABR mode\n");
- printf("-V <value> specifies the value (0 - 9) of VBR quality (0=best) (default:%d)\n", vbrqualDef);
- printf("-q <value> specifies the MPEG algorithm quality (0-9; 0=best) (default:%d)\n", algqualDef);
- printf("--silent the output of LAME is hidden (default:disabled)\n");
-
- printf("\nVorbis mode params:\n");
- printf("-b <rate> <rate> is the nominal bitrate (default:unset)\n");
- printf("-m <rate> <rate> is the minimum bitrate (default:unset)\n");
- printf("-M <rate> <rate> is the maximum bitrate (default:unset)\n");
- printf("-q <value> specifies the value (0 - 10) of VBR quality (10=best) (default:%d)\n", oggqualDef);
- printf("--silent the output of oggenc is hidden (default:disabled)\n");
-
- printf("\nFlac mode params:\n");
- printf("[params] optional Arguments passed to the Encoder\n");
- printf(" recommended is: --best -b 1152\n");
-
- printf("\n--help this help message\n");
-
- printf("\n\nIf a parameter is not given the default value is used\n");
- printf("If using VBR mode for MP3 -b and -B must be multiples of 8; the maximum is 160!\n");
- exit(2);
-}
-
-int main(int argc, char *argv[]) {
- int i;
- char *inputFileName;
-
- if (argc < 2)
- showhelp(argv[0]);
-
- /* compression mode */
- gCompMode = kMP3Mode;
- i = 1;
- if (strcmp(argv[1], "--mp3") == 0) {
- gCompMode = kMP3Mode;
- i++;
- } else if (strcmp(argv[1], "--vorbis") == 0) {
- gCompMode = kVorbisMode;
- i++;
- } else if (strcmp(argv[1], "--flac") == 0) {
- gCompMode = kFlacMode;
- i++;
- }
- switch (gCompMode) {
- case kMP3Mode:
- tempEncoded = TEMP_MP3;
- if (!process_mp3_parms(argc, argv, i))
- showhelp(argv[0]);
- break;
- case kVorbisMode:
- tempEncoded = TEMP_OGG;
- if (!process_ogg_parms(argc, argv, i))
- showhelp(argv[0]);
- break;
- case kFlacMode:
- tempEncoded = TEMP_FLAC;
- if (!process_flac_parms(argc, argv, i))
- showhelp(argv[0]);
- break;
- }
-
- i = argc - 1;
- inputFileName = argv[i];
- if (detectFile(inputFileName))
- sagaEncode(inputFileName);
-
- return (0);
-}
Deleted: tools/branches/gsoc2007-decompiler/compress_scumm_bun.cpp
===================================================================
--- tools/branches/gsoc2007-decompiler/compress_scumm_bun.cpp 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress_scumm_bun.cpp 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,1186 +0,0 @@
-/* compress_scumm_bun - compressor for bundle files
- * Copyright (C) 2004-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "compress.h"
-
-/*
- * The "IMC" codec below (see cases 13 & 15 in decompressCodec) is actually a
- * variant of the IMA codec, see also
- * <http://www.multimedia.cx/simpleaudio.html>
- *
- * It is somewhat different, though: the standard ADPCM codecs use a fixed
- * size for their data packets (4 bits), while the codec implemented here
- * varies the size of each "packet" between 2 and 7 bits.
- */
-
-static byte _imcTableEntryBitCount[89];
-
-static const int16 imcTable[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14,
- 16, 17, 19, 21, 23, 25, 28, 31,
- 34, 37, 41, 45, 50, 55, 60, 66,
- 73, 80, 88, 97, 107, 118, 130, 143,
- 157, 173, 190, 209, 230, 253, 279, 307,
- 337, 371, 408, 449, 494, 544, 598, 658,
- 724, 796, 876, 963, 1060, 1166, 1282, 1411,
- 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024,
- 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484,
- 7132, 7845, 8630, 9493,10442,11487,12635,13899,
- 15289,16818,18500,20350,22385,24623,27086,29794,
- 32767
-};
-
-static const byte imxOtherTable[6][64] = {
- {
- 0xFF,
- 4
- },
-
- {
- 0xFF, 0xFF,
- 2, 8
- },
-
- {
- 0xFF, 0xFF, 0xFF, 0xFF,
- 1, 2, 4, 6
- },
-
- {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 1, 2, 4, 6, 8, 12, 16, 32
- },
-
- {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 1, 2, 4, 6, 8, 10, 12, 14,
- 16, 18, 20, 22, 24, 26, 28, 32
- },
-
- {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32
- }
-};
-
-void initializeImcTables() {
- int pos;
-
- for (pos = 0; pos < ARRAYSIZE(imcTable); ++pos) {
- byte put = 0;
- int32 tableValue = ((imcTable[pos] * 4) / 7) / 2;
- while (tableValue != 0) {
- tableValue /= 2;
- put++;
- }
- if (put < 2) {
- put = 2;
- }
- if (put > 7) {
- put = 7;
- }
- _imcTableEntryBitCount[pos] = put;
- }
-}
-
-#define NextBit \
- do { \
- bit = mask & 1; \
- mask >>= 1; \
- if (!--bitsleft) { \
- mask = READ_LE_UINT16(srcptr); \
- srcptr += 2; \
- bitsleft = 16; \
- } \
- } while (0)
-
-static int32 compDecode(byte *src, byte *dst) {
- byte *result, *srcptr = src, *dstptr = dst;
- int data, size, bit, bitsleft = 16, mask = READ_LE_UINT16(srcptr);
- srcptr += 2;
-
- for (;;) {
- NextBit;
- if (bit) {
- *dstptr++ = *srcptr++;
- } else {
- NextBit;
- if (!bit) {
- NextBit;
- size = bit << 1;
- NextBit;
- size = (size | bit) + 3;
- data = *srcptr++ | 0xffffff00;
- } else {
- data = *srcptr++;
- size = *srcptr++;
-
- data |= 0xfffff000 + ((size & 0xf0) << 4);
- size = (size & 0x0f) + 3;
-
- if (size == 3)
- if (((*srcptr++) + 1) == 1)
- return (int32)(dstptr - dst);
- }
- result = dstptr + data;
- while (size--)
- *dstptr++ = *result++;
- }
- }
-}
-#undef NextBit
-
-int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 input_size) {
- int32 output_size, channels;
- int32 offset1, offset2, offset3, length, k, c, s, j, r, t, z;
- byte *src, *t_table, *p, *ptr;
- byte t_tmp1, t_tmp2;
-
- switch (codec) {
- case 0:
- memcpy(comp_output, comp_input, input_size);
- output_size = input_size;
- break;
-
- case 1:
- output_size = compDecode(comp_input, comp_output);
- break;
-
- case 2:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
- break;
-
- case 3:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
- p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
- break;
-
- case 4:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
- p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
-
- t_table = (byte *)malloc(output_size);
- memset(t_table, 0, output_size);
-
- src = comp_output;
- length = (output_size << 3) / 12;
- k = 0;
- if (length > 0) {
- c = -12;
- s = 0;
- j = 0;
- do {
- ptr = src + length + (k >> 1);
- t_tmp2 = src[j];
- if (k & 1) {
- r = c >> 3;
- t_table[r + 2] = ((t_tmp2 & 0x0f) << 4) | (ptr[1] >> 4);
- t_table[r + 1] = (t_tmp2 & 0xf0) | (t_table[r + 1]);
- } else {
- r = s >> 3;
- t_table[r + 0] = ((t_tmp2 & 0x0f) << 4) | (ptr[0] & 0x0f);
- t_table[r + 1] = t_tmp2 >> 4;
- }
- s += 12;
- c += 12;
- k++;
- j++;
- } while (k < length);
- }
- offset1 = ((length - 1) * 3) >> 1;
- t_table[offset1 + 1] = (t_table[offset1 + 1]) | (src[length - 1] & 0xf0);
- memcpy(src, t_table, output_size);
- free(t_table);
- break;
-
- case 5:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
- p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
-
- t_table = (byte *)malloc(output_size);
- memset(t_table, 0, output_size);
-
- src = comp_output;
- length = (output_size << 3) / 12;
- k = 1;
- c = 0;
- s = 12;
- t_table[0] = src[length] >> 4;
- t = length + k;
- j = 1;
- if (t > k) {
- do {
- t_tmp1 = *(src + length + (k >> 1));
- t_tmp2 = src[j - 1];
- if (k & 1) {
- r = c >> 3;
- t_table[r + 0] = (t_tmp2 & 0xf0) | t_table[r];
- t_table[r + 1] = ((t_tmp2 & 0x0f) << 4) | (t_tmp1 & 0x0f);
- } else {
- r = s >> 3;
- t_table[r + 0] = t_tmp2 >> 4;
- t_table[r - 1] = ((t_tmp2 & 0x0f) << 4) | (t_tmp1 >> 4);
- }
- s += 12;
- c += 12;
- k++;
- j++;
- } while (k < t);
- }
- memcpy(src, t_table, output_size);
- free(t_table);
- break;
-
- case 6:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
- p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
-
- t_table = (byte *)malloc(output_size);
- memset(t_table, 0, output_size);
-
- src = comp_output;
- length = (output_size << 3) / 12;
- k = 0;
- c = 0;
- j = 0;
- s = -12;
- t_table[0] = src[output_size - 1];
- t_table[output_size - 1] = src[length - 1];
- t = length - 1;
- if (t > 0) {
- do {
- t_tmp1 = *(src + length + (k >> 1));
- t_tmp2 = src[j];
- if (k & 1) {
- r = s >> 3;
- t_table[r + 2] = (t_tmp2 & 0xf0) | t_table[r + 2];
- t_table[r + 3] = ((t_tmp2 & 0x0f) << 4) | (t_tmp1 >> 4);
- } else {
- r = c >> 3;
- t_table[r + 2] = t_tmp2 >> 4;
- t_table[r + 1] = ((t_tmp2 & 0x0f) << 4) | (t_tmp1 & 0x0f);
- }
- s += 12;
- c += 12;
- k++;
- j++;
- } while (k < t);
- }
- memcpy(src, t_table, output_size);
- free(t_table);
- break;
-
- case 10:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
- p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
-
- t_table = (byte *)malloc(output_size);
- memcpy(t_table, p, output_size);
-
- offset1 = output_size / 3;
- offset2 = offset1 << 1;
- offset3 = offset2;
- src = comp_output;
-
- while (offset1--) {
- offset2 -= 2;
- offset3--;
- t_table[offset2 + 0] = src[offset1];
- t_table[offset2 + 1] = src[offset3];
- }
-
- src = comp_output;
- length = (output_size << 3) / 12;
- k = 0;
- if (length > 0) {
- c = -12;
- s = 0;
- do {
- j = length + (k >> 1);
- t_tmp1 = t_table[k];
- if (k & 1) {
- r = c >> 3;
- t_tmp2 = t_table[j + 1];
- src[r + 2] = ((t_tmp1 & 0x0f) << 4) | (t_tmp2 >> 4);
- src[r + 1] = (src[r + 1]) | (t_tmp1 & 0xf0);
- } else {
- r = s >> 3;
- t_tmp2 = t_table[j];
- src[r + 0] = ((t_tmp1 & 0x0f) << 4) | (t_tmp2 & 0x0f);
- src[r + 1] = t_tmp1 >> 4;
- }
- s += 12;
- c += 12;
- k++;
- } while (k < length);
- }
- offset1 = ((length - 1) * 3) >> 1;
- src[offset1 + 1] = (t_table[length] & 0xf0) | src[offset1 + 1];
- free(t_table);
- break;
-
- case 11:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
- p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
-
- t_table = (byte *)malloc(output_size);
- memcpy(t_table, p, output_size);
-
- offset1 = output_size / 3;
- offset2 = offset1 << 1;
- offset3 = offset2;
- src = comp_output;
-
- while (offset1--) {
- offset2 -= 2;
- offset3--;
- t_table[offset2 + 0] = src[offset1];
- t_table[offset2 + 1] = src[offset3];
- }
-
- src = comp_output;
- length = (output_size << 3) / 12;
- k = 1;
- c = 0;
- s = 12;
- t_tmp1 = t_table[length] >> 4;
- src[0] = t_tmp1;
- t = length + k;
- if (t > k) {
- do {
- j = length + (k >> 1);
- t_tmp1 = t_table[k - 1];
- t_tmp2 = t_table[j];
- if (k & 1) {
- r = c >> 3;
- src[r + 0] = (src[r]) | (t_tmp1 & 0xf0);
- src[r + 1] = ((t_tmp1 & 0x0f) << 4) | (t_tmp2 & 0x0f);
- } else {
- r = s >> 3;
- src[r + 0] = t_tmp1 >> 4;
- src[r - 1] = ((t_tmp1 & 0x0f) << 4) | (t_tmp2 >> 4);
- }
- s += 12;
- c += 12;
- k++;
- } while (k < t);
- }
- free(t_table);
- break;
-
- case 12:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
- p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
- p[z] += p[z - 1];
-
- t_table = (byte *)malloc(output_size);
- memcpy(t_table, p, output_size);
-
- offset1 = output_size / 3;
- offset2 = offset1 << 1;
- offset3 = offset2;
- src = comp_output;
-
- while (offset1--) {
- offset2 -= 2;
- offset3--;
- t_table[offset2 + 0] = src[offset1];
- t_table[offset2 + 1] = src[offset3];
- }
-
- src = comp_output;
- length = (output_size << 3) / 12;
- k = 0;
- c = 0;
- s = -12;
- src[0] = t_table[output_size - 1];
- src[output_size - 1] = t_table[length - 1];
- t = length - 1;
- if (t > 0) {
- do {
- j = length + (k >> 1);
- t_tmp1 = t_table[k];
- t_tmp2 = t_table[j];
- if (k & 1) {
- r = s >> 3;
- src[r + 2] = (src[r + 2]) | (t_tmp1 & 0xf0);
- src[r + 3] = ((t_tmp1 & 0x0f) << 4) | (t_tmp2 >> 4);
- } else {
- r = c >> 3;
- src[r + 2] = t_tmp1 >> 4;
- src[r + 1] = ((t_tmp1 & 0x0f) << 4) | (t_tmp2 & 0x0f);
- }
- s += 12;
- c += 12;
- k++;
- } while (k < t);
- }
- free(t_table);
- break;
-
- case 13:
- case 15:
- if (codec == 13) {
- channels = 1;
- } else {
- channels = 2;
- }
-
- {
- // Decoder for the the IMA ADPCM variants used in COMI.
- // Contrary to regular IMA ADPCM, this codec uses a variable
- // bitsize for the encoded data.
-
- const int MAX_CHANNELS = 2;
- int32 outputSamplesLeft;
- int32 destPos;
- int16 firstWord;
- byte initialTablePos[MAX_CHANNELS] = {0, 0};
- int32 initialimcTableEntry[MAX_CHANNELS] = {7, 7};
- int32 initialOutputWord[MAX_CHANNELS] = {0, 0};
- int32 totalBitOffset, curTablePos, outputWord;
- byte *dst;
- int i;
-
- // We only support mono and stereo
- assert(channels == 1 || channels == 2);
-
- src = comp_input;
- dst = comp_output;
- output_size = 0x2000;
- outputSamplesLeft = 0x1000;
-
- // Every data packet contains 0x2000 bytes of audio data
- // when extracted. In order to encode bigger data sets,
- // one has to split the data into multiple blocks.
- //
- // Every block starts with a 2 byte word. If that word is
- // non-zero, it indicates the size of a block of raw audio
- // data (not encoded) following it. That data we simply copy
- // to the output buffer and the proceed by decoding the
- // remaining data.
- //
- // If on the other hand the word is zero, then what follows
- // are 7*channels bytes containing seed data for the decoder.
- firstWord = READ_BE_UINT16(src);
- src += 2;
- if (firstWord != 0) {
- // Copy raw data
- memcpy(dst, src, firstWord);
- dst += firstWord;
- src += firstWord;
- assert((firstWord & 1) == 0);
- outputSamplesLeft -= firstWord / 2;
- } else {
- // Read the seed values for the decoder.
- for (i = 0; i < channels; i++) {
- initialTablePos[i] = *src;
- src += 1;
- initialimcTableEntry[i] = READ_BE_UINT32(src);
- src += 4;
- initialOutputWord[i] = READ_BE_UINT32(src);
- src += 4;
- }
- }
-
- totalBitOffset = 0;
- // The channels are encoded separately.
- for (int chan = 0; chan < channels; chan++) {
- // Read initial state (this makes it possible for the data stream
- // to be split & spread across multiple data chunks.
- curTablePos = initialTablePos[chan];
- //imcTableEntry = initialimcTableEntry[chan];
- outputWord = initialOutputWord[chan];
-
- // We need to interleave the channels in the output; we achieve
- // that by using a variables dest offset:
- destPos = chan * 2;
-
- const int bound = (channels == 1)
- ? outputSamplesLeft
- : ((chan == 0)
- ? (outputSamplesLeft+1) / 2
- : outputSamplesLeft / 2);
- for (i = 0; i < bound; ++i) {
- // Determine the size (in bits) of the next data packet
- const int32 curTableEntryBitCount = _imcTableEntryBitCount[curTablePos];
- assert(2 <= curTableEntryBitCount && curTableEntryBitCount <= 7);
-
- // Read the next data packet
- const byte *readPos = src + (totalBitOffset >> 3);
- const uint16 readWord = (uint16)(READ_BE_UINT16(readPos) << (totalBitOffset & 7));
- const byte packet = (byte)(readWord >> (16 - curTableEntryBitCount));
-
- // Advance read position to the next data packet
- totalBitOffset += curTableEntryBitCount;
-
- // Decode the data packet into a delta value for the output signal.
- const byte signBitMask = (1 << (curTableEntryBitCount - 1));
- const byte dataBitMask = (signBitMask - 1);
- const byte data = (packet & dataBitMask);
-
- int32 delta = imcTable[curTablePos] * (2 * data + 1) >> (curTableEntryBitCount - 1);
-
- // The topmost bit in the data packet tells is a sign bit
- if ((packet & signBitMask) != 0) {
- delta = -delta;
- }
-
- // Accumulate the delta onto the output data
- outputWord += delta;
-
- // Clip outputWord to 16 bit signed, and write it into the destination stream
- if (outputWord > 0x7fff)
- outputWord = 0x7fff;
- if (outputWord < -0x8000)
- outputWord = -0x8000;
- WRITE_BE_UINT16(dst + destPos, outputWord);
- destPos += channels << 1;
-
- // Adjust the curTablePos
- curTablePos += (int8)imxOtherTable[curTableEntryBitCount - 2][data];
- if (curTablePos < 0)
- curTablePos = 0;
- else if (curTablePos >= ARRAYSIZE(imcTable))
- curTablePos = ARRAYSIZE(imcTable) - 1;
- }
- }
- }
- break;
-
- default:
- printf("decompressCodec() Unknown codec %d!", (int)codec);
- output_size = 0;
- break;
- }
-
- return output_size;
-}
-
-void showhelp(char *exename) {
- printf("\nUsage: %s <inputfile> <inputdir> <outputdir> [--ogg] [encoder params]\n", exename);
- printf("\nMP3 mode params:\n");
- printf(" -b <rate> <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:%d)\n", minBitrDef);
- printf(" -B <rate> <rate> is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef);
- printf(" --vbr LAME uses the VBR mode (default)\n");
- printf(" --abr LAME uses the ABR mode\n");
- printf(" -V <value> specifies the value (0 - 9) of VBR quality (0=best) (default:%d)\n", vbrqualDef);
- printf(" -q <value> specifies the MPEG algorithm quality (0-9; 0=best) (default:%d)\n", algqualDef);
- printf(" --silent the output of LAME is hidden (default:disabled)\n");
-
- printf("\nVorbis mode params:\n");
- printf(" -b <rate> <rate> is the nominal bitrate (default:unset)\n");
- printf(" -m <rate> <rate> is the minimum bitrate (default:unset)\n");
- printf(" -M <rate> <rate> is the maximum bitrate (default:unset)\n");
- printf(" -q <value> specifies the value (0 - 10) of VBR quality (10=best) (default:%d)\n", oggqualDef);
- printf(" --silent the output of oggenc is hidden (default:disabled)\n");
- exit(2);
-}
-
-struct BundleAudioTable {
- char filename[24];
- int size;
- int offset;
-};
-
-static FILE *_waveTmpFile;
-static int32 _waveDataSize;
-static BundleAudioTable *bundleTable;
-static BundleAudioTable cbundleTable[10000]; // difficult to calculate
-static int32 cbundleCurIndex = 0;
-
-void encodeWaveWithOgg(char *filename) {
- char fbuf[2048];
- char fbuf2[2048];
- sprintf(fbuf, "%s.wav", filename);
- sprintf(fbuf2, "%s.ogg", filename);
- encodeAudio(fbuf, false, -1, fbuf2, kVorbisMode);
-}
-
-void encodeWaveWithLame(char *filename) {
- char fbuf[2048];
- char fbuf2[2048];
-
- sprintf(fbuf, "%s.wav", filename);
- sprintf(fbuf2, "%s.mp3", filename);
- encodeAudio(fbuf, false, -1, fbuf2, kMP3Mode);
-}
-
-void writeWaveHeader(int s_size, int rate, int chan) {
- int bits = 16;
- byte wav[44];
- memset(wav, 0, 44);
- wav[0] = 'R';
- wav[1] = 'I';
- wav[2] = 'F';
- wav[3] = 'F';
- wav[4] = (s_size + 36) & 0xff;
- wav[5] = ((s_size + 36) >> 8) & 0xff;
- wav[6] = ((s_size + 36) >> 16) & 0xff;
- wav[7] = ((s_size + 36) >> 24) & 0xff;
- wav[8] = 'W';
- wav[9] = 'A';
- wav[10] = 'V';
- wav[11] = 'E';
- wav[12] = 'f';
- wav[13] = 'm';
- wav[14] = 't';
- wav[15] = 0x20;
- wav[16] = 16;
- wav[20] = 1;
- wav[22] = chan;
- wav[24] = rate & 0xff;
- wav[25] = (rate >> 8) & 0xff;
- wav[26] = (rate >> 16) & 0xff;
- wav[27] = (rate >> 24) & 0xff;
- wav[28] = (rate * chan * (bits / 8)) & 0xff;
- wav[29] = ((rate * chan * (bits / 8))>> 8) & 0xff;
- wav[30] = ((rate * chan * (bits / 8)) >> 16) & 0xff;
- wav[31] = ((rate * chan * (bits / 8)) >> 24) & 0xff;
- wav[32] = (chan * (bits / 8)) & 0xff;
- wav[33] = ((chan * (bits / 8)) >> 8) & 0xff;
- wav[34] = bits;
- wav[36] = 'd';
- wav[37] = 'a';
- wav[38] = 't';
- wav[39] = 'a';
- wav[40] = s_size & 0xff;
- wav[41] = (s_size >> 8) & 0xff;
- wav[42] = (s_size >> 16) & 0xff;
- wav[43] = (s_size >> 24) & 0xff;
-
- fseek(_waveTmpFile, 0, SEEK_SET);
- if (fwrite(wav, 1, 44, _waveTmpFile) != 44) {
- printf("error write temp wave file");
- exit(1);
- }
- fclose(_waveTmpFile);
- _waveTmpFile = NULL;
-}
-
-void writeToTempWave(char *fileName, byte *output_data, unsigned int size) {
- if (!_waveTmpFile) {
- _waveTmpFile = fopen(fileName, "wb");
- if (!_waveTmpFile) {
- printf("error write temp wave file");
- exit(1);
- }
- byte wav[44];
- memset(wav, 0, 44);
- if (fwrite(output_data, 1, 44, _waveTmpFile) != 44) {
- printf("error write temp wave file");
- exit(1);
- }
- _waveDataSize = 0;
- }
- for (unsigned int j = 0; j < size - 1; j += 2) {
- byte tmp = output_data[j + 0];
- output_data[j + 0] = output_data[j + 1];
- output_data[j + 1] = tmp;
- }
- if (fwrite(output_data, 1, size, _waveTmpFile) != size) {
- printf("error write temp wave file");
- exit(1);
- }
- _waveDataSize += size;
-}
-
-static bool _oggMode = false; // mp3 default
-
-typedef struct { int offset, size, codec; } CompTable;
-
-byte *decompressBundleSound(int index, FILE *input, int32 &finalSize) {
- byte compOutput[0x2000];
- int i;
-
- fseek(input, bundleTable[index].offset, SEEK_SET);
-
- uint32 tag = readUint32BE(input);
- assert(tag == 'COMP');
- int numCompItems = readUint32BE(input);
- fseek(input, 8, SEEK_CUR);
-
- CompTable *compTable = (CompTable *)malloc(sizeof(CompTable) * numCompItems);
- int32 maxSize = 0;
- for (i = 0; i < numCompItems; i++) {
- compTable[i].offset = readUint32BE(input);
- compTable[i].size = readUint32BE(input);
- compTable[i].codec = readUint32BE(input);
- fseek(input, 4, SEEK_CUR);
- if (compTable[i].size > maxSize)
- maxSize = compTable[i].size;
- }
- // CMI hack: one more byte at the end of input buffer
- byte *compInput = (byte *)malloc(maxSize + 1);
- byte *compFinal = (byte *)malloc(numCompItems * 0x2000);
-
- finalSize = 0;
-
- for (i = 0; i < numCompItems; i++) {
- compInput[compTable[i].size] = 0;
- fseek(input, bundleTable[index].offset + compTable[i].offset, SEEK_SET);
- fread(compInput, 1, compTable[i].size, input);
- int outputSize = decompressCodec(compTable[i].codec, compInput, compOutput, compTable[i].size);
- assert(outputSize <= 0x2000);
- memcpy(compFinal + finalSize, compOutput, outputSize);
- finalSize += outputSize;
- }
-
- free(compInput);
- free(compTable);
-
- return compFinal;
-}
-
-byte *convertTo16bit(byte *ptr, int inputSize, int &outputSize, int bits, int freq, int channels) {
- outputSize = inputSize;
- if (bits == 8)
- outputSize *= 2;
- if (bits == 12)
- outputSize = (outputSize / 3) * 4;
-
- byte *outputBuf = (byte *)malloc(outputSize);
- if (bits == 8) {
- byte *buf = outputBuf;
- byte *src = ptr;
- for (int i = 0; i < inputSize; i++) {
- uint16 val = (*src++ - 0x80) << 8;
- *buf++ = (byte)(val >> 8);
- *buf++ = (byte)val;
- }
- }
- if (bits == 12) {
- int loop_size = inputSize / 3;
- byte *decoded = outputBuf;
- byte *source = ptr;
- uint32 value;
-
- while (loop_size--) {
- byte v1 = *source++;
- byte v2 = *source++;
- byte v3 = *source++;
- value = ((((v2 & 0x0f) << 8) | v1) << 4) - 0x8000;
- *decoded++ = (byte)((value >> 8) & 0xff);
- *decoded++ = (byte)(value & 0xff);
- value = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
- *decoded++ = (byte)((value >> 8) & 0xff);
- *decoded++ = (byte)(value & 0xff);
- }
- }
- if (bits == 16) {
- int loop_size = inputSize / 2;
- byte *buf = outputBuf;
- byte *src = ptr;
- while (loop_size--) {
- *buf++ = *src++;
- *buf++ = *src++;
- }
- }
-
- return outputBuf;
-}
-
-void countMapElements(byte *ptr, int &numRegions, int &numJumps, int &numSyncs) {
- uint32 tag;
- int32 size = 0;
-
- do {
- tag = READ_BE_UINT32(ptr); ptr += 4;
- switch(tag) {
- case 'TEXT':
- case 'STOP':
- case 'FRMT':
- case 'DATA':
- size = READ_BE_UINT32(ptr); ptr += size + 4;
- break;
- case 'REGN':
- numRegions++;
- size = READ_BE_UINT32(ptr); ptr += size + 4;
- break;
- case 'JUMP':
- numJumps++;
- size = READ_BE_UINT32(ptr); ptr += size + 4;
- break;
- case 'SYNC':
- numSyncs++;
- size = READ_BE_UINT32(ptr); ptr += size + 4;
- break;
- default:
- error("countMapElements() Unknown tag of Map");
- }
- } while (tag != 'DATA');
-}
-
-struct Region {
- int32 offset;
- int32 length;
-};
-
-struct Jump {
- int32 offset;
- int32 dest;
- byte hookId;
- int16 fadeDelay;
-};
-
-struct Sync {
- int32 size;
- byte *ptr;
-};
-
-static Region *_region;
-static int _numRegions;
-
-void writeRegions(byte *ptr, int bits, int freq, int channels, char *dir, char *filename, FILE *output) {
- char tmpPath[200];
-
- for (int l = 0; l < _numRegions; l++) {
- int outputSize = 0;
- int size = _region[l].length;
- int offset = _region[l].offset;
- byte *outputData = convertTo16bit(ptr + offset, size, outputSize, bits, freq, channels);
- sprintf(tmpPath, "%s/%s_reg%03d.wav", dir, filename, l);
- writeToTempWave(tmpPath, outputData, outputSize);
- writeWaveHeader(_waveDataSize, freq, channels);
- free(outputData);
- sprintf(tmpPath, "%s/%s_reg%03d", dir, filename, l);
- if (_oggMode)
- encodeWaveWithOgg(tmpPath);
- else
- encodeWaveWithLame(tmpPath);
- sprintf(tmpPath, "%s/%s_reg%03d.wav", dir, filename, l);
- unlink(tmpPath);
-
- int32 startPos = ftell(output);
- if (_oggMode)
- sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.ogg", filename, l);
- else
- sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.mp3", filename, l);
- cbundleTable[cbundleCurIndex].offset = startPos;
-
- if (_oggMode)
- sprintf(tmpPath, "%s/%s_reg%03d.ogg", dir, filename, l);
- else
- sprintf(tmpPath, "%s/%s_reg%03d.mp3", dir, filename, l);
- FILE *cmpFile = fopen(tmpPath, "rb");
- fseek(cmpFile, 0, SEEK_END);
- size = ftell(cmpFile);
- fseek(cmpFile, 0, SEEK_SET);
- byte *tmpBuf = (byte *)malloc(size);
- fread(tmpBuf, size, 1, cmpFile);
- fclose(cmpFile);
- unlink(tmpPath);
- fwrite(tmpBuf, size, 1, output);
- free(tmpBuf);
- cbundleTable[cbundleCurIndex].size = ftell(output) - startPos;
- cbundleCurIndex++;
- }
- free(_region);
-}
-
-void recalcRegions(int32 &value, int bits, int freq, int channels) {
- int size = value;
- if (bits == 8)
- size *= 2;
- if (bits == 12)
- size = (size / 3) * 4;
- value = size;
-}
-
-void writeToRMAPFile(byte *ptr, FILE *output, char *filename, int &offsetData, int &bits, int &freq, int &channels) {
- byte *s_ptr = ptr;
- int32 size = 0;
- int l;
-
- uint32 tag = READ_BE_UINT32(ptr);
- assert(tag == 'iMUS');
- ptr += 16;
-
- int curIndexRegion = 0;
- int curIndexJump = 0;
- int curIndexSync = 0;
-
- int numRegions = 0, numJumps = 0, numSyncs = 0;
- countMapElements(ptr, numRegions, numJumps, numSyncs);
- Region *region = (Region *)malloc(sizeof(Region) * numRegions);
- _region = (Region *)malloc(sizeof(Region) * numRegions);
- _numRegions = numRegions;
- Jump *jump = (Jump *)malloc(sizeof(Jump) * numJumps);
- Sync *sync = (Sync *)malloc(sizeof(Sync) * numSyncs);
-
- do {
- tag = READ_BE_UINT32(ptr); ptr += 4;
- switch (tag) {
- case 'FRMT':
- ptr += 12;
- bits = READ_BE_UINT32(ptr); ptr += 4;
- freq = READ_BE_UINT32(ptr); ptr += 4;
- channels = READ_BE_UINT32(ptr); ptr += 4;
- break;
- case 'TEXT':
- case 'STOP':
- size = READ_BE_UINT32(ptr); ptr += size + 4;
- break;
- case 'REGN':
- ptr += 4;
- region[curIndexRegion].offset = READ_BE_UINT32(ptr); ptr += 4;
- region[curIndexRegion].length = READ_BE_UINT32(ptr); ptr += 4;
- curIndexRegion++;
- break;
- case 'JUMP':
- ptr += 4;
- jump[curIndexJump].offset = READ_BE_UINT32(ptr); ptr += 4;
- jump[curIndexJump].dest = READ_BE_UINT32(ptr); ptr += 4;
- jump[curIndexJump].hookId = READ_BE_UINT32(ptr); ptr += 4;
- jump[curIndexJump].fadeDelay = READ_BE_UINT32(ptr); ptr += 4;
- curIndexJump++;
- break;
- case 'SYNC':
- size = READ_BE_UINT32(ptr); ptr += 4;
- sync[curIndexSync].size = size;
- sync[curIndexSync].ptr = (byte *)malloc(size);
- memcpy(sync[curIndexSync].ptr, ptr, size);
- curIndexSync++;
- ptr += size;
- break;
- case 'DATA':
- ptr += 4;
- break;
- default:
- error("writeToRMAPFile() Unknown tag of Map for sound '%s'", filename);
- }
- } while (tag != 'DATA');
- offsetData = (int32)(ptr - s_ptr);
-
- int32 startPos = ftell(output);
- sprintf(cbundleTable[cbundleCurIndex].filename, "%s.map", filename);
- cbundleTable[cbundleCurIndex].offset = startPos;
-
- writeUint32BE(output, 'RMAP');
- writeUint32BE(output, 2); // version
- writeUint32BE(output, 16); // bits
- writeUint32BE(output, freq);
- writeUint32BE(output, channels);
- writeUint32BE(output, numRegions);
- writeUint32BE(output, numJumps);
- writeUint32BE(output, numSyncs);
- memcpy(_region, region, sizeof(Region) * numRegions);
- for (l = 0; l < numRegions; l++) {
- _region[l].offset -= offsetData;
- region[l].offset -= offsetData;
- recalcRegions(region[l].offset, bits, freq, channels);
- recalcRegions(region[l].length, bits, freq, channels);
- writeUint32BE(output, region[l].offset);
- writeUint32BE(output, region[l].length);
- }
- for (l = 0; l < numJumps; l++) {
- jump[l].offset -= offsetData;
- jump[l].dest -= offsetData;
- recalcRegions(jump[l].offset, bits, freq, channels);
- recalcRegions(jump[l].dest, bits, freq, channels);
- writeUint32BE(output, jump[l].offset);
- writeUint32BE(output, jump[l].dest);
- writeUint32BE(output, jump[l].hookId);
- writeUint32BE(output, jump[l].fadeDelay);
- }
- for (l = 0; l < numSyncs; l++) {
- writeUint32BE(output, sync[l].size);
- fwrite(sync[l].ptr, sync[l].size, 1, output);
- free(sync[l].ptr);
- }
- free(region);
- free(jump);
- free(sync);
-
- cbundleTable[cbundleCurIndex].size = ftell(output) - startPos;
- cbundleCurIndex++;
-}
-
-int main(int argc, char *argv[]) {
- if (argc < 4)
- showhelp(argv[0]);
-
- char inputDir[200];
- char outputDir[200];
- char inputFilename[200];
- char tmpPath[200];
-
- uint32 tag;
- int32 numFiles, offset, i;
-
- strcpy(inputFilename, argv[1]);
- strcpy(inputDir, argv[2]);
- strcpy(outputDir, argv[3]);
-
- if (argc > 4) {
- i = 4;
-
- if (strcmp(argv[i], "--ogg") == 0) {
- _oggMode = true;
- i++;
- }
-
- if (argc > i) {
- // HACK: The functions in compress.c expect the last
- // argument to be a filename. As we don't expect one,
- // we simply add a dummy argument to the list.
- char **args = (char **)malloc((argc + 1) * sizeof(char *));
- char dummyName[] = "dummy";
- int j;
-
- for (j = 0; j < argc; j++)
- args[j] = argv[j];
- args[j] = dummyName;
-
- int result;
-
- if (_oggMode)
- result = process_ogg_parms(argc + 1, args, i);
- else
- result = process_mp3_parms(argc + 1, args, i);
-
- if (!result)
- showhelp(argv[0]);
-
- free(args);
- }
- }
-
- char *index = strrchr(inputFilename, '.');
- if (index != NULL) {
- *index = 0;
- }
-
- sprintf(tmpPath, "%s/%s.bun", inputDir, inputFilename);
-
- FILE *input = fopen(tmpPath, "rb");
- if (!input) {
- printf("Cannot open file: %s\n", tmpPath);
- exit(-1);
- }
-
- sprintf(tmpPath, "%s/%s.bun", outputDir, inputFilename);
-
- FILE *output = fopen(tmpPath, "wb");
- if (!output) {
- printf("Cannot open file: %s\n", tmpPath);
- exit(-1);
- }
-
- writeUint32BE(output, 'LB23');
- writeUint32BE(output, 0); // will be later
- writeUint32BE(output, 0); // will be later
-
- initializeImcTables();
-
- tag = readUint32BE(input);
- assert(tag == 'LB83');
- offset = readUint32BE(input);
- numFiles = readUint32BE(input);
-
- bundleTable = (BundleAudioTable *)malloc(numFiles * sizeof(BundleAudioTable));
- fseek(input, offset, SEEK_SET);
-
- for (i = 0; i < numFiles; i++) {
- char filename[13], c;
- int z = 0;
- int z2;
-
- for (z2 = 0; z2 < 8; z2++)
- if ((c = readByte(input)) != 0)
- filename[z++] = c;
- filename[z++] = '.';
- for (z2 = 0; z2 < 4; z2++)
- if ((c = readByte(input)) != 0)
- filename[z++] = c;
- filename[z] = '\0';
- strcpy(bundleTable[i].filename, filename);
- bundleTable[i].offset = readUint32BE(input);
- bundleTable[i].size = readUint32BE(input);
- }
-
- for (i = 0; i < numFiles; i++) {
- if (strcmp(bundleTable[i].filename, "PRELOAD.") == 0)
- continue;
- int offsetData = 0, bits = 0, freq = 0, channels = 0, size = 0;
- byte *compFinal = decompressBundleSound(i, input, size);
- writeToRMAPFile(compFinal, output, bundleTable[i].filename, offsetData, bits, freq, channels);
- writeRegions(compFinal + offsetData, bits, freq, channels, outputDir, bundleTable[i].filename, output);
- free(compFinal);
- }
-
- int32 curPos = ftell(output);
- for (i = 0; i < cbundleCurIndex; i++) {
- fwrite(cbundleTable[i].filename, 24, 1, output);
- writeUint32BE(output, cbundleTable[i].offset);
- writeUint32BE(output, cbundleTable[i].size);
- }
-
- fseek(output, 4, SEEK_SET);
- writeUint32BE(output, curPos);
- writeUint32BE(output, cbundleCurIndex);
-
- free(bundleTable);
-
- fclose(input);
-
- printf("compression done.\n");
-
- return 0;
-}
Deleted: tools/branches/gsoc2007-decompiler/compress_scumm_san.cpp
===================================================================
--- tools/branches/gsoc2007-decompiler/compress_scumm_san.cpp 2007-07-06 17:50:27 UTC (rev 27942)
+++ tools/branches/gsoc2007-decompiler/compress_scumm_san.cpp 2007-07-06 17:58:45 UTC (rev 27943)
@@ -1,912 +0,0 @@
-/* compress_scumm_san - compressor for smush san files
- * Copyright (C) 2004-2006 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
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list