[Scummvm-cvs-logs] SF.net SVN: scummvm:[47579] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Jan 26 23:48:50 CET 2010
Revision: 47579
http://scummvm.svn.sourceforge.net/scummvm/?rev=47579&view=rev
Author: fingolfin
Date: 2010-01-26 22:48:45 +0000 (Tue, 26 Jan 2010)
Log Message:
-----------
Moved audio stream implementations (for MP3, FLAC, etc.) to new dir sound/decoders/
Modified Paths:
--------------
scummvm/trunk/engines/agos/animation.cpp
scummvm/trunk/engines/agos/sound.cpp
scummvm/trunk/engines/cine/sound.cpp
scummvm/trunk/engines/draci/sound.cpp
scummvm/trunk/engines/drascula/sound.cpp
scummvm/trunk/engines/gob/sound/sounddesc.cpp
scummvm/trunk/engines/gob/sound/soundmixer.cpp
scummvm/trunk/engines/groovie/roq.cpp
scummvm/trunk/engines/groovie/vdx.cpp
scummvm/trunk/engines/kyra/lol.cpp
scummvm/trunk/engines/kyra/sound.cpp
scummvm/trunk/engines/kyra/sound_digital.cpp
scummvm/trunk/engines/kyra/sound_towns.cpp
scummvm/trunk/engines/kyra/vqa.cpp
scummvm/trunk/engines/m4/sound.cpp
scummvm/trunk/engines/m4/sound.h
scummvm/trunk/engines/made/made.h
scummvm/trunk/engines/made/pmvplayer.cpp
scummvm/trunk/engines/made/resource.cpp
scummvm/trunk/engines/mohawk/sound.cpp
scummvm/trunk/engines/mohawk/sound.h
scummvm/trunk/engines/mohawk/video/qt_player.cpp
scummvm/trunk/engines/parallaction/sound.h
scummvm/trunk/engines/parallaction/sound_br.cpp
scummvm/trunk/engines/parallaction/sound_ns.cpp
scummvm/trunk/engines/queen/sound.cpp
scummvm/trunk/engines/saga/music.cpp
scummvm/trunk/engines/saga/music.h
scummvm/trunk/engines/saga/sndres.cpp
scummvm/trunk/engines/saga/sound.cpp
scummvm/trunk/engines/saga/sound.h
scummvm/trunk/engines/sci/sound/audio.cpp
scummvm/trunk/engines/sci/sound/iterator/iterator.cpp
scummvm/trunk/engines/sci/sound/music.cpp
scummvm/trunk/engines/scumm/he/cup_player_he.cpp
scummvm/trunk/engines/scumm/he/resource_he.cpp
scummvm/trunk/engines/scumm/he/sound_he.cpp
scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
scummvm/trunk/engines/scumm/player_mod.cpp
scummvm/trunk/engines/scumm/smush/smush_mixer.cpp
scummvm/trunk/engines/scumm/smush/smush_player.cpp
scummvm/trunk/engines/scumm/sound.cpp
scummvm/trunk/engines/sky/intro.cpp
scummvm/trunk/engines/sky/sound.cpp
scummvm/trunk/engines/sword1/animation.cpp
scummvm/trunk/engines/sword1/music.cpp
scummvm/trunk/engines/sword1/sound.cpp
scummvm/trunk/engines/sword2/music.cpp
scummvm/trunk/engines/sword2/sound.cpp
scummvm/trunk/engines/teenagent/teenagent.cpp
scummvm/trunk/engines/tinsel/bmv.cpp
scummvm/trunk/engines/tinsel/music.cpp
scummvm/trunk/engines/tinsel/sound.cpp
scummvm/trunk/engines/touche/resource.cpp
scummvm/trunk/engines/tucker/resource.cpp
scummvm/trunk/engines/tucker/sequences.cpp
scummvm/trunk/graphics/video/avi_decoder.cpp
scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp
scummvm/trunk/graphics/video/smk_decoder.cpp
scummvm/trunk/sound/audiocd.cpp
scummvm/trunk/sound/audiostream.cpp
scummvm/trunk/sound/module.mk
Added Paths:
-----------
scummvm/trunk/sound/decoders/
scummvm/trunk/sound/decoders/adpcm.cpp
scummvm/trunk/sound/decoders/adpcm.h
scummvm/trunk/sound/decoders/aiff.cpp
scummvm/trunk/sound/decoders/aiff.h
scummvm/trunk/sound/decoders/flac.cpp
scummvm/trunk/sound/decoders/flac.h
scummvm/trunk/sound/decoders/iff_sound.cpp
scummvm/trunk/sound/decoders/iff_sound.h
scummvm/trunk/sound/decoders/mp3.cpp
scummvm/trunk/sound/decoders/mp3.h
scummvm/trunk/sound/decoders/raw.cpp
scummvm/trunk/sound/decoders/raw.h
scummvm/trunk/sound/decoders/shorten.cpp
scummvm/trunk/sound/decoders/shorten.h
scummvm/trunk/sound/decoders/vag.cpp
scummvm/trunk/sound/decoders/vag.h
scummvm/trunk/sound/decoders/voc.cpp
scummvm/trunk/sound/decoders/voc.h
scummvm/trunk/sound/decoders/vorbis.cpp
scummvm/trunk/sound/decoders/vorbis.h
scummvm/trunk/sound/decoders/wave.cpp
scummvm/trunk/sound/decoders/wave.h
Removed Paths:
-------------
scummvm/trunk/sound/adpcm.cpp
scummvm/trunk/sound/adpcm.h
scummvm/trunk/sound/aiff.cpp
scummvm/trunk/sound/aiff.h
scummvm/trunk/sound/flac.cpp
scummvm/trunk/sound/flac.h
scummvm/trunk/sound/iff_sound.cpp
scummvm/trunk/sound/iff_sound.h
scummvm/trunk/sound/mp3.cpp
scummvm/trunk/sound/mp3.h
scummvm/trunk/sound/raw.cpp
scummvm/trunk/sound/raw.h
scummvm/trunk/sound/shorten.cpp
scummvm/trunk/sound/shorten.h
scummvm/trunk/sound/vag.cpp
scummvm/trunk/sound/vag.h
scummvm/trunk/sound/voc.cpp
scummvm/trunk/sound/voc.h
scummvm/trunk/sound/vorbis.cpp
scummvm/trunk/sound/vorbis.h
scummvm/trunk/sound/wave.cpp
scummvm/trunk/sound/wave.h
Modified: scummvm/trunk/engines/agos/animation.cpp
===================================================================
--- scummvm/trunk/engines/agos/animation.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/agos/animation.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -40,7 +40,7 @@
#include "agos/agos.h"
#include "sound/audiostream.h"
-#include "sound/wave.h"
+#include "sound/decoders/wave.h"
#include "gui/message.h"
Modified: scummvm/trunk/engines/agos/sound.cpp
===================================================================
--- scummvm/trunk/engines/agos/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/agos/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,13 +30,13 @@
#include "agos/sound.h"
#include "sound/audiostream.h"
-#include "sound/flac.h"
+#include "sound/decoders/flac.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/voc.h"
-#include "sound/vorbis.h"
-#include "sound/wave.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/voc.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/wave.h"
using Common::File;
Modified: scummvm/trunk/engines/cine/sound.cpp
===================================================================
--- scummvm/trunk/engines/cine/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/cine/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -32,7 +32,7 @@
#include "sound/audiostream.h"
#include "sound/fmopl.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "sound/mods/soundfx.h"
namespace Cine {
Modified: scummvm/trunk/engines/draci/sound.cpp
===================================================================
--- scummvm/trunk/engines/draci/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/draci/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -35,7 +35,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Draci {
Modified: scummvm/trunk/engines/drascula/sound.cpp
===================================================================
--- scummvm/trunk/engines/drascula/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/drascula/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -26,8 +26,8 @@
#include "sound/audiocd.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
-#include "sound/voc.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/voc.h"
#include "common/config-manager.h"
Modified: scummvm/trunk/engines/gob/sound/sounddesc.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/sounddesc.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/gob/sound/sounddesc.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -26,8 +26,8 @@
#include "common/util.h"
#include "common/stream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
-#include "sound/wave.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/wave.h"
#include "gob/sound/sounddesc.h"
#include "gob/resources.h"
Modified: scummvm/trunk/engines/gob/sound/soundmixer.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/soundmixer.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/gob/sound/soundmixer.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -26,7 +26,7 @@
#include "gob/sound/soundmixer.h"
#include "gob/sound/sounddesc.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Gob {
Modified: scummvm/trunk/engines/groovie/roq.cpp
===================================================================
--- scummvm/trunk/engines/groovie/roq.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/groovie/roq.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -36,7 +36,7 @@
#include "graphics/conversion.h"
#endif
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Groovie {
Modified: scummvm/trunk/engines/groovie/vdx.cpp
===================================================================
--- scummvm/trunk/engines/groovie/vdx.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/groovie/vdx.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -28,7 +28,7 @@
#include "groovie/vdx.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#define TILE_SIZE 4 // Size of each tile on the image: only ever seen 4 so far
#define VDX_IDENT 0x9267 // 37479
Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/kyra/lol.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -34,7 +34,7 @@
#include "kyra/util.h"
#include "kyra/debugger.h"
-#include "sound/voc.h"
+#include "sound/decoders/voc.h"
#include "sound/audiostream.h"
#include "common/config-manager.h"
Modified: scummvm/trunk/engines/kyra/sound.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/kyra/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,13 +31,13 @@
#include "kyra/sound.h"
#include "sound/mixer.h"
-#include "sound/voc.h"
+#include "sound/decoders/voc.h"
#include "sound/audiostream.h"
-#include "sound/flac.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/vorbis.h"
+#include "sound/decoders/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/vorbis.h"
namespace Kyra {
Modified: scummvm/trunk/engines/kyra/sound_digital.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_digital.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/kyra/sound_digital.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -29,9 +29,9 @@
#include "sound/audiostream.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/flac.h"
namespace Kyra {
Modified: scummvm/trunk/engines/kyra/sound_towns.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_towns.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/kyra/sound_towns.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,7 +30,7 @@
#include "sound/audiocd.h"
#include "sound/audiostream.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "common/util.h"
Modified: scummvm/trunk/engines/kyra/vqa.cpp
===================================================================
--- scummvm/trunk/engines/kyra/vqa.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/kyra/vqa.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -37,7 +37,7 @@
#include "common/system.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "kyra/sound.h"
#include "kyra/screen.h"
Modified: scummvm/trunk/engines/m4/sound.cpp
===================================================================
--- scummvm/trunk/engines/m4/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/m4/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,7 +31,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace M4 {
Modified: scummvm/trunk/engines/m4/sound.h
===================================================================
--- scummvm/trunk/engines/m4/sound.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/m4/sound.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,9 +31,9 @@
#include "common/file.h"
#include "common/array.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/flac.h"
namespace M4 {
Modified: scummvm/trunk/engines/made/made.h
===================================================================
--- scummvm/trunk/engines/made/made.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/made/made.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -40,7 +40,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/voc.h"
+#include "sound/decoders/voc.h"
#include "sound/audiocd.h"
#include "engines/engine.h"
Modified: scummvm/trunk/engines/made/pmvplayer.cpp
===================================================================
--- scummvm/trunk/engines/made/pmvplayer.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/made/pmvplayer.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -26,7 +26,7 @@
#include "made/pmvplayer.h"
#include "made/screen.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Made {
Modified: scummvm/trunk/engines/made/resource.cpp
===================================================================
--- scummvm/trunk/engines/made/resource.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/made/resource.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -25,7 +25,7 @@
#include "common/endian.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "made/resource.h"
#include "made/graphics.h"
Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/mohawk/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -28,9 +28,9 @@
#include "common/util.h"
#include "sound/audiostream.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/wave.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/wave.h"
namespace Mohawk {
Modified: scummvm/trunk/engines/mohawk/sound.h
===================================================================
--- scummvm/trunk/engines/mohawk/sound.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/mohawk/sound.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,7 +30,7 @@
#include "common/str.h"
#include "sound/audiostream.h"
-#include "sound/adpcm.h"
+#include "sound/decoders/adpcm.h"
#include "sound/mididrv.h"
#include "sound/midiparser.h"
#include "sound/mixer.h"
Modified: scummvm/trunk/engines/mohawk/video/qt_player.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video/qt_player.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/mohawk/video/qt_player.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -39,8 +39,8 @@
#include "common/zlib.h"
// Audio codecs
-#include "sound/adpcm.h"
-#include "sound/raw.h"
+#include "sound/decoders/adpcm.h"
+#include "sound/decoders/raw.h"
#include "mohawk/video/qdm2.h"
// Video codecs
Modified: scummvm/trunk/engines/parallaction/sound.h
===================================================================
--- scummvm/trunk/engines/parallaction/sound.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/parallaction/sound.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,7 +30,7 @@
#include "common/mutex.h"
#include "sound/audiostream.h"
-#include "sound/iff_sound.h"
+#include "sound/decoders/iff_sound.h"
#include "sound/mixer.h"
#include "sound/mididrv.h"
Modified: scummvm/trunk/engines/parallaction/sound_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound_br.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/parallaction/sound_br.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,7 +31,7 @@
#include "sound/mididrv.h"
#include "sound/midiparser.h"
#include "sound/mods/protracker.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "parallaction/disk.h"
#include "parallaction/parallaction.h"
Modified: scummvm/trunk/engines/parallaction/sound_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound_ns.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/parallaction/sound_ns.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,7 +30,7 @@
#include "sound/mixer.h"
#include "sound/midiparser.h"
#include "sound/mods/protracker.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "parallaction/sound.h"
#include "parallaction/parallaction.h"
Modified: scummvm/trunk/engines/queen/sound.cpp
===================================================================
--- scummvm/trunk/engines/queen/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/queen/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -36,11 +36,11 @@
#include "queen/resource.h"
#include "sound/audiostream.h"
-#include "sound/flac.h"
+#include "sound/decoders/flac.h"
#include "sound/mididrv.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/vorbis.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/vorbis.h"
#define SB_HEADER_SIZE_V104 110
#define SB_HEADER_SIZE_V110 122
Modified: scummvm/trunk/engines/saga/music.cpp
===================================================================
--- scummvm/trunk/engines/saga/music.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/saga/music.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -33,7 +33,7 @@
#include "sound/audiostream.h"
#include "sound/mididrv.h"
#include "sound/midiparser.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "common/config-manager.h"
#include "common/file.h"
Modified: scummvm/trunk/engines/saga/music.h
===================================================================
--- scummvm/trunk/engines/saga/music.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/saga/music.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,9 +31,9 @@
#include "sound/audiocd.h"
#include "sound/mididrv.h"
#include "sound/midiparser.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/flac.h"
#include "common/mutex.h"
namespace Saga {
Modified: scummvm/trunk/engines/saga/sndres.cpp
===================================================================
--- scummvm/trunk/engines/saga/sndres.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/saga/sndres.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -35,14 +35,14 @@
#include "common/file.h"
#include "sound/audiostream.h"
-#include "sound/adpcm.h"
-#include "sound/aiff.h"
+#include "sound/decoders/adpcm.h"
+#include "sound/decoders/aiff.h"
#ifdef ENABLE_SAGA2
-#include "sound/shorten.h"
+#include "sound/decoders/shorten.h"
#endif
-#include "sound/raw.h"
-#include "sound/voc.h"
-#include "sound/wave.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/voc.h"
+#include "sound/decoders/wave.h"
namespace Saga {
Modified: scummvm/trunk/engines/saga/sound.cpp
===================================================================
--- scummvm/trunk/engines/saga/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/saga/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,8 +30,8 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/adpcm.h"
-#include "sound/raw.h"
+#include "sound/decoders/adpcm.h"
+#include "sound/decoders/raw.h"
namespace Saga {
Modified: scummvm/trunk/engines/saga/sound.h
===================================================================
--- scummvm/trunk/engines/saga/sound.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/saga/sound.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,9 +30,9 @@
#include "common/file.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/flac.h"
namespace Saga {
Modified: scummvm/trunk/engines/sci/sound/audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/audio.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sci/sound/audio.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -32,8 +32,8 @@
#include "sound/audiostream.h"
#include "sound/audiocd.h"
-#include "sound/raw.h"
-#include "sound/wave.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/wave.h"
namespace Sci {
Modified: scummvm/trunk/engines/sci/sound/iterator/iterator.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/iterator/iterator.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sci/sound/iterator/iterator.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -36,7 +36,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Sci {
Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sci/sound/music.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -24,7 +24,7 @@
*/
#include "sound/audiostream.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "common/config-manager.h"
#include "sci/sci.h"
Modified: scummvm/trunk/engines/scumm/he/cup_player_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/cup_player_he.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/he/cup_player_he.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -28,7 +28,7 @@
#include "common/system.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "scumm/scumm.h"
#include "scumm/util.h"
#include "scumm/he/intern_he.h"
Modified: scummvm/trunk/engines/scumm/he/resource_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/resource_he.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/he/resource_he.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,7 +31,7 @@
#include "scumm/he/resource_he.h"
#include "scumm/he/sound_he.h"
-#include "sound/wave.h"
+#include "sound/decoders/wave.h"
#include "graphics/cursorman.h"
#include "common/archive.h"
Modified: scummvm/trunk/engines/scumm/he/sound_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/he/sound_he.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -35,16 +35,16 @@
#include "common/timer.h"
#include "common/util.h"
-#include "sound/adpcm.h"
+#include "sound/decoders/adpcm.h"
#include "sound/audiocd.h"
-#include "sound/flac.h"
+#include "sound/decoders/flac.h"
#include "sound/mididrv.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/voc.h"
-#include "sound/vorbis.h"
-#include "sound/wave.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/voc.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/wave.h"
namespace Scumm {
Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -35,7 +35,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Scumm {
Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -26,10 +26,10 @@
#include "common/scummsys.h"
#include "common/util.h"
-#include "sound/flac.h"
-#include "sound/voc.h"
-#include "sound/vorbis.h"
-#include "sound/mp3.h"
+#include "sound/decoders/flac.h"
+#include "sound/decoders/voc.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/mp3.h"
#include "scumm/scumm.h"
#include "scumm/util.h"
Modified: scummvm/trunk/engines/scumm/player_mod.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_mod.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/player_mod.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -27,7 +27,7 @@
#include "scumm/player_mod.h"
#include "sound/mixer.h"
#include "sound/rate.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Scumm {
Modified: scummvm/trunk/engines/scumm/smush/smush_mixer.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_mixer.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/smush/smush_mixer.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -33,7 +33,7 @@
#include "scumm/imuse/imuse.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Scumm {
Modified: scummvm/trunk/engines/scumm/smush/smush_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/smush/smush_player.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -50,9 +50,9 @@
#include "scumm/insane/insane.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/vorbis.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/vorbis.h"
#include "common/zlib.h"
Modified: scummvm/trunk/engines/scumm/sound.cpp
===================================================================
--- scummvm/trunk/engines/scumm/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/scumm/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -35,16 +35,16 @@
#include "scumm/sound.h"
#include "scumm/util.h"
-#include "sound/adpcm.h"
+#include "sound/decoders/adpcm.h"
#include "sound/audiocd.h"
-#include "sound/flac.h"
+#include "sound/decoders/flac.h"
#include "sound/mididrv.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/voc.h"
-#include "sound/vorbis.h"
-#include "sound/wave.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/voc.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/wave.h"
namespace Scumm {
Modified: scummvm/trunk/engines/sky/intro.cpp
===================================================================
--- scummvm/trunk/engines/sky/intro.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sky/intro.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -39,7 +39,7 @@
#include "sky/text.h"
#include "sound/audiostream.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Sky {
Modified: scummvm/trunk/engines/sky/sound.cpp
===================================================================
--- scummvm/trunk/engines/sky/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sky/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -34,7 +34,7 @@
#include "sky/struc.h"
#include "sound/audiostream.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Sky {
Modified: scummvm/trunk/engines/sword1/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword1/animation.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sword1/animation.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -28,7 +28,7 @@
#include "sword1/sword1.h"
#include "sword1/animation.h"
#include "sword1/text.h"
-#include "sound/vorbis.h"
+#include "sound/decoders/vorbis.h"
#include "common/config-manager.h"
#include "common/endian.h"
Modified: scummvm/trunk/engines/sword1/music.cpp
===================================================================
--- scummvm/trunk/engines/sword1/music.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sword1/music.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -32,13 +32,13 @@
#include "sword1/sword1.h"
#include "sword1/music.h"
-#include "sound/aiff.h"
-#include "sound/flac.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/wave.h"
-#include "sound/vag.h"
+#include "sound/decoders/aiff.h"
+#include "sound/decoders/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/wave.h"
+#include "sound/decoders/vag.h"
#define SMP_BUFSIZE 8192
Modified: scummvm/trunk/engines/sword1/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sword1/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -36,12 +36,12 @@
#include "sword1/logic.h"
#include "sword1/sword1.h"
-#include "sound/flac.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/vorbis.h"
-#include "sound/wave.h"
-#include "sound/vag.h"
+#include "sound/decoders/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/wave.h"
+#include "sound/decoders/vag.h"
namespace Sword1 {
Modified: scummvm/trunk/engines/sword2/music.cpp
===================================================================
--- scummvm/trunk/engines/sword2/music.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sword2/music.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -35,12 +35,12 @@
#include "common/file.h"
#include "common/system.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/flac.h"
+#include "sound/decoders/wave.h"
+#include "sound/decoders/vag.h"
#include "sound/rate.h"
-#include "sound/wave.h"
-#include "sound/vag.h"
#include "sword2/sword2.h"
#include "sword2/defs.h"
Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/sword2/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -46,8 +46,8 @@
#include "sword2/resman.h"
#include "sword2/sound.h"
-#include "sound/wave.h"
-#include "sound/vag.h"
+#include "sound/decoders/wave.h"
+#include "sound/decoders/vag.h"
namespace Sword2 {
Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -29,7 +29,7 @@
#include "common/system.h"
#include "engines/advancedDetector.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "graphics/cursorman.h"
#include "graphics/thumbnail.h"
#include "teenagent/console.h"
Modified: scummvm/trunk/engines/tinsel/bmv.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/bmv.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/tinsel/bmv.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -42,7 +42,7 @@
#include "tinsel/tinlib.h"
#include "tinsel/tinsel.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Tinsel {
Modified: scummvm/trunk/engines/tinsel/music.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/music.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/tinsel/music.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,7 +31,7 @@
#include "sound/mididrv.h"
#include "sound/midiparser.h"
#include "sound/audiocd.h"
-#include "sound/adpcm.h"
+#include "sound/decoders/adpcm.h"
#include "common/config-manager.h"
#include "common/file.h"
Modified: scummvm/trunk/engines/tinsel/sound.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/sound.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/tinsel/sound.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -39,12 +39,12 @@
#include "common/system.h"
#include "sound/mixer.h"
-#include "sound/adpcm.h"
-#include "sound/vag.h"
-#include "sound/flac.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/vorbis.h"
+#include "sound/decoders/adpcm.h"
+#include "sound/decoders/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/vag.h"
+#include "sound/decoders/vorbis.h"
#include "gui/message.h"
Modified: scummvm/trunk/engines/touche/resource.cpp
===================================================================
--- scummvm/trunk/engines/touche/resource.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/touche/resource.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -25,12 +25,12 @@
-#include "sound/flac.h"
+#include "sound/decoders/flac.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/voc.h"
-#include "sound/vorbis.h"
-#include "sound/raw.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/voc.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/raw.h"
#include "sound/audiostream.h"
#include "touche/midi.h"
Modified: scummvm/trunk/engines/tucker/resource.cpp
===================================================================
--- scummvm/trunk/engines/tucker/resource.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/tucker/resource.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -26,10 +26,10 @@
#include "common/file.h"
#include "sound/audiostream.h"
-#include "sound/flac.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/wave.h"
+#include "sound/decoders/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/wave.h"
#include "tucker/tucker.h"
#include "tucker/graphics.h"
Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/engines/tucker/sequences.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -26,8 +26,8 @@
#include "common/system.h"
#include "sound/audiostream.h"
-#include "sound/raw.h"
-#include "sound/wave.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/wave.h"
#include "tucker/tucker.h"
#include "tucker/graphics.h"
Modified: scummvm/trunk/graphics/video/avi_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/avi_decoder.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/graphics/video/avi_decoder.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -31,7 +31,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
#include "graphics/video/avi_decoder.h"
Modified: scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp
===================================================================
--- scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -34,7 +34,7 @@
#include "graphics/video/coktelvideo/indeo3.h"
#include "sound/audiostream.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Graphics {
Modified: scummvm/trunk/graphics/video/smk_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/smk_decoder.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/graphics/video/smk_decoder.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -37,7 +37,7 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/raw.h"
+#include "sound/decoders/raw.h"
namespace Graphics {
Deleted: scummvm/trunk/sound/adpcm.cpp
===================================================================
--- scummvm/trunk/sound/adpcm.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/sound/adpcm.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -1,627 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 "common/endian.h"
-
-#include "sound/adpcm.h"
-#include "sound/audiostream.h"
-
-
-namespace Audio {
-
-class ADPCMInputStream : public RewindableAudioStream {
-private:
- Common::SeekableReadStream *_stream;
- bool _disposeAfterUse;
- int32 _startpos;
- int32 _endpos;
- int _channels;
- typesADPCM _type;
- uint32 _blockAlign;
- uint32 _blockPos[2];
- uint8 _chunkPos;
- uint16 _chunkData;
- int _blockLen;
- int _rate;
-
- struct ADPCMChannelStatus {
- byte predictor;
- int16 delta;
- int16 coeff1;
- int16 coeff2;
- int16 sample1;
- int16 sample2;
- };
-
- struct adpcmStatus {
- // OKI/IMA
- struct {
- int32 last;
- int32 stepIndex;
- } ima_ch[2];
-
- // Apple QuickTime IMA ADPCM
- int32 streamPos[2];
-
- // MS ADPCM
- ADPCMChannelStatus ch[2];
-
- // Tinsel
- double predictor;
- double K0, K1;
- double d0, d1;
- } _status;
-
- void reset();
- int16 stepAdjust(byte);
- int16 decodeOKI(byte);
- int16 decodeIMA(byte code, int channel = 0); // Default to using the left channel/using one channel
- int16 decodeMS(ADPCMChannelStatus *c, byte);
- int16 decodeTinsel(int16, double);
-
-public:
- ADPCMInputStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign);
- ~ADPCMInputStream();
-
- int readBuffer(int16 *buffer, const int numSamples);
- int readBufferOKI(int16 *buffer, const int numSamples);
- int readBufferIMA(int16 *buffer, const int numSamples);
- int readBufferMSIMA1(int16 *buffer, const int numSamples);
- int readBufferMSIMA2(int16 *buffer, const int numSamples);
- int readBufferMS(int channels, int16 *buffer, const int numSamples);
- void readBufferTinselHeader();
- int readBufferTinsel4(int channels, int16 *buffer, const int numSamples);
- int readBufferTinsel6(int channels, int16 *buffer, const int numSamples);
- int readBufferTinsel8(int channels, int16 *buffer, const int numSamples);
- int readBufferApple(int16 *buffer, const int numSamples);
-
- bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
- bool isStereo() const { return _channels == 2; }
- int getRate() const { return _rate; }
-
- bool rewind();
-};
-
-// Routines to convert 12 bit linear samples to the
-// Dialogic or Oki ADPCM coding format aka VOX.
-// See also <http://www.comptek.ru/telephony/tnotes/tt1-13.html>
-//
-// IMA ADPCM support is based on
-// <http://wiki.multimedia.cx/index.php?title=IMA_ADPCM>
-//
-// In addition, also MS IMA ADPCM is supported. See
-// <http://wiki.multimedia.cx/index.php?title=Microsoft_IMA_ADPCM>.
-
-ADPCMInputStream::ADPCMInputStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign)
- : _stream(stream), _disposeAfterUse(disposeAfterUse), _channels(channels), _type(type), _blockAlign(blockAlign), _rate(rate) {
-
- if (type == kADPCMMSIma && blockAlign == 0)
- error("ADPCMInputStream(): blockAlign isn't specified for MS IMA ADPCM");
- if (type == kADPCMMS && blockAlign == 0)
- error("ADPCMInputStream(): blockAlign isn't specified for MS ADPCM");
-
- if (type == kADPCMTinsel4 && blockAlign == 0)
- error("ADPCMInputStream(): blockAlign isn't specified for Tinsel 4-bit ADPCM");
- if (type == kADPCMTinsel6 && blockAlign == 0)
- error("ADPCMInputStream(): blockAlign isn't specified for Tinsel 6-bit ADPCM");
- if (type == kADPCMTinsel8 && blockAlign == 0)
- error("ADPCMInputStream(): blockAlign isn't specified for Tinsel 8-bit ADPCM");
-
- if (type == kADPCMTinsel4 && channels != 1)
- error("ADPCMInputStream(): Tinsel 4-bit ADPCM only supports mono");
- if (type == kADPCMTinsel6 && channels != 1)
- error("ADPCMInputStream(): Tinsel 6-bit ADPCM only supports mono");
- if (type == kADPCMTinsel8 && channels != 1)
- error("ADPCMInputStream(): Tinsel 8-bit ADPCM only supports mono");
-
- _startpos = stream->pos();
- _endpos = _startpos + size;
- reset();
-}
-
-ADPCMInputStream::~ADPCMInputStream() {
- if (_disposeAfterUse)
- delete _stream;
-}
-
-void ADPCMInputStream::reset() {
- memset(&_status, 0, sizeof(_status));
- _blockLen = 0;
- _blockPos[0] = _blockPos[1] = _blockAlign; // To make sure first header is read
- _status.streamPos[0] = 0;
- _status.streamPos[1] = _blockAlign;
- _chunkPos = 0;
-}
-
-bool ADPCMInputStream::rewind() {
- // TODO: Error checking.
- reset();
- _stream->seek(_startpos);
- return true;
-}
-
-int ADPCMInputStream::readBuffer(int16 *buffer, const int numSamples) {
- int samplesDecoded = 0;
- switch (_type) {
- case kADPCMOki:
- samplesDecoded = readBufferOKI(buffer, numSamples);
- break;
- case kADPCMMSIma:
- if (_channels == 1)
- samplesDecoded = readBufferMSIMA1(buffer, numSamples);
- else
- samplesDecoded = readBufferMSIMA2(buffer, numSamples);
- break;
- case kADPCMMS:
- samplesDecoded = readBufferMS(_channels, buffer, numSamples);
- break;
- case kADPCMTinsel4:
- samplesDecoded = readBufferTinsel4(_channels, buffer, numSamples);
- break;
- case kADPCMTinsel6:
- samplesDecoded = readBufferTinsel6(_channels, buffer, numSamples);
- break;
- case kADPCMTinsel8:
- samplesDecoded = readBufferTinsel8(_channels, buffer, numSamples);
- break;
- case kADPCMIma:
- samplesDecoded = readBufferIMA(buffer, numSamples);
- break;
- case kADPCMApple:
- samplesDecoded = readBufferApple(buffer, numSamples);
- break;
- default:
- error("Unsupported ADPCM encoding");
- break;
- }
-
- return samplesDecoded;
-}
-
-int ADPCMInputStream::readBufferOKI(int16 *buffer, const int numSamples) {
- int samples;
- byte data;
-
- assert(numSamples % 2 == 0);
-
- for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
- data = _stream->readByte();
- buffer[samples] = decodeOKI((data >> 4) & 0x0f);
- buffer[samples + 1] = decodeOKI(data & 0x0f);
- }
- return samples;
-}
-
-int ADPCMInputStream::readBufferIMA(int16 *buffer, const int numSamples) {
- int samples;
- byte data;
-
- assert(numSamples % 2 == 0);
-
- for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
- data = _stream->readByte();
- buffer[samples] = decodeIMA((data >> 4) & 0x0f);
- buffer[samples + 1] = decodeIMA(data & 0x0f, _channels == 2 ? 1 : 0);
- }
- return samples;
-}
-
-int ADPCMInputStream::readBufferApple(int16 *buffer, const int numSamples) {
- // Need to write 2 samples per channel
- assert(numSamples % (2 * _channels) == 0);
-
- // Current sample positions
- int samples[2] = { 0, 0};
- // Current data bytes
- byte data[2] = { 0, 0};
- // Current nibble selectors
- bool lowNibble[2] = {true, true};
-
- // Number of samples per channel
- int chanSamples = numSamples / _channels;
-
- for (int i = 0; i < _channels; i++) {
- _stream->seek(_status.streamPos[i]);
-
- while ((samples[i] < chanSamples) &&
- // Last byte read and a new one needed
- !((_stream->eos() || (_stream->pos() >= _endpos)) && lowNibble[i])) {
-
- if (_blockPos[i] == _blockAlign) {
- // 2 byte header per block
- uint16 temp = _stream->readUint16BE();
-
- // First 9 bits are the upper bits of the predictor
- _status.ima_ch[i].last = (int16) (temp & 0xFF80);
- // Lower 7 bits are the step index
- _status.ima_ch[i].stepIndex = temp & 0x007F;
-
- // Clip the step index
- _status.ima_ch[i].stepIndex = CLIP<int32>(_status.ima_ch[i].stepIndex, 0, 88);
-
- _blockPos[i] = 2;
- }
-
- // First decode the lower nibble, then the upper
- if (lowNibble[i])
- data[i] = _stream->readByte();
-
- int16 sample;
- if (lowNibble[i])
- sample = decodeIMA(data[i] & 0x0F, i);
- else
- sample = decodeIMA(data[i] >> 4, i);
-
- // The original is interleaved block-wise, we want it sample-wise
- buffer[_channels * samples[i] + i] = sample;
-
- samples[i]++;
-
- // Different nibble
- lowNibble[i] = !lowNibble[i];
-
- // We're about to decode a new lower nibble again, so advance the block position
- if (lowNibble[i])
- _blockPos[i]++;
-
- if (_channels == 2)
- if (_blockPos[i] == _blockAlign)
- // We're at the end of the block.
- // Since the channels are interleaved, skip the next block
- _stream->skip(MIN<uint32>(_blockAlign, _endpos - _stream->pos()));
-
- _status.streamPos[i] = _stream->pos();
- }
- }
-
- return samples[0] + samples[1];
-}
-
-int ADPCMInputStream::readBufferMSIMA1(int16 *buffer, const int numSamples) {
- int samples = 0;
- byte data;
-
- assert(numSamples % 2 == 0);
-
- while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
- if (_blockPos[0] == _blockAlign) {
- // read block header
- _status.ima_ch[0].last = _stream->readSint16LE();
- _status.ima_ch[0].stepIndex = _stream->readSint16LE();
- _blockPos[0] = 4;
- }
-
- for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
- data = _stream->readByte();
- _blockPos[0]++;
- buffer[samples] = decodeIMA(data & 0x0f);
- buffer[samples + 1] = decodeIMA((data >> 4) & 0x0f);
- }
- }
- return samples;
-}
-
-
-// Microsoft as usual tries to implement it differently. This method
-// is used for stereo data.
-int ADPCMInputStream::readBufferMSIMA2(int16 *buffer, const int numSamples) {
- int samples;
- uint32 data;
- int nibble;
- byte k;
-
- for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos;) {
- for (int channel = 0; channel < 2; channel++) {
- data = _stream->readUint32LE();
-
- for (nibble = 0; nibble < 8; nibble++) {
- k = ((data & 0xf0000000) >> 28);
- buffer[samples + channel + nibble * 2] = decodeIMA(k);
- data <<= 4;
- }
- }
- samples += 16;
- }
- return samples;
-}
-
-static const int MSADPCMAdaptCoeff1[] = {
- 256, 512, 0, 192, 240, 460, 392
-};
-
-static const int MSADPCMAdaptCoeff2[] = {
- 0, -256, 0, 64, 0, -208, -232
-};
-
-int ADPCMInputStream::readBufferMS(int channels, int16 *buffer, const int numSamples) {
- int samples;
- byte data;
- int i = 0;
-
- samples = 0;
-
- while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
- if (_blockPos[0] == _blockAlign) {
- // read block header
- for (i = 0; i < channels; i++) {
- _status.ch[i].predictor = CLIP(_stream->readByte(), (byte)0, (byte)6);
- _status.ch[i].coeff1 = MSADPCMAdaptCoeff1[_status.ch[i].predictor];
- _status.ch[i].coeff2 = MSADPCMAdaptCoeff2[_status.ch[i].predictor];
- }
-
- for (i = 0; i < channels; i++)
- _status.ch[i].delta = _stream->readSint16LE();
-
- for (i = 0; i < channels; i++)
- _status.ch[i].sample1 = _stream->readSint16LE();
-
- for (i = 0; i < channels; i++)
- buffer[samples++] = _status.ch[i].sample2 = _stream->readSint16LE();
-
- for (i = 0; i < channels; i++)
- buffer[samples++] = _status.ch[i].sample1;
-
- _blockPos[0] = channels * 7;
- }
-
- for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
- data = _stream->readByte();
- _blockPos[0]++;
- buffer[samples] = decodeMS(&_status.ch[0], (data >> 4) & 0x0f);
- buffer[samples + 1] = decodeMS(&_status.ch[channels - 1], data & 0x0f);
- }
- }
-
- return samples;
-}
-
-static const double TinselFilterTable[4][2] = {
- {0, 0 },
- {0.9375, 0},
- {1.796875, -0.8125},
- {1.53125, -0.859375}
-};
-
-void ADPCMInputStream::readBufferTinselHeader() {
- uint8 start = _stream->readByte();
- uint8 filterVal = (start & 0xC0) >> 6;
-
- if ((start & 0x20) != 0) {
- //Lower 6 bit are negative
-
- // Negate
- start = ~(start | 0xC0) + 1;
-
- _status.predictor = 1 << start;
- } else {
- // Lower 6 bit are positive
-
- // Truncate
- start &= 0x1F;
-
- _status.predictor = ((double) 1.0) / (1 << start);
- }
-
- _status.K0 = TinselFilterTable[filterVal][0];
- _status.K1 = TinselFilterTable[filterVal][1];
-}
-
-int ADPCMInputStream::readBufferTinsel4(int channels, int16 *buffer, const int numSamples) {
- int samples;
- uint16 data;
- const double eVal = 1.142822265;
-
- samples = 0;
-
- assert(numSamples % 2 == 0);
-
- while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
- if (_blockPos[0] == _blockAlign) {
- readBufferTinselHeader();
- _blockPos[0] = 0;
- }
-
- for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2, _blockPos[0]++) {
- // Read 1 byte = 8 bits = two 4 bit blocks
- data = _stream->readByte();
- buffer[samples] = decodeTinsel((data << 8) & 0xF000, eVal);
- buffer[samples+1] = decodeTinsel((data << 12) & 0xF000, eVal);
- }
- }
-
- return samples;
-}
-
-int ADPCMInputStream::readBufferTinsel6(int channels, int16 *buffer, const int numSamples) {
- int samples;
- const double eVal = 1.032226562;
-
- samples = 0;
-
- while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
- if (_blockPos[0] == _blockAlign) {
- readBufferTinselHeader();
- _blockPos[0] = 0;
- _chunkPos = 0;
- }
-
- for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples++, _chunkPos = (_chunkPos + 1) % 4) {
-
- switch (_chunkPos) {
- case 0:
- _chunkData = _stream->readByte();
- buffer[samples] = decodeTinsel((_chunkData << 8) & 0xFC00, eVal);
- break;
- case 1:
- _chunkData = (_chunkData << 8) | (_stream->readByte());
- buffer[samples] = decodeTinsel((_chunkData << 6) & 0xFC00, eVal);
- _blockPos[0]++;
- break;
- case 2:
- _chunkData = (_chunkData << 8) | (_stream->readByte());
- buffer[samples] = decodeTinsel((_chunkData << 4) & 0xFC00, eVal);
- _blockPos[0]++;
- break;
- case 3:
- _chunkData = (_chunkData << 8);
- buffer[samples] = decodeTinsel((_chunkData << 2) & 0xFC00, eVal);
- _blockPos[0]++;
- break;
- }
-
- }
-
- }
-
- return samples;
-}
-
-int ADPCMInputStream::readBufferTinsel8(int channels, int16 *buffer, const int numSamples) {
- int samples;
- byte data;
- const double eVal = 1.007843258;
-
- samples = 0;
-
- while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
- if (_blockPos[0] == _blockAlign) {
- readBufferTinselHeader();
- _blockPos[0] = 0;
- }
-
- for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples++, _blockPos[0]++) {
- // Read 1 byte = 8 bits = one 8 bit block
- data = _stream->readByte();
- buffer[samples] = decodeTinsel(data << 8, eVal);
- }
- }
-
- return samples;
-}
-
-static const int MSADPCMAdaptationTable[] = {
- 230, 230, 230, 230, 307, 409, 512, 614,
- 768, 614, 512, 409, 307, 230, 230, 230
-};
-
-
-int16 ADPCMInputStream::decodeMS(ADPCMChannelStatus *c, byte code) {
- int32 predictor;
-
- predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
- predictor += (signed)((code & 0x08) ? (code - 0x10) : (code)) * c->delta;
-
- predictor = CLIP<int32>(predictor, -32768, 32767);
-
- c->sample2 = c->sample1;
- c->sample1 = predictor;
- c->delta = (MSADPCMAdaptationTable[(int)code] * c->delta) >> 8;
-
- if (c->delta < 16)
- c->delta = 16;
-
- return (int16)predictor;
-}
-
-// adjust the step for use on the next sample.
-int16 ADPCMInputStream::stepAdjust(byte code) {
- static const int16 adjusts[] = {-1, -1, -1, -1, 2, 4, 6, 8};
-
- return adjusts[code & 0x07];
-}
-
-static const int16 okiStepSize[49] = {
- 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
-};
-
-// Decode Linear to ADPCM
-int16 ADPCMInputStream::decodeOKI(byte code) {
- int16 diff, E, samp;
-
- E = (2 * (code & 0x7) + 1) * okiStepSize[_status.ima_ch[0].stepIndex] / 8;
- diff = (code & 0x08) ? -E : E;
- samp = _status.ima_ch[0].last + diff;
- // Clip the values to +/- 2^11 (supposed to be 12 bits)
- samp = CLIP<int16>(samp, -2048, 2047);
-
- _status.ima_ch[0].last = samp;
- _status.ima_ch[0].stepIndex += stepAdjust(code);
- _status.ima_ch[0].stepIndex = CLIP<int32>(_status.ima_ch[0].stepIndex, 0, ARRAYSIZE(okiStepSize) - 1);
-
- // * 16 effectively converts 12-bit input to 16-bit output
- return samp * 16;
-}
-
-static const uint16 imaStepTable[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
-};
-
-int16 ADPCMInputStream::decodeIMA(byte code, int channel) {
- int32 E = (2 * (code & 0x7) + 1) * imaStepTable[_status.ima_ch[channel].stepIndex] / 8;
- int32 diff = (code & 0x08) ? -E : E;
- int32 samp = CLIP<int32>(_status.ima_ch[channel].last + diff, -32768, 32767);
-
- _status.ima_ch[channel].last = samp;
- _status.ima_ch[channel].stepIndex += stepAdjust(code);
- _status.ima_ch[channel].stepIndex = CLIP<int32>(_status.ima_ch[channel].stepIndex, 0, ARRAYSIZE(imaStepTable) - 1);
-
- return samp;
-}
-
-int16 ADPCMInputStream::decodeTinsel(int16 code, double eVal) {
- double sample;
-
- sample = (double) code;
- sample *= eVal * _status.predictor;
- sample += (_status.d0 * _status.K0) + (_status.d1 * _status.K1);
-
- _status.d1 = _status.d0;
- _status.d0 = sample;
-
- return (int16) CLIP<double>(sample, -32768.0, 32767.0);
-}
-
-RewindableAudioStream *makeADPCMStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) {
- return new ADPCMInputStream(stream, disposeAfterUse, size, type, rate, channels, blockAlign);
-}
-
-} // End of namespace Audio
Deleted: scummvm/trunk/sound/adpcm.h
===================================================================
--- scummvm/trunk/sound/adpcm.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/sound/adpcm.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -1,86 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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$
- *
- */
-
-/**
- * @file
- * Sound decoder used in engines:
- * - agos
- * - saga
- * - scumm
- * - tinsel
- */
-
-#ifndef SOUND_ADPCM_H
-#define SOUND_ADPCM_H
-
-#include "common/scummsys.h"
-#include "common/stream.h"
-
-
-namespace Audio {
-
-class AudioStream;
-class RewindableAudioStream;
-
-// There are several types of ADPCM encoding, only some are supported here
-// For all the different encodings, refer to:
-// http://wiki.multimedia.cx/index.php?title=Category:ADPCM_Audio_Codecs
-// Usually, if the audio stream we're trying to play has the FourCC header
-// string intact, it's easy to discern which encoding is used
-enum typesADPCM {
- kADPCMOki, // Dialogic/Oki ADPCM (aka VOX)
- kADPCMMSIma, // Microsoft IMA ADPCM
- kADPCMMS, // Microsoft ADPCM
- kADPCMTinsel4, // 4-bit ADPCM used by the Tinsel engine
- kADPCMTinsel6, // 6-bit ADPCM used by the Tinsel engine
- kADPCMTinsel8, // 8-bit ADPCM used by the Tinsel engine
- kADPCMIma, // Standard IMA ADPCM
- kADPCMApple // Apple QuickTime IMA ADPCM
-};
-
-/**
- * Takes an input stream containing ADPCM compressed sound data and creates
- * an RewindableAudioStream from that.
- *
- * @param stream the SeekableReadStream from which to read the ADPCM data
- * @param disposeAfterUse whether to delete the stream after use
- * @param size how many bytes to read from the stream (0 = all)
- * @param type the compression type used
- * @param rate the sampling rate
- * @param channels the number of channels
- * @param blockAlign block alignment ???
- * @return a new RewindableAudioStream, or NULL, if an error occured
- */
-RewindableAudioStream *makeADPCMStream(
- Common::SeekableReadStream *stream,
- bool disposeAfterUse,
- uint32 size, typesADPCM type,
- int rate = 22050,
- int channels = 2,
- uint32 blockAlign = 0);
-
-} // End of namespace Audio
-
-#endif
Deleted: scummvm/trunk/sound/aiff.cpp
===================================================================
--- scummvm/trunk/sound/aiff.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/sound/aiff.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -1,179 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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$
- *
- */
-
-/*
- * The code in this file is based on information found at
- * http://www.borg.com/~jglatt/tech/aiff.htm
- *
- * We currently only implement uncompressed AIFF. If we ever need AIFF-C, SoX
- * (http://sox.sourceforge.net) may be a good place to start from.
- */
-
-#include "common/endian.h"
-#include "common/util.h"
-#include "common/stream.h"
-
-#include "sound/aiff.h"
-#include "sound/audiostream.h"
-#include "sound/mixer.h"
-#include "sound/raw.h"
-
-namespace Audio {
-
-uint32 readExtended(Common::SeekableReadStream &stream) {
- // The sample rate is stored as an "80 bit IEEE Standard 754 floating
- // point number (Standard Apple Numeric Environment [SANE] data type
- // Extended).
-
- byte buf[10];
- uint32 mantissa;
- uint32 last = 0;
- byte exp;
-
- stream.read(buf, 10);
- mantissa = READ_BE_UINT32(buf + 2);
- exp = 30 - buf[1];
-
- while (exp--) {
- last = mantissa;
- mantissa >>= 1;
- }
-
- if (last & 0x00000001)
- mantissa++;
-
- return mantissa;
-}
-
-bool loadAIFFFromStream(Common::SeekableReadStream &stream, int &size, int &rate, byte &flags) {
- byte buf[4];
-
- stream.read(buf, 4);
- if (memcmp(buf, "FORM", 4) != 0) {
- warning("loadAIFFFromStream: No 'FORM' header");
- return false;
- }
-
- stream.readUint32BE();
-
- // This could be AIFC, but we don't handle that case.
-
- stream.read(buf, 4);
- if (memcmp(buf, "AIFF", 4) != 0) {
- warning("loadAIFFFromStream: No 'AIFF' header");
- return false;
- }
-
- // From here on, we only care about the COMM and SSND chunks, which are
- // the only required chunks.
-
- bool foundCOMM = false;
- bool foundSSND = false;
-
- uint16 numChannels = 0, bitsPerSample = 0;
- uint32 numSampleFrames = 0, offset = 0, blockSize = 0, soundOffset = 0;
-
- while (!(foundCOMM && foundSSND) && !stream.err() && !stream.eos()) {
- uint32 length, pos;
-
- stream.read(buf, 4);
- length = stream.readUint32BE();
- pos = stream.pos();
-
- if (memcmp(buf, "COMM", 4) == 0) {
- foundCOMM = true;
- numChannels = stream.readUint16BE();
- numSampleFrames = stream.readUint32BE();
- bitsPerSample = stream.readUint16BE();
- rate = readExtended(stream);
- size = numSampleFrames * numChannels * (bitsPerSample / 8);
- } else if (memcmp(buf, "SSND", 4) == 0) {
- foundSSND = true;
- offset = stream.readUint32BE();
- blockSize = stream.readUint32BE();
- soundOffset = stream.pos();
- }
-
- stream.seek(pos + length);
- }
-
- if (!foundCOMM) {
- warning("loadAIFFFromStream: Cound not find 'COMM' chunk");
- return false;
- }
-
- if (!foundSSND) {
- warning("loadAIFFFromStream: Cound not find 'SSND' chunk");
- return false;
- }
-
- // We only implement a subset of the AIFF standard.
-
- if (numChannels < 1 || numChannels > 2) {
- warning("loadAIFFFromStream: Only 1 or 2 channels are supported, not %d", numChannels);
- return false;
- }
-
- if (bitsPerSample != 8 && bitsPerSample != 16) {
- warning("loadAIFFFromStream: Only 8 or 16 bits per sample are supported, not %d", bitsPerSample);
- return false;
- }
-
- if (offset != 0 || blockSize != 0) {
- warning("loadAIFFFromStream: Block-aligned data is not supported");
- return false;
- }
-
- // Samples are always signed, and big endian.
-
- flags = 0;
- if (bitsPerSample == 16)
- flags |= Audio::FLAG_16BITS;
- if (numChannels == 2)
- flags |= Audio::FLAG_STEREO;
-
- stream.seek(soundOffset);
-
- // Stream now points at the sample data
-
- return true;
-}
-
-SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream &stream) {
- int size, rate;
- byte *data, flags;
-
- if (!loadAIFFFromStream(stream, size, rate, flags))
- return 0;
-
- data = (byte *)malloc(size);
- assert(data);
- stream.read(data, size);
-
- // Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
- return makeRawMemoryStream(data, size, rate, flags);
-}
-
-} // End of namespace Audio
Deleted: scummvm/trunk/sound/aiff.h
===================================================================
--- scummvm/trunk/sound/aiff.h 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/sound/aiff.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -1,63 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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$
- *
- */
-
-/**
- * @file
- * Sound decoder used in engines:
- * - saga
- * - sword1
- */
-
-#ifndef SOUND_AIFF_H
-#define SOUND_AIFF_H
-
-#include "common/scummsys.h"
-
-namespace Common { class SeekableReadStream; }
-
-namespace Audio {
-
-class SeekableAudioStream;
-
-/**
- * Try to load an AIFF from the given seekable stream. Returns true if
- * successful. In that case, the stream's seek position will be set to the
- * start of the audio data, and size, rate and flags contain information
- * necessary for playback. Currently this function only supports uncompressed
- * raw PCM data as well as IMA ADPCM.
- */
-extern bool loadAIFFFromStream(Common::SeekableReadStream &stream, int &size, int &rate, byte &flags);
-
-/**
- * Try to load an AIFF from the given seekable stream and create an AudioStream
- * from that data.
- *
- * This function uses loadAIFFFromStream() internally.
- */
-SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream &stream);
-
-} // End of namespace Audio
-
-#endif
Modified: scummvm/trunk/sound/audiocd.cpp
===================================================================
--- scummvm/trunk/sound/audiocd.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/sound/audiocd.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -25,9 +25,9 @@
#include "sound/audiocd.h"
#include "sound/audiostream.h"
-#include "sound/mp3.h"
-#include "sound/vorbis.h"
-#include "sound/flac.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/vorbis.h"
+#include "sound/decoders/flac.h"
#include "engines/engine.h"
#include "common/util.h"
#include "common/system.h"
Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp 2010-01-26 22:45:52 UTC (rev 47578)
+++ scummvm/trunk/sound/audiostream.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -30,11 +30,11 @@
#include "common/util.h"
#include "sound/audiostream.h"
-#include "sound/flac.h"
+#include "sound/decoders/flac.h"
#include "sound/mixer.h"
-#include "sound/mp3.h"
-#include "sound/raw.h"
-#include "sound/vorbis.h"
+#include "sound/decoders/mp3.h"
+#include "sound/decoders/raw.h"
+#include "sound/decoders/vorbis.h"
namespace Audio {
Copied: scummvm/trunk/sound/decoders/adpcm.cpp (from rev 47576, scummvm/trunk/sound/adpcm.cpp)
===================================================================
--- scummvm/trunk/sound/decoders/adpcm.cpp (rev 0)
+++ scummvm/trunk/sound/decoders/adpcm.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -0,0 +1,627 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 "common/endian.h"
+
+#include "sound/decoders/adpcm.h"
+#include "sound/audiostream.h"
+
+
+namespace Audio {
+
+class ADPCMInputStream : public RewindableAudioStream {
+private:
+ Common::SeekableReadStream *_stream;
+ bool _disposeAfterUse;
+ int32 _startpos;
+ int32 _endpos;
+ int _channels;
+ typesADPCM _type;
+ uint32 _blockAlign;
+ uint32 _blockPos[2];
+ uint8 _chunkPos;
+ uint16 _chunkData;
+ int _blockLen;
+ int _rate;
+
+ struct ADPCMChannelStatus {
+ byte predictor;
+ int16 delta;
+ int16 coeff1;
+ int16 coeff2;
+ int16 sample1;
+ int16 sample2;
+ };
+
+ struct adpcmStatus {
+ // OKI/IMA
+ struct {
+ int32 last;
+ int32 stepIndex;
+ } ima_ch[2];
+
+ // Apple QuickTime IMA ADPCM
+ int32 streamPos[2];
+
+ // MS ADPCM
+ ADPCMChannelStatus ch[2];
+
+ // Tinsel
+ double predictor;
+ double K0, K1;
+ double d0, d1;
+ } _status;
+
+ void reset();
+ int16 stepAdjust(byte);
+ int16 decodeOKI(byte);
+ int16 decodeIMA(byte code, int channel = 0); // Default to using the left channel/using one channel
+ int16 decodeMS(ADPCMChannelStatus *c, byte);
+ int16 decodeTinsel(int16, double);
+
+public:
+ ADPCMInputStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign);
+ ~ADPCMInputStream();
+
+ int readBuffer(int16 *buffer, const int numSamples);
+ int readBufferOKI(int16 *buffer, const int numSamples);
+ int readBufferIMA(int16 *buffer, const int numSamples);
+ int readBufferMSIMA1(int16 *buffer, const int numSamples);
+ int readBufferMSIMA2(int16 *buffer, const int numSamples);
+ int readBufferMS(int channels, int16 *buffer, const int numSamples);
+ void readBufferTinselHeader();
+ int readBufferTinsel4(int channels, int16 *buffer, const int numSamples);
+ int readBufferTinsel6(int channels, int16 *buffer, const int numSamples);
+ int readBufferTinsel8(int channels, int16 *buffer, const int numSamples);
+ int readBufferApple(int16 *buffer, const int numSamples);
+
+ bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
+ bool isStereo() const { return _channels == 2; }
+ int getRate() const { return _rate; }
+
+ bool rewind();
+};
+
+// Routines to convert 12 bit linear samples to the
+// Dialogic or Oki ADPCM coding format aka VOX.
+// See also <http://www.comptek.ru/telephony/tnotes/tt1-13.html>
+//
+// IMA ADPCM support is based on
+// <http://wiki.multimedia.cx/index.php?title=IMA_ADPCM>
+//
+// In addition, also MS IMA ADPCM is supported. See
+// <http://wiki.multimedia.cx/index.php?title=Microsoft_IMA_ADPCM>.
+
+ADPCMInputStream::ADPCMInputStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign)
+ : _stream(stream), _disposeAfterUse(disposeAfterUse), _channels(channels), _type(type), _blockAlign(blockAlign), _rate(rate) {
+
+ if (type == kADPCMMSIma && blockAlign == 0)
+ error("ADPCMInputStream(): blockAlign isn't specified for MS IMA ADPCM");
+ if (type == kADPCMMS && blockAlign == 0)
+ error("ADPCMInputStream(): blockAlign isn't specified for MS ADPCM");
+
+ if (type == kADPCMTinsel4 && blockAlign == 0)
+ error("ADPCMInputStream(): blockAlign isn't specified for Tinsel 4-bit ADPCM");
+ if (type == kADPCMTinsel6 && blockAlign == 0)
+ error("ADPCMInputStream(): blockAlign isn't specified for Tinsel 6-bit ADPCM");
+ if (type == kADPCMTinsel8 && blockAlign == 0)
+ error("ADPCMInputStream(): blockAlign isn't specified for Tinsel 8-bit ADPCM");
+
+ if (type == kADPCMTinsel4 && channels != 1)
+ error("ADPCMInputStream(): Tinsel 4-bit ADPCM only supports mono");
+ if (type == kADPCMTinsel6 && channels != 1)
+ error("ADPCMInputStream(): Tinsel 6-bit ADPCM only supports mono");
+ if (type == kADPCMTinsel8 && channels != 1)
+ error("ADPCMInputStream(): Tinsel 8-bit ADPCM only supports mono");
+
+ _startpos = stream->pos();
+ _endpos = _startpos + size;
+ reset();
+}
+
+ADPCMInputStream::~ADPCMInputStream() {
+ if (_disposeAfterUse)
+ delete _stream;
+}
+
+void ADPCMInputStream::reset() {
+ memset(&_status, 0, sizeof(_status));
+ _blockLen = 0;
+ _blockPos[0] = _blockPos[1] = _blockAlign; // To make sure first header is read
+ _status.streamPos[0] = 0;
+ _status.streamPos[1] = _blockAlign;
+ _chunkPos = 0;
+}
+
+bool ADPCMInputStream::rewind() {
+ // TODO: Error checking.
+ reset();
+ _stream->seek(_startpos);
+ return true;
+}
+
+int ADPCMInputStream::readBuffer(int16 *buffer, const int numSamples) {
+ int samplesDecoded = 0;
+ switch (_type) {
+ case kADPCMOki:
+ samplesDecoded = readBufferOKI(buffer, numSamples);
+ break;
+ case kADPCMMSIma:
+ if (_channels == 1)
+ samplesDecoded = readBufferMSIMA1(buffer, numSamples);
+ else
+ samplesDecoded = readBufferMSIMA2(buffer, numSamples);
+ break;
+ case kADPCMMS:
+ samplesDecoded = readBufferMS(_channels, buffer, numSamples);
+ break;
+ case kADPCMTinsel4:
+ samplesDecoded = readBufferTinsel4(_channels, buffer, numSamples);
+ break;
+ case kADPCMTinsel6:
+ samplesDecoded = readBufferTinsel6(_channels, buffer, numSamples);
+ break;
+ case kADPCMTinsel8:
+ samplesDecoded = readBufferTinsel8(_channels, buffer, numSamples);
+ break;
+ case kADPCMIma:
+ samplesDecoded = readBufferIMA(buffer, numSamples);
+ break;
+ case kADPCMApple:
+ samplesDecoded = readBufferApple(buffer, numSamples);
+ break;
+ default:
+ error("Unsupported ADPCM encoding");
+ break;
+ }
+
+ return samplesDecoded;
+}
+
+int ADPCMInputStream::readBufferOKI(int16 *buffer, const int numSamples) {
+ int samples;
+ byte data;
+
+ assert(numSamples % 2 == 0);
+
+ for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
+ data = _stream->readByte();
+ buffer[samples] = decodeOKI((data >> 4) & 0x0f);
+ buffer[samples + 1] = decodeOKI(data & 0x0f);
+ }
+ return samples;
+}
+
+int ADPCMInputStream::readBufferIMA(int16 *buffer, const int numSamples) {
+ int samples;
+ byte data;
+
+ assert(numSamples % 2 == 0);
+
+ for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
+ data = _stream->readByte();
+ buffer[samples] = decodeIMA((data >> 4) & 0x0f);
+ buffer[samples + 1] = decodeIMA(data & 0x0f, _channels == 2 ? 1 : 0);
+ }
+ return samples;
+}
+
+int ADPCMInputStream::readBufferApple(int16 *buffer, const int numSamples) {
+ // Need to write 2 samples per channel
+ assert(numSamples % (2 * _channels) == 0);
+
+ // Current sample positions
+ int samples[2] = { 0, 0};
+ // Current data bytes
+ byte data[2] = { 0, 0};
+ // Current nibble selectors
+ bool lowNibble[2] = {true, true};
+
+ // Number of samples per channel
+ int chanSamples = numSamples / _channels;
+
+ for (int i = 0; i < _channels; i++) {
+ _stream->seek(_status.streamPos[i]);
+
+ while ((samples[i] < chanSamples) &&
+ // Last byte read and a new one needed
+ !((_stream->eos() || (_stream->pos() >= _endpos)) && lowNibble[i])) {
+
+ if (_blockPos[i] == _blockAlign) {
+ // 2 byte header per block
+ uint16 temp = _stream->readUint16BE();
+
+ // First 9 bits are the upper bits of the predictor
+ _status.ima_ch[i].last = (int16) (temp & 0xFF80);
+ // Lower 7 bits are the step index
+ _status.ima_ch[i].stepIndex = temp & 0x007F;
+
+ // Clip the step index
+ _status.ima_ch[i].stepIndex = CLIP<int32>(_status.ima_ch[i].stepIndex, 0, 88);
+
+ _blockPos[i] = 2;
+ }
+
+ // First decode the lower nibble, then the upper
+ if (lowNibble[i])
+ data[i] = _stream->readByte();
+
+ int16 sample;
+ if (lowNibble[i])
+ sample = decodeIMA(data[i] & 0x0F, i);
+ else
+ sample = decodeIMA(data[i] >> 4, i);
+
+ // The original is interleaved block-wise, we want it sample-wise
+ buffer[_channels * samples[i] + i] = sample;
+
+ samples[i]++;
+
+ // Different nibble
+ lowNibble[i] = !lowNibble[i];
+
+ // We're about to decode a new lower nibble again, so advance the block position
+ if (lowNibble[i])
+ _blockPos[i]++;
+
+ if (_channels == 2)
+ if (_blockPos[i] == _blockAlign)
+ // We're at the end of the block.
+ // Since the channels are interleaved, skip the next block
+ _stream->skip(MIN<uint32>(_blockAlign, _endpos - _stream->pos()));
+
+ _status.streamPos[i] = _stream->pos();
+ }
+ }
+
+ return samples[0] + samples[1];
+}
+
+int ADPCMInputStream::readBufferMSIMA1(int16 *buffer, const int numSamples) {
+ int samples = 0;
+ byte data;
+
+ assert(numSamples % 2 == 0);
+
+ while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
+ if (_blockPos[0] == _blockAlign) {
+ // read block header
+ _status.ima_ch[0].last = _stream->readSint16LE();
+ _status.ima_ch[0].stepIndex = _stream->readSint16LE();
+ _blockPos[0] = 4;
+ }
+
+ for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
+ data = _stream->readByte();
+ _blockPos[0]++;
+ buffer[samples] = decodeIMA(data & 0x0f);
+ buffer[samples + 1] = decodeIMA((data >> 4) & 0x0f);
+ }
+ }
+ return samples;
+}
+
+
+// Microsoft as usual tries to implement it differently. This method
+// is used for stereo data.
+int ADPCMInputStream::readBufferMSIMA2(int16 *buffer, const int numSamples) {
+ int samples;
+ uint32 data;
+ int nibble;
+ byte k;
+
+ for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos;) {
+ for (int channel = 0; channel < 2; channel++) {
+ data = _stream->readUint32LE();
+
+ for (nibble = 0; nibble < 8; nibble++) {
+ k = ((data & 0xf0000000) >> 28);
+ buffer[samples + channel + nibble * 2] = decodeIMA(k);
+ data <<= 4;
+ }
+ }
+ samples += 16;
+ }
+ return samples;
+}
+
+static const int MSADPCMAdaptCoeff1[] = {
+ 256, 512, 0, 192, 240, 460, 392
+};
+
+static const int MSADPCMAdaptCoeff2[] = {
+ 0, -256, 0, 64, 0, -208, -232
+};
+
+int ADPCMInputStream::readBufferMS(int channels, int16 *buffer, const int numSamples) {
+ int samples;
+ byte data;
+ int i = 0;
+
+ samples = 0;
+
+ while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
+ if (_blockPos[0] == _blockAlign) {
+ // read block header
+ for (i = 0; i < channels; i++) {
+ _status.ch[i].predictor = CLIP(_stream->readByte(), (byte)0, (byte)6);
+ _status.ch[i].coeff1 = MSADPCMAdaptCoeff1[_status.ch[i].predictor];
+ _status.ch[i].coeff2 = MSADPCMAdaptCoeff2[_status.ch[i].predictor];
+ }
+
+ for (i = 0; i < channels; i++)
+ _status.ch[i].delta = _stream->readSint16LE();
+
+ for (i = 0; i < channels; i++)
+ _status.ch[i].sample1 = _stream->readSint16LE();
+
+ for (i = 0; i < channels; i++)
+ buffer[samples++] = _status.ch[i].sample2 = _stream->readSint16LE();
+
+ for (i = 0; i < channels; i++)
+ buffer[samples++] = _status.ch[i].sample1;
+
+ _blockPos[0] = channels * 7;
+ }
+
+ for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
+ data = _stream->readByte();
+ _blockPos[0]++;
+ buffer[samples] = decodeMS(&_status.ch[0], (data >> 4) & 0x0f);
+ buffer[samples + 1] = decodeMS(&_status.ch[channels - 1], data & 0x0f);
+ }
+ }
+
+ return samples;
+}
+
+static const double TinselFilterTable[4][2] = {
+ {0, 0 },
+ {0.9375, 0},
+ {1.796875, -0.8125},
+ {1.53125, -0.859375}
+};
+
+void ADPCMInputStream::readBufferTinselHeader() {
+ uint8 start = _stream->readByte();
+ uint8 filterVal = (start & 0xC0) >> 6;
+
+ if ((start & 0x20) != 0) {
+ //Lower 6 bit are negative
+
+ // Negate
+ start = ~(start | 0xC0) + 1;
+
+ _status.predictor = 1 << start;
+ } else {
+ // Lower 6 bit are positive
+
+ // Truncate
+ start &= 0x1F;
+
+ _status.predictor = ((double) 1.0) / (1 << start);
+ }
+
+ _status.K0 = TinselFilterTable[filterVal][0];
+ _status.K1 = TinselFilterTable[filterVal][1];
+}
+
+int ADPCMInputStream::readBufferTinsel4(int channels, int16 *buffer, const int numSamples) {
+ int samples;
+ uint16 data;
+ const double eVal = 1.142822265;
+
+ samples = 0;
+
+ assert(numSamples % 2 == 0);
+
+ while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
+ if (_blockPos[0] == _blockAlign) {
+ readBufferTinselHeader();
+ _blockPos[0] = 0;
+ }
+
+ for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2, _blockPos[0]++) {
+ // Read 1 byte = 8 bits = two 4 bit blocks
+ data = _stream->readByte();
+ buffer[samples] = decodeTinsel((data << 8) & 0xF000, eVal);
+ buffer[samples+1] = decodeTinsel((data << 12) & 0xF000, eVal);
+ }
+ }
+
+ return samples;
+}
+
+int ADPCMInputStream::readBufferTinsel6(int channels, int16 *buffer, const int numSamples) {
+ int samples;
+ const double eVal = 1.032226562;
+
+ samples = 0;
+
+ while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
+ if (_blockPos[0] == _blockAlign) {
+ readBufferTinselHeader();
+ _blockPos[0] = 0;
+ _chunkPos = 0;
+ }
+
+ for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples++, _chunkPos = (_chunkPos + 1) % 4) {
+
+ switch (_chunkPos) {
+ case 0:
+ _chunkData = _stream->readByte();
+ buffer[samples] = decodeTinsel((_chunkData << 8) & 0xFC00, eVal);
+ break;
+ case 1:
+ _chunkData = (_chunkData << 8) | (_stream->readByte());
+ buffer[samples] = decodeTinsel((_chunkData << 6) & 0xFC00, eVal);
+ _blockPos[0]++;
+ break;
+ case 2:
+ _chunkData = (_chunkData << 8) | (_stream->readByte());
+ buffer[samples] = decodeTinsel((_chunkData << 4) & 0xFC00, eVal);
+ _blockPos[0]++;
+ break;
+ case 3:
+ _chunkData = (_chunkData << 8);
+ buffer[samples] = decodeTinsel((_chunkData << 2) & 0xFC00, eVal);
+ _blockPos[0]++;
+ break;
+ }
+
+ }
+
+ }
+
+ return samples;
+}
+
+int ADPCMInputStream::readBufferTinsel8(int channels, int16 *buffer, const int numSamples) {
+ int samples;
+ byte data;
+ const double eVal = 1.007843258;
+
+ samples = 0;
+
+ while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
+ if (_blockPos[0] == _blockAlign) {
+ readBufferTinselHeader();
+ _blockPos[0] = 0;
+ }
+
+ for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples++, _blockPos[0]++) {
+ // Read 1 byte = 8 bits = one 8 bit block
+ data = _stream->readByte();
+ buffer[samples] = decodeTinsel(data << 8, eVal);
+ }
+ }
+
+ return samples;
+}
+
+static const int MSADPCMAdaptationTable[] = {
+ 230, 230, 230, 230, 307, 409, 512, 614,
+ 768, 614, 512, 409, 307, 230, 230, 230
+};
+
+
+int16 ADPCMInputStream::decodeMS(ADPCMChannelStatus *c, byte code) {
+ int32 predictor;
+
+ predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
+ predictor += (signed)((code & 0x08) ? (code - 0x10) : (code)) * c->delta;
+
+ predictor = CLIP<int32>(predictor, -32768, 32767);
+
+ c->sample2 = c->sample1;
+ c->sample1 = predictor;
+ c->delta = (MSADPCMAdaptationTable[(int)code] * c->delta) >> 8;
+
+ if (c->delta < 16)
+ c->delta = 16;
+
+ return (int16)predictor;
+}
+
+// adjust the step for use on the next sample.
+int16 ADPCMInputStream::stepAdjust(byte code) {
+ static const int16 adjusts[] = {-1, -1, -1, -1, 2, 4, 6, 8};
+
+ return adjusts[code & 0x07];
+}
+
+static const int16 okiStepSize[49] = {
+ 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
+};
+
+// Decode Linear to ADPCM
+int16 ADPCMInputStream::decodeOKI(byte code) {
+ int16 diff, E, samp;
+
+ E = (2 * (code & 0x7) + 1) * okiStepSize[_status.ima_ch[0].stepIndex] / 8;
+ diff = (code & 0x08) ? -E : E;
+ samp = _status.ima_ch[0].last + diff;
+ // Clip the values to +/- 2^11 (supposed to be 12 bits)
+ samp = CLIP<int16>(samp, -2048, 2047);
+
+ _status.ima_ch[0].last = samp;
+ _status.ima_ch[0].stepIndex += stepAdjust(code);
+ _status.ima_ch[0].stepIndex = CLIP<int32>(_status.ima_ch[0].stepIndex, 0, ARRAYSIZE(okiStepSize) - 1);
+
+ // * 16 effectively converts 12-bit input to 16-bit output
+ return samp * 16;
+}
+
+static const uint16 imaStepTable[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
+};
+
+int16 ADPCMInputStream::decodeIMA(byte code, int channel) {
+ int32 E = (2 * (code & 0x7) + 1) * imaStepTable[_status.ima_ch[channel].stepIndex] / 8;
+ int32 diff = (code & 0x08) ? -E : E;
+ int32 samp = CLIP<int32>(_status.ima_ch[channel].last + diff, -32768, 32767);
+
+ _status.ima_ch[channel].last = samp;
+ _status.ima_ch[channel].stepIndex += stepAdjust(code);
+ _status.ima_ch[channel].stepIndex = CLIP<int32>(_status.ima_ch[channel].stepIndex, 0, ARRAYSIZE(imaStepTable) - 1);
+
+ return samp;
+}
+
+int16 ADPCMInputStream::decodeTinsel(int16 code, double eVal) {
+ double sample;
+
+ sample = (double) code;
+ sample *= eVal * _status.predictor;
+ sample += (_status.d0 * _status.K0) + (_status.d1 * _status.K1);
+
+ _status.d1 = _status.d0;
+ _status.d0 = sample;
+
+ return (int16) CLIP<double>(sample, -32768.0, 32767.0);
+}
+
+RewindableAudioStream *makeADPCMStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) {
+ return new ADPCMInputStream(stream, disposeAfterUse, size, type, rate, channels, blockAlign);
+}
+
+} // End of namespace Audio
Copied: scummvm/trunk/sound/decoders/adpcm.h (from rev 47576, scummvm/trunk/sound/adpcm.h)
===================================================================
--- scummvm/trunk/sound/decoders/adpcm.h (rev 0)
+++ scummvm/trunk/sound/decoders/adpcm.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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$
+ *
+ */
+
+/**
+ * @file
+ * Sound decoder used in engines:
+ * - agos
+ * - saga
+ * - scumm
+ * - tinsel
+ */
+
+#ifndef SOUND_ADPCM_H
+#define SOUND_ADPCM_H
+
+#include "common/scummsys.h"
+#include "common/stream.h"
+
+
+namespace Audio {
+
+class AudioStream;
+class RewindableAudioStream;
+
+// There are several types of ADPCM encoding, only some are supported here
+// For all the different encodings, refer to:
+// http://wiki.multimedia.cx/index.php?title=Category:ADPCM_Audio_Codecs
+// Usually, if the audio stream we're trying to play has the FourCC header
+// string intact, it's easy to discern which encoding is used
+enum typesADPCM {
+ kADPCMOki, // Dialogic/Oki ADPCM (aka VOX)
+ kADPCMMSIma, // Microsoft IMA ADPCM
+ kADPCMMS, // Microsoft ADPCM
+ kADPCMTinsel4, // 4-bit ADPCM used by the Tinsel engine
+ kADPCMTinsel6, // 6-bit ADPCM used by the Tinsel engine
+ kADPCMTinsel8, // 8-bit ADPCM used by the Tinsel engine
+ kADPCMIma, // Standard IMA ADPCM
+ kADPCMApple // Apple QuickTime IMA ADPCM
+};
+
+/**
+ * Takes an input stream containing ADPCM compressed sound data and creates
+ * an RewindableAudioStream from that.
+ *
+ * @param stream the SeekableReadStream from which to read the ADPCM data
+ * @param disposeAfterUse whether to delete the stream after use
+ * @param size how many bytes to read from the stream (0 = all)
+ * @param type the compression type used
+ * @param rate the sampling rate
+ * @param channels the number of channels
+ * @param blockAlign block alignment ???
+ * @return a new RewindableAudioStream, or NULL, if an error occured
+ */
+RewindableAudioStream *makeADPCMStream(
+ Common::SeekableReadStream *stream,
+ bool disposeAfterUse,
+ uint32 size, typesADPCM type,
+ int rate = 22050,
+ int channels = 2,
+ uint32 blockAlign = 0);
+
+} // End of namespace Audio
+
+#endif
Copied: scummvm/trunk/sound/decoders/aiff.cpp (from rev 47576, scummvm/trunk/sound/aiff.cpp)
===================================================================
--- scummvm/trunk/sound/decoders/aiff.cpp (rev 0)
+++ scummvm/trunk/sound/decoders/aiff.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -0,0 +1,179 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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$
+ *
+ */
+
+/*
+ * The code in this file is based on information found at
+ * http://www.borg.com/~jglatt/tech/aiff.htm
+ *
+ * We currently only implement uncompressed AIFF. If we ever need AIFF-C, SoX
+ * (http://sox.sourceforge.net) may be a good place to start from.
+ */
+
+#include "common/endian.h"
+#include "common/util.h"
+#include "common/stream.h"
+
+#include "sound/decoders/aiff.h"
+#include "sound/audiostream.h"
+#include "sound/mixer.h"
+#include "sound/decoders/raw.h"
+
+namespace Audio {
+
+uint32 readExtended(Common::SeekableReadStream &stream) {
+ // The sample rate is stored as an "80 bit IEEE Standard 754 floating
+ // point number (Standard Apple Numeric Environment [SANE] data type
+ // Extended).
+
+ byte buf[10];
+ uint32 mantissa;
+ uint32 last = 0;
+ byte exp;
+
+ stream.read(buf, 10);
+ mantissa = READ_BE_UINT32(buf + 2);
+ exp = 30 - buf[1];
+
+ while (exp--) {
+ last = mantissa;
+ mantissa >>= 1;
+ }
+
+ if (last & 0x00000001)
+ mantissa++;
+
+ return mantissa;
+}
+
+bool loadAIFFFromStream(Common::SeekableReadStream &stream, int &size, int &rate, byte &flags) {
+ byte buf[4];
+
+ stream.read(buf, 4);
+ if (memcmp(buf, "FORM", 4) != 0) {
+ warning("loadAIFFFromStream: No 'FORM' header");
+ return false;
+ }
+
+ stream.readUint32BE();
+
+ // This could be AIFC, but we don't handle that case.
+
+ stream.read(buf, 4);
+ if (memcmp(buf, "AIFF", 4) != 0) {
+ warning("loadAIFFFromStream: No 'AIFF' header");
+ return false;
+ }
+
+ // From here on, we only care about the COMM and SSND chunks, which are
+ // the only required chunks.
+
+ bool foundCOMM = false;
+ bool foundSSND = false;
+
+ uint16 numChannels = 0, bitsPerSample = 0;
+ uint32 numSampleFrames = 0, offset = 0, blockSize = 0, soundOffset = 0;
+
+ while (!(foundCOMM && foundSSND) && !stream.err() && !stream.eos()) {
+ uint32 length, pos;
+
+ stream.read(buf, 4);
+ length = stream.readUint32BE();
+ pos = stream.pos();
+
+ if (memcmp(buf, "COMM", 4) == 0) {
+ foundCOMM = true;
+ numChannels = stream.readUint16BE();
+ numSampleFrames = stream.readUint32BE();
+ bitsPerSample = stream.readUint16BE();
+ rate = readExtended(stream);
+ size = numSampleFrames * numChannels * (bitsPerSample / 8);
+ } else if (memcmp(buf, "SSND", 4) == 0) {
+ foundSSND = true;
+ offset = stream.readUint32BE();
+ blockSize = stream.readUint32BE();
+ soundOffset = stream.pos();
+ }
+
+ stream.seek(pos + length);
+ }
+
+ if (!foundCOMM) {
+ warning("loadAIFFFromStream: Cound not find 'COMM' chunk");
+ return false;
+ }
+
+ if (!foundSSND) {
+ warning("loadAIFFFromStream: Cound not find 'SSND' chunk");
+ return false;
+ }
+
+ // We only implement a subset of the AIFF standard.
+
+ if (numChannels < 1 || numChannels > 2) {
+ warning("loadAIFFFromStream: Only 1 or 2 channels are supported, not %d", numChannels);
+ return false;
+ }
+
+ if (bitsPerSample != 8 && bitsPerSample != 16) {
+ warning("loadAIFFFromStream: Only 8 or 16 bits per sample are supported, not %d", bitsPerSample);
+ return false;
+ }
+
+ if (offset != 0 || blockSize != 0) {
+ warning("loadAIFFFromStream: Block-aligned data is not supported");
+ return false;
+ }
+
+ // Samples are always signed, and big endian.
+
+ flags = 0;
+ if (bitsPerSample == 16)
+ flags |= Audio::FLAG_16BITS;
+ if (numChannels == 2)
+ flags |= Audio::FLAG_STEREO;
+
+ stream.seek(soundOffset);
+
+ // Stream now points at the sample data
+
+ return true;
+}
+
+SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream &stream) {
+ int size, rate;
+ byte *data, flags;
+
+ if (!loadAIFFFromStream(stream, size, rate, flags))
+ return 0;
+
+ data = (byte *)malloc(size);
+ assert(data);
+ stream.read(data, size);
+
+ // Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
+ return makeRawMemoryStream(data, size, rate, flags);
+}
+
+} // End of namespace Audio
Copied: scummvm/trunk/sound/decoders/aiff.h (from rev 47576, scummvm/trunk/sound/aiff.h)
===================================================================
--- scummvm/trunk/sound/decoders/aiff.h (rev 0)
+++ scummvm/trunk/sound/decoders/aiff.h 2010-01-26 22:48:45 UTC (rev 47579)
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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$
+ *
+ */
+
+/**
+ * @file
+ * Sound decoder used in engines:
+ * - saga
+ * - sword1
+ */
+
+#ifndef SOUND_AIFF_H
+#define SOUND_AIFF_H
+
+#include "common/scummsys.h"
+
+namespace Common { class SeekableReadStream; }
+
+namespace Audio {
+
+class SeekableAudioStream;
+
+/**
+ * Try to load an AIFF from the given seekable stream. Returns true if
+ * successful. In that case, the stream's seek position will be set to the
+ * start of the audio data, and size, rate and flags contain information
+ * necessary for playback. Currently this function only supports uncompressed
+ * raw PCM data as well as IMA ADPCM.
+ */
+extern bool loadAIFFFromStream(Common::SeekableReadStream &stream, int &size, int &rate, byte &flags);
+
+/**
+ * Try to load an AIFF from the given seekable stream and create an AudioStream
+ * from that data.
+ *
+ * This function uses loadAIFFFromStream() internally.
+ */
+SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream &stream);
+
+} // End of namespace Audio
+
+#endif
Copied: scummvm/trunk/sound/decoders/flac.cpp (from rev 47576, scummvm/trunk/sound/flac.cpp)
===================================================================
--- scummvm/trunk/sound/decoders/flac.cpp (rev 0)
+++ scummvm/trunk/sound/decoders/flac.cpp 2010-01-26 22:48:45 UTC (rev 47579)
@@ -0,0 +1,735 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 "sound/decoders/flac.h"
+
+#ifdef USE_FLAC
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/util.h"
+
+#include "sound/audiostream.h"
+#include "sound/audiocd.h"
+
+#define FLAC__NO_DLL // that MS-magic gave me headaches - just link the library you like
+#include <FLAC/export.h>
+
+
+// check if we have FLAC >= 1.1.3; LEGACY_FLAC code can be removed once FLAC-1.1.3 propagates everywhere
+#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
+#define LEGACY_FLAC
+#else
+#undef LEGACY_FLAC
+#endif
+
+
+#ifdef LEGACY_FLAC
+
+// Before FLAC 1.1.3, we needed to use the stream decoder API.
+#include <FLAC/seekable_stream_decoder.h>
+typedef uint FLAC_size_t;
+
+#else
+
+// With FLAC 1.1.3, the stream decoder API was merged into the regular
+// stream API. In order to stay compatible with older FLAC versions, we
+// simply add some typedefs and #ifdefs to map between the old and new API.
+// We use the typedefs (instead of only #defines) in order to somewhat
+// improve the readability of the code.
+
+#include <FLAC/stream_decoder.h>
+typedef size_t FLAC_size_t;
+// Add aliases for the old names
+typedef FLAC__StreamDecoderState FLAC__SeekableStreamDecoderState;
+typedef FLAC__StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus;
+typedef FLAC__StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus;
+typedef FLAC__StreamDecoderTellStatus FLAC__SeekableStreamDecoderTellStatus;
+typedef FLAC__StreamDecoderLengthStatus FLAC__SeekableStreamDecoderLengthStatus;
+typedef FLAC__StreamDecoder FLAC__SeekableStreamDecoder;
+
+#endif
+
+
+namespace Audio {
+
+#pragma mark -
+#pragma mark --- Flac stream ---
+#pragma mark -
+
+static const uint MAX_OUTPUT_CHANNELS = 2;
+
+
+class FlacInputStream : public SeekableAudioStream {
+protected:
+ Common::SeekableReadStream *_inStream;
+ bool _disposeAfterUse;
+
+ ::FLAC__SeekableStreamDecoder *_decoder;
+
+ /** Header of the stream */
+ FLAC__StreamMetadata_StreamInfo _streaminfo;
+
+ /** index + 1(!) of the last sample to be played */
+ FLAC__uint64 _lastSample;
+
+ /** total play time */
+ Timestamp _length;
+
+ /** true if the last sample was decoded from the FLAC-API - there might still be data in the buffer */
+ bool _lastSampleWritten;
+
+ typedef int16 SampleType;
+ enum { BUFTYPE_BITS = 16 };
+
+ enum {
+ // Maximal buffer size. According to the FLAC format specification, the block size is
+ // a 16 bit value (in fact it seems the maximal block size is 32768, but we play it safe).
+ BUFFER_SIZE = 65536
+ };
+
+ struct {
+ SampleType bufData[BUFFER_SIZE];
+ SampleType *bufReadPos;
+ uint bufFill;
+ } _sampleCache;
+
+ SampleType *_outBuffer;
+ uint _requestedSamples;
+
+ typedef void (*PFCONVERTBUFFERS)(SampleType*, const FLAC__int32*[], uint, const uint, const uint8);
+ PFCONVERTBUFFERS _methodConvertBuffers;
+
+
+public:
+ FlacInputStream(Common::SeekableReadStream *inStream, bool dispose);
+ virtual ~FlacInputStream();
+
+ int readBuffer(int16 *buffer, const int numSamples);
+
+ bool isStereo() const { return _streaminfo.channels >= 2; }
+ int getRate() const { return _streaminfo.sample_rate; }
+ bool endOfData() const {
+ // End of data is reached if there either is no valid stream data available,
+ // or if we reached the last sample and completely emptied the sample cache.
+ return _streaminfo.channels == 0 || (_lastSampleWritten && _sampleCache.bufFill == 0);
+ }
+
+ bool seek(const Timestamp &where);
+ Timestamp getLength() const { return _length; }
+
+ bool isStreamDecoderReady() const { return getStreamDecoderState() == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC ; }
+protected:
+ uint getChannels() const { return MIN<uint>(_streaminfo.channels, MAX_OUTPUT_CHANNELS); }
+
+ bool allocateBuffer(uint minSamples);
+
+ inline FLAC__StreamDecoderState getStreamDecoderState() const;
+
+ inline bool processSingleBlock();
+ inline bool processUntilEndOfMetadata();
+ bool seekAbsolute(FLAC__uint64 sample);
+
+ inline ::FLAC__SeekableStreamDecoderReadStatus callbackRead(FLAC__byte buffer[], FLAC_size_t *bytes);
+ inline ::FLAC__SeekableStreamDecoderSeekStatus callbackSeek(FLAC__uint64 absoluteByteOffset);
+ inline ::FLAC__SeekableStreamDecoderTellStatus callbackTell(FLAC__uint64 *absoluteByteOffset);
+ inline ::FLAC__SeekableStreamDecoderLengthStatus callbackLength(FLAC__uint64 *streamLength);
+ inline bool callbackEOF();
+ inline ::FLAC__StreamDecoderWriteStatus callbackWrite(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
+ inline void callbackMetadata(const ::FLAC__StreamMetadata *metadata);
+ inline void callbackError(::FLAC__StreamDecoderErrorStatus status);
+
+private:
+ static ::FLAC__SeekableStreamDecoderReadStatus callWrapRead(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], FLAC_size_t *bytes, void *clientData);
+ static ::FLAC__SeekableStreamDecoderSeekStatus callWrapSeek(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absoluteByteOffset, void *clientData);
+ static ::FLAC__SeekableStreamDecoderTellStatus callWrapTell(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absoluteByteOffset, void *clientData);
+ static ::FLAC__SeekableStreamDecoderLengthStatus callWrapLength(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *streamLength, void *clientData);
+ static FLAC__bool callWrapEOF(const ::FLAC__SeekableStreamDecoder *decoder, void *clientData);
+ static ::FLAC__StreamDecoderWriteStatus callWrapWrite(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *clientData);
+ static void callWrapMetadata(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *clientData);
+ static void callWrapError(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *clientData);
+
+ void setBestConvertBufferMethod();
+ static void convertBuffersGeneric(SampleType* bufDestination, const FLAC__int32 *inChannels[], uint numSamples, const uint numChannels, const uint8 numBits);
+ static void convertBuffersStereoNS(SampleType* bufDestination, const FLAC__int32 *inChannels[], uint numSamples, const uint numChannels, const uint8 numBits);
+ static void convertBuffersStereo8Bit(SampleType* bufDestination, const FLAC__int32 *inChannels[], uint numSamples, const uint numChannels, const uint8 numBits);
+ static void convertBuffersMonoNS(SampleType* bufDestination, const FLAC__int32 *inChannels[], uint numSamples, const uint numChannels, const uint8 numBits);
+ static void convertBuffersMono8Bit(SampleType* bufDestination, const FLAC__int32 *inChannels[], uint numSamples, const uint numChannels, const uint8 numBits);
+};
+
+FlacInputStream::FlacInputStream(Common::SeekableReadStream *inStream, bool dispose)
+#ifdef LEGACY_FLAC
+ : _decoder(::FLAC__seekable_stream_decoder_new()),
+#else
+ : _decoder(::FLAC__stream_decoder_new()),
+#endif
+ _inStream(inStream),
+ _disposeAfterUse(dispose),
+ _length(0, 1000), _lastSample(0),
+ _outBuffer(NULL), _requestedSamples(0), _lastSampleWritten(false),
+ _methodConvertBuffers(&FlacInputStream::convertBuffersGeneric)
+{
+ assert(_inStream);
+ memset(&_streaminfo, 0, sizeof(_streaminfo));
+
+ _sampleCache.bufReadPos = NULL;
+ _sampleCache.bufFill = 0;
+
+ _methodConvertBuffers = &FlacInputStream::convertBuffersGeneric;
+
+ bool success;
+#ifdef LEGACY_FLAC
+ ::FLAC__seekable_stream_decoder_set_read_callback(_decoder, &FlacInputStream::callWrapRead);
@@ 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