summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
committerBjörn Stenberg <bjorn@haxx.se>2007-01-08 23:53:00 +0000
commit7039a05147b8bbfc829babea1c65bd436450b505 (patch)
tree4ba555eb84ed97b72b0575034d5b0530a393713e
parent6d4c19707ef95942e323cbdc89fbbfdbe45e7cc5 (diff)
downloadrockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.gz
rockbox-7039a05147b8bbfc829babea1c65bd436450b505.zip
Splitting out songdbj
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11953 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--songdbj/AlbumEntry.java76
-rw-r--r--songdbj/ArtistEntry.java56
-rw-r--r--songdbj/Entry.java14
-rw-r--r--songdbj/FileEntry.java155
-rw-r--r--songdbj/MpegInfo.java367
-rw-r--r--songdbj/OggVorbisInfo.java311
-rw-r--r--songdbj/RundbEntry.java28
-rw-r--r--songdbj/RuntimeDatabase.java81
-rw-r--r--songdbj/SongDB.java74
-rw-r--r--songdbj/SongEntry.java167
-rw-r--r--songdbj/TagDatabase.java377
-rw-r--r--songdbj/TagInfo.java112
-rwxr-xr-xsongdbj/build.sh2
-rw-r--r--songdbj/classes/META-INF/MANIFEST.MF4
-rw-r--r--songdbj/classes/META-INF/services/javax.sound.sampled.spi.AudioFileReader4
-rw-r--r--songdbj/classes/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider3
-rw-r--r--songdbj/com/jcraft/jogg/Buffer.java541
-rw-r--r--songdbj/com/jcraft/jogg/Packet.java82
-rw-r--r--songdbj/com/jcraft/jogg/Page.java973
-rw-r--r--songdbj/com/jcraft/jogg/StreamState.java657
-rw-r--r--songdbj/com/jcraft/jogg/SyncState.java275
-rw-r--r--songdbj/com/jcraft/jorbis/AllocChain.java31
-rw-r--r--songdbj/com/jcraft/jorbis/Block.java188
-rw-r--r--songdbj/com/jcraft/jorbis/ChainingExample.java61
-rw-r--r--songdbj/com/jcraft/jorbis/CodeBook.java742
-rw-r--r--songdbj/com/jcraft/jorbis/Comment.java252
-rw-r--r--songdbj/com/jcraft/jorbis/DecodeExample.java316
-rw-r--r--songdbj/com/jcraft/jorbis/Drft.java1317
-rw-r--r--songdbj/com/jcraft/jorbis/DspState.java459
-rw-r--r--songdbj/com/jcraft/jorbis/EncodeAuxNearestMatch.java36
-rw-r--r--songdbj/com/jcraft/jorbis/EncodeAuxThreshMatch.java33
-rw-r--r--songdbj/com/jcraft/jorbis/Floor0.java352
-rw-r--r--songdbj/com/jcraft/jorbis/Floor1.java653
-rw-r--r--songdbj/com/jcraft/jorbis/FuncFloor.java45
-rw-r--r--songdbj/com/jcraft/jorbis/FuncMapping.java40
-rw-r--r--songdbj/com/jcraft/jorbis/FuncResidue.java43
-rw-r--r--songdbj/com/jcraft/jorbis/FuncTime.java40
-rw-r--r--songdbj/com/jcraft/jorbis/Info.java516
-rw-r--r--songdbj/com/jcraft/jorbis/InfoMode.java33
-rw-r--r--songdbj/com/jcraft/jorbis/JOrbisException.java35
-rw-r--r--songdbj/com/jcraft/jorbis/Lookup.java154
-rw-r--r--songdbj/com/jcraft/jorbis/Lpc.java254
-rw-r--r--songdbj/com/jcraft/jorbis/Lsp.java111
-rw-r--r--songdbj/com/jcraft/jorbis/Mapping0.java566
-rw-r--r--songdbj/com/jcraft/jorbis/Mdct.java249
-rw-r--r--songdbj/com/jcraft/jorbis/PsyInfo.java72
-rw-r--r--songdbj/com/jcraft/jorbis/PsyLook.java187
-rw-r--r--songdbj/com/jcraft/jorbis/Residue0.java454
-rw-r--r--songdbj/com/jcraft/jorbis/Residue1.java51
-rw-r--r--songdbj/com/jcraft/jorbis/Residue2.java44
-rw-r--r--songdbj/com/jcraft/jorbis/StaticCodeBook.java588
-rw-r--r--songdbj/com/jcraft/jorbis/Time0.java38
-rw-r--r--songdbj/com/jcraft/jorbis/VorbisFile.java1361
-rw-r--r--songdbj/com/jcraft/jorbis/VorbisFile.java.new1240
-rw-r--r--songdbj/de/jarnbjo/ogg/BasicStream.java121
-rw-r--r--songdbj/de/jarnbjo/ogg/CachedUrlStream.java252
-rw-r--r--songdbj/de/jarnbjo/ogg/EndOfOggStreamException.java45
-rw-r--r--songdbj/de/jarnbjo/ogg/FileStream.java154
-rw-r--r--songdbj/de/jarnbjo/ogg/LogicalOggStream.java151
-rw-r--r--songdbj/de/jarnbjo/ogg/LogicalOggStreamImpl.java213
-rw-r--r--songdbj/de/jarnbjo/ogg/OggFormatException.java50
-rw-r--r--songdbj/de/jarnbjo/ogg/OggPage.java431
-rw-r--r--songdbj/de/jarnbjo/ogg/OnDemandUrlStream.java127
-rw-r--r--songdbj/de/jarnbjo/ogg/PhysicalOggStream.java124
-rw-r--r--songdbj/de/jarnbjo/ogg/UncachedUrlStream.java207
-rw-r--r--songdbj/de/jarnbjo/util/audio/FadeableAudioInputStream.java62
-rw-r--r--songdbj/de/jarnbjo/util/io/BitInputStream.java185
-rw-r--r--songdbj/de/jarnbjo/util/io/ByteArrayBitInputStream.java352
-rw-r--r--songdbj/de/jarnbjo/util/io/HuffmanNode.java144
-rw-r--r--songdbj/de/jarnbjo/vorbis/AudioPacket.java328
-rw-r--r--songdbj/de/jarnbjo/vorbis/CodeBook.java275
-rw-r--r--songdbj/de/jarnbjo/vorbis/CommentHeader.java244
-rw-r--r--songdbj/de/jarnbjo/vorbis/Floor.java124
-rw-r--r--songdbj/de/jarnbjo/vorbis/Floor0.java74
-rw-r--r--songdbj/de/jarnbjo/vorbis/Floor1.java324
-rw-r--r--songdbj/de/jarnbjo/vorbis/IdentificationHeader.java120
-rw-r--r--songdbj/de/jarnbjo/vorbis/Mapping.java59
-rw-r--r--songdbj/de/jarnbjo/vorbis/Mapping0.java146
-rw-r--r--songdbj/de/jarnbjo/vorbis/MdctFloat.java321
-rw-r--r--songdbj/de/jarnbjo/vorbis/Mode.java75
-rw-r--r--songdbj/de/jarnbjo/vorbis/Residue.java260
-rw-r--r--songdbj/de/jarnbjo/vorbis/Residue0.java53
-rw-r--r--songdbj/de/jarnbjo/vorbis/Residue1.java55
-rw-r--r--songdbj/de/jarnbjo/vorbis/Residue2.java123
-rw-r--r--songdbj/de/jarnbjo/vorbis/SetupHeader.java131
-rw-r--r--songdbj/de/jarnbjo/vorbis/Util.java127
-rw-r--r--songdbj/de/jarnbjo/vorbis/VorbisAudioFileReader.java217
-rw-r--r--songdbj/de/jarnbjo/vorbis/VorbisFormatException.java51
-rw-r--r--songdbj/de/jarnbjo/vorbis/VorbisStream.java247
-rw-r--r--songdbj/entagged/audioformats/AudioFile.java186
-rw-r--r--songdbj/entagged/audioformats/EncodingInfo.java116
-rw-r--r--songdbj/entagged/audioformats/Tag.java116
-rw-r--r--songdbj/entagged/audioformats/asf/AsfFileReader.java112
-rw-r--r--songdbj/entagged/audioformats/asf/data/AsfHeader.java279
-rw-r--r--songdbj/entagged/audioformats/asf/data/AudioStreamChunk.java292
-rw-r--r--songdbj/entagged/audioformats/asf/data/Chunk.java135
-rw-r--r--songdbj/entagged/audioformats/asf/data/ContentDescription.java251
-rw-r--r--songdbj/entagged/audioformats/asf/data/ContentDescriptor.java517
-rw-r--r--songdbj/entagged/audioformats/asf/data/EncodingChunk.java95
-rw-r--r--songdbj/entagged/audioformats/asf/data/ExtendedContentDescription.java299
-rw-r--r--songdbj/entagged/audioformats/asf/data/FileHeader.java235
-rw-r--r--songdbj/entagged/audioformats/asf/data/GUID.java329
-rw-r--r--songdbj/entagged/audioformats/asf/data/StreamChunk.java173
-rw-r--r--songdbj/entagged/audioformats/asf/data/VideoStreamChunk.java98
-rw-r--r--songdbj/entagged/audioformats/asf/data/wrapper/ContentDescriptorTagField.java130
-rw-r--r--songdbj/entagged/audioformats/asf/io/AsfHeaderReader.java178
-rw-r--r--songdbj/entagged/audioformats/asf/io/ChunkHeaderReader.java57
-rw-r--r--songdbj/entagged/audioformats/asf/io/ContentDescriptionReader.java175
-rw-r--r--songdbj/entagged/audioformats/asf/io/EncodingChunkReader.java118
-rw-r--r--songdbj/entagged/audioformats/asf/io/ExtContentDescReader.java182
-rw-r--r--songdbj/entagged/audioformats/asf/io/FileHeaderReader.java116
-rw-r--r--songdbj/entagged/audioformats/asf/io/StreamChunkReader.java187
-rw-r--r--songdbj/entagged/audioformats/asf/util/ChunkPositionComparator.java52
-rw-r--r--songdbj/entagged/audioformats/asf/util/TagConverter.java234
-rw-r--r--songdbj/entagged/audioformats/asf/util/Utils.java306
-rw-r--r--songdbj/entagged/audioformats/exceptions/CannotReadException.java33
-rw-r--r--songdbj/entagged/audioformats/exceptions/CannotWriteException.java33
-rw-r--r--songdbj/entagged/audioformats/generic/AbstractTag.java308
-rw-r--r--songdbj/entagged/audioformats/generic/AbstractTagCreator.java66
-rw-r--r--songdbj/entagged/audioformats/generic/AudioFileReader.java126
-rw-r--r--songdbj/entagged/audioformats/generic/GenericTag.java133
-rw-r--r--songdbj/entagged/audioformats/generic/OldTag.java382
-rw-r--r--songdbj/entagged/audioformats/generic/TagField.java43
-rw-r--r--songdbj/entagged/audioformats/generic/TagTextField.java33
-rw-r--r--songdbj/entagged/audioformats/generic/Utils.java95
-rw-r--r--songdbj/javazoom/jl/converter/Converter.java411
-rw-r--r--songdbj/javazoom/jl/converter/RiffFile.java495
-rw-r--r--songdbj/javazoom/jl/converter/WaveFile.java522
-rw-r--r--songdbj/javazoom/jl/converter/WaveFileObuffer.java141
-rw-r--r--songdbj/javazoom/jl/converter/jlc.java216
-rw-r--r--songdbj/javazoom/jl/decoder/BitReserve.java223
-rw-r--r--songdbj/javazoom/jl/decoder/Bitstream.java655
-rw-r--r--songdbj/javazoom/jl/decoder/BitstreamErrors.java72
-rw-r--r--songdbj/javazoom/jl/decoder/BitstreamException.java71
-rw-r--r--songdbj/javazoom/jl/decoder/Control.java57
-rw-r--r--songdbj/javazoom/jl/decoder/Crc16.java70
-rw-r--r--songdbj/javazoom/jl/decoder/Decoder.java357
-rw-r--r--songdbj/javazoom/jl/decoder/DecoderErrors.java38
-rw-r--r--songdbj/javazoom/jl/decoder/DecoderException.java61
-rw-r--r--songdbj/javazoom/jl/decoder/Equalizer.java227
-rw-r--r--songdbj/javazoom/jl/decoder/FrameDecoder.java38
-rw-r--r--songdbj/javazoom/jl/decoder/Header.java762
-rw-r--r--songdbj/javazoom/jl/decoder/InputStreamSource.java80
-rw-r--r--songdbj/javazoom/jl/decoder/JavaLayerError.java31
-rw-r--r--songdbj/javazoom/jl/decoder/JavaLayerErrors.java40
-rw-r--r--songdbj/javazoom/jl/decoder/JavaLayerException.java80
-rw-r--r--songdbj/javazoom/jl/decoder/JavaLayerHook.java36
-rw-r--r--songdbj/javazoom/jl/decoder/JavaLayerUtils.java207
-rw-r--r--songdbj/javazoom/jl/decoder/LayerIDecoder.java444
-rw-r--r--songdbj/javazoom/jl/decoder/LayerIIDecoder.java1064
-rw-r--r--songdbj/javazoom/jl/decoder/LayerIIIDecoder.java2439
-rw-r--r--songdbj/javazoom/jl/decoder/Manager.java46
-rw-r--r--songdbj/javazoom/jl/decoder/Obuffer.java88
-rw-r--r--songdbj/javazoom/jl/decoder/OutputChannels.java143
-rw-r--r--songdbj/javazoom/jl/decoder/SampleBuffer.java132
-rw-r--r--songdbj/javazoom/jl/decoder/Source.java49
-rw-r--r--songdbj/javazoom/jl/decoder/SynthesisFilter.java1817
-rw-r--r--songdbj/javazoom/jl/decoder/au2lin.serbin539 -> 0 bytes
-rw-r--r--songdbj/javazoom/jl/decoder/huffcodetab.java600
-rw-r--r--songdbj/javazoom/jl/decoder/l3reorder.serbin13925 -> 0 bytes
-rw-r--r--songdbj/javazoom/jl/decoder/lin2au.serbin16411 -> 0 bytes
-rw-r--r--songdbj/javazoom/jl/decoder/readme.txt15
-rw-r--r--songdbj/javazoom/jl/decoder/sfd.serbin2075 -> 0 bytes
-rw-r--r--songdbj/javazoom/jl/player/AudioDevice.java103
-rw-r--r--songdbj/javazoom/jl/player/AudioDeviceBase.java177
-rw-r--r--songdbj/javazoom/jl/player/AudioDeviceFactory.java87
-rw-r--r--songdbj/javazoom/jl/player/FactoryRegistry.java129
-rw-r--r--songdbj/javazoom/jl/player/JavaSoundAudioDevice.java215
-rw-r--r--songdbj/javazoom/jl/player/JavaSoundAudioDeviceFactory.java85
-rw-r--r--songdbj/javazoom/jl/player/NullAudioDevice.java37
-rw-r--r--songdbj/javazoom/jl/player/Player.java251
-rw-r--r--songdbj/javazoom/jl/player/PlayerApplet.java246
-rw-r--r--songdbj/javazoom/jl/player/advanced/AdvancedPlayer.java242
-rw-r--r--songdbj/javazoom/jl/player/advanced/PlaybackEvent.java51
-rw-r--r--songdbj/javazoom/jl/player/advanced/PlaybackListener.java30
-rw-r--r--songdbj/javazoom/jl/player/advanced/jlap.java116
-rw-r--r--songdbj/javazoom/jl/player/jlp.java176
-rw-r--r--songdbj/javazoom/spi/PropertiesContainer.java31
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/convert/DecodedMpegAudioInputStream.java334
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/convert/MpegFormatConversionProvider.java120
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/IcyListener.java131
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileFormat.java103
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileReader.java772
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFormat.java67
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/MpegEncoding.java47
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/MpegFileFormatType.java40
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyInputStream.java412
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyTag.java42
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3MetadataParser.java50
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3Tag.java52
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3TagParseSupport.java62
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/StringableTag.java36
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseEvent.java44
-rw-r--r--songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseListener.java37
-rw-r--r--songdbj/javazoom/spi/vorbis/sampled/convert/DecodedVorbisAudioInputStream.java519
-rw-r--r--songdbj/javazoom/spi/vorbis/sampled/convert/VorbisFormatConversionProvider.java244
-rw-r--r--songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileFormat.java85
-rw-r--r--songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileReader.java502
-rw-r--r--songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFormat.java66
-rw-r--r--songdbj/javazoom/spi/vorbis/sampled/file/VorbisEncoding.java41
-rw-r--r--songdbj/javazoom/spi/vorbis/sampled/file/VorbisFileFormatType.java41
-rw-r--r--songdbj/net/shredzone/ifish/ltr/FormatDecodeException.java66
-rw-r--r--songdbj/net/shredzone/ifish/ltr/LTR.java251
-rw-r--r--songdbj/net/shredzone/ifish/ltr/LTRmp3.java165
-rw-r--r--songdbj/net/shredzone/ifish/ltr/OggFastFileStream.java249
-rw-r--r--songdbj/net/shredzone/ifish/ltr/TagAsf.java170
-rw-r--r--songdbj/net/shredzone/ifish/ltr/TagMp3v1.java184
-rw-r--r--songdbj/net/shredzone/ifish/ltr/TagMp3v2.java441
-rw-r--r--songdbj/net/shredzone/ifish/ltr/TagMp3v200.java373
-rw-r--r--songdbj/net/shredzone/ifish/ltr/TagOggVorbis.java207
-rw-r--r--songdbj/org/tritonus/file/AiffAudioFileReader.java244
-rw-r--r--songdbj/org/tritonus/file/AiffAudioFileWriter.java104
-rw-r--r--songdbj/org/tritonus/file/AiffAudioOutputStream.java205
-rw-r--r--songdbj/org/tritonus/file/AiffTool.java82
-rw-r--r--songdbj/org/tritonus/file/AuAudioFileReader.java185
-rw-r--r--songdbj/org/tritonus/file/AuAudioFileWriter.java104
-rw-r--r--songdbj/org/tritonus/file/AuAudioOutputStream.java121
-rw-r--r--songdbj/org/tritonus/file/AuTool.java95
-rw-r--r--songdbj/org/tritonus/file/WaveAudioFileReader.java300
-rw-r--r--songdbj/org/tritonus/file/WaveAudioFileWriter.java103
-rw-r--r--songdbj/org/tritonus/file/WaveAudioOutputStream.java201
-rw-r--r--songdbj/org/tritonus/file/WaveTool.java115
-rw-r--r--songdbj/org/tritonus/file/gsm/GSMAudioFileReader.java142
-rw-r--r--songdbj/org/tritonus/file/gsm/GSMAudioFileWriter.java77
-rw-r--r--songdbj/org/tritonus/file/gsm/package.html10
-rw-r--r--songdbj/org/tritonus/file/jorbis/JorbisAudioFileReader.java231
-rw-r--r--songdbj/org/tritonus/file/jorbis/package.html10
-rw-r--r--songdbj/org/tritonus/file/mpeg/MpegAudioFileWriter.java75
-rw-r--r--songdbj/org/tritonus/file/mpeg/package.html10
-rw-r--r--songdbj/org/tritonus/file/package.html10
-rw-r--r--songdbj/org/tritonus/file/pvorbis/VorbisAudioFileReader.java302
-rw-r--r--songdbj/org/tritonus/file/pvorbis/VorbisAudioFileWriter.java75
-rw-r--r--songdbj/org/tritonus/file/pvorbis/package.html12
-rw-r--r--songdbj/org/tritonus/file/vorbis/VorbisAudioFileReader.java302
-rw-r--r--songdbj/org/tritonus/file/vorbis/VorbisAudioFileWriter.java75
-rw-r--r--songdbj/org/tritonus/file/vorbis/package.html12
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Buffer.java173
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Ogg.java104
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Packet.java113
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Page.java131
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/StreamState.java143
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/SyncState.java127
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/package.html12
-rw-r--r--songdbj/org/tritonus/lowlevel/pogg/Buffer.java284
-rw-r--r--songdbj/org/tritonus/lowlevel/pogg/Ogg.java104
-rw-r--r--songdbj/org/tritonus/lowlevel/pogg/Packet.java133
-rw-r--r--songdbj/org/tritonus/lowlevel/pogg/Page.java298
-rw-r--r--songdbj/org/tritonus/lowlevel/pogg/StreamState.java703
-rw-r--r--songdbj/org/tritonus/lowlevel/pogg/SyncState.java339
-rw-r--r--songdbj/org/tritonus/lowlevel/pogg/package.html12
-rw-r--r--songdbj/org/tritonus/share/ArraySet.java87
-rw-r--r--songdbj/org/tritonus/share/GlobalInfo.java60
-rw-r--r--songdbj/org/tritonus/share/StringHashedSet.java112
-rw-r--r--songdbj/org/tritonus/share/TCircularBuffer.java268
-rw-r--r--songdbj/org/tritonus/share/TDebug.java192
-rw-r--r--songdbj/org/tritonus/share/TNotifier.java140
-rw-r--r--songdbj/org/tritonus/share/TSettings.java75
-rw-r--r--songdbj/org/tritonus/share/package.html10
-rw-r--r--songdbj/org/tritonus/share/sampled/AudioFileTypes.java155
-rw-r--r--songdbj/org/tritonus/share/sampled/AudioFormatSet.java155
-rw-r--r--songdbj/org/tritonus/share/sampled/AudioFormats.java131
-rw-r--r--songdbj/org/tritonus/share/sampled/AudioSystemShadow.java115
-rw-r--r--songdbj/org/tritonus/share/sampled/AudioUtils.java181
-rw-r--r--songdbj/org/tritonus/share/sampled/Encodings.java183
-rw-r--r--songdbj/org/tritonus/share/sampled/FloatSampleBuffer.java734
-rw-r--r--songdbj/org/tritonus/share/sampled/FloatSampleTools.java696
-rw-r--r--songdbj/org/tritonus/share/sampled/TAudioFormat.java110
-rw-r--r--songdbj/org/tritonus/share/sampled/TConversionTool.java1224
-rw-r--r--songdbj/org/tritonus/share/sampled/TVolumeUtils.java55
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/TAsynchronousFilteredAudioInputStream.java256
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java120
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/TEncodingFormatConversionProvider.java129
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/TFormatConversionProvider.java170
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/TMatrixFormatConversionProvider.java182
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/TSimpleFormatConversionProvider.java367
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/TSynchronousFilteredAudioInputStream.java271
-rw-r--r--songdbj/org/tritonus/share/sampled/convert/package.html17
-rw-r--r--songdbj/org/tritonus/share/sampled/file/AudioOutputStream.java113
-rw-r--r--songdbj/org/tritonus/share/sampled/file/HeaderlessAudioOutputStream.java58
-rw-r--r--songdbj/org/tritonus/share/sampled/file/TAudioFileFormat.java113
-rw-r--r--songdbj/org/tritonus/share/sampled/file/TAudioFileReader.java510
-rw-r--r--songdbj/org/tritonus/share/sampled/file/TAudioFileWriter.java484
-rw-r--r--songdbj/org/tritonus/share/sampled/file/TAudioOutputStream.java197
-rw-r--r--songdbj/org/tritonus/share/sampled/file/TDataOutputStream.java79
-rw-r--r--songdbj/org/tritonus/share/sampled/file/THeaderlessAudioFileWriter.java84
-rw-r--r--songdbj/org/tritonus/share/sampled/file/TNonSeekableDataOutputStream.java109
-rw-r--r--songdbj/org/tritonus/share/sampled/file/TSeekableDataOutputStream.java86
-rw-r--r--songdbj/org/tritonus/share/sampled/file/package.html18
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TBaseDataLine.java107
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TBooleanControl.java128
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TClip.java340
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TCompoundControl.java90
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TCompoundControlType.java55
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TControlController.java98
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TControllable.java62
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TDataLine.java304
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TEnumControl.java92
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TFloatControl.java134
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TLine.java362
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TMixer.java506
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TMixerInfo.java56
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TMixerProvider.java240
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TPort.java77
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/TSoftClip.java318
-rw-r--r--songdbj/org/tritonus/share/sampled/mixer/package.html14
-rw-r--r--songdbj/org/tritonus/share/sampled/package.html10
306 files changed, 0 insertions, 63685 deletions
diff --git a/songdbj/AlbumEntry.java b/songdbj/AlbumEntry.java
deleted file mode 100644
index 14c209547b..0000000000
--- a/songdbj/AlbumEntry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-import java.util.*;
-import java.io.*;
-
-public class AlbumEntry extends Entry implements Comparable {
- protected String name;
- protected ArtistEntry artist;
- protected Vector songs;
- protected int songcount;
-
- public AlbumEntry(String n) {
- name=n;
- songs=new Vector();
- artist=null;
- songcount=0;
- }
-
- protected class SongSorter implements Comparator {
- public int compare(Object o1, Object o2) {
- SongEntry s1=(SongEntry)o1;
- SongEntry s2=(SongEntry)o2;
- int track1=s1.getTrack(),track2=s2.getTrack();
- if(track1>track2)
- return 1;
- else if(track1<track2)
- return -1;
- return s1.getFile().getFile().getName().compareTo(s2.getFile().getFile().getName());
- }
- }
-
- public void addSong(SongEntry e) {
- songs.add(e);
- e.setAlbum(this);
- e.setArtist(artist);
- songcount++;
- Collections.sort(songs,new SongSorter());
- }
-
- public int size() { return songcount; }
- public void setArtist(ArtistEntry a) {
- a.addAlbum(this);
- if(artist!=null&&artist!=a&&!artist.getName().equals("<various artists>")) {
- artist.removeAlbum(this);
- artist=TagDatabase.getInstance().getArtistEntry("<various artists>");
- }
- else
- artist=a;
- }
- public ArtistEntry getArtist() { return artist; }
-
- public int compareTo(Object o) {
- return String.CASE_INSENSITIVE_ORDER.compare(name,((AlbumEntry)o).getName());
- }
-
- public String getName() { return name; }
- public Collection getSongs() { return songs; }
- public void write(DataOutputStream w) throws IOException {
- int x;
- w.writeBytes(name);
- for(x=TagDatabase.getInstance().albumlen-name.length();x>0;x--)
- w.write(0);
- w.writeInt(artist.getOffset());
- Iterator i2 = songs.iterator();
- x=0;
- while(i2.hasNext()) {
- Entry e = (Entry) i2.next();
- w.writeInt(e.getOffset());
- x++;
- }
- for(;x<TagDatabase.getInstance().songarraylen;x++)
- w.writeInt(0);
- }
- public static int entrySize() {
- TagDatabase td=TagDatabase.getInstance();
- return td.albumlen+4+td.songarraylen*4;
- }
-} \ No newline at end of file
diff --git a/songdbj/ArtistEntry.java b/songdbj/ArtistEntry.java
deleted file mode 100644
index fcaaac7dee..0000000000
--- a/songdbj/ArtistEntry.java
+++ /dev/null
@@ -1,56 +0,0 @@
-import java.util.*;
-import java.io.*;
-
-public class ArtistEntry extends Entry implements Comparable {
- protected String name;
- protected Vector albums;
- protected int albumcount;
-
- public ArtistEntry(String n) {
- name=n;
- albums=new Vector();
- albumcount=0;
- }
-
- public void addAlbum(AlbumEntry e) {
- if(!albums.contains(e)) {
- albums.add(e);
- e.setArtist(this);
- albumcount++;
- Collections.sort(albums);
- }
- }
-
- public void removeAlbum(AlbumEntry e) {
- albums.remove(e);
- albumcount--;
- }
-
- public int size() { return albumcount; }
-
- public int compareTo(Object o) {
- return String.CASE_INSENSITIVE_ORDER.compare(name,((ArtistEntry)o).getName());
- }
-
- public String getName() { return name; }
- public Collection getAlbums() { return albums; }
- public void write(DataOutputStream w) throws IOException {
- int x;
- w.writeBytes(name);
- for(x=TagDatabase.getInstance().artistlen-name.length();x>0;x--)
- w.write(0);
- Iterator i2 = albums.iterator();
- x=0;
- while(i2.hasNext()) {
- Entry e = (Entry) i2.next();
- w.writeInt(e.getOffset());
- x++;
- }
- for(;x<TagDatabase.getInstance().albumarraylen;x++)
- w.writeInt(0);
- }
- public static int entrySize() {
- TagDatabase td=TagDatabase.getInstance();
- return td.artistlen+4*td.albumarraylen;
- }
-} \ No newline at end of file
diff --git a/songdbj/Entry.java b/songdbj/Entry.java
deleted file mode 100644
index 19ead66c06..0000000000
--- a/songdbj/Entry.java
+++ /dev/null
@@ -1,14 +0,0 @@
-import java.io.*;
-
-public abstract class Entry {
- protected int offset;
-
- public Entry() {
- offset=-1;
- }
-
- public void setOffset(int pos) { offset=pos; }
- public int getOffset() { return offset; }
-
- public abstract void write(DataOutputStream w) throws IOException;
-} \ No newline at end of file
diff --git a/songdbj/FileEntry.java b/songdbj/FileEntry.java
deleted file mode 100644
index 9af5b3d70a..0000000000
--- a/songdbj/FileEntry.java
+++ /dev/null
@@ -1,155 +0,0 @@
-import java.io.*;
-
-public class FileEntry extends Entry implements Comparable {
- protected String filename;
- protected int hash;
- protected SongEntry sentry;
- protected RundbEntry rentry;
- protected File file;
-
- public FileEntry(File f) throws FileNotFoundException, IOException {
- filename=convertPath(f.getAbsolutePath());
- file=f;
- sentry=null;
- rentry=null;
- }
-
- public int compareTo(Object o) {
- return String.CASE_INSENSITIVE_ORDER.compare(filename,((FileEntry)o).getFilename());
- }
-
- public String getFilename() { return filename; }
-
- public File getFile() { return file; }
-
- protected void calcHash() throws FileNotFoundException, IOException {
- DataInputStream r = new DataInputStream(new FileInputStream(file));
- byte[] buf = new byte[32768];
- if(sentry!=null)
- r.skip(sentry.getFirstFrameOffset());
- r.read(buf);
- hash=CalcCRC32(buf);
- r.close();
- }
-
- public int getHash() { return hash; }
-
- public static String add(String t) {
- String add=TagDatabase.getInstance().add;
- if(add!=null)
- return add+t;
- else
- return t;
- }
-
- public static String convertPath(String t) {
- String temp = add(strip(t)).replace('\\','/');
- if (temp.charAt(0)!='/')
- temp="/"+temp;
- return temp;
- }
-
- public static String strip(String t) {
- return stripPrefix(stripDriveletter(stripPrefix(t)));
- }
-
- public static String stripPrefix(String t) {
- String prefix=TagDatabase.getInstance().strip;
- if(prefix!=null&&t.toLowerCase().startsWith(prefix.toLowerCase())) {
- return t.substring(prefix.length());
- }
- return t;
- }
-
- public static String stripDriveletter(String t) {
- if(t.indexOf(':')==1) { // second char is ':'
- return t.substring(2);
- }
- return t;
- }
-
- public void setSongEntry(SongEntry e) { sentry=e; try { calcHash(); } catch(Exception d) { } }
- public void setRundbEntry(RundbEntry e) { rentry=e; }
- public SongEntry getSongEntry() { return sentry; }
- public RundbEntry getRundbEntry() { return rentry; }
- public int getSongEntryOffset() {
- if(sentry!=null)
- return sentry.getOffset();
- else
- return -1;
- }
- public int getRundbEntryOffset() {
-/* if(rentry!=null)
- return rentry.getOffset();
- else*/
- return -1;
- }
- public void write(DataOutputStream w) throws IOException {
- String name=getFilename();
- w.writeBytes(name);
- for(int x=TagDatabase.getInstance().filelen-name.length();x>0;x--)
- w.write(0);
- w.writeInt(hash);
- w.writeInt(getSongEntryOffset());
- w.writeInt(getRundbEntryOffset());
- }
-
- public static int entrySize() {
- return TagDatabase.getInstance().filelen+12;
- }
-
- static final int crc_table[] =
- { // CRC32 lookup table for polynomial 0x04C11DB7
- 0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
- 0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61,
- 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD, 0x4C11DB70, 0x48D0C6C7,
- 0x4593E01E, 0x4152FDA9, 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75,
- 0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3,
- 0x709F7B7A, 0x745E66CD, 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039,
- 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58, 0xBAEA46EF,
- 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D,
- 0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49, 0xC7361B4C, 0xC3F706FB,
- 0xCEB42022, 0xCA753D95, 0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1,
- 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 0x34867077, 0x30476DC0,
- 0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072,
- 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16, 0x018AEB13, 0x054BF6A4,
- 0x0808D07D, 0x0CC9CDCA, 0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE,
- 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08,
- 0x571D7DD1, 0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
- 0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B, 0xBB60ADFC,
- 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6,
- 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A, 0xE0B41DE7, 0xE4750050,
- 0xE9362689, 0xEDF73B3E, 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2,
- 0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34,
- 0xDC3ABDED, 0xD8FBA05A, 0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637,
- 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB, 0x4F040D56, 0x4BC510E1,
- 0x46863638, 0x42472B8F, 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53,
- 0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5,
- 0x3F9B762C, 0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF,
- 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 0xF12F560E, 0xF5EE4BB9,
- 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B,
- 0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD,
- 0xCDA1F604, 0xC960EBB3, 0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7,
- 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71,
- 0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3,
- 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640, 0x4E8EE645, 0x4A4FFBF2,
- 0x470CDD2B, 0x43CDC09C, 0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8,
- 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24, 0x119B4BE9, 0x155A565E,
- 0x18197087, 0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
- 0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D, 0x2056CD3A,
- 0x2D15EBE3, 0x29D4F654, 0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0,
- 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C, 0xE3A1CBC1, 0xE760D676,
- 0xEA23F0AF, 0xEEE2ED18, 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4,
- 0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662,
- 0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668,
- 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
- };
-
- public static int CalcCRC32(byte[] buf) {
- int i;
- int crc = 0xffffffff;
- for (i = 0; i < buf.length; i++)
- crc = (crc << 8) ^ crc_table[(int)((crc >> 24) ^ buf[i]) & 0xFF];
- return crc;
- }
-} \ No newline at end of file
diff --git a/songdbj/MpegInfo.java b/songdbj/MpegInfo.java
deleted file mode 100644
index 6f57879883..0000000000
--- a/songdbj/MpegInfo.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * MpegInfo.
- *
- * JavaZOOM : jlgui@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-
-/**
- * This class gives information (audio format and comments) about MPEG file or URL.
- */
-public class MpegInfo implements TagInfo
-{
- protected int channels = -1;
- protected String channelsMode = null;
- protected String version = null;
- protected int rate = 0;
- protected String layer = null;
- protected String emphasis = null;
- protected int nominalbitrate = 0;
- protected long total = 0;
- protected String vendor = null;
- protected String location = null;
- protected long size = 0;
- protected boolean copyright = false;
- protected boolean crc = false;
- protected boolean original = false;
- protected boolean priv = false;
- protected boolean vbr = false;
- protected int track = -1;
- protected int offset = 0;
- protected String year = null;
- protected String genre = null;
- protected String title = null;
- protected String artist = null;
- protected String album = null;
- protected Vector comments = null;
-
- /**
- * Constructor.
- */
- public MpegInfo()
- {
- super();
- }
-
- /**
- * Load and parse MPEG info from File.
- * @param input
- * @throws IOException
- */
- public void load(File input) throws IOException, UnsupportedAudioFileException
- {
- size = input.length();
- location = input.getPath();
- loadInfo(input);
- }
-
- /**
- * Load and parse MPEG info from URL.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- public void load(URL input) throws IOException, UnsupportedAudioFileException
- {
- location = input.toString();
- loadInfo(input);
- }
-
- /**
- * Load and parse MPEG info from InputStream.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- public void load(InputStream input) throws IOException, UnsupportedAudioFileException
- {
- loadInfo(input);
- }
-
- /**
- * Load info from input stream.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException
- {
- AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
- loadInfo(aff);
- }
-
- /**
- * Load MP3 info from file.
- * @param file
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException
- {
- InputStream in = new BufferedInputStream(new FileInputStream(file));
- loadInfo(in);
- in.close();
- }
-
- /**
- * Load info from AudioFileFormat.
- * @param aff
- */
- protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException
- {
- String type = aff.getType().toString();
- if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format");
- if (aff instanceof TAudioFileFormat)
- {
- Map props = ((TAudioFileFormat) aff).properties();
- if (props.containsKey("mp3.channels")) channels = ((Integer)props.get("mp3.channels")).intValue();
- if (props.containsKey("mp3.frequency.hz")) rate = ((Integer)props.get("mp3.frequency.hz")).intValue();
- if (props.containsKey("mp3.bitrate.nominal.bps")) nominalbitrate = ((Integer)props.get("mp3.bitrate.nominal.bps")).intValue();
- if (props.containsKey("mp3.version.layer")) layer = "Layer "+(String)props.get("mp3.version.layer");
- if (props.containsKey("mp3.version.mpeg"))
- {
- version = (String)props.get("mp3.version.mpeg");
- if (version.equals("1")) version = "MPEG1";
- else if (version.equals("2")) version = "MPEG2-LSF";
- else if (version.equals("2.5")) version = "MPEG2.5-LSF";
- }
- if (props.containsKey("mp3.mode"))
- {
- int mode = ((Integer)props.get("mp3.mode")).intValue();
- if (mode==0) channelsMode = "Stereo";
- else if (mode==1) channelsMode = "Joint Stereo";
- else if (mode==2) channelsMode = "Dual Channel";
- else if (mode==3) channelsMode = "Single Channel";
- }
- if (props.containsKey("mp3.crc")) crc = ((Boolean)props.get("mp3.crc")).booleanValue();
- if (props.containsKey("mp3.vbr")) vbr = ((Boolean)props.get("mp3.vbr")).booleanValue();
- if (props.containsKey("mp3.copyright")) copyright = ((Boolean)props.get("mp3.copyright")).booleanValue();
- if (props.containsKey("mp3.original")) original = ((Boolean)props.get("mp3.original")).booleanValue();
- emphasis="none";
-
- if (props.containsKey("title")) title = (String)props.get("title");
- if (props.containsKey("author")) artist = (String)props.get("author");
- if (props.containsKey("album")) album = (String)props.get("album");
- if (props.containsKey("date")) year = (String)props.get("date");
- if (props.containsKey("duration")) total = (long) Math.round((((Long)props.get("duration")).longValue())/1000000);
- if (props.containsKey("mp3.id3tag.genre")) genre = (String)props.get("mp3.id3tag.genre");
-
- if (props.containsKey("mp3.header.pos")) {
- offset = ((Integer)props.get("mp3.header.pos")).intValue();
- }
- else
- offset = 0;
- if (props.containsKey("mp3.id3tag.track"))
- {
- try
- {
- track = Integer.parseInt((String)props.get("mp3.id3tag.track"));
- }
- catch (NumberFormatException e1)
- {
- // Not a number
- }
- }
- }
- }
-
- /**
- * Load MP3 info from URL.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException
- {
- AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
- loadInfo(aff);
- loadShoutastInfo(aff);
- }
-
- /**
- * Load Shoutcast info from AudioFileFormat.
- * @param aff
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadShoutastInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException
- {
- String type = aff.getType().toString();
- if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format");
- if (aff instanceof TAudioFileFormat)
- {
- Map props = ((TAudioFileFormat) aff).properties();
- // Try shoutcast meta data (if any).
- Iterator it = props.keySet().iterator();
- comments = new Vector();
- while (it.hasNext())
- {
- String key = (String) it.next();
- if (key.startsWith("mp3.shoutcast.metadata."))
- {
- String value = (String) props.get(key);
- key = key.substring(23,key.length());
- if (key.equalsIgnoreCase("icy-name"))
- {
- title = value;
- }
- else if (key.equalsIgnoreCase("icy-genre"))
- {
- genre = value;
- }
- else
- {
- comments.add(key+"="+value);
- }
- }
- }
- }
- }
-
- public boolean getVBR()
- {
- return vbr;
- }
-
- public int getChannels()
- {
- return channels;
- }
-
- public String getVersion()
- {
- return version;
- }
-
- public String getEmphasis()
- {
- return emphasis;
- }
-
- public boolean getCopyright()
- {
- return copyright;
- }
-
- public boolean getCRC()
- {
- return crc;
- }
-
- public boolean getOriginal()
- {
- return original;
- }
-
- public String getLayer()
- {
- return layer;
- }
-
- public long getSize()
- {
- return size;
- }
-
- public String getLocation()
- {
- return location;
- }
-
- /*-- TagInfo Implementation --*/
-
- public int getSamplingRate()
- {
- return rate;
- }
-
- public int getBitRate()
- {
- return nominalbitrate;
- }
-
- public long getPlayTime()
- {
- return total;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public String getArtist()
- {
- return artist;
- }
-
- public String getAlbum()
- {
- return album;
- }
-
- public int getTrack()
- {
- return track;
- }
-
- public String getGenre()
- {
- return genre;
- }
-
- public Vector getComment()
- {
- return comments;
- }
-
- public String getYear()
- {
- return year;
- }
-
- /**
- * Get channels mode.
- * @return
- */
- public String getChannelsMode()
- {
- return channelsMode;
- }
-
- public int getFirstFrameOffset() {
- return offset;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/OggVorbisInfo.java b/songdbj/OggVorbisInfo.java
deleted file mode 100644
index ab07299e77..0000000000
--- a/songdbj/OggVorbisInfo.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * OggVorbisInfo.
- *
- * JavaZOOM : jlgui@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.net.URL;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-
-/**
- * This class gives information (audio format and comments) about Ogg Vorbis file or URL.
- */
-public class OggVorbisInfo implements TagInfo
-{
- protected int serial = 0;
- protected int channels = 0;
- protected int version = 0;
- protected int rate = 0;
- protected int minbitrate = 0;
- protected int maxbitrate = 0;
- protected int averagebitrate = 0;
- protected int nominalbitrate = 0;
- protected long totalms = 0;
- protected String vendor = "";
- protected String location = null;
-
- protected long size = 0;
- protected int track = -1;
- protected String year = null;
- protected String genre = null;
- protected String title = null;
- protected String artist = null;
- protected String album = null;
- protected Vector comments = new Vector();
-
-
- /***
- * Constructor.
- */
- public OggVorbisInfo()
- {
- super();
- }
-
- /**
- * Load and parse Ogg Vorbis info from File.
- * @param input
- * @throws IOException
- */
- public void load(File input) throws IOException, UnsupportedAudioFileException
- {
- size = input.length();
- location = input.getPath();
- loadInfo(input);
- }
-
- /**
- * Load and parse Ogg Vorbis info from URL.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- public void load(URL input) throws IOException, UnsupportedAudioFileException
- {
- location = input.toString();
- loadInfo(input);
- }
-
- /**
- * Load and parse Ogg Vorbis info from InputStream.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- public void load(InputStream input) throws IOException, UnsupportedAudioFileException
- {
- loadInfo(input);
- }
-
- /**
- * Load info from input stream.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException
- {
- AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
- loadInfo(aff);
- }
-
- /**
- * Load Ogg Vorbis info from file.
- * @param file
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException
- {
- InputStream in = new BufferedInputStream(new FileInputStream(file));
- loadInfo(in);
- in.close();
- }
-
- /**
- * Load Ogg Vorbis info from URL.
- * @param input
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException
- {
- AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
- loadInfo(aff);
- loadExtendedInfo(aff);
- }
-
- /**
- * Load info from AudioFileFormat.
- * @param aff
- * @throws UnsupportedAudioFileException
- */
- protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException
- {
- String type = aff.getType().toString();
- if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format");
- if (aff instanceof TAudioFileFormat)
- {
- Map props = ((TAudioFileFormat) aff).properties();
- if (props.containsKey("ogg.channels")) channels = ((Integer)props.get("ogg.channels")).intValue();
- if (props.containsKey("ogg.frequency.hz")) rate = ((Integer)props.get("ogg.frequency.hz")).intValue();
- if (props.containsKey("ogg.bitrate.nominal.bps")) nominalbitrate = ((Integer)props.get("ogg.bitrate.nominal.bps")).intValue();
- averagebitrate = nominalbitrate;
- if (props.containsKey("ogg.bitrate.max.bps")) maxbitrate = ((Integer)props.get("ogg.bitrate.max.bps")).intValue();
- if (props.containsKey("ogg.bitrate.min.bps")) minbitrate = ((Integer)props.get("ogg.bitrate.min.bps")).intValue();
- if (props.containsKey("ogg.version")) version = ((Integer)props.get("ogg.version")).intValue();
- if (props.containsKey("ogg.serial")) serial = ((Integer)props.get("ogg.serial")).intValue();
- if (props.containsKey("ogg.comment.encodedby")) vendor = (String)props.get("ogg.comment.encodedby");
-
- if (props.containsKey("copyright")) comments.add((String)props.get("copyright"));
- if (props.containsKey("title")) title = (String)props.get("title");
- if (props.containsKey("author")) artist = (String)props.get("author");
- if (props.containsKey("album")) album = (String)props.get("album");
- if (props.containsKey("date")) year = (String)props.get("date");
- if (props.containsKey("comment")) comments.add((String)props.get("comment"));
- if (props.containsKey("duration")) totalms = (long) Math.round((((Long)props.get("duration")).longValue())/1000000);
- if (props.containsKey("ogg.comment.genre")) genre = (String)props.get("ogg.comment.genre");
- if (props.containsKey("ogg.comment.track"))
- {
- try
- {
- track = Integer.parseInt((String)props.get("ogg.comment.track"));
- }
- catch (NumberFormatException e1)
- {
- // Not a number
- }
- }
- if (props.containsKey("ogg.comment.ext.1")) comments.add((String)props.get("ogg.comment.ext.1"));
- if (props.containsKey("ogg.comment.ext.2")) comments.add((String)props.get("ogg.comment.ext.2"));
- if (props.containsKey("ogg.comment.ext.3")) comments.add((String)props.get("ogg.comment.ext.3"));
- }
- }
-
- /**
- * Load extended info from AudioFileFormat.
- * @param aff
- * @throws IOException
- * @throws UnsupportedAudioFileException
- */
- protected void loadExtendedInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException
- {
- String type = aff.getType().toString();
- if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format");
- if (aff instanceof TAudioFileFormat)
- {
- Map props = ((TAudioFileFormat) aff).properties();
- // How to load icecast meta data (if any) ??
- }
- }
-
- public int getSerial()
- {
- return serial;
- }
-
- public int getChannels()
- {
- return channels;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- public int getMinBitrate()
- {
- return minbitrate;
- }
-
- public int getMaxBitrate()
- {
- return maxbitrate;
- }
-
- public int getAverageBitrate()
- {
- return averagebitrate;
- }
-
- public long getSize()
- {
- return size;
- }
-
- public String getVendor()
- {
- return vendor;
- }
-
- public String getLocation()
- {
- return location;
- }
-
- /*-- TagInfo Implementation --*/
-
- public int getSamplingRate()
- {
- return rate;
- }
-
- public int getBitRate()
- {
- return nominalbitrate;
- }
-
- public long getPlayTime()
- {
- return totalms;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public String getArtist()
- {
- return artist;
- }
-
- public String getAlbum()
- {
- return album;
- }
-
- public int getTrack()
- {
- return track;
- }
-
- public String getGenre()
- {
- return genre;
- }
-
- public Vector getComment()
- {
- return comments;
- }
-
- public String getYear()
- {
- return year;
- }
-
- public int getFirstFrameOffset() {
- return 0;
- }
-} \ No newline at end of file
diff --git a/songdbj/RundbEntry.java b/songdbj/RundbEntry.java
deleted file mode 100644
index c13cbe4924..0000000000
--- a/songdbj/RundbEntry.java
+++ /dev/null
@@ -1,28 +0,0 @@
-import java.io.*;
-
-public class RundbEntry extends Entry {
- protected FileEntry file;
- protected short rating, voladj;
- protected int playcount,lastplayed;
-
- public RundbEntry(FileEntry f) {
- file=f;
- rating=0;
- voladj=0;
- playcount=0;
- lastplayed=0;
- }
-
- public void write(DataOutputStream w) throws IOException {
- w.writeInt(file.getOffset());
- w.writeInt(file.getHash());
- w.writeShort(rating);
- w.writeShort(voladj);
- w.writeInt(playcount);
- w.writeInt(lastplayed);
- }
-
- public static int entrySize() {
- return 20;
- }
-} \ No newline at end of file
diff --git a/songdbj/RuntimeDatabase.java b/songdbj/RuntimeDatabase.java
deleted file mode 100644
index e96e8207cc..0000000000
--- a/songdbj/RuntimeDatabase.java
+++ /dev/null
@@ -1,81 +0,0 @@
-import java.util.*;
-import java.io.*;
-import java.lang.reflect.Array;
-
-/*
- TreeSet for runtimedatabase with entry hash used in compareto
- fix commandline interface.
-*/
-
-public class RuntimeDatabase {
- protected static RuntimeDatabase instance=null;
- protected TreeMap entries;
- protected int entrycount;
- public static final int headersize = 8;
-
- protected RuntimeDatabase() {
- entries=new TreeMap();
- }
-
- public static RuntimeDatabase getInstance() {
- if(instance==null)
- instance=new RuntimeDatabase();
- return instance;
- }
-
- public RundbEntry getEntry(FileEntry file) {
- Integer key = new Integer(file.getHash());
- if(!entries.containsKey(key)) {
- RundbEntry e = new RundbEntry(file);
- entries.put(key,e);
- return e;
- }
- else
- return (RundbEntry)entries.get(key);
- }
-
- protected void calcOffsets() {
- Collection values = entries.values();
- Iterator i;
- int offset=headersize;
- i=values.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.setOffset(offset);
- offset+=RundbEntry.entrySize();
- }
- entrycount=values.size();
- }
-
- public int isDirty() {
- return 0;
- }
-
- protected void writeHeader(DataOutputStream w) throws IOException {
- w.write('R');
- w.write('R');
- w.write('D');
- w.write(0x1);
- w.writeInt(entrycount);
- }
-
- public void prepareWrite() {
- System.out.println("Calculating Runtime Database Offsets..");
- calcOffsets();
- }
-
- public void writeDatabase(File f) throws IOException {
- int x;
- Iterator i;
- DataOutputStream w = new DataOutputStream(new FileOutputStream(f));
- System.out.println("Writing runtime database..");
- writeHeader(w);
- i=entries.values().iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.write(w);
- }
- w.flush();
- w.close();
- }
-} \ No newline at end of file
diff --git a/songdbj/SongDB.java b/songdbj/SongDB.java
deleted file mode 100644
index 4b7f2aae03..0000000000
--- a/songdbj/SongDB.java
+++ /dev/null
@@ -1,74 +0,0 @@
-import java.io.*;
-import java.lang.reflect.Array;
-
-public class SongDB {
-
- public static final void main(String[] args) {
- TagDatabase td = TagDatabase.getInstance();
- File tdfile = new File("rockbox.tagdb");
- // RuntimeDatabase rd = RuntimeDatabase.getInstance();
- int i = 0, j;
- String arg,path = null;
-
- while (i < args.length) {
- arg = args[i++];
- if (arg.equals("--dirisnotalbumname")) {
- td.dirisalbumname=false;
- }
- else if(arg.equals("--dirisalbum")) {
- td.dirisalbum=true;
- }
- else if(arg.equals("--dontshowduplicates")) {
- td.showduplicates=false;
- }
- else if(arg.equals("--strip")) {
- if (i < args.length)
- td.strip = args[i++];
- else {
- System.err.println("--strip requires a path");
- System.exit(0);
- }
- }
- else if(arg.equals("--add")) {
- if (i < args.length)
- td.add = args[i++];
- else {
- System.err.println("--add requires a path");
- System.exit(0);
- }
- }
- else {
- if(path!=null) {
- System.err.println("you can't specify more than one path!");
- System.exit(0);
- }
- path = arg;
- }
- }
- if (i != args.length||path==null) {
- System.out.println("Usage: SongDB [--showduplicates] [--strip <directory>] [--add <directory>] [--dirisnotalbumname] [--dirisalbum] <directory>");
- return;
- }
- if(tdfile.exists()&&!tdfile.canWrite()) {
- System.out.println("rockbox.tagdb is not writable.");
- return;
- }
- try {
- tdfile.createNewFile();
- }
- catch(Exception e) {
- System.out.println("Error while trying to create rockbox.tagdb: "+e.getMessage());
- return;
- }
- td.add(new File(path));
- try {
- td.prepareWrite();
- // rd.prepareWrite();
- td.writeDatabase(new File("rockbox.tagdb"));
- // rd.writeDatabase(new File("rockbox.rundb"));
- }
- catch(IOException e) {
- System.out.println(e);
- }
- }
-} \ No newline at end of file
diff --git a/songdbj/SongEntry.java b/songdbj/SongEntry.java
deleted file mode 100644
index cf6f887a7b..0000000000
--- a/songdbj/SongEntry.java
+++ /dev/null
@@ -1,167 +0,0 @@
-import java.util.*;
-import java.io.*;
-import javax.sound.sampled.UnsupportedAudioFileException;
-import java.lang.NumberFormatException;
-import net.shredzone.ifish.ltr.LTR;
-
-public class SongEntry extends Entry implements Comparable {
- protected TagInfo info;
- protected LTR tag;
- protected ArtistEntry artist;
- protected AlbumEntry album;
- protected FileEntry file;
-
- public SongEntry(FileEntry f) {
- file=f;
- file.setSongEntry(this);
- readTagInfo();
- }
-
- public void setAlbum(AlbumEntry a) { album=a; }
- public void setArtist(ArtistEntry a) { artist=a; }
- public AlbumEntry getAlbum() { return album; }
- public ArtistEntry getArtist() { return artist; }
- public FileEntry getFile() { return file; }
-
- public int compareTo(Object o) {
- return String.CASE_INSENSITIVE_ORDER.compare(getName(),((SongEntry)o).getName());
- }
-
- public String getName() {
- String title=tag.getTitle();
- if(title==null)
- title = stripExt(file.getFile().getName());
- title=title.trim();
- if(title.equals(""))
- title = stripExt(file.getFile().getName());
- return title;
- }
-
- public static String stripExt(String t) {
- return t.substring(0,t.lastIndexOf('.'));
- }
-
- public String getAlbumTag() {
- String album=tag.getAlbum();
- if(album==null)
- album = "<no album tag>";
- album=album.trim();
- if(album.equals(""))
- album = "<no album tag>";
- if(TagDatabase.getInstance().dirisalbumname&&album.equals("<no album tag>")) {
- album = file.getFile().getParentFile().getName();
- }
- return album;
- }
-
- public String getArtistTag() {
- String artist=tag.getArtist();
- if(artist==null)
- artist = "<no artist tag>";
- artist=artist.trim();
- if(artist.equals(""))
- artist = "<no artist tag>";
- return artist;
- }
-
- public String getGenreTag() {
- String genre=tag.getGenre();
- if(genre==null)
- genre = "<no genre tag>";
- genre=genre.trim();
- if(genre.equals(""))
- genre = "<no genre tag>";
- return genre;
- }
-
- public int getYear() {
- try {
- return Integer.parseInt(tag.getYear());
- } catch(NumberFormatException e) {
- return 0;
- }
- }
-
- public int getTrack() {
- try {
- return Integer.parseInt(tag.getTrack());
- } catch(NumberFormatException e) {
- return 0;
- }
- }
-
- public int getBitRate() { if(info==null) return -1; return info.getBitRate()/1000; }
-
- public int getPlayTime() { if(info==null) return -1; return (int)info.getPlayTime(); }
-
- public int getSamplingRate() { if(info==null) return -1; return info.getSamplingRate(); }
-
- public int getFirstFrameOffset() { if(info==null) return 0; return info.getFirstFrameOffset(); }
-
- public boolean gotTagInfo() { return tag!=null; }
-
- protected void readTagInfo() {
- // Check Mpeg format.
- try
- {
- info = new MpegInfo();
- info.load(file.getFile());
- }
-/* catch (IOException ex)
- {
- //ex.printStackTrace();
- System.out.println(ex);
- info = null;
- }*/
- catch (Exception ex)
- {
- // Error..
- info = null;
- }
-
- if (info == null)
- {
- // Check Ogg Vorbis format.
- try
- {
- info = new OggVorbisInfo();
- info.load(file.getFile());
- }
- /*catch (IOException ex)
- {
- //ex.printStackTrace();
- System.out.println(ex);
- info = null;
- }*/
- catch (Exception ex)
- {
- // Not Ogg Vorbis Format
- //System.out.println("Failed reading tag for "+location.getAbsolutePath()+", tried mp3 and vorbis.");
- info = null;
- }
- }
- tag = LTR.create(file.getFile());
- }
-
- public void write(DataOutputStream w) throws IOException {
- String name=getName();
- w.writeBytes(name);
- for(int x=TagDatabase.getInstance().songlen-name.length();x>0;x--)
- w.write(0);
- w.writeInt(artist.getOffset());
- w.writeInt(album.getOffset());
- w.writeInt(file.getOffset());
- w.writeBytes(getGenreTag());
- for(int x=TagDatabase.getInstance().genrelen-getGenreTag().length();x>0;x--)
- w.write(0);
- w.writeShort(getBitRate());
- w.writeShort(getYear());
- w.writeInt(getPlayTime());
- w.writeShort(getTrack());
- w.writeShort(getSamplingRate());
- }
- public static int entrySize() {
- TagDatabase td=TagDatabase.getInstance();
- return td.songlen+12+td.genrelen+12;
- }
-} \ No newline at end of file
diff --git a/songdbj/TagDatabase.java b/songdbj/TagDatabase.java
deleted file mode 100644
index 36c2c09f37..0000000000
--- a/songdbj/TagDatabase.java
+++ /dev/null
@@ -1,377 +0,0 @@
-import java.util.*;
-import java.io.*;
-import java.lang.reflect.Array;
-
-/*
- TreeSet for runtimedatabase with entry hash used in compareto
- fix commandline interface.
-*/
-
-public class TagDatabase {
- protected static TagDatabase instance=null;
- protected TreeMap songs;
- protected TreeMap files;
- protected TreeMap filehashes;
- protected TreeMap albums;
- protected TreeMap artists;
- protected int artiststart,albumstart,songstart,filestart;
- protected int artistcount,albumcount,songcount,filecount;
- public int artistlen,albumlen,songlen,genrelen,filelen,songarraylen,albumarraylen;
- public String strip,add;
- public boolean haveOldDatabase,dirisalbum,dirisalbumname,showduplicates;
- protected Vector sortedsongs,sortedfiles,sortedalbums,sortedartists;
-
- protected TagDatabase() {
- songs=new TreeMap();
- files=new TreeMap();
- filehashes=new TreeMap();
- albums=new TreeMap();
- artists=new TreeMap();
- strip=null;
- add=null;
- haveOldDatabase=false;
- dirisalbum=false;
- dirisalbumname=true;
- showduplicates=true;
- }
-
- public static TagDatabase getInstance() {
- if(instance==null)
- instance=new TagDatabase();
- return instance;
- }
-
- public void removeFileEntry(File file) {
- String key = file.getAbsolutePath();
- files.remove(key);
- }
-
- public FileEntry getFileEntry(File file) throws FileNotFoundException, IOException {
- String key = file.getAbsolutePath();
- if(!files.containsKey(key)) {
- FileEntry f = new FileEntry(file);
- files.put(key,f);
- return f;
- }
- else
- return (FileEntry)files.get(key);
- }
-
- public ArtistEntry getArtistEntry(String name) {
- String key = name.toLowerCase();
- if(!artists.containsKey(key)) {
- ArtistEntry a = new ArtistEntry(name);
- artists.put(key,a);
- return a;
- }
- else
- return (ArtistEntry)artists.get(key);
- }
-
- public String getAlbumKey(String name, String directory) {
- if(dirisalbum)
- return directory;
- else
- return name.toLowerCase()+"___"+directory;
- }
-
- public AlbumEntry getAlbumEntry(String name,String directory) {
- String key = getAlbumKey(name,directory);
- if(!albums.containsKey(key)) {
- AlbumEntry a = new AlbumEntry(name);
- albums.put(key,a);
- return a;
- }
- else
- return (AlbumEntry)albums.get(key);
- }
-
- public void removeSongEntry(FileEntry file) {
- String key = file.getFilename();
- songs.remove(key);
- file.setSongEntry(null);
- }
-
- public SongEntry getSongEntry(FileEntry file) {
- String key = file.getFilename();
- if(!songs.containsKey(key)) {
- SongEntry s = new SongEntry(file);
- songs.put(key,s);
- return s;
- }
- else
- return (SongEntry)songs.get(key);
- }
-
- private class SongFilter implements FileFilter {
- public boolean accept(File f) {
- if(f.isDirectory()) // always accept directories.
- return true;
- String name=f.getName();
- return name.endsWith(".mp3")||name.endsWith(".ogg");
- }
- }
-
- public void add(File f) {
- if(!f.isDirectory()) {
- if(f.isFile()) {
- addSong(f);
- }
- }
- else {
- File[] files = f.listFiles(new SongFilter());
- int length=Array.getLength(files);
- System.out.println(FileEntry.convertPath(f.getAbsolutePath()));
- for(int i=0;i<length;i++) {
- add(files[i]);
- }
- }
- }
-
- protected FileEntry addSong(File f) {
- FileEntry file = null;
- try {
- file = getFileEntry(f);
- }
- catch(Exception e) {
- return null;
- }
- SongEntry song = getSongEntry(file);
- if(!song.gotTagInfo()) {
- removeSongEntry(file);
- return null;
- }
- ArtistEntry artist = getArtistEntry(song.getArtistTag());
- AlbumEntry album = getAlbumEntry(song.getAlbumTag(),f.getParent());
- album.setArtist(artist);
- album.addSong(song);
- return file;
- }
-
- protected int align(int len) {
- while((len&3)!=0) len++;
- return len;
- }
-
- protected void calcLimits() {
- ArtistEntry longartist=null,longalbumarray=null;
- AlbumEntry longalbum=null, longsongarray=null;
- SongEntry longsong=null,longgenre=null;
- FileEntry longfile=null;
- Iterator i;
- artistlen=0;
- albumarraylen=0;
- i=sortedartists.iterator();
- while(i.hasNext()) {
- ArtistEntry artist = (ArtistEntry) i.next();
- int length=artist.getName().length();
- int albumcount=artist.size();
- if(length > artistlen) {
- artistlen=align(length);
- longartist=artist;
- }
- if(albumcount> albumarraylen) {
- albumarraylen=albumcount;
- longalbumarray=artist;
- }
- }
- artistcount=sortedartists.size();
- if(longartist!=null)
- System.out.println("Artist with longest name ("+artistlen+") :"+longartist.getName());
- if(longalbumarray!=null)
- System.out.println("Artist with most albums ("+albumarraylen+") :"+longalbumarray.getName());
- albumlen=0;
- songarraylen=0;
- i=sortedalbums.iterator();
- while(i.hasNext()) {
- AlbumEntry album = (AlbumEntry) i.next();
- int length=album.getName().length();
- int songcount=album.size();
- if(length > albumlen) {
- albumlen=align(length);
- longalbum=album;
- }
- if(songcount> songarraylen) {
- songarraylen=songcount;
- longsongarray=album;
- }
- }
- albumcount=sortedalbums.size();
- if(longalbum!=null)
- System.out.println("Album with longest name ("+albumlen+") :"+longalbum.getName());
- if(longsongarray!=null)
- System.out.println("Album with most songs ("+songarraylen+") :"+longsongarray.getName());
- filelen=0;
- i=sortedfiles.iterator();
- while(i.hasNext()) {
- FileEntry file = (FileEntry) i.next();
- int length=file.getFilename().length();
- if(length> filelen) {
- filelen=align(length);
- longfile=file;
- }
- }
- filecount=sortedfiles.size();
- if(longfile!=null)
- System.out.println("File with longest filename ("+filelen+") :"+longfile.getFilename());
- songlen=0;
- genrelen=0;
- i=sortedsongs.iterator();
- while(i.hasNext()) {
- SongEntry song = (SongEntry) i.next();
- int tlength=song.getName().length();
- int glength=song.getGenreTag().length();
- if(tlength> songlen) {
- songlen=align(tlength);
- longsong=song;
- }
- if(glength> genrelen) {
- genrelen=align(glength);
- longgenre=song;
- }
- }
- songcount=sortedsongs.size();
- if(longsong!=null)
- System.out.println("Song with longest name ("+songlen+") :"+longsong.getName());
- if(longsong!=null)
- System.out.println("Song with longest genre ("+genrelen+") :"+longgenre.getGenreTag());
- System.out.println("Artistcount: "+artistcount);
- System.out.println("Albumcount : "+albumcount);
- System.out.println("Songcount : "+songcount);
- System.out.println("Filecount : "+filecount);
- artiststart=68;
- albumstart=artiststart+artistcount*ArtistEntry.entrySize();
- songstart=albumstart+albumcount*AlbumEntry.entrySize();
- filestart=songstart+songcount*SongEntry.entrySize();
- }
-
- protected void calcOffsets() {
- Iterator i;
- int offset=artiststart;
- i=sortedartists.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.setOffset(offset);
- offset+=ArtistEntry.entrySize();
- }
-// assert(offset==albumstart);
- i=sortedalbums.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.setOffset(offset);
- offset+=AlbumEntry.entrySize();
- }
-// assert(offset==songstart);
- i=sortedsongs.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.setOffset(offset);
- offset+=SongEntry.entrySize();
- }
-// assert(offset==filestart);
- i=sortedfiles.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.setOffset(offset);
- offset+=FileEntry.entrySize();
- }
- }
-
- protected void calcHashes() {
- Iterator i;
- i=sortedfiles.iterator();
- while(i.hasNext()) {
- FileEntry file = (FileEntry) i.next();
- Integer key = new Integer(file.getHash());
- if(!filehashes.containsKey(key))
- filehashes.put(key,file);
- else {
- System.out.println("Duplicate hash:");
- System.out.println(((FileEntry)filehashes.get(key)).getFilename());
- System.out.println(file.getFilename());
- }
- }
- }
-
- protected void writeHeader(DataOutputStream w) throws IOException {
- w.write('R');
- w.write('D');
- w.write('B');
- w.write(0x3);
- w.writeInt(artiststart);
- w.writeInt(albumstart);
- w.writeInt(songstart);
- w.writeInt(filestart);
- w.writeInt(artistcount);
- w.writeInt(albumcount);
- w.writeInt(songcount);
- w.writeInt(filecount);
- w.writeInt(artistlen);
- w.writeInt(albumlen);
- w.writeInt(songlen);
- w.writeInt(genrelen);
- w.writeInt(filelen);
- w.writeInt(songarraylen);
- w.writeInt(albumarraylen);
- w.writeInt(RuntimeDatabase.getInstance().isDirty());
- }
-
- public void prepareWrite() {
- System.out.println("Sorting artists..");
- sortedartists=new Vector();
- sortedartists.addAll(artists.values());
- Collections.sort(sortedartists);
- System.out.println("Sorting albums..");
- sortedalbums=new Vector();
- sortedalbums.addAll(albums.values());
- Collections.sort(sortedalbums);
- System.out.println("Sorting songs..");
- sortedsongs=new Vector();
- sortedsongs.addAll(songs.values());
- Collections.sort(sortedsongs);
- System.out.println("Sorting files..");
- sortedfiles=new Vector();
- sortedfiles.addAll(files.values());
- Collections.sort(sortedfiles);
- System.out.println("Calculating tag database limits..");
- calcLimits();
- System.out.println("Calculating tag database offsets..");
- calcOffsets();
- if(showduplicates) {
- System.out.println("Comparing file hashes..");
- calcHashes();
- }
- }
-
- public void writeDatabase(File f) throws IOException {
- int x;
- Iterator i;
- DataOutputStream w = new DataOutputStream(new FileOutputStream(f));
- System.out.println("Writing tag database..");
- writeHeader(w);
-
- i=sortedartists.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.write(w);
- }
- i=sortedalbums.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.write(w);
- }
- i=sortedsongs.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.write(w);
- }
- i=sortedfiles.iterator();
- while(i.hasNext()) {
- Entry e = (Entry) i.next();
- e.write(w);
- }
- // done...
- w.flush();
- w.close();
- }
-} \ No newline at end of file
diff --git a/songdbj/TagInfo.java b/songdbj/TagInfo.java
deleted file mode 100644
index 2259226025..0000000000
--- a/songdbj/TagInfo.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * TagInfo.
- *
- * JavaZOOM : jlgui@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Vector;
-
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-/**
- * This interface define needed features for song information.
- * Adapted from Scott Pennell interface.
- */
-public interface TagInfo
-{
-
- public void load(InputStream input) throws IOException, UnsupportedAudioFileException;
-
- public void load(URL input) throws IOException, UnsupportedAudioFileException;
-
- public void load(File input) throws IOException, UnsupportedAudioFileException;
-
- /**
- * Get Sampling Rate
- * @return
- */
- public int getSamplingRate();
-
- /**
- * Get Nominal Bitrate
- * @return bitrate in bps
- */
- public int getBitRate();
-
- /**
- * Get channels.
- * @return channels
- */
- public int getChannels();
-
- /**
- * Get play time in seconds.
- * @return
- */
- public long getPlayTime();
-
- /**
- * Get the title of the song.
- * @return the title of the song
- */
- public String getTitle();
-
- /**
- * Get the artist that performed the song
- * @return the artist that performed the song
- */
- public String getArtist();
-
- /**
- * Get the name of the album upon which the song resides
- * @return the album name
- */
- public String getAlbum();
-
- /**
- * Get the track number of this track on the album
- * @return the track number
- */
- public int getTrack();
-
- /**
- * Get the genre string of the music
- * @return the genre string
- */
- public String getGenre();
-
- /**
- * Get the year the track was released
- * @return the year the track was released
- */
- public String getYear();
-
- /**
- * Get any comments provided about the song
- * @return the comments
- */
- public Vector getComment();
-
- public int getFirstFrameOffset();
-} \ No newline at end of file
diff --git a/songdbj/build.sh b/songdbj/build.sh
deleted file mode 100755
index e8b6b850a0..0000000000
--- a/songdbj/build.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-javac -d classes -cp . -source 1.5 -target 1.5 `find -name '*.java'`
-jar cvfm SongDB.jar classes/META-INF/MANIFEST.MF -C classes/ .
diff --git a/songdbj/classes/META-INF/MANIFEST.MF b/songdbj/classes/META-INF/MANIFEST.MF
deleted file mode 100644
index 14ecfed112..0000000000
--- a/songdbj/classes/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,4 +0,0 @@
-Manifest-Version: 1.0
-Created-By: Apache Ant 1.5.1
-Main-Class: SongDB
-
diff --git a/songdbj/classes/META-INF/services/javax.sound.sampled.spi.AudioFileReader b/songdbj/classes/META-INF/services/javax.sound.sampled.spi.AudioFileReader
deleted file mode 100644
index 48c0ea73ca..0000000000
--- a/songdbj/classes/META-INF/services/javax.sound.sampled.spi.AudioFileReader
+++ /dev/null
@@ -1,4 +0,0 @@
-# for the javalayer mp3 decoder
-javazoom.spi.mpeg.sampled.file.MpegAudioFileReader
-# for the vorbis decoder
-javazoom.spi.vorbis.sampled.file.VorbisAudioFileReader \ No newline at end of file
diff --git a/songdbj/classes/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider b/songdbj/classes/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider
deleted file mode 100644
index fe7eeca426..0000000000
--- a/songdbj/classes/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider
+++ /dev/null
@@ -1,3 +0,0 @@
-# for the javalayer mp3 decoder
-javazoom.spi.mpeg.sampled.convert.MpegFormatConversionProvider
-javazoom.spi.vorbis.sampled.convert.VorbisFormatConversionProvider
diff --git a/songdbj/com/jcraft/jogg/Buffer.java b/songdbj/com/jcraft/jogg/Buffer.java
deleted file mode 100644
index a40a9def9c..0000000000
--- a/songdbj/com/jcraft/jogg/Buffer.java
+++ /dev/null
@@ -1,541 +0,0 @@
-/* -*-mode:java; c-basic-offset:2; -*- */
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jogg;
-
-public class Buffer{
- private static final int BUFFER_INCREMENT=256;
-
- private static final int[] mask={
- 0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
- 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
- 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
- 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff,
- 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff,
- 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,
- 0x3fffffff,0x7fffffff,0xffffffff
- };
-
- int ptr=0;
- byte[] buffer=null;
- int endbit=0;
- int endbyte=0;
- int storage=0;
-
- public void writeinit(){
- buffer=new byte[BUFFER_INCREMENT];
- ptr=0;
- buffer[0]=(byte)'\0';
- storage=BUFFER_INCREMENT;
- }
-
- public void write(byte[] s){
- for(int i=0; i<s.length; i++){
- if(s[i]==0)break;
- write(s[i],8);
- }
- }
-
- public void read(byte[] s, int bytes){
- int i=0;
- while(bytes--!=0){
- s[i++]=(byte)(read(8));
- }
- }
-
- void reset(){
- ptr=0;
- buffer[0]=(byte)'\0';
- endbit=endbyte=0;
- }
-
- public void writeclear(){
- buffer=null;
- }
-
- public void readinit(byte[] buf, int bytes){
- readinit(buf, 0, bytes);
- }
-
- public void readinit(byte[] buf, int start, int bytes){
-//System.err.println("readinit: start="+start+", bytes="+bytes);
-//for(int i=0;i<bytes; i++){
-//System.err.println(i+": "+Integer.toHexString(buf[i+start]));
-//}
- ptr=start;
- buffer=buf;
- endbit=endbyte=0;
- storage=bytes;
- }
-
- public void write(int value, int bits){
-//System.err.println("write: "+Integer.toHexString(value)+", bits="+bits+" ptr="+ptr+", storage="+storage+", endbyte="+endbyte);
- if(endbyte+4>=storage){
- byte[] foo=new byte[storage+BUFFER_INCREMENT];
- System.arraycopy(buffer, 0, foo, 0, storage);
- buffer=foo;
- storage+=BUFFER_INCREMENT;
- }
-
- value&=mask[bits];
- bits+=endbit;
- buffer[ptr]|=(byte)(value<<endbit);
-
- if(bits>=8){
- buffer[ptr+1]=(byte)(value>>>(8-endbit));
- if(bits>=16){
- buffer[ptr+2]=(byte)(value>>>(16-endbit));
- if(bits>=24){
- buffer[ptr+3]=(byte)(value>>>(24-endbit));
- if(bits>=32){
- if(endbit>0)
- buffer[ptr+4]=(byte)(value>>>(32-endbit));
- else
- buffer[ptr+4]=0;
- }
- }
- }
- }
-
- endbyte+=bits/8;
- ptr+=bits/8;
- endbit=bits&7;
- }
-
- public int look(int bits){
- int ret;
- int m=mask[bits];
-
- bits+=endbit;
-
-//System.err.println("look ptr:"+ptr+", bits="+bits+", endbit="+endbit+", storage="+storage);
-
- if(endbyte+4>=storage){
- if(endbyte+(bits-1)/8>=storage)return(-1);
- }
-
- ret=((buffer[ptr])&0xff)>>>endbit;
-// ret=((byte)(buffer[ptr]))>>>endbit;
- if(bits>8){
- ret|=((buffer[ptr+1])&0xff)<<(8-endbit);
-// ret|=((byte)(buffer[ptr+1]))<<(8-endbit);
- if(bits>16){
- ret|=((buffer[ptr+2])&0xff)<<(16-endbit);
-// ret|=((byte)(buffer[ptr+2]))<<(16-endbit);
- if(bits>24){
- ret|=((buffer[ptr+3])&0xff)<<(24-endbit);
-//System.err.print("ret="+Integer.toHexString(ret)+", ((byte)(buffer[ptr+3]))="+Integer.toHexString(((buffer[ptr+3])&0xff)));
-// ret|=((byte)(buffer[ptr+3]))<<(24-endbit);
-//System.err.println(" ->ret="+Integer.toHexString(ret));
- if(bits>32 && endbit!=0){
- ret|=((buffer[ptr+4])&0xff)<<(32-endbit);
-// ret|=((byte)(buffer[ptr+4]))<<(32-endbit);
- }
- }
- }
- }
- return(m&ret);
- }
-
- public int look1(){
- if(endbyte>=storage)return(-1);
- return((buffer[ptr]>>endbit)&1);
- }
-
- public void adv(int bits){
- bits+=endbit;
- ptr+=bits/8;
- endbyte+=bits/8;
- endbit=bits&7;
- }
-
- public void adv1(){
- ++endbit;
- if(endbit>7){
- endbit=0;
- ptr++;
- endbyte++;
- }
- }
-
- public int read(int bits){
-//System.err.println(this+" read: bits="+bits+", storage="+storage+", endbyte="+endbyte);
-//System.err.println(this+" read: bits="+bits+", storage="+storage+", endbyte="+endbyte+
-// ", ptr="+ptr+", endbit="+endbit+", buf[ptr]="+buffer[ptr]);
-
- int ret;
- int m=mask[bits];
-
- bits+=endbit;
-
- if(endbyte+4>=storage){
- ret=-1;
- if(endbyte+(bits-1)/8>=storage){
- ptr+=bits/8;
- endbyte+=bits/8;
- endbit=bits&7;
- return(ret);
- }
- }
-
-/*
- ret=(byte)(buffer[ptr]>>>endbit);
- if(bits>8){
- ret|=(buffer[ptr+1]<<(8-endbit));
- if(bits>16){
- ret|=(buffer[ptr+2]<<(16-endbit));
- if(bits>24){
- ret|=(buffer[ptr+3]<<(24-endbit));
- if(bits>32 && endbit>0){
- ret|=(buffer[ptr+4]<<(32-endbit));
- }
- }
- }
- }
-*/
- ret=((buffer[ptr])&0xff)>>>endbit;
- if(bits>8){
- ret|=((buffer[ptr+1])&0xff)<<(8-endbit);
-// ret|=((byte)(buffer[ptr+1]))<<(8-endbit);
- if(bits>16){
- ret|=((buffer[ptr+2])&0xff)<<(16-endbit);
-// ret|=((byte)(buffer[ptr+2]))<<(16-endbit);
- if(bits>24){
- ret|=((buffer[ptr+3])&0xff)<<(24-endbit);
-// ret|=((byte)(buffer[ptr+3]))<<(24-endbit);
- if(bits>32 && endbit!=0){
- ret|=((buffer[ptr+4])&0xff)<<(32-endbit);
-// ret|=((byte)(buffer[ptr+4]))<<(32-endbit);
- }
- }
- }
- }
-
- ret&=m;
-
- ptr+=bits/8;
-// ptr=bits/8;
- endbyte+=bits/8;
-// endbyte=bits/8;
- endbit=bits&7;
- return(ret);
- }
-
- public int readB(int bits){
- //System.err.println(this+" read: bits="+bits+", storage="+storage+", endbyte="+endbyte+
- // ", ptr="+ptr+", endbit="+endbit+", buf[ptr]="+buffer[ptr]);
- int ret;
- int m=32-bits;
-
- bits+=endbit;
-
- if(endbyte+4>=storage){
- /* not the main path */
- ret=-1;
- if(endbyte*8+bits>storage*8) {
- ptr+=bits/8;
- endbyte+=bits/8;
- endbit=bits&7;
- return(ret);
- }
- }
-
- ret=(buffer[ptr]&0xff)<<(24+endbit);
- if(bits>8){
- ret|=(buffer[ptr+1]&0xff)<<(16+endbit);
- if(bits>16){
- ret|=(buffer[ptr+2]&0xff)<<(8+endbit);
- if(bits>24){
- ret|=(buffer[ptr+3]&0xff)<<(endbit);
- if(bits>32 && (endbit != 0))
- ret|=(buffer[ptr+4]&0xff)>>(8-endbit);
- }
- }
- }
- ret=(ret>>>(m>>1))>>>((m+1)>>1);
-
- ptr+=bits/8;
- endbyte+=bits/8;
- endbit=bits&7;
- return(ret);
- }
-
- public int read1(){
- int ret;
- if(endbyte>=storage){
- ret=-1;
- endbit++;
- if(endbit>7){
- endbit=0;
- ptr++;
- endbyte++;
- }
- return(ret);
- }
-
- ret=(buffer[ptr]>>endbit)&1;
-
- endbit++;
- if(endbit>7){
- endbit=0;
- ptr++;
- endbyte++;
- }
- return(ret);
- }
-
- public int bytes(){
- return(endbyte+(endbit+7)/8);
- }
-
- public int bits(){
- return(endbyte*8+endbit);
- }
-
- public byte[] buffer(){
- return(buffer);
- }
-
- public static int ilog(int v){
- int ret=0;
- while(v>0){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-
- public static void report(String in){
- System.err.println(in);
- System.exit(1);
- }
-
- /*
- static void cliptest(int[] b, int vals, int bits, int[] comp, int compsize){
- int bytes;
- byte[] buffer;
-
- o.reset();
- for(int i=0;i<vals;i++){
- o.write(b[i],((bits!=0)?bits:ilog(b[i])));
- }
- buffer=o.buffer();
- bytes=o.bytes();
-System.err.println("cliptest: bytes="+bytes);
- if(bytes!=compsize)report("wrong number of bytes!\n");
- for(int i=0;i<bytes;i++){
- if(buffer[i]!=(byte)comp[i]){
- for(int j=0;j<bytes;j++){
- System.err.println(j+": "+Integer.toHexString(buffer[j])+" "+
- Integer.toHexString(comp[j]));
- }
- report("wrote incorrect value!\n");
- }
- }
-System.err.println("bits: "+bits);
- r.readinit(buffer,bytes);
- for(int i=0;i<vals;i++){
- int tbit=(bits!=0)?bits:ilog(b[i]);
-System.err.println(Integer.toHexString(b[i])+" tbit: "+tbit);
- if(r.look(tbit)==-1){
- report("out of data!\n");
- }
- if(r.look(tbit)!=(b[i]&mask[tbit])){
- report(i+" looked at incorrect value! "+Integer.toHexString(r.look(tbit))+", "+Integer.toHexString(b[i]&mask[tbit])+":"+b[i]+" bit="+tbit);
- }
- if(tbit==1){
- if(r.look1()!=(b[i]&mask[tbit])){
- report("looked at single bit incorrect value!\n");
- }
- }
- if(tbit==1){
- if(r.read1()!=(b[i]&mask[tbit])){
- report("read incorrect single bit value!\n");
- }
- }
- else{
- if(r.read(tbit)!=(b[i]&mask[tbit])){
- report("read incorrect value!\n");
- }
- }
- }
- if(r.bytes()!=bytes){
- report("leftover bytes after read!\n");
- }
- }
-
- static int[] testbuffer1=
- {18,12,103948,4325,543,76,432,52,3,65,4,56,32,42,34,21,1,23,32,546,456,7,
- 567,56,8,8,55,3,52,342,341,4,265,7,67,86,2199,21,7,1,5,1,4};
- static int test1size=43;
-
- static int[] testbuffer2=
- {216531625,1237861823,56732452,131,3212421,12325343,34547562,12313212,
- 1233432,534,5,346435231,14436467,7869299,76326614,167548585,
- 85525151,0,12321,1,349528352};
- static int test2size=21;
-
- static int[] large=
- {2136531625,2137861823,56732452,131,3212421,12325343,34547562,12313212,
- 1233432,534,5,2146435231,14436467,7869299,76326614,167548585,
- 85525151,0,12321,1,2146528352};
-
- static int[] testbuffer3=
- {1,0,14,0,1,0,12,0,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,0,0,1,
- 0,1,30,1,1,1,0,0,1,0,0,0,12,0,11,0,1,0,0,1};
- static int test3size=56;
-
- static int onesize=33;
- static int[] one={146,25,44,151,195,15,153,176,233,131,196,65,85,172,47,40,
- 34,242,223,136,35,222,211,86,171,50,225,135,214,75,172,
- 223,4};
-
- static int twosize=6;
- static int[] two={61,255,255,251,231,29};
-
- static int threesize=54;
- static int[] three={169,2,232,252,91,132,156,36,89,13,123,176,144,32,254,
- 142,224,85,59,121,144,79,124,23,67,90,90,216,79,23,83,
- 58,135,196,61,55,129,183,54,101,100,170,37,127,126,10,
- 100,52,4,14,18,86,77,1};
-
- static int foursize=38;
- static int[] four={18,6,163,252,97,194,104,131,32,1,7,82,137,42,129,11,72,
- 132,60,220,112,8,196,109,64,179,86,9,137,195,208,122,169,
- 28,2,133,0,1};
-
- static int fivesize=45;
- static int[] five={169,2,126,139,144,172,30,4,80,72,240,59,130,218,73,62,
- 241,24,210,44,4,20,0,248,116,49,135,100,110,130,181,169,
- 84,75,159,2,1,0,132,192,8,0,0,18,22};
-
- static int sixsize=7;
- static int[] six={17,177,170,242,169,19,148};
-
- static Buffer o=new Buffer();
- static Buffer r=new Buffer();
-
- public static void main(String[] arg){
- byte[] buffer;
- int bytes;
-// o=new Buffer();
-// r=new Buffer();
-
- o.writeinit();
-
- System.err.print("\nSmall preclipped packing: ");
- cliptest(testbuffer1,test1size,0,one,onesize);
- System.err.print("ok.");
-
- System.err.print("\nNull bit call: ");
- cliptest(testbuffer3,test3size,0,two,twosize);
- System.err.print("ok.");
-
- System.err.print("\nLarge preclipped packing: ");
- cliptest(testbuffer2,test2size,0,three,threesize);
- System.err.print("ok.");
-
- System.err.print("\n32 bit preclipped packing: ");
- o.reset();
- for(int i=0;i<test2size;i++)
- o.write(large[i],32);
- buffer=o.buffer();
- bytes=o.bytes();
-
-
- r.readinit(buffer,bytes);
- for(int i=0;i<test2size;i++){
- if(r.look(32)==-1){
- report("out of data. failed!");
- }
- if(r.look(32)!=large[i]){
- System.err.print(r.look(32)+" != "+large[i]+" ("+
- Integer.toHexString(r.look(32))+"!="+
- Integer.toHexString(large[i])+")");
- report("read incorrect value!\n");
- }
- r.adv(32);
- }
- if(r.bytes()!=bytes)report("leftover bytes after read!\n");
- System.err.print("ok.");
-
- System.err.print("\nSmall unclipped packing: ");
- cliptest(testbuffer1,test1size,7,four,foursize);
- System.err.print("ok.");
-
- System.err.print("\nLarge unclipped packing: ");
- cliptest(testbuffer2,test2size,17,five,fivesize);
- System.err.print("ok.");
-
- System.err.print("\nSingle bit unclicpped packing: ");
- cliptest(testbuffer3,test3size,1,six,sixsize);
- System.err.print("ok.");
-
- System.err.print("\nTesting read past end: ");
- r.readinit("\0\0\0\0\0\0\0\0".getBytes(),8);
- for(int i=0;i<64;i++){
- if(r.read(1)!=0){
- System.err.print("failed; got -1 prematurely.\n");
- System.exit(1);
- }
- }
-
- if(r.look(1)!=-1 ||
- r.read(1)!=-1){
- System.err.print("failed; read past end without -1.\n");
- System.exit(1);
- }
-
- r.readinit("\0\0\0\0\0\0\0\0".getBytes(),8);
- if(r.read(30)!=0 || r.read(16)!=0){
- System.err.print("failed 2; got -1 prematurely.\n");
- System.exit(1);
- }
-
- if(r.look(18)!=0 ||
- r.look(18)!=0){
- System.err.print("failed 3; got -1 prematurely.\n");
- System.exit(1);
- }
- if(r.look(19)!=-1 ||
- r.look(19)!=-1){
- System.err.print("failed; read past end without -1.\n");
- System.exit(1);
- }
- if(r.look(32)!=-1 ||
- r.look(32)!=-1){
- System.err.print("failed; read past end without -1.\n");
- System.exit(1);
- }
- System.err.print("ok.\n\n");
- }
- */
-}
-
-
-
-
-
diff --git a/songdbj/com/jcraft/jogg/Packet.java b/songdbj/com/jcraft/jogg/Packet.java
deleted file mode 100644
index 22a8a5439b..0000000000
--- a/songdbj/com/jcraft/jogg/Packet.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jogg;
-
-public class Packet{
- public byte[] packet_base;
- public int packet;
- public int bytes;
- public int b_o_s;
- public int e_o_s;
-
- public long granulepos;
-
- public long packetno; // sequence number for decode; the framing
- // knows where there's a hole in the data,
- // but we need coupling so that the codec
- // (which is in a seperate abstraction
- // layer) also knows about the gap
-
- /*
- // TEST
- static int sequence=0;
- static int lastno=0;
- void checkpacket(int len, int no, int pos){
- if(bytes!=len){
- System.err.println("incorrect packet length!");
- System.exit(1);
- }
- if(granulepos!=pos){
- System.err.println("incorrect packet position!");
- System.exit(1);
- }
-
- // packet number just follows sequence/gap; adjust the input number
- // for that
- if(no==0){
- sequence=0;
- }
- else{
- sequence++;
- if(no>lastno+1)
- sequence++;
- }
- lastno=no;
- if(packetno!=sequence){
- System.err.println("incorrect packet sequence "+packetno+" != "+sequence);
- System.exit(1);
- }
-
- // Test data
- for(int j=0;j<bytes;j++){
- if((packet_base[packet+j]&0xff)!=((j+no)&0xff)){
- System.err.println("body data mismatch at pos "+ j+": "+(packet_base[packet+j]&0xff)+"!="+((j+no)&0xff)+"!\n");
- System.exit(1);
- }
- }
- }
- */
-}
diff --git a/songdbj/com/jcraft/jogg/Page.java b/songdbj/com/jcraft/jogg/Page.java
deleted file mode 100644
index fc1add010e..0000000000
--- a/songdbj/com/jcraft/jogg/Page.java
+++ /dev/null
@@ -1,973 +0,0 @@
-/* -*-mode:java; c-basic-offset:2; -*- */
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jogg;
-
-public class Page{
- private static int[] crc_lookup=new int[256];
- static {
- for(int i=0; i<crc_lookup.length; i++){
- crc_lookup[i]=crc_entry(i);
- }
- }
-
- private static int crc_entry(int index){
- int r=index<<24;
- for(int i=0; i<8; i++){
- if((r& 0x80000000)!=0){
- r=(r << 1)^0x04c11db7; /* The same as the ethernet generator
- polynomial, although we use an
- unreflected alg and an init/final
- of 0, not 0xffffffff */
- }
- else{
- r<<=1;
- }
- }
- return(r&0xffffffff);
- }
-
- public byte[] header_base;
- public int header;
- public int header_len;
- public byte[] body_base;
- public int body;
- public int body_len;
-
- int version(){
- return header_base[header+4]&0xff;
- }
- int continued(){
- return (header_base[header+5]&0x01);
- }
- public int bos(){
- return (header_base[header+5]&0x02);
- }
- public int eos(){
- return (header_base[header+5]&0x04);
- }
- public long granulepos(){
- long foo=header_base[header+13]&0xff;
- foo=(foo<<8)|(header_base[header+12]&0xff);
- foo=(foo<<8)|(header_base[header+11]&0xff);
- foo=(foo<<8)|(header_base[header+10]&0xff);
- foo=(foo<<8)|(header_base[header+9]&0xff);
- foo=(foo<<8)|(header_base[header+8]&0xff);
- foo=(foo<<8)|(header_base[header+7]&0xff);
- foo=(foo<<8)|(header_base[header+6]&0xff);
- return(foo);
- }
- public int serialno(){
- return (header_base[header+14]&0xff)|
- ((header_base[header+15]&0xff)<<8)|
- ((header_base[header+16]&0xff)<<16)|
- ((header_base[header+17]&0xff)<<24);
- }
- int pageno(){
- return (header_base[header+18]&0xff)|
- ((header_base[header+19]&0xff)<<8)|
- ((header_base[header+20]&0xff)<<16)|
- ((header_base[header+21]&0xff)<<24);
- }
-
- void checksum(){
- int crc_reg=0;
-
-// for(int i=0;i<header_len;i++){
-// System.err.println("chksum: "+Integer.toHexString(header_base[header+i]&0xff));
-// }
-
- for(int i=0;i<header_len;i++){
- crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg>>>24)&0xff)^(header_base[header+i]&0xff)];
- }
- for(int i=0;i<body_len;i++){
- crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg>>>24)&0xff)^(body_base[body+i]&0xff)];
- }
- header_base[header+22]=(byte)crc_reg/*&0xff*/;
- header_base[header+23]=(byte)(crc_reg>>>8)/*&0xff*/;
- header_base[header+24]=(byte)(crc_reg>>>16)/*&0xff*/;
- header_base[header+25]=(byte)(crc_reg>>>24)/*&0xff*/;
- }
- public Page copy(){
- return copy(new Page());
- }
- public Page copy(Page p){
- byte[] tmp=new byte[header_len];
- System.arraycopy(header_base, header, tmp, 0, header_len);
- p.header_len=header_len;
- p.header_base=tmp;
- p.header=0;
- tmp=new byte[body_len];
- System.arraycopy(body_base, body, tmp, 0, body_len);
- p.body_len=body_len;
- p.body_base=tmp;
- p.body=0;
- return p;
- }
- /*
- // TEST
- static StreamState os_en, os_de;
- static SyncState oy;
- void check_page(byte[] data_base, int data, int[] _header){
- // Test data
- for(int j=0;j<body_len;j++)
- if(body_base[body+j]!=data_base[data+j]){
- System.err.println("body data mismatch at pos "+j+": "+data_base[data+j]+"!="+body_base[body+j]+"!\n");
- System.exit(1);
- }
-
- // Test header
- for(int j=0;j<header_len;j++){
- if((header_base[header+j]&0xff)!=_header[j]){
- System.err.println("header content mismatch at pos "+j);
- for(int jj=0;jj<_header[26]+27;jj++)
- System.err.print(" ("+jj+")"+Integer.toHexString(_header[jj])+":"+Integer.toHexString(header_base[header+jj]));
- System.err.println("");
- System.exit(1);
- }
- }
- if(header_len!=_header[26]+27){
- System.err.print("header length incorrect! ("+header_len+"!="+(_header[26]+27)+")");
- System.exit(1);
- }
- }
-
- void print_header(){
- System.err.println("\nHEADER:");
- System.err.println(" capture: "+
- (header_base[header+0]&0xff)+" "+
- (header_base[header+1]&0xff)+" "+
- (header_base[header+2]&0xff)+" "+
- (header_base[header+3]&0xff)+" "+
- " version: "+(header_base[header+4]&0xff)+" flags: "+
- (header_base[header+5]&0xff));
- System.err.println(" pcmpos: "+
- (((header_base[header+9]&0xff)<<24)|
- ((header_base[header+8]&0xff)<<16)|
- ((header_base[header+7]&0xff)<<8)|
- ((header_base[header+6]&0xff)))+
- " serialno: "+
- (((header_base[header+17]&0xff)<<24)|
- ((header_base[header+16]&0xff)<<16)|
- ((header_base[header+15]&0xff)<<8)|
- ((header_base[header+14]&0xff)))+
- " pageno: "+
- (((header_base[header+21]&0xff)<<24)|
- ((header_base[header+20]&0xff)<<16)|
- ((header_base[header+19]&0xff)<<8)|
- ((header_base[header+18]&0xff))));
-
- System.err.println(" checksum: "+
- (header_base[header+22]&0xff)+":"+
- (header_base[header+23]&0xff)+":"+
- (header_base[header+24]&0xff)+":"+
- (header_base[header+25]&0xff)+"\n segments: "+
- (header_base[header+26]&0xff)+" (");
- for(int j=27;j<header_len;j++){
- System.err.println((header_base[header+j]&0xff)+" ");
- }
- System.err.println(")\n");
- }
-
- void copy_page(){
- byte[] tmp=new byte[header_len];
- System.arraycopy(header_base, header, tmp, 0, header_len);
- header_base=tmp;
- header=0;
- tmp=new byte[body_len];
- System.arraycopy(body_base, body, tmp, 0, body_len);
- body_base=tmp;
- body=0;
- }
-
- static void test_pack(int[] pl, int[][] headers){
- byte[] data=new byte[1024*1024]; // for scripted test cases only
- int inptr=0;
- int outptr=0;
- int deptr=0;
- int depacket=0;
- int pcm_pos=7;
- int packets,pageno=0,pageout=0;
- int eosflag=0;
- int bosflag=0;
-
- os_en.reset();
- os_de.reset();
- oy.reset();
-
- for(packets=0;;packets++){
- if(pl[packets]==-1)break;
- }
-
- for(int i=0;i<packets;i++){
- // construct a test packet
- Packet op=new Packet();
- int len=pl[i];
- op.packet_base=data;
- op.packet=inptr;
- op.bytes=len;
- op.e_o_s=(pl[i+1]<0?1:0);
- op.granulepos=pcm_pos;
-
- pcm_pos+=1024;
-
- for(int j=0;j<len;j++){
- data[inptr++]=(byte)(i+j);
- }
-
- // submit the test packet
- os_en.packetin(op);
-
- // retrieve any finished pages
- {
- Page og=new Page();
-
- while(os_en.pageout(og)!=0){
- // We have a page. Check it carefully
- //System.err.print(pageno+", ");
- if(headers[pageno]==null){
- System.err.println("coded too many pages!");
- System.exit(1);
- }
- og.check_page(data, outptr, headers[pageno]);
-
- outptr+=og.body_len;
- pageno++;
-
-//System.err.println("1# pageno="+pageno+", pageout="+pageout);
-
- // have a complete page; submit it to sync/decode
-
- {
- Page og_de=new Page();
- Packet op_de=new Packet();
- int index=oy.buffer(og.header_len+og.body_len);
- byte[] buf=oy.data;
- System.arraycopy(og.header_base, og.header, buf, index, og.header_len);
- System.arraycopy(og.body_base, og.body, buf, index+og.header_len, og.body_len);
- oy.wrote(og.header_len+og.body_len);
-
-//System.err.println("2# pageno="+pageno+", pageout="+pageout);
-
- while(oy.pageout(og_de)>0){
- // got a page. Happy happy. Verify that it's good.
-
- og_de.check_page(data, deptr, headers[pageout]);
- deptr+=og_de.body_len;
- pageout++;
-
- // submit it to deconstitution
- os_de.pagein(og_de);
-
- // packets out?
- while(os_de.packetout(op_de)>0){
-
- // verify the packet!
- // check data
- boolean check=false;
- for(int ii=0; ii<op_de.bytes; ii++){
- if(data[depacket+ii]!=op_de.packet_base[op_de.packet+ii]){
- check=true;
- break;
- }
- }
- if(check){
- System.err.println("packet data mismatch in decode! pos="+
- depacket);
- System.exit(1);
- }
-
- // check bos flag
- if(bosflag==0 && op_de.b_o_s==0){
- System.err.println("b_o_s flag not set on packet!");
- System.exit(1);
- }
- if(bosflag!=0 && op_de.b_o_s!=0){
- System.err.println("b_o_s flag incorrectly set on packet!");
- System.exit(1);
- }
-
- bosflag=1;
- depacket+=op_de.bytes;
-
- // check eos flag
- if(eosflag!=0){
- System.err.println("Multiple decoded packets with eos flag!");
- System.exit(1);
- }
-
- if(op_de.e_o_s!=0)eosflag=1;
-
- // check pcmpos flag
- if(op_de.granulepos!=-1){
- System.err.print(" pcm:"+op_de.granulepos+" ");
- }
- }
- }
- }
- }
- }
- }
- //free(data);
- if(headers[pageno]!=null){
- System.err.println("did not write last page!");
- System.exit(1);
- }
- if(headers[pageout]!=null){
- System.err.println("did not decode last page!");
- System.exit(1);
- }
- if(inptr!=outptr){
- System.err.println("encoded page data incomplete!");
- System.exit(1);
- }
- if(inptr!=deptr){
- System.err.println("decoded page data incomplete!");
- System.exit(1);
- }
- if(inptr!=depacket){
- System.err.println("decoded packet data incomplete!");
- System.exit(1);
- }
- if(eosflag==0){
- System.err.println("Never got a packet with EOS set!");
- }
- System.err.println("ok.");
- }
-
- static void error(){
- System.err.println("error!");
- System.exit(1);
- }
- public static void main(String[] arg){
-
- os_en=new StreamState(0x04030201);
- os_de=new StreamState(0x04030201);
-
- oy=new SyncState();
-
- // Exercise each code path in the framing code. Also verify that
- // the checksums are working.
-
- {
- // 17 only
- int[] packets={17, -1};
- int[] head1={0x4f,0x67,0x67,0x53,0,0x06,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0x15,0xed,0xec,0x91,
- 1,
- 17};
- int[][] headret={head1, null};
-
- System.err.print("testing single page encoding... ");
- test_pack(packets,headret);
- }
-
- {
- // 17, 254, 255, 256, 500, 510, 600 byte, pad
- int[] packets={17, 254, 255, 256, 500, 510, 600, -1};
- int[] head1={0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0x59,0x10,0x6c,0x2c,
- 1,
- 17};
- int[] head2={0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x89,0x33,0x85,0xce,
- 13,
- 254,255,0,255,1,255,245,255,255,0,
- 255,255,90};
- int[][] headret={head1,head2,null};
-
- System.err.print("testing basic page encoding... ");
- test_pack(packets,headret);
- }
-
- {
- // nil packets; beginning,middle,end
- int[] packets={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1};
-
- int[] head1={0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
- int[] head2={0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x5c,0x3f,0x66,0xcb,
- 17,
- 17,254,255,0,0,255,1,0,255,245,255,255,0,
- 255,255,90,0};
- int[][] headret={head1,head2,null};
-
- System.err.print("testing basic nil packets... ");
- test_pack(packets,headret);
- }
-
- {
- // large initial packet
- int[] packets={4345,259,255,-1};
-
- int[] head1={0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0x01,0x27,0x31,0xaa,
- 18,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,10};
-
- int[] head2={0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x7f,0x4e,0x8a,0xd2,
- 4,
- 255,4,255,0};
- int[][] headret={head1,head2,null};
-
- System.err.print("testing initial-packet lacing > 4k... ");
- test_pack(packets,headret);
- }
-
- {
- // continuing packet test
- int[] packets={0,4345,259,255,-1};
-
- int[] head1={0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
- int[] head2={0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x34,0x24,0xd5,0x29,
- 17,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255};
-
- int[] head3={0x4f,0x67,0x67,0x53,0,0x05,
- 0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0xc8,0xc3,0xcb,0xed,
- 5,
- 10,255,4,255,0};
- int[][] headret={head1,head2,head3,null};
-
- System.err.print("testing single packet page span... ");
- test_pack(packets,headret);
- }
-
- // page with the 255 segment limit
- {
-
- int[] packets={0,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,50,-1};
-
- int[] head1={0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
- int[] head2={0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0xed,0x2a,0x2e,0xa7,
- 255,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10};
-
- int[] head3={0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0x6c,0x3b,0x82,0x3d,
- 1,
- 50};
- int[][] headret={head1,head2,head3,null};
-
- System.err.print("testing max packet segments... ");
- test_pack(packets,headret);
- }
-
- {
- // packet that overspans over an entire page
-
- int[] packets={0,100,9000,259,255,-1};
-
- int[] head1={0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
- int[] head2={0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x3c,0xd9,0x4d,0x3f,
- 17,
- 100,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255};
-
- int[] head3={0x4f,0x67,0x67,0x53,0,0x01,
- 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0xbd,0xd5,0xb5,0x8b,
- 17,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255};
-
- int[] head4={0x4f,0x67,0x67,0x53,0,0x05,
- 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,3,0,0,0,
- 0xef,0xdd,0x88,0xde,
- 7,
- 255,255,75,255,4,255,0};
- int[][] headret={head1,head2,head3,head4,null};
-
- System.err.print("testing very large packets... ");
- test_pack(packets,headret);
- }
-
- {
- // term only page. why not?
-
- int[] packets={0,100,4080,-1};
-
- int[] head1={0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
- int[] head2={0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x3c,0xd9,0x4d,0x3f,
- 17,
- 100,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255};
-
- int[] head3={0x4f,0x67,0x67,0x53,0,0x05,
- 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0xd4,0xe0,0x60,0xe5,
- 1,0};
-
- int[][] headret={head1,head2,head3,null};
-
- System.err.print("testing zero data page (1 nil packet)... ");
- test_pack(packets,headret);
- }
-
- {
- // build a bunch of pages for testing
- byte[] data=new byte[1024*1024];
- int[] pl={0,100,4079,2956,2057,76,34,912,0,234,1000,1000,1000,300,-1};
- int inptr=0;
- Page[] og=new Page[5];
- for(int i=0; i<5; i++){
- og[i]=new Page();
- }
-
- os_en.reset();
-
- for(int i=0;pl[i]!=-1;i++){
- Packet op=new Packet();
- int len=pl[i];
-
- op.packet_base=data;
- op.packet=inptr;
- op.bytes=len;
- op.e_o_s=(pl[i+1]<0?1:0);
- op.granulepos=(i+1)*1000;
-
- for(int j=0;j<len;j++)data[inptr++]=(byte)(i+j);
- os_en.packetin(op);
- }
-
-// free(data);
-
- // retrieve finished pages
- for(int i=0;i<5;i++){
- if(os_en.pageout(og[i])==0){
- System.err.print("Too few pages output building sync tests!\n");
- System.exit(1);
- }
- og[i].copy_page();
- }
-
- // Test lost pages on pagein/packetout: no rollback
- {
- Page temp=new Page();
- Packet test=new Packet();
-
- System.err.print("Testing loss of pages... ");
-
- oy.reset();
- os_de.reset();
- for(int i=0;i<5;i++){
- int index=oy.buffer(og[i].header_len);
- System.arraycopy(og[i].header_base, og[i].header,
- oy.data, index, og[i].header_len);
- oy.wrote(og[i].header_len);
- index=oy.buffer(og[i].body_len);
- System.arraycopy(og[i].body_base, og[i].body,
- oy.data, index, og[i].body_len);
- oy.wrote(og[i].body_len);
- }
-
- oy.pageout(temp);
- os_de.pagein(temp);
- oy.pageout(temp);
- os_de.pagein(temp);
- oy.pageout(temp);
-
- // skip
- oy.pageout(temp);
- os_de.pagein(temp);
-
- // do we get the expected results/packets?
-
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(0,0,0);
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(100,1,-1);
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(4079,2,3000);
- if(os_de.packetout(test)!=-1){
- System.err.println("Error: loss of page did not return error");
- System.exit(1);
- }
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(76,5,-1);
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(34,6,-1);
- System.err.println("ok.");
- }
-
- // Test lost pages on pagein/packetout: rollback with continuation
- {
- Page temp=new Page();
- Packet test=new Packet();
-
- System.err.print("Testing loss of pages (rollback required)... ");
-
- oy.reset();
- os_de.reset();
- for(int i=0;i<5;i++){
- int index=oy.buffer(og[i].header_len);
- System.arraycopy(og[i].header_base, og[i].header,
- oy.data, index, og[i].header_len);
- oy.wrote(og[i].header_len);
- index=oy.buffer(og[i].body_len);
- System.arraycopy(og[i].body_base, og[i].body,
- oy.data, index, og[i].body_len);
- oy.wrote(og[i].body_len);
- }
-
- oy.pageout(temp);
- os_de.pagein(temp);
- oy.pageout(temp);
- os_de.pagein(temp);
- oy.pageout(temp);
- os_de.pagein(temp);
- oy.pageout(temp);
- // skip
- oy.pageout(temp);
- os_de.pagein(temp);
-
- // do we get the expected results/packets?
-
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(0,0,0);
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(100,1,-1);
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(4079,2,3000);
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(2956,3,4000);
- if(os_de.packetout(test)!=-1){
- System.err.println("Error: loss of page did not return error");
- System.exit(1);
- }
- if(os_de.packetout(test)!=1)error();
- test.checkpacket(300,13,14000);
- System.err.println("ok.");
- }
-
- // the rest only test sync
- {
- Page og_de=new Page();
- // Test fractional page inputs: incomplete capture
- System.err.print("Testing sync on partial inputs... ");
- oy.reset();
- int index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header,
- oy.data, index, 3);
- oy.wrote(3);
- if(oy.pageout(og_de)>0)error();
-
- // Test fractional page inputs: incomplete fixed header
- index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header+3,
- oy.data, index, 20);
-
- oy.wrote(20);
- if(oy.pageout(og_de)>0)error();
-
- // Test fractional page inputs: incomplete header
- index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header+23,
- oy.data, index, 5);
- oy.wrote(5);
- if(oy.pageout(og_de)>0)error();
-
- // Test fractional page inputs: incomplete body
- index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header+28,
- oy.data, index, og[1].header_len-28);
- oy.wrote(og[1].header_len-28);
- if(oy.pageout(og_de)>0)error();
-
- index=oy.buffer(og[1].body_len);
- System.arraycopy(og[1].body_base, og[1].body,
- oy.data, index, 1000);
- oy.wrote(1000);
- if(oy.pageout(og_de)>0)error();
-
- index=oy.buffer(og[1].body_len);
- System.arraycopy(og[1].body_base, og[1].body+1000,
- oy.data, index, og[1].body_len-1000);
- oy.wrote(og[1].body_len-1000);
- if(oy.pageout(og_de)<=0)error();
- System.err.println("ok.");
- }
-
- // Test fractional page inputs: page + incomplete capture
- {
- Page og_de=new Page();
- System.err.print("Testing sync on 1+partial inputs... ");
- oy.reset();
-
- int index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header,
- oy.data, index, og[1].header_len);
- oy.wrote(og[1].header_len);
-
- index=oy.buffer(og[1].body_len);
- System.arraycopy(og[1].body_base, og[1].body,
- oy.data, index, og[1].body_len);
- oy.wrote(og[1].body_len);
-
- index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header,
- oy.data, index, 20);
- oy.wrote(20);
- if(oy.pageout(og_de)<=0)error();
- if(oy.pageout(og_de)>0)error();
-
- index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header+20,
- oy.data, index, og[1].header_len-20);
- oy.wrote(og[1].header_len-20);
- index=oy.buffer(og[1].body_len);
- System.arraycopy(og[1].body_base, og[1].body,
- oy.data, index, og[1].body_len);
-
- oy.wrote(og[1].body_len);
- if(oy.pageout(og_de)<=0)error();
-
- System.err.println("ok.");
- }
-
-// // // // // // // // //
- // Test recapture: garbage + page
- {
- Page og_de=new Page();
- System.err.print("Testing search for capture... ");
- oy.reset();
-
- // 'garbage'
- int index=oy.buffer(og[1].body_len);
- System.arraycopy(og[1].body_base, og[1].body,
- oy.data, index, og[1].body_len);
- oy.wrote(og[1].body_len);
-
- index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header,
- oy.data, index, og[1].header_len);
- oy.wrote(og[1].header_len);
-
- index=oy.buffer(og[1].body_len);
- System.arraycopy(og[1].body_base, og[1].body,
- oy.data, index, og[1].body_len);
- oy.wrote(og[1].body_len);
-
- index=oy.buffer(og[2].header_len);
- System.arraycopy(og[2].header_base, og[2].header,
- oy.data, index, 20);
-
- oy.wrote(20);
- if(oy.pageout(og_de)>0)error();
- if(oy.pageout(og_de)<=0)error();
- if(oy.pageout(og_de)>0)error();
-
- index=oy.buffer(og[2].header_len);
- System.arraycopy(og[2].header_base, og[2].header+20,
- oy.data, index, og[2].header_len-20);
- oy.wrote(og[2].header_len-20);
- index=oy.buffer(og[2].body_len);
- System.arraycopy(og[2].body_base, og[2].body,
- oy.data, index, og[2].body_len);
- oy.wrote(og[2].body_len);
- if(oy.pageout(og_de)<=0)error();
-
- System.err.println("ok.");
- }
-
- // Test recapture: page + garbage + page
- {
- Page og_de=new Page();
- System.err.print("Testing recapture... ");
- oy.reset();
-
- int index=oy.buffer(og[1].header_len);
- System.arraycopy(og[1].header_base, og[1].header,
- oy.data, index, og[1].header_len);
- oy.wrote(og[1].header_len);
-
- index=oy.buffer(og[1].body_len);
- System.arraycopy(og[1].body_base, og[1].body,
- oy.data, index, og[1].body_len);
- oy.wrote(og[1].body_len);
-
- index=oy.buffer(og[2].header_len);
- System.arraycopy(og[2].header_base, og[2].header,
- oy.data, index, og[2].header_len);
- oy.wrote(og[2].header_len);
-
- index=oy.buffer(og[2].header_len);
- System.arraycopy(og[2].header_base, og[2].header,
- oy.data, index, og[2].header_len);
- oy.wrote(og[2].header_len);
-
- if(oy.pageout(og_de)<=0)error();
-
- index=oy.buffer(og[2].body_len);
- System.arraycopy(og[2].body_base, og[2].body,
- oy.data, index, og[2].body_len-5);
- oy.wrote(og[2].body_len-5);
-
- index=oy.buffer(og[3].header_len);
- System.arraycopy(og[3].header_base, og[3].header,
- oy.data, index, og[3].header_len);
- oy.wrote(og[3].header_len);
-
- index=oy.buffer(og[3].body_len);
- System.arraycopy(og[3].body_base, og[3].body,
- oy.data, index, og[3].body_len);
- oy.wrote(og[3].body_len);
-
- if(oy.pageout(og_de)>0)error();
- if(oy.pageout(og_de)<=0)error();
-
- System.err.println("ok.");
- }
- }
- //return(0);
- }
- */
-}
diff --git a/songdbj/com/jcraft/jogg/StreamState.java b/songdbj/com/jcraft/jogg/StreamState.java
deleted file mode 100644
index 2f34b374f8..0000000000
--- a/songdbj/com/jcraft/jogg/StreamState.java
+++ /dev/null
@@ -1,657 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jogg;
-
-public class StreamState{
- byte[] body_data; /* bytes from packet bodies */
- int body_storage; /* storage elements allocated */
- int body_fill; /* elements stored; fill mark */
-private int body_returned; /* elements of fill returned */
-
-
- int[] lacing_vals; /* The values that will go to the segment table */
- long[] granule_vals; /* pcm_pos values for headers. Not compact
- this way, but it is simple coupled to the
- lacing fifo */
- int lacing_storage;
- int lacing_fill;
- int lacing_packet;
- int lacing_returned;
-
- byte[] header=new byte[282]; /* working space for header encode */
- int header_fill;
-
- public int e_o_s; /* set when we have buffered the last packet in the
- logical bitstream */
- int b_o_s; /* set after we've written the initial page
- of a logical bitstream */
- int serialno;
- int pageno;
- long packetno; /* sequence number for decode; the framing
- knows where there's a hole in the data,
- but we need coupling so that the codec
- (which is in a seperate abstraction
- layer) also knows about the gap */
- long granulepos;
-
- public StreamState(){
- init();
- }
-
- StreamState(int serialno){
- this();
- init(serialno);
- }
- void init(){
- body_storage=16*1024;
- body_data=new byte[body_storage];
- lacing_storage=1024;
- lacing_vals=new int[lacing_storage];
- granule_vals=new long[lacing_storage];
- }
- public void init(int serialno){
- if(body_data==null){ init(); }
- else{
- for(int i=0; i<body_data.length; i++) body_data[i]=0;
- for(int i=0; i<lacing_vals.length; i++) lacing_vals[i]=0;
- for(int i=0; i<granule_vals.length; i++) granule_vals[i]=0;
- }
- this.serialno=serialno;
- }
- public void clear(){
- body_data=null;
- lacing_vals=null;
- granule_vals=null;
- //memset(os,0,sizeof(ogg_stream_state));
- }
- void destroy(){
- clear();
- }
- void body_expand(int needed){
- if(body_storage<=body_fill+needed){
- body_storage+=(needed+1024);
- byte[] foo=new byte[body_storage];
- System.arraycopy(body_data, 0, foo, 0, body_data.length);
- body_data=foo;
-//System.out.println("expand: body_fill="+body_fill+", body_storage="+body_data.length);
- }
- }
- void lacing_expand(int needed){
- if(lacing_storage<=lacing_fill+needed){
- lacing_storage+=(needed+32);
- int[] foo=new int[lacing_storage];
- System.arraycopy(lacing_vals, 0, foo, 0, lacing_vals.length);
- lacing_vals=foo;
-
- long[] bar=new long[lacing_storage];
- System.arraycopy(granule_vals, 0, bar, 0, granule_vals.length);
- granule_vals=bar;
- }
- }
-
- /* submit data to the internal buffer of the framing engine */
- public int packetin(Packet op){
- int lacing_val=op.bytes/255+1;
-
- if(body_returned!=0){
- /* advance packet data according to the body_returned pointer. We
- had to keep it around to return a pointer into the buffer last
- call */
-
- body_fill-=body_returned;
- if(body_fill!=0){
-// memmove(os->body_data,os->body_data+os->body_returned,
-// os->body_fill*sizeof(char));
- System.arraycopy(body_data, body_returned, body_data, 0, body_fill);
- }
- body_returned=0;
- }
-
- /* make sure we have the buffer storage */
- body_expand(op.bytes);
- lacing_expand(lacing_val);
-
- /* Copy in the submitted packet. Yes, the copy is a waste; this is
- the liability of overly clean abstraction for the time being. It
- will actually be fairly easy to eliminate the extra copy in the
- future */
-
- System.arraycopy(op.packet_base, op.packet, body_data, body_fill, op.bytes);
- body_fill+=op.bytes;
-//System.out.println("add: "+body_fill);
-
- /* Store lacing vals for this packet */
- int j;
- for(j=0;j<lacing_val-1;j++){
- lacing_vals[lacing_fill+j]=255;
- granule_vals[lacing_fill+j]=granulepos;
- }
- lacing_vals[lacing_fill+j]=(op.bytes)%255;
- granulepos=granule_vals[lacing_fill+j]=op.granulepos;
-
- /* flag the first segment as the beginning of the packet */
- lacing_vals[lacing_fill]|= 0x100;
-
- lacing_fill+=lacing_val;
-
- /* for the sake of completeness */
- packetno++;
-
- if(op.e_o_s!=0)e_o_s=1;
- return(0);
- }
-
- public int packetout(Packet op){
-
- /* The last part of decode. We have the stream broken into packet
- segments. Now we need to group them into packets (or return the
- out of sync markers) */
-
- int ptr=lacing_returned;
-
- if(lacing_packet<=ptr){
- return(0);
- }
-
- if((lacing_vals[ptr]&0x400)!=0){
- /* We lost sync here; let the app know */
- lacing_returned++;
-
- /* we need to tell the codec there's a gap; it might need to
- handle previous packet dependencies. */
- packetno++;
- return(-1);
- }
-
- /* Gather the whole packet. We'll have no holes or a partial packet */
- {
- int size=lacing_vals[ptr]&0xff;
- int bytes=0;
-
- op.packet_base=body_data;
- op.packet=body_returned;
- op.e_o_s=lacing_vals[ptr]&0x200; /* last packet of the stream? */
- op.b_o_s=lacing_vals[ptr]&0x100; /* first packet of the stream? */
- bytes+=size;
-
- while(size==255){
- int val=lacing_vals[++ptr];
- size=val&0xff;
- if((val&0x200)!=0)op.e_o_s=0x200;
- bytes+=size;
- }
-
- op.packetno=packetno;
- op.granulepos=granule_vals[ptr];
- op.bytes=bytes;
-
-//System.out.println(this+" # body_returned="+body_returned);
- body_returned+=bytes;
-//System.out.println(this+"## body_returned="+body_returned);
-
- lacing_returned=ptr+1;
- }
- packetno++;
- return(1);
- }
-
-
- // add the incoming page to the stream state; we decompose the page
- // into packet segments here as well.
-
- public int pagein(Page og){
- byte[] header_base=og.header_base;
- int header=og.header;
- byte[] body_base=og.body_base;
- int body=og.body;
- int bodysize=og.body_len;
- int segptr=0;
-
- int version=og.version();
- int continued=og.continued();
- int bos=og.bos();
- int eos=og.eos();
- long granulepos=og.granulepos();
- int _serialno=og.serialno();
- int _pageno=og.pageno();
- int segments=header_base[header+26]&0xff;
-
- // clean up 'returned data'
- {
- int lr=lacing_returned;
- int br=body_returned;
-
- // body data
-
-//System.out.println("br="+br+", body_fill="+body_fill);
-
- if(br!=0){
- body_fill-=br;
- if(body_fill!=0){
- System.arraycopy(body_data, br, body_data, 0, body_fill);
- }
- body_returned=0;
- }
-
-//System.out.println("?? br="+br+", body_fill="+body_fill+" body_returned="+body_returned);
-
- if(lr!=0){
- // segment table
- if((lacing_fill-lr)!=0){
- System.arraycopy(lacing_vals, lr, lacing_vals, 0, lacing_fill-lr);
- System.arraycopy(granule_vals, lr, granule_vals, 0, lacing_fill-lr);
- }
- lacing_fill-=lr;
- lacing_packet-=lr;
- lacing_returned=0;
- }
- }
-
- // check the serial number
- if(_serialno!=serialno)return(-1);
- if(version>0)return(-1);
-
- lacing_expand(segments+1);
-
- // are we in sequence?
- if(_pageno!=pageno){
- int i;
-
- // unroll previous partial packet (if any)
- for(i=lacing_packet;i<lacing_fill;i++){
- body_fill-=lacing_vals[i]&0xff;
-//System.out.println("??");
- }
- lacing_fill=lacing_packet;
-
- // make a note of dropped data in segment table
- if(pageno!=-1){
- lacing_vals[lacing_fill++]=0x400;
- lacing_packet++;
- }
-
- // are we a 'continued packet' page? If so, we'll need to skip
- // some segments
- if(continued!=0){
- bos=0;
- for(;segptr<segments;segptr++){
- int val=(header_base[header+27+segptr]&0xff);
- body+=val;
- bodysize-=val;
- if(val<255){
- segptr++;
- break;
- }
- }
- }
- }
-
-//System.out.println("bodysize="+bodysize);
-
- if(bodysize!=0){
- body_expand(bodysize);
- System.arraycopy(body_base, body, body_data, body_fill, bodysize);
- body_fill+=bodysize;
- }
-
-//System.out.println("bodyfill="+body_fill);
-
- {
- int saved=-1;
- while(segptr<segments){
- int val=(header_base[header+27+segptr]&0xff);
- lacing_vals[lacing_fill]=val;
- granule_vals[lacing_fill]=-1;
-
- if(bos!=0){
- lacing_vals[lacing_fill]|=0x100;
- bos=0;
- }
-
- if(val<255)saved=lacing_fill;
-
- lacing_fill++;
- segptr++;
-
- if(val<255)lacing_packet=lacing_fill;
- }
-
- /* set the granulepos on the last pcmval of the last full packet */
- if(saved!=-1){
- granule_vals[saved]=granulepos;
- }
- }
-
- if(eos!=0){
- e_o_s=1;
- if(lacing_fill>0)
- lacing_vals[lacing_fill-1]|=0x200;
- }
-
- pageno=_pageno+1;
- return(0);
- }
-
-
-/* This will flush remaining packets into a page (returning nonzero),
- even if there is not enough data to trigger a flush normally
- (undersized page). If there are no packets or partial packets to
- flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will
- try to flush a normal sized page like ogg_stream_pageout; a call to
- ogg_stream_flush does not gurantee that all packets have flushed.
- Only a return value of 0 from ogg_stream_flush indicates all packet
- data is flushed into pages.
-
- ogg_stream_page will flush the last page in a stream even if it's
- undersized; you almost certainly want to use ogg_stream_pageout
- (and *not* ogg_stream_flush) unless you need to flush an undersized
- page in the middle of a stream for some reason. */
-
- public int flush(Page og){
-
-//System.out.println(this+" ---body_returned: "+body_returned);
-
- int i;
- int vals=0;
- int maxvals=(lacing_fill>255?255:lacing_fill);
- int bytes=0;
- int acc=0;
- long granule_pos=granule_vals[0];
-
- if(maxvals==0)return(0);
-
- /* construct a page */
- /* decide how many segments to include */
-
- /* If this is the initial header case, the first page must only include
- the initial header packet */
- if(b_o_s==0){ /* 'initial header page' case */
- granule_pos=0;
- for(vals=0;vals<maxvals;vals++){
- if((lacing_vals[vals]&0x0ff)<255){
- vals++;
- break;
- }
- }
- }
- else{
- for(vals=0;vals<maxvals;vals++){
- if(acc>4096)break;
- acc+=(lacing_vals[vals]&0x0ff);
- granule_pos=granule_vals[vals];
- }
- }
-
- /* construct the header in temp storage */
- System.arraycopy("OggS".getBytes(), 0, header, 0, 4);
-
- /* stream structure version */
- header[4]=0x00;
-
- /* continued packet flag? */
- header[5]=0x00;
- if((lacing_vals[0]&0x100)==0)header[5]|=0x01;
- /* first page flag? */
- if(b_o_s==0) header[5]|=0x02;
- /* last page flag? */
- if(e_o_s!=0 && lacing_fill==vals) header[5]|=0x04;
- b_o_s=1;
-
- /* 64 bits of PCM position */
- for(i=6;i<14;i++){
- header[i]=(byte)granule_pos;
- granule_pos>>>=8;
- }
-
- /* 32 bits of stream serial number */
- {
- int _serialno=serialno;
- for(i=14;i<18;i++){
- header[i]=(byte)_serialno;
- _serialno>>>=8;
- }
- }
-
- /* 32 bits of page counter (we have both counter and page header
- because this val can roll over) */
- if(pageno==-1)pageno=0; /* because someone called
- stream_reset; this would be a
- strange thing to do in an
- encode stream, but it has
- plausible uses */
- {
- int _pageno=pageno++;
- for(i=18;i<22;i++){
- header[i]=(byte)_pageno;
- _pageno>>>=8;
- }
- }
-
- /* zero for computation; filled in later */
- header[22]=0;
- header[23]=0;
- header[24]=0;
- header[25]=0;
-
- /* segment table */
- header[26]=(byte)vals;
- for(i=0;i<vals;i++){
- header[i+27]=(byte)lacing_vals[i];
- bytes+=(header[i+27]&0xff);
- }
-
- /* set pointers in the ogg_page struct */
- og.header_base=header;
- og.header=0;
- og.header_len=header_fill=vals+27;
- og.body_base=body_data;
- og.body=body_returned;
- og.body_len=bytes;
-
- /* advance the lacing data and set the body_returned pointer */
-
-//System.out.println("###body_returned: "+body_returned);
-
- lacing_fill-=vals;
- System.arraycopy(lacing_vals, vals, lacing_vals, 0, lacing_fill*4);
- System.arraycopy(granule_vals, vals, granule_vals, 0, lacing_fill*8);
- body_returned+=bytes;
-
-//System.out.println("####body_returned: "+body_returned);
-
- /* calculate the checksum */
-
- og.checksum();
-
- /* done */
- return(1);
- }
-
-
-/* This constructs pages from buffered packet segments. The pointers
-returned are to static buffers; do not free. The returned buffers are
-good only until the next call (using the same ogg_stream_state) */
- public int pageout(Page og){
-// if(body_returned!=0){
-// /* advance packet data according to the body_returned pointer. We
-// had to keep it around to return a pointer into the buffer last
-// call */
-//
-// body_fill-=body_returned;
-// if(body_fill!=0){ // overlap?
-// System.arraycopy(body_data, body_returned, body_data, 0, body_fill);
-// }
-// body_returned=0;
-// }
-//
-//System.out.println("pageout: e_o_s="+e_o_s+" lacing_fill="+lacing_fill+" body_fill="+body_fill+", lacing_fill="+lacing_fill+" b_o_s="+b_o_s);
-//
-// if((e_o_s!=0&&lacing_fill!=0) || /* 'were done, now flush' case */
-// body_fill > 4096 || /* 'page nominal size' case */
-// lacing_fill>=255 || /* 'segment table full' case */
-// (lacing_fill!=0&&b_o_s==0)){ /* 'initial header page' case */
-// int vals=0,bytes=0;
-// int maxvals=(lacing_fill>255?255:lacing_fill);
-// long acc=0;
-// long pcm_pos=granule_vals[0];
-//
-// /* construct a page */
-// /* decide how many segments to include */
-//
-// /* If this is the initial header case, the first page must only include
-// the initial header packet */
-// if(b_o_s==0){ /* 'initial header page' case */
-// pcm_pos=0;
-// for(vals=0;vals<maxvals;vals++){
-// if((lacing_vals[vals]&0x0ff)<255){
-// vals++;
-// break;
-// }
-// }
-// }
-// else{
-// for(vals=0;vals<maxvals;vals++){
-// if(acc>4096)break;
-// acc+=lacing_vals[vals]&0x0ff;
-// pcm_pos=granule_vals[vals];
-// }
-// }
-//
-// /* construct the header in temp storage */
-// System.arraycopy("OggS".getBytes(), 0, header, 0, 4);
-//
-// /* stream structure version */
-// header[4]=0x00;
-//
-// /* continued packet flag? */
-// header[5]=0x00;
-// if((lacing_vals[0]&0x100)==0)header[5]|=0x01;
-// /* first page flag? */
-// if(b_o_s==0)header[5]|=0x02;
-// /* last page flag? */
-// if(e_o_s!=0 && lacing_fill==vals)header[5]|=0x04;
-// b_o_s=1;
-//
-// /* 64 bits of PCM position */
-// for(int i=6;i<14;i++){
-// header[i]=(byte)pcm_pos;
-// pcm_pos>>>=8;
-// }
-//
-// /* 32 bits of stream serial number */
-// {
-// int serialn=serialno;
-// for(int i=14;i<18;i++){
-// header[i]=(byte)serialn;
-// serialn>>>=8;
-// }
-// }
-//
-//
-///* 32 bits of page counter (we have both counter and page header
-// because this val can roll over) */
-// if(pageno==-1)pageno=0; /* because someone called
-// stream_reset; this would be a
-// strange thing to do in an
-// encode stream, but it has
-// plausible uses */
-// {
-// int pagen=pageno++;
-// for(int i=18;i<22;i++){
-// header[i]=(byte)pagen;
-// pagen>>>=8;
-// }
-// }
-//
-// /* zero for computation; filled in later */
-// header[22]=0;
-// header[23]=0;
-// header[24]=0;
-// header[25]=0;
-//
-// /* segment table */
-// header[26]=(byte)vals;
-// for(int i=0;i<vals;i++){
-// header[i+27]=(byte)lacing_vals[i];
-// bytes+=header[i+27]&0xff;
-//// bytes+=header[i+27]=(lacing_vals[i]&0xff);
-// }
-//
-// /* advance the lacing data and set the body_returned pointer */
-//
-// lacing_fill-=vals;
-// System.arraycopy(lacing_vals, vals, lacing_vals, 0, lacing_fill);
-// System.arraycopy(granule_vals, vals, granule_vals, 0, lacing_fill);
-// body_returned=bytes;
-//
-// /* set pointers in the ogg_page struct */
-// og.header_base=header;
-// og.header=0;
-// og.header_len=header_fill=vals+27;
-//
-// og.body_base=body_data;
-// og.body=0;
-// og.body_len=bytes;
-//
-// /* calculate the checksum */
-//
-// og.checksum();
-// return(1);
-// }
-// /* not enough data to construct a page and not end of stream */
-// return(0);
-//System.out.println("pageout: "+body_returned);
- if((e_o_s!=0&&lacing_fill!=0) || /* 'were done, now flush' case */
- body_fill-body_returned> 4096 || /* 'page nominal size' case */
- lacing_fill>=255 || /* 'segment table full' case */
- (lacing_fill!=0&&b_o_s==0)){ /* 'initial header page' case */
- return flush(og);
- }
- return 0;
- }
-
- public int eof(){
- return e_o_s;
- }
-
- public int reset(){
- body_fill=0;
- body_returned=0;
-
- lacing_fill=0;
- lacing_packet=0;
- lacing_returned=0;
-
- header_fill=0;
-
- e_o_s=0;
- b_o_s=0;
- pageno=-1;
- packetno=0;
- granulepos=0;
- return(0);
- }
-}
diff --git a/songdbj/com/jcraft/jogg/SyncState.java b/songdbj/com/jcraft/jogg/SyncState.java
deleted file mode 100644
index b3705e54dd..0000000000
--- a/songdbj/com/jcraft/jogg/SyncState.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jogg;
-
-// DECODING PRIMITIVES: packet streaming layer
-
-// This has two layers to place more of the multi-serialno and paging
-// control in the application's hands. First, we expose a data buffer
-// using ogg_decode_buffer(). The app either copies into the
-// buffer, or passes it directly to read(), etc. We then call
-// ogg_decode_wrote() to tell how many bytes we just added.
-//
-// Pages are returned (pointers into the buffer in ogg_sync_state)
-// by ogg_decode_stream(). The page is then submitted to
-// ogg_decode_page() along with the appropriate
-// ogg_stream_state* (ie, matching serialno). We then get raw
-// packets out calling ogg_stream_packet() with a
-// ogg_stream_state. See the 'frame-prog.txt' docs for details and
-// example code.
-
-public class SyncState{
-
- public byte[] data;
- int storage;
- int fill;
- int returned;
-
- int unsynced;
- int headerbytes;
- int bodybytes;
-
- public int clear(){
- data=null;
- return(0);
- }
-
-// !!!!!!!!!!!!
-// byte[] buffer(int size){
- public int buffer(int size){
- // first, clear out any space that has been previously returned
- if(returned!=0){
- fill-=returned;
- if(fill>0){
- System.arraycopy(data, returned, data, 0, fill);
- }
- returned=0;
- }
-
- if(size>storage-fill){
- // We need to extend the internal buffer
- int newsize=size+fill+4096; // an extra page to be nice
- if(data!=null){
- byte[] foo=new byte[newsize];
- System.arraycopy(data, 0, foo, 0, data.length);
- data=foo;
- }
- else{
- data=new byte[newsize];
- }
- storage=newsize;
- }
-
- // expose a segment at least as large as requested at the fill mark
-// return((char *)oy->data+oy->fill);
-// return(data);
- return(fill);
- }
-
- public int wrote(int bytes){
- if(fill+bytes>storage)return(-1);
- fill+=bytes;
- return(0);
- }
-
-// sync the stream. This is meant to be useful for finding page
-// boundaries.
-//
-// return values for this:
-// -n) skipped n bytes
-// 0) page not ready; more data (no bytes skipped)
-// n) page synced at current location; page length n bytes
- private Page pageseek=new Page();
- private byte[] chksum=new byte[4];
- public int pageseek(Page og){
- int page=returned;
- int next;
- int bytes=fill-returned;
-
- if(headerbytes==0){
- int _headerbytes,i;
- if(bytes<27)return(0); // not enough for a header
-
- /* verify capture pattern */
-//!!!!!!!!!!!
- if(data[page]!='O' ||
- data[page+1]!='g' ||
- data[page+2]!='g' ||
- data[page+3]!='S'){
- headerbytes=0;
- bodybytes=0;
-
- // search for possible capture
- next=0;
- for(int ii=0; ii<bytes-1; ii++){
- if(data[page+1+ii]=='O'){next=page+1+ii; break;}
- }
- //next=memchr(page+1,'O',bytes-1);
- if(next==0) next=fill;
-
- returned=next;
- return(-(next-page));
- }
- _headerbytes=(data[page+26]&0xff)+27;
- if(bytes<_headerbytes)return(0); // not enough for header + seg table
-
- // count up body length in the segment table
-
- for(i=0;i<(data[page+26]&0xff);i++){
- bodybytes+=(data[page+27+i]&0xff);
- }
- headerbytes=_headerbytes;
- }
-
- if(bodybytes+headerbytes>bytes)return(0);
-
- // The whole test page is buffered. Verify the checksum
- synchronized(chksum){
- // Grab the checksum bytes, set the header field to zero
-
- System.arraycopy(data, page+22, chksum, 0, 4);
- data[page+22]=0;
- data[page+23]=0;
- data[page+24]=0;
- data[page+25]=0;
-
- // set up a temp page struct and recompute the checksum
- Page log=pageseek;
- log.header_base=data;
- log.header=page;
- log.header_len=headerbytes;
-
- log.body_base=data;
- log.body=page+headerbytes;
- log.body_len=bodybytes;
- log.checksum();
-
- // Compare
- if(chksum[0]!=data[page+22] ||
- chksum[1]!=data[page+23] ||
- chksum[2]!=data[page+24] ||
- chksum[3]!=data[page+25]){
- // D'oh. Mismatch! Corrupt page (or miscapture and not a page at all)
- // replace the computed checksum with the one actually read in
- System.arraycopy(chksum, 0, data, page+22, 4);
- // Bad checksum. Lose sync */
-
- headerbytes=0;
- bodybytes=0;
- // search for possible capture
- next=0;
- for(int ii=0; ii<bytes-1; ii++){
- if(data[page+1+ii]=='O'){next=page+1+ii; break;}
- }
- //next=memchr(page+1,'O',bytes-1);
- if(next==0) next=fill;
- returned=next;
- return(-(next-page));
- }
- }
-
- // yes, have a whole page all ready to go
- {
- page=returned;
-
- if(og!=null){
- og.header_base=data;
- og.header=page;
- og.header_len=headerbytes;
- og.body_base=data;
- og.body=page+headerbytes;
- og.body_len=bodybytes;
- }
-
- unsynced=0;
- returned+=(bytes=headerbytes+bodybytes);
- headerbytes=0;
- bodybytes=0;
- return(bytes);
- }
-// headerbytes=0;
-// bodybytes=0;
-// next=0;
-// for(int ii=0; ii<bytes-1; ii++){
-// if(data[page+1+ii]=='O'){next=page+1+ii;}
-// }
-// //next=memchr(page+1,'O',bytes-1);
-// if(next==0) next=fill;
-// returned=next;
-// return(-(next-page));
- }
-
-
-// sync the stream and get a page. Keep trying until we find a page.
-// Supress 'sync errors' after reporting the first.
-//
-// return values:
-// -1) recapture (hole in data)
-// 0) need more data
-// 1) page returned
-//
-// Returns pointers into buffered data; invalidated by next call to
-// _stream, _clear, _init, or _buffer
-
- public int pageout(Page og){
- // all we need to do is verify a page at the head of the stream
- // buffer. If it doesn't verify, we look for the next potential
- // frame
-
- while(true){
- int ret=pageseek(og);
- if(ret>0){
- // have a page
- return(1);
- }
- if(ret==0){
- // need more data
- return(0);
- }
-
- // head did not start a synced page... skipped some bytes
- if(unsynced==0){
- unsynced=1;
- return(-1);
- }
- // loop. keep looking
- }
- }
-
-// clear things to an initial state. Good to call, eg, before seeking
- public int reset(){
- fill=0;
- returned=0;
- unsynced=0;
- headerbytes=0;
- bodybytes=0;
- return(0);
- }
- public void init(){}
-
- public int getDataOffset(){ return returned; }
- public int getBufferOffset(){ return fill; }
-}
diff --git a/songdbj/com/jcraft/jorbis/AllocChain.java b/songdbj/com/jcraft/jorbis/AllocChain.java
deleted file mode 100644
index b3492d5c94..0000000000
--- a/songdbj/com/jcraft/jorbis/AllocChain.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class AllocChain{
- Object ptr;
- AllocChain next;
-};
diff --git a/songdbj/com/jcraft/jorbis/Block.java b/songdbj/com/jcraft/jorbis/Block.java
deleted file mode 100644
index 8fd15f76bf..0000000000
--- a/songdbj/com/jcraft/jorbis/Block.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-public class Block{
- ///necessary stream state for linking to the framing abstraction
- float[][] pcm=new float[0][]; // this is a pointer into local storage
- Buffer opb=new Buffer();
-
- int lW;
- int W;
- int nW;
- int pcmend;
- int mode;
-
- int eofflag;
- long granulepos;
- long sequence;
- DspState vd; // For read-only access of configuration
-
- // local storage to avoid remallocing; it's up to the mapping to
- // structure it
-//byte[] localstore;
-//int localtop;
-//int localalloc;
-//int totaluse;
-//AllocChain reap;
-
- // bitmetrics for the frame
- int glue_bits;
- int time_bits;
- int floor_bits;
- int res_bits;
-
- public Block(DspState vd){
- this.vd=vd;
-// localalloc=0;
-// localstore=null;
- if(vd.analysisp!=0){
- opb.writeinit();
- }
- }
-
- public void init(DspState vd){
- this.vd=vd;
- }
-
-// int alloc(int bytes){
-// bytes=(bytes+(8-1))&(~(8-1));
-// if(bytes+localtop>localalloc){
-// if(localstore!=null){
-// AllocChain link=new AllocChain();
-// totaluse+=localtop;
-// link.next=reap;
-// link.ptr=localstore;
-// reap=link;
-// }
-// // highly conservative
-// localalloc=bytes;
-// localstore=new byte[localalloc];
-// localtop=0;
-// }
-// {
-// int foo=localtop;
-// //void *ret=(void *)(((char *)vb->localstore)+vb->localtop);
-// localtop+=bytes;
-// return foo;
-// }
-// }
-
- // reap the chain, pull the ripcord
-// void ripcord(){
-// // reap the chain
-// while(reap!=null){
-// AllocChain next=reap.next;
-// //free(reap->ptr);
-// reap.ptr=null;
-// //memset(reap,0,sizeof(struct alloc_chain));
-// //free(reap);
-// reap=next;
-// }
-// // consolidate storage
-// if(totaluse!=0){
-// //vb->localstore=realloc(vb->localstore,vb->totaluse+vb->localalloc);
-// byte[] foo=new byte[totaluse+localalloc];
-// System.arraycopy(localstore, 0, foo, 0, localstore.length);
-// localstore=foo;
-// localalloc+=totaluse;
-// totaluse=0;
-// }
-// // pull the ripcord
-// localtop=0;
-// reap=null;
-// }
-
- public int clear(){
- if(vd!=null){
- if(vd.analysisp!=0){
- opb.writeclear();
- }
- }
- //ripcord();
- //if(localstore!=null)
- // localstore=null;
- //memset(vb,0,sizeof(vorbis_block));
- return(0);
- }
-
- public int synthesis(Packet op){
- Info vi=vd.vi;
-
- // first things first. Make sure decode is ready
- // ripcord();
- opb.readinit(op.packet_base, op.packet, op.bytes);
-
- // Check the packet type
- if(opb.read(1)!=0){
- // Oops. This is not an audio data packet
- return(-1);
- }
-
- // read our mode and pre/post windowsize
- int _mode=opb.read(vd.modebits);
- if(_mode==-1)return(-1);
-
- mode=_mode;
- W=vi.mode_param[mode].blockflag;
- if(W!=0){
- lW=opb.read(1);
- nW=opb.read(1);
- if(nW==-1) return(-1);
- }
- else{
- lW=0;
- nW=0;
- }
-
- // more setup
- granulepos=op.granulepos;
- sequence=op.packetno-3; // first block is third packet
- eofflag=op.e_o_s;
-
- // alloc pcm passback storage
- pcmend=vi.blocksizes[W];
- //pcm=alloc(vi.channels);
- if(pcm.length<vi.channels){
- pcm=new float[vi.channels][];
- }
- for(int i=0;i<vi.channels;i++){
- if(pcm[i]==null || pcm[i].length<pcmend){
- pcm[i]=new float[pcmend];
- //pcm[i]=alloc(pcmend);
- }
- else{
- for(int j=0;j<pcmend;j++){ pcm[i][j]=0; }
- }
- }
-
- // unpack_header enforces range checking
- int type=vi.map_type[vi.mode_param[mode].mapping];
- return(FuncMapping.mapping_P[type].inverse(this, vd.mode[mode]));
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/ChainingExample.java b/songdbj/com/jcraft/jorbis/ChainingExample.java
deleted file mode 100644
index 82592f29c4..0000000000
--- a/songdbj/com/jcraft/jorbis/ChainingExample.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class ChainingExample{
- public static void main(String[] arg){
- VorbisFile ov=null;
-
- try{
- ov=new VorbisFile(System.in, null, -1);
- }
- catch(Exception e){
- System.err.println(e);
- return;
- }
-
- if(ov.seekable()){
- System.out.println("Input bitstream contained "+ov.streams()+" logical bitstream section(s).");
- System.out.println("Total bitstream playing time: "+ov.time_total(-1)+" seconds\n");
- }
- else{
- System.out.println("Standard input was not seekable.");
- System.out.println("First logical bitstream information:\n");
- }
-
- for(int i=0;i<ov.streams();i++){
- Info vi=ov.getInfo(i);
- System.out.println("\tlogical bitstream section "+(i+1)+" information:");
- System.out.println("\t\t"+vi.rate+"Hz "+vi.channels+" channels bitrate "+
- (ov.bitrate(i)/1000)+"kbps serial number="+ov.serialnumber(i));
- System.out.print("\t\tcompressed length: "+ov.raw_total(i)+" bytes ");
- System.out.println(" play time: "+ov.time_total(i)+"s");
- Comment vc=ov.getComment(i);
- System.out.println(vc);
- }
- //clear(&ov);
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/CodeBook.java b/songdbj/com/jcraft/jorbis/CodeBook.java
deleted file mode 100644
index 9708e066a4..0000000000
--- a/songdbj/com/jcraft/jorbis/CodeBook.java
+++ /dev/null
@@ -1,742 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class CodeBook{
- int dim; // codebook dimensions (elements per vector)
- int entries; // codebook entries
- StaticCodeBook c=new StaticCodeBook();
-
- float[] valuelist; // list of dim*entries actual entry values
- int[] codelist; // list of bitstream codewords for each entry
- DecodeAux decode_tree;
-
- // returns the number of bits
- int encode(int a, Buffer b){
- b.write(codelist[a], c.lengthlist[a]);
- return(c.lengthlist[a]);
- }
-
- // One the encode side, our vector writers are each designed for a
- // specific purpose, and the encoder is not flexible without modification:
- //
- // The LSP vector coder uses a single stage nearest-match with no
- // interleave, so no step and no error return. This is specced by floor0
- // and doesn't change.
- //
- // Residue0 encoding interleaves, uses multiple stages, and each stage
- // peels of a specific amount of resolution from a lattice (thus we want
- // to match by threshhold, not nearest match). Residue doesn't *have* to
- // be encoded that way, but to change it, one will need to add more
- // infrastructure on the encode side (decode side is specced and simpler)
-
- // floor0 LSP (single stage, non interleaved, nearest match)
- // returns entry number and *modifies a* to the quantization value
- int errorv(float[] a){
- int best=best(a,1);
- for(int k=0;k<dim;k++){
- a[k]=valuelist[best*dim+k];
- }
- return(best);
- }
-
- // returns the number of bits and *modifies a* to the quantization value
- int encodev(int best, float[] a, Buffer b){
- for(int k=0;k<dim;k++){
- a[k]=valuelist[best*dim+k];
- }
- return(encode(best,b));
- }
-
- // res0 (multistage, interleave, lattice)
- // returns the number of bits and *modifies a* to the remainder value
- int encodevs(float[] a, Buffer b, int step,int addmul){
- int best=besterror(a,step,addmul);
- return(encode(best,b));
- }
-
- private int[] t=new int[15]; // decodevs_add is synchronized for re-using t.
- synchronized int decodevs_add(float[]a, int offset, Buffer b, int n){
- int step=n/dim;
- int entry;
- int i,j,o;
-
- if(t.length<step){
- t=new int[step];
- }
-
- for(i = 0; i < step; i++){
- entry=decode(b);
- if(entry==-1)return(-1);
- t[i]=entry*dim;
- }
- for(i=0,o=0;i<dim;i++,o+=step){
- for(j=0;j<step;j++){
- a[offset+o+j]+=valuelist[t[j]+i];
- }
- }
-
- return(0);
- }
-
- int decodev_add(float[]a, int offset, Buffer b,int n){
- int i,j,entry;
- int t;
-
- if(dim>8){
- for(i=0;i<n;){
- entry = decode(b);
- if(entry==-1)return(-1);
- t=entry*dim;
- for(j=0;j<dim;){
- a[offset+(i++)]+=valuelist[t+(j++)];
- }
- }
- }
- else{
- for(i=0;i<n;){
- entry=decode(b);
- if(entry==-1)return(-1);
- t=entry*dim;
- j=0;
- switch(dim){
- case 8:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 7:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 6:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 5:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 4:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 3:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 2:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 1:
- a[offset+(i++)]+=valuelist[t+(j++)];
- case 0:
- break;
- }
- }
- }
- return(0);
- }
-
- int decodev_set(float[] a,int offset, Buffer b, int n){
- int i,j,entry;
- int t;
-
- for(i=0;i<n;){
- entry = decode(b);
- if(entry==-1)return(-1);
- t=entry*dim;
- for(j=0;j<dim;){
- a[offset+i++]=valuelist[t+(j++)];
- }
- }
- return(0);
- }
-
- int decodevv_add(float[][] a, int offset,int ch, Buffer b,int n){
- int i,j,k,entry;
- int chptr=0;
- //System.out.println("decodevv_add: a="+a+",b="+b+",valuelist="+valuelist);
-
- for(i=offset/ch;i<(offset+n)/ch;){
- entry = decode(b);
- if(entry==-1)return(-1);
-
- int t = entry*dim;
- for(j=0;j<dim;j++){
- a[chptr++][i]+=valuelist[t+j];
- if(chptr==ch){
- chptr=0;
- i++;
- }
- }
- }
- return(0);
- }
-
-
- // Decode side is specced and easier, because we don't need to find
- // matches using different criteria; we simply read and map. There are
- // two things we need to do 'depending':
- //
- // We may need to support interleave. We don't really, but it's
- // convenient to do it here rather than rebuild the vector later.
- //
- // Cascades may be additive or multiplicitive; this is not inherent in
- // the codebook, but set in the code using the codebook. Like
- // interleaving, it's easiest to do it here.
- // stage==0 -> declarative (set the value)
- // stage==1 -> additive
- // stage==2 -> multiplicitive
-
- // returns the entry number or -1 on eof
- int decode(Buffer b){
- int ptr=0;
- DecodeAux t=decode_tree;
- int lok=b.look(t.tabn);
- //System.err.println(this+" "+t+" lok="+lok+", tabn="+t.tabn);
-
- if(lok>=0){
- ptr=t.tab[lok];
- b.adv(t.tabl[lok]);
- if(ptr<=0){
- return -ptr;
- }
- }
- do{
- switch(b.read1()){
- case 0:
- ptr=t.ptr0[ptr];
- break;
- case 1:
- ptr=t.ptr1[ptr];
- break;
- case -1:
- default:
- return(-1);
- }
- }
- while(ptr>0);
- return(-ptr);
- }
-
- // returns the entry number or -1 on eof
- int decodevs(float[] a, int index, Buffer b, int step,int addmul){
- int entry=decode(b);
- if(entry==-1)return(-1);
- switch(addmul){
- case -1:
- for(int i=0,o=0;i<dim;i++,o+=step)
- a[index+o]=valuelist[entry*dim+i];
- break;
- case 0:
- for(int i=0,o=0;i<dim;i++,o+=step)
- a[index+o]+=valuelist[entry*dim+i];
- break;
- case 1:
- for(int i=0,o=0;i<dim;i++,o+=step)
- a[index+o]*=valuelist[entry*dim+i];
- break;
- default:
- //System.err.println("CodeBook.decodeves: addmul="+addmul);
- }
- return(entry);
- }
-
- int best(float[] a, int step){
- EncodeAuxNearestMatch nt=c.nearest_tree;
- EncodeAuxThreshMatch tt=c.thresh_tree;
- int ptr=0;
-
- // we assume for now that a thresh tree is the only other possibility
- if(tt!=null){
- int index=0;
- // find the quant val of each scalar
- for(int k=0,o=step*(dim-1);k<dim;k++,o-=step){
- int i;
- // linear search the quant list for now; it's small and although
- // with > 8 entries, it would be faster to bisect, this would be
- // a misplaced optimization for now
- for(i=0;i<tt.threshvals-1;i++){
- if(a[o]<tt.quantthresh[i]){
- break;
- }
- }
- index=(index*tt.quantvals)+tt.quantmap[i];
- }
- // regular lattices are easy :-)
- if(c.lengthlist[index]>0){
- // is this unused? If so, we'll
- // use a decision tree after all
- // and fall through
- return(index);
- }
- }
- if(nt!=null){
- // optimized using the decision tree
- while(true){
- float c=0.f;
- int p=nt.p[ptr];
- int q=nt.q[ptr];
- for(int k=0,o=0;k<dim;k++,o+=step){
- c+=(valuelist[p+k]-valuelist[q+k])*
- (a[o]-(valuelist[p+k]+valuelist[q+k])*.5);
- }
- if(c>0.){ // in A
- ptr= -nt.ptr0[ptr];
- }
- else{ // in B
- ptr= -nt.ptr1[ptr];
- }
- if(ptr<=0)break;
- }
- return(-ptr);
- }
-
- // brute force it!
- {
- int besti=-1;
- float best=0.f;
- int e=0;
- for(int i=0;i<entries;i++){
- if(c.lengthlist[i]>0){
- float _this=dist(dim, valuelist, e, a, step);
- if(besti==-1 || _this<best){
- best=_this;
- besti=i;
- }
- }
- e+=dim;
- }
- return(besti);
- }
- }
-
- // returns the entry number and *modifies a* to the remainder value
- int besterror(float[] a, int step, int addmul){
- int best=best(a,step);
- switch(addmul){
- case 0:
- for(int i=0,o=0;i<dim;i++,o+=step)
- a[o]-=valuelist[best*dim+i];
- break;
- case 1:
- for(int i=0,o=0;i<dim;i++,o+=step){
- float val=valuelist[best*dim+i];
- if(val==0){
- a[o]=0;
- }else{
- a[o]/=val;
- }
- }
- break;
- }
- return(best);
- }
-
- void clear(){
- // static book is not cleared; we're likely called on the lookup and
- // the static codebook belongs to the info struct
- //if(decode_tree!=null){
- // free(b->decode_tree->ptr0);
- // free(b->decode_tree->ptr1);
- // memset(b->decode_tree,0,sizeof(decode_aux));
- // free(b->decode_tree);
- //}
- //if(valuelist!=null)free(b->valuelist);
- //if(codelist!=null)free(b->codelist);
- //memset(b,0,sizeof(codebook));
- }
-
- private static float dist(int el, float[] ref, int index, float[] b, int step){
- float acc=(float)0.;
- for(int i=0; i<el; i++){
- float val=(ref[index+i]-b[i*step]);
- acc+=val*val;
- }
- return(acc);
- }
-
-/*
- int init_encode(StaticCodeBook s){
- //memset(c,0,sizeof(codebook));
- c=s;
- entries=s.entries;
- dim=s.dim;
- codelist=make_words(s.lengthlist, s.entries);
- valuelist=s.unquantize();
- return(0);
- }
-*/
-
- int init_decode(StaticCodeBook s){
- //memset(c,0,sizeof(codebook));
- c=s;
- entries=s.entries;
- dim=s.dim;
- valuelist=s.unquantize();
-
- decode_tree=make_decode_tree();
- if(decode_tree==null){
- //goto err_out;
- clear();
- return(-1);
- }
- return(0);
-// err_out:
-// vorbis_book_clear(c);
-// return(-1);
- }
-
- // given a list of word lengths, generate a list of codewords. Works
- // for length ordered or unordered, always assigns the lowest valued
- // codewords first. Extended to handle unused entries (length 0)
- static int[] make_words(int[] l, int n){
- int[] marker=new int[33];
- int[] r=new int[n];
- //memset(marker,0,sizeof(marker));
-
- for(int i=0;i<n;i++){
- int length=l[i];
- if(length>0){
- int entry=marker[length];
-
- // when we claim a node for an entry, we also claim the nodes
- // below it (pruning off the imagined tree that may have dangled
- // from it) as well as blocking the use of any nodes directly
- // above for leaves
-
- // update ourself
- if(length<32 && (entry>>>length)!=0){
- // error condition; the lengths must specify an overpopulated tree
- //free(r);
- return(null);
- }
- r[i]=entry;
-
- // Look to see if the next shorter marker points to the node
- // above. if so, update it and repeat.
- {
- for(int j=length;j>0;j--){
- if((marker[j]&1)!=0){
- // have to jump branches
- if(j==1)marker[1]++;
- else marker[j]=marker[j-1]<<1;
- break; // invariant says next upper marker would already
- // have been moved if it was on the same path
- }
- marker[j]++;
- }
- }
-
- // prune the tree; the implicit invariant says all the longer
- // markers were dangling from our just-taken node. Dangle them
- // from our *new* node.
- for(int j=length+1;j<33;j++){
- if((marker[j]>>>1) == entry){
- entry=marker[j];
- marker[j]=marker[j-1]<<1;
- }
- else{
- break;
- }
- }
- }
- }
-
- // bitreverse the words because our bitwise packer/unpacker is LSb
- // endian
- for(int i=0;i<n;i++){
- int temp=0;
- for(int j=0;j<l[i];j++){
- temp<<=1;
- temp|=(r[i]>>>j)&1;
- }
- r[i]=temp;
- }
-
- return(r);
- }
-
- // build the decode helper tree from the codewords
- DecodeAux make_decode_tree(){
- int top=0;
- DecodeAux t=new DecodeAux();
- int[] ptr0=t.ptr0=new int[entries*2];
- int[] ptr1=t.ptr1=new int[entries*2];
- int[] codelist=make_words(c.lengthlist, c.entries);
-
- if(codelist==null)return(null);
- t.aux=entries*2;
-
- for(int i=0;i<entries;i++){
- if(c.lengthlist[i]>0){
- int ptr=0;
- int j;
- for(j=0;j<c.lengthlist[i]-1;j++){
- int bit=(codelist[i]>>>j)&1;
- if(bit==0){
- if(ptr0[ptr]==0){
- ptr0[ptr]=++top;
- }
- ptr=ptr0[ptr];
- }
- else{
- if(ptr1[ptr]==0){
- ptr1[ptr]= ++top;
- }
- ptr=ptr1[ptr];
- }
- }
-
- if(((codelist[i]>>>j)&1)==0){ ptr0[ptr]=-i; }
- else{ ptr1[ptr]=-i; }
-
- }
- }
- //free(codelist);
-
- t.tabn = ilog(entries)-4;
-
- if(t.tabn<5)t.tabn=5;
- int n = 1<<t.tabn;
- t.tab = new int[n];
- t.tabl = new int[n];
- for(int i = 0; i < n; i++){
- int p = 0;
- int j=0;
- for(j = 0; j < t.tabn && (p > 0 || j == 0); j++){
- if ((i&(1<<j))!=0){
- p = ptr1[p];
- }
- else{
- p = ptr0[p];
- }
- }
- t.tab[i]=p; // -code
- t.tabl[i]=j; // length
- }
-
- return(t);
- }
-
- private static int ilog(int v){
- int ret=0;
- while(v!=0){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-
-/*
- // TEST
- // Simple enough; pack a few candidate codebooks, unpack them. Code a
- // number of vectors through (keeping track of the quantized values),
- // and decode using the unpacked book. quantized version of in should
- // exactly equal out
-
- //#include "vorbis/book/lsp20_0.vqh"
- //#include "vorbis/book/lsp32_0.vqh"
- //#include "vorbis/book/res0_1a.vqh"
- static final int TESTSIZE=40;
-
- static float[] test1={
- 0.105939,
- 0.215373,
- 0.429117,
- 0.587974,
-
- 0.181173,
- 0.296583,
- 0.515707,
- 0.715261,
-
- 0.162327,
- 0.263834,
- 0.342876,
- 0.406025,
-
- 0.103571,
- 0.223561,
- 0.368513,
- 0.540313,
-
- 0.136672,
- 0.395882,
- 0.587183,
- 0.652476,
-
- 0.114338,
- 0.417300,
- 0.525486,
- 0.698679,
-
- 0.147492,
- 0.324481,
- 0.643089,
- 0.757582,
-
- 0.139556,
- 0.215795,
- 0.324559,
- 0.399387,
-
- 0.120236,
- 0.267420,
- 0.446940,
- 0.608760,
-
- 0.115587,
- 0.287234,
- 0.571081,
- 0.708603,
- };
-
- static float[] test2={
- 0.088654,
- 0.165742,
- 0.279013,
- 0.395894,
-
- 0.110812,
- 0.218422,
- 0.283423,
- 0.371719,
-
- 0.136985,
- 0.186066,
- 0.309814,
- 0.381521,
-
- 0.123925,
- 0.211707,
- 0.314771,
- 0.433026,
-
- 0.088619,
- 0.192276,
- 0.277568,
- 0.343509,
-
- 0.068400,
- 0.132901,
- 0.223999,
- 0.302538,
-
- 0.202159,
- 0.306131,
- 0.360362,
- 0.416066,
-
- 0.072591,
- 0.178019,
- 0.304315,
- 0.376516,
-
- 0.094336,
- 0.188401,
- 0.325119,
- 0.390264,
-
- 0.091636,
- 0.223099,
- 0.282899,
- 0.375124,
- };
-
- static float[] test3={
- 0,1,-2,3,4,-5,6,7,8,9,
- 8,-2,7,-1,4,6,8,3,1,-9,
- 10,11,12,13,14,15,26,17,18,19,
- 30,-25,-30,-1,-5,-32,4,3,-2,0};
-
-// static_codebook *testlist[]={&_vq_book_lsp20_0,
-// &_vq_book_lsp32_0,
-// &_vq_book_res0_1a,NULL};
- static[][] float testvec={test1,test2,test3};
-
- static void main(String[] arg){
- Buffer write=new Buffer();
- Buffer read=new Buffer();
- int ptr=0;
- write.writeinit();
-
- System.err.println("Testing codebook abstraction...:");
-
- while(testlist[ptr]!=null){
- CodeBook c=new CodeBook();
- StaticCodeBook s=new StaticCodeBook();;
- float *qv=alloca(sizeof(float)*TESTSIZE);
- float *iv=alloca(sizeof(float)*TESTSIZE);
- memcpy(qv,testvec[ptr],sizeof(float)*TESTSIZE);
- memset(iv,0,sizeof(float)*TESTSIZE);
-
- System.err.print("\tpacking/coding "+ptr+"... ");
-
- // pack the codebook, write the testvector
- write.reset();
- vorbis_book_init_encode(&c,testlist[ptr]); // get it into memory
- // we can write
- vorbis_staticbook_pack(testlist[ptr],&write);
- System.err.print("Codebook size "+write.bytes()+" bytes... ");
- for(int i=0;i<TESTSIZE;i+=c.dim){
- vorbis_book_encodev(&c,qv+i,&write);
- }
- c.clear();
-
- System.err.print("OK.\n");
- System.err.print("\tunpacking/decoding "+ptr+"... ");
-
- // transfer the write data to a read buffer and unpack/read
- _oggpack_readinit(&read,_oggpack_buffer(&write),_oggpack_bytes(&write));
- if(s.unpack(read)){
- System.err.print("Error unpacking codebook.\n");
- System.exit(1);
- }
- if(vorbis_book_init_decode(&c,&s)){
- System.err.print("Error initializing codebook.\n");
- System.exit(1);
- }
- for(int i=0;i<TESTSIZE;i+=c.dim){
- if(vorbis_book_decodevs(&c,iv+i,&read,1,-1)==-1){
- System.err.print("Error reading codebook test data (EOP).\n");
- System.exit(1);
- }
- }
- for(int i=0;i<TESTSIZE;i++){
- if(fabs(qv[i]-iv[i])>.000001){
- System.err.print("read ("+iv[i]+") != written ("+qv[i]+") at position ("+i+")\n");
- System.exit(1);
- }
- }
-
- System.err.print("OK\n");
- ptr++;
- }
- // The above is the trivial stuff;
- // now try unquantizing a log scale codebook
- }
-*/
-}
-
-class DecodeAux{
- int[] tab;
- int[] tabl;
- int tabn;
-
- int[] ptr0;
- int[] ptr1;
- int aux; // number of tree entries
-}
diff --git a/songdbj/com/jcraft/jorbis/Comment.java b/songdbj/com/jcraft/jorbis/Comment.java
deleted file mode 100644
index f83b7cb985..0000000000
--- a/songdbj/com/jcraft/jorbis/Comment.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-// the comments are not part of vorbis_info so that vorbis_info can be
-// static storage
-public class Comment{
- private static byte[] _vorbis="vorbis".getBytes();
-
- private static final int OV_EFAULT=-129;
- private static final int OV_EIMPL=-130;
-
- // unlimited user comment fields. libvorbis writes 'libvorbis'
- // whatever vendor is set to in encode
- public byte[][] user_comments;
- public int[] comment_lengths;
- public int comments;
- public byte[] vendor;
-
- public void init(){
- user_comments=null;
- comments=0;
- vendor=null;
- }
-
- public void add(String comment){
- add(comment.getBytes());
- }
-
- private void add(byte[] comment){
- byte[][] foo=new byte[comments+2][];
- if(user_comments!=null){
- System.arraycopy(user_comments, 0, foo, 0, comments);
- }
- user_comments=foo;
-
- int[] goo=new int[comments+2];
- if(comment_lengths!=null){
- System.arraycopy(comment_lengths, 0, goo, 0, comments);
- }
- comment_lengths=goo;
-
- byte[] bar=new byte[comment.length+1];
- System.arraycopy(comment, 0, bar, 0, comment.length);
- user_comments[comments]=bar;
- comment_lengths[comments]=comment.length;
- comments++;
- user_comments[comments]=null;
- }
-
- public void add_tag(String tag, String contents){
- if(contents==null) contents="";
- add(tag+"="+contents);
- }
-
-/*
- private void add_tag(byte[] tag, byte[] contents){
- byte[] foo=new byte[tag.length+contents.length+1];
- int j=0;
- for(int i=0; i<tag.length; i++){foo[j++]=tag[i];}
- foo[j++]=(byte)'='; j++;
- for(int i=0; i<contents.length; i++){foo[j++]=tag[i];}
- add(foo);
- }
-*/
-
- // This is more or less the same as strncasecmp - but that doesn't exist
- // * everywhere, and this is a fairly trivial function, so we include it
- static boolean tagcompare(byte[] s1, byte[] s2, int n){
- int c=0;
- byte u1, u2;
- while(c < n){
- u1=s1[c]; u2=s2[c];
- if('Z'>=u1 && u1>='A')u1=(byte)(u1-'A'+'a');
- if('Z'>=u2 && u2>='A')u2=(byte)(u2-'A'+'a');
- if(u1!=u2){ return false; }
- c++;
- }
- return true;
- }
-
- public String query(String tag){
- return query(tag, 0);
- }
-
- public String query(String tag, int count){
- int foo=query(tag.getBytes(), count);
- if(foo==-1)return null;
- byte[] comment=user_comments[foo];
- for(int i=0; i<comment_lengths[foo]; i++){
- if(comment[i]=='='){
- return new String(comment, i+1, comment_lengths[foo]-(i+1));
- }
- }
- return null;
- }
-
- private int query(byte[] tag, int count){
- int i=0;
- int found = 0;
- int fulltaglen = tag.length + 1;
- byte[] fulltag = new byte[fulltaglen];
- System.arraycopy(tag, 0, fulltag, 0, tag.length);
- fulltag[tag.length]=(byte)'=';
-
- for(i=0;i<comments;i++){
- if(tagcompare(user_comments[i], fulltag, fulltaglen)){
- if(count==found){
- // We return a pointer to the data, not a copy
- //return user_comments[i] + taglen + 1;
- return i;
- }
- else{ found++; }
- }
- }
- return -1;
- }
-
- int unpack(Buffer opb){
- int vendorlen=opb.read(32);
- if(vendorlen<0){
- //goto err_out;
- clear();
- return(-1);
- }
- vendor=new byte[vendorlen+1];
- opb.read(vendor,vendorlen);
- comments=opb.read(32);
- if(comments<0){
- //goto err_out;
- clear();
- return(-1);
- }
- user_comments=new byte[comments+1][];
- comment_lengths=new int[comments+1];
-
- for(int i=0;i<comments;i++){
- int len=opb.read(32);
- if(len<0){
- //goto err_out;
- clear();
- return(-1);
- }
- comment_lengths[i]=len;
- user_comments[i]=new byte[len+1];
- opb.read(user_comments[i], len);
- }
- if(opb.read(1)!=1){
- //goto err_out; // EOP check
- clear();
- return(-1);
-
- }
- return(0);
-// err_out:
-// comment_clear(vc);
-// return(-1);
- }
-
- int pack(Buffer opb){
- byte[] temp="Xiphophorus libVorbis I 20000508".getBytes();
-
- // preamble
- opb.write(0x03,8);
- opb.write(_vorbis);
-
- // vendor
- opb.write(temp.length,32);
- opb.write(temp);
-
- // comments
-
- opb.write(comments,32);
- if(comments!=0){
- for(int i=0;i<comments;i++){
- if(user_comments[i]!=null){
- opb.write(comment_lengths[i],32);
- opb.write(user_comments[i]);
- }
- else{
- opb.write(0,32);
- }
- }
- }
- opb.write(1,1);
- return(0);
- }
-
- public int header_out(Packet op){
- Buffer opb=new Buffer();
- opb.writeinit();
-
- if(pack(opb)!=0) return OV_EIMPL;
-
- op.packet_base = new byte[opb.bytes()];
- op.packet=0;
- op.bytes=opb.bytes();
- System.arraycopy(opb.buffer(), 0, op.packet_base, 0, op.bytes);
- op.b_o_s=0;
- op.e_o_s=0;
- op.granulepos=0;
- return 0;
- }
-
- void clear(){
- for(int i=0;i<comments;i++)
- user_comments[i]=null;
- user_comments=null;
- vendor=null;
- }
-
- public String getVendor(){
- return new String(vendor, 0, vendor.length-1);
- }
- public String getComment(int i){
- if(comments<=i)return null;
- return new String(user_comments[i], 0, user_comments[i].length-1);
- }
- public String toString(){
- String foo="Vendor: "+new String(vendor, 0, vendor.length-1);
- for(int i=0; i<comments; i++){
- foo=foo+"\nComment: "+new String(user_comments[i], 0, user_comments[i].length-1);
- }
- foo=foo+"\n";
- return foo;
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/DecodeExample.java b/songdbj/com/jcraft/jorbis/DecodeExample.java
deleted file mode 100644
index f8768969a2..0000000000
--- a/songdbj/com/jcraft/jorbis/DecodeExample.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-// Takes a vorbis bitstream from stdin and writes raw stereo PCM to
-// stdout. Decodes simple and chained OggVorbis files from beginning
-// to end. Vorbisfile.a is somewhat more complex than the code below.
-
-class DecodeExample{
- static int convsize=4096*2;
- static byte[] convbuffer=new byte[convsize]; // take 8k out of the data segment, not the stack
-
- public static void main(String[] arg){
- java.io.InputStream input=System.in;
- if(arg.length>0){
- try{
- input=new java.io.FileInputStream(arg[0]);
- }
- catch(Exception e){
- System.err.println(e);
- }
- }
-
- SyncState oy=new SyncState(); // sync and verify incoming physical bitstream
- StreamState os=new StreamState(); // take physical pages, weld into a logical stream of packets
- Page og=new Page(); // one Ogg bitstream page. Vorbis packets are inside
- Packet op=new Packet(); // one raw packet of data for decode
-
- Info vi=new Info(); // struct that stores all the static vorbis bitstream settings
- Comment vc=new Comment(); // struct that stores all the bitstream user comments
- DspState vd=new DspState(); // central working state for the packet->PCM decoder
- Block vb=new Block(vd); // local working space for packet->PCM decode
-
- byte[] buffer;
- int bytes=0;
-
- // Decode setup
-
- oy.init(); // Now we can read pages
-
- while(true){ // we repeat if the bitstream is chained
- int eos=0;
-
- // grab some data at the head of the stream. We want the first page
- // (which is guaranteed to be small and only contain the Vorbis
- // stream initial header) We need the first page to get the stream
- // serialno.
-
- // submit a 4k block to libvorbis' Ogg layer
- int index=oy.buffer(4096);
- buffer=oy.data;
- try{
- bytes=input.read(buffer, index, 4096);
- }
- catch(Exception e){
- System.err.println(e);
- System.exit(-1);
- }
- oy.wrote(bytes);
-
- // Get the first page.
- if(oy.pageout(og)!=1){
- // have we simply run out of data? If so, we're done.
- if(bytes<4096)break;
-
- // error case. Must not be Vorbis data
- System.err.println("Input does not appear to be an Ogg bitstream.");
- System.exit(1);
- }
-
- // Get the serial number and set up the rest of decode.
- // serialno first; use it to set up a logical stream
- os.init(og.serialno());
-
- // extract the initial header from the first page and verify that the
- // Ogg bitstream is in fact Vorbis data
-
- // I handle the initial header first instead of just having the code
- // read all three Vorbis headers at once because reading the initial
- // header is an easy way to identify a Vorbis bitstream and it's
- // useful to see that functionality seperated out.
-
- vi.init();
- vc.init();
- if(os.pagein(og)<0){
- // error; stream version mismatch perhaps
- System.err.println("Error reading first page of Ogg bitstream data.");
- System.exit(1);
- }
-
- if(os.packetout(op)!=1){
- // no page? must not be vorbis
- System.err.println("Error reading initial header packet.");
- System.exit(1);
- }
-
- if(vi.synthesis_headerin(vc,op)<0){
- // error case; not a vorbis header
- System.err.println("This Ogg bitstream does not contain Vorbis audio data.");
- System.exit(1);
- }
-
- // At this point, we're sure we're Vorbis. We've set up the logical
- // (Ogg) bitstream decoder. Get the comment and codebook headers and
- // set up the Vorbis decoder
-
- // The next two packets in order are the comment and codebook headers.
- // They're likely large and may span multiple pages. Thus we reead
- // and submit data until we get our two pacakets, watching that no
- // pages are missing. If a page is missing, error out; losing a
- // header page is the only place where missing data is fatal. */
-
- int i=0;
- while(i<2){
- while(i<2){
-
- int result=oy.pageout(og);
- if(result==0) break; // Need more data
- // Don't complain about missing or corrupt data yet. We'll
- // catch it at the packet output phase
-
- if(result==1){
- os.pagein(og); // we can ignore any errors here
- // as they'll also become apparent
- // at packetout
- while(i<2){
- result=os.packetout(op);
- if(result==0)break;
- if(result==-1){
- // Uh oh; data at some point was corrupted or missing!
- // We can't tolerate that in a header. Die.
- System.err.println("Corrupt secondary header. Exiting.");
- System.exit(1);
- }
- vi.synthesis_headerin(vc,op);
- i++;
- }
- }
- }
- // no harm in not checking before adding more
- index=oy.buffer(4096);
- buffer=oy.data;
- try{
- bytes=input.read(buffer, index, 4096);
- }
- catch(Exception e){
- System.err.println(e);
- System.exit(1);
- }
- if(bytes==0 && i<2){
- System.err.println("End of file before finding all Vorbis headers!");
- System.exit(1);
- }
- oy.wrote(bytes);
- }
-
- // Throw the comments plus a few lines about the bitstream we're
- // decoding
- {
- byte[][] ptr=vc.user_comments;
- for(int j=0; j<ptr.length;j++){
- if(ptr[j]==null) break;
- System.err.println(new String(ptr[j], 0, ptr[j].length-1));
- }
- System.err.println("\nBitstream is "+vi.channels+" channel, "+vi.rate+"Hz");
- System.err.println("Encoded by: "+new String(vc.vendor, 0, vc.vendor.length-1)+"\n");
- }
-
- convsize=4096/vi.channels;
-
- // OK, got and parsed all three headers. Initialize the Vorbis
- // packet->PCM decoder.
- vd.synthesis_init(vi); // central decode state
- vb.init(vd); // local state for most of the decode
- // so multiple block decodes can
- // proceed in parallel. We could init
- // multiple vorbis_block structures
- // for vd here
-
- float[][][] _pcm=new float[1][][];
- int[] _index=new int[vi.channels];
- // The rest is just a straight decode loop until end of stream
- while(eos==0){
- while(eos==0){
-
- int result=oy.pageout(og);
- if(result==0)break; // need more data
- if(result==-1){ // missing or corrupt data at this page position
- System.err.println("Corrupt or missing data in bitstream; continuing...");
- }
- else{
- os.pagein(og); // can safely ignore errors at
- // this point
- while(true){
- result=os.packetout(op);
-
- if(result==0)break; // need more data
- if(result==-1){ // missing or corrupt data at this page position
- // no reason to complain; already complained above
- }
- else{
- // we have a packet. Decode it
- int samples;
- if(vb.synthesis(op)==0){ // test for success!
- vd.synthesis_blockin(vb);
- }
-
- // **pcm is a multichannel float vector. In stereo, for
- // example, pcm[0] is left, and pcm[1] is right. samples is
- // the size of each channel. Convert the float values
- // (-1.<=range<=1.) to whatever PCM format and write it out
-
- while((samples=vd.synthesis_pcmout(_pcm, _index))>0){
- float[][] pcm=_pcm[0];
- boolean clipflag=false;
- int bout=(samples<convsize?samples:convsize);
-
- // convert floats to 16 bit signed ints (host order) and
- // interleave
- for(i=0;i<vi.channels;i++){
- int ptr=i*2;
- //int ptr=i;
- int mono=_index[i];
- for(int j=0;j<bout;j++){
- int val=(int)(pcm[i][mono+j]*32767.);
-// short val=(short)(pcm[i][mono+j]*32767.);
-// int val=(int)Math.round(pcm[i][mono+j]*32767.);
- // might as well guard against clipping
- if(val>32767){
- val=32767;
- clipflag=true;
- }
- if(val<-32768){
- val=-32768;
- clipflag=true;
- }
- if(val<0) val=val|0x8000;
- convbuffer[ptr]=(byte)(val);
- convbuffer[ptr+1]=(byte)(val>>>8);
- ptr+=2*(vi.channels);
- }
- }
-
- //if(clipflag)
- // System.err.println("Clipping in frame "+vd.sequence);
-
- System.out.write(convbuffer, 0, 2*vi.channels*bout);
-
- vd.synthesis_read(bout); // tell libvorbis how
- // many samples we
- // actually consumed
- }
- }
- }
- if(og.eos()!=0)eos=1;
- }
- }
- if(eos==0){
- index=oy.buffer(4096);
- buffer=oy.data;
- try{
- bytes=input.read(buffer,index,4096);
- }
- catch(Exception e){
- System.err.println(e);
- System.exit(1);
- }
- oy.wrote(bytes);
- if(bytes==0)eos=1;
- }
- }
-
- // clean up this logical bitstream; before exit we see if we're
- // followed by another [chained]
-
- os.clear();
-
- // ogg_page and ogg_packet structs always point to storage in
- // libvorbis. They're never freed or manipulated directly
-
- vb.clear();
- vd.clear();
- vi.clear(); // must be called last
- }
-
- // OK, clean up the framer
- oy.clear();
- System.err.println("Done.");
- }
-}
-
diff --git a/songdbj/com/jcraft/jorbis/Drft.java b/songdbj/com/jcraft/jorbis/Drft.java
deleted file mode 100644
index c7ff2032e7..0000000000
--- a/songdbj/com/jcraft/jorbis/Drft.java
+++ /dev/null
@@ -1,1317 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class Drft{
- int n;
- float[] trigcache;
- int[] splitcache;
-
- void backward(float[] data){
- //System.err.println("Drft.backward");
- if(n==1)return;
- drftb1(n,data,trigcache,trigcache,n,splitcache);
- }
-
- void init(int n){
- //System.err.println("Drft.init");
- this.n=n;
- trigcache=new float[3*n];
- splitcache=new int[32];
- fdrffti(n, trigcache, splitcache);
- }
-
- void clear(){
- //System.err.println("Drft.clear");
- if(trigcache!=null)trigcache=null;
- if(splitcache!=null)splitcache=null;
-// memset(l,0,sizeof(drft_lookup));
- }
-
- static int[] ntryh = { 4,2,3,5 };
- static float tpi = 6.28318530717958647692528676655900577f;
- static float hsqt2 = .70710678118654752440084436210485f;
- static float taui = .86602540378443864676372317075293618f;
- static float taur = -.5f;
- static float sqrt2 = 1.4142135623730950488016887242097f;
-
- static void drfti1(int n, float[] wa, int index, int[] ifac){
- float arg,argh,argld,fi;
- int ntry=0,i,j=-1;
- int k1, l1, l2, ib;
- int ld, ii, ip, is, nq, nr;
- int ido, ipm, nfm1;
- int nl=n;
- int nf=0;
-
- int state=101;
-
- loop: while(true){
- switch(state){
- case 101:
- j++;
- if (j < 4)
- ntry=ntryh[j];
- else
- ntry+=2;
- case 104:
- nq=nl/ntry;
- nr=nl-ntry*nq;
- if(nr!=0){
- state=101;
- break;
- }
- nf++;
- ifac[nf+1]=ntry;
- nl=nq;
- if(ntry!=2){
- state=107;
- break;
- }
- if(nf==1){
- state=107;
- break;
- }
-
- for(i=1;i<nf;i++){
- ib=nf-i+1;
- ifac[ib+1]=ifac[ib];
- }
- ifac[2] = 2;
- case 107:
- if(nl!=1){
- state=104;
- break;
- }
- ifac[0]=n;
- ifac[1]=nf;
- argh=tpi/n;
- is=0;
- nfm1=nf-1;
- l1=1;
-
- if(nfm1==0)return;
-
- for (k1=0;k1<nfm1;k1++){
- ip=ifac[k1+2];
- ld=0;
- l2=l1*ip;
- ido=n/l2;
- ipm=ip-1;
-
- for (j=0;j<ipm;j++){
- ld+=l1;
- i=is;
- argld=(float)ld*argh;
- fi=0.f;
- for (ii=2;ii<ido;ii+=2){
- fi+=1.f;
- arg=fi*argld;
- wa[index+i++]=(float)Math.cos(arg);
- wa[index+i++]=(float)Math.sin(arg);
- }
- is+=ido;
- }
- l1=l2;
- }
- break loop;
- }
- }
- }
-
- static void fdrffti(int n, float[] wsave, int[] ifac){
-//System.err.println("fdrffti: n="+n);
- if(n == 1) return;
- drfti1(n, wsave, n, ifac);
- }
-
- static void dradf2(int ido,int l1,float[] cc, float[] ch, float[] wa1, int index){
- int i,k;
- float ti2,tr2;
- int t0,t1,t2,t3,t4,t5,t6;
-
- t1=0;
- t0=(t2=l1*ido);
- t3=ido<<1;
- for(k=0;k<l1;k++){
- ch[t1<<1]=cc[t1]+cc[t2];
- ch[(t1<<1)+t3-1]=cc[t1]-cc[t2];
- t1+=ido;
- t2+=ido;
- }
-
- if(ido<2)return;
-
- if(ido!=2){
- t1=0;
- t2=t0;
- for(k=0;k<l1;k++){
- t3=t2;
- t4=(t1<<1)+(ido<<1);
- t5=t1;
- t6=t1+t1;
- for(i=2;i<ido;i+=2){
- t3+=2;
- t4-=2;
- t5+=2;
- t6+=2;
- tr2=wa1[index+i-2]*cc[t3-1]+wa1[index+i-1]*cc[t3];
- ti2=wa1[index+i-2]*cc[t3]-wa1[index+i-1]*cc[t3-1];
- ch[t6]=cc[t5]+ti2;
- ch[t4]=ti2-cc[t5];
- ch[t6-1]=cc[t5-1]+tr2;
- ch[t4-1]=cc[t5-1]-tr2;
- }
- t1+=ido;
- t2+=ido;
- }
- if(ido%2==1)return;
- }
-
- t3=(t2=(t1=ido)-1);
- t2+=t0;
- for(k=0;k<l1;k++){
- ch[t1]=-cc[t2];
- ch[t1-1]=cc[t3];
- t1+=ido<<1;
- t2+=ido;
- t3+=ido;
- }
- }
-
- static void dradf4(int ido,int l1,float[] cc, float[] ch,
- float[] wa1, int index1,
- float[] wa2, int index2,
- float[] wa3, int index3){
- int i,k,t0,t1,t2,t3,t4,t5,t6;
- float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
- t0=l1*ido;
-
- t1=t0;
- t4=t1<<1;
- t2=t1+(t1<<1);
- t3=0;
-
- for(k=0;k<l1;k++){
- tr1=cc[t1]+cc[t2];
- tr2=cc[t3]+cc[t4];
-
- ch[t5=t3<<2]=tr1+tr2;
- ch[(ido<<2)+t5-1]=tr2-tr1;
- ch[(t5+=(ido<<1))-1]=cc[t3]-cc[t4];
- ch[t5]=cc[t2]-cc[t1];
-
- t1+=ido;
- t2+=ido;
- t3+=ido;
- t4+=ido;
- }
- if(ido<2)return;
-
- if(ido!=2){
- t1=0;
- for(k=0;k<l1;k++){
- t2=t1;
- t4=t1<<2;
- t5=(t6=ido<<1)+t4;
- for(i=2;i<ido;i+=2){
- t3=(t2+=2);
- t4+=2;
- t5-=2;
-
- t3+=t0;
- cr2=wa1[index1+i-2]*cc[t3-1]+wa1[index1+i-1]*cc[t3];
- ci2=wa1[index1+i-2]*cc[t3]-wa1[index1+i-1]*cc[t3-1];
- t3+=t0;
- cr3=wa2[index2+i-2]*cc[t3-1]+wa2[index2+i-1]*cc[t3];
- ci3=wa2[index2+i-2]*cc[t3]-wa2[index2+i-1]*cc[t3-1];
- t3+=t0;
- cr4=wa3[index3+i-2]*cc[t3-1]+wa3[index3+i-1]*cc[t3];
- ci4=wa3[index3+i-2]*cc[t3]-wa3[index3+i-1]*cc[t3-1];
-
- tr1=cr2+cr4;
- tr4=cr4-cr2;
- ti1=ci2+ci4;
- ti4=ci2-ci4;
-
- ti2=cc[t2]+ci3;
- ti3=cc[t2]-ci3;
- tr2=cc[t2-1]+cr3;
- tr3=cc[t2-1]-cr3;
-
- ch[t4-1]=tr1+tr2;
- ch[t4]=ti1+ti2;
-
- ch[t5-1]=tr3-ti4;
- ch[t5]=tr4-ti3;
-
- ch[t4+t6-1]=ti4+tr3;
- ch[t4+t6]=tr4+ti3;
-
- ch[t5+t6-1]=tr2-tr1;
- ch[t5+t6]=ti1-ti2;
- }
- t1+=ido;
- }
- if((ido&1)!=0)return;
- }
-
- t2=(t1=t0+ido-1)+(t0<<1);
- t3=ido<<2;
- t4=ido;
- t5=ido<<1;
- t6=ido;
-
- for(k=0;k<l1;k++){
- ti1=-hsqt2*(cc[t1]+cc[t2]);
- tr1=hsqt2*(cc[t1]-cc[t2]);
-
- ch[t4-1]=tr1+cc[t6-1];
- ch[t4+t5-1]=cc[t6-1]-tr1;
-
- ch[t4]=ti1-cc[t1+t0];
- ch[t4+t5]=ti1+cc[t1+t0];
-
- t1+=ido;
- t2+=ido;
- t4+=t3;
- t6+=ido;
- }
- }
-
- static void dradfg(int ido,int ip,int l1,int idl1,float[] cc,float[] c1,
- float[] c2, float[] ch, float[] ch2, float[] wa, int index){
- int idij,ipph,i,j,k,l,ic,ik,is;
- int t0,t1,t2=0,t3,t4,t5,t6,t7,t8,t9,t10;
- float dc2,ai1,ai2,ar1,ar2,ds2;
- int nbd;
- float dcp=0,arg,dsp=0,ar1h,ar2h;
- int idp2,ipp2;
-
- arg=tpi/(float)ip;
- dcp=(float)Math.cos(arg);
- dsp=(float)Math.sin(arg);
- ipph=(ip+1)>>1;
- ipp2=ip;
- idp2=ido;
- nbd=(ido-1)>>1;
- t0=l1*ido;
- t10=ip*ido;
-
- int state=100;
- loop: while(true){
- switch(state){
- case 101:
- if(ido==1){
- state=119;
- break;
- }
- for(ik=0;ik<idl1;ik++)ch2[ik]=c2[ik];
-
- t1=0;
- for(j=1;j<ip;j++){
- t1+=t0;
- t2=t1;
- for(k=0;k<l1;k++){
- ch[t2]=c1[t2];
- t2+=ido;
- }
- }
-
- is=-ido;
- t1=0;
- if(nbd>l1){
- for(j=1;j<ip;j++){
- t1+=t0;
- is+=ido;
- t2= -ido+t1;
- for(k=0;k<l1;k++){
- idij=is-1;
- t2+=ido;
- t3=t2;
- for(i=2;i<ido;i+=2){
- idij+=2;
- t3+=2;
- ch[t3-1]=wa[index+idij-1]*c1[t3-1]+wa[index+idij]*c1[t3];
- ch[t3]=wa[index+idij-1]*c1[t3]-wa[index+idij]*c1[t3-1];
- }
- }
- }
- }
- else{
-
- for(j=1;j<ip;j++){
- is+=ido;
- idij=is-1;
- t1+=t0;
- t2=t1;
- for(i=2;i<ido;i+=2){
- idij+=2;
- t2+=2;
- t3=t2;
- for(k=0;k<l1;k++){
- ch[t3-1]=wa[index+idij-1]*c1[t3-1]+wa[index+idij]*c1[t3];
- ch[t3]=wa[index+idij-1]*c1[t3]-wa[index+idij]*c1[t3-1];
- t3+=ido;
- }
- }
- }
- }
-
- t1=0;
- t2=ipp2*t0;
- if(nbd<l1){
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
- for(i=2;i<ido;i+=2){
- t3+=2;
- t4+=2;
- t5=t3-ido;
- t6=t4-ido;
- for(k=0;k<l1;k++){
- t5+=ido;
- t6+=ido;
- c1[t5-1]=ch[t5-1]+ch[t6-1];
- c1[t6-1]=ch[t5]-ch[t6];
- c1[t5]=ch[t5]+ch[t6];
- c1[t6]=ch[t6-1]-ch[t5-1];
- }
- }
- }
- }
- else{
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
- for(k=0;k<l1;k++){
- t5=t3;
- t6=t4;
- for(i=2;i<ido;i+=2){
- t5+=2;
- t6+=2;
- c1[t5-1]=ch[t5-1]+ch[t6-1];
- c1[t6-1]=ch[t5]-ch[t6];
- c1[t5]=ch[t5]+ch[t6];
- c1[t6]=ch[t6-1]-ch[t5-1];
- }
- t3+=ido;
- t4+=ido;
- }
- }
- }
- case 119:
- for(ik=0;ik<idl1;ik++)c2[ik]=ch2[ik];
-
- t1=0;
- t2=ipp2*idl1;
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1-ido;
- t4=t2-ido;
- for(k=0;k<l1;k++){
- t3+=ido;
- t4+=ido;
- c1[t3]=ch[t3]+ch[t4];
- c1[t4]=ch[t4]-ch[t3];
- }
- }
-
- ar1=1.f;
- ai1=0.f;
- t1=0;
- t2=ipp2*idl1;
- t3=(ip-1)*idl1;
- for(l=1;l<ipph;l++){
- t1+=idl1;
- t2-=idl1;
- ar1h=dcp*ar1-dsp*ai1;
- ai1=dcp*ai1+dsp*ar1;
- ar1=ar1h;
- t4=t1;
- t5=t2;
- t6=t3;
- t7=idl1;
-
- for(ik=0;ik<idl1;ik++){
- ch2[t4++]=c2[ik]+ar1*c2[t7++];
- ch2[t5++]=ai1*c2[t6++];
- }
-
- dc2=ar1;
- ds2=ai1;
- ar2=ar1;
- ai2=ai1;
-
- t4=idl1;
- t5=(ipp2-1)*idl1;
- for(j=2;j<ipph;j++){
- t4+=idl1;
- t5-=idl1;
-
- ar2h=dc2*ar2-ds2*ai2;
- ai2=dc2*ai2+ds2*ar2;
- ar2=ar2h;
-
- t6=t1;
- t7=t2;
- t8=t4;
- t9=t5;
- for(ik=0;ik<idl1;ik++){
- ch2[t6++]+=ar2*c2[t8++];
- ch2[t7++]+=ai2*c2[t9++];
- }
- }
- }
- t1=0;
- for(j=1;j<ipph;j++){
- t1+=idl1;
- t2=t1;
- for(ik=0;ik<idl1;ik++)ch2[ik]+=c2[t2++];
- }
-
- if(ido<l1){
- state=132;
- break;
- }
-
- t1=0;
- t2=0;
- for(k=0;k<l1;k++){
- t3=t1;
- t4=t2;
- for(i=0;i<ido;i++)cc[t4++]=ch[t3++];
- t1+=ido;
- t2+=t10;
- }
- state=135;
- break;
-
- case 132:
- for(i=0;i<ido;i++){
- t1=i;
- t2=i;
- for(k=0;k<l1;k++){
- cc[t2]=ch[t1];
- t1+=ido;
- t2+=t10;
- }
- }
- case 135:
- t1=0;
- t2=ido<<1;
- t3=0;
- t4=ipp2*t0;
- for(j=1;j<ipph;j++){
- t1+=t2;
- t3+=t0;
- t4-=t0;
-
- t5=t1;
- t6=t3;
- t7=t4;
-
- for(k=0;k<l1;k++){
- cc[t5-1]=ch[t6];
- cc[t5]=ch[t7];
- t5+=t10;
- t6+=ido;
- t7+=ido;
- }
- }
-
- if(ido==1)return;
- if(nbd<l1){
- state=141;
- break;
- }
-
- t1=-ido;
- t3=0;
- t4=0;
- t5=ipp2*t0;
- for(j=1;j<ipph;j++){
- t1+=t2;
- t3+=t2;
- t4+=t0;
- t5-=t0;
- t6=t1;
- t7=t3;
- t8=t4;
- t9=t5;
- for(k=0;k<l1;k++){
- for(i=2;i<ido;i+=2){
- ic=idp2-i;
- cc[i+t7-1]=ch[i+t8-1]+ch[i+t9-1];
- cc[ic+t6-1]=ch[i+t8-1]-ch[i+t9-1];
- cc[i+t7]=ch[i+t8]+ch[i+t9];
- cc[ic+t6]=ch[i+t9]-ch[i+t8];
- }
- t6+=t10;
- t7+=t10;
- t8+=ido;
- t9+=ido;
- }
- }
- return;
- case 141:
- t1=-ido;
- t3=0;
- t4=0;
- t5=ipp2*t0;
- for(j=1;j<ipph;j++){
- t1+=t2;
- t3+=t2;
- t4+=t0;
- t5-=t0;
- for(i=2;i<ido;i+=2){
- t6=idp2+t1-i;
- t7=i+t3;
- t8=i+t4;
- t9=i+t5;
- for(k=0;k<l1;k++){
- cc[t7-1]=ch[t8-1]+ch[t9-1];
- cc[t6-1]=ch[t8-1]-ch[t9-1];
- cc[t7]=ch[t8]+ch[t9];
- cc[t6]=ch[t9]-ch[t8];
- t6+=t10;
- t7+=t10;
- t8+=ido;
- t9+=ido;
- }
- }
- }
- break loop;
- }
- }
- }
-
- static void drftf1(int n,float[] c, float[] ch, float[] wa, int[] ifac){
- int i,k1,l1,l2;
- int na,kh,nf;
- int ip,iw,ido,idl1,ix2,ix3;
-
- nf=ifac[1];
- na=1;
- l2=n;
- iw=n;
-
- for(k1=0;k1<nf;k1++){
- kh=nf-k1;
- ip=ifac[kh+1];
- l1=l2/ip;
- ido=n/l2;
- idl1=ido*l1;
- iw-=(ip-1)*ido;
- na=1-na;
-
- int state=100;
- loop: while(true){
- switch(state){
- case 100:
- if(ip!=4){
- state=102;
- break;
- }
-
- ix2=iw+ido;
- ix3=ix2+ido;
- if(na!=0)
- dradf4(ido,l1,ch,c,wa,iw-1,wa,ix2-1,wa,ix3-1);
- else
- dradf4(ido,l1,c,ch,wa,iw-1,wa,ix2-1,wa,ix3-1);
- state=110;
- break;
- case 102:
- if(ip!=2){
- state=104;
- break;
- }
- if(na!=0){
- state=103;
- break;
- }
- dradf2(ido,l1,c,ch,wa, iw-1);
- state=110;
- break;
- case 103:
- dradf2(ido,l1,ch,c,wa, iw-1);
- case 104:
- if(ido==1)na=1-na;
- if(na!=0){
- state=109;
- break;
- }
- dradfg(ido,ip,l1,idl1,c,c,c,ch,ch,wa,iw-1);
- na=1;
- state=110;
- break;
- case 109:
- dradfg(ido,ip,l1,idl1,ch,ch,ch,c,c,wa,iw-1);
- na=0;
- case 110:
- l2=l1;
- break loop;
- }
- }
- }
- if(na==1)return;
- for(i=0;i<n;i++)c[i]=ch[i];
- }
-
- static void dradb2(int ido,int l1,float[] cc,float[] ch,float[] wa1, int index){
- int i,k,t0,t1,t2,t3,t4,t5,t6;
- float ti2,tr2;
-
- t0=l1*ido;
-
- t1=0;
- t2=0;
- t3=(ido<<1)-1;
- for(k=0;k<l1;k++){
- ch[t1]=cc[t2]+cc[t3+t2];
- ch[t1+t0]=cc[t2]-cc[t3+t2];
- t2=(t1+=ido)<<1;
- }
-
- if(ido<2)return;
- if(ido!=2){
- t1=0;
- t2=0;
- for(k=0;k<l1;k++){
- t3=t1;
- t5=(t4=t2)+(ido<<1);
- t6=t0+t1;
- for(i=2;i<ido;i+=2){
- t3+=2;
- t4+=2;
- t5-=2;
- t6+=2;
- ch[t3-1]=cc[t4-1]+cc[t5-1];
- tr2=cc[t4-1]-cc[t5-1];
- ch[t3]=cc[t4]-cc[t5];
- ti2=cc[t4]+cc[t5];
- ch[t6-1]=wa1[index+i-2]*tr2-wa1[index+i-1]*ti2;
- ch[t6]=wa1[index+i-2]*ti2+wa1[index+i-1]*tr2;
- }
- t2=(t1+=ido)<<1;
- }
- if((ido%2)==1)return;
- }
-
- t1=ido-1;
- t2=ido-1;
- for(k=0;k<l1;k++){
- ch[t1]=cc[t2]+cc[t2];
- ch[t1+t0]=-(cc[t2+1]+cc[t2+1]);
- t1+=ido;
- t2+=ido<<1;
- }
- }
-
- static void dradb3(int ido,int l1,float[] cc,float[] ch,
- float[] wa1, int index1,
- float[] wa2, int index2){
- int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
- float ci2,ci3,di2,di3,cr2,cr3,dr2,dr3,ti2,tr2;
- t0=l1*ido;
-
- t1=0;
- t2=t0<<1;
- t3=ido<<1;
- t4=ido+(ido<<1);
- t5=0;
- for(k=0;k<l1;k++){
- tr2=cc[t3-1]+cc[t3-1];
- cr2=cc[t5]+(taur*tr2);
- ch[t1]=cc[t5]+tr2;
- ci3=taui*(cc[t3]+cc[t3]);
- ch[t1+t0]=cr2-ci3;
- ch[t1+t2]=cr2+ci3;
- t1+=ido;
- t3+=t4;
- t5+=t4;
- }
-
- if(ido==1)return;
-
- t1=0;
- t3=ido<<1;
- for(k=0;k<l1;k++){
- t7=t1+(t1<<1);
- t6=(t5=t7+t3);
- t8=t1;
- t10=(t9=t1+t0)+t0;
-
- for(i=2;i<ido;i+=2){
- t5+=2;
- t6-=2;
- t7+=2;
- t8+=2;
- t9+=2;
- t10+=2;
- tr2=cc[t5-1]+cc[t6-1];
- cr2=cc[t7-1]+(taur*tr2);
- ch[t8-1]=cc[t7-1]+tr2;
- ti2=cc[t5]-cc[t6];
- ci2=cc[t7]+(taur*ti2);
- ch[t8]=cc[t7]+ti2;
- cr3=taui*(cc[t5-1]-cc[t6-1]);
- ci3=taui*(cc[t5]+cc[t6]);
- dr2=cr2-ci3;
- dr3=cr2+ci3;
- di2=ci2+cr3;
- di3=ci2-cr3;
- ch[t9-1]=wa1[index1+i-2]*dr2-wa1[index1+i-1]*di2;
- ch[t9]=wa1[index1+i-2]*di2+wa1[index1+i-1]*dr2;
- ch[t10-1]=wa2[index2+i-2]*dr3-wa2[index2+i-1]*di3;
- ch[t10]=wa2[index2+i-2]*di3+wa2[index2+i-1]*dr3;
- }
- t1+=ido;
- }
- }
-
- static void dradb4(int ido,int l1,float[] cc,float[] ch,
- float[] wa1, int index1,
- float[] wa2, int index2,
- float[] wa3, int index3){
- int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8;
- float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
- t0=l1*ido;
-
- t1=0;
- t2=ido<<2;
- t3=0;
- t6=ido<<1;
- for(k=0;k<l1;k++){
- t4=t3+t6;
- t5=t1;
- tr3=cc[t4-1]+cc[t4-1];
- tr4=cc[t4]+cc[t4];
- tr1=cc[t3]-cc[(t4+=t6)-1];
- tr2=cc[t3]+cc[t4-1];
- ch[t5]=tr2+tr3;
- ch[t5+=t0]=tr1-tr4;
- ch[t5+=t0]=tr2-tr3;
- ch[t5+=t0]=tr1+tr4;
- t1+=ido;
- t3+=t2;
- }
-
- if(ido<2)return;
- if(ido!=2){
- t1=0;
- for(k=0;k<l1;k++){
- t5=(t4=(t3=(t2=t1<<2)+t6))+t6;
- t7=t1;
- for(i=2;i<ido;i+=2){
- t2+=2;
- t3+=2;
- t4-=2;
- t5-=2;
- t7+=2;
- ti1=cc[t2]+cc[t5];
- ti2=cc[t2]-cc[t5];
- ti3=cc[t3]-cc[t4];
- tr4=cc[t3]+cc[t4];
- tr1=cc[t2-1]-cc[t5-1];
- tr2=cc[t2-1]+cc[t5-1];
- ti4=cc[t3-1]-cc[t4-1];
- tr3=cc[t3-1]+cc[t4-1];
- ch[t7-1]=tr2+tr3;
- cr3=tr2-tr3;
- ch[t7]=ti2+ti3;
- ci3=ti2-ti3;
- cr2=tr1-tr4;
- cr4=tr1+tr4;
- ci2=ti1+ti4;
- ci4=ti1-ti4;
-
- ch[(t8=t7+t0)-1]=wa1[index1+i-2]*cr2-wa1[index1+i-1]*ci2;
- ch[t8]=wa1[index1+i-2]*ci2+wa1[index1+i-1]*cr2;
- ch[(t8+=t0)-1]=wa2[index2+i-2]*cr3-wa2[index2+i-1]*ci3;
- ch[t8]=wa2[index2+i-2]*ci3+wa2[index2+i-1]*cr3;
- ch[(t8+=t0)-1]=wa3[index3+i-2]*cr4-wa3[index3+i-1]*ci4;
- ch[t8]=wa3[index3+i-2]*ci4+wa3[index3+i-1]*cr4;
- }
- t1+=ido;
- }
- if(ido%2 == 1)return;
- }
-
- t1=ido;
- t2=ido<<2;
- t3=ido-1;
- t4=ido+(ido<<1);
- for(k=0;k<l1;k++){
- t5=t3;
- ti1=cc[t1]+cc[t4];
- ti2=cc[t4]-cc[t1];
- tr1=cc[t1-1]-cc[t4-1];
- tr2=cc[t1-1]+cc[t4-1];
- ch[t5]=tr2+tr2;
- ch[t5+=t0]=sqrt2*(tr1-ti1);
- ch[t5+=t0]=ti2+ti2;
- ch[t5+=t0]=-sqrt2*(tr1+ti1);
-
- t3+=ido;
- t1+=t2;
- t4+=t2;
- }
- }
-
- static void dradbg(int ido,int ip,int l1,int idl1,float[] cc,float[] c1,
- float[] c2,float[] ch,float[] ch2,float[] wa, int index ){
-
- int idij,ipph=0,i,j,k,l,ik,is,t0=0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10=0,
- t11,t12;
- float dc2,ai1,ai2,ar1,ar2,ds2;
- int nbd=0;
- float dcp=0,arg,dsp=0,ar1h,ar2h;
- int ipp2=0;
-
- int state=100;
-
- loop: while(true){
- switch(state){
- case 100:
- t10=ip*ido;
- t0=l1*ido;
- arg=tpi/(float)ip;
- dcp=(float)Math.cos(arg);
- dsp=(float)Math.sin(arg);
- nbd=(ido-1)>>>1;
- ipp2=ip;
- ipph=(ip+1)>>>1;
- if(ido<l1){
- state=103;
- break;
- }
- t1=0;
- t2=0;
- for(k=0;k<l1;k++){
- t3=t1;
- t4=t2;
- for(i=0;i<ido;i++){
- ch[t3]=cc[t4];
- t3++;
- t4++;
- }
- t1+=ido;
- t2+=t10;
- }
- state=106;
- break;
- case 103:
- t1=0;
- for(i=0;i<ido;i++){
- t2=t1;
- t3=t1;
- for(k=0;k<l1;k++){
- ch[t2]=cc[t3];
- t2+=ido;
- t3+=t10;
- }
- t1++;
- }
- case 106:
- t1=0;
- t2=ipp2*t0;
- t7=(t5=ido<<1);
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
- t6=t5;
- for(k=0;k<l1;k++){
- ch[t3]=cc[t6-1]+cc[t6-1];
- ch[t4]=cc[t6]+cc[t6];
- t3+=ido;
- t4+=ido;
- t6+=t10;
- }
- t5+=t7;
- }
- if (ido == 1){
- state=116;
- break;
- }
- if(nbd<l1){
- state=112;
- break;
- }
-
- t1=0;
- t2=ipp2*t0;
- t7=0;
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
-
- t7+=(ido<<1);
- t8=t7;
- for(k=0;k<l1;k++){
- t5=t3;
- t6=t4;
- t9=t8;
- t11=t8;
- for(i=2;i<ido;i+=2){
- t5+=2;
- t6+=2;
- t9+=2;
- t11-=2;
- ch[t5-1]=cc[t9-1]+cc[t11-1];
- ch[t6-1]=cc[t9-1]-cc[t11-1];
- ch[t5]=cc[t9]-cc[t11];
- ch[t6]=cc[t9]+cc[t11];
- }
- t3+=ido;
- t4+=ido;
- t8+=t10;
- }
- }
- state=116;
- break;
- case 112:
- t1=0;
- t2=ipp2*t0;
- t7=0;
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
- t7+=(ido<<1);
- t8=t7;
- t9=t7;
- for(i=2;i<ido;i+=2){
- t3+=2;
- t4+=2;
- t8+=2;
- t9-=2;
- t5=t3;
- t6=t4;
- t11=t8;
- t12=t9;
- for(k=0;k<l1;k++){
- ch[t5-1]=cc[t11-1]+cc[t12-1];
- ch[t6-1]=cc[t11-1]-cc[t12-1];
- ch[t5]=cc[t11]-cc[t12];
- ch[t6]=cc[t11]+cc[t12];
- t5+=ido;
- t6+=ido;
- t11+=t10;
- t12+=t10;
- }
- }
- }
- case 116:
- ar1=1.f;
- ai1=0.f;
- t1=0;
- t9=(t2=ipp2*idl1);
- t3=(ip-1)*idl1;
- for(l=1;l<ipph;l++){
- t1+=idl1;
- t2-=idl1;
-
- ar1h=dcp*ar1-dsp*ai1;
- ai1=dcp*ai1+dsp*ar1;
- ar1=ar1h;
- t4=t1;
- t5=t2;
- t6=0;
- t7=idl1;
- t8=t3;
- for(ik=0;ik<idl1;ik++){
- c2[t4++]=ch2[t6++]+ar1*ch2[t7++];
- c2[t5++]=ai1*ch2[t8++];
- }
- dc2=ar1;
- ds2=ai1;
- ar2=ar1;
- ai2=ai1;
-
- t6=idl1;
- t7=t9-idl1;
- for(j=2;j<ipph;j++){
- t6+=idl1;
- t7-=idl1;
- ar2h=dc2*ar2-ds2*ai2;
- ai2=dc2*ai2+ds2*ar2;
- ar2=ar2h;
- t4=t1;
- t5=t2;
- t11=t6;
- t12=t7;
- for(ik=0;ik<idl1;ik++){
- c2[t4++]+=ar2*ch2[t11++];
- c2[t5++]+=ai2*ch2[t12++];
- }
- }
- }
-
- t1=0;
- for(j=1;j<ipph;j++){
- t1+=idl1;
- t2=t1;
- for(ik=0;ik<idl1;ik++)ch2[ik]+=ch2[t2++];
- }
-
- t1=0;
- t2=ipp2*t0;
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
- for(k=0;k<l1;k++){
- ch[t3]=c1[t3]-c1[t4];
- ch[t4]=c1[t3]+c1[t4];
- t3+=ido;
- t4+=ido;
- }
- }
-
- if(ido==1){
- state=132;
- break;
- }
- if(nbd<l1){
- state=128;
- break;
- }
-
- t1=0;
- t2=ipp2*t0;
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
- for(k=0;k<l1;k++){
- t5=t3;
- t6=t4;
- for(i=2;i<ido;i+=2){
- t5+=2;
- t6+=2;
- ch[t5-1]=c1[t5-1]-c1[t6];
- ch[t6-1]=c1[t5-1]+c1[t6];
- ch[t5]=c1[t5]+c1[t6-1];
- ch[t6]=c1[t5]-c1[t6-1];
- }
- t3+=ido;
- t4+=ido;
- }
- }
- state=132;
- break;
- case 128:
- t1=0;
- t2=ipp2*t0;
- for(j=1;j<ipph;j++){
- t1+=t0;
- t2-=t0;
- t3=t1;
- t4=t2;
- for(i=2;i<ido;i+=2){
- t3+=2;
- t4+=2;
- t5=t3;
- t6=t4;
- for(k=0;k<l1;k++){
- ch[t5-1]=c1[t5-1]-c1[t6];
- ch[t6-1]=c1[t5-1]+c1[t6];
- ch[t5]=c1[t5]+c1[t6-1];
- ch[t6]=c1[t5]-c1[t6-1];
- t5+=ido;
- t6+=ido;
- }
- }
- }
- case 132:
- if(ido==1)return;
-
- for(ik=0;ik<idl1;ik++)c2[ik]=ch2[ik];
-
- t1=0;
- for(j=1;j<ip;j++){
- t2=(t1+=t0);
- for(k=0;k<l1;k++){
- c1[t2]=ch[t2];
- t2+=ido;
- }
- }
-
- if(nbd>l1){
- state=139;
- break;
- }
-
- is= -ido-1;
- t1=0;
- for(j=1;j<ip;j++){
- is+=ido;
- t1+=t0;
- idij=is;
- t2=t1;
- for(i=2;i<ido;i+=2){
- t2+=2;
- idij+=2;
- t3=t2;
- for(k=0;k<l1;k++){
- c1[t3-1]=wa[index+idij-1]*ch[t3-1]-wa[index+idij]*ch[t3];
- c1[t3]=wa[index+idij-1]*ch[t3]+wa[index+idij]*ch[t3-1];
- t3+=ido;
- }
- }
- }
- return;
-
- case 139:
- is= -ido-1;
- t1=0;
- for(j=1;j<ip;j++){
- is+=ido;
- t1+=t0;
- t2=t1;
- for(k=0;k<l1;k++){
- idij=is;
- t3=t2;
- for(i=2;i<ido;i+=2){
- idij+=2;
- t3+=2;
- c1[t3-1]=wa[index+idij-1]*ch[t3-1]-wa[index+idij]*ch[t3];
- c1[t3]=wa[index+idij-1]*ch[t3]+wa[index+idij]*ch[t3-1];
- }
- t2+=ido;
- }
- }
- break loop;
- }
- }
- }
-
- static void drftb1(int n, float[] c, float[] ch, float[] wa, int index, int[] ifac){
- int i,k1,l1,l2=0;
- int na;
- int nf,ip=0,iw,ix2,ix3,ido=0,idl1=0;
-
- nf=ifac[1];
- na=0;
- l1=1;
- iw=1;
-
- for(k1=0;k1<nf;k1++){
- int state=100;
- loop: while(true){
- switch(state){
- case 100:
- ip=ifac[k1 + 2];
- l2=ip*l1;
- ido=n/l2;
- idl1=ido*l1;
- if(ip!=4){
- state=103;
- break;
- }
- ix2=iw+ido;
- ix3=ix2+ido;
-
- if(na!=0)
- dradb4(ido,l1,ch,c,wa,index+iw-1,wa,index+ix2-1,wa,index+ix3-1);
- else
- dradb4(ido,l1,c,ch,wa,index+iw-1,wa,index+ix2-1,wa,index+ix3-1);
- na=1-na;
- state=115;
- break;
- case 103:
- if(ip!=2){
- state=106;
- break;
- }
-
- if(na!=0)
- dradb2(ido,l1,ch,c,wa,index+iw-1);
- else
- dradb2(ido,l1,c,ch,wa,index+iw-1);
- na=1-na;
- state=115;
- break;
-
- case 106:
- if(ip!=3){
- state=109;
- break;
- }
-
- ix2=iw+ido;
- if(na!=0)
- dradb3(ido,l1,ch,c,wa,index+iw-1,wa,index+ix2-1);
- else
- dradb3(ido,l1,c,ch,wa,index+iw-1,wa,index+ix2-1);
- na=1-na;
- state=115;
- break;
- case 109:
- // The radix five case can be translated later.....
- // if(ip!=5)goto L112;
- //
- //ix2=iw+ido;
- //ix3=ix2+ido;
- //ix4=ix3+ido;
- //if(na!=0)
- // dradb5(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1,wa+ix4-1);
- //else
- // dradb5(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1,wa+ix4-1);
- //na=1-na;
- //state=115;
- //break;
- if(na!=0)
- dradbg(ido,ip,l1,idl1,ch,ch,ch,c,c,wa,index+iw-1);
- else
- dradbg(ido,ip,l1,idl1,c,c,c,ch,ch,wa,index+iw-1);
- if(ido==1)na=1-na;
-
- case 115:
- l1=l2;
- iw+=(ip-1)*ido;
- break loop;
- }
- }
- }
- if(na==0)return;
- for(i=0;i<n;i++)c[i]=ch[i];
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/DspState.java b/songdbj/com/jcraft/jorbis/DspState.java
deleted file mode 100644
index 5676f640c1..0000000000
--- a/songdbj/com/jcraft/jorbis/DspState.java
+++ /dev/null
@@ -1,459 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-public class DspState{
- static final float M_PI=3.1415926539f;
- static final int VI_TRANSFORMB=1;
- static final int VI_WINDOWB=1;
-
- int analysisp;
- Info vi;
- int modebits;
-
- float[][] pcm;
- //float[][] pcmret;
- int pcm_storage;
- int pcm_current;
- int pcm_returned;
-
- float[] multipliers;
- int envelope_storage;
- int envelope_current;
-
- int eofflag;
-
- int lW;
- int W;
- int nW;
- int centerW;
-
- long granulepos;
- long sequence;
-
- long glue_bits;
- long time_bits;
- long floor_bits;
- long res_bits;
-
- // local lookup storage
-//!! Envelope ve=new Envelope(); // envelope
-//float **window[2][2][2]; // block, leadin, leadout, type
- float[][][][][] window; // block, leadin, leadout, type
- //vorbis_look_transform **transform[2]; // block, type
- Object[][] transform;
- CodeBook[] fullbooks;
- // backend lookups are tied to the mode, not the backend or naked mapping
- Object[] mode;
-
- // local storage, only used on the encoding side. This way the
- // application does not need to worry about freeing some packets'
- // memory and not others'; packet storage is always tracked.
- // Cleared next call to a _dsp_ function
- byte[] header;
- byte[] header1;
- byte[] header2;
-
- public DspState(){
- transform=new Object[2][];
- window=new float[2][][][][];
- window[0]=new float[2][][][];
- window[0][0]=new float[2][][];
- window[0][1]=new float[2][][];
- window[0][0][0]=new float[2][];
- window[0][0][1]=new float[2][];
- window[0][1][0]=new float[2][];
- window[0][1][1]=new float[2][];
- window[1]=new float[2][][][];
- window[1][0]=new float[2][][];
- window[1][1]=new float[2][][];
- window[1][0][0]=new float[2][];
- window[1][0][1]=new float[2][];
- window[1][1][0]=new float[2][];
- window[1][1][1]=new float[2][];
- }
-
- private static int ilog2(int v){
- int ret=0;
- while(v>1){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-
- static float[] window(int type, int window, int left, int right){
- float[] ret=new float[window];
- switch(type){
- case 0:
- // The 'vorbis window' (window 0) is sin(sin(x)*sin(x)*2pi)
- {
- int leftbegin=window/4-left/2;
- int rightbegin=window-window/4-right/2;
-
- for(int i=0;i<left;i++){
- float x=(float)((i+.5)/left*M_PI/2.);
- x=(float)Math.sin(x);
- x*=x;
- x*=M_PI/2.;
- x=(float)Math.sin(x);
- ret[i+leftbegin]=x;
- }
-
- for(int i=leftbegin+left;i<rightbegin;i++){
- ret[i]=1.f;
- }
-
- for(int i=0;i<right;i++){
- float x=(float)((right-i-.5)/right*M_PI/2.);
- x=(float)Math.sin(x);
- x*=x;
- x*=M_PI/2.;
- x=(float)Math.sin(x);
- ret[i+rightbegin]=x;
- }
- }
- break;
- default:
- //free(ret);
- return(null);
- }
- return(ret);
- }
-
- // Analysis side code, but directly related to blocking. Thus it's
- // here and not in analysis.c (which is for analysis transforms only).
- // The init is here because some of it is shared
-
- int init(Info vi, boolean encp){
-//System.err.println("DspState.init: vi="+vi+", encp="+encp);
- //memset(v,0,sizeof(vorbis_dsp_state));
- this.vi=vi;
- modebits=ilog2(vi.modes);
-
- transform[0]=new Object[VI_TRANSFORMB];
- transform[1]=new Object[VI_TRANSFORMB];
-
- // MDCT is tranform 0
-
- transform[0][0]=new Mdct();
- transform[1][0]=new Mdct();
- ((Mdct)transform[0][0]).init(vi.blocksizes[0]);
- ((Mdct)transform[1][0]).init(vi.blocksizes[1]);
-
- window[0][0][0]=new float[VI_WINDOWB][];
- window[0][0][1]=window[0][0][0];
- window[0][1][0]=window[0][0][0];
- window[0][1][1]=window[0][0][0];
- window[1][0][0]=new float[VI_WINDOWB][];
- window[1][0][1]=new float[VI_WINDOWB][];
- window[1][1][0]=new float[VI_WINDOWB][];
- window[1][1][1]=new float[VI_WINDOWB][];
-
- for(int i=0;i<VI_WINDOWB;i++){
- window[0][0][0][i]=
- window(i,vi.blocksizes[0],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
- window[1][0][0][i]=
- window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[0]/2);
- window[1][0][1][i]=
- window(i,vi.blocksizes[1],vi.blocksizes[0]/2,vi.blocksizes[1]/2);
- window[1][1][0][i]=
- window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[0]/2);
- window[1][1][1][i]=
- window(i,vi.blocksizes[1],vi.blocksizes[1]/2,vi.blocksizes[1]/2);
- }
-
-// if(encp){ // encode/decode differ here
-// // finish the codebooks
-// fullbooks=new CodeBook[vi.books];
-// for(int i=0;i<vi.books;i++){
-// fullbooks[i]=new CodeBook();
-// fullbooks[i].init_encode(vi.book_param[i]);
-// }
-// analysisp=1;
-// }
-// else{
- // finish the codebooks
- fullbooks=new CodeBook[vi.books];
- for(int i=0;i<vi.books;i++){
- fullbooks[i]=new CodeBook();
- fullbooks[i].init_decode(vi.book_param[i]);
- }
-// }
-
- // initialize the storage vectors to a decent size greater than the
- // minimum
-
- pcm_storage=8192; // we'll assume later that we have
- // a minimum of twice the blocksize of
- // accumulated samples in analysis
- pcm=new float[vi.channels][];
- //pcmret=new float[vi.channels][];
- {
- for(int i=0;i<vi.channels;i++){
- pcm[i]=new float[pcm_storage];
- }
- }
-
- // all 1 (large block) or 0 (small block)
- // explicitly set for the sake of clarity
- lW=0; // previous window size
- W=0; // current window size
-
- // all vector indexes; multiples of samples_per_envelope_step
- centerW=vi.blocksizes[1]/2;
-
- pcm_current=centerW;
-
- // initialize all the mapping/backend lookups
- mode=new Object[vi.modes];
- for(int i=0;i<vi.modes;i++){
- int mapnum=vi.mode_param[i].mapping;
- int maptype=vi.map_type[mapnum];
- mode[i]=FuncMapping.mapping_P[maptype].look(this,vi.mode_param[i],
- vi.map_param[mapnum]);
- }
- return(0);
- }
-
- public int synthesis_init(Info vi){
- init(vi, false);
- // Adjust centerW to allow an easier mechanism for determining output
- pcm_returned=centerW;
- centerW-= vi.blocksizes[W]/4+vi.blocksizes[lW]/4;
- granulepos=-1;
- sequence=-1;
- return(0);
- }
-
- DspState(Info vi){
- this();
- init(vi, false);
- // Adjust centerW to allow an easier mechanism for determining output
- pcm_returned=centerW;
- centerW-= vi.blocksizes[W]/4+vi.blocksizes[lW]/4;
- granulepos=-1;
- sequence=-1;
- }
-
- // Unike in analysis, the window is only partially applied for each
- // block. The time domain envelope is not yet handled at the point of
- // calling (as it relies on the previous block).
-
- public int synthesis_blockin(Block vb){
- // Shift out any PCM/multipliers that we returned previously
- // centerW is currently the center of the last block added
- if(centerW>vi.blocksizes[1]/2 && pcm_returned>8192){
- // don't shift too much; we need to have a minimum PCM buffer of
- // 1/2 long block
-
- int shiftPCM=centerW-vi.blocksizes[1]/2;
- shiftPCM=(pcm_returned<shiftPCM?pcm_returned:shiftPCM);
-
- pcm_current-=shiftPCM;
- centerW-=shiftPCM;
- pcm_returned-=shiftPCM;
- if(shiftPCM!=0){
- for(int i=0;i<vi.channels;i++){
- System.arraycopy(pcm[i], shiftPCM, pcm[i], 0, pcm_current);
- }
- }
- }
-
- lW=W;
- W=vb.W;
- nW=-1;
-
- glue_bits+=vb.glue_bits;
- time_bits+=vb.time_bits;
- floor_bits+=vb.floor_bits;
- res_bits+=vb.res_bits;
-
- if(sequence+1 != vb.sequence)granulepos=-1; // out of sequence; lose count
-
- sequence=vb.sequence;
-
- {
- int sizeW=vi.blocksizes[W];
- int _centerW=centerW+vi.blocksizes[lW]/4+sizeW/4;
- int beginW=_centerW-sizeW/2;
- int endW=beginW+sizeW;
- int beginSl=0;
- int endSl=0;
-
- // Do we have enough PCM/mult storage for the block?
- if(endW>pcm_storage){
- // expand the storage
- pcm_storage=endW+vi.blocksizes[1];
- for(int i=0;i<vi.channels;i++){
- float[] foo=new float[pcm_storage];
- System.arraycopy(pcm[i], 0, foo, 0, pcm[i].length);
- pcm[i]=foo;
- }
- }
-
- // overlap/add PCM
- switch(W){
- case 0:
- beginSl=0;
- endSl=vi.blocksizes[0]/2;
- break;
- case 1:
- beginSl=vi.blocksizes[1]/4-vi.blocksizes[lW]/4;
- endSl=beginSl+vi.blocksizes[lW]/2;
- break;
- }
-
- for(int j=0;j<vi.channels;j++){
- int _pcm=beginW;
- // the overlap/add section
- int i=0;
- for(i=beginSl;i<endSl;i++){
- pcm[j][_pcm+i]+=vb.pcm[j][i];
- }
- // the remaining section
- for(;i<sizeW;i++){
- pcm[j][_pcm+i]=vb.pcm[j][i];
- }
- }
-
- // track the frame number... This is for convenience, but also
- // making sure our last packet doesn't end with added padding. If
- // the last packet is partial, the number of samples we'll have to
- // return will be past the vb->granulepos.
- //
- // This is not foolproof! It will be confused if we begin
- // decoding at the last page after a seek or hole. In that case,
- // we don't have a starting point to judge where the last frame
- // is. For this reason, vorbisfile will always try to make sure
- // it reads the last two marked pages in proper sequence
-
- if(granulepos==-1){
- granulepos=vb.granulepos;
- }
- else{
- granulepos+=(_centerW-centerW);
- if(vb.granulepos!=-1 && granulepos!=vb.granulepos){
- if(granulepos>vb.granulepos && vb.eofflag!=0){
- // partial last frame. Strip the padding off
- _centerW-=(granulepos-vb.granulepos);
- }// else{ Shouldn't happen *unless* the bitstream is out of
- // spec. Either way, believe the bitstream }
- granulepos=vb.granulepos;
- }
- }
-
- // Update, cleanup
-
- centerW=_centerW;
- pcm_current=endW;
- if(vb.eofflag!=0)eofflag=1;
- }
- return(0);
- }
-
- // pcm==NULL indicates we just want the pending samples, no more
- public int synthesis_pcmout(float[][][] _pcm, int[] index){
- if(pcm_returned<centerW){
- if(_pcm!=null){
- for(int i=0;i<vi.channels;i++){
-// pcmret[i]=pcm[i]+v.pcm_returned;
-//!!!!!!!!
- index[i]=pcm_returned;
- }
- _pcm[0]=pcm;
- }
- return(centerW-pcm_returned);
- }
- return(0);
- }
-
- public int synthesis_read(int bytes){
- if(bytes!=0 && pcm_returned+bytes>centerW)return(-1);
- pcm_returned+=bytes;
- return(0);
- }
-
- public void clear(){
-/*
- if(window[0][0][0]!=0){
- for(i=0;i<VI_WINDOWB;i++)
- if(v->window[0][0][0][i])free(v->window[0][0][0][i]);
- free(v->window[0][0][0]);
-
- for(j=0;j<2;j++)
- for(k=0;k<2;k++){
- for(i=0;i<VI_WINDOWB;i++)
- if(v->window[1][j][k][i])free(v->window[1][j][k][i]);
- free(v->window[1][j][k]);
- }
- }
-
- if(v->pcm){
- for(i=0;i<vi->channels;i++)
- if(v->pcm[i])free(v->pcm[i]);
- free(v->pcm);
- if(v->pcmret)free(v->pcmret);
- }
- if(v->multipliers)free(v->multipliers);
-
- _ve_envelope_clear(&v->ve);
- if(v->transform[0]){
- mdct_clear(v->transform[0][0]);
- free(v->transform[0][0]);
- free(v->transform[0]);
- }
- if(v->transform[1]){
- mdct_clear(v->transform[1][0]);
- free(v->transform[1][0]);
- free(v->transform[1]);
- }
-
- // free mode lookups; these are actually vorbis_look_mapping structs
- if(vi){
- for(i=0;i<vi->modes;i++){
- int mapnum=vi->mode_param[i]->mapping;
- int maptype=vi->map_type[mapnum];
- _mapping_P[maptype]->free_look(v->mode[i]);
- }
- // free codebooks
- for(i=0;i<vi->books;i++)
- vorbis_book_clear(v->fullbooks+i);
- }
-
- if(v->mode)free(v->mode);
- if(v->fullbooks)free(v->fullbooks);
-
- // free header, header1, header2
- if(v->header)free(v->header);
- if(v->header1)free(v->header1);
- if(v->header2)free(v->header2);
-
- memset(v,0,sizeof(vorbis_dsp_state));
- }
-*/
-}
-}
diff --git a/songdbj/com/jcraft/jorbis/EncodeAuxNearestMatch.java b/songdbj/com/jcraft/jorbis/EncodeAuxNearestMatch.java
deleted file mode 100644
index c4b3b06c6e..0000000000
--- a/songdbj/com/jcraft/jorbis/EncodeAuxNearestMatch.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class EncodeAuxNearestMatch{
- int[] ptr0;
- int[] ptr1;
-
- int[] p; // decision points (each is an entry)
- int[] q; // decision points (each is an entry)
- int aux; // number of tree entries
- int alloc;
-}
diff --git a/songdbj/com/jcraft/jorbis/EncodeAuxThreshMatch.java b/songdbj/com/jcraft/jorbis/EncodeAuxThreshMatch.java
deleted file mode 100644
index 33cb58733c..0000000000
--- a/songdbj/com/jcraft/jorbis/EncodeAuxThreshMatch.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class EncodeAuxThreshMatch{
- float[] quantthresh;
- int[] quantmap;
- int quantvals;
- int threshvals;
-}
diff --git a/songdbj/com/jcraft/jorbis/Floor0.java b/songdbj/com/jcraft/jorbis/Floor0.java
deleted file mode 100644
index 3f1d1c32d5..0000000000
--- a/songdbj/com/jcraft/jorbis/Floor0.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class Floor0 extends FuncFloor{
-
- void pack(Object i, Buffer opb){
- InfoFloor0 info=(InfoFloor0)i;
- opb.write(info.order,8);
- opb.write(info.rate,16);
- opb.write(info.barkmap,16);
- opb.write(info.ampbits,6);
- opb.write(info.ampdB,8);
- opb.write(info.numbooks-1,4);
- for(int j=0;j<info.numbooks;j++)
- opb.write(info.books[j],8);
- }
-
- Object unpack(Info vi , Buffer opb){
- InfoFloor0 info=new InfoFloor0();
- info.order=opb.read(8);
- info.rate=opb.read(16);
- info.barkmap=opb.read(16);
- info.ampbits=opb.read(6);
- info.ampdB=opb.read(8);
- info.numbooks=opb.read(4)+1;
-
- if((info.order<1)||
- (info.rate<1)||
- (info.barkmap<1)||
- (info.numbooks<1)){
- //free_info(info);
- return(null);
- }
-
- for(int j=0;j<info.numbooks;j++){
- info.books[j]=opb.read(8);
- if(info.books[j]<0 || info.books[j]>=vi.books){
- //free_info(info);
- return(null);
- }
- }
- return(info);
-// err_out:
-// free_info(info);
-// return(NULL);
- }
- Object look(DspState vd, InfoMode mi, Object i){
- float scale;
- Info vi=vd.vi;
- InfoFloor0 info=(InfoFloor0)i;
- LookFloor0 look=new LookFloor0();
- look.m=info.order;
- look.n=vi.blocksizes[mi.blockflag]/2;
- look.ln=info.barkmap;
- look.vi=info;
- look.lpclook.init(look.ln,look.m);
-
- // we choose a scaling constant so that:
- // floor(bark(rate/2-1)*C)=mapped-1
- // floor(bark(rate/2)*C)=mapped
- scale=look.ln/toBARK((float)(info.rate/2.));
-
- // the mapping from a linear scale to a smaller bark scale is
- // straightforward. We do *not* make sure that the linear mapping
- // does not skip bark-scale bins; the decoder simply skips them and
- // the encoder may do what it wishes in filling them. They're
- // necessary in some mapping combinations to keep the scale spacing
- // accurate
- look.linearmap=new int[look.n];
- for(int j=0;j<look.n;j++){
- int val=(int)Math.floor(toBARK((float)((info.rate/2.)/look.n*j))
- *scale); // bark numbers represent band edges
- if(val>=look.ln)val=look.ln; // guard against the approximation
- look.linearmap[j]=val;
- }
- return look;
- }
-
- static float toBARK(float f){
- return (float)(13.1*Math.atan(.00074*(f))+2.24*Math.atan((f)*(f)*1.85e-8)+1e-4*(f));
- }
-
- Object state(Object i){
- EchstateFloor0 state=new EchstateFloor0();
- InfoFloor0 info=(InfoFloor0)i;
-
- // a safe size if usually too big (dim==1)
- state.codewords=new int[info.order];
- state.curve=new float[info.barkmap];
- state.frameno=-1;
- return(state);
- }
- void free_info(Object i){}
- void free_look(Object i){}
- void free_state(Object vs){}
- int forward(Block vb, Object i, float[] in, float[] out, Object vs){return 0;}
-
- float[] lsp=null;
- int inverse(Block vb, Object i, float[] out){
- //System.err.println("Floor0.inverse "+i.getClass()+"]");
- LookFloor0 look=(LookFloor0)i;
- InfoFloor0 info=look.vi;
- int ampraw=vb.opb.read(info.ampbits);
- if(ampraw>0){ // also handles the -1 out of data case
- int maxval=(1<<info.ampbits)-1;
- float amp=(float)ampraw/maxval*info.ampdB;
- int booknum=vb.opb.read(ilog(info.numbooks));
-
- if(booknum!=-1 && booknum<info.numbooks){
-
- synchronized(this){
- if(lsp==null||lsp.length<look.m){
- lsp=new float[look.m];
- }
- else{
- for(int j=0; j<look.m; j++)lsp[j]=0.f;
- }
-
- CodeBook b=vb.vd.fullbooks[info.books[booknum]];
- float last=0.f;
-
- //memset(out,0,sizeof(float)*look->m);
- for(int j=0; j<look.m; j++)out[j]=0.0f;
-
- for(int j=0;j<look.m;j+=b.dim){
- if(b.decodevs(lsp, j, vb.opb, 1, -1)==-1){
- //goto eop;
- // memset(out,0,sizeof(float)*look->n);
- for(int k=0; k<look.n; k++)out[k]=0.0f;
- return(0);
- }
- }
- for(int j=0;j<look.m;){
- for(int k=0;k<b.dim;k++,j++)lsp[j]+=last;
- last=lsp[j-1];
- }
- // take the coefficients back to a spectral envelope curve
- /*
- lsp_to_lpc(out,out,look.m);
- lpc_to_curve(out,out,amp,look,"",0);
- for(int j=0;j<look.n;j++){
- out[j]=fromdB(out[j]-info.ampdB);
- }
- */
- Lsp.lsp_to_curve(out,look.linearmap,look.n,look.ln,
- lsp,look.m,amp,info.ampdB);
-
- return(1);
- }
- }
- }
-// eop:
-// memset(out,0,sizeof(float)*look->n);
- return(0);
- }
-
- Object inverse1(Block vb, Object i, Object memo){
- //System.err.println("Floor0.inverse "+i.getClass()+"]");
- LookFloor0 look=(LookFloor0)i;
- InfoFloor0 info=look.vi;
- float[] lsp=null;
- if(memo instanceof float[]){
- lsp=(float[])memo;
- }
-
- int ampraw=vb.opb.read(info.ampbits);
- if(ampraw>0){ // also handles the -1 out of data case
- int maxval=(1<<info.ampbits)-1;
- float amp=(float)ampraw/maxval*info.ampdB;
- int booknum=vb.opb.read(ilog(info.numbooks));
-
- if(booknum!=-1 && booknum<info.numbooks){
- CodeBook b=vb.vd.fullbooks[info.books[booknum]];
- float last=0.f;
-
- if(lsp==null||lsp.length<look.m+1){
- lsp=new float[look.m+1];
- }
- else{
- for(int j=0; j<lsp.length; j++)lsp[j]=0.f;
- }
-
- for(int j=0;j<look.m;j+=b.dim){
- if(b.decodev_set(lsp, j, vb.opb, b.dim)==-1){
- //goto eop;
- return(null);
- }
- }
-
- for(int j=0;j<look.m;){
- for(int k=0;k<b.dim;k++,j++)lsp[j]+=last;
- last=lsp[j-1];
- }
- lsp[look.m]=amp;
- return(lsp);
- }
- }
-// eop:
- return(null);
- }
-
- int inverse2(Block vb, Object i, Object memo, float[] out){
- //System.err.println("Floor0.inverse "+i.getClass()+"]");
- LookFloor0 look=(LookFloor0)i;
- InfoFloor0 info=look.vi;
-
- if(memo!=null){
- float[] lsp=(float[])memo;
- float amp=lsp[look.m];
-
- Lsp.lsp_to_curve(out,look.linearmap,look.n,look.ln,
- lsp,look.m,amp,info.ampdB);
- return(1);
- }
-// eop:
-// memset(out,0,sizeof(float)*look->n);
- for(int j=0; j<look.n; j++){
- out[j]=0.f;
- }
- return(0);
- }
-
- static float fromdB(float x){
- return (float)(Math.exp((x)*.11512925));
- }
- private static int ilog(int v){
- int ret=0;
- while(v!=0){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-
- static void lsp_to_lpc(float[] lsp, float[] lpc, int m){
- int i,j,m2=m/2;
- float[] O=new float[m2];
- float[] E=new float[m2];
- float A;
- float[] Ae=new float[m2+1];
- float[] Ao=new float[m2+1];
- float B;
- float[] Be=new float[m2];
- float[] Bo=new float[m2];
- float temp;
-
- // even/odd roots setup
- for(i=0;i<m2;i++){
- O[i]=(float)(-2.*Math.cos(lsp[i*2]));
- E[i]=(float)(-2.*Math.cos(lsp[i*2+1]));
- }
-
- // set up impulse response
- for(j=0;j<m2;j++){
- Ae[j]=0.f;
- Ao[j]=1.f;
- Be[j]=0.f;
- Bo[j]=1.f;
- }
- Ao[j]=1.f;
- Ae[j]=1.f;
-
- // run impulse response
- for(i=1;i<m+1;i++){
- A=B=0.f;
- for(j=0;j<m2;j++){
- temp=O[j]*Ao[j]+Ae[j];
- Ae[j]=Ao[j];
- Ao[j]=A;
- A+=temp;
-
- temp=E[j]*Bo[j]+Be[j];
- Be[j]=Bo[j];
- Bo[j]=B;
- B+=temp;
- }
- lpc[i-1]=(A+Ao[j]+B-Ae[j])/2;
- Ao[j]=A;
- Ae[j]=B;
- }
- }
-
- static void lpc_to_curve(float[] curve, float[] lpc,float amp,
- LookFloor0 l, String name, int frameno){
- // l->m+1 must be less than l->ln, but guard in case we get a bad stream
- float[] lcurve=new float[Math.max(l.ln*2,l.m*2+2)];
-
- if(amp==0){
- //memset(curve,0,sizeof(float)*l->n);
- for(int j=0; j<l.n; j++)curve[j]=0.0f;
- return;
- }
- l.lpclook.lpc_to_curve(lcurve,lpc,amp);
-
- for(int i=0;i<l.n;i++)curve[i]=lcurve[l.linearmap[i]];
- }
-}
-
-class InfoFloor0{
- int order;
- int rate;
- int barkmap;
-
- int ampbits;
- int ampdB;
-
- int numbooks; // <= 16
- int[] books=new int[16];
-}
-
-class LookFloor0{
- int n;
- int ln;
- int m;
- int[] linearmap;
-
- InfoFloor0 vi;
- Lpc lpclook=new Lpc();
-}
-
-class EchstateFloor0{
- int[] codewords;
- float[] curve;
- long frameno;
- long codes;
-}
diff --git a/songdbj/com/jcraft/jorbis/Floor1.java b/songdbj/com/jcraft/jorbis/Floor1.java
deleted file mode 100644
index 1e52c3e537..0000000000
--- a/songdbj/com/jcraft/jorbis/Floor1.java
+++ /dev/null
@@ -1,653 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class Floor1 extends FuncFloor{
- static final int floor1_rangedb=140;
- static final int VIF_POSIT=63;
-
- void pack(Object i, Buffer opb){
- InfoFloor1 info=(InfoFloor1)i;
-
- int count=0;
- int rangebits;
- int maxposit=info.postlist[1];
- int maxclass=-1;
-
- /* save out partitions */
- opb.write(info.partitions,5); /* only 0 to 31 legal */
- for(int j=0;j<info.partitions;j++){
- opb.write(info.partitionclass[j],4); /* only 0 to 15 legal */
- if(maxclass<info.partitionclass[j])
- maxclass=info.partitionclass[j];
- }
-
- /* save out partition classes */
- for(int j=0;j<maxclass+1;j++){
- opb.write(info.class_dim[j]-1,3); /* 1 to 8 */
- opb.write(info.class_subs[j],2); /* 0 to 3 */
- if(info.class_subs[j]!=0){
- opb.write(info.class_book[j],8);
- }
- for(int k=0;k<(1<<info.class_subs[j]);k++){
- opb.write(info.class_subbook[j][k]+1,8);
- }
- }
-
- /* save out the post list */
- opb.write(info.mult-1,2); /* only 1,2,3,4 legal now */
- opb.write(ilog2(maxposit),4);
- rangebits=ilog2(maxposit);
-
- for(int j=0,k=0;j<info.partitions;j++){
- count+=info.class_dim[info.partitionclass[j]];
- for(;k<count;k++){
- opb.write(info.postlist[k+2],rangebits);
- }
- }
- }
-
- Object unpack(Info vi , Buffer opb){
- int count=0,maxclass=-1,rangebits;
- InfoFloor1 info=new InfoFloor1();
-
- /* read partitions */
- info.partitions=opb.read(5); /* only 0 to 31 legal */
- for(int j=0;j<info.partitions;j++){
- info.partitionclass[j]=opb.read(4); /* only 0 to 15 legal */
- if(maxclass<info.partitionclass[j])
- maxclass=info.partitionclass[j];
- }
-
- /* read partition classes */
- for(int j=0;j<maxclass+1;j++){
- info.class_dim[j]=opb.read(3)+1; /* 1 to 8 */
- info.class_subs[j]=opb.read(2); /* 0,1,2,3 bits */
- if(info.class_subs[j]<0){
- //goto err_out;
- info.free();
- return(null);
- }
- if(info.class_subs[j]!=0){
- info.class_book[j]=opb.read(8);
- }
- if(info.class_book[j]<0 || info.class_book[j]>=vi.books){
- //goto err_out;
- info.free();
- return(null);
- }
- for(int k=0;k<(1<<info.class_subs[j]);k++){
- info.class_subbook[j][k]=opb.read(8)-1;
- if(info.class_subbook[j][k]<-1 || info.class_subbook[j][k]>=vi.books){
- //goto err_out;
- info.free();
- return(null);
- }
- }
- }
-
- /* read the post list */
- info.mult=opb.read(2)+1; /* only 1,2,3,4 legal now */
- rangebits=opb.read(4);
-
- for(int j=0,k=0;j<info.partitions;j++){
- count+=info.class_dim[info.partitionclass[j]];
- for(;k<count;k++){
- int t=info.postlist[k+2]=opb.read(rangebits);
- if(t<0 || t>=(1<<rangebits)){
- //goto err_out;
- info.free();
- return(null);
- }
- }
- }
- info.postlist[0]=0;
- info.postlist[1]=1<<rangebits;
-
- return(info);
-// err_out:
-// info.free();
-// return(null);
- }
-
- Object look(DspState vd, InfoMode mi, Object i){
- int _n=0;
-
- int[] sortpointer=new int[VIF_POSIT+2];
-
-// Info vi=vd.vi;
-
- InfoFloor1 info=(InfoFloor1)i;
- LookFloor1 look=new LookFloor1();
- look.vi=info;
- look.n=info.postlist[1];
-
- /* we drop each position value in-between already decoded values,
- and use linear interpolation to predict each new value past the
- edges. The positions are read in the order of the position
- list... we precompute the bounding positions in the lookup. Of
- course, the neighbors can change (if a position is declined), but
- this is an initial mapping */
-
- for(int j=0;j<info.partitions;j++){
- _n+=info.class_dim[info.partitionclass[j]];
- }
- _n+=2;
- look.posts=_n;
-
- /* also store a sorted position index */
- for(int j=0;j<_n;j++){
- sortpointer[j]=j;
- }
-// qsort(sortpointer,n,sizeof(int),icomp); // !!
-
- int foo;
- for(int j=0; j<_n-1; j++){
- for(int k=j; k<_n; k++){
- if(info.postlist[sortpointer[j]]>info.postlist[sortpointer[k]]){
- foo=sortpointer[k];
- sortpointer[k]=sortpointer[j];
- sortpointer[j]=foo;
- }
- }
- }
-
- /* points from sort order back to range number */
- for(int j=0;j<_n;j++){
- look.forward_index[j]=sortpointer[j];
- }
- /* points from range order to sorted position */
- for(int j=0;j<_n;j++){
- look.reverse_index[look.forward_index[j]]=j;
- }
- /* we actually need the post values too */
- for(int j=0;j<_n;j++){
- look.sorted_index[j]=info.postlist[look.forward_index[j]];
- }
-
-
- /* quantize values to multiplier spec */
- switch(info.mult){
- case 1: /* 1024 -> 256 */
- look.quant_q=256;
- break;
- case 2: /* 1024 -> 128 */
- look.quant_q=128;
- break;
- case 3: /* 1024 -> 86 */
- look.quant_q=86;
- break;
- case 4: /* 1024 -> 64 */
- look.quant_q=64;
- break;
- default:
- look.quant_q=-1;
- }
-
- /* discover our neighbors for decode where we don't use fit flags
- (that would push the neighbors outward) */
- for(int j=0;j<_n-2;j++){
- int lo=0;
- int hi=1;
- int lx=0;
- int hx=look.n;
- int currentx=info.postlist[j+2];
- for(int k=0;k<j+2;k++){
- int x=info.postlist[k];
- if(x>lx && x<currentx){
- lo=k;
- lx=x;
- }
- if(x<hx && x>currentx){
- hi=k;
- hx=x;
- }
- }
- look.loneighbor[j]=lo;
- look.hineighbor[j]=hi;
- }
-
- return look;
- }
-
- void free_info(Object i){}
- void free_look(Object i){}
- void free_state(Object vs){}
-
- int forward(Block vb, Object i, float[] in, float[] out, Object vs){return 0;}
-
- Object inverse1(Block vb, Object ii, Object memo){
- //System.err.println("Floor1.inverse "+i.getClass()+"]");
- LookFloor1 look=(LookFloor1)ii;
- InfoFloor1 info=look.vi;
- CodeBook[] books=vb.vd.fullbooks;
-
- /* unpack wrapped/predicted values from stream */
- if(vb.opb.read(1)==1){
- int[] fit_value=null;
- if(memo instanceof int[]){
- fit_value=(int[])memo;
- }
- if(fit_value==null || fit_value.length<look.posts){
- fit_value=new int[look.posts];
- }
- else{
- for(int i=0; i<fit_value.length; i++) fit_value[i]=0;
- }
-
- fit_value[0]=vb.opb.read(ilog(look.quant_q-1));
- fit_value[1]=vb.opb.read(ilog(look.quant_q-1));
-
- /* partition by partition */
- for(int i=0,j=2;i<info.partitions;i++){
- int clss=info.partitionclass[i];
- int cdim=info.class_dim[clss];
- int csubbits=info.class_subs[clss];
- int csub=1<<csubbits;
- int cval=0;
-
- /* decode the partition's first stage cascade value */
- if(csubbits!=0){
- cval=books[info.class_book[clss]].decode(vb.opb);
-
- if(cval==-1){
- //goto eop;
- return(null);
- }
- }
-
- for(int k=0;k<cdim;k++){
- int book=info.class_subbook[clss][cval&(csub-1)];
- cval>>>=csubbits;
- if(book>=0){
- if((fit_value[j+k]=books[book].decode(vb.opb))==-1){
- //goto eop;
- return(null);
- }
- }
- else{
- fit_value[j+k]=0;
- }
- }
- j+=cdim;
- }
-
- /* unwrap positive values and reconsitute via linear interpolation */
- for(int i=2;i<look.posts;i++){
- int predicted=render_point(info.postlist[look.loneighbor[i-2]],
- info.postlist[look.hineighbor[i-2]],
- fit_value[look.loneighbor[i-2]],
- fit_value[look.hineighbor[i-2]],
- info.postlist[i]);
- int hiroom=look.quant_q-predicted;
- int loroom=predicted;
- int room=(hiroom<loroom?hiroom:loroom)<<1;
- int val=fit_value[i];
-
- if(val!=0){
- if(val>=room){
- if(hiroom>loroom){
- val = val-loroom;
- }
- else{
- val = -1-(val-hiroom);
- }
- }
- else{
- if((val&1)!=0){
- val= -((val+1)>>>1);
- }
- else{
- val>>=1;
- }
- }
-
- fit_value[i]=val+predicted;
- fit_value[look.loneighbor[i-2]]&=0x7fff;
- fit_value[look.hineighbor[i-2]]&=0x7fff;
- }
- else{
- fit_value[i]=predicted|0x8000;
- }
- }
- return(fit_value);
- }
-
-// eop:
-// return(NULL);
- return(null);
- }
-
- private static int render_point(int x0,int x1,int y0,int y1,int x){
- y0&=0x7fff; /* mask off flag */
- y1&=0x7fff;
-
- {
- int dy=y1-y0;
- int adx=x1-x0;
- int ady=Math.abs(dy);
- int err=ady*(x-x0);
-
- int off=(int)(err/adx);
- if(dy<0)return(y0-off);
- return(y0+off);
- }
- }
-
- int inverse2(Block vb, Object i, Object memo, float[] out){
- LookFloor1 look=(LookFloor1)i;
- InfoFloor1 info=look.vi;
- int n=vb.vd.vi.blocksizes[vb.mode]/2;
-
- if(memo!=null){
- /* render the lines */
- int[] fit_value=(int[] )memo;
- int hx=0;
- int lx=0;
- int ly=fit_value[0]*info.mult;
- for(int j=1;j<look.posts;j++){
- int current=look.forward_index[j];
- int hy=fit_value[current]&0x7fff;
- if(hy==fit_value[current]){
- hy*=info.mult;
- hx=info.postlist[current];
-
- render_line(lx,hx,ly,hy,out);
-
- lx=hx;
- ly=hy;
- }
- }
- for(int j=hx;j<n;j++){
- out[j]*=out[j-1]; /* be certain */
- }
- return(1);
- }
- for(int j=0; j<n; j++){
- out[j]=0.f;
- }
- return(0);
- }
-
-
- private static float[] FLOOR_fromdB_LOOKUP={
- 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F,
- 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F,
- 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F,
- 2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F,
- 2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F,
- 3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F,
- 4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F,
- 6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F,
- 7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F,
- 1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F,
- 1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F,
- 1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F,
- 2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F,
- 2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F,
- 3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F,
- 4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F,
- 5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F,
- 7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F,
- 9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F,
- 1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F,
- 1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F,
- 2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F,
- 2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F,
- 3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F,
- 4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F,
- 5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F,
- 7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F,
- 9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F,
- 0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F,
- 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F,
- 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F,
- 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F,
- 0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F,
- 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F,
- 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F,
- 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F,
- 0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F,
- 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
- 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
- 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
- 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F,
- 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F,
- 0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F,
- 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F,
- 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F,
- 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F,
- 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
- 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F,
- 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F,
- 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F,
- 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F,
- 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F,
- 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F,
- 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F,
- 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F,
- 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
- 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F,
- 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F,
- 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F,
- 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F,
- 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F,
- 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F,
- 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F,
- 0.82788260F, 0.88168307F, 0.9389798F, 1.F
- };
-
- private static void render_line(int x0, int x1,int y0,int y1,float[] d){
- int dy=y1-y0;
- int adx=x1-x0;
- int ady=Math.abs(dy);
- int base=dy/adx;
- int sy=(dy<0?base-1:base+1);
- int x=x0;
- int y=y0;
- int err=0;
-
- ady-=Math.abs(base*adx);
-
- d[x]*=FLOOR_fromdB_LOOKUP[y];
- while(++x<x1){
- err=err+ady;
- if(err>=adx){
- err-=adx;
- y+=sy;
- }
- else{
- y+=base;
- }
- d[x]*=FLOOR_fromdB_LOOKUP[y];
- }
- }
-
- static int ilog(int v){
- int ret=0;
- while(v!=0){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-
- private static int ilog2(int v){
- int ret=0;
- while(v>1){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-}
-
-class InfoFloor1{
- static final int VIF_POSIT=63;
- static final int VIF_CLASS=16;
- static final int VIF_PARTS=31;
-
- int partitions; /* 0 to 31 */
- int[] partitionclass=new int[VIF_PARTS]; /* 0 to 15 */
-
- int[] class_dim=new int[VIF_CLASS]; /* 1 to 8 */
- int[] class_subs=new int[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */
- int[] class_book=new int[VIF_CLASS]; /* subs ^ dim entries */
- int[][] class_subbook=new int[VIF_CLASS][]; /* [VIF_CLASS][subs] */
-
-
- int mult; /* 1 2 3 or 4 */
- int[] postlist=new int[VIF_POSIT+2]; /* first two implicit */
-
-
- /* encode side analysis parameters */
- float maxover;
- float maxunder;
- float maxerr;
-
- int twofitminsize;
- int twofitminused;
- int twofitweight;
- float twofitatten;
- int unusedminsize;
- int unusedmin_n;
-
- int n;
-
- InfoFloor1(){
- for(int i=0; i<class_subbook.length; i++){
- class_subbook[i]=new int[8];
- }
- }
-
- void free(){
- partitionclass=null;
- class_dim=null;
- class_subs=null;
- class_book=null;
- class_subbook=null;
- postlist=null;
- }
-
- Object copy_info(){
- InfoFloor1 info=this;
- InfoFloor1 ret=new InfoFloor1();
-
- ret.partitions=info.partitions;
- System.arraycopy(info.partitionclass, 0, ret.partitionclass, 0, VIF_PARTS);
- System.arraycopy(info.class_dim, 0, ret.class_dim, 0, VIF_CLASS);
- System.arraycopy(info.class_subs, 0, ret.class_subs, 0, VIF_CLASS);
- System.arraycopy(info.class_book, 0, ret.class_book, 0, VIF_CLASS);
-
- for(int j=0; j<VIF_CLASS; j++){
- System.arraycopy(info.class_subbook[j], 0,
- ret.class_subbook[j], 0, 8);
- }
-
- ret.mult=info.mult;
- System.arraycopy(info.postlist, 0, ret.postlist, 0, VIF_POSIT+2);
-
- ret.maxover=info.maxover;
- ret.maxunder=info.maxunder;
- ret.maxerr=info.maxerr;
-
- ret.twofitminsize=info.twofitminsize;
- ret.twofitminused=info.twofitminused;
- ret.twofitweight=info.twofitweight;
- ret.twofitatten=info.twofitatten;
- ret.unusedminsize=info.unusedminsize;
- ret.unusedmin_n=info.unusedmin_n;
-
- ret.n=info.n;
-
- return(ret);
- }
-
-}
-
-class LookFloor1{
- static final int VIF_POSIT=63;
-
- int[] sorted_index=new int[VIF_POSIT+2];
- int[] forward_index=new int[VIF_POSIT+2];
- int[] reverse_index=new int[VIF_POSIT+2];
- int[] hineighbor=new int[VIF_POSIT];
- int[] loneighbor=new int[VIF_POSIT];
- int posts;
-
- int n;
- int quant_q;
- InfoFloor1 vi;
-
- int phrasebits;
- int postbits;
- int frames;
-
- void free(){
-
-/*
- System.out.println("floor 1 bit usage "+
- (float)(phrasebits/frames)
- +":"+
- (float)(postbits/frames)
- +"("+
- (float)((postbits+phrasebits)/frames)
- +" total)"
-
-*/
-
- sorted_index=null;
- forward_index=null;
- reverse_index=null;
- hineighbor=null;
- loneighbor=null;
- }
-}
-
-class Lsfit_acc{
- long x0;
- long x1;
-
- long xa;
- long ya;
- long x2a;
- long y2a;
- long xya;
- long n;
- long an;
- long un;
- long edgey0;
- long edgey1;
-}
-
-class EchstateFloor1{
- int[] codewords;
- float[] curve;
- long frameno;
- long codes;
-}
diff --git a/songdbj/com/jcraft/jorbis/FuncFloor.java b/songdbj/com/jcraft/jorbis/FuncFloor.java
deleted file mode 100644
index f438d0f260..0000000000
--- a/songdbj/com/jcraft/jorbis/FuncFloor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-abstract class FuncFloor{
-// public static FuncFloor[] floor_P={new Floor0()};
- public static FuncFloor[] floor_P={new Floor0(),new Floor1()};
-
- abstract void pack(Object i, Buffer opb);
- abstract Object unpack(Info vi, Buffer opb);
- abstract Object look(DspState vd, InfoMode mi, Object i);
-// abstract Object state(Object i);
- abstract void free_info(Object i);
- abstract void free_look(Object i);
- abstract void free_state(Object vs);
- abstract int forward(Block vb, Object i, float[] in, float[] out, Object vs);
-// abstract int inverse(Block vb, Object i, float[] out);
- abstract Object inverse1(Block vb, Object i, Object memo);
- abstract int inverse2(Block vb, Object i, Object memo, float[] out);
-}
diff --git a/songdbj/com/jcraft/jorbis/FuncMapping.java b/songdbj/com/jcraft/jorbis/FuncMapping.java
deleted file mode 100644
index c8ecf75fe7..0000000000
--- a/songdbj/com/jcraft/jorbis/FuncMapping.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-abstract class FuncMapping{
- public static FuncMapping[] mapping_P={new Mapping0()};
-
- abstract void pack(Info info , Object imap, Buffer buffer);
- abstract Object unpack(Info info , Buffer buffer);
- abstract Object look(DspState vd, InfoMode vm, Object m);
- abstract void free_info(Object imap);
- abstract void free_look(Object imap);
-// abstract int forward(Block vd, Object lm);
- abstract int inverse(Block vd, Object lm);
-}
diff --git a/songdbj/com/jcraft/jorbis/FuncResidue.java b/songdbj/com/jcraft/jorbis/FuncResidue.java
deleted file mode 100644
index 4cbf6a1d53..0000000000
--- a/songdbj/com/jcraft/jorbis/FuncResidue.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-abstract class FuncResidue{
- public static FuncResidue[] residue_P={new Residue0(),
- new Residue1(),
- new Residue2()};
-
- abstract void pack(Object vr, Buffer opb);
- abstract Object unpack(Info vi, Buffer opb);
- abstract Object look(DspState vd, InfoMode vm, Object vr);
- abstract void free_info(Object i);
- abstract void free_look(Object i);
- abstract int forward(Block vb,Object vl, float[][] in, int ch);
-// abstract int inverse(Block vb, Object vl, float[][] in, int ch);
-abstract int inverse(Block vb, Object vl, float[][] in, int[] nonzero,int ch);
-}
diff --git a/songdbj/com/jcraft/jorbis/FuncTime.java b/songdbj/com/jcraft/jorbis/FuncTime.java
deleted file mode 100644
index b3cd080461..0000000000
--- a/songdbj/com/jcraft/jorbis/FuncTime.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-abstract class FuncTime{
- public static FuncTime[] time_P={new Time0()};
-
- abstract void pack(Object i, Buffer opb);
- abstract Object unpack(Info vi , Buffer opb);
- abstract Object look(DspState vd, InfoMode vm, Object i);
- abstract void free_info(Object i);
- abstract void free_look(Object i);
- abstract int forward(Block vb, Object i);
- abstract int inverse(Block vb, Object i, float[] in, float[] out);
-}
diff --git a/songdbj/com/jcraft/jorbis/Info.java b/songdbj/com/jcraft/jorbis/Info.java
deleted file mode 100644
index dffd4d9de2..0000000000
--- a/songdbj/com/jcraft/jorbis/Info.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-public class Info{
- private static final int OV_EBADPACKET=-136;
- private static final int OV_ENOTAUDIO=-135;
-
- private static byte[] _vorbis="vorbis".getBytes();
- private static final int VI_TIMEB=1;
-// private static final int VI_FLOORB=1;
- private static final int VI_FLOORB=2;
-// private static final int VI_RESB=1;
- private static final int VI_RESB=3;
- private static final int VI_MAPB=1;
- private static final int VI_WINDOWB=1;
-
- public int version;
- public int channels;
- public int rate;
-
- // The below bitrate declarations are *hints*.
- // Combinations of the three values carry the following implications:
- //
- // all three set to the same value:
- // implies a fixed rate bitstream
- // only nominal set:
- // implies a VBR stream that averages the nominal bitrate. No hard
- // upper/lower limit
- // upper and or lower set:
- // implies a VBR bitstream that obeys the bitrate limits. nominal
- // may also be set to give a nominal rate.
- // none set:
- // the coder does not care to speculate.
-
- int bitrate_upper;
- int bitrate_nominal;
- int bitrate_lower;
-
- // Vorbis supports only short and long blocks, but allows the
- // encoder to choose the sizes
-
- int[] blocksizes=new int[2];
-
- // modes are the primary means of supporting on-the-fly different
- // blocksizes, different channel mappings (LR or mid-side),
- // different residue backends, etc. Each mode consists of a
- // blocksize flag and a mapping (along with the mapping setup
-
- int modes;
- int maps;
- int times;
- int floors;
- int residues;
- int books;
- int psys; // encode only
-
- InfoMode[] mode_param=null;
-
- int[] map_type=null;
- Object[] map_param=null;
-
- int[] time_type=null;
- Object[] time_param=null;
-
- int[] floor_type=null;
- Object[] floor_param=null;
-
- int[] residue_type=null;
- Object[] residue_param=null;
-
- StaticCodeBook[] book_param=null;
-
- PsyInfo[] psy_param=new PsyInfo[64]; // encode only
-
- // for block long/sort tuning; encode only
- int envelopesa;
- float preecho_thresh;
- float preecho_clamp;
-
- // used by synthesis, which has a full, alloced vi
- public void init(){
- rate=0;
- //memset(vi,0,sizeof(vorbis_info));
- }
-
- public void clear(){
- for(int i=0;i<modes;i++){ mode_param[i]=null; }
- mode_param=null;
-
- for(int i=0;i<maps;i++){ // unpack does the range checking
- FuncMapping.mapping_P[map_type[i]].free_info(map_param[i]);
- }
- map_param=null;
-
- for(int i=0;i<times;i++){ // unpack does the range checking
- FuncTime.time_P[time_type[i]].free_info(time_param[i]);
- }
- time_param=null;
-
- for(int i=0;i<floors;i++){ // unpack does the range checking
- FuncFloor.floor_P[floor_type[i]].free_info(floor_param[i]);
- }
- floor_param=null;
-
- for(int i=0;i<residues;i++){ // unpack does the range checking
- FuncResidue.residue_P[residue_type[i]].free_info(residue_param[i]);
- }
- residue_param=null;
-
- // the static codebooks *are* freed if you call info_clear, because
- // decode side does alloc a 'static' codebook. Calling clear on the
- // full codebook does not clear the static codebook (that's our
- // responsibility)
- for(int i=0;i<books;i++){
- // just in case the decoder pre-cleared to save space
- if(book_param[i]!=null){
- book_param[i].clear();
- book_param[i]=null;
- }
- }
- //if(vi->book_param)free(vi->book_param);
- book_param=null;
-
- for(int i=0;i<psys;i++){
- psy_param[i].free();
- }
- //if(vi->psy_param)free(vi->psy_param);
- //memset(vi,0,sizeof(vorbis_info));
- }
-
- // Header packing/unpacking
- int unpack_info(Buffer opb){
- version=opb.read(32);
- if(version!=0)return(-1);
-
- channels=opb.read(8);
- rate=opb.read(32);
-
- bitrate_upper=opb.read(32);
- bitrate_nominal=opb.read(32);
- bitrate_lower=opb.read(32);
-
- blocksizes[0]=1<<opb.read(4);
- blocksizes[1]=1<<opb.read(4);
-
- if((rate<1) ||
- (channels<1)||
- (blocksizes[0]<8)||
- (blocksizes[1]<blocksizes[0]) ||
- (opb.read(1)!=1)){
- //goto err_out; // EOP check
- clear();
- return(-1);
- }
- return(0);
- // err_out:
- // vorbis_info_clear(vi);
- // return(-1);
- }
-
- // all of the real encoding details are here. The modes, books,
- // everything
- int unpack_books(Buffer opb){
-
- //d* codebooks
- books=opb.read(8)+1;
-
- if(book_param==null || book_param.length!=books)
- book_param=new StaticCodeBook[books];
- for(int i=0;i<books;i++){
- book_param[i]=new StaticCodeBook();
- if(book_param[i].unpack(opb)!=0){
- //goto err_out;
- clear();
- return(-1);
- }
- }
-
- // time backend settings
- times=opb.read(6)+1;
- if(time_type==null || time_type.length!=times) time_type=new int[times];
- if(time_param==null || time_param.length!=times)
- time_param=new Object[times];
- for(int i=0;i<times;i++){
- time_type[i]=opb.read(16);
- if(time_type[i]<0 || time_type[i]>=VI_TIMEB){
- //goto err_out;
- clear();
- return(-1);
- }
- time_param[i]=FuncTime.time_P[time_type[i]].unpack(this, opb);
- if(time_param[i]==null){
- //goto err_out;
- clear();
- return(-1);
- }
- }
-
- // floor backend settings
- floors=opb.read(6)+1;
- if(floor_type==null || floor_type.length!=floors)
- floor_type=new int[floors];
- if(floor_param==null || floor_param.length!=floors)
- floor_param=new Object[floors];
-
- for(int i=0;i<floors;i++){
- floor_type[i]=opb.read(16);
- if(floor_type[i]<0 || floor_type[i]>=VI_FLOORB){
- //goto err_out;
- clear();
- return(-1);
- }
-
- floor_param[i]=FuncFloor.floor_P[floor_type[i]].unpack(this,opb);
- if(floor_param[i]==null){
- //goto err_out;
- clear();
- return(-1);
- }
- }
-
- // residue backend settings
- residues=opb.read(6)+1;
-
- if(residue_type==null || residue_type.length!=residues)
- residue_type=new int[residues];
-
- if(residue_param==null || residue_param.length!=residues)
- residue_param=new Object[residues];
-
- for(int i=0;i<residues;i++){
- residue_type[i]=opb.read(16);
- if(residue_type[i]<0 || residue_type[i]>=VI_RESB){
-// goto err_out;
- clear();
- return(-1);
- }
- residue_param[i]=FuncResidue.residue_P[residue_type[i]].unpack(this,opb);
- if(residue_param[i]==null){
-// goto err_out;
- clear();
- return(-1);
- }
- }
-
- // map backend settings
- maps=opb.read(6)+1;
- if(map_type==null || map_type.length!=maps) map_type=new int[maps];
- if(map_param==null || map_param.length!=maps) map_param=new Object[maps];
- for(int i=0;i<maps;i++){
- map_type[i]=opb.read(16);
- if(map_type[i]<0 || map_type[i]>=VI_MAPB){
-// goto err_out;
- clear();
- return(-1);
- }
- map_param[i]=FuncMapping.mapping_P[map_type[i]].unpack(this,opb);
- if(map_param[i]==null){
-// goto err_out;
- clear();
- return(-1);
- }
- }
-
- // mode settings
- modes=opb.read(6)+1;
- if(mode_param==null || mode_param.length!=modes)
- mode_param=new InfoMode[modes];
- for(int i=0;i<modes;i++){
- mode_param[i]=new InfoMode();
- mode_param[i].blockflag=opb.read(1);
- mode_param[i].windowtype=opb.read(16);
- mode_param[i].transformtype=opb.read(16);
- mode_param[i].mapping=opb.read(8);
-
- if((mode_param[i].windowtype>=VI_WINDOWB)||
- (mode_param[i].transformtype>=VI_WINDOWB)||
- (mode_param[i].mapping>=maps)){
-// goto err_out;
- clear();
- return(-1);
- }
- }
-
- if(opb.read(1)!=1){
- //goto err_out; // top level EOP check
- clear();
- return(-1);
- }
-
- return(0);
-// err_out:
-// vorbis_info_clear(vi);
-// return(-1);
- }
-
- // The Vorbis header is in three packets; the initial small packet in
- // the first page that identifies basic parameters, a second packet
- // with bitstream comments and a third packet that holds the
- // codebook.
-
- public int synthesis_headerin(Comment vc, Packet op){
- Buffer opb=new Buffer();
-
- if(op!=null){
- opb.readinit(op.packet_base, op.packet, op.bytes);
-
- // Which of the three types of header is this?
- // Also verify header-ness, vorbis
- {
- byte[] buffer=new byte[6];
- int packtype=opb.read(8);
- //memset(buffer,0,6);
- opb.read(buffer,6);
- if(buffer[0]!='v' || buffer[1]!='o' || buffer[2]!='r' ||
- buffer[3]!='b' || buffer[4]!='i' || buffer[5]!='s'){
- // not a vorbis header
- return(-1);
- }
- switch(packtype){
- case 0x01: // least significant *bit* is read first
- if(op.b_o_s==0){
- // Not the initial packet
- return(-1);
- }
- if(rate!=0){
- // previously initialized info header
- return(-1);
- }
- return(unpack_info(opb));
- case 0x03: // least significant *bit* is read first
- if(rate==0){
- // um... we didn't get the initial header
- return(-1);
- }
- return(vc.unpack(opb));
- case 0x05: // least significant *bit* is read first
- if(rate==0 || vc.vendor==null){
- // um... we didn;t get the initial header or comments yet
- return(-1);
- }
- return(unpack_books(opb));
- default:
- // Not a valid vorbis header type
- //return(-1);
- break;
- }
- }
- }
- return(-1);
- }
-
- // pack side
- int pack_info(Buffer opb){
- // preamble
- opb.write(0x01,8);
- opb.write(_vorbis);
-
- // basic information about the stream
- opb.write(0x00,32);
- opb.write(channels,8);
- opb.write(rate,32);
-
- opb.write(bitrate_upper,32);
- opb.write(bitrate_nominal,32);
- opb.write(bitrate_lower,32);
-
- opb.write(ilog2(blocksizes[0]),4);
- opb.write(ilog2(blocksizes[1]),4);
- opb.write(1,1);
- return(0);
- }
-
- int pack_books(Buffer opb){
- opb.write(0x05,8);
- opb.write(_vorbis);
-
- // books
- opb.write(books-1,8);
- for(int i=0;i<books;i++){
- if(book_param[i].pack(opb)!=0){
- //goto err_out;
- return(-1);
- }
- }
-
- // times
- opb.write(times-1,6);
- for(int i=0;i<times;i++){
- opb.write(time_type[i],16);
- FuncTime.time_P[time_type[i]].pack(this.time_param[i],opb);
- }
-
- // floors
- opb.write(floors-1,6);
- for(int i=0;i<floors;i++){
- opb.write(floor_type[i],16);
- FuncFloor.floor_P[floor_type[i]].pack(floor_param[i],opb);
- }
-
- // residues
- opb.write(residues-1,6);
- for(int i=0;i<residues;i++){
- opb.write(residue_type[i],16);
- FuncResidue.residue_P[residue_type[i]].pack(residue_param[i],opb);
- }
-
- // maps
- opb.write(maps-1,6);
- for(int i=0;i<maps;i++){
- opb.write(map_type[i],16);
- FuncMapping.mapping_P[map_type[i]].pack(this,map_param[i],opb);
- }
-
- // modes
- opb.write(modes-1,6);
- for(int i=0;i<modes;i++){
- opb.write(mode_param[i].blockflag,1);
- opb.write(mode_param[i].windowtype,16);
- opb.write(mode_param[i].transformtype,16);
- opb.write(mode_param[i].mapping,8);
- }
- opb.write(1,1);
- return(0);
- //err_out:
- //return(-1);
- }
-
-// static void v_writestring(Buffer o, byte[] s){
-// int i=0;
-// while(s[i]!=0){
-// o.write(s[i++],8);
-// }
-// }
-
-// static void v_readstring(Buffer o, byte[] buf, int bytes){
-// int i=0
-// while(bytes--!=0){
-// buf[i++]=o.read(8);
-// }
-// }
-
-// private Buffer opb_blocksize=new Buffer();
- public int blocksize(Packet op){
- //codec_setup_info *ci=vi->codec_setup;
- Buffer opb=new Buffer();
-// synchronized(opb_blocksize){
- int mode;
-
- opb.readinit(op.packet_base, op.packet, op.bytes);
-
- /* Check the packet type */
- if(opb.read(1)!=0){
- /* Oops. This is not an audio data packet */
- return(OV_ENOTAUDIO);
- }
- {
- int modebits=0;
- int v=modes;
- while(v>1){
- modebits++;
- v>>>=1;
- }
-
- /* read our mode and pre/post windowsize */
- mode=opb.read(modebits);
- }
- if(mode==-1)return(OV_EBADPACKET);
- return(blocksizes[mode_param[mode].blockflag]);
-// }
- }
-
- private static int ilog2(int v){
- int ret=0;
- while(v>1){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-
- public String toString(){
- return "version:"+new Integer(version)+
- ", channels:"+new Integer(channels)+
- ", rate:"+new Integer(rate)+
- ", bitrate:"+new Integer(bitrate_upper)+","+
- new Integer(bitrate_nominal)+","+
- new Integer(bitrate_lower);
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/InfoMode.java b/songdbj/com/jcraft/jorbis/InfoMode.java
deleted file mode 100644
index b570aa5c21..0000000000
--- a/songdbj/com/jcraft/jorbis/InfoMode.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class InfoMode{
- int blockflag;
- int windowtype;
- int transformtype;
- int mapping;
-}
diff --git a/songdbj/com/jcraft/jorbis/JOrbisException.java b/songdbj/com/jcraft/jorbis/JOrbisException.java
deleted file mode 100644
index ce09d4f9fc..0000000000
--- a/songdbj/com/jcraft/jorbis/JOrbisException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-public class JOrbisException extends Exception {
- public JOrbisException () {
- super();
- }
- public JOrbisException (String s) {
- super ("JOrbis: "+s);
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/Lookup.java b/songdbj/com/jcraft/jorbis/Lookup.java
deleted file mode 100644
index fb7651a19f..0000000000
--- a/songdbj/com/jcraft/jorbis/Lookup.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class Lookup{
- static final int COS_LOOKUP_SZ=128;
- static final float[] COS_LOOKUP={
- +1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f,
- +0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f,
- +0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f,
- +0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f,
- +0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f,
- +0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f,
- +0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f,
- +0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f,
- +0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f,
- +0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f,
- +0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f,
- +0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f,
- +0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f,
- +0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f,
- +0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f,
- +0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f,
- +0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f,
- -0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f,
- -0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f,
- -0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f,
- -0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f,
- -0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f,
- -0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f,
- -0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f,
- -0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f,
- -0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f,
- -0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f,
- -0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f,
- -0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f,
- -0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f,
- -0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f,
- -0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f,
- -1.0000000000000f,
- };
- /* interpolated lookup based cos function, domain 0 to PI only */
- static float coslook(float a){
- double d=a*(.31830989*(float)COS_LOOKUP_SZ);
- int i=(int)d;
- return COS_LOOKUP[i]+ ((float)(d-i))*(COS_LOOKUP[i+1]-COS_LOOKUP[i]);
- }
-
- static final int INVSQ_LOOKUP_SZ=32;
- static final float[] INVSQ_LOOKUP={
- 1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f,
- 1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f,
- 1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f,
- 1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f,
- 1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f,
- 1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f,
- 1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f,
- 1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f,
- 1.000000000000f,
- };
- /* interpolated 1./sqrt(p) where .5 <= p < 1. */
- static float invsqlook(float a){
-// System.out.println(a);
- double d=a*(2.f*(float)INVSQ_LOOKUP_SZ)-(float)INVSQ_LOOKUP_SZ;
- int i=(int)d;
- return INVSQ_LOOKUP[i]+ ((float)(d-i))*(INVSQ_LOOKUP[i+1]-INVSQ_LOOKUP[i]);
- }
-
- static final int INVSQ2EXP_LOOKUP_MIN=-32;
- static final int INVSQ2EXP_LOOKUP_MAX=32;
- static final float[] INVSQ2EXP_LOOKUP={
- 65536.f, 46340.95001f, 32768.f, 23170.47501f,
- 16384.f, 11585.2375f, 8192.f, 5792.618751f,
- 4096.f, 2896.309376f, 2048.f, 1448.154688f,
- 1024.f, 724.0773439f, 512.f, 362.038672f,
- 256.f, 181.019336f, 128.f, 90.50966799f,
- 64.f, 45.254834f, 32.f, 22.627417f,
- 16.f, 11.3137085f, 8.f, 5.656854249f,
- 4.f, 2.828427125f, 2.f, 1.414213562f,
- 1.f, 0.7071067812f, 0.5f, 0.3535533906f,
- 0.25f, 0.1767766953f, 0.125f, 0.08838834765f,
- 0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f,
- 0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f,
- 0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f,
- 0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f,
- 0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f,
- 6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f,
- 1.525878906e-05f,
- };
- /* interpolated 1./sqrt(p) where .5 <= p < 1. */
- static float invsq2explook(int a){
- return INVSQ2EXP_LOOKUP[a-INVSQ2EXP_LOOKUP_MIN];
- }
-
- static final int FROMdB_LOOKUP_SZ=35;
- static final int FROMdB2_LOOKUP_SZ=32;
- static final int FROMdB_SHIFT=5;
- static final int FROMdB2_SHIFT=3;
- static final int FROMdB2_MASK=31;
- static final float[] FROMdB_LOOKUP={
- 1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f,
- 0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f,
- 0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f,
- 0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f,
- 0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f,
- 0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f,
- 1.584893192e-05f, 1e-05f,6.309573445e-06f,3.981071706e-06f,
- 2.511886432e-06f,1.584893192e-06f, 1e-06f,6.309573445e-07f,
- 3.981071706e-07f,2.511886432e-07f,1.584893192e-07f,
- };
- static final float[] FROMdB2_LOOKUP={
- 0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f,
- 0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f,
- 0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f,
- 0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f,
- 0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f,
- 0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f,
- 0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f,
- 0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f,
- };
- /* interpolated lookup based fromdB function, domain -140dB to 0dB only */
- static float fromdBlook(float a){
- int i=(int)(a*((float)(-(1<<FROMdB2_SHIFT))));
- return (i<0)?1.f:
- ((i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))?0.f:
- FROMdB_LOOKUP[i>>>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]);
- }
-
-}
-
-
diff --git a/songdbj/com/jcraft/jorbis/Lpc.java b/songdbj/com/jcraft/jorbis/Lpc.java
deleted file mode 100644
index 452ed86d91..0000000000
--- a/songdbj/com/jcraft/jorbis/Lpc.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class Lpc{
- // en/decode lookups
- Drft fft=new Drft();;
-
- int ln;
- int m;
-
- // Autocorrelation LPC coeff generation algorithm invented by
- // N. Levinson in 1947, modified by J. Durbin in 1959.
-
- // Input : n elements of time doamin data
- // Output: m lpc coefficients, excitation energy
-
- static float lpc_from_data(float[] data, float[] lpc,int n,int m){
- float[] aut=new float[m+1];
- float error;
- int i,j;
-
- // autocorrelation, p+1 lag coefficients
-
- j=m+1;
- while(j--!=0){
- float d=0;
- for(i=j;i<n;i++)d+=data[i]*data[i-j];
- aut[j]=d;
- }
-
- // Generate lpc coefficients from autocorr values
-
- error=aut[0];
- /*
- if(error==0){
- for(int k=0; k<m; k++) lpc[k]=0.0f;
- return 0;
- }
- */
-
- for(i=0;i<m;i++){
- float r=-aut[i+1];
-
- if(error==0){
- for(int k=0; k<m; k++) lpc[k]=0.0f;
- return 0;
- }
-
- // Sum up this iteration's reflection coefficient; note that in
- // Vorbis we don't save it. If anyone wants to recycle this code
- // and needs reflection coefficients, save the results of 'r' from
- // each iteration.
-
- for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
- r/=error;
-
- // Update LPC coefficients and total error
-
- lpc[i]=r;
- for(j=0;j<i/2;j++){
- float tmp=lpc[j];
- lpc[j]+=r*lpc[i-1-j];
- lpc[i-1-j]+=r*tmp;
- }
- if(i%2!=0)lpc[j]+=lpc[j]*r;
-
- error*=1.0-r*r;
- }
-
- // we need the error value to know how big an impulse to hit the
- // filter with later
-
- return error;
- }
-
- // Input : n element envelope spectral curve
- // Output: m lpc coefficients, excitation energy
-
- float lpc_from_curve(float[] curve, float[] lpc){
- int n=ln;
- float[] work=new float[n+n];
- float fscale=(float)(.5/n);
- int i,j;
-
- // input is a real curve. make it complex-real
- // This mixes phase, but the LPC generation doesn't care.
- for(i=0;i<n;i++){
- work[i*2]=curve[i]*fscale;
- work[i*2+1]=0;
- }
- work[n*2-1]=curve[n-1]*fscale;
-
- n*=2;
- fft.backward(work);
-
- // The autocorrelation will not be circular. Shift, else we lose
- // most of the power in the edges.
-
- for(i=0,j=n/2;i<n/2;){
- float temp=work[i];
- work[i++]=work[j];
- work[j++]=temp;
- }
-
- return(lpc_from_data(work,lpc,n,m));
- }
-
- void init(int mapped, int m){
- //memset(l,0,sizeof(lpc_lookup));
-
- ln=mapped;
- this.m=m;
-
- // we cheat decoding the LPC spectrum via FFTs
- fft.init(mapped*2);
- }
-
- void clear(){
- fft.clear();
- }
-
- static float FAST_HYPOT(float a, float b){
- return (float)Math.sqrt((a)*(a) + (b)*(b));
- }
-
- // One can do this the long way by generating the transfer function in
- // the time domain and taking the forward FFT of the result. The
- // results from direct calculation are cleaner and faster.
- //
- // This version does a linear curve generation and then later
- // interpolates the log curve from the linear curve.
-
- void lpc_to_curve(float[] curve, float[] lpc, float amp){
-
- //memset(curve,0,sizeof(float)*l->ln*2);
- for(int i=0; i<ln*2; i++)curve[i]=0.0f;
-
- if(amp==0)return;
-
- for(int i=0;i<m;i++){
- curve[i*2+1]=lpc[i]/(4*amp);
- curve[i*2+2]=-lpc[i]/(4*amp);
- }
-
- fft.backward(curve); // reappropriated ;-)
-
- {
- int l2=ln*2;
- float unit=(float)(1./amp);
- curve[0]=(float)(1./(curve[0]*2+unit));
- for(int i=1;i<ln;i++){
- float real=(curve[i]+curve[l2-i]);
- float imag=(curve[i]-curve[l2-i]);
-
- float a = real + unit;
- curve[i] = (float)(1.0 / FAST_HYPOT(a, imag));
- }
- }
- }
-
-/*
- // subtract or add an lpc filter to data. Vorbis doesn't actually use this.
-
- static void lpc_residue(float[] coeff, float[] prime,int m,
- float[] data, int n){
-
- // in: coeff[0...m-1] LPC coefficients
- // prime[0...m-1] initial values
- // data[0...n-1] data samples
- // out: data[0...n-1] residuals from LPC prediction
-
- float[] work=new float[m+n];
- float y;
-
- if(prime==null){
- for(int i=0;i<m;i++){
- work[i]=0;
- }
- }
- else{
- for(int i=0;i<m;i++){
- work[i]=prime[i];
- }
- }
-
- for(int i=0;i<n;i++){
- y=0;
- for(int j=0;j<m;j++){
- y-=work[i+j]*coeff[m-j-1];
- }
- work[i+m]=data[i];
- data[i]-=y;
- }
- }
-
- static void lpc_predict(float[] coeff, float[] prime,int m,
- float[] data, int n){
-
- // in: coeff[0...m-1] LPC coefficients
- // prime[0...m-1] initial values (allocated size of n+m-1)
- // data[0...n-1] residuals from LPC prediction
- // out: data[0...n-1] data samples
-
- int o,p;
- float y;
- float[] work=new float[m+n];
-
- if(prime==null){
- for(int i=0;i<m;i++){
- work[i]=0.f;
- }
- }
- else{
- for(int i=0;i<m;i++){
- work[i]=prime[i];
- }
- }
-
- for(int i=0;i<n;i++){
- y=data[i];
- o=i;
- p=m;
- for(int j=0;j<m;j++){
- y-=work[o++]*coeff[--p];
- }
- data[i]=work[o]=y;
- }
- }
-*/
-}
diff --git a/songdbj/com/jcraft/jorbis/Lsp.java b/songdbj/com/jcraft/jorbis/Lsp.java
deleted file mode 100644
index 550c7d62ee..0000000000
--- a/songdbj/com/jcraft/jorbis/Lsp.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-/*
- function: LSP (also called LSF) conversion routines
-
- The LSP generation code is taken (with minimal modification) from
- "On the Computation of the LSP Frequencies" by Joseph Rothweiler
- <rothwlr@altavista.net>, available at:
-
- http://www2.xtdl.com/~rothwlr/lsfpaper/lsfpage.html
- ********************************************************************/
-
-class Lsp{
-
- static final float M_PI=(float)(3.1415926539);
-
- static void lsp_to_curve(float[] curve,
- int[] map, int n, int ln,
- float[] lsp, int m,
- float amp, float ampoffset){
- int i;
- float wdel=M_PI/ln;
- for(i=0;i<m;i++)lsp[i]=Lookup.coslook(lsp[i]);
- int m2=(m/2)*2;
-
- i=0;
- while(i<n){
- int k=map[i];
- float p=.7071067812f;
- float q=.7071067812f;
- float w=Lookup.coslook(wdel*k);
- int ftmp=0;
- int c=m>>>1;
-
- for(int j=0;j<m2;j+=2){
- q*=lsp[j]-w;
- p*=lsp[j+1]-w;
- }
-
- if((m&1)!=0){
- /* odd order filter; slightly assymetric */
- /* the last coefficient */
- q*=lsp[m-1]-w;
- q*=q;
- p*=p*(1.f-w*w);
- }
- else{
- /* even order filter; still symmetric */
- q*=q*(1.f+w);
- p*=p*(1.f-w);
- }
-
- // q=frexp(p+q,&qexp);
- q=p+q;
- int hx=Float.floatToIntBits(q);
- int ix=0x7fffffff&hx;
- int qexp=0;
-
- if(ix>=0x7f800000||(ix==0)){
- // 0,inf,nan
- }
- else{
- if(ix<0x00800000){ // subnormal
- q*=3.3554432000e+07; // 0x4c000000
- hx=Float.floatToIntBits(q);
- ix=0x7fffffff&hx;
- qexp=-25;
- }
- qexp += ((ix>>>23)-126);
- hx=(hx&0x807fffff)|0x3f000000;
- q=Float.intBitsToFloat(hx);
- }
-
- q=Lookup.fromdBlook(amp*
- Lookup.invsqlook(q)*
- Lookup.invsq2explook(qexp+m)-ampoffset);
-
- do{curve[i++]*=q;}
-// do{curve[i++]=q;}
- while(i<n&&map[i]==k);
-
- }
- }
-}
-
-
diff --git a/songdbj/com/jcraft/jorbis/Mapping0.java b/songdbj/com/jcraft/jorbis/Mapping0.java
deleted file mode 100644
index a2c3d06b5e..0000000000
--- a/songdbj/com/jcraft/jorbis/Mapping0.java
+++ /dev/null
@@ -1,566 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class Mapping0 extends FuncMapping{
- static int seq=0;
- void free_info(Object imap){};
- void free_look(Object imap){
-/*
- LookMapping0 l=(LookMapping0)imap;
- InfoMapping0 info=l.map;
- if(l!=null){
- for(int i=0;i<l.map.submaps;i++){
- l.time_func[i].free_look(l.time_look[i]);
- l.floor_func[i].free_look(l.floor_look[i]);
- l.residue_func[i].free_look(l.residue_look[i]);
- if(l.psy_look!=null)l.psy_look[i].clear();
- }
- }
-
- if(l.floor_state!=null){
- for(int i=0;i<l.ch;i++)
- l.floor_func[info.chmuxlist[i]].free_state(l.floor_state[i]);
- //free(l.floor_state);
- }
-
- if(l.decay!=null){
- for(int i=0;i<l.ch;i++){
- //if(l.decay[i])free(l->decay[i]);
- l.decay[i]=null;
- }
- //free(l->decay);
- l.decay=null;
- }
- //free(l->time_func);
- //free(l->floor_func);
- //free(l->residue_func);
- //free(l->time_look);
- //free(l->floor_look);
- //free(l->residue_look);
- //f(l->psy_look)free(l->psy_look);
- l.time_func=null;
- l.floor_func=null;
- l.residue_func=null;
- l.time_look=null;
- l.floor_look=null;
- l.residue_look=null;
- //memset(l,0,sizeof(vorbis_look_mapping0));
- //free(l);
-*/
- }
-
- Object look(DspState vd, InfoMode vm, Object m){
-//System.err.println("Mapping0.look");
- Info vi=vd.vi;
- LookMapping0 look=new LookMapping0();
- InfoMapping0 info=look.map=(InfoMapping0)m;
- look.mode=vm;
-
- look.time_look=new Object[info.submaps];
- look.floor_look=new Object[info.submaps];
- look.residue_look=new Object[info.submaps];
-
-/*
- if(vd.analysisp!=0){
- look.floor_state=new Object[vi.channels];
- }
- if(vi.psys!=0){
- look.psy_look=new PsyLook[info.submaps];
- for(int i=0; i<info.submaps; i++){ look.psy_look[i]=new PsyLook(); }
- }
-*/
-
- look.time_func=new FuncTime[info.submaps];
- look.floor_func=new FuncFloor[info.submaps];
- look.residue_func=new FuncResidue[info.submaps];
-
- for(int i=0;i<info.submaps;i++){
- int timenum=info.timesubmap[i];
- int floornum=info.floorsubmap[i];
- int resnum=info.residuesubmap[i];
-
- look.time_func[i]=FuncTime.time_P[vi.time_type[timenum]];
- look.time_look[i]=look.time_func[i].look(vd,vm,vi.time_param[timenum]);
- look.floor_func[i]=FuncFloor.floor_P[vi.floor_type[floornum]];
- look.floor_look[i]=look.floor_func[i].
- look(vd,vm,vi.floor_param[floornum]);
- look.residue_func[i]=FuncResidue.residue_P[vi.residue_type[resnum]];
- look.residue_look[i]=look.residue_func[i].
- look(vd,vm,vi.residue_param[resnum]);
-
-/*
- if(vi.psys!=0 && vd.analysisp!=0){
- int psynum=info.psysubmap[i];
- look.psy_look[i].init(vi.psy_param[psynum],
- vi.blocksizes[vm.blockflag]/2,vi.rate);
- }
-*/
- }
-
- if(vi.psys!=0 && vd.analysisp!=0){
- /*
- if(info->psy[0] != info->psy[1]){
-
- int psynum=info->psy[0];
- look->psy_look[0]=_ogg_calloc(1,sizeof(vorbis_look_psy));
- _vp_psy_init(look->psy_look[0],ci->psy_param[psynum],
- ci->psy_g_param,
- ci->blocksizes[vm->blockflag]/2,vi->rate);
-
- psynum=info->psy[1];
- look->psy_look[1]=_ogg_calloc(1,sizeof(vorbis_look_psy));
- _vp_psy_init(look->psy_look[1],ci->psy_param[psynum],
- ci->psy_g_param,
- ci->blocksizes[vm->blockflag]/2,vi->rate);
- }else{
-
- int psynum=info->psy[0];
- look->psy_look[0]=_ogg_calloc(1,sizeof(vorbis_look_psy));
- look->psy_look[1]=look->psy_look[0];
- _vp_psy_init(look->psy_look[0],ci->psy_param[psynum],
- ci->psy_g_param,
- ci->blocksizes[vm->blockflag]/2,vi->rate);
-
- }
- */
- }
-
- look.ch=vi.channels;
-// if(vd->analysisp)drft_init(&look->fft_look,ci->blocksizes[vm->blockflag]);
-
- return(look);
-//return null;
- }
-
- void pack(Info vi, Object imap, Buffer opb){
- InfoMapping0 info=(InfoMapping0)imap;
-
- /* another 'we meant to do it this way' hack... up to beta 4, we
- packed 4 binary zeros here to signify one submapping in use. We
- now redefine that to mean four bitflags that indicate use of
- deeper features; bit0:submappings, bit1:coupling,
- bit2,3:reserved. This is backward compatable with all actual uses
- of the beta code. */
-
- if(info.submaps>1){
- opb.write(1,1);
- opb.write(info.submaps-1,4);
- }
- else{
- opb.write(0,1);
- }
-
- if(info.coupling_steps>0){
- opb.write(1,1);
- opb.write(info.coupling_steps-1,8);
- for(int i=0;i<info.coupling_steps;i++){
- opb.write(info.coupling_mag[i],ilog2(vi.channels));
- opb.write(info.coupling_ang[i],ilog2(vi.channels));
- }
- }
- else{
- opb.write(0,1);
- }
-
- opb.write(0,2); /* 2,3:reserved */
-
- /* we don't write the channel submappings if we only have one... */
- if(info.submaps>1){
- for(int i=0;i<vi.channels;i++)
- opb.write(info.chmuxlist[i],4);
- }
- for(int i=0;i<info.submaps;i++){
- opb.write(info.timesubmap[i],8);
- opb.write(info.floorsubmap[i],8);
- opb.write(info.residuesubmap[i],8);
- }
- }
-
- // also responsible for range checking
- Object unpack(Info vi, Buffer opb){
- InfoMapping0 info=new InfoMapping0();
-
- // !!!!
- if(opb.read(1)!=0){
- info.submaps=opb.read(4)+1;
- }
- else{
- info.submaps=1;
- }
-
- if(opb.read(1)!=0){
- info.coupling_steps=opb.read(8)+1;
-
- for(int i=0;i<info.coupling_steps;i++){
- int testM=info.coupling_mag[i]=opb.read(ilog2(vi.channels));
- int testA=info.coupling_ang[i]=opb.read(ilog2(vi.channels));
-
- if(testM<0 ||
- testA<0 ||
- testM==testA ||
- testM>=vi.channels ||
- testA>=vi.channels){
- //goto err_out;
- info.free();
- return(null);
- }
- }
- }
-
- if(opb.read(2)>0){ /* 2,3:reserved */
- //goto err_out;
- info.free();
- return(null);
- }
-
- if(info.submaps>1){
- for(int i=0;i<vi.channels;i++){
- info.chmuxlist[i]=opb.read(4);
- if(info.chmuxlist[i]>=info.submaps){
- //goto err_out;
- info.free();
- return(null);
- }
- }
- }
-
- for(int i=0;i<info.submaps;i++){
- info.timesubmap[i]=opb.read(8);
- if(info.timesubmap[i]>=vi.times){
- //goto err_out;
- info.free();
- return(null);
- }
- info.floorsubmap[i]=opb.read(8);
- if(info.floorsubmap[i]>=vi.floors){
- //goto err_out;
- info.free();
- return(null);
- }
- info.residuesubmap[i]=opb.read(8);
- if(info.residuesubmap[i]>=vi.residues){
- //goto err_out;
- info.free();
- return(null);
- }
- }
- return info;
- //err_out:
- //free_info(info);
- //return(NULL);
- }
-
-/*
- // no time mapping implementation for now
- static int seq=0;
- int forward(Block vb, Object l){
- DspState vd=vb.vd;
- Info vi=vd.vi;
- LookMapping0 look=(LookMapping0)l;
- InfoMapping0 info=look.map;
- InfoMode mode=look.mode;
- int n=vb.pcmend;
- float[] window=vd.window[vb.W][vb.lW][vb.nW][mode.windowtype];
-
- float[][] pcmbundle=new float[vi.channles][];
- int[] nonzero=new int[vi.channels];
-
- // time domain pre-window: NONE IMPLEMENTED
-
- // window the PCM data: takes PCM vector, vb; modifies PCM vector
-
- for(int i=0;i<vi.channels;i++){
- float[] pcm=vb.pcm[i];
- for(int j=0;j<n;j++)
- pcm[j]*=window[j];
- }
-
- // time-domain post-window: NONE IMPLEMENTED
-
- // transform the PCM data; takes PCM vector, vb; modifies PCM vector
- // only MDCT right now....
- for(int i=0;i<vi.channels;i++){
- float[] pcm=vb.pcm[i];
- mdct_forward(vd.transform[vb.W][0],pcm,pcm);
- }
-
- {
- float[] floor=_vorbis_block_alloc(vb,n*sizeof(float)/2);
-
- for(int i=0;i<vi.channels;i++){
- float[] pcm=vb.pcm[i];
- float[] decay=look.decay[i];
- int submap=info.chmuxlist[i];
-
- // if some other mode/mapping was called last frame, our decay
- // accumulator is out of date. Clear it.
- //if(look.lastframe+1 != vb->sequence)
- // memset(decay,0,n*sizeof(float)/2);
-
- // perform psychoacoustics; do masking
- _vp_compute_mask(look.psy_look[submap],pcm,floor,decay);
-
- _analysis_output("mdct",seq,pcm,n/2,0,1);
- _analysis_output("lmdct",seq,pcm,n/2,0,0);
- _analysis_output("prefloor",seq,floor,n/2,0,1);
-
- // perform floor encoding
- nonzero[i]=look.floor_func[submap].
- forward(vb,look.floor_look[submap],floor,floor,look.floor_state[i]);
-
- _analysis_output("floor",seq,floor,n/2,0,1);
-
- // apply the floor, do optional noise levelling
- _vp_apply_floor(look->psy_look+submap,pcm,floor);
-
- _analysis_output("res",seq++,pcm,n/2,0,0);
- }
-
- // perform residue encoding with residue mapping; this is
- // multiplexed. All the channels belonging to one submap are
- // encoded (values interleaved), then the next submap, etc
-
- for(int i=0;i<info.submaps;i++){
- int ch_in_bundle=0;
- for(int j=0;j<vi.channels;j++){
- if(info.chmuxlist[j]==i && nonzero[j]==1){
- pcmbundle[ch_in_bundle++]=vb.pcm[j];
- }
- }
- look.residue_func[i].forward(vb,look.residue_look[i], pcmbundle,ch_in_bundle);
- }
- }
- look.lastframe=vb.sequence;
- return(0);
- }
-*/
-
- float[][] pcmbundle=null;
- int[] zerobundle=null;
- int[] nonzero=null;
- Object[] floormemo=null;
-
- synchronized int inverse(Block vb, Object l){
- //System.err.println("Mapping0.inverse");
- DspState vd=vb.vd;
- Info vi=vd.vi;
- LookMapping0 look=(LookMapping0)l;
- InfoMapping0 info=look.map;
- InfoMode mode=look.mode;
- int n=vb.pcmend=vi.blocksizes[vb.W];
-
- float[] window=vd.window[vb.W][vb.lW][vb.nW][mode.windowtype];
- // float[][] pcmbundle=new float[vi.channels][];
- // int[] nonzero=new int[vi.channels];
- if(pcmbundle==null || pcmbundle.length<vi.channels){
- pcmbundle=new float[vi.channels][];
- nonzero=new int[vi.channels];
- zerobundle=new int[vi.channels];
- floormemo=new Object[vi.channels];
- }
-
- // time domain information decode (note that applying the
- // information would have to happen later; we'll probably add a
- // function entry to the harness for that later
- // NOT IMPLEMENTED
-
- // recover the spectral envelope; store it in the PCM vector for now
- for(int i=0;i<vi.channels;i++){
- float[] pcm=vb.pcm[i];
- int submap=info.chmuxlist[i];
-
- floormemo[i]=look.floor_func[submap].inverse1(vb,look.
- floor_look[submap],
- floormemo[i]
- );
- if(floormemo[i]!=null){ nonzero[i]=1; }
- else{ nonzero[i]=0; }
- for(int j=0; j<n/2; j++){
- pcm[j]=0;
- }
-
- //_analysis_output("ifloor",seq+i,pcm,n/2,0,1);
- }
-
- for(int i=0; i<info.coupling_steps; i++){
- if(nonzero[info.coupling_mag[i]]!=0 ||
- nonzero[info.coupling_ang[i]]!=0){
- nonzero[info.coupling_mag[i]]=1;
- nonzero[info.coupling_ang[i]]=1;
- }
- }
-
- // recover the residue, apply directly to the spectral envelope
-
- for(int i=0;i<info.submaps;i++){
- int ch_in_bundle=0;
- for(int j=0;j<vi.channels;j++){
- if(info.chmuxlist[j]==i){
- if(nonzero[j]!=0){
- zerobundle[ch_in_bundle]=1;
- }
- else{
- zerobundle[ch_in_bundle]=0;
- }
- pcmbundle[ch_in_bundle++]=vb.pcm[j];
- }
- }
-
- look.residue_func[i].inverse(vb,look.residue_look[i],
- pcmbundle,zerobundle,ch_in_bundle);
- }
-
-
- for(int i=info.coupling_steps-1;i>=0;i--){
- float[] pcmM=vb.pcm[info.coupling_mag[i]];
- float[] pcmA=vb.pcm[info.coupling_ang[i]];
-
- for(int j=0;j<n/2;j++){
- float mag=pcmM[j];
- float ang=pcmA[j];
-
- if(mag>0){
- if(ang>0){
- pcmM[j]=mag;
- pcmA[j]=mag-ang;
- }
- else{
- pcmA[j]=mag;
- pcmM[j]=mag+ang;
- }
- }
- else{
- if(ang>0){
- pcmM[j]=mag;
- pcmA[j]=mag+ang;
- }
- else{
- pcmA[j]=mag;
- pcmM[j]=mag-ang;
- }
- }
- }
- }
-
-// /* compute and apply spectral envelope */
-
- for(int i=0;i<vi.channels;i++){
- float[] pcm=vb.pcm[i];
- int submap=info.chmuxlist[i];
- look.floor_func[submap].inverse2(vb,look.floor_look[submap],floormemo[i],pcm);
- }
-
- // transform the PCM data; takes PCM vector, vb; modifies PCM vector
- // only MDCT right now....
-
- for(int i=0;i<vi.channels;i++){
- float[] pcm=vb.pcm[i];
- //_analysis_output("out",seq+i,pcm,n/2,0,0);
- ((Mdct)vd.transform[vb.W][0]).backward(pcm,pcm);
- }
-
- // now apply the decoded pre-window time information
- // NOT IMPLEMENTED
-
- // window the data
- for(int i=0;i<vi.channels;i++){
- float[] pcm=vb.pcm[i];
- if(nonzero[i]!=0){
- for(int j=0;j<n;j++){
- pcm[j]*=window[j];
- }
- }
- else{
- for(int j=0;j<n;j++){
- pcm[j]=0.f;
- }
- }
- //_analysis_output("final",seq++,pcm,n,0,0);
- }
-
- // now apply the decoded post-window time information
- // NOT IMPLEMENTED
- // all done!
- return(0);
- }
-
-
- private static int ilog2(int v){
- int ret=0;
- while(v>1){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-}
-
-class InfoMapping0{
- int submaps; // <= 16
- int[] chmuxlist=new int[256]; // up to 256 channels in a Vorbis stream
-
- int[] timesubmap=new int[16]; // [mux]
- int[] floorsubmap=new int[16]; // [mux] submap to floors
- int[] residuesubmap=new int[16];// [mux] submap to residue
- int[] psysubmap=new int[16]; // [mux]; encode only
-
- int coupling_steps;
- int[] coupling_mag=new int[256];
- int[] coupling_ang=new int[256];
-
- void free(){
- chmuxlist=null;
- timesubmap=null;
- floorsubmap=null;
- residuesubmap=null;
- psysubmap=null;
-
- coupling_mag=null;
- coupling_ang=null;
- }
-}
-
-class LookMapping0{
- InfoMode mode;
- InfoMapping0 map;
- Object[] time_look;
- Object[] floor_look;
- Object[] floor_state;
- Object[] residue_look;
- PsyLook[] psy_look;
-
- FuncTime[] time_func;
- FuncFloor[] floor_func;
- FuncResidue[] residue_func;
-
- int ch;
- float[][] decay;
- int lastframe; // if a different mode is called, we need to
- // invalidate decay and floor state
-}
diff --git a/songdbj/com/jcraft/jorbis/Mdct.java b/songdbj/com/jcraft/jorbis/Mdct.java
deleted file mode 100644
index bd5cc38fb7..0000000000
--- a/songdbj/com/jcraft/jorbis/Mdct.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class Mdct{
-
- static private final float cPI3_8=0.38268343236508977175f;
- static private final float cPI2_8=0.70710678118654752441f;
- static private final float cPI1_8=0.92387953251128675613f;
-
- int n;
- int log2n;
-
- float[] trig;
- int[] bitrev;
-
- float scale;
-
- void init(int n){
- bitrev=new int[n/4];
- trig=new float[n+n/4];
-
- int n2=n>>>1;
- log2n=(int)Math.rint(Math.log(n)/Math.log(2));
- this.n=n;
-
-
- int AE=0;
- int AO=1;
- int BE=AE+n/2;
- int BO=BE+1;
- int CE=BE+n/2;
- int CO=CE+1;
- // trig lookups...
- for(int i=0;i<n/4;i++){
- trig[AE+i*2]=(float)Math.cos((Math.PI/n)*(4*i));
- trig[AO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i));
- trig[BE+i*2]=(float)Math.cos((Math.PI/(2*n))*(2*i+1));
- trig[BO+i*2]=(float)Math.sin((Math.PI/(2*n))*(2*i+1));
- }
- for(int i=0;i<n/8;i++){
- trig[CE+i*2]=(float)Math.cos((Math.PI/n)*(4*i+2));
- trig[CO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i+2));
- }
-
- {
- int mask=(1<<(log2n-1))-1;
- int msb=1<<(log2n-2);
- for(int i=0;i<n/8;i++){
- int acc=0;
- for(int j=0;msb>>>j!=0;j++)
- if(((msb>>>j)&i)!=0)acc|=1<<j;
- bitrev[i*2]=((~acc)&mask);
-// bitrev[i*2]=((~acc)&mask)-1;
- bitrev[i*2+1]=acc;
- }
- }
- scale=4.f/n;
- }
-
- void clear(){
- }
-
- void forward(float[] in, float[] out){
- }
-
- float[] _x=new float[1024];
- float[] _w=new float[1024];
-
- synchronized void backward(float[] in, float[] out){
- if(_x.length<n/2){_x=new float[n/2];}
- if(_w.length<n/2){_w=new float[n/2];}
- float[] x=_x;
- float[] w=_w;
- int n2=n>>>1;
- int n4=n>>>2;
- int n8=n>>>3;
-
- // rotate + step 1
- {
- int inO=1;
- int xO=0;
- int A=n2;
-
- int i;
- for(i=0;i<n8;i++){
- A-=2;
- x[xO++]=-in[inO+2]*trig[A+1] - in[inO]*trig[A];
- x[xO++]= in[inO]*trig[A+1] - in[inO+2]*trig[A];
- inO+=4;
- }
-
- inO=n2-4;
-
- for(i=0;i<n8;i++){
- A-=2;
- x[xO++]=in[inO]*trig[A+1] + in[inO+2]*trig[A];
- x[xO++]=in[inO]*trig[A] - in[inO+2]*trig[A+1];
- inO-=4;
- }
- }
-
- float[] xxx=mdct_kernel(x,w,n,n2,n4,n8);
- int xx=0;
-
- // step 8
-
- {
- int B=n2;
- int o1=n4,o2=o1-1;
- int o3=n4+n2,o4=o3-1;
-
- for(int i=0;i<n4;i++){
- float temp1= (xxx[xx] * trig[B+1] - xxx[xx+1] * trig[B]);
- float temp2=-(xxx[xx] * trig[B] + xxx[xx+1] * trig[B+1]);
-
- out[o1]=-temp1;
- out[o2]= temp1;
- out[o3]= temp2;
- out[o4]= temp2;
-
- o1++;
- o2--;
- o3++;
- o4--;
- xx+=2;
- B+=2;
- }
- }
- }
- private float[] mdct_kernel(float[] x, float[] w,
- int n, int n2, int n4, int n8){
- // step 2
-
- int xA=n4;
- int xB=0;
- int w2=n4;
- int A=n2;
-
- for(int i=0;i<n4;){
- float x0=x[xA] - x[xB];
- float x1;
- w[w2+i]=x[xA++]+x[xB++];
-
- x1=x[xA]-x[xB];
- A-=4;
-
- w[i++]= x0 * trig[A] + x1 * trig[A+1];
- w[i]= x1 * trig[A] - x0 * trig[A+1];
-
- w[w2+i]=x[xA++]+x[xB++];
- i++;
- }
-
- // step 3
-
- {
- for(int i=0;i<log2n-3;i++){
- int k0=n>>>(i+2);
- int k1=1<<(i+3);
- int wbase=n2-2;
-
- A=0;
- float[] temp;
-
- for(int r=0;r<(k0>>>2);r++){
- int w1=wbase;
- w2=w1-(k0>>1);
- float AEv= trig[A],wA;
- float AOv= trig[A+1],wB;
- wbase-=2;
-
- k0++;
- for(int s=0;s<(2<<i);s++){
- wB =w[w1] -w[w2];
- x[w1] =w[w1] +w[w2];
-
- wA =w[++w1] -w[++w2];
- x[w1] =w[w1] +w[w2];
-
- x[w2] =wA*AEv - wB*AOv;
- x[w2-1]=wB*AEv + wA*AOv;
-
- w1-=k0;
- w2-=k0;
- }
- k0--;
- A+=k1;
- }
-
- temp=w;
- w=x;
- x=temp;
- }
- }
-
- // step 4, 5, 6, 7
- {
- int C=n;
- int bit=0;
- int x1=0;
- int x2=n2-1;
-
- for(int i=0;i<n8;i++){
- int t1=bitrev[bit++];
- int t2=bitrev[bit++];
-
- float wA=w[t1]-w[t2+1];
- float wB=w[t1-1]+w[t2];
- float wC=w[t1]+w[t2+1];
- float wD=w[t1-1]-w[t2];
-
- float wACE=wA* trig[C];
- float wBCE=wB* trig[C++];
- float wACO=wA* trig[C];
- float wBCO=wB* trig[C++];
-
- x[x1++]=( wC+wACO+wBCE)*.5f;
- x[x2--]=(-wD+wBCO-wACE)*.5f;
- x[x1++]=( wD+wBCO-wACE)*.5f;
- x[x2--]=( wC-wACO-wBCE)*.5f;
- }
- }
- return(x);
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/PsyInfo.java b/songdbj/com/jcraft/jorbis/PsyInfo.java
deleted file mode 100644
index 599c41e52d..0000000000
--- a/songdbj/com/jcraft/jorbis/PsyInfo.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-// psychoacoustic setup
-class PsyInfo{
- int athp;
- int decayp;
- int smoothp;
- int noisefitp;
- int noisefit_subblock;
- float noisefit_threshdB;
-
- float ath_att;
-
- int tonemaskp;
- float[] toneatt_125Hz=new float[5];
- float[] toneatt_250Hz=new float[5];
- float[] toneatt_500Hz=new float[5];
- float[] toneatt_1000Hz=new float[5];
- float[] toneatt_2000Hz=new float[5];
- float[] toneatt_4000Hz=new float[5];
- float[] toneatt_8000Hz=new float[5];
-
- int peakattp;
- float[] peakatt_125Hz=new float[5];
- float[] peakatt_250Hz=new float[5];
- float[] peakatt_500Hz=new float[5];
- float[] peakatt_1000Hz=new float[5];
- float[] peakatt_2000Hz=new float[5];
- float[] peakatt_4000Hz=new float[5];
- float[] peakatt_8000Hz=new float[5];
-
- int noisemaskp;
- float[] noiseatt_125Hz=new float[5];
- float[] noiseatt_250Hz=new float[5];
- float[] noiseatt_500Hz=new float[5];
- float[] noiseatt_1000Hz=new float[5];
- float[] noiseatt_2000Hz=new float[5];
- float[] noiseatt_4000Hz=new float[5];
- float[] noiseatt_8000Hz=new float[5];
-
- float max_curve_dB;
-
- float attack_coeff;
- float decay_coeff;
-
- void free(){}
-}
diff --git a/songdbj/com/jcraft/jorbis/PsyLook.java b/songdbj/com/jcraft/jorbis/PsyLook.java
deleted file mode 100644
index 9da85edfb1..0000000000
--- a/songdbj/com/jcraft/jorbis/PsyLook.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-class PsyLook {
- int n;
- PsyInfo vi;
-
- float[][][] tonecurves;
- float[][] peakatt;
- float[][][] noisecurves;
-
- float[] ath;
- int[] octave;
-
- void init(PsyInfo vi, int n, int rate){
- /*
- float rate2=rate/2.;
- //memset(p,0,sizeof(vorbis_look_psy));
- ath=new float[n];
- octave=new int[n];
- this.vi=vi;
- this.n=n;
-
- // set up the lookups for a given blocksize and sample rate
- // Vorbis max sample rate is limited by 26 Bark (54kHz)
- set_curve(ATH_Bark_dB, ath,n,rate);
- for(int i=0;i<n;i++)
- ath[i]=fromdB(ath[i]+vi.ath_att);
-
- for(int i=0;i<n;i++){
- int oc=rint(toOC((i+.5)*rate2/n)*2.);
- if(oc<0)oc=0;
- if(oc>12)oc=12;
- octave[i]=oc;
- }
-
- tonecurves=malloc(13*sizeof(float **));
- noisecurves=malloc(13*sizeof(float **));
- peakatt=malloc(7*sizeof(float *));
- for(int i=0;i<13;i++){
- tonecurves[i]=malloc(9*sizeof(float *));
- noisecurves[i]=malloc(9*sizeof(float *));
- }
- for(i=0;i<7;i++)
- peakatt[i]=malloc(5*sizeof(float));
-
- for(i=0;i<13;i++){
- for(j=0;j<9;j++){
- tonecurves[i][j]=malloc(EHMER_MAX*sizeof(float));
- noisecurves[i][j]=malloc(EHMER_MAX*sizeof(float));
- }
- }
-
- // OK, yeah, this was a silly way to do it
- memcpy(tonecurves[0][2],tone_125_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[0][4],tone_125_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[0][6],tone_125_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[0][8],tone_125_100dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(tonecurves[2][2],tone_250_40dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[2][4],tone_250_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[2][6],tone_250_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[2][8],tone_250_80dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(tonecurves[4][2],tone_500_40dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[4][4],tone_500_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[4][6],tone_500_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[4][8],tone_500_100dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(tonecurves[6][2],tone_1000_40dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[6][4],tone_1000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[6][6],tone_1000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[6][8],tone_1000_100dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(tonecurves[8][2],tone_2000_40dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[8][4],tone_2000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[8][6],tone_2000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[8][8],tone_2000_100dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(tonecurves[10][2],tone_4000_40dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[10][4],tone_4000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[10][6],tone_4000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[10][8],tone_4000_100dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(tonecurves[12][2],tone_4000_40dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[12][4],tone_4000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[12][6],tone_8000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(tonecurves[12][8],tone_8000_100dB_SL,sizeof(float)*EHMER_MAX);
-
-
- memcpy(noisecurves[0][2],noise_500_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[0][4],noise_500_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[0][6],noise_500_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[0][8],noise_500_80dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(noisecurves[2][2],noise_500_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[2][4],noise_500_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[2][6],noise_500_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[2][8],noise_500_80dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(noisecurves[4][2],noise_500_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[4][4],noise_500_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[4][6],noise_500_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[4][8],noise_500_80dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(noisecurves[6][2],noise_1000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[6][4],noise_1000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[6][6],noise_1000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[6][8],noise_1000_80dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(noisecurves[8][2],noise_2000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[8][4],noise_2000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[8][6],noise_2000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[8][8],noise_2000_80dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(noisecurves[10][2],noise_4000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[10][4],noise_4000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[10][6],noise_4000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[10][8],noise_4000_80dB_SL,sizeof(float)*EHMER_MAX);
-
- memcpy(noisecurves[12][2],noise_4000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[12][4],noise_4000_60dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[12][6],noise_4000_80dB_SL,sizeof(float)*EHMER_MAX);
- memcpy(noisecurves[12][8],noise_4000_80dB_SL,sizeof(float)*EHMER_MAX);
-
- setup_curve(tonecurves[0],0,vi.toneatt_125Hz);
- setup_curve(tonecurves[2],2,vi.toneatt_250Hz);
- setup_curve(tonecurves[4],4,vi.toneatt_500Hz);
- setup_curve(tonecurves[6],6,vi.toneatt_1000Hz);
- setup_curve(tonecurves[8],8,vi.toneatt_2000Hz);
- setup_curve(tonecurves[10],10,vi.toneatt_4000Hz);
- setup_curve(tonecurves[12],12,vi.toneatt_8000Hz);
-
- setup_curve(noisecurves[0],0,vi.noiseatt_125Hz);
- setup_curve(noisecurves[2],2,vi.noiseatt_250Hz);
- setup_curve(noisecurves[4],4,vi.noiseatt_500Hz);
- setup_curve(noisecurves[6],6,vi.noiseatt_1000Hz);
- setup_curve(noisecurves[8],8,vi.noiseatt_2000Hz);
- setup_curve(noisecurves[10],10,vi.noiseatt_4000Hz);
- setup_curve(noisecurves[12],12,vi.noiseatt_8000Hz);
-
- for(i=1;i<13;i+=2){
- for(j=0;j<9;j++){
- interp_curve_dB(tonecurves[i][j],
- tonecurves[i-1][j],
- tonecurves[i+1][j],.5);
- interp_curve_dB(noisecurves[i][j],
- noisecurves[i-1][j],
- noisecurves[i+1][j],.5);
- }
- }
- for(i=0;i<5;i++){
- peakatt[0][i]=fromdB(vi.peakatt_125Hz[i]);
- peakatt[1][i]=fromdB(vi.peakatt_250Hz[i]);
- peakatt[2][i]=fromdB(vi.peakatt_500Hz[i]);
- peakatt[3][i]=fromdB(vi.peakatt_1000Hz[i]);
- peakatt[4][i]=fromdB(vi.peakatt_2000Hz[i]);
- peakatt[5][i]=fromdB(vi.peakatt_4000Hz[i]);
- peakatt[6][i]=fromdB(vi.peakatt_8000Hz[i]);
- }
- */
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/Residue0.java b/songdbj/com/jcraft/jorbis/Residue0.java
deleted file mode 100644
index be42518f1c..0000000000
--- a/songdbj/com/jcraft/jorbis/Residue0.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class Residue0 extends FuncResidue{
- void pack(Object vr, Buffer opb){
- InfoResidue0 info=(InfoResidue0)vr;
- int acc=0;
- opb.write(info.begin,24);
- opb.write(info.end,24);
-
- opb.write(info.grouping-1,24); /* residue vectors to group and
- code with a partitioned book */
- opb.write(info.partitions-1,6); /* possible partition choices */
- opb.write(info.groupbook,8); /* group huffman book */
-
- /* secondstages is a bitmask; as encoding progresses pass by pass, a
- bitmask of one indicates this partition class has bits to write
- this pass */
- for(int j=0;j<info.partitions;j++){
- if(ilog(info.secondstages[j])>3){
- /* yes, this is a minor hack due to not thinking ahead */
- opb.write(info.secondstages[j],3);
- opb.write(1,1);
- opb.write(info.secondstages[j]>>>3,5);
- }
- else{
- opb.write(info.secondstages[j],4); /* trailing zero */
- }
- acc+=icount(info.secondstages[j]);
- }
- for(int j=0;j<acc;j++){
- opb.write(info.booklist[j],8);
- }
- }
-
- Object unpack(Info vi, Buffer opb){
- int acc=0;
- InfoResidue0 info=new InfoResidue0();
-
- info.begin=opb.read(24);
- info.end=opb.read(24);
- info.grouping=opb.read(24)+1;
- info.partitions=opb.read(6)+1;
- info.groupbook=opb.read(8);
-
- for(int j=0;j<info.partitions;j++){
- int cascade=opb.read(3);
- if(opb.read(1)!=0){
- cascade|=(opb.read(5)<<3);
- }
- info.secondstages[j]=cascade;
- acc+=icount(cascade);
- }
-
- for(int j=0;j<acc;j++){
- info.booklist[j]=opb.read(8);
-// if(info.booklist[j]==255)info.booklist[j]=-1;
- }
-
- if(info.groupbook>=vi.books){
- free_info(info);
- return(null);
- }
-
- for(int j=0;j<acc;j++){
- if(info.booklist[j]>=vi.books){
- free_info(info);
- return(null);
- }
- }
- return(info);
-// errout:
-// free_info(info);
-// return(NULL);
- }
-
- Object look(DspState vd, InfoMode vm, Object vr){
- InfoResidue0 info=(InfoResidue0)vr;
- LookResidue0 look=new LookResidue0();
- int acc=0;
- int dim;
- int maxstage=0;
- look.info=info;
- look.map=vm.mapping;
-
- look.parts=info.partitions;
- look.fullbooks=vd.fullbooks;
- look.phrasebook=vd.fullbooks[info.groupbook];
-
- dim=look.phrasebook.dim;
-
- look.partbooks=new int[look.parts][];
-
- for(int j=0;j<look.parts;j++){
- int stages=ilog(info.secondstages[j]);
- if(stages!=0){
- if(stages>maxstage)maxstage=stages;
- look.partbooks[j]=new int[stages];
- for(int k=0; k<stages; k++){
- if((info.secondstages[j]&(1<<k))!=0){
- look.partbooks[j][k]=info.booklist[acc++];
- }
- }
- }
- }
-
- look.partvals=(int)Math.rint(Math.pow(look.parts,dim));
- look.stages=maxstage;
- look.decodemap=new int[look.partvals][];
- for(int j=0;j<look.partvals;j++){
- int val=j;
- int mult=look.partvals/look.parts;
- look.decodemap[j]=new int[dim];
-
- for(int k=0;k<dim;k++){
- int deco=val/mult;
- val-=deco*mult;
- mult/=look.parts;
- look.decodemap[j][k]=deco;
- }
- }
- return(look);
- }
- void free_info(Object i){}
- void free_look(Object i){}
- int forward(Block vb,Object vl, float[][] in, int ch){
- System.err.println("Residue0.forward: not implemented");
- return 0;
- }
-
- static int[][][] partword=new int[2][][]; // _01inverse is synchronized for
- // re-using partword
- synchronized static int _01inverse(Block vb, Object vl,
- float[][] in,int ch,int decodepart){
- int i,j,k,l,s;
- LookResidue0 look=(LookResidue0 )vl;
- InfoResidue0 info=look.info;
-
- // move all this setup out later
- int samples_per_partition=info.grouping;
- int partitions_per_word=look.phrasebook.dim;
- int n=info.end-info.begin;
-
- int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
-
- if(partword.length<ch){
- partword=new int[ch][][];
- for(j=0;j<ch;j++){
- partword[j]=new int[partwords][];
- }
- }
- else{
- for(j=0;j<ch;j++){
- if(partword[j]==null || partword[j].length<partwords)
- partword[j]=new int[partwords][];
- }
- }
-
- for(s=0;s<look.stages;s++){
- // each loop decodes on partition codeword containing
- // partitions_pre_word partitions
- for(i=0,l=0;i<partvals;l++){
- if(s==0){
- // fetch the partition word for each channel
- for(j=0;j<ch;j++){
- int temp=look.phrasebook.decode(vb.opb);
- if(temp==-1){
- //goto eopbreak;
- return(0);
- }
- partword[j][l]=look.decodemap[temp];
- if(partword[j][l]==null){
-// goto errout;
- return(0);
- }
- }
- }
-
- // now we decode residual values for the partitions
- for(k=0;k<partitions_per_word && i<partvals;k++,i++)
- for(j=0;j<ch;j++){
- int offset=info.begin+i*samples_per_partition;
- if((info.secondstages[partword[j][l][k]]&(1<<s))!=0){
- CodeBook stagebook=look.fullbooks[look.partbooks[partword[j][l][k]][s]];
-// CodeBook stagebook=look.partbooks[partword[j][l][k]][s];
- if(stagebook!=null){
- if(decodepart==0){
- if(stagebook.decodevs_add(in[j],offset,vb.opb,samples_per_partition)==-1){
- // goto errout;
- return(0);
- }
- }
- else if(decodepart==1){
- if(stagebook.decodev_add(in[j], offset, vb.opb,samples_per_partition)==-1){
- // goto errout;
- return(0);
- }
- }
- }
- }
- }
- }
- }
-// errout:
-// eopbreak:
- return(0);
- }
-
- static int _2inverse(Block vb, Object vl, float[][] in, int ch){
- int i,j,k,l,s;
- LookResidue0 look=(LookResidue0 )vl;
- InfoResidue0 info=look.info;
-
- // move all this setup out later
- int samples_per_partition=info.grouping;
- int partitions_per_word=look.phrasebook.dim;
- int n=info.end-info.begin;
-
- int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
-
- int[][] partword=new int[partwords][];
- for(s=0;s<look.stages;s++){
- for(i=0,l=0;i<partvals;l++){
- if(s==0){
- // fetch the partition word for each channel
- int temp=look.phrasebook.decode(vb.opb);
- if(temp==-1){
- // goto eopbreak;
- return(0);
- }
- partword[l]=look.decodemap[temp];
- if(partword[l]==null){
- // goto errout;
- return(0);
- }
- }
-
- // now we decode residual values for the partitions
- for(k=0;k<partitions_per_word && i<partvals;k++,i++){
- int offset=info.begin+i*samples_per_partition;
- if((info.secondstages[partword[l][k]]&(1<<s))!=0){
- CodeBook stagebook=look.fullbooks[look.partbooks[partword[l][k]][s]];
- if(stagebook!=null){
- if(stagebook.decodevv_add(in, offset, ch, vb.opb,samples_per_partition)==-1){
- // goto errout;
- return(0);
- }
- }
- }
- }
- }
- }
-// errout:
-// eopbreak:
- return(0);
- }
-
- int inverse(Block vb, Object vl, float[][] in, int[] nonzero, int ch){
- //System.err.println("Residue0.inverse");
- int used=0;
- for(int i=0;i<ch;i++){
- if(nonzero[i]!=0){
- in[used++]=in[i];
- }
- }
- if(used!=0)
- return(_01inverse(vb,vl,in,used,0));
- else
- return(0);
- }
-
-/*
- int inverse(Block vb, Object vl, float[][] in, int ch){
-//System.err.println("Residue0.inverse");
- int i,j,k,l,transend=vb.pcmend/2;
- LookResidue0 look=(LookResidue0 )vl;
- InfoResidue0 info=look.info;
-
- // move all this setup out later
- int samples_per_partition=info.grouping;
- int partitions_per_word=look.phrasebook.dim;
- int n=info.end-info.begin;
-
- int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
- int[][] partword=new int[ch][];
- float[] work=new float[samples_per_partition];
- partvals=partwords*partitions_per_word;
-
- // make sure we're zeroed up to the start
- for(j=0;j<ch;j++){
- for(k=0; k<info.begin; k++)in[j][k]=0.0f;
- }
-
- for(i=info.begin,l=0;i<info.end;){
- // fetch the partition word for each channel
- for(j=0;j<ch;j++){
- int temp=look.phrasebook.decode(vb.opb);
- if(temp==-1){
- //goto eopbreak;
- if(i<transend){
- for(j=0;j<ch;j++){
- for(k=0;k<transend-i;k++)in[j][i+k]=0.0f;
- }
- }
- return(0);
- }
- partword[j]=look.decodemap[temp];
- if(partword[j]==null){
- //goto errout;
- for(j=0;j<ch;j++){
- for(k=0;k<transend;k++)in[j][k]=0.0f;
- }
- return(0);
- }
- }
-
- // now we decode interleaved residual values for the partitions
- for(k=0;k<partitions_per_word;k++,l++,i+=samples_per_partition){
- for(j=0;j<ch;j++){
- int part=partword[j][k];
- if(decodepart(vb.opb,work, in[j], i,samples_per_partition,
- info.secondstages[part],
- look.partbooks[part])==-1){
- //goto eopbreak;
- if(i<transend){
- for(j=0;j<ch;j++){
- for(k=0;k<transend-i;k++)in[j][i+k]=0.0f;
- }
- }
- return(0);
- }
- }
- }
- }
-
-// eopbreak:
- if(i<transend){
- for(j=0;j<ch;j++){
- for(k=0;k<transend-i;k++)in[j][i+k]=0.0f;
- }
- }
- return(0);
-
-// errout:
-// for(j=0;j<ch;j++)
-// for(k=0;k<transend;k++)in[j][k]=0.0f;
-// return(0);
- }
- int decodepart(Buffer opb, float[] work, float[] vec, int veci,
- int n, int stages, CodeBook[] books){
- int i,j;
- for(i=0;i<n;i++)work[i]=0.0f;
-
- for(j=0;j<stages;j++){
- int dim=books[j].dim;
- int step=n/dim;
- for(i=0;i<step;i++){
- if(books[j].decodevs(work, i, opb, step, 0)==-1){
- return(-1);
- }
- }
- }
- for(i=0;i<n;i++){
- vec[veci+i]*=work[i];
- }
- return(0);
- }
-*/
-
- private static int ilog(int v){
- int ret=0;
- while(v!=0){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
- private static int icount(int v){
- int ret=0;
- while(v!=0){
- ret+=(v&1);
- v>>>=1;
- }
- return(ret);
- }
-}
-
-class LookResidue0 {
- InfoResidue0 info;
- int map;
-
- int parts;
- int stages;
- CodeBook[] fullbooks;
- CodeBook phrasebook;
- int[][] partbooks;
-// CodeBook[][] partbooks;
-
- int partvals;
- int[][] decodemap;
-
- int postbits;
- int phrasebits;
-// int[][] frames;
- int frames;
-}
-
-class InfoResidue0{
- // block-partitioned VQ coded straight residue
- int begin;
- int end;
-
- // first stage (lossless partitioning)
- int grouping; // group n vectors per partition
- int partitions; // possible codebooks for a partition
- int groupbook; // huffbook for partitioning
- int[] secondstages=new int[64]; // expanded out to pointers in lookup
- int[] booklist=new int[256]; // list of second stage books
-
- // encode-only heuristic settings
- float[] entmax=new float[64]; // book entropy threshholds
- float[] ampmax=new float[64]; // book amp threshholds
- int[] subgrp=new int[64]; // book heuristic subgroup size
- int[] blimit=new int[64]; // subgroup position limits
-}
diff --git a/songdbj/com/jcraft/jorbis/Residue1.java b/songdbj/com/jcraft/jorbis/Residue1.java
deleted file mode 100644
index c29ed8d671..0000000000
--- a/songdbj/com/jcraft/jorbis/Residue1.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class Residue1 extends Residue0{
- int forward(Block vb,Object vl, float[][] in, int ch){
- System.err.println("Residue0.forward: not implemented");
- return 0;
- }
-
- int inverse(Block vb, Object vl, float[][] in, int[] nonzero, int ch){
-//System.err.println("Residue0.inverse");
- int used=0;
- for(int i=0; i<ch; i++){
- if(nonzero[i]!=0){
- in[used++]=in[i];
- }
- }
- if(used!=0){
- return(_01inverse(vb,vl,in,used,1));
- }
- else{
- return 0;
- }
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/Residue2.java b/songdbj/com/jcraft/jorbis/Residue2.java
deleted file mode 100644
index 146a8341e5..0000000000
--- a/songdbj/com/jcraft/jorbis/Residue2.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class Residue2 extends Residue0{
- int forward(Block vb,Object vl, float[][] in, int ch){
- System.err.println("Residue0.forward: not implemented");
- return 0;
- }
-
- int inverse(Block vb, Object vl, float[][] in, int[] nonzero, int ch){
-//System.err.println("Residue0.inverse");
- int i=0;
- for(i=0;i<ch;i++)if(nonzero[i]!=0)break;
- if(i==ch)return(0); /* no nonzero vectors */
-
- return(_2inverse(vb,vl,in, ch));
- }
-}
diff --git a/songdbj/com/jcraft/jorbis/StaticCodeBook.java b/songdbj/com/jcraft/jorbis/StaticCodeBook.java
deleted file mode 100644
index 7d9d6dc232..0000000000
--- a/songdbj/com/jcraft/jorbis/StaticCodeBook.java
+++ /dev/null
@@ -1,588 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class StaticCodeBook{
- int dim; // codebook dimensions (elements per vector)
- int entries; // codebook entries
- int[] lengthlist; // codeword lengths in bits
-
- // mapping
- int maptype; // 0=none
- // 1=implicitly populated values from map column
- // 2=listed arbitrary values
-
- // The below does a linear, single monotonic sequence mapping.
- int q_min; // packed 32 bit float; quant value 0 maps to minval
- int q_delta; // packed 32 bit float; val 1 - val 0 == delta
- int q_quant; // bits: 0 < quant <= 16
- int q_sequencep; // bitflag
-
- // additional information for log (dB) mapping; the linear mapping
- // is assumed to actually be values in dB. encodebias is used to
- // assign an error weight to 0 dB. We have two additional flags:
- // zeroflag indicates if entry zero is to represent -Inf dB; negflag
- // indicates if we're to represent negative linear values in a
- // mirror of the positive mapping.
-
- int[] quantlist; // map == 1: (int)(entries/dim) element column map
- // map == 2: list of dim*entries quantized entry vals
-
- // encode helpers
- EncodeAuxNearestMatch nearest_tree;
- EncodeAuxThreshMatch thresh_tree;
-
- StaticCodeBook(){}
- StaticCodeBook(int dim, int entries, int[] lengthlist,
- int maptype, int q_min, int q_delta,
- int q_quant, int q_sequencep, int[] quantlist,
- //EncodeAuxNearestmatch nearest_tree,
- Object nearest_tree,
- // EncodeAuxThreshmatch thresh_tree,
- Object thresh_tree
- ){
- this();
- this.dim=dim; this.entries=entries; this.lengthlist=lengthlist;
- this.maptype=maptype; this.q_min=q_min; this.q_delta=q_delta;
- this.q_quant=q_quant; this.q_sequencep=q_sequencep;
- this.quantlist=quantlist;
- }
-
- int pack(Buffer opb){
- int i;
- boolean ordered=false;
-
- opb.write(0x564342,24);
- opb.write(dim, 16);
- opb.write(entries, 24);
-
- // pack the codewords. There are two packings; length ordered and
- // length random. Decide between the two now.
-
- for(i=1;i<entries;i++){
- if(lengthlist[i]<lengthlist[i-1])break;
- }
- if(i==entries)ordered=true;
-
- if(ordered){
- // length ordered. We only need to say how many codewords of
- // each length. The actual codewords are generated
- // deterministically
-
- int count=0;
- opb.write(1,1); // ordered
- opb.write(lengthlist[0]-1,5); // 1 to 32
-
- for(i=1;i<entries;i++){
- int _this=lengthlist[i];
- int _last=lengthlist[i-1];
- if(_this>_last){
- for(int j=_last;j<_this;j++){
- opb.write(i-count,ilog(entries-count));
- count=i;
- }
- }
- }
- opb.write(i-count,ilog(entries-count));
- }
- else{
- // length random. Again, we don't code the codeword itself, just
- // the length. This time, though, we have to encode each length
- opb.write(0,1); // unordered
-
- // algortihmic mapping has use for 'unused entries', which we tag
- // here. The algorithmic mapping happens as usual, but the unused
- // entry has no codeword.
- for(i=0;i<entries;i++){
- if(lengthlist[i]==0)break;
- }
-
- if(i==entries){
- opb.write(0,1); // no unused entries
- for(i=0;i<entries;i++){
- opb.write(lengthlist[i]-1,5);
- }
- }
- else{
- opb.write(1,1); // we have unused entries; thus we tag
- for(i=0;i<entries;i++){
- if(lengthlist[i]==0){
- opb.write(0,1);
- }
- else{
- opb.write(1,1);
- opb.write(lengthlist[i]-1,5);
- }
- }
- }
- }
-
- // is the entry number the desired return value, or do we have a
- // mapping? If we have a mapping, what type?
- opb.write(maptype,4);
- switch(maptype){
- case 0:
- // no mapping
- break;
- case 1:
- case 2:
- // implicitly populated value mapping
- // explicitly populated value mapping
- if(quantlist==null){
- // no quantlist? error
- return(-1);
- }
-
- // values that define the dequantization
- opb.write(q_min,32);
- opb.write(q_delta,32);
- opb.write(q_quant-1,4);
- opb.write(q_sequencep,1);
-
- {
- int quantvals=0;
- switch(maptype){
- case 1:
- // a single column of (c->entries/c->dim) quantized values for
- // building a full value list algorithmically (square lattice)
- quantvals=maptype1_quantvals();
- break;
- case 2:
- // every value (c->entries*c->dim total) specified explicitly
- quantvals=entries*dim;
- break;
- }
-
- // quantized values
- for(i=0;i<quantvals;i++){
- opb.write(Math.abs(quantlist[i]),q_quant);
- }
- }
- break;
- default:
- // error case; we don't have any other map types now
- return(-1);
- }
- return(0);
- }
-/*
-*/
-
- // unpacks a codebook from the packet buffer into the codebook struct,
- // readies the codebook auxiliary structures for decode
- int unpack(Buffer opb){
- int i;
- //memset(s,0,sizeof(static_codebook));
-
- // make sure alignment is correct
- if(opb.read(24)!=0x564342){
-// goto _eofout;
- clear();
- return(-1);
- }
-
- // first the basic parameters
- dim=opb.read(16);
- entries=opb.read(24);
- if(entries==-1){
-// goto _eofout;
- clear();
- return(-1);
- }
-
- // codeword ordering.... length ordered or unordered?
- switch(opb.read(1)){
- case 0:
- // unordered
- lengthlist=new int[entries];
-
- // allocated but unused entries?
- if(opb.read(1)!=0){
- // yes, unused entries
-
- for(i=0;i<entries;i++){
- if(opb.read(1)!=0){
- int num=opb.read(5);
- if(num==-1){
-// goto _eofout;
- clear();
- return(-1);
- }
- lengthlist[i]=num+1;
- }
- else{
- lengthlist[i]=0;
- }
- }
- }
- else{
- // all entries used; no tagging
- for(i=0;i<entries;i++){
- int num=opb.read(5);
- if(num==-1){
-// goto _eofout;
- clear();
- return(-1);
- }
- lengthlist[i]=num+1;
- }
- }
- break;
- case 1:
- // ordered
- {
- int length=opb.read(5)+1;
- lengthlist=new int[entries];
-
- for(i=0;i<entries;){
- int num=opb.read(ilog(entries-i));
- if(num==-1){
-// goto _eofout;
- clear();
- return(-1);
- }
- for(int j=0;j<num;j++,i++){
- lengthlist[i]=length;
- }
- length++;
- }
- }
- break;
- default:
- // EOF
- return(-1);
- }
-
- // Do we have a mapping to unpack?
- switch((maptype=opb.read(4))){
- case 0:
- // no mapping
- break;
- case 1:
- case 2:
- // implicitly populated value mapping
- // explicitly populated value mapping
- q_min=opb.read(32);
- q_delta=opb.read(32);
- q_quant=opb.read(4)+1;
- q_sequencep=opb.read(1);
-
- {
- int quantvals=0;
- switch(maptype){
- case 1:
- quantvals=maptype1_quantvals();
- break;
- case 2:
- quantvals=entries*dim;
- break;
- }
-
- // quantized values
- quantlist=new int[quantvals];
- for(i=0;i<quantvals;i++){
- quantlist[i]=opb.read(q_quant);
- }
- if(quantlist[quantvals-1]==-1){
-// goto _eofout;
- clear();
- return(-1);
- }
- }
- break;
- default:
-// goto _eofout;
- clear();
- return(-1);
- }
- // all set
- return(0);
-// _errout:
-// _eofout:
-// vorbis_staticbook_clear(s);
-// return(-1);
- }
-
- // there might be a straightforward one-line way to do the below
- // that's portable and totally safe against roundoff, but I haven't
- // thought of it. Therefore, we opt on the side of caution
- private int maptype1_quantvals(){
- int vals=(int)(Math.floor(Math.pow(entries,1./dim)));
-
- // the above *should* be reliable, but we'll not assume that FP is
- // ever reliable when bitstream sync is at stake; verify via integer
- // means that vals really is the greatest value of dim for which
- // vals^b->bim <= b->entries
- // treat the above as an initial guess
- while(true){
- int acc=1;
- int acc1=1;
- for(int i=0;i<dim;i++){
- acc*=vals;
- acc1*=vals+1;
- }
- if(acc<=entries && acc1>entries){ return(vals); }
- else{
- if(acc>entries){ vals--; }
- else{ vals++; }
- }
- }
- }
-
- void clear(){
-// if(quantlist!=null)free(b->quantlist);
-// if(lengthlist!=null)free(b->lengthlist);
-// if(nearest_tree!=null){
-// free(b->nearest_tree->ptr0);
-// free(b->nearest_tree->ptr1);
-// free(b->nearest_tree->p);
-// free(b->nearest_tree->q);
-// memset(b->nearest_tree,0,sizeof(encode_aux_nearestmatch));
-// free(b->nearest_tree);
-// }
-// if(thresh_tree!=null){
-// free(b->thresh_tree->quantthresh);
-// free(b->thresh_tree->quantmap);
-// memset(b->thresh_tree,0,sizeof(encode_aux_threshmatch));
-// free(b->thresh_tree);
-// }
-// memset(b,0,sizeof(static_codebook));
- }
-
- // unpack the quantized list of values for encode/decode
- // we need to deal with two map types: in map type 1, the values are
- // generated algorithmically (each column of the vector counts through
- // the values in the quant vector). in map type 2, all the values came
- // in in an explicit list. Both value lists must be unpacked
- float[] unquantize(){
-
- if(maptype==1 || maptype==2){
- int quantvals;
- float mindel=float32_unpack(q_min);
- float delta=float32_unpack(q_delta);
- float[] r=new float[entries*dim];
-
- //System.err.println("q_min="+q_min+", mindel="+mindel);
-
- // maptype 1 and 2 both use a quantized value vector, but
- // different sizes
- switch(maptype){
- case 1:
- // most of the time, entries%dimensions == 0, but we need to be
- // well defined. We define that the possible vales at each
- // scalar is values == entries/dim. If entries%dim != 0, we'll
- // have 'too few' values (values*dim<entries), which means that
- // we'll have 'left over' entries; left over entries use zeroed
- // values (and are wasted). So don't generate codebooks like that
- quantvals=maptype1_quantvals();
- for(int j=0;j<entries;j++){
- float last=0.f;
- int indexdiv=1;
- for(int k=0;k<dim;k++){
- int index=(j/indexdiv)%quantvals;
- float val=quantlist[index];
- val=Math.abs(val)*delta+mindel+last;
- if(q_sequencep!=0)last=val;
- r[j*dim+k]=val;
- indexdiv*=quantvals;
- }
- }
- break;
- case 2:
- for(int j=0;j<entries;j++){
- float last=0.f;
- for(int k=0;k<dim;k++){
- float val=quantlist[j*dim+k];
-//if((j*dim+k)==0){System.err.println(" | 0 -> "+val+" | ");}
- val=Math.abs(val)*delta+mindel+last;
- if(q_sequencep!=0)last=val;
- r[j*dim+k]=val;
-//if((j*dim+k)==0){System.err.println(" $ r[0] -> "+r[0]+" | ");}
- }
- }
-//System.err.println("\nr[0]="+r[0]);
- }
- return(r);
- }
- return(null);
- }
-
- private static int ilog(int v){
- int ret=0;
- while(v!=0){
- ret++;
- v>>>=1;
- }
- return(ret);
- }
-
- // 32 bit float (not IEEE; nonnormalized mantissa +
- // biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
- // Why not IEEE? It's just not that important here.
-
- static final int VQ_FEXP=10;
- static final int VQ_FMAN=21;
- static final int VQ_FEXP_BIAS=768; // bias toward values smaller than 1.
-
- // doesn't currently guard under/overflow
- static long float32_pack(float val){
- int sign=0;
- int exp;
- int mant;
- if(val<0){
- sign=0x80000000;
- val= -val;
- }
- exp=(int)Math.floor(Math.log(val)/Math.log(2));
- mant=(int)Math.rint(Math.pow(val,(VQ_FMAN-1)-exp));
- exp=(exp+VQ_FEXP_BIAS)<<VQ_FMAN;
- return(sign|exp|mant);
- }
-
- static float float32_unpack(int val){
- float mant=val&0x1fffff;
- float sign=val&0x80000000;
- float exp =(val&0x7fe00000)>>>VQ_FMAN;
-//System.err.println("mant="+mant+", sign="+sign+", exp="+exp);
- //if(sign!=0.0)mant= -mant;
- if((val&0x80000000)!=0)mant= -mant;
-//System.err.println("mant="+mant);
- return(ldexp(mant,((int)exp)-(VQ_FMAN-1)-VQ_FEXP_BIAS));
- }
-
- static float ldexp(float foo, int e){
- return (float)(foo*Math.pow(2, e));
- }
-
-/*
- // TEST
- // Unit tests of the dequantizer; this stuff will be OK
- // cross-platform, I simply want to be sure that special mapping cases
- // actually work properly; a bug could go unnoticed for a while
-
- // cases:
- //
- // no mapping
- // full, explicit mapping
- // algorithmic mapping
- //
- // nonsequential
- // sequential
-
- static int[] full_quantlist1={0,1,2,3, 4,5,6,7, 8,3,6,1};
- static int[] partial_quantlist1={0,7,2};
-
- // no mapping
- static StaticCodeBook test1=new StaticCodeBook(4,16,null,
- 0,0,0,0,0,
- null,null,null);
- static float[] test1_result=null;
-
- // linear, full mapping, nonsequential
- static StaticCodeBook test2=new StaticCodeBook(4,3,null,
- 2,-533200896,1611661312,4,0,
- full_quantlist1, null, null);
- static float[] test2_result={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2};
-
- // linear, full mapping, sequential
- static StaticCodeBook test3=new StaticCodeBook(4,3,null,
- 2, -533200896,1611661312,4,1,
- full_quantlist1,null, null);
- static float[] test3_result={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6};
-
- // linear, algorithmic mapping, nonsequential
- static StaticCodeBook test4=new StaticCodeBook(3,27,null,
- 1,-533200896,1611661312,4,0,
- partial_quantlist1,null,null);
- static float[] test4_result={-3,-3,-3, 4,-3,-3, -1,-3,-3,
- -3, 4,-3, 4, 4,-3, -1, 4,-3,
- -3,-1,-3, 4,-1,-3, -1,-1,-3,
- -3,-3, 4, 4,-3, 4, -1,-3, 4,
- -3, 4, 4, 4, 4, 4, -1, 4, 4,
- -3,-1, 4, 4,-1, 4, -1,-1, 4,
- -3,-3,-1, 4,-3,-1, -1,-3,-1,
- -3, 4,-1, 4, 4,-1, -1, 4,-1,
- -3,-1,-1, 4,-1,-1, -1,-1,-1};
-
- // linear, algorithmic mapping, sequential
- static StaticCodeBook test5=new StaticCodeBook(3,27,null,
- 1,-533200896,1611661312,4,1,
- partial_quantlist1,null,null);
- static float[] test5_result={-3,-6,-9, 4, 1,-2, -1,-4,-7,
- -3, 1,-2, 4, 8, 5, -1, 3, 0,
- -3,-4,-7, 4, 3, 0, -1,-2,-5,
- -3,-6,-2, 4, 1, 5, -1,-4, 0,
- -3, 1, 5, 4, 8,12, -1, 3, 7,
- -3,-4, 0, 4, 3, 7, -1,-2, 2,
- -3,-6,-7, 4, 1, 0, -1,-4,-5,
- -3, 1, 0, 4, 8, 7, -1, 3, 2,
- -3,-4,-5, 4, 3, 2, -1,-2,-3};
-
- void run_test(float[] comp){
- float[] out=unquantize();
- if(comp!=null){
- if(out==null){
- System.err.println("_book_unquantize incorrectly returned NULL");
- System.exit(1);
- }
- for(int i=0;i<entries*dim;i++){
- if(Math.abs(out[i]-comp[i])>.0001){
- System.err.println("disagreement in unquantized and reference data:\nposition "+i+": "+out[i]+" != "+comp[i]);
- System.exit(1);
- }
- }
- }
- else{
- if(out!=null){
- System.err.println("_book_unquantize returned a value array:\n correct result should have been NULL");
- System.exit(1);
- }
- }
- }
-
- public static void main(String[] arg){
- // run the nine dequant tests, and compare to the hand-rolled results
- System.err.print("Dequant test 1... ");
- test1.run_test(test1_result);
- System.err.print("OK\nDequant test 2... ");
- test2.run_test(test2_result);
- System.err.print("OK\nDequant test 3... ");
- test3.run_test(test3_result);
- System.err.print("OK\nDequant test 4... ");
- test4.run_test(test4_result);
- System.err.print("OK\nDequant test 5... ");
- test5.run_test(test5_result);
- System.err.print("OK\n\n");
- }
-*/
-}
-
-
-
-
-
diff --git a/songdbj/com/jcraft/jorbis/Time0.java b/songdbj/com/jcraft/jorbis/Time0.java
deleted file mode 100644
index f6a9fcb077..0000000000
--- a/songdbj/com/jcraft/jorbis/Time0.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-class Time0 extends FuncTime{
- void pack(Object i, Buffer opb){}
- Object unpack(Info vi , Buffer opb){return "";}
- Object look(DspState vd, InfoMode mi, Object i){return "";}
- void free_info(Object i){}
- void free_look(Object i){}
- int forward(Block vb, Object i){return 0;}
- int inverse(Block vb, Object i, float[] in, float[] out){return 0;}
-}
diff --git a/songdbj/com/jcraft/jorbis/VorbisFile.java b/songdbj/com/jcraft/jorbis/VorbisFile.java
deleted file mode 100644
index 64edff006e..0000000000
--- a/songdbj/com/jcraft/jorbis/VorbisFile.java
+++ /dev/null
@@ -1,1361 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-public class VorbisFile{
- static final int CHUNKSIZE=8500;
- static final int SEEK_SET=0;
- static final int SEEK_CUR=1;
- static final int SEEK_END=2;
-
- static final int OV_FALSE=-1;
- static final int OV_EOF=-2;
- static final int OV_HOLE=-3;
-
- static final int OV_EREAD=-128;
- static final int OV_EFAULT=-129;
- static final int OV_EIMPL=-130;
- static final int OV_EINVAL=-131;
- static final int OV_ENOTVORBIS=-132;
- static final int OV_EBADHEADER=-133;
- static final int OV_EVERSION=-134;
- static final int OV_ENOTAUDIO=-135;
- static final int OV_EBADPACKET=-136;
- static final int OV_EBADLINK=-137;
- static final int OV_ENOSEEK=-138;
-
- InputStream datasource;
- boolean seekable=false;
- long offset;
- long end;
-
- SyncState oy=new SyncState();
-
- int links;
- long[] offsets;
- long[] dataoffsets;
- int[] serialnos;
- long[] pcmlengths;
- Info[] vi;
- Comment[] vc;
-
- // Decoding working state local storage
- long pcm_offset;
- boolean decode_ready=false;
- int current_serialno;
- int current_link;
-
- float bittrack;
- float samptrack;
-
- StreamState os=new StreamState(); // take physical pages, weld into a logical
- // stream of packets
- DspState vd=new DspState(); // central working state for
- // the packet->PCM decoder
- Block vb=new Block(vd); // local working space for packet->PCM decode
-
- //ov_callbacks callbacks;
-
- public VorbisFile(String file) throws JOrbisException {
- super();
- InputStream is=null;
- try{
- is=new SeekableInputStream(file);
- int ret=open(is, null, 0);
- if(ret==-1){
- throw new JOrbisException("VorbisFile: open return -1");
- }
- }
- catch(Exception e){
- throw new JOrbisException("VorbisFile: "+e.toString());
- }
- finally{
- if(is != null){
- try {
- is.close();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public VorbisFile(InputStream is, byte[] initial, int ibytes)
- throws JOrbisException {
- super();
- int ret=open(is, initial, ibytes);
- if(ret==-1){
- }
- }
-
- private int get_data(){
- int index=oy.buffer(CHUNKSIZE);
- byte[] buffer=oy.data;
-// int bytes=callbacks.read_func(buffer, index, 1, CHUNKSIZE, datasource);
- int bytes=0;
- try{
- bytes=datasource.read(buffer, index, CHUNKSIZE);
- }
- catch(Exception e){
- //System.err.println(e);
- return OV_EREAD;
- }
- oy.wrote(bytes);
- if(bytes==-1){
-// System.out.println("bytes="+bytes);
- bytes=0;
- }
- return bytes;
- }
-
- private void seek_helper(long offst){
- //callbacks.seek_func(datasource, offst, SEEK_SET);
- fseek(datasource, offst, SEEK_SET);
- this.offset=offst;
- oy.reset();
- }
-
- private int get_next_page(Page page, long boundary){
- if(boundary>0) boundary+=offset;
- while(true){
- int more;
- if(boundary>0 && offset>=boundary)return OV_FALSE;
- more=oy.pageseek(page);
- if(more<0){offset-=more;}
- else{
- if(more==0){
- if(boundary==0)return OV_FALSE;
-// if(get_data()<=0)return -1;
- int ret=get_data();
- if(ret==0) return OV_EOF;
- if(ret<0) return OV_EREAD;
- }
- else{
- int ret=(int)offset; //!!!
- offset+=more;
- return ret;
- }
- }
- }
- }
-
- private int get_prev_page(Page page) throws JOrbisException {
- long begin=offset; //!!!
- int ret;
- int offst=-1;
- while(offst==-1){
- begin-=CHUNKSIZE;
- if(begin<0)
- begin=0;
- seek_helper(begin);
- while(offset<begin+CHUNKSIZE){
- ret=get_next_page(page, begin+CHUNKSIZE-offset);
- if(ret==OV_EREAD){ return OV_EREAD; }
- if(ret<0){
- if(offst == -1)
- throw new JOrbisException();
- break;
- }
- else{ offst=ret; }
- }
- }
- seek_helper(offst); //!!!
- ret=get_next_page(page, CHUNKSIZE);
- if(ret<0){
- //System.err.println("Missed page fencepost at end of logical bitstream Exiting");
- //System.exit(1);
- return OV_EFAULT;
- }
- return offst;
- }
-
- int bisect_forward_serialno(long begin, long searched, long end, int currentno, int m){
- long endsearched=end;
- long next=end;
- Page page=new Page();
- int ret;
-
- while(searched<endsearched){
- long bisect;
- if(endsearched-searched<CHUNKSIZE){
- bisect=searched;
- }
- else{
- bisect=(searched+endsearched)/2;
- }
-
- seek_helper(bisect);
- ret=get_next_page(page, -1);
- if(ret==OV_EREAD) return OV_EREAD;
- if(ret<0 || page.serialno()!=currentno){
- endsearched=bisect;
- if(ret>=0)next=ret;
- }
- else{
- searched=ret+page.header_len+page.body_len;
- }
- }
- seek_helper(next);
- ret=get_next_page(page, -1);
- if(ret==OV_EREAD) return OV_EREAD;
-
- if(searched>=end || ret==-1){
- links=m+1;
- offsets=new long[m+2];
- offsets[m+1]=searched;
- }
- else{
- ret=bisect_forward_serialno(next, offset, end, page.serialno(), m+1);
- if(ret==OV_EREAD)return OV_EREAD;
- }
- offsets[m]=begin;
- return 0;
- }
-
- // uses the local ogg_stream storage in vf; this is important for
- // non-streaming input sources
- int fetch_headers(Info vi, Comment vc, int[] serialno, Page og_ptr){
- //System.err.println("fetch_headers");
- Page og=new Page();
- Packet op=new Packet();
- int ret;
-
- if(og_ptr==null){
- ret=get_next_page(og, CHUNKSIZE);
- if(ret==OV_EREAD)return OV_EREAD;
- if(ret<0) return OV_ENOTVORBIS;
- og_ptr=og;
- }
-
- if(serialno!=null)serialno[0]=og_ptr.serialno();
-
- os.init(og_ptr.serialno());
-
- // extract the initial header from the first page and verify that the
- // Ogg bitstream is in fact Vorbis data
-
- vi.init();
- vc.init();
-
- int i=0;
- while(i<3){
- os.pagein(og_ptr);
- while(i<3){
- int result=os.packetout(op);
- if(result==0)break;
- if(result==-1){
- //System.err.println("Corrupt header in logical bitstream.");
- //goto bail_header;
- vi.clear();
- vc.clear();
- os.clear();
- return -1;
- }
- if(vi.synthesis_headerin(vc, op)!=0){
- //System.err.println("Illegal header in logical bitstream.");
- //goto bail_header;
- vi.clear();
- vc.clear();
- os.clear();
- return -1;
- }
- i++;
- }
- if(i<3)
- if(get_next_page(og_ptr, 1)<0){
- //System.err.println("Missing header in logical bitstream.");
- //goto bail_header;
- vi.clear();
- vc.clear();
- os.clear();
- return -1;
- }
- }
- return 0;
-
-// bail_header:
-// vorbis_info_clear(vi);
-// vorbis_comment_clear(vc);
-// ogg_stream_clear(&vf->os);
-// return -1;
- }
-
- // last step of the OggVorbis_File initialization; get all the
- // vorbis_info structs and PCM positions. Only called by the seekable
- // initialization (local stream storage is hacked slightly; pay
- // attention to how that's done)
- void prefetch_all_headers(Info first_i,Comment first_c,
- int dataoffset) throws JOrbisException {
- Page og=new Page();
- int ret;
-
- vi=new Info[links];
- vc=new Comment[links];
- dataoffsets=new long[links];
- pcmlengths=new long[links];
- serialnos=new int[links];
-
- for(int i=0;i<links;i++){
- if(first_i!=null && first_c!=null && i==0){
- // we already grabbed the initial header earlier. This just
- // saves the waste of grabbing it again
- // !!!!!!!!!!!!!
- vi[i]=first_i;
- //memcpy(vf->vi+i,first_i,sizeof(vorbis_info));
- vc[i]=first_c;
- //memcpy(vf->vc+i,first_c,sizeof(vorbis_comment));
- dataoffsets[i]=dataoffset;
- }
- else{
- // seek to the location of the initial header
- seek_helper(offsets[i]); //!!!
- vi[i]=new Info();
- vc[i]=new Comment();
- if(fetch_headers(vi[i], vc[i], null, null)==-1){
- //System.err.println("Error opening logical bitstream #"+(i+1)+"\n");
- dataoffsets[i]=-1;
- }
- else{
- dataoffsets[i]=offset;
- os.clear();
- }
- }
-
- // get the serial number and PCM length of this link. To do this,
- // get the last page of the stream
- {
- long end=offsets[i+1]; //!!!
- seek_helper(end);
-
- while(true){
- ret=get_prev_page(og);
- if(ret==-1){
- // this should not be possible
- //System.err.println("Could not find last page of logical "+
- // "bitstream #"+(i)+"\n");
- vi[i].clear();
- vc[i].clear();
- break;
- }
- if(og.granulepos()!=-1){
- serialnos[i]=og.serialno();
- pcmlengths[i]=og.granulepos();
- break;
- }
- }
- }
- }
- }
-
- int make_decode_ready(){
- if(decode_ready)System.exit(1);
- vd.synthesis_init(vi[0]);
- vb.init(vd);
- decode_ready=true;
- return(0);
- }
-
- int open_seekable() throws JOrbisException {
- Info initial_i=new Info();
- Comment initial_c=new Comment();
- int serialno;
- long end;
- int ret;
- int dataoffset;
- Page og=new Page();
- // is this even vorbis...?
- int[] foo=new int[1];
- ret=fetch_headers(initial_i, initial_c, foo, null);
- serialno=foo[0];
- dataoffset=(int)offset; //!!
- os.clear();
- if(ret==-1)return(-1);
- // we can seek, so set out learning all about this file
- seekable=true;
- //(callbacks.seek_func)(datasource, 0, SEEK_END);
- fseek(datasource, 0, SEEK_END);
- //offset=end=(callbacks.tell_func)(datasource);
- offset=ftell(datasource);
- end=offset;
- // We get the offset for the last page of the physical bitstream.
- // Most OggVorbis files will contain a single logical bitstream
- end=get_prev_page(og);
- // moer than one logical bitstream?
- if(og.serialno()!=serialno){
- // Chained bitstream. Bisect-search each logical bitstream
- // section. Do so based on serial number only
- if(bisect_forward_serialno(0,0,end+1,serialno,0)<0){
- clear();
- return OV_EREAD;
- }
- }
- else{
- // Only one logical bitstream
- if(bisect_forward_serialno(0,end,end+1,serialno,0)<0){
- clear();
- return OV_EREAD;
- }
- }
- prefetch_all_headers(initial_i, initial_c, dataoffset);
- return(raw_seek(0));
- }
-
- int open_nonseekable(){
- //System.err.println("open_nonseekable");
- // we cannot seek. Set up a 'single' (current) logical bitstream entry
- links=1;
- vi=new Info[links]; vi[0]=new Info(); // ??
- vc=new Comment[links]; vc[0]=new Comment(); // ?? bug?
-
- // Try to fetch the headers, maintaining all the storage
- int[]foo=new int[1];
- if(fetch_headers(vi[0], vc[0], foo, null)==-1)return(-1);
- current_serialno=foo[0];
- make_decode_ready();
- return 0;
- }
-
- // clear out the current logical bitstream decoder
- void decode_clear(){
- os.clear();
- vd.clear();
- vb.clear();
- decode_ready=false;
- bittrack=0.f;
- samptrack=0.f;
- }
-
- // fetch and process a packet. Handles the case where we're at a
- // bitstream boundary and dumps the decoding machine. If the decoding
- // machine is unloaded, it loads it. It also keeps pcm_offset up to
- // date (seek and read both use this. seek uses a special hack with
- // readp).
- //
- // return: -1) hole in the data (lost packet)
- // 0) need more date (only if readp==0)/eof
- // 1) got a packet
-
- int process_packet(int readp){
- Page og=new Page();
-
- // handle one packet. Try to fetch it from current stream state
- // extract packets from page
- while(true){
- // process a packet if we can. If the machine isn't loaded,
- // neither is a page
- if(decode_ready){
- Packet op=new Packet();
- int result=os.packetout(op);
- long granulepos;
- // if(result==-1)return(-1); // hole in the data. For now, swallow
- // and go. We'll need to add a real
- // error code in a bit.
- if(result>0){
- // got a packet. process it
- granulepos=op.granulepos;
- if(vb.synthesis(op)==0){ // lazy check for lazy
- // header handling. The
- // header packets aren't
- // audio, so if/when we
- // submit them,
- // vorbis_synthesis will
- // reject them
- // suck in the synthesis data and track bitrate
- {
- int oldsamples=vd.synthesis_pcmout(null, null);
- vd.synthesis_blockin(vb);
- samptrack+=vd.synthesis_pcmout(null, null)-oldsamples;
- bittrack+=op.bytes*8;
- }
-
- // update the pcm offset.
- if(granulepos!=-1 && op.e_o_s==0){
- int link=(seekable?current_link:0);
- int samples;
- // this packet has a pcm_offset on it (the last packet
- // completed on a page carries the offset) After processing
- // (above), we know the pcm position of the *last* sample
- // ready to be returned. Find the offset of the *first*
- //
- // As an aside, this trick is inaccurate if we begin
- // reading anew right at the last page; the end-of-stream
- // granulepos declares the last frame in the stream, and the
- // last packet of the last page may be a partial frame.
- // So, we need a previous granulepos from an in-sequence page
- // to have a reference point. Thus the !op.e_o_s clause above
-
- samples=vd.synthesis_pcmout(null, null);
- granulepos-=samples;
- for(int i=0;i<link;i++){
- granulepos+=pcmlengths[i];
- }
- pcm_offset=granulepos;
- }
- return(1);
- }
- }
- }
-
- if(readp==0)return(0);
- if(get_next_page(og,-1)<0)return(0); // eof. leave unitialized
-
- // bitrate tracking; add the header's bytes here, the body bytes
- // are done by packet above
- bittrack+=og.header_len*8;
-
- // has our decoding just traversed a bitstream boundary?
- if(decode_ready){
- if(current_serialno!=og.serialno()){
- decode_clear();
- }
- }
-
- // Do we need to load a new machine before submitting the page?
- // This is different in the seekable and non-seekable cases.
- //
- // In the seekable case, we already have all the header
- // information loaded and cached; we just initialize the machine
- // with it and continue on our merry way.
- //
- // In the non-seekable (streaming) case, we'll only be at a
- // boundary if we just left the previous logical bitstream and
- // we're now nominally at the header of the next bitstream
-
- if(!decode_ready){
- int i;
- if(seekable){
- current_serialno=og.serialno();
-
- // match the serialno to bitstream section. We use this rather than
- // offset positions to avoid problems near logical bitstream
- // boundaries
- for(i=0;i<links;i++){
- if(serialnos[i]==current_serialno)break;
- }
- if(i==links)return(-1); // sign of a bogus stream. error out,
- // leave machine uninitialized
- current_link=i;
-
- os.init(current_serialno);
- os.reset();
-
- }
- else{
- // we're streaming
- // fetch the three header packets, build the info struct
- int foo[]=new int[1];
- int ret=fetch_headers(vi[0], vc[0], foo, og);
- current_serialno=foo[0];
- if(ret!=0)return ret;
- current_link++;
- i=0;
- }
- make_decode_ready();
- }
- os.pagein(og);
- }
- }
-
- //The helpers are over; it's all toplevel interface from here on out
- // clear out the OggVorbis_File struct
- int clear(){
- vb.clear();
- vd.clear();
- os.clear();
-
- if(vi!=null && links!=0){
- for(int i=0;i<links;i++){
- vi[i].clear();
- vc[i].clear();
- }
- vi=null;
- vc=null;
- }
- if(dataoffsets!=null)dataoffsets=null;
- if(pcmlengths!=null)pcmlengths=null;
- if(serialnos!=null)serialnos=null;
- if(offsets!=null)offsets=null;
- oy.clear();
- //if(datasource!=null)(vf->callbacks.close_func)(vf->datasource);
- //memset(vf,0,sizeof(OggVorbis_File));
- return(0);
- }
-
- static int fseek(InputStream fis,
- //int64_t off,
- long off,
- int whence){
- if(fis instanceof SeekableInputStream){
- SeekableInputStream sis=(SeekableInputStream)fis;
- try{
- if(whence==SEEK_SET){
- sis.seek(off);
- }
- else if(whence==SEEK_END){
- sis.seek(sis.getLength()-off);
- }
- else{
- //System.out.println("seek: "+whence+" is not supported");
- }
- }
- catch(Exception e){
- }
- return 0;
- }
- try{
- if(whence==0){ fis.reset(); }
- fis.skip(off);
- }
- catch(Exception e){return -1;}
- return 0;
- }
-
- static long ftell(InputStream fis){
- try{
- if(fis instanceof SeekableInputStream){
- SeekableInputStream sis=(SeekableInputStream)fis;
- return (sis.tell());
- }
- }
- catch(Exception e){
- }
- return 0;
- }
-
- // inspects the OggVorbis file and finds/documents all the logical
- // bitstreams contained in it. Tries to be tolerant of logical
- // bitstream sections that are truncated/woogie.
- //
- // return: -1) error
- // 0) OK
-
- int open(InputStream is, byte[] initial, int ibytes) throws JOrbisException {
- //callbacks callbacks = {
- // (size_t (*)(void *, size_t, size_t, void *)) fread,
- // (int (*)(void *, int64_t, int)) _fseek,
- // (int (*)(void *)) fclose,
- // (long (*)(void *)) ftell
- // };
- return open_callbacks(is, initial, ibytes//, callbacks
- );
- }
-
- int open_callbacks(InputStream is, byte[] initial,
- int ibytes//, callbacks callbacks
- ) throws JOrbisException {
- int ret;
- datasource=is;
- //callbacks = _callbacks;
- // init the framing state
- oy.init();
-
- // perhaps some data was previously read into a buffer for testing
- // against other stream types. Allow initialization from this
- // previously read data (as we may be reading from a non-seekable
- // stream)
- if(initial!=null){
- int index=oy.buffer(ibytes);
- System.arraycopy(initial, 0, oy.data, index, ibytes);
- oy.wrote(ibytes);
- }
- // can we seek? Stevens suggests the seek test was portable
- if(is instanceof SeekableInputStream){ ret=open_seekable(); }
- else{ ret=open_nonseekable(); }
- if(ret!=0){
- datasource=null;
- clear();
- }
- return ret;
- }
-
- // How many logical bitstreams in this physical bitstream?
- public int streams(){
- return links;
- }
-
- // Is the FILE * associated with vf seekable?
- public boolean seekable(){
- return seekable;
- }
-
- // returns the bitrate for a given logical bitstream or the entire
- // physical bitstream. If the file is open for random access, it will
- // find the *actual* average bitrate. If the file is streaming, it
- // returns the nominal bitrate (if set) else the average of the
- // upper/lower bounds (if set) else -1 (unset).
- //
- // If you want the actual bitrate field settings, get them from the
- // vorbis_info structs
-
- public int bitrate(int i){
- if(i>=links)return(-1);
- if(!seekable && i!=0)return(bitrate(0));
- if(i<0){
- long bits=0;
- for(int j=0;j<links;j++){
- bits+=(offsets[j+1]-dataoffsets[j])*8;
- }
- return((int)Math.rint(bits/time_total(-1)));
- }
- else{
- if(seekable){
- // return the actual bitrate
- return((int)Math.rint((offsets[i+1]-dataoffsets[i])*8/time_total(i)));
- }
- else{
- // return nominal if set
- if(vi[i].bitrate_nominal>0){
- return vi[i].bitrate_nominal;
- }
- else{
- if(vi[i].bitrate_upper>0){
- if(vi[i].bitrate_lower>0){
- return (vi[i].bitrate_upper+vi[i].bitrate_lower)/2;
- }else{
- return vi[i].bitrate_upper;
- }
- }
- return(-1);
- }
- }
- }
- }
-
- // returns the actual bitrate since last call. returns -1 if no
- // additional data to offer since last call (or at beginning of stream)
- public int bitrate_instant(){
- int _link=(seekable?current_link:0);
- if(samptrack==0)return(-1);
- int ret=(int)(bittrack/samptrack*vi[_link].rate+.5);
- bittrack=0.f;
- samptrack=0.f;
- return(ret);
- }
-
- public int serialnumber(int i){
- if(i>=links)return(-1);
- if(!seekable && i>=0)return(serialnumber(-1));
- if(i<0){
- return(current_serialno);
- }
- else{
- return(serialnos[i]);
- }
- }
-
- // returns: total raw (compressed) length of content if i==-1
- // raw (compressed) length of that logical bitstream for i==0 to n
- // -1 if the stream is not seekable (we can't know the length)
-
- public long raw_total(int i){
- if(!seekable || i>=links)return(-1);
- if(i<0){
- long acc=0; // bug?
- for(int j=0;j<links;j++){
- acc+=raw_total(j);
- }
- return(acc);
- }
- else{
- return(offsets[i+1]-offsets[i]);
- }
- }
-
- // returns: total PCM length (samples) of content if i==-1
- // PCM length (samples) of that logical bitstream for i==0 to n
- // -1 if the stream is not seekable (we can't know the length)
- public long pcm_total(int i){
- if(!seekable || i>=links)return(-1);
- if(i<0){
- long acc=0;
- for(int j=0;j<links;j++){
- acc+=pcm_total(j);
- }
- return(acc);
- }
- else{
- return(pcmlengths[i]);
- }
- }
-
- // returns: total seconds of content if i==-1
- // seconds in that logical bitstream for i==0 to n
- // -1 if the stream is not seekable (we can't know the length)
- public float time_total(int i){
- if(!seekable || i>=links)return(-1);
- if(i<0){
- float acc=0;
- for(int j=0;j<links;j++){
- acc+=time_total(j);
- }
- return(acc);
- }
- else{
- return((float)(pcmlengths[i])/vi[i].rate);
- }
- }
-
- // seek to an offset relative to the *compressed* data. This also
- // immediately sucks in and decodes pages to update the PCM cursor. It
- // will cross a logical bitstream boundary, but only if it can't get
- // any packets out of the tail of the bitstream we seek to (so no
- // surprises).
- //
- // returns zero on success, nonzero on failure
-
- public int raw_seek(int pos){
- if(!seekable)return(-1); // don't dump machine if we can't seek
- if(pos<0 || pos>offsets[links]){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-
- // clear out decoding machine state
- pcm_offset=-1;
- decode_clear();
-
- // seek
- seek_helper(pos);
-
- // we need to make sure the pcm_offset is set. We use the
- // _fetch_packet helper to process one packet with readp set, then
- // call it until it returns '0' with readp not set (the last packet
- // from a page has the 'granulepos' field set, and that's how the
- // helper updates the offset
-
- switch(process_packet(1)){
- case 0:
- // oh, eof. There are no packets remaining. Set the pcm offset to
- // the end of file
- pcm_offset=pcm_total(-1);
- return(0);
- case -1:
- // error! missing data or invalid bitstream structure
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- default:
- // all OK
- break;
- }
- while(true){
- switch(process_packet(0)){
- case 0:
- // the offset is set. If it's a bogus bitstream with no offset
- // information, it's not but that's not our fault. We still run
- // gracefully, we're just missing the offset
- return(0);
- case -1:
- // error! missing data or invalid bitstream structure
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- default:
- // continue processing packets
- break;
- }
- }
-
- // seek_error:
- // dump the machine so we're in a known state
- //pcm_offset=-1;
- //decode_clear();
- //return -1;
- }
-
- // seek to a sample offset relative to the decompressed pcm stream
- // returns zero on success, nonzero on failure
-
- public int pcm_seek(long pos){
- int link=-1;
- long total=pcm_total(-1);
-
- if(!seekable)return(-1); // don't dump machine if we can't seek
- if(pos<0 || pos>total){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-
- // which bitstream section does this pcm offset occur in?
- for(link=links-1;link>=0;link--){
- total-=pcmlengths[link];
- if(pos>=total)break;
- }
-
- // search within the logical bitstream for the page with the highest
- // pcm_pos preceeding (or equal to) pos. There is a danger here;
- // missing pages or incorrect frame number information in the
- // bitstream could make our task impossible. Account for that (it
- // would be an error condition)
- {
- long target=pos-total;
- long end=offsets[link+1];
- long begin=offsets[link];
- int best=(int)begin;
-
- Page og=new Page();
- while(begin<end){
- long bisect;
- int ret;
-
- if(end-begin<CHUNKSIZE){
- bisect=begin;
- }
- else{
- bisect=(end+begin)/2;
- }
-
- seek_helper(bisect);
- ret=get_next_page(og,end-bisect);
-
- if(ret==-1){
- end=bisect;
- }
- else{
- long granulepos=og.granulepos();
- if(granulepos<target){
- best=ret; // raw offset of packet with granulepos
- begin=offset; // raw offset of next packet
- }
- else{
- end=bisect;
- }
- }
- }
- // found our page. seek to it (call raw_seek).
- if(raw_seek(best)!=0){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
- }
-
- // verify result
- if(pcm_offset>=pos){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
- if(pos>pcm_total(-1)){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-
- // discard samples until we reach the desired position. Crossing a
- // logical bitstream boundary with abandon is OK.
- while(pcm_offset<pos){
- float[][] pcm;
- int target=(int)(pos-pcm_offset);
- float[][][] _pcm=new float[1][][];
- int[] _index=new int[getInfo(-1).channels];
- int samples=vd.synthesis_pcmout(_pcm, _index);
- pcm=_pcm[0];
-
- if(samples>target)samples=target;
- vd.synthesis_read(samples);
- pcm_offset+=samples;
-
- if(samples<target)
- if(process_packet(1)==0){
- pcm_offset=pcm_total(-1); // eof
- }
- }
- return 0;
-
- // seek_error:
- // dump machine so we're in a known state
- //pcm_offset=-1;
- //decode_clear();
- //return -1;
- }
-
- // seek to a playback time relative to the decompressed pcm stream
- // returns zero on success, nonzero on failure
- int time_seek(float seconds){
- // translate time to PCM position and call pcm_seek
-
- int link=-1;
- long pcm_total=pcm_total(-1);
- float time_total=time_total(-1);
-
- if(!seekable)return(-1); // don't dump machine if we can't seek
- if(seconds<0 || seconds>time_total){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-
- // which bitstream section does this time offset occur in?
- for(link=links-1;link>=0;link--){
- pcm_total-=pcmlengths[link];
- time_total-=time_total(link);
- if(seconds>=time_total)break;
- }
-
- // enough information to convert time offset to pcm offset
- {
- long target=(long)(pcm_total+(seconds-time_total)*vi[link].rate);
- return(pcm_seek(target));
- }
-
- //seek_error:
- // dump machine so we're in a known state
- //pcm_offset=-1;
- //decode_clear();
- //return -1;
- }
-
- // tell the current stream offset cursor. Note that seek followed by
- // tell will likely not give the set offset due to caching
- public long raw_tell(){
- return(offset);
- }
-
- // return PCM offset (sample) of next PCM sample to be read
- public long pcm_tell(){
- return(pcm_offset);
- }
-
- // return time offset (seconds) of next PCM sample to be read
- public float time_tell(){
- // translate time to PCM position and call pcm_seek
-
- int link=-1;
- long pcm_total=0;
- float time_total=0.f;
-
- if(seekable){
- pcm_total=pcm_total(-1);
- time_total=time_total(-1);
-
- // which bitstream section does this time offset occur in?
- for(link=links-1;link>=0;link--){
- pcm_total-=pcmlengths[link];
- time_total-=time_total(link);
- if(pcm_offset>=pcm_total)break;
- }
- }
-
- return((float)time_total+(float)(pcm_offset-pcm_total)/vi[link].rate);
- }
-
- // link: -1) return the vorbis_info struct for the bitstream section
- // currently being decoded
- // 0-n) to request information for a specific bitstream section
- //
- // In the case of a non-seekable bitstream, any call returns the
- // current bitstream. NULL in the case that the machine is not
- // initialized
-
- public Info getInfo(int link){
- if(seekable){
- if(link<0){
- if(decode_ready){
- return vi[current_link];
- }
- else{
- return null;
- }
- }
- else{
- if(link>=links){
- return null;
- }
- else{
- return vi[link];
- }
- }
- }
- else{
- if(decode_ready){
- return vi[0];
- }
- else{
- return null;
- }
- }
- }
-
- public Comment getComment(int link){
- if(seekable){
- if(link<0){
- if(decode_ready){ return vc[current_link]; }
- else{ return null; }
- }
- else{
- if(link>=links){ return null;}
- else{ return vc[link]; }
- }
- }
- else{
- if(decode_ready){ return vc[0]; }
- else{ return null; }
- }
- }
-
- int host_is_big_endian() {
- return 1;
-// short pattern = 0xbabe;
-// unsigned char *bytewise = (unsigned char *)&pattern;
-// if (bytewise[0] == 0xba) return 1;
-// assert(bytewise[0] == 0xbe);
-// return 0;
- }
-
- // up to this point, everything could more or less hide the multiple
- // logical bitstream nature of chaining from the toplevel application
- // if the toplevel application didn't particularly care. However, at
- // the point that we actually read audio back, the multiple-section
- // nature must surface: Multiple bitstream sections do not necessarily
- // have to have the same number of channels or sampling rate.
- //
- // read returns the sequential logical bitstream number currently
- // being decoded along with the PCM data in order that the toplevel
- // application can take action on channel/sample rate changes. This
- // number will be incremented even for streamed (non-seekable) streams
- // (for seekable streams, it represents the actual logical bitstream
- // index within the physical bitstream. Note that the accessor
- // functions above are aware of this dichotomy).
- //
- // input values: buffer) a buffer to hold packed PCM data for return
- // length) the byte length requested to be placed into buffer
- // bigendianp) should the data be packed LSB first (0) or
- // MSB first (1)
- // word) word size for output. currently 1 (byte) or
- // 2 (16 bit short)
- //
- // return values: -1) error/hole in data
- // 0) EOF
- // n) number of bytes of PCM actually returned. The
- // below works on a packet-by-packet basis, so the
- // return length is not related to the 'length' passed
- // in, just guaranteed to fit.
- //
- // *section) set to the logical bitstream number
-
- int read(byte[] buffer,int length,
- int bigendianp, int word, int sgned, int[] bitstream){
- int host_endian = host_is_big_endian();
- int index=0;
-
- while(true){
- if(decode_ready){
- float[][] pcm;
- float[][][] _pcm=new float[1][][];
- int[] _index=new int[getInfo(-1).channels];
- int samples=vd.synthesis_pcmout(_pcm, _index);
- pcm=_pcm[0];
- if(samples!=0){
- // yay! proceed to pack data into the byte buffer
- int channels=getInfo(-1).channels;
- int bytespersample=word * channels;
- if(samples>length/bytespersample)samples=length/bytespersample;
-
- // a tight loop to pack each size
- {
- int val;
- if(word==1){
- int off=(sgned!=0?0:128);
- for(int j=0;j<samples;j++){
- for(int i=0;i<channels;i++){
- val=(int)(pcm[i][_index[i]+j]*128. + 0.5);
- if(val>127)val=127;
- else if(val<-128)val=-128;
- buffer[index++]=(byte)(val+off);
- }
- }
- }
- else{
- int off=(sgned!=0?0:32768);
-
- if(host_endian==bigendianp){
- if(sgned!=0){
- for(int i=0;i<channels;i++) { // It's faster in this order
- int src=_index[i];
- int dest=i;
- for(int j=0;j<samples;j++) {
- val=(int)(pcm[i][src+j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- buffer[dest]=(byte)(val>>>8);
- buffer[dest+1]=(byte)(val);
- dest+=channels*2;
- }
- }
- }
- else{
- for(int i=0;i<channels;i++) {
- float[] src=pcm[i];
- int dest=i;
- for(int j=0;j<samples;j++) {
- val=(int)(src[j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- buffer[dest]=(byte)((val+off)>>>8);
- buffer[dest+1]=(byte)(val+off);
- dest+=channels*2;
- }
- }
- }
- }
- else if(bigendianp!=0){
- for(int j=0;j<samples;j++){
- for(int i=0;i<channels;i++){
- val=(int)(pcm[i][j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- val+=off;
- buffer[index++]=(byte)(val>>>8);
- buffer[index++]=(byte)val;
- }
- }
- }
- else{
- //int val;
- for(int j=0;j<samples;j++){
- for(int i=0;i<channels;i++){
- val=(int)(pcm[i][j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- val+=off;
- buffer[index++]=(byte)val;
- buffer[index++]=(byte)(val>>>8);
- }
- }
- }
- }
- }
-
- vd.synthesis_read(samples);
- pcm_offset+=samples;
- if(bitstream!=null)bitstream[0]=current_link;
- return(samples*bytespersample);
- }
- }
-
- // suck in another packet
- switch(process_packet(1)){
- case 0:
- return(0);
- case -1:
- return -1;
- default:
- break;
- }
- }
- }
-
- public Info[] getInfo(){return vi;}
- public Comment[] getComment(){return vc;}
-
-/*
- public static void main(String[] arg){
- try{
- VorbisFile foo=new VorbisFile(arg[0]);
- int links=foo.streams();
- System.out.println("links="+links);
- Comment[] comment=foo.getComment();
- Info[] info=foo.getInfo();
- for(int i=0; i<links; i++){
- System.out.println(info[i]);
- System.out.println(comment[i]);
- }
- System.out.println("raw_total: "+foo.raw_total(-1));
- System.out.println("pcm_total: "+foo.pcm_total(-1));
- System.out.println("time_total: "+foo.time_total(-1));
- }
- catch(Exception e){
- System.err.println(e);
- }
- }
-*/
-
- public void close() throws java.io.IOException {
- datasource.close();
- }
-
- class SeekableInputStream extends InputStream {
- java.io.RandomAccessFile raf=null;
- final String mode="r";
- private SeekableInputStream(){
- }
- SeekableInputStream(String file) throws java.io.IOException{
- raf=new java.io.RandomAccessFile(file, mode);
- }
- public int read() throws java.io.IOException{
- return raf.read();
- }
- public int read(byte[] buf) throws java.io.IOException{
- return raf.read(buf);
- }
- public int read(byte[] buf , int s, int len) throws java.io.IOException{
- return raf.read(buf, s, len);
- }
- public long skip(long n) throws java.io.IOException{
- return (long)(raf.skipBytes((int)n));
- }
- public long getLength() throws java.io.IOException{
- return raf.length();
- }
- public long tell() throws java.io.IOException{
- return raf.getFilePointer();
- }
- public int available() throws java.io.IOException{
- return (raf.length()==raf.getFilePointer())? 0 : 1;
- }
- public void close() throws java.io.IOException{
- raf.close();
- }
- public synchronized void mark(int m){
- }
- public synchronized void reset() throws java.io.IOException{
- }
- public boolean markSupported(){
- return false;
- }
- public void seek(long pos) throws java.io.IOException{
- raf.seek(pos);
- }
- }
-
-}
diff --git a/songdbj/com/jcraft/jorbis/VorbisFile.java.new b/songdbj/com/jcraft/jorbis/VorbisFile.java.new
deleted file mode 100644
index 1f822b0991..0000000000
--- a/songdbj/com/jcraft/jorbis/VorbisFile.java.new
+++ /dev/null
@@ -1,1240 +0,0 @@
-/* JOrbis
- * Copyright (C) 2000 ymnk, JCraft,Inc.
- *
- * Written by: 2000 ymnk<ymnk@jcraft.com>
- *
- * Many thanks to
- * Monty <monty@xiph.org> and
- * The XIPHOPHORUS Company http://www.xiph.org/ .
- * JOrbis has been based on their awesome works, Vorbis codec.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package com.jcraft.jorbis;
-
-import com.jcraft.jogg.*;
-import java.io.InputStream;
-
-public class VorbisFile{
- static final int CHUNKSIZE=4096;
- static final int SEEK_SET=0;
-
- InputStream datasource;
- boolean seekable=false;
- long offset;
- long end;
-
- SyncState oy=new SyncState();
-
- int links;
- Comment[] vc;
- Info[] vi;
-
- long[] offsets;
- long[] dataoffsets;
- int[] serialnos;
- long[] pcmlengths;
-
-
-
- // Decoding working state local storage
- long pcm_offset;
- boolean decode_ready=false;
- int current_serialno;
- int current_link;
-
- float bittrack;
- float samptrack;
-
- StreamState os=new StreamState(); // take physical pages, weld into a logical
- // stream of packets
- DspState vd=new DspState(); // central working state for
- // the packet->PCM decoder
- Block vb=new Block(vd); // local working space for packet->PCM decode
-
- //ov_callbacks callbacks;
-
- public VorbisFile(String file) throws JOrbisException {
- super();
- InputStream is=null;
- try{ is=new java.io.BufferedInputStream(new java.io.FileInputStream(file));}
- catch(Exception e){
- throw new JOrbisException("VorbisFile: "+e.toString());
- }
- int ret=open(is, null, 0);
- if(ret==-1){
- throw new JOrbisException("VorbisFile: open return -1");
- }
- }
-
- public VorbisFile(InputStream is, byte[] initial, int ibytes)
- throws JOrbisException {
- super();
- int ret=open(is, initial, ibytes);
- if(ret==-1){
- }
- }
-
- private int get_data(){
- int index=oy.buffer(CHUNKSIZE);
- byte[] buffer=oy.data;
-// int bytes=callbacks.read_func(buffer, index, 1, CHUNKSIZE, datasource);
- int bytes=0;
- try{
- bytes=datasource.read(buffer, index, CHUNKSIZE);
- }
- catch(Exception e){System.err.println(e);}
- oy.wrote(bytes);
- return bytes;
- }
-
- private void seek_helper(int offst){
- //callbacks.seek_func(datasource, offst, SEEK_SET);
- fseek64_wrap(datasource, offst, SEEK_SET);
- this.offset=offst;
- oy.reset();
- }
-
- private int get_next_page(Page page, int boundary){
- if(boundary>0) boundary+=offset;
- while(true){
- int more;
- if(boundary>0 && offset>=boundary)return -1;
- more=oy.pageseek(page);
- if(more<0){offset-=more;}
- else{
- if(more==0){
- if(boundary==0)return -1;
- if(get_data()<=0)return -1;
- }
- else{
- int ret=(int)offset; //!!!
- offset+=more;
- return ret;
- }
- }
- }
- }
-
- private int get_prev_page(Page page){
- int begin=(int)offset; //!!!
- int ret;
- int offst=-1;
- while(offst==-1){
- begin-=CHUNKSIZE;
- seek_helper(begin);
- while(offset<begin+CHUNKSIZE){
- ret=get_next_page(page, begin+CHUNKSIZE-((int)offset));
- if(ret==-1){ break; }
- else{ offst=ret; }
- }
- }
- seek_helper((int)offset); //!!!
- ret=get_next_page(page, CHUNKSIZE);
- if(ret==-1){
- System.err.println("Missed page fencepost at end of logical bitstream Exiting");
- System.exit(1);
- }
- return offst;
- }
-
- void bisect_forward_serialno(int begin, int searched, int end, int currentno, int m){
- int endsearched=end;
- int next=end;
- Page page=new Page();
- int ret;
- while(searched<endsearched){
- int bisect;
- if(endsearched-searched<CHUNKSIZE){
- bisect=searched;
- }
- else{
- bisect=(searched+endsearched)/2;
- }
-
- seek_helper(bisect);
- ret=get_next_page(page, -1);
- if(ret<0 || page.serialno()!=currentno){
- endsearched=bisect;
- if(ret>=0)next=ret;
- }
- else{
- searched=ret+page.header_len+page.body_len;
- }
- }
- seek_helper(next);
- ret=get_next_page(page, -1);
-
- if(searched>=end || ret==-1){
- links=m+1;
- offsets=new long[m+2];
- offsets[m+1]=searched;
- }
- else{
- bisect_forward_serialno(next, (int)offset, end, page.serialno(), m+1);
- }
- offsets[m]=begin;
- }
-
- // uses the local ogg_stream storage in vf; this is important for
- // non-streaming input sources
- int fetch_headers(Info vi, Comment vc, int[] serialno){
- //System.err.println("fetch_headers");
- Page og=new Page();
- Packet op=new Packet();
- int ret;
-
- ret=get_next_page(og, CHUNKSIZE);
- if(ret==-1){
- System.err.println("Did not find initial header for bitstream.");
- return -1;
- }
-
- if(serialno!=null)serialno[0]=og.serialno();
-
- os.init(og.serialno());
-
- // extract the initial header from the first page and verify that the
- // Ogg bitstream is in fact Vorbis data
-
- vi.init();
- vc.init();
-
- int i=0;
- while(i<3){
- os.pagein(og);
- while(i<3){
- int result=os.packetout(op);
- if(result==0)break;
- if(result==-1){
- System.err.println("Corrupt header in logical bitstream.");
- //goto bail_header;
- vi.clear();
- vc.clear();
- os.clear();
- return -1;
- }
- if(vi.synthesis_headerin(vc, op)!=0){
- System.err.println("Illegal header in logical bitstream.");
- //goto bail_header;
- vi.clear();
- vc.clear();
- os.clear();
- return -1;
- }
- i++;
- }
- if(i<3)
- if(get_next_page(og, 1)<0){
- System.err.println("Missing header in logical bitstream.");
- //goto bail_header;
- vi.clear();
- vc.clear();
- os.clear();
- return -1;
- }
- }
- return 0;
-
-// bail_header:
-// vorbis_info_clear(vi);
-// vorbis_comment_clear(vc);
-// ogg_stream_clear(&vf->os);
-// return -1;
- }
-
- // last step of the OggVorbis_File initialization; get all the
- // vorbis_info structs and PCM positions. Only called by the seekable
- // initialization (local stream storage is hacked slightly; pay
- // attention to how that's done)
- void prefetch_all_headers(Info first_i,Comment first_c, int dataoffset){
- Page og=new Page();
- int ret;
-
- vi=new Info[links];
- vc=new Comment[links];
- dataoffsets=new long[links];
- pcmlengths=new long[links];
- serialnos=new int[links];
-
- for(int i=0;i<links;i++){
- if(first_i!=null && first_c!=null && i==0){
- // we already grabbed the initial header earlier. This just
- // saves the waste of grabbing it again
- // !!!!!!!!!!!!!
- vi[i]=first_i;
- //memcpy(vf->vi+i,first_i,sizeof(vorbis_info));
- vc[i]=first_c;
- //memcpy(vf->vc+i,first_c,sizeof(vorbis_comment));
- dataoffsets[i]=dataoffset;
- }
- else{
- // seek to the location of the initial header
- seek_helper((int)offsets[i]); //!!!
- if(fetch_headers(vi[i], vc[i], null)==-1){
- System.err.println("Error opening logical bitstream #"+(i+1)+"\n");
- dataoffsets[i]=-1;
- }
- else{
- dataoffsets[i]=offset;
- os.clear();
- }
- }
-
- // get the serial number and PCM length of this link. To do this,
- // get the last page of the stream
- {
- int end=(int)offsets[i+1]; //!!!
- seek_helper(end);
-
- while(true){
- ret=get_prev_page(og);
- if(ret==-1){
- // this should not be possible
- System.err.println("Could not find last page of logical "+
- "bitstream #"+(i)+"\n");
- vi[i].clear();
- vc[i].clear();
- break;
- }
- if(og.granulepos()!=-1){
- serialnos[i]=og.serialno();
- pcmlengths[i]=og.granulepos();
- break;
- }
- }
- }
- }
- }
-
- int make_decode_ready(){
- if(decode_ready)System.exit(1);
- vd.synthesis_init(vi[0]);
- vb.init(vd);
- decode_ready=true;
- return(0);
- }
-
- int open_seekable(){
- Info initial_i=new Info();
- Comment initial_c=new Comment();
- int serialno,end;
- int ret;
- int dataoffset;
- Page og=new Page();
-System.out.println("open_seekable");
- // is this even vorbis...?
- int[] foo=new int[1];
- ret=fetch_headers(initial_i, initial_c, foo);
- serialno=foo[0];
- dataoffset=(int)offset; //!!
- os.clear();
- if(ret==-1)return(-1);
-
- // we can seek, so set out learning all about this file
- seekable=true;
- //(callbacks.seek_func)(datasource, 0, SEEK_END);
- fseek64_wrap(datasource, (int)offset, SEEK_SET);
- //offset=end=(callbacks.tell_func)(datasource);
- end=(int)offset;
-
- // We get the offset for the last page of the physical bitstream.
- // Most OggVorbis files will contain a single logical bitstream
- end=get_prev_page(og);
-
- // moer than one logical bitstream?
- if(og.serialno()!=serialno){
- // Chained bitstream. Bisect-search each logical bitstream
- // section. Do so based on serial number only
- bisect_forward_serialno(0,0,end+1,serialno,0);
- }
- else{
- // Only one logical bitstream
- bisect_forward_serialno(0,end,end+1,serialno,0);
- }
- prefetch_all_headers(initial_i, initial_c, dataoffset);
-
-System.out.println("?");
- return(raw_seek(0));
- }
-
- int open_nonseekable(){
- //System.err.println("open_nonseekable");
- // we cannot seek. Set up a 'single' (current) logical bitstream entry
- links=1;
- vi=new Info[links]; vi[0]=new Info(); // ??
- vc=new Comment[links]; vc[0]=new Comment(); // ?? bug?
-
- // Try to fetch the headers, maintaining all the storage
- int[]foo=new int[1];
- if(fetch_headers(vi[0], vc[0], foo)==-1)return(-1);
- current_serialno=foo[0];
- make_decode_ready();
- return 0;
- }
-
- // clear out the current logical bitstream decoder
- void decode_clear(){
- os.clear();
- vd.clear();
- vb.clear();
- decode_ready=false;
- bittrack=0.f;
- samptrack=0.f;
- }
-
- // fetch and process a packet. Handles the case where we're at a
- // bitstream boundary and dumps the decoding machine. If the decoding
- // machine is unloaded, it loads it. It also keeps pcm_offset up to
- // date (seek and read both use this. seek uses a special hack with
- // readp).
- //
- // return: -1) hole in the data (lost packet)
- // 0) need more date (only if readp==0)/eof
- // 1) got a packet
-
- int process_packet(int readp){
-System.out.println("porcess_packet:"+ readp+" , decode_ready="+decode_ready);
- Page og=new Page();
-
- // handle one packet. Try to fetch it from current stream state
- // extract packets from page
- while(true){
- // process a packet if we can. If the machine isn't loaded,
- // neither is a page
- if(decode_ready){
- Packet op=new Packet();
- int result=os.packetout(op);
- long granulepos;
- // if(result==-1)return(-1); // hole in the data. For now, swallow
- // and go. We'll need to add a real
- // error code in a bit.
- if(result>0){
- // got a packet. process it
- granulepos=op.granulepos;
- if(vb.synthesis(op)==0){ // lazy check for lazy
- // header handling. The
- // header packets aren't
- // audio, so if/when we
- // submit them,
- // vorbis_synthesis will
- // reject them
- // suck in the synthesis data and track bitrate
- {
- int oldsamples=vd.synthesis_pcmout(null, null);
- vd.synthesis_blockin(vb);
- samptrack+=vd.synthesis_pcmout(null, null)-oldsamples;
- bittrack+=op.bytes*8;
- }
-
- // update the pcm offset.
- if(granulepos!=-1 && op.e_o_s==0){
- int link=(seekable?current_link:0);
- int samples;
- // this packet has a pcm_offset on it (the last packet
- // completed on a page carries the offset) After processing
- // (above), we know the pcm position of the *last* sample
- // ready to be returned. Find the offset of the *first*
- //
- // As an aside, this trick is inaccurate if we begin
- // reading anew right at the last page; the end-of-stream
- // granulepos declares the last frame in the stream, and the
- // last packet of the last page may be a partial frame.
- // So, we need a previous granulepos from an in-sequence page
- // to have a reference point. Thus the !op.e_o_s clause above
-
- samples=vd.synthesis_pcmout(null, null);
- granulepos-=samples;
- for(int i=0;i<link;i++){
- granulepos+=pcmlengths[i];
- }
- pcm_offset=granulepos;
- }
- return(1);
- }
- }
- }
-
- if(readp==0)return(0);
- if(get_next_page(og,-1)<0)return(0); // eof. leave unitialized
-
- // bitrate tracking; add the header's bytes here, the body bytes
- // are done by packet above
- bittrack+=og.header_len*8;
-
- // has our decoding just traversed a bitstream boundary?
- if(decode_ready){
- if(current_serialno!=og.serialno()){
- decode_clear();
- }
- }
-
- // Do we need to load a new machine before submitting the page?
- // This is different in the seekable and non-seekable cases.
- //
- // In the seekable case, we already have all the header
- // information loaded and cached; we just initialize the machine
- // with it and continue on our merry way.
- //
- // In the non-seekable (streaming) case, we'll only be at a
- // boundary if we just left the previous logical bitstream and
- // we're now nominally at the header of the next bitstream
-
- if(!decode_ready){
- int i;
- if(seekable){
- current_serialno=og.serialno();
-
- // match the serialno to bitstream section. We use this rather than
- // offset positions to avoid problems near logical bitstream
- // boundaries
- for(i=0;i<links;i++){
- if(serialnos[i]==current_serialno)break;
- }
- if(i==links)return(-1); // sign of a bogus stream. error out,
- // leave machine uninitialized
- current_link=i;
-
- os.init(current_serialno);
- os.reset();
-
- }
- else{
- // we're streaming
- // fetch the three header packets, build the info struct
- int foo[]=new int[1];
- fetch_headers(vi[0], vc[0], foo);
- current_serialno=foo[0];
- current_link++;
- i=0;
- }
- make_decode_ready();
- }
- os.pagein(og);
- }
- }
-
- //The helpers are over; it's all toplevel interface from here on out
- // clear out the OggVorbis_File struct
- int clear(){
- vb.clear();
- vd.clear();
- os.clear();
-
- if(vi!=null && links!=0){
- for(int i=0;i<links;i++){
- vi[i].clear();
- vc[i].clear();
- }
- vi=null;
- vc=null;
- }
- if(dataoffsets!=null)dataoffsets=null;
- if(pcmlengths!=null)pcmlengths=null;
- if(serialnos!=null)serialnos=null;
- if(offsets!=null)offsets=null;
- oy.clear();
- //if(datasource!=null)(vf->callbacks.close_func)(vf->datasource);
- //memset(vf,0,sizeof(OggVorbis_File));
- return(0);
- }
-
- static int fseek64_wrap(InputStream fis,
- //int64_t off,
- int off,
- int whence){
-
- if(!fis.markSupported()){ return -1; }
- try{
- try{if(whence==0){ fis.reset(); }}
- catch(Exception ee){System.out.println(ee);}
- fis.skip(off);
- }
- catch(Exception e){ System.out.println(e);
- //return -1;
- }
- return 0;
- }
-
- // inspects the OggVorbis file and finds/documents all the logical
- // bitstreams contained in it. Tries to be tolerant of logical
- // bitstream sections that are truncated/woogie.
- //
- // return: -1) error
- // 0) OK
-
- int open(InputStream is, byte[] initial, int ibytes){
- return open_callbacks(is, initial, ibytes//, callbacks
- );
- }
-
- int open_callbacks(InputStream is, byte[] initial,
- int ibytes//, callbacks callbacks
- ){
-// int offset=callbacks.seek_func(f,0,SEEK_CUR);
- int _offset=fseek64_wrap(is, (int)offset, SEEK_SET);
- int ret;
- // memset(vf,0,sizeof(OggVorbis_File));
- datasource=is;
- //callbacks = _callbacks;
-
- // init the framing state
- oy.init();
-
- // perhaps some data was previously read into a buffer for testing
- // against other stream types. Allow initialization from this
- // previously read data (as we may be reading from a non-seekable
- // stream)
- if(initial!=null){
- int index=oy.buffer(ibytes);
- System.arraycopy(initial, 0, oy.data, index, ibytes);
- oy.wrote(ibytes);
- }
-
-System.out.println("open_callbacks="+_offset);
- // can we seek? Stevens suggests the seek test was portable
- if(_offset!=-1){ ret=open_seekable(); }
- else{ ret=open_nonseekable(); }
-
-System.out.println("ret="+ret);
-
- if(ret!=0){
- datasource=null;
- clear();
- }
-
- return(ret);
- }
-
- // How many logical bitstreams in this physical bitstream?
- public int streams(){
- return links;
- }
-
- // Is the FILE * associated with vf seekable?
- public boolean seekable(){
- return seekable;
- }
-
- // returns the bitrate for a given logical bitstream or the entire
- // physical bitstream. If the file is open for random access, it will
- // find the *actual* average bitrate. If the file is streaming, it
- // returns the nominal bitrate (if set) else the average of the
- // upper/lower bounds (if set) else -1 (unset).
- //
- // If you want the actual bitrate field settings, get them from the
- // vorbis_info structs
-
- public int bitrate(int i){
- if(i>=links)return(-1);
- if(!seekable && i!=0)return(bitrate(0));
- if(i<0){
- long bits=0;
- for(int j=0;j<links;j++){
- bits+=(offsets[j+1]-dataoffsets[j])*8;
- }
- return((int)Math.rint(bits/time_total(-1)));
- }
- else{
- if(seekable){
- // return the actual bitrate
- return((int)Math.rint((offsets[i+1]-dataoffsets[i])*8/time_total(i)));
- }
- else{
- // return nominal if set
- if(vi[i].bitrate_nominal>0){
- return vi[i].bitrate_nominal;
- }
- else{
- if(vi[i].bitrate_upper>0){
- if(vi[i].bitrate_lower>0){
- return (vi[i].bitrate_upper+vi[i].bitrate_lower)/2;
- }else{
- return vi[i].bitrate_upper;
- }
- }
- return(-1);
- }
- }
- }
- }
-
- // returns the actual bitrate since last call. returns -1 if no
- // additional data to offer since last call (or at beginning of stream)
- public int bitrate_instant(){
- int _link=(seekable?current_link:0);
- if(samptrack==0)return(-1);
- int ret=(int)(bittrack/samptrack*vi[_link].rate+.5);
- bittrack=0.f;
- samptrack=0.f;
- return(ret);
- }
-
- public int serialnumber(int i){
- if(i>=links)return(-1);
- if(!seekable && i>=0)return(serialnumber(-1));
- if(i<0){
- return(current_serialno);
- }
- else{
- return(serialnos[i]);
- }
- }
-
- // returns: total raw (compressed) length of content if i==-1
- // raw (compressed) length of that logical bitstream for i==0 to n
- // -1 if the stream is not seekable (we can't know the length)
-
- public long raw_total(int i){
-System.out.println("raw_total: "+seekable);
- if(!seekable || i>=links)return(-1);
- if(i<0){
- long acc=0; // bug?
- for(int j=0;j<links;j++){
- acc+=raw_total(j);
- }
- return(acc);
- }
- else{
- return(offsets[i+1]-offsets[i]);
- }
- }
-
- // returns: total PCM length (samples) of content if i==-1
- // PCM length (samples) of that logical bitstream for i==0 to n
- // -1 if the stream is not seekable (we can't know the length)
- public long pcm_total(int i){
- if(!seekable || i>=links)return(-1);
- if(i<0){
- long acc=0;
- for(int j=0;j<links;j++){
- acc+=pcm_total(j);
- }
- return(acc);
- }
- else{
- return(pcmlengths[i]);
- }
- }
-
- // returns: total seconds of content if i==-1
- // seconds in that logical bitstream for i==0 to n
- // -1 if the stream is not seekable (we can't know the length)
- public float time_total(int i){
- if(!seekable || i>=links)return(-1);
- if(i<0){
- float acc=0;
- for(int j=0;j<links;j++){
- acc+=time_total(j);
- }
- return(acc);
- }
- else{
- return((float)(pcmlengths[i])/vi[i].rate);
- }
- }
-
- // seek to an offset relative to the *compressed* data. This also
- // immediately sucks in and decodes pages to update the PCM cursor. It
- // will cross a logical bitstream boundary, but only if it can't get
- // any packets out of the tail of the bitstream we seek to (so no
- // surprises).
- //
- // returns zero on success, nonzero on failure
-
- public int raw_seek(int pos){
-System.out.println("raw_seek: "+pos);
- if(!seekable)return(-1); // don't dump machine if we can't seek
- if(pos<0 || pos>offsets[links]){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-System.out.println("#1");
- // clear out decoding machine state
- pcm_offset=-1;
-System.out.println("#2");
- decode_clear();
-System.out.println("#3");
- // seek
- seek_helper(pos);
-
- // we need to make sure the pcm_offset is set. We use the
- // _fetch_packet helper to process one packet with readp set, then
- // call it until it returns '0' with readp not set (the last packet
- // from a page has the 'granulepos' field set, and that's how the
- // helper updates the offset
-System.out.println("#4");
- switch(process_packet(1)){
- case 0:
-System.out.println("?0");
- // oh, eof. There are no packets remaining. Set the pcm offset to
- // the end of file
- pcm_offset=pcm_total(-1);
- return(0);
- case -1:
-System.out.println("?-1");
- // error! missing data or invalid bitstream structure
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- default:
-System.out.println("?break");
- // all OK
- break;
- }
-System.out.println("pcm_offset="+pcm_offset);
- while(true){
- switch(process_packet(0)){
- case 0:
- // the offset is set. If it's a bogus bitstream with no offset
- // information, it's not but that's not our fault. We still run
- // gracefully, we're just missing the offset
- return(0);
- case -1:
- // error! missing data or invalid bitstream structure
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- default:
- // continue processing packets
- break;
- }
- }
-
- // seek_error:
- // dump the machine so we're in a known state
- //pcm_offset=-1;
- //decode_clear();
- //return -1;
- }
-
- // seek to a sample offset relative to the decompressed pcm stream
- // returns zero on success, nonzero on failure
-
- public int pcm_seek(long pos){
- int link=-1;
- long total=pcm_total(-1);
-
- if(!seekable)return(-1); // don't dump machine if we can't seek
- if(pos<0 || pos>total){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-
- // which bitstream section does this pcm offset occur in?
- for(link=links-1;link>=0;link--){
- total-=pcmlengths[link];
- if(pos>=total)break;
- }
-
- // search within the logical bitstream for the page with the highest
- // pcm_pos preceeding (or equal to) pos. There is a danger here;
- // missing pages or incorrect frame number information in the
- // bitstream could make our task impossible. Account for that (it
- // would be an error condition)
- {
- long target=pos-total;
- int end=(int)offsets[link+1];
- int begin=(int)offsets[link];
- int best=begin;
-
- Page og=new Page();
- while(begin<end){
- int bisect;
- int ret;
-
- if(end-begin<CHUNKSIZE){
- bisect=begin;
- }
- else{
- bisect=(end+begin)/2;
- }
-
- seek_helper(bisect);
- ret=get_next_page(og,end-bisect);
-
- if(ret==-1){
- end=bisect;
- }
- else{
- long granulepos=og.granulepos();
- if(granulepos<target){
- best=ret; // raw offset of packet with granulepos
- begin=(int)offset; // raw offset of next packet
- }
- else{
- end=bisect;
- }
- }
- }
- // found our page. seek to it (call raw_seek).
- if(raw_seek(best)!=0){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
- }
-
- // verify result
- if(pcm_offset>=pos){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
- if(pos>pcm_total(-1)){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-
- // discard samples until we reach the desired position. Crossing a
- // logical bitstream boundary with abandon is OK.
- while(pcm_offset<pos){
- float[][] pcm;
- int target=(int)(pos-pcm_offset);
- float[][][] _pcm=new float[1][][];
- int[] _index=new int[info(-1).channels];
- int samples=vd.synthesis_pcmout(_pcm, _index);
- pcm=_pcm[0];
-
- if(samples>target)samples=target;
- vd.synthesis_read(samples);
- pcm_offset+=samples;
-
- if(samples<target)
- if(process_packet(1)==0){
- pcm_offset=pcm_total(-1); // eof
- }
- }
- return 0;
-
- // seek_error:
- // dump machine so we're in a known state
- //pcm_offset=-1;
- //decode_clear();
- //return -1;
- }
-
- // seek to a playback time relative to the decompressed pcm stream
- // returns zero on success, nonzero on failure
- public int time_seek(float seconds){
- // translate time to PCM position and call pcm_seek
-
- int link=-1;
- long pcm_total=pcm_total(-1);
- float time_total=time_total(-1);
-
- if(!seekable)return(-1); // don't dump machine if we can't seek
- if(seconds<0 || seconds>time_total){
- //goto seek_error;
- pcm_offset=-1;
- decode_clear();
- return -1;
- }
-
- // which bitstream section does this time offset occur in?
- for(link=links-1;link>=0;link--){
- pcm_total-=pcmlengths[link];
- time_total-=time_total(link);
- if(seconds>=time_total)break;
- }
-
- // enough information to convert time offset to pcm offset
- {
- long target=(long)(pcm_total+(seconds-time_total)*vi[link].rate);
- return(pcm_seek(target));
- }
-
- //seek_error:
- // dump machine so we're in a known state
- //pcm_offset=-1;
- //decode_clear();
- //return -1;
- }
-
- // tell the current stream offset cursor. Note that seek followed by
- // tell will likely not give the set offset due to caching
- public long raw_tell(){
- return(offset);
- }
-
- // return PCM offset (sample) of next PCM sample to be read
- public long pcm_tell(){
- return(pcm_offset);
- }
-
- // return time offset (seconds) of next PCM sample to be read
- public float time_tell(){
- // translate time to PCM position and call pcm_seek
-
- int link=-1;
- long pcm_total=0;
- float time_total=0.f;
-
- if(seekable){
- pcm_total=pcm_total(-1);
- time_total=time_total(-1);
-
- // which bitstream section does this time offset occur in?
- for(link=links-1;link>=0;link--){
- pcm_total-=pcmlengths[link];
- time_total-=time_total(link);
- if(pcm_offset>=pcm_total)break;
- }
- }
-
- return((float)time_total+(float)(pcm_offset-pcm_total)/vi[link].rate);
- }
-
- // link: -1) return the vorbis_info struct for the bitstream section
- // currently being decoded
- // 0-n) to request information for a specific bitstream section
- //
- // In the case of a non-seekable bitstream, any call returns the
- // current bitstream. NULL in the case that the machine is not
- // initialized
-
- public Info info(int link){
- if(seekable){
- if(link<0){
- if(decode_ready){
- return vi[current_link];
- }
- else{
- return null;
- }
- }
- else{
- if(link>=links){
- return null;
- }
- else{
- return vi[link];
- }
- }
- }
- else{
- if(decode_ready){
- return vi[0];
- }
- else{
- return null;
- }
- }
- }
-
- public Comment comment(int link){
- if(seekable){
- if(link<0){
- if(decode_ready){ return vc[current_link]; }
- else{ return null; }
- }
- else{
- if(link>=links){ return null;}
- else{ return vc[link]; }
- }
- }
- else{
- if(decode_ready){ return vc[0]; }
- else{ return null; }
- }
- }
-
- int host_is_big_endian() {
- return 1;
-// short pattern = 0xbabe;
-// unsigned char *bytewise = (unsigned char *)&pattern;
-// if (bytewise[0] == 0xba) return 1;
-// assert(bytewise[0] == 0xbe);
-// return 0;
- }
-
- // up to this point, everything could more or less hide the multiple
- // logical bitstream nature of chaining from the toplevel application
- // if the toplevel application didn't particularly care. However, at
- // the point that we actually read audio back, the multiple-section
- // nature must surface: Multiple bitstream sections do not necessarily
- // have to have the same number of channels or sampling rate.
- //
- // read returns the sequential logical bitstream number currently
- // being decoded along with the PCM data in order that the toplevel
- // application can take action on channel/sample rate changes. This
- // number will be incremented even for streamed (non-seekable) streams
- // (for seekable streams, it represents the actual logical bitstream
- // index within the physical bitstream. Note that the accessor
- // functions above are aware of this dichotomy).
- //
- // input values: buffer) a buffer to hold packed PCM data for return
- // length) the byte length requested to be placed into buffer
- // bigendianp) should the data be packed LSB first (0) or
- // MSB first (1)
- // word) word size for output. currently 1 (byte) or
- // 2 (16 bit short)
- //
- // return values: -1) error/hole in data
- // 0) EOF
- // n) number of bytes of PCM actually returned. The
- // below works on a packet-by-packet basis, so the
- // return length is not related to the 'length' passed
- // in, just guaranteed to fit.
- //
- // *section) set to the logical bitstream number
-
- int read(byte[] buffer,int length,
- int bigendianp, int word, int sgned, int[] bitstream){
- int host_endian = host_is_big_endian();
- int index=0;
-
- while(true){
- if(decode_ready){
- float[][] pcm;
- float[][][] _pcm=new float[1][][];
- int[] _index=new int[info(-1).channels];
- int samples=vd.synthesis_pcmout(_pcm, _index);
- pcm=_pcm[0];
- if(samples!=0){
- // yay! proceed to pack data into the byte buffer
- int channels=info(-1).channels;
- int bytespersample=word * channels;
- if(samples>length/bytespersample)samples=length/bytespersample;
-
- // a tight loop to pack each size
- {
- int val;
- if(word==1){
- int off=(sgned!=0?0:128);
- for(int j=0;j<samples;j++){
- for(int i=0;i<channels;i++){
- val=(int)(pcm[i][_index[i]+j]*128. + 0.5);
- if(val>127)val=127;
- else if(val<-128)val=-128;
- buffer[index++]=(byte)(val+off);
- }
- }
- }
- else{
- int off=(sgned!=0?0:32768);
-
- if(host_endian==bigendianp){
- if(sgned!=0){
- for(int i=0;i<channels;i++) { // It's faster in this order
- int src=_index[i];
- int dest=i;
- for(int j=0;j<samples;j++) {
- val=(int)(pcm[i][src+j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- buffer[dest]=(byte)(val>>>8);
- buffer[dest+1]=(byte)(val);
- dest+=channels*2;
- }
- }
- }
- else{
- for(int i=0;i<channels;i++) {
- float[] src=pcm[i];
- int dest=i;
- for(int j=0;j<samples;j++) {
- val=(int)(src[j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- buffer[dest]=(byte)((val+off)>>>8);
- buffer[dest+1]=(byte)(val+off);
- dest+=channels*2;
- }
- }
- }
- }
- else if(bigendianp!=0){
- for(int j=0;j<samples;j++){
- for(int i=0;i<channels;i++){
- val=(int)(pcm[i][j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- val+=off;
- buffer[index++]=(byte)(val>>>8);
- buffer[index++]=(byte)val;
- }
- }
- }
- else{
- //int val;
- for(int j=0;j<samples;j++){
- for(int i=0;i<channels;i++){
- val=(int)(pcm[i][j]*32768. + 0.5);
- if(val>32767)val=32767;
- else if(val<-32768)val=-32768;
- val+=off;
- buffer[index++]=(byte)val;
- buffer[index++]=(byte)(val>>>8);
- }
- }
- }
- }
- }
-
- vd.synthesis_read(samples);
- pcm_offset+=samples;
- if(bitstream!=null)bitstream[0]=current_link;
- return(samples*bytespersample);
- }
- }
-
- // suck in another packet
- switch(process_packet(1)){
- case 0:
- return(0);
- case -1:
- return -1;
- default:
- break;
- }
- }
- }
-
- public int getLinks(){return links;}
- public Info[] getInfo(){return vi;}
- public Comment[] getComment(){return vc;}
-
- public static void main(String[] arg){
- try{
- VorbisFile foo=new VorbisFile(arg[0]);
- int links=foo.getLinks();
- System.out.println("links="+links);
- Comment[] comment=foo.getComment();
- Info[] info=foo.getInfo();
- for(int i=0; i<links; i++){
- System.out.println(info[i]);
- System.out.println(comment[i]);
- }
- System.out.println("raw_total: "+foo.raw_total(-1));
- System.out.println("pcm_total: "+foo.pcm_total(-1));
- System.out.println("time_total: "+foo.time_total(-1));
- }
- catch(Exception e){
- System.err.println(e);
- }
- }
-}
diff --git a/songdbj/de/jarnbjo/ogg/BasicStream.java b/songdbj/de/jarnbjo/ogg/BasicStream.java
deleted file mode 100644
index 9939524d6c..0000000000
--- a/songdbj/de/jarnbjo/ogg/BasicStream.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.3 2004/09/21 12:09:45 shred
- * *** empty log message ***
- *
- * Revision 1.2 2004/09/21 06:38:45 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-
-/**
- * Implementation of the <code>PhysicalOggStream</code> interface for reading
- * an Ogg stream from a URL. This class performs
- * no internal caching, and will not read data from the network before
- * requested to do so. It is intended to be used in non-realtime applications
- * like file download managers or similar.
- */
-
-public class BasicStream implements PhysicalOggStream {
-
- private boolean closed=false;
- private InputStream sourceStream;
- private Object drainLock=new Object();
- private LinkedList pageCache=new LinkedList();
- private long numberOfSamples=-1;
- private int position=0;
-
- private HashMap logicalStreams=new HashMap();
- private OggPage firstPage;
-
- public BasicStream(InputStream sourceStream) throws OggFormatException, IOException {
- firstPage=OggPage.create(sourceStream);
- position+=firstPage.getTotalLength();
- LogicalOggStreamImpl los=new LogicalOggStreamImpl(this, firstPage.getStreamSerialNumber());
- logicalStreams.put(new Integer(firstPage.getStreamSerialNumber()), los);
- los.checkFormat(firstPage);
- }
-
- public Collection getLogicalStreams() {
- return logicalStreams.values();
- }
-
- public boolean isOpen() {
- return !closed;
- }
-
- public void close() throws IOException {
- closed=true;
- sourceStream.close();
- }
-
- public int getContentLength() {
- return -1;
- }
-
- public int getPosition() {
- return position;
- }
-
- int pageNumber=2;
-
- public OggPage getOggPage(int index) throws IOException {
- if(firstPage!=null) {
- OggPage tmp=firstPage;
- firstPage=null;
- return tmp;
- }
- else {
- OggPage page=OggPage.create(sourceStream);
- position+=page.getTotalLength();
- return page;
- }
- }
-
- private LogicalOggStream getLogicalStream(int serialNumber) {
- return (LogicalOggStream)logicalStreams.get(new Integer(serialNumber));
- }
-
- public void setTime(long granulePosition) throws IOException {
- throw new UnsupportedOperationException("Method not supported by this class");
- }
-
- /**
- * @return always <code>false</code>
- */
-
- public boolean isSeekable() {
- return false;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/CachedUrlStream.java b/songdbj/de/jarnbjo/ogg/CachedUrlStream.java
deleted file mode 100644
index 86f792e272..0000000000
--- a/songdbj/de/jarnbjo/ogg/CachedUrlStream.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.1 2003/04/10 19:48:22 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Implementation of the <code>PhysicalOggStream</code> interface for reading
- * and caching an Ogg stream from a URL. This class reads the data as fast as
- * possible from the URL, caches it locally either in memory or on disk, and
- * supports seeking within the available data.
- */
-
-public class CachedUrlStream implements PhysicalOggStream {
-
- private boolean closed=false;
- private URLConnection source;
- private InputStream sourceStream;
- private Object drainLock=new Object();
- private RandomAccessFile drain;
- private byte[] memoryCache;
- private ArrayList pageOffsets=new ArrayList();
- private ArrayList pageLengths=new ArrayList();
- private long numberOfSamples=-1;
- private long cacheLength;
-
- private HashMap logicalStreams=new HashMap();
-
- private LoaderThread loaderThread;
-
- /**
- * Creates an instance of this class, using a memory cache.
- */
-
- public CachedUrlStream(URL source) throws OggFormatException, IOException {
- this(source, null);
- }
-
- /**
- * Creates an instance of this class, using the specified file as cache. The
- * file is not automatically deleted when this class is disposed.
- */
-
- public CachedUrlStream(URL source, RandomAccessFile drain) throws OggFormatException, IOException {
-
- this.source=source.openConnection();
-
- if(drain==null) {
- int contentLength=this.source.getContentLength();
- if(contentLength==-1) {
- throw new IOException("The URLConncetion's content length must be set when operating with a in-memory cache.");
- }
- memoryCache=new byte[contentLength];
- }
-
- this.drain=drain;
- this.sourceStream=this.source.getInputStream();
-
- loaderThread=new LoaderThread(sourceStream, drain, memoryCache);
- new Thread(loaderThread).start();
-
- while(!loaderThread.isBosDone() || pageOffsets.size()<20) {
- System.out.print("pageOffsets.size(): "+pageOffsets.size()+"\r");
- try {
- Thread.sleep(200);
- }
- catch (InterruptedException ex) {
- }
- }
- System.out.println();
- System.out.println("caching "+pageOffsets.size()+"/20 pages\r");
- }
-
- public Collection getLogicalStreams() {
- return logicalStreams.values();
- }
-
- public boolean isOpen() {
- return !closed;
- }
-
- public void close() throws IOException {
- closed=true;
- sourceStream.close();
- }
-
- public long getCacheLength() {
- return cacheLength;
- }
-
- /*
- private OggPage getNextPage() throws EndOfOggStreamException, IOException, OggFormatException {
- return getNextPage(false);
- }
-
- private OggPage getNextPage(boolean skipData) throws EndOfOggStreamException, IOException, OggFormatException {
- return OggPage.create(sourceStream, skipData);
- }
- */
-
- public OggPage getOggPage(int index) throws IOException {
- synchronized(drainLock) {
- Long offset=(Long)pageOffsets.get(index);
- Long length=(Long)pageLengths.get(index);
- if(offset!=null) {
- if(drain!=null) {
- drain.seek(offset.longValue());
- return OggPage.create(drain);
- }
- else {
- byte[] tmpArray=new byte[length.intValue()];
- System.arraycopy(memoryCache, offset.intValue(), tmpArray, 0, length.intValue());
- return OggPage.create(tmpArray);
- }
- }
- else {
- return null;
- }
- }
- }
-
- private LogicalOggStream getLogicalStream(int serialNumber) {
- return (LogicalOggStream)logicalStreams.get(new Integer(serialNumber));
- }
-
- public void setTime(long granulePosition) throws IOException {
- for(Iterator iter=logicalStreams.values().iterator(); iter.hasNext(); ) {
- LogicalOggStream los=(LogicalOggStream)iter.next();
- los.setTime(granulePosition);
- }
- }
-
- public class LoaderThread implements Runnable {
-
- private InputStream source;
- private RandomAccessFile drain;
- private byte[] memoryCache;
-
- private boolean bosDone=false;
-
- private int pageNumber;
-
- public LoaderThread(InputStream source, RandomAccessFile drain, byte[] memoryCache) {
- this.source=source;
- this.drain=drain;
- this.memoryCache=memoryCache;
- }
-
- public void run() {
- try {
- boolean eos=false;
- byte[] buffer=new byte[8192];
- while(!eos) {
- OggPage op=OggPage.create(source);
- synchronized (drainLock) {
- int listSize=pageOffsets.size();
-
- long pos=
- listSize>0?
- ((Long)pageOffsets.get(listSize-1)).longValue()+
- ((Long)pageLengths.get(listSize-1)).longValue():
- 0;
-
- byte[] arr1=op.getHeader();
- byte[] arr2=op.getSegmentTable();
- byte[] arr3=op.getData();
-
- if(drain!=null) {
- drain.seek(pos);
- drain.write(arr1);
- drain.write(arr2);
- drain.write(arr3);
- }
- else {
- System.arraycopy(arr1, 0, memoryCache, (int)pos, arr1.length);
- System.arraycopy(arr2, 0, memoryCache, (int)pos+arr1.length, arr2.length);
- System.arraycopy(arr3, 0, memoryCache, (int)pos+arr1.length+arr2.length, arr3.length);
- }
-
- pageOffsets.add(new Long(pos));
- pageLengths.add(new Long(arr1.length+arr2.length+arr3.length));
- }
-
- if(!op.isBos()) {
- bosDone=true;
- //System.out.println("bosDone=true;");
- }
- if(op.isEos()) {
- eos=true;
- }
-
- LogicalOggStreamImpl los=(LogicalOggStreamImpl)getLogicalStream(op.getStreamSerialNumber());
- if(los==null) {
- los=new LogicalOggStreamImpl(CachedUrlStream.this, op.getStreamSerialNumber());
- logicalStreams.put(new Integer(op.getStreamSerialNumber()), los);
- los.checkFormat(op);
- }
-
- los.addPageNumberMapping(pageNumber);
- los.addGranulePosition(op.getAbsoluteGranulePosition());
-
- pageNumber++;
- cacheLength=op.getAbsoluteGranulePosition();
- //System.out.println("read page: "+pageNumber);
- }
- }
- catch(EndOfOggStreamException e) {
- // ok
- }
- catch(IOException e) {
- e.printStackTrace();
- }
- }
-
- public boolean isBosDone() {
- return bosDone;
- }
- }
-
- public boolean isSeekable() {
- return true;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/EndOfOggStreamException.java b/songdbj/de/jarnbjo/ogg/EndOfOggStreamException.java
deleted file mode 100644
index 4a0c3200f4..0000000000
--- a/songdbj/de/jarnbjo/ogg/EndOfOggStreamException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2005/02/09 23:10:47 shred
- * Serial UID für jarnbjo
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
- package de.jarnbjo.ogg;
-
-import java.io.IOException;
-
-/**
- * Exception thrown when reaching the end of an Ogg stream
- */
-
-public class EndOfOggStreamException extends IOException {
- private static final long serialVersionUID = 3907210438109444408L;
-
- public EndOfOggStreamException() {
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/FileStream.java b/songdbj/de/jarnbjo/ogg/FileStream.java
deleted file mode 100644
index 5a526300bf..0000000000
--- a/songdbj/de/jarnbjo/ogg/FileStream.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.1 2003/04/10 19:48:22 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Implementation of the <code>PhysicalOggStream</code> interface for accessing
- * normal disk files.
- */
-
-public class FileStream implements PhysicalOggStream {
-
- private boolean closed=false;
- private RandomAccessFile source;
- private long[] pageOffsets;
- private long numberOfSamples=-1;
-
- private HashMap logicalStreams=new HashMap();
-
- /**
- * Creates access to the specified file through the <code>PhysicalOggStream</code> interface.
- * The specified source file must have been opened for reading.
- *
- * @param source the file to read from
- *
- * @throws OggFormatException if the stream format is incorrect
- * @throws IOException if some other IO error occurs when reading the file
- */
-
- public FileStream(RandomAccessFile source) throws OggFormatException, IOException {
- this.source=source;
-
- ArrayList po=new ArrayList();
- int pageNumber=0;
- try {
- while(true) {
- po.add(new Long(this.source.getFilePointer()));
-
- // skip data if pageNumber>0
- OggPage op=getNextPage(pageNumber>0);
- if(op==null) {
- break;
- }
-
- LogicalOggStreamImpl los=(LogicalOggStreamImpl)getLogicalStream(op.getStreamSerialNumber());
- if(los==null) {
- los=new LogicalOggStreamImpl(this, op.getStreamSerialNumber());
- logicalStreams.put(new Integer(op.getStreamSerialNumber()), los);
- }
-
- if(pageNumber==0) {
- los.checkFormat(op);
- }
-
- los.addPageNumberMapping(pageNumber);
- los.addGranulePosition(op.getAbsoluteGranulePosition());
-
- if(pageNumber>0) {
- this.source.seek(this.source.getFilePointer()+op.getTotalLength());
- }
-
- pageNumber++;
- }
- }
- catch(EndOfOggStreamException e) {
- // ok
- }
- catch(IOException e) {
- throw e;
- }
- //System.out.println("pageNumber: "+pageNumber);
- this.source.seek(0L);
- pageOffsets=new long[po.size()];
- int i=0;
- Iterator iter=po.iterator();
- while(iter.hasNext()) {
- pageOffsets[i++]=((Long)iter.next()).longValue();
- }
- }
-
- public Collection getLogicalStreams() {
- return logicalStreams.values();
- }
-
- public boolean isOpen() {
- return !closed;
- }
-
- public void close() throws IOException {
- closed=true;
- source.close();
- }
-
- private OggPage getNextPage() throws EndOfOggStreamException, IOException, OggFormatException {
- return getNextPage(false);
- }
-
- private OggPage getNextPage(boolean skipData) throws EndOfOggStreamException, IOException, OggFormatException {
- return OggPage.create(source, skipData);
- }
-
- public OggPage getOggPage(int index) throws IOException {
- source.seek(pageOffsets[index]);
- return OggPage.create(source);
- }
-
- private LogicalOggStream getLogicalStream(int serialNumber) {
- return (LogicalOggStream)logicalStreams.get(new Integer(serialNumber));
- }
-
- public void setTime(long granulePosition) throws IOException {
- for(Iterator iter=logicalStreams.values().iterator(); iter.hasNext(); ) {
- LogicalOggStream los=(LogicalOggStream)iter.next();
- los.setTime(granulePosition);
- }
- }
-
- /**
- * @return always <code>true</code>
- */
-
- public boolean isSeekable() {
- return true;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/LogicalOggStream.java b/songdbj/de/jarnbjo/ogg/LogicalOggStream.java
deleted file mode 100644
index 2f97b2a728..0000000000
--- a/songdbj/de/jarnbjo/ogg/LogicalOggStream.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/04/10 19:48:22 jarnbjo
- * no message
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.IOException;
-
-/**
- * Interface providing access to a logical Ogg stream as part of a
- * physical Ogg stream.
- */
-
-
-public interface LogicalOggStream {
-
- public static final String FORMAT_UNKNOWN = "application/octet-stream";
-
- public static final String FORMAT_VORBIS = "audio/x-vorbis";
- public static final String FORMAT_FLAC = "audio/x-flac";
- public static final String FORMAT_THEORA = "video/x-theora";
-
- /**
- * <i>Note:</i> To read from the stream, you must use either
- * this method or the method <code>getNextOggPacket</code>.
- * Mixing calls to the two methods will cause data corruption.
- *
- * @return the next Ogg page
- *
- * @see #getNextOggPacket()
- *
- * @throws OggFormatException if the ogg stream is corrupted
- * @throws IOException if some other IO error occurs
- */
-
- public OggPage getNextOggPage() throws OggFormatException, IOException;
-
- /**
- * <i>Note:</i> To read from the stream, you must use either
- * this method or the method <code>getNextOggPage</code>.
- * Mixing calls to the two methods will cause data corruption.
- *
- * @return the next packet as a byte array
- *
- * @see #getNextOggPage()
- *
- * @throws OggFormatException if the ogg stream is corrupted
- * @throws IOException if some other IO error occurs
- */
-
- public byte[] getNextOggPacket() throws OggFormatException, IOException;
-
- /**
- * Checks if this stream is open for reading.
- *
- * @return <code>true</code> if this stream is open for reading,
- * <code>false</code> otherwise
- */
-
- public boolean isOpen();
-
- /**
- * Closes this stream. After invoking this method, no further access
- * to the streams data is possible.
- *
- * @throws IOException if an IO error occurs
- */
-
- public void close() throws IOException;
-
- /**
- * Sets the stream's position to the beginning of the stream.
- * This method does not work if the physical Ogg stream is not
- * seekable.
- *
- * @throws OggFormatException if the ogg stream is corrupted
- * @throws IOException if some other IO error occurs
- */
-
- public void reset() throws OggFormatException, IOException;
-
- /**
- * This method does not work if the physical Ogg stream is not
- * seekable.
- *
- * @return the granule position of the last page within
- * this stream
- */
-
- public long getMaximumGranulePosition();
-
- /**
- * This method is invoked on all logical streams when
- * calling the same method on the physical stream. The
- * same restrictions as mentioned there apply.
- * This method does not work if the physical Ogg stream is not
- * seekable.
- *
- * @param granulePosition
- *
- * @see PhysicalOggStream#setTime(long)
- *
- * @throws IOException if an IO error occurs
- */
-
- public void setTime(long granulePosition) throws IOException;
-
- /**
- * @return the last parsed granule position of this stream
- */
-
- public long getTime();
-
- /**
- * @return the content type of this stream
- *
- * @see #FORMAT_UNKNOWN
- * @see #FORMAT_VORBIS
- * @see #FORMAT_FLAC
- * @see #FORMAT_THEORA
- */
-
- public String getFormat();
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/LogicalOggStreamImpl.java b/songdbj/de/jarnbjo/ogg/LogicalOggStreamImpl.java
deleted file mode 100644
index 1a503e91ca..0000000000
--- a/songdbj/de/jarnbjo/ogg/LogicalOggStreamImpl.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/03/31 00:23:04 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:26 jarnbjo
- * no message
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.*;
-import java.util.*;
-
-public class LogicalOggStreamImpl implements LogicalOggStream {
-
- private PhysicalOggStream source;
- private int serialNumber;
-
- private ArrayList pageNumberMapping=new ArrayList();
- private ArrayList granulePositions=new ArrayList();
-
- private int pageIndex=0;
- private OggPage currentPage;
- private int currentSegmentIndex;
-
- private boolean open=true;
-
- private String format=FORMAT_UNKNOWN;
-
- public LogicalOggStreamImpl(PhysicalOggStream source, int serialNumber) {
- this.source=source;
- this.serialNumber=serialNumber;
- }
-
- public void addPageNumberMapping(int physicalPageNumber) {
- pageNumberMapping.add(new Integer(physicalPageNumber));
- }
-
- public void addGranulePosition(long granulePosition) {
- granulePositions.add(new Long(granulePosition));
- }
-
- public synchronized void reset() throws OggFormatException, IOException {
- currentPage=null;
- currentSegmentIndex=0;
- pageIndex=0;
- }
-
- public synchronized OggPage getNextOggPage() throws EndOfOggStreamException, OggFormatException, IOException {
- if(source.isSeekable()) {
- currentPage=source.getOggPage(((Integer)pageNumberMapping.get(pageIndex++)).intValue());
- }
- else {
- currentPage=source.getOggPage(-1);
- }
- return currentPage;
- }
-
- public synchronized byte[] getNextOggPacket() throws EndOfOggStreamException, OggFormatException, IOException {
- ByteArrayOutputStream res=new ByteArrayOutputStream();
- int segmentLength=0;
-
- if(currentPage==null) {
- currentPage=getNextOggPage();
- }
-
- do {
- if(currentSegmentIndex>=currentPage.getSegmentOffsets().length) {
- currentSegmentIndex=0;
-
- if(!currentPage.isEos()) {
- if(source.isSeekable() && pageNumberMapping.size()<=pageIndex) {
- while(pageNumberMapping.size()<=pageIndex+10) {
- try {
- Thread.sleep(1000);
- }
- catch (InterruptedException ex) {
- }
- }
- }
- currentPage=getNextOggPage();
-
- if(res.size()==0 && currentPage.isContinued()) {
- boolean done=false;
- while(!done) {
- if(currentPage.getSegmentLengths()[currentSegmentIndex++]!=255) {
- done=true;
- }
- if(currentSegmentIndex>currentPage.getSegmentTable().length) {
- currentPage=source.getOggPage(((Integer)pageNumberMapping.get(pageIndex++)).intValue());
- }
- }
- }
- }
- else {
- throw new EndOfOggStreamException();
- }
- }
- segmentLength=currentPage.getSegmentLengths()[currentSegmentIndex];
- res.write(currentPage.getData(), currentPage.getSegmentOffsets()[currentSegmentIndex], segmentLength);
- currentSegmentIndex++;
- } while(segmentLength==255);
-
- return res.toByteArray();
- }
-
- public boolean isOpen() {
- return open;
- }
-
- public void close() throws IOException {
- open=false;
- }
-
- public long getMaximumGranulePosition() {
- Long mgp=(Long)granulePositions.get(granulePositions.size()-1);
- return mgp.longValue();
- }
-
- public synchronized long getTime() {
- return currentPage!=null?currentPage.getAbsoluteGranulePosition():-1;
- }
-
- public synchronized void setTime(long granulePosition) throws IOException {
-
- int page=0;
- for(page=0; page<granulePositions.size(); page++) {
- Long gp=(Long)granulePositions.get(page);
- if(gp.longValue()>granulePosition) {
- break;
- }
- }
-
- pageIndex=page;
- currentPage=source.getOggPage(((Integer)pageNumberMapping.get(pageIndex++)).intValue());
- currentSegmentIndex=0;
- int segmentLength=0;
- do {
- if(currentSegmentIndex>=currentPage.getSegmentOffsets().length) {
- currentSegmentIndex=0;
- if(pageIndex>=pageNumberMapping.size()) {
- throw new EndOfOggStreamException();
- }
- currentPage=source.getOggPage(((Integer)pageNumberMapping.get(pageIndex++)).intValue());
- }
- segmentLength=currentPage.getSegmentLengths()[currentSegmentIndex];
- currentSegmentIndex++;
- } while(segmentLength==255);
- }
-
- public void checkFormat(OggPage page) {
- byte[] data=page.getData();
-
- if(data.length>=7 &&
- data[1]==0x76 &&
- data[2]==0x6f &&
- data[3]==0x72 &&
- data[4]==0x62 &&
- data[5]==0x69 &&
- data[6]==0x73) {
-
- format=FORMAT_VORBIS;
- }
- else if(data.length>=7 &&
- data[1]==0x74 &&
- data[2]==0x68 &&
- data[3]==0x65 &&
- data[4]==0x6f &&
- data[5]==0x72 &&
- data[6]==0x61) {
-
- format=FORMAT_THEORA;
- }
- else if (data.length==4 &&
- data[0]==0x66 &&
- data[1]==0x4c &&
- data[2]==0x61 &&
- data[3]==0x43) {
-
- format=FORMAT_FLAC;
- }
- }
-
- public String getFormat() {
- return format;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/OggFormatException.java b/songdbj/de/jarnbjo/ogg/OggFormatException.java
deleted file mode 100644
index a6b2466b92..0000000000
--- a/songdbj/de/jarnbjo/ogg/OggFormatException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2005/02/09 23:10:47 shred
- * Serial UID für jarnbjo
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.IOException;
-
-/**
- * Exception thrown when trying to read a corrupted Ogg stream.
- */
-
-public class OggFormatException extends IOException {
- private static final long serialVersionUID = 3544953238333175349L;
-
- public OggFormatException() {
- super();
- }
-
- public OggFormatException(String message) {
- super(message);
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/OggPage.java b/songdbj/de/jarnbjo/ogg/OggPage.java
deleted file mode 100644
index cc965cc7a9..0000000000
--- a/songdbj/de/jarnbjo/ogg/OggPage.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/10 19:48:22 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/31 00:23:04 jarnbjo
- * no message
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.*;
-
-import de.jarnbjo.util.io.*;
-
-/**
- * <p>An instance of this class represents an ogg page read from an ogg file
- * or network stream. It has no public constructor, but instances can be
- * created by the <code>create</code> methods, supplying a JMF stream or
- * a <code>RandomAccessFile</code>
- * which is positioned at the beginning of an Ogg page.</p>
- *
- * <p>Furtheron, the class provides methods for accessing the raw page data,
- * as well as data attributes like segmenting information, sequence number,
- * stream serial number, chechsum and wether this page is the beginning or
- * end of a logical bitstream (BOS, EOS) and if the page data starts with a
- * continued packet or a fresh data packet.</p>
- */
-
-public class OggPage {
-
- private int version;
- private boolean continued, bos, eos;
- private long absoluteGranulePosition;
- private int streamSerialNumber, pageSequenceNumber, pageCheckSum;
- private int[] segmentOffsets;
- private int[] segmentLengths;
- private int totalLength;
- private byte[] header, segmentTable, data;
-
- protected OggPage() {
- }
-
- private OggPage(
- int version,
- boolean continued,
- boolean bos,
- boolean eos,
- long absoluteGranulePosition,
- int streamSerialNumber,
- int pageSequenceNumber,
- int pageCheckSum,
- int[] segmentOffsets,
- int[] segmentLengths,
- int totalLength,
- byte[] header,
- byte[] segmentTable,
- byte[] data) {
-
- this.version=version;
- this.continued=continued;
- this.bos=bos;
- this.eos=eos;
- this.absoluteGranulePosition=absoluteGranulePosition;
- this.streamSerialNumber=streamSerialNumber;
- this.pageSequenceNumber=pageSequenceNumber;
- this.pageCheckSum=pageCheckSum;
- this.segmentOffsets=segmentOffsets;
- this.segmentLengths=segmentLengths;
- this.totalLength=totalLength;
- this.header=header;
- this.segmentTable=segmentTable;
- this.data=data;
- }
-
- /**
- * this method equals to create(RandomAccessFile source, false)
- *
- * @see #create(RandomAccessFile, boolean)
- */
-
- public static OggPage create(RandomAccessFile source) throws IOException, EndOfOggStreamException, OggFormatException {
- return create(source, false);
- }
-
- /**
- * This method is called to read data from the current position in the
- * specified RandomAccessFile and create a new OggPage instance based on the data
- * read. If the parameter <code>skipData</code> is set to <code>true</code>,
- * the actual page segments (page data) is skipped and not read into
- * memory. This mode is useful when scanning through an ogg file to build
- * a seek table.
- *
- * @param source the source from which the ogg page is generated
- * @param skipData if set to <code>true</code>, the actual page data is not read into memory
- * @return an ogg page created by reading data from the specified source, starting at the current position
- * @throws FormatException if the data read from the specified source is not matching the specification for an ogg page
- * @throws EndOfStreamException if it is not possible to read an entire ogg page from the specified source
- * @throws IOException if some other I/O error is detected when reading from the source
- *
- * @see #create(RandomAccessFile)
- */
-
- public static OggPage create(RandomAccessFile source, boolean skipData) throws IOException, EndOfOggStreamException, OggFormatException {
- return create((Object)source, skipData);
- }
-
- /**
- * this method equals to create(InputStream source, false)
- *
- * @see #create(InputStream, boolean)
- */
-
- public static OggPage create(InputStream source) throws IOException, EndOfOggStreamException, OggFormatException {
- return create(source, false);
- }
-
- /**
- * This method is called to read data from the current position in the
- * specified InpuStream and create a new OggPage instance based on the data
- * read. If the parameter <code>skipData</code> is set to <code>true</code>,
- * the actual page segments (page data) is skipped and not read into
- * memory. This mode is useful when scanning through an ogg file to build
- * a seek table.
- *
- * @param source the source from which the ogg page is generated
- * @param skipData if set to <code>true</code>, the actual page data is not read into memory
- * @return an ogg page created by reading data from the specified source, starting at the current position
- * @throws FormatException if the data read from the specified source is not matching the specification for an ogg page
- * @throws EndOfStreamException if it is not possible to read an entire ogg page from the specified source
- * @throws IOException if some other I/O error is detected when reading from the source
- *
- * @see #create(InputStream)
- */
-
- public static OggPage create(InputStream source, boolean skipData) throws IOException, EndOfOggStreamException, OggFormatException {
- return create((Object)source, skipData);
- }
-
- /**
- * this method equals to create(byte[] source, false)
- *
- * @see #create(byte[], boolean)
- */
-
- public static OggPage create(byte[] source) throws IOException, EndOfOggStreamException, OggFormatException {
- return create(source, false);
- }
-
- /**
- * This method is called to
- * create a new OggPage instance based on the specified byte array.
- *
- * @param source the source from which the ogg page is generated
- * @param skipData if set to <code>true</code>, the actual page data is not read into memory
- * @return an ogg page created by reading data from the specified source, starting at the current position
- * @throws FormatException if the data read from the specified source is not matching the specification for an ogg page
- * @throws EndOfStreamException if it is not possible to read an entire ogg page from the specified source
- * @throws IOException if some other I/O error is detected when reading from the source
- *
- * @see #create(byte[])
- */
-
- public static OggPage create(byte[] source, boolean skipData) throws IOException, EndOfOggStreamException, OggFormatException {
- return create((Object)source, skipData);
- }
-
- private static OggPage create(Object source, boolean skipData) throws IOException, EndOfOggStreamException, OggFormatException {
-
- try {
- int sourceOffset=27;
-
- byte[] header=new byte[27];
- if(source instanceof RandomAccessFile) {
- RandomAccessFile raf=(RandomAccessFile)source;
- if(raf.getFilePointer()==raf.length()) {
- return null;
- }
- raf.readFully(header);
- }
- else if(source instanceof InputStream) {
- readFully((InputStream)source, header);
- }
- else if(source instanceof byte[]) {
- System.arraycopy((byte[])source, 0, header, 0, 27);
- }
-
- BitInputStream bdSource=new ByteArrayBitInputStream(header);
-
- int capture=bdSource.getInt(32);
-
- if(capture!=0x5367674f) {
- //throw new FormatException("Ogg page does not start with 'OggS' (0x4f676753)");
-
- /*
- ** This condition is IMHO an error, but older Ogg files often contain
- ** pages with a different capture than OggS. I am not sure how to
- ** manage these pages, but the decoder seems to work properly, if
- ** the incorrect capture is simply ignored.
- */
-
- String cs=Integer.toHexString(capture);
- while(cs.length()<8) {
- cs="0"+cs;
- }
- cs=cs.substring(6, 8)+cs.substring(4, 6)+cs.substring(2, 4)+cs.substring(0, 2);
- char c1=(char)(Integer.valueOf(cs.substring(0, 2), 16).intValue());
- char c2=(char)(Integer.valueOf(cs.substring(2, 4), 16).intValue());
- char c3=(char)(Integer.valueOf(cs.substring(4, 6), 16).intValue());
- char c4=(char)(Integer.valueOf(cs.substring(6, 8), 16).intValue());
- System.out.println("Ogg packet header is 0x"+cs+" ("+c1+c2+c3+c4+"), should be 0x4f676753 (OggS)");
- }
-
- int version=bdSource.getInt(8);
- byte tmp=(byte)bdSource.getInt(8);
- boolean bf1=(tmp&1)!=0;
- boolean bos=(tmp&2)!=0;
- boolean eos=(tmp&4)!=0;
- long absoluteGranulePosition=bdSource.getLong(64);
- int streamSerialNumber=bdSource.getInt(32);
- int pageSequenceNumber=bdSource.getInt(32);
- int pageCheckSum=bdSource.getInt(32);
- int pageSegments=bdSource.getInt(8);
-
- //System.out.println("OggPage: "+streamSerialNumber+" / "+absoluteGranulePosition+" / "+pageSequenceNumber);
-
- int[] segmentOffsets=new int[pageSegments];
- int[] segmentLengths=new int[pageSegments];
- int totalLength=0;
-
- byte[] segmentTable=new byte[pageSegments];
- byte[] tmpBuf=new byte[1];
-
- for(int i=0; i<pageSegments; i++) {
- int l=0;
- if(source instanceof RandomAccessFile) {
- l=((int)((RandomAccessFile)source).readByte()&0xff);
- }
- else if(source instanceof InputStream) {
- l=(int)((InputStream)source).read();
- }
- else if(source instanceof byte[]) {
- l=(int)((byte[])source)[sourceOffset++];
- l&=255;
- }
- segmentTable[i]=(byte)l;
- segmentLengths[i]=l;
- segmentOffsets[i]=totalLength;
- totalLength+=l;
- }
-
- byte[] data=null;
-
- if(!skipData) {
-
- //System.out.println("createPage: "+absoluteGranulePosition*1000/44100);
-
- data=new byte[totalLength];
- //source.read(data, 0, totalLength);
- if(source instanceof RandomAccessFile) {
- ((RandomAccessFile)source).readFully(data);
- }
- else if(source instanceof InputStream) {
- readFully((InputStream)source, data);
- }
- else if(source instanceof byte[]) {
- System.arraycopy(source, sourceOffset, data, 0, totalLength);
- }
- }
-
- return new OggPage(version, bf1, bos, eos, absoluteGranulePosition, streamSerialNumber, pageSequenceNumber, pageCheckSum, segmentOffsets, segmentLengths, totalLength, header, segmentTable, data);
- }
- catch(EOFException e) {
- throw new EndOfOggStreamException();
- }
- }
-
- private static void readFully(InputStream source, byte[] buffer) throws IOException {
- int total=0;
- while(total<buffer.length) {
- int read=source.read(buffer, total, buffer.length-total);
- if(read==-1) {
- throw new EndOfOggStreamException();
- }
- total+=read;
- }
- }
-
- /**
- * Returns the absolute granule position of the last complete
- * packet contained in this Ogg page, or -1 if the page contains a single
- * packet, which is not completed on this page. For pages containing Vorbis
- * data, this value is the sample index within the Vorbis stream. The Vorbis
- * stream does not necessarily start with sample index 0.
- *
- * @return the absolute granule position of the last packet completed on
- * this page
- */
-
-
- public long getAbsoluteGranulePosition() {
- return absoluteGranulePosition;
- }
-
- /**
- * Returns the stream serial number of this ogg page.
- *
- * @return this page's serial number
- */
-
- public int getStreamSerialNumber() {
- return streamSerialNumber;
- }
-
- /**
- * Return the sequnce number of this ogg page.
- *
- * @return this page's sequence number
- */
-
- public int getPageSequenceNumber() {
- return pageSequenceNumber;
- }
-
- /**
- * Return the check sum of this ogg page.
- *
- * @return this page's check sum
- */
-
- public int getPageCheckSum() {
- return pageCheckSum;
- }
-
- /**
- * @return the total number of bytes in the page data
- */
-
-
- public int getTotalLength() {
- if(data!=null) {
- return 27+segmentTable.length+data.length;
- }
- else {
- return totalLength;
- }
- }
-
- /**
- * @return a ByteBuffer containing the page data
- */
-
-
- public byte[] getData() {
- return data;
- }
-
- public byte[] getHeader() {
- return header;
- }
-
- public byte[] getSegmentTable() {
- return segmentTable;
- }
-
- public int[] getSegmentOffsets() {
- return segmentOffsets;
- }
-
- public int[] getSegmentLengths() {
- return segmentLengths;
- }
-
- /**
- * @return <code>true</code> if this page begins with a continued packet
- */
-
- public boolean isContinued() {
- return continued;
- }
-
- /**
- * @return <code>true</code> if this page begins with a fresh packet
- */
-
- public boolean isFresh() {
- return !continued;
- }
-
- /**
- * @return <code>true</code> if this page is the beginning of a logical stream
- */
-
- public boolean isBos() {
- return bos;
- }
-
- /**
- * @return <code>true</code> if this page is the end of a logical stream
- */
-
- public boolean isEos() {
- return eos;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/OnDemandUrlStream.java b/songdbj/de/jarnbjo/ogg/OnDemandUrlStream.java
deleted file mode 100644
index 98159c4e7c..0000000000
--- a/songdbj/de/jarnbjo/ogg/OnDemandUrlStream.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.1 2003/04/10 19:48:22 jarnbjo
- * no message
- *
- * Revision 1.1 2003/03/31 00:23:04 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Implementation of the <code>PhysicalOggStream</code> interface for reading
- * an Ogg stream from a URL. This class performs
- * no internal caching, and will not read data from the network before
- * requested to do so. It is intended to be used in non-realtime applications
- * like file download managers or similar.
- */
-
-public class OnDemandUrlStream implements PhysicalOggStream {
-
- private boolean closed=false;
- private URLConnection source;
- private InputStream sourceStream;
- private Object drainLock=new Object();
- private LinkedList pageCache=new LinkedList();
- private long numberOfSamples=-1;
- private int contentLength=0;
- private int position=0;
-
- private HashMap logicalStreams=new HashMap();
- private OggPage firstPage;
-
- private static final int PAGECACHE_SIZE = 20;
-
- public OnDemandUrlStream(URL source) throws OggFormatException, IOException {
- this.source=source.openConnection();
- this.sourceStream=this.source.getInputStream();
-
- contentLength=this.source.getContentLength();
-
- firstPage=OggPage.create(sourceStream);
- position+=firstPage.getTotalLength();
- LogicalOggStreamImpl los=new LogicalOggStreamImpl(this, firstPage.getStreamSerialNumber());
- logicalStreams.put(new Integer(firstPage.getStreamSerialNumber()), los);
- los.checkFormat(firstPage);
- }
-
- public Collection getLogicalStreams() {
- return logicalStreams.values();
- }
-
- public boolean isOpen() {
- return !closed;
- }
-
- public void close() throws IOException {
- closed=true;
- sourceStream.close();
- }
-
- public int getContentLength() {
- return contentLength;
- }
-
- public int getPosition() {
- return position;
- }
-
- int pageNumber=2;
-
- public OggPage getOggPage(int index) throws IOException {
- if(firstPage!=null) {
- OggPage tmp=firstPage;
- firstPage=null;
- return tmp;
- }
- else {
- OggPage page=OggPage.create(sourceStream);
- position+=page.getTotalLength();
- return page;
- }
- }
-
- private LogicalOggStream getLogicalStream(int serialNumber) {
- return (LogicalOggStream)logicalStreams.get(new Integer(serialNumber));
- }
-
- public void setTime(long granulePosition) throws IOException {
- throw new UnsupportedOperationException("Method not supported by this class");
- }
-
- /**
- * @return always <code>false</code>
- */
-
- public boolean isSeekable() {
- return false;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/PhysicalOggStream.java b/songdbj/de/jarnbjo/ogg/PhysicalOggStream.java
deleted file mode 100644
index 5f342a38b7..0000000000
--- a/songdbj/de/jarnbjo/ogg/PhysicalOggStream.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/10 19:48:22 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/31 00:23:04 jarnbjo
- * no message
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * Interface providing access to a physical Ogg stream. Typically this is
- * a file.
- */
-
-public interface PhysicalOggStream {
-
- /**
- * Returns a collection of objects implementing <code>LogicalOggStream</code>
- * for accessing the separate logical streams within this physical Ogg stream.
- *
- * @return a collection of objects implementing <code>LogicalOggStream</code>
- * which are representing the logical streams contained within this
- * physical stream
- *
- * @see LogicalOggStream
- */
-
- public Collection getLogicalStreams();
-
- /**
- * Return the Ogg page with the absolute index <code>index</code>,
- * independent from the logical structure of this stream or if the
- * index parameter is -1, the next Ogg page is returned.
- * This method should only be used by implementations of <code>LogicalOggStream</code>
- * to access the raw pages.
- *
- * @param index the absolute index starting from 0 at the beginning of
- * the file or stream or -1 to get the next page in a non-seekable
- * stream
- *
- * @return the Ogg page with the physical absolute index <code>index</code>
- *
- * @throws OggFormatException if the ogg stream is corrupted
- * @throws IOException if some other IO error occurs
- */
-
- public OggPage getOggPage(int index) throws OggFormatException, IOException;
-
- /**
- * Checks if this stream is open for reading.
- *
- * @return <code>true</code> if this stream is open for reading,
- * <code>false</code> otherwise
- */
-
- public boolean isOpen();
-
- /**
- * Closes this stream. After invoking this method, no further access
- * to the streams data is possible.
- *
- * @throws IOException
- */
-
- public void close() throws IOException;
-
- /**
- * Sets this stream's (and its logical stream's) position to the granule
- * position. The next packet read from any logical stream will be the
- * first packet beginning on the first page with a granule position higher
- * than the argument.<br><br>
- *
- * At the moment, this method only works correctly for Ogg files with
- * a single logical Vorbis stream, and due to the different interpretations
- * of the granule position, depending on mixed content, this method will
- * never be able to work for mixed streams. Chained and interleaved streams are
- * also not yet supported. Actually, this method is only a hack to support
- * seeking from JMF, but may of course be abused otherwise too :)
- *
- * @param granulePosition
- *
- * @throws OggFormatException if the ogg stream is corrupted
- * @throws IOException if some other IO error occurs
- */
-
- public void setTime(long granulePosition) throws OggFormatException, IOException;
-
- /**
- * @return <code>true</code> if the stream is seekable, <code>false</code>
- * otherwise
- */
-
- public boolean isSeekable();
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/ogg/UncachedUrlStream.java b/songdbj/de/jarnbjo/ogg/UncachedUrlStream.java
deleted file mode 100644
index a07f0ac00e..0000000000
--- a/songdbj/de/jarnbjo/ogg/UncachedUrlStream.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.1 2003/04/10 19:48:22 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.ogg;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Implementation of the <code>PhysicalOggStream</code> interface for reading
- * an Ogg stream from a URL. This class performs only the necessary caching
- * to provide continous playback. Seeking within the stream is not supported.
- */
-
-public class UncachedUrlStream implements PhysicalOggStream {
-
- private boolean closed=false;
- private URLConnection source;
- private InputStream sourceStream;
- private Object drainLock=new Object();
- private LinkedList pageCache=new LinkedList();
- private long numberOfSamples=-1;
-
- private HashMap logicalStreams=new HashMap();
-
- private LoaderThread loaderThread;
-
- private static final int PAGECACHE_SIZE = 10;
-
- /** Creates an instance of the <code>PhysicalOggStream</code> interface
- * suitable for reading an Ogg stream from a URL.
- */
-
- public UncachedUrlStream(URL source) throws OggFormatException, IOException {
-
- this.source=source.openConnection();
- this.sourceStream=this.source.getInputStream();
-
- loaderThread=new LoaderThread(sourceStream, pageCache);
- new Thread(loaderThread).start();
-
- while(!loaderThread.isBosDone() || pageCache.size()<PAGECACHE_SIZE) {
- try {
- Thread.sleep(200);
- }
- catch (InterruptedException ex) {
- }
- //System.out.print("caching "+pageCache.size()+"/"+PAGECACHE_SIZE+" pages\r");
- }
- //System.out.println();
- }
-
- public Collection getLogicalStreams() {
- return logicalStreams.values();
- }
-
- public boolean isOpen() {
- return !closed;
- }
-
- public void close() throws IOException {
- closed=true;
- sourceStream.close();
- }
-
- /*
- public long getCacheLength() {
- return cacheLength;
- }
- */
-
- /*
- private OggPage getNextPage() throws EndOfOggStreamException, IOException, OggFormatException {
- return getNextPage(false);
- }
-
- private OggPage getNextPage(boolean skipData) throws EndOfOggStreamException, IOException, OggFormatException {
- return OggPage.create(sourceStream, skipData);
- }
- */
-
- public OggPage getOggPage(int index) throws IOException {
- while(pageCache.size()==0) {
- try {
- Thread.sleep(100);
- }
- catch (InterruptedException ex) {
- }
- }
- synchronized(drainLock) {
- //OggPage page=(OggPage)pageCache.getFirst();
- //pageCache.removeFirst();
- //return page;
- return (OggPage)pageCache.removeFirst();
- }
- }
-
- private LogicalOggStream getLogicalStream(int serialNumber) {
- return (LogicalOggStream)logicalStreams.get(new Integer(serialNumber));
- }
-
- public void setTime(long granulePosition) throws IOException {
- throw new UnsupportedOperationException("Method not supported by this class");
- }
-
- public class LoaderThread implements Runnable {
-
- private InputStream source;
- private LinkedList pageCache;
- private RandomAccessFile drain;
- private byte[] memoryCache;
-
- private boolean bosDone=false;
-
- private int pageNumber;
-
- public LoaderThread(InputStream source, LinkedList pageCache) {
- this.source=source;
- this.pageCache=pageCache;
- }
-
- public void run() {
- try {
- boolean eos=false;
- byte[] buffer=new byte[8192];
- while(!eos) {
- OggPage op=OggPage.create(source);
- synchronized (drainLock) {
- pageCache.add(op);
- }
-
- if(!op.isBos()) {
- bosDone=true;
- }
- if(op.isEos()) {
- eos=true;
- }
-
- LogicalOggStreamImpl los=(LogicalOggStreamImpl)getLogicalStream(op.getStreamSerialNumber());
- if(los==null) {
- los=new LogicalOggStreamImpl(UncachedUrlStream.this, op.getStreamSerialNumber());
- logicalStreams.put(new Integer(op.getStreamSerialNumber()), los);
- los.checkFormat(op);
- }
-
- //los.addPageNumberMapping(pageNumber);
- //los.addGranulePosition(op.getAbsoluteGranulePosition());
-
- pageNumber++;
-
- while(pageCache.size()>PAGECACHE_SIZE) {
- try {
- Thread.sleep(200);
- }
- catch (InterruptedException ex) {
- }
- }
- }
- }
- catch(EndOfOggStreamException e) {
- // ok
- }
- catch(IOException e) {
- e.printStackTrace();
- }
- }
-
- public boolean isBosDone() {
- return bosDone;
- }
- }
-
- /**
- * @return always <code>false</code>
- */
-
- public boolean isSeekable() {
- return false;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/util/audio/FadeableAudioInputStream.java b/songdbj/de/jarnbjo/util/audio/FadeableAudioInputStream.java
deleted file mode 100644
index 4916102d4b..0000000000
--- a/songdbj/de/jarnbjo/util/audio/FadeableAudioInputStream.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package de.jarnbjo.util.audio;
-
-import java.io.*;
-import javax.sound.sampled.*;
-
-public class FadeableAudioInputStream extends AudioInputStream {
-
- private AudioInputStream stream;
- private boolean fading=false;
- private double phi=0.0;
-
- public FadeableAudioInputStream(AudioInputStream stream) throws IOException {
- super(stream, stream.getFormat(), -1L);
- }
-
- public void fadeOut() {
- fading=true;
- phi=0.0;
- }
-
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- public int read(byte[] b, int offset, int length) throws IOException {
- int read=super.read(b, offset, length);
-
- //System.out.println("read "+read);
-
- if(fading) {
- int j=0, l=0, r=0;
- double gain=0.0;
-
- for(int i=offset; i<offset+read; i+=4) {
- j=i;
- l=((int)b[j++])&0xff;
- l|=((int)b[j++])<<8;
- r=((int)b[j++])&0xff;
- r|=((int)b[j])<<8;
-
- if(phi<Math.PI/2) {
- phi+=0.000015;
- }
-
- gain=Math.cos(phi);
- //System.out.println("gain "+gain);
-
- l=(int)(l*gain);
- r=(int)(r*gain);
-
- j=i;
- b[j++]=(byte)(l&0xff);
- b[j++]=(byte)((l>>8)&0xff);
- b[j++]=(byte)(r&0xff);
- b[j++]=(byte)((r>>8)&0xff);
- }
- }
-
- return read;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/util/io/BitInputStream.java b/songdbj/de/jarnbjo/util/io/BitInputStream.java
deleted file mode 100644
index 89cadb8380..0000000000
--- a/songdbj/de/jarnbjo/util/io/BitInputStream.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.5 2003/04/10 19:48:31 jarnbjo
- * no message
- *
- * Revision 1.4 2003/03/16 20:57:06 jarnbjo
- * no message
- *
- * Revision 1.3 2003/03/16 20:56:56 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:39 jarnbjo
- * no message
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.util.io;
-
-import java.io.IOException;
-
-/**
- * An interface with methods allowing bit-wise reading from
- * an input stream. All methods in this interface are optional
- * and an implementation not support a method or a specific state
- * (e.g. endian) will throw an UnspportedOperationException if
- * such a method is being called. This should be speicified in
- * the implementation documentation.
- */
-
-public interface BitInputStream {
-
- /**
- * constant for setting this stream's mode to little endian
- *
- * @see #setEndian(int)
- */
-
- public static final int LITTLE_ENDIAN = 0;
-
- /**
- * constant for setting this stream's mode to big endian
- *
- * @see #setEndian(int)
- */
-
- public static final int BIG_ENDIAN = 1;
-
- /**
- * reads one bit (as a boolean) from the input stream
- *
- * @return <code>true</code> if the next bit is 1,
- * <code>false</code> otherwise
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public boolean getBit() throws IOException;
-
- /**
- * reads <code>bits</code> number of bits from the input
- * stream
- *
- * @return the unsigned integer value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public int getInt(int bits) throws IOException;
-
- /**
- * reads <code>bits</code> number of bits from the input
- * stream
- *
- * @return the signed integer value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public int getSignedInt(int bits) throws IOException;
-
- /**
- * reads a huffman codeword based on the <code>root</code>
- * parameter and returns the decoded value
- *
- * @param root the root of the Huffman tree used to decode the codeword
- * @return the decoded unsigned integer value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public int getInt(HuffmanNode root) throws IOException;
-
- /**
- * reads an integer encoded as "signed rice" as described in
- * the FLAC audio format specification
- *
- * @param order
- * @return the decoded integer value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public int readSignedRice(int order) throws IOException;
-
- /**
- * fills the array from <code>offset</code> with <code>len</code>
- * integers encoded as "signed rice" as described in
- * the FLAC audio format specification
- *
- * @param order
- * @param buffer
- * @param offset
- * @param len
- * @return the decoded integer value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public void readSignedRice(int order, int[] buffer, int offset, int len) throws IOException;
-
- /**
- * reads <code>bits</code> number of bits from the input
- * stream
- *
- * @return the unsigned long value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public long getLong(int bits) throws IOException;
-
- /**
- * causes the read pointer to be moved to the beginning
- * of the next byte, remaining bits in the current byte
- * are discarded
- *
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public void align();
-
- /**
- * changes the endian mode used when reading bit-wise from
- * the stream, changing the mode mid-stream will cause the
- * read cursor to move to the beginning of the next byte
- * (as if calling the <code>allign</code> method
- *
- * @see #align()
- *
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public void setEndian(int endian);
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/util/io/ByteArrayBitInputStream.java b/songdbj/de/jarnbjo/util/io/ByteArrayBitInputStream.java
deleted file mode 100644
index 9c84c7daca..0000000000
--- a/songdbj/de/jarnbjo/util/io/ByteArrayBitInputStream.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/10 19:48:31 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:39 jarnbjo
- * no message
- *
- * Revision 1.1 2003/03/03 21:02:20 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.util.io;
-
-import java.io.IOException;
-
-/**
- * Implementation of the <code>BitInputStream</code> interface,
- * using a byte array as data source.
-*/
-
-public class ByteArrayBitInputStream implements BitInputStream {
-
- private byte[] source;
- private byte currentByte;
-
- private int endian;
-
- private int byteIndex=0;
- private int bitIndex=0;
-
- public ByteArrayBitInputStream(byte[] source) {
- this(source, LITTLE_ENDIAN);
- }
-
- public ByteArrayBitInputStream(byte[] source, int endian) {
- this.endian=endian;
- this.source=source;
- currentByte=source[0];
- bitIndex=(endian==LITTLE_ENDIAN)?0:7;
- }
-
- public boolean getBit() throws IOException {
- if(endian==LITTLE_ENDIAN) {
- if(bitIndex>7) {
- bitIndex=0;
- currentByte=source[++byteIndex];
- }
- return (currentByte&(1<<(bitIndex++)))!=0;
- }
- else {
- if(bitIndex<0) {
- bitIndex=7;
- currentByte=source[++byteIndex];
- }
- return (currentByte&(1<<(bitIndex--)))!=0;
- }
- }
-
- public int getInt(int bits) throws IOException {
- if(bits>32) {
- throw new IllegalArgumentException("Argument \"bits\" must be <= 32");
- }
- int res=0;
- if(endian==LITTLE_ENDIAN) {
- for(int i=0; i<bits; i++) {
- if(getBit()) {
- res|=(1<<i);
- }
- }
- }
- else {
- if(bitIndex<0) {
- bitIndex=7;
- currentByte=source[++byteIndex];
- }
- if(bits<=bitIndex+1) {
- int ci=((int)currentByte)&0xff;
- int offset=1+bitIndex-bits;
- int mask=((1<<bits)-1)<<offset;
- res=(ci&mask)>>offset;
- bitIndex-=bits;
- }
- else {
- res=(((int)currentByte)&0xff&((1<<(bitIndex+1))-1))<<(bits-bitIndex-1);
- bits-=bitIndex+1;
- currentByte=source[++byteIndex];
- while(bits>=8) {
- bits-=8;
- res|=(((int)source[byteIndex])&0xff)<<bits;
- currentByte=source[++byteIndex];
- }
- if(bits>0) {
- int ci=((int)source[byteIndex])&0xff;
- res|=(ci>>(8-bits))&((1<<bits)-1);
- bitIndex=7-bits;
- }
- else {
- currentByte=source[--byteIndex];
- bitIndex=-1;
- }
- }
- }
-
- return res;
- }
-
- public int getSignedInt(int bits) throws IOException {
- int raw=getInt(bits);
- if(raw>=1<<(bits-1)) {
- raw-=1<<bits;
- }
- return raw;
- }
-
- public int getInt(HuffmanNode root) throws IOException {
- while(root.value==null) {
- if(bitIndex>7) {
- bitIndex=0;
- currentByte=source[++byteIndex];
- }
- root=(currentByte&(1<<(bitIndex++)))!=0?root.o1:root.o0;
- }
- return root.value.intValue();
- }
-
- public long getLong(int bits) throws IOException {
- if(bits>64) {
- throw new IllegalArgumentException("Argument \"bits\" must be <= 64");
- }
- long res=0;
- if(endian==LITTLE_ENDIAN) {
- for(int i=0; i<bits; i++) {
- if(getBit()) {
- res|=(1L<<i);
- }
- }
- }
- else {
- for(int i=bits-1; i>=0; i--) {
- if(getBit()) {
- res|=(1L<<i);
- }
- }
- }
- return res;
- }
-
- /**
- * <p>reads an integer encoded as "signed rice" as described in
- * the FLAC audio format specification</p>
- *
- * <p><b>not supported for little endian</b></p>
- *
- * @param order
- * @return the decoded integer value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public int readSignedRice(int order) throws IOException {
-
- int msbs=-1, lsbs=0, res=0;
-
- if(endian==LITTLE_ENDIAN) {
- // little endian
- throw new UnsupportedOperationException("ByteArrayBitInputStream.readSignedRice() is only supported in big endian mode");
- }
- else {
- // big endian
-
- byte cb=source[byteIndex];
- do {
- msbs++;
- if(bitIndex<0) {
- bitIndex=7;
- byteIndex++;
- cb=source[byteIndex];
- }
- } while((cb&(1<<bitIndex--))==0);
-
- int bits=order;
-
- if(bitIndex<0) {
- bitIndex=7;
- byteIndex++;
- }
- if(bits<=bitIndex+1) {
- int ci=((int)source[byteIndex])&0xff;
- int offset=1+bitIndex-bits;
- int mask=((1<<bits)-1)<<offset;
- lsbs=(ci&mask)>>offset;
- bitIndex-=bits;
- }
- else {
- lsbs=(((int)source[byteIndex])&0xff&((1<<(bitIndex+1))-1))<<(bits-bitIndex-1);
- bits-=bitIndex+1;
- byteIndex++;
- while(bits>=8) {
- bits-=8;
- lsbs|=(((int)source[byteIndex])&0xff)<<bits;
- byteIndex++;
- }
- if(bits>0) {
- int ci=((int)source[byteIndex])&0xff;
- lsbs|=(ci>>(8-bits))&((1<<bits)-1);
- bitIndex=7-bits;
- }
- else {
- byteIndex--;
- bitIndex=-1;
- }
- }
-
- res=(msbs<<order)|lsbs;
- }
-
- return (res&1)==1?-(res>>1)-1:(res>>1);
- }
-
- /**
- * <p>fills the array from <code>offset</code> with <code>len</code>
- * integers encoded as "signed rice" as described in
- * the FLAC audio format specification</p>
- *
- * <p><b>not supported for little endian</b></p>
- *
- * @param order
- * @param buffer
- * @param offset
- * @param len
- * @return the decoded integer value read from the stream
- *
- * @throws IOException if an I/O error occurs
- * @throws UnsupportedOperationException if the method is not supported by the implementation
- */
-
- public void readSignedRice(int order, int[] buffer, int off, int len) throws IOException {
-
- if(endian==LITTLE_ENDIAN) {
- // little endian
- throw new UnsupportedOperationException("ByteArrayBitInputStream.readSignedRice() is only supported in big endian mode");
- }
- else {
- // big endian
- for(int i=off; i<off+len; i++) {
-
- int msbs=-1, lsbs=0;
-
- byte cb=source[byteIndex];
- do {
- msbs++;
- if(bitIndex<0) {
- bitIndex=7;
- byteIndex++;
- cb=source[byteIndex];
- }
- } while((cb&(1<<bitIndex--))==0);
-
- int bits=order;
-
- if(bitIndex<0) {
- bitIndex=7;
- byteIndex++;
- }
- if(bits<=bitIndex+1) {
- int ci=((int)source[byteIndex])&0xff;
- int offset=1+bitIndex-bits;
- int mask=((1<<bits)-1)<<offset;
- lsbs=(ci&mask)>>offset;
- bitIndex-=bits;
- }
- else {
- lsbs=(((int)source[byteIndex])&0xff&((1<<(bitIndex+1))-1))<<(bits-bitIndex-1);
- bits-=bitIndex+1;
- byteIndex++;
- while(bits>=8) {
- bits-=8;
- lsbs|=(((int)source[byteIndex])&0xff)<<bits;
- byteIndex++;
- }
- if(bits>0) {
- int ci=((int)source[byteIndex])&0xff;
- lsbs|=(ci>>(8-bits))&((1<<bits)-1);
- bitIndex=7-bits;
- }
- else {
- byteIndex--;
- bitIndex=-1;
- }
- }
-
- int res=(msbs<<order)|lsbs;
- buffer[i]=(res&1)==1?-(res>>1)-1:(res>>1);
- }
- }
- }
-
- public void align() {
- if(endian==BIG_ENDIAN && bitIndex>=0) {
- bitIndex=7;
- byteIndex++;
- }
- else if(endian==LITTLE_ENDIAN && bitIndex<=7) {
- bitIndex=0;
- byteIndex++;
- }
- }
-
- public void setEndian(int endian) {
- if(this.endian==BIG_ENDIAN && endian==LITTLE_ENDIAN) {
- bitIndex=0;
- byteIndex++;
- }
- else if(this.endian==LITTLE_ENDIAN && endian==BIG_ENDIAN) {
- bitIndex=7;
- byteIndex++;
- }
- this.endian=endian;
- }
-
- /**
- * @return the byte array used as a source for this instance
- */
-
- public byte[] getSource() {
- return source;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/util/io/HuffmanNode.java b/songdbj/de/jarnbjo/util/io/HuffmanNode.java
deleted file mode 100644
index 88600a4ddd..0000000000
--- a/songdbj/de/jarnbjo/util/io/HuffmanNode.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/04/10 19:48:31 jarnbjo
- * no message
- *
- */
-
-package de.jarnbjo.util.io;
-
-import java.io.IOException;
-import de.jarnbjo.util.io.BitInputStream;
-
-/**
- * Representation of a node in a Huffman tree, used to read
- * Huffman compressed codewords from e.g. a Vorbis stream.
- */
-
-final public class HuffmanNode {
-
- private HuffmanNode parent;
- private int depth=0;
- protected HuffmanNode o0, o1;
- protected Integer value;
- private boolean full=false;
-
- /**
- * creates a new Huffman tree root node
- */
-
- public HuffmanNode() {
- this(null);
- }
-
- protected HuffmanNode(HuffmanNode parent) {
- this.parent=parent;
- if(parent!=null) {
- depth=parent.getDepth()+1;
- }
- }
-
- protected HuffmanNode(HuffmanNode parent, int value) {
- this(parent);
- this.value=new Integer(value);
- full=true;
- }
-
- protected int read(BitInputStream bis) throws IOException {
- HuffmanNode iter=this;
- while(iter.value==null) {
- iter=bis.getBit()?iter.o1:iter.o0;
- }
- return iter.value.intValue();
- }
-
- protected HuffmanNode get0() {
- return o0==null?set0(new HuffmanNode(this)):o0;
- }
-
- protected HuffmanNode get1() {
- return o1==null?set1(new HuffmanNode(this)):o1;
- }
-
- protected Integer getValue() {
- return value;
- }
-
- private HuffmanNode getParent() {
- return parent;
- }
-
- protected int getDepth() {
- return depth;
- }
-
- private boolean isFull() {
- return full?true:(full=o0!=null&&o0.isFull()&&o1!=null&&o1.isFull());
- }
-
- private HuffmanNode set0(HuffmanNode value) {
- return o0=value;
- }
-
- private HuffmanNode set1(HuffmanNode value) {
- return o1=value;
- }
-
- private void setValue(Integer value) {
- full=true;
- this.value=value;
- }
-
- /**
- * creates a new tree node at the first free location at the given
- * depth, and assigns the value to it
- *
- * @param depth the tree depth of the new node (codeword length in bits)
- * @param value the node's new value
- */
-
- public boolean setNewValue(int depth, int value) {
- if(isFull()) {
- return false;
- }
- if(depth==1) {
- if(o0==null) {
- set0(new HuffmanNode(this, value));
- return true;
- }
- else if(o1==null) {
- set1(new HuffmanNode(this, value));
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return get0().setNewValue(depth-1, value)?
- true:
- get1().setNewValue(depth-1, value);
- }
- }
-}
diff --git a/songdbj/de/jarnbjo/vorbis/AudioPacket.java b/songdbj/de/jarnbjo/vorbis/AudioPacket.java
deleted file mode 100644
index 90a54073c1..0000000000
--- a/songdbj/de/jarnbjo/vorbis/AudioPacket.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 06:39:06 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-class AudioPacket {
-
- private int modeNumber;
- private Mode mode;
- private Mapping mapping;
- private int n; // block size
- private boolean blockFlag, previousWindowFlag, nextWindowFlag;
-
- private int windowCenter, leftWindowStart, leftWindowEnd, leftN, rightWindowStart, rightWindowEnd, rightN;
- private float[] window;
- private float[][] pcm;
- private int[][] pcmInt;
-
- private Floor[] channelFloors;
- private boolean[] noResidues;
-
- private final static float[][] windows=new float[8][];
-
- protected AudioPacket(final VorbisStream vorbis, final BitInputStream source) throws VorbisFormatException, IOException {
-
- final SetupHeader sHeader=vorbis.getSetupHeader();
- final IdentificationHeader iHeader=vorbis.getIdentificationHeader();
- final Mode[] modes=sHeader.getModes();
- final Mapping[] mappings=sHeader.getMappings();
- final Residue[] residues=sHeader.getResidues();
- final int channels=iHeader.getChannels();
-
- if(source.getInt(1)!=0) {
- throw new VorbisFormatException("Packet type mismatch when trying to create an audio packet.");
- }
-
- modeNumber=source.getInt(Util.ilog(modes.length-1));
-
- try {
- mode=modes[modeNumber];
- }
- catch(ArrayIndexOutOfBoundsException e) {
- throw new VorbisFormatException("Reference to invalid mode in audio packet.");
- }
-
- mapping=mappings[mode.getMapping()];
-
- final int[] magnitudes=mapping.getMagnitudes();
- final int[] angles=mapping.getAngles();
-
- blockFlag=mode.getBlockFlag();
-
- final int blockSize0=iHeader.getBlockSize0();
- final int blockSize1=iHeader.getBlockSize1();
-
- n=blockFlag?blockSize1:blockSize0;
-
- if(blockFlag) {
- previousWindowFlag=source.getBit();
- nextWindowFlag=source.getBit();
- }
-
- windowCenter=n/2;
-
- if(blockFlag && !previousWindowFlag) {
- leftWindowStart=n/4-blockSize0/4;
- leftWindowEnd=n/4+blockSize0/4;
- leftN=blockSize0/2;
- }
- else {
- leftWindowStart=0;
- leftWindowEnd=n/2;
- leftN=windowCenter;
- }
-
- if(blockFlag && !nextWindowFlag) {
- rightWindowStart=n*3/4-blockSize0/4;
- rightWindowEnd=n*3/4+blockSize0/4;
- rightN=blockSize0/2;
- }
- else {
- rightWindowStart=windowCenter;
- rightWindowEnd=n;
- rightN=n/2;
- }
-
- window=getComputedWindow();//new double[n];
-
- channelFloors=new Floor[channels];
- noResidues=new boolean[channels];
-
- pcm=new float[channels][n];
- pcmInt=new int[channels][n];
-
- boolean allFloorsEmpty=true;
-
- for(int i=0; i<channels; i++) {
- int submapNumber=mapping.getMux()[i];
- int floorNumber=mapping.getSubmapFloors()[submapNumber];
- Floor decodedFloor=sHeader.getFloors()[floorNumber].decodeFloor(vorbis, source);
- channelFloors[i]=decodedFloor;
- noResidues[i]=decodedFloor==null;
- if(decodedFloor!=null) {
- allFloorsEmpty=false;
- }
- }
-
- if(allFloorsEmpty) {
- return;
- }
-
- for(int i=0; i<magnitudes.length; i++) {
- if(!noResidues[magnitudes[i]] ||
- !noResidues[angles[i]]) {
-
- noResidues[magnitudes[i]]=false;
- noResidues[angles[i]]=false;
- }
- }
-
- Residue[] decodedResidues=new Residue[mapping.getSubmaps()];
-
- for(int i=0; i<mapping.getSubmaps(); i++) {
- int ch=0;
- boolean[] doNotDecodeFlags=new boolean[channels];
- for(int j=0; j<channels; j++) {
- if(mapping.getMux()[j]==i) {
- doNotDecodeFlags[ch++]=noResidues[j];
- }
- }
- int residueNumber=mapping.getSubmapResidues()[i];
- Residue residue=residues[residueNumber];
-
- residue.decodeResidue(vorbis, source, mode, ch, doNotDecodeFlags, pcm);
- }
-
-
- for(int i=mapping.getCouplingSteps()-1; i>=0; i--) {
- double newA=0, newM=0;
- final float[] magnitudeVector=pcm[magnitudes[i]];
- final float[] angleVector=pcm[angles[i]];
- for(int j=0; j<magnitudeVector.length; j++) {
- float a=angleVector[j];
- float m=magnitudeVector[j];
- if(a>0) {
- //magnitudeVector[j]=m;
- angleVector[j]=m>0?m-a:m+a;
- }
- else {
- magnitudeVector[j]=m>0?m+a:m-a;
- angleVector[j]=m;
- }
- }
- }
-
- for(int i=0; i<channels; i++) {
- if(channelFloors[i]!=null) {
- channelFloors[i].computeFloor(pcm[i]);
- }
- }
-
- // perform an inverse mdct to all channels
-
- for(int i=0; i<channels; i++) {
- MdctFloat mdct=blockFlag?iHeader.getMdct1():iHeader.getMdct0();
- mdct.imdct(pcm[i], window, pcmInt[i]);
- }
-
- }
-
- private float[] getComputedWindow() {
- int ix=(blockFlag?4:0)+(previousWindowFlag?2:0)+(nextWindowFlag?1:0);
- float[] w=windows[ix];
- if(w==null) {
- w=new float[n];
-
- for(int i=0;i<leftN;i++){
- float x=(float)((i+.5)/leftN*Math.PI/2.);
- x=(float)Math.sin(x);
- x*=x;
- x*=(float)Math.PI/2.;
- x=(float)Math.sin(x);
- w[i+leftWindowStart]=x;
- }
-
- for(int i=leftWindowEnd; i<rightWindowStart; w[i++]=1.0f);
-
- for(int i=0;i<rightN;i++){
- float x=(float)((rightN-i-.5)/rightN*Math.PI/2.);
- x=(float)Math.sin(x);
- x*=x;
- x*=(float)Math.PI/2.;
- x=(float)Math.sin(x);
- w[i+rightWindowStart]=x;
- }
-
- windows[ix]=w;
- }
- return w;
- }
-
- protected int getNumberOfSamples() {
- return rightWindowStart-leftWindowStart;
- }
-
- protected int getPcm(final AudioPacket previousPacket, final int[][] buffer) {
- int channels=pcm.length;
- int val;
-
- // copy left window flank and mix with right window flank from
- // the previous audio packet
- for(int i=0; i<channels; i++) {
- int j1=0, j2=previousPacket.rightWindowStart;
- final int[] ppcm=previousPacket.pcmInt[i];
- final int[] tpcm=pcmInt[i];
- final int[] target=buffer[i];
-
- for(int j=leftWindowStart; j<leftWindowEnd; j++) {
- val=ppcm[j2++]+tpcm[j];
- if(val>32767) val=32767;
- if(val<-32768) val=-32768;
- target[j1++]=val;
- }
- }
-
- // use System.arraycopy to copy the middle part (if any)
- // of the window
- if(leftWindowEnd+1<rightWindowStart) {
- for(int i=0; i<channels; i++) {
- System.arraycopy(pcmInt[i], leftWindowEnd, buffer[i], leftWindowEnd-leftWindowStart, rightWindowStart-leftWindowEnd);
- }
- }
-
- return rightWindowStart-leftWindowStart;
- }
-
- protected void getPcm(final AudioPacket previousPacket, final byte[] buffer) {
- int channels=pcm.length;
- int val;
-
- // copy left window flank and mix with right window flank from
- // the previous audio packet
- for(int i=0; i<channels; i++) {
- int ix=0, j2=previousPacket.rightWindowStart;
- final int[] ppcm=previousPacket.pcmInt[i];
- final int[] tpcm=pcmInt[i];
- for(int j=leftWindowStart; j<leftWindowEnd; j++) {
- val=ppcm[j2++]+tpcm[j];
- if(val>32767) val=32767;
- if(val<-32768) val=-32768;
- buffer[ix+(i*2)+1]=(byte)(val&0xff);
- buffer[ix+(i*2)]=(byte)((val>>8)&0xff);
- ix+=channels*2;
- }
-
- ix=(leftWindowEnd-leftWindowStart)*channels*2;
- for(int j=leftWindowEnd; j<rightWindowStart; j++) {
- val=tpcm[j];
- if(val>32767) val=32767;
- if(val<-32768) val=-32768;
- buffer[ix+(i*2)+1]=(byte)(val&0xff);
- buffer[ix+(i*2)]=(byte)((val>>8)&0xff);
- ix+=channels*2;
- }
- }
- }
-
- protected float[] getWindow() {
- return window;
- }
-
- protected int getLeftWindowStart() {
- return leftWindowStart;
- }
-
- protected int getLeftWindowEnd() {
- return leftWindowEnd;
- }
-
- protected int getRightWindowStart() {
- return rightWindowStart;
- }
-
- protected int getRightWindowEnd() {
- return rightWindowEnd;
- }
-
- public int[][] getPcm() {
- return pcmInt;
- }
-
- public float[][] getFreqencyDomain() {
- return pcm;
- }
-}
diff --git a/songdbj/de/jarnbjo/vorbis/CodeBook.java b/songdbj/de/jarnbjo/vorbis/CodeBook.java
deleted file mode 100644
index c865b120ca..0000000000
--- a/songdbj/de/jarnbjo/vorbis/CodeBook.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 06:39:06 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/10 19:49:04 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import de.jarnbjo.util.io.BitInputStream;
-import de.jarnbjo.util.io.HuffmanNode;
-
-class CodeBook {
-
- private HuffmanNode huffmanRoot;
- private int dimensions, entries;
-
- private int[] entryLengths;
- private float[][] valueVector;
-
- protected CodeBook(BitInputStream source) throws VorbisFormatException, IOException {
-
- // check sync
- if(source.getInt(24)!=0x564342) {
- throw new VorbisFormatException("The code book sync pattern is not correct.");
- }
-
- dimensions=source.getInt(16);
- entries=source.getInt(24);
-
- entryLengths=new int[entries];
-
- boolean ordered=source.getBit();
-
- if(ordered) {
- int cl=source.getInt(5)+1;
- for(int i=0; i<entryLengths.length; ) {
- int num=source.getInt(Util.ilog(entryLengths.length-i));
- if(i+num>entryLengths.length) {
- throw new VorbisFormatException("The codebook entry length list is longer than the actual number of entry lengths.");
- }
- Arrays.fill(entryLengths, i, i+num, cl);
- cl++;
- i+=num;
- }
- }
- else {
- // !ordered
- boolean sparse=source.getBit();
-
- if(sparse) {
- for(int i=0; i<entryLengths.length; i++) {
- if(source.getBit()) {
- entryLengths[i]=source.getInt(5)+1;
- }
- else {
- entryLengths[i]=-1;
- }
- }
- }
- else {
- // !sparse
- for(int i=0; i<entryLengths.length; i++) {
- entryLengths[i]=source.getInt(5)+1;
- }
- }
- }
-
- if (!createHuffmanTree(entryLengths)) {
- throw new VorbisFormatException("An exception was thrown when building the codebook Huffman tree.");
- }
-
- int codeBookLookupType=source.getInt(4);
-
- switch(codeBookLookupType) {
- case 0:
- // codebook has no scalar vectors to be calculated
- break;
- case 1:
- case 2:
- float codeBookMinimumValue=Util.float32unpack(source.getInt(32));
- float codeBookDeltaValue=Util.float32unpack(source.getInt(32));
-
- int codeBookValueBits=source.getInt(4)+1;
- boolean codeBookSequenceP=source.getBit();
-
- int codeBookLookupValues=0;
-
- if(codeBookLookupType==1) {
- codeBookLookupValues=Util.lookup1Values(entries, dimensions);
- }
- else {
- codeBookLookupValues=entries*dimensions;
- }
-
- int codeBookMultiplicands[]=new int[codeBookLookupValues];
-
- for(int i=0; i<codeBookMultiplicands.length; i++) {
- codeBookMultiplicands[i]=source.getInt(codeBookValueBits);
- }
-
- valueVector=new float[entries][dimensions];
-
- if(codeBookLookupType==1) {
- for(int i=0; i<entries; i++) {
- float last=0;
- int indexDivisor=1;
- for(int j=0; j<dimensions; j++) {
- int multiplicandOffset=
- (i/indexDivisor)%codeBookLookupValues;
- valueVector[i][j]=
- codeBookMultiplicands[multiplicandOffset]*codeBookDeltaValue+codeBookMinimumValue+last;
- if(codeBookSequenceP) {
- last=valueVector[i][j];
- }
- indexDivisor*=codeBookLookupValues;
- }
- }
- }
- else {
- throw new UnsupportedOperationException();
- /** @todo implement */
- }
- break;
- default:
- throw new VorbisFormatException("Unsupported codebook lookup type: "+codeBookLookupType);
- }
- }
-
- private static long totalTime=0;
-
- private boolean createHuffmanTree(int[] entryLengths) {
- huffmanRoot=new HuffmanNode();
- for(int i=0; i<entryLengths.length; i++) {
- int el=entryLengths[i];
- if(el>0) {
- if(!huffmanRoot.setNewValue(el, i)) {
- return false;
- }
- }
- }
- return true;
- }
-
- protected int getDimensions() {
- return dimensions;
- }
-
- protected int getEntries() {
- return entries;
- }
-
- protected HuffmanNode getHuffmanRoot() {
- return huffmanRoot;
- }
-
- //public float[] readVQ(ReadableBitChannel source) throws IOException {
- // return valueVector[readInt(source)];
- //}
-
- protected int readInt(final BitInputStream source) throws IOException {
- return source.getInt(huffmanRoot);
- /*
- HuffmanNode node;
- for(node=huffmanRoot; node.value==null; node=source.getBit()?node.o1:node.o0);
- return node.value.intValue();
- */
- }
-
- protected void readVvAdd(float[][] a, BitInputStream source, int offset, int length)
- throws VorbisFormatException, IOException {
-
- int i,j;//k;//entry;
- int chptr=0;
- int ch=a.length;
-
- if(ch==0) {
- return;
- }
-
- int lim=(offset+length)/ch;
-
- for(i=offset/ch;i<lim;){
- final float[] ve=valueVector[source.getInt(huffmanRoot)];
- for(j=0;j<dimensions;j++){
- a[chptr++][i]+=ve[j];
- if(chptr==ch){
- chptr=0;
- i++;
- }
- }
- }
- }
-
- /*
- public void readVAdd(double[] a, ReadableBitChannel source, int offset, int length)
- throws FormatException, IOException {
-
- int i,j,entry;
- int t;
-
- if(dimensions>8){
- for(i=0;i<length;){
- entry = readInt(source);
- //if(entry==-1)return(-1);
- //t=entry*dimensions;
- for(j=0;j<dimensions;){
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- }
- }
- }
- else{
- for(i=0;i<length;){
- entry=readInt(source);
- //if(entry==-1)return(-1);
- //t=entry*dim;
- j=0;
- switch(dimensions){
- case 8:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 7:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 6:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 5:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 4:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 3:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 2:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 1:
- a[offset+(i++)]+=valueVector[entry][j++];//valuelist[t+(j++)];
- case 0:
- break;
- }
- }
- }
- }
- */
-
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/CommentHeader.java b/songdbj/de/jarnbjo/vorbis/CommentHeader.java
deleted file mode 100644
index dd00ebca38..0000000000
--- a/songdbj/de/jarnbjo/vorbis/CommentHeader.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.*;
-
-import java.util.*;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-/**
- */
-
-public class CommentHeader {
-
- public static final String TITLE = "TITLE";
- public static final String ARTIST = "ARTIST";
- public static final String ALBUM = "ALBUM";
- public static final String TRACKNUMBER = "TRACKNUMBER";
- public static final String VERSION = "VERSION";
- public static final String PERFORMER = "PERFORMER";
- public static final String COPYRIGHT = "COPYRIGHT";
- public static final String LICENSE = "LICENSE";
- public static final String ORGANIZATION = "ORGANIZATION";
- public static final String DESCRIPTION = "DESCRIPTION";
- public static final String GENRE = "GENRE";
- public static final String DATE = "DATE";
- public static final String LOCATION = "LOCATION";
- public static final String CONTACT = "CONTACT";
- public static final String ISRC = "ISRC";
-
- private String vendor;
- private HashMap comments=new HashMap();
- private boolean framingBit;
-
- private static final long HEADER = 0x736962726f76L; // 'vorbis'
-
- public CommentHeader(BitInputStream source) throws VorbisFormatException, IOException {
- if(source.getLong(48)!=HEADER) {
- throw new VorbisFormatException("The identification header has an illegal leading.");
- }
-
- vendor=getString(source);
-
- int ucLength=source.getInt(32);
-
- for(int i=0; i<ucLength; i++) {
- String comment=getString(source);
- int ix=comment.indexOf('=');
- String key=comment.substring(0, ix);
- String value=comment.substring(ix+1);
- //comments.put(key, value);
- addComment(key, value);
- }
-
- framingBit=source.getInt(8)!=0;
- }
-
- private void addComment(String key, String value) {
- key = key.toUpperCase(); // Comment keys are case insensitive
- ArrayList al=(ArrayList)comments.get(key);
- if(al==null) {
- al=new ArrayList();
- comments.put(key, al);
- }
- al.add(value);
- }
-
- public String getVendor() {
- return vendor;
- }
-
- public String getComment(String key) {
- ArrayList al=(ArrayList)comments.get(key);
- return al==null?(String)null:(String)al.get(0);
- }
-
- public String[] getComments(String key) {
- ArrayList al=(ArrayList)comments.get(key);
- return al==null?new String[0]:(String[])al.toArray(new String[al.size()]);
- }
-
- public String getTitle() {
- return getComment(TITLE);
- }
-
- public String[] getTitles() {
- return getComments(TITLE);
- }
-
- public String getVersion() {
- return getComment(VERSION);
- }
-
- public String[] getVersions() {
- return getComments(VERSION);
- }
-
- public String getAlbum() {
- return getComment(ALBUM);
- }
-
- public String[] getAlbums() {
- return getComments(ALBUM);
- }
-
- public String getTrackNumber() {
- return getComment(TRACKNUMBER);
- }
-
- public String[] getTrackNumbers() {
- return getComments(TRACKNUMBER);
- }
-
- public String getArtist() {
- return getComment(ARTIST);
- }
-
- public String[] getArtists() {
- return getComments(ARTIST);
- }
-
- public String getPerformer() {
- return getComment(PERFORMER);
- }
-
- public String[] getPerformers() {
- return getComments(PERFORMER);
- }
-
- public String getCopyright() {
- return getComment(COPYRIGHT);
- }
-
- public String[] getCopyrights() {
- return getComments(COPYRIGHT);
- }
-
- public String getLicense() {
- return getComment(LICENSE);
- }
-
- public String[] getLicenses() {
- return getComments(LICENSE);
- }
-
- public String getOrganization() {
- return getComment(ORGANIZATION);
- }
-
- public String[] getOrganizations() {
- return getComments(ORGANIZATION);
- }
-
- public String getDescription() {
- return getComment(DESCRIPTION);
- }
-
- public String[] getDescriptions() {
- return getComments(DESCRIPTION);
- }
-
- public String getGenre() {
- return getComment(GENRE);
- }
-
- public String[] getGenres() {
- return getComments(GENRE);
- }
-
- public String getDate() {
- return getComment(DATE);
- }
-
- public String[] getDates() {
- return getComments(DATE);
- }
-
- public String getLocation() {
- return getComment(LOCATION);
- }
-
- public String[] getLocations() {
- return getComments(LOCATION);
- }
-
- public String getContact() {
- return getComment(CONTACT);
- }
-
- public String[] getContacts() {
- return getComments(CONTACT);
- }
-
- public String getIsrc() {
- return getComment(ISRC);
- }
-
- public String[] getIsrcs() {
- return getComments(ISRC);
- }
-
-
- private String getString(BitInputStream source) throws IOException, VorbisFormatException {
-
- int length=source.getInt(32);
-
- byte[] strArray=new byte[length];
-
- for(int i=0; i<length; i++) {
- strArray[i]=(byte)source.getInt(8);
- }
-
- return new String(strArray, "UTF-8");
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Floor.java b/songdbj/de/jarnbjo/vorbis/Floor.java
deleted file mode 100644
index 5be2798dfb..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Floor.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/10 19:49:04 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-
-public abstract class Floor {
-
- public final static float[] DB_STATIC_TABLE={
- 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f,
- 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f,
- 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.128753e-07f,
- 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f,
- 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f,
- 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f,
- 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f,
- 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f,
- 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f,
- 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f,
- 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f,
- 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f,
- 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f,
- 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f,
- 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f,
- 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f,
- 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f,
- 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f,
- 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f,
- 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f,
- 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f,
- 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f,
- 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f,
- 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f,
- 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f,
- 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f,
- 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f,
- 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f,
- 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f,
- 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f,
- 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f,
- 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f,
- 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f,
- 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f,
- 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f,
- 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f,
- 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f,
- 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f,
- 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f,
- 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f,
- 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f,
- 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f,
- 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f,
- 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f,
- 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f,
- 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f,
- 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f,
- 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f,
- 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f,
- 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f,
- 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f,
- 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f,
- 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f,
- 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f,
- 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f,
- 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f,
- 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f,
- 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f,
- 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f,
- 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f,
- 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f,
- 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f,
- 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f,
- 0.82788260f, 0.88168307f, 0.9389798f, 1.0f};
-
- static Floor createInstance(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
-
- int type=source.getInt(16);
- switch(type) {
- case 0:
- return new Floor0(source, header);
- case 1:
- return new Floor1(source, header);
- default:
- throw new VorbisFormatException("Floor type "+type+" is not supported.");
- }
- }
-
- abstract int getType();
- abstract Floor decodeFloor(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException;
- abstract void computeFloor(float[] vector);
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Floor0.java b/songdbj/de/jarnbjo/vorbis/Floor0.java
deleted file mode 100644
index 4e94b27b73..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Floor0.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-class Floor0 extends Floor {
-
- private int order, rate, barkMapSize, amplitudeBits, amplitudeOffset;
- private int bookList[];
-
- protected Floor0(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
-
- order=source.getInt(8);
- rate=source.getInt(16);
- barkMapSize=source.getInt(16);
- amplitudeBits=source.getInt(6);
- amplitudeOffset=source.getInt(8);
-
- int bookCount=source.getInt(4)+1;
- bookList=new int[bookCount];
-
- for(int i=0; i<bookList.length; i++) {
- bookList[i]=source.getInt(8);
- if(bookList[i]>header.getCodeBooks().length) {
- throw new VorbisFormatException("A floor0_book_list entry is higher than the code book count.");
- }
- }
- }
-
- protected int getType() {
- return 0;
- }
-
- protected Floor decodeFloor(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException {
- /** @todo implement */
- throw new UnsupportedOperationException();
- }
-
- protected void computeFloor(float[] vector) {
- /** @todo implement */
- throw new UnsupportedOperationException();
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Floor1.java b/songdbj/de/jarnbjo/vorbis/Floor1.java
deleted file mode 100644
index 69a118b44e..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Floor1.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$multip
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-import java.util.*;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-
-class Floor1 extends Floor implements Cloneable {
-
- private int[] partitionClassList;
- private int maximumClass, multiplier, rangeBits;
- private int[] classDimensions;
- private int[] classSubclasses;
- private int[] classMasterbooks;
- private int[][] subclassBooks;
- private int[] xList;
- private int[] yList;
- private int[] lowNeighbours, highNeighbours;
- //private boolean[] step2Flags;
-
- private static final int[] RANGES = {256, 128, 86, 64};
-
- private Floor1() {
- }
-
- protected Floor1(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
-
- maximumClass=-1;
- int partitions=source.getInt(5);
- partitionClassList=new int[partitions];
-
- for(int i=0; i<partitionClassList.length; i++) {
- partitionClassList[i]=source.getInt(4);
- if(partitionClassList[i]>maximumClass) {
- maximumClass=partitionClassList[i];
- }
- }
-
-
- classDimensions=new int[maximumClass+1];
- classSubclasses=new int[maximumClass+1];
- classMasterbooks=new int[maximumClass+1];
- subclassBooks=new int[maximumClass+1][];
-
- int xListLength=2;
-
- for(int i=0; i<=maximumClass; i++) {
- classDimensions[i]=source.getInt(3)+1;
- xListLength+=classDimensions[i];
- classSubclasses[i]=source.getInt(2);
-
- if(classDimensions[i] > header.getCodeBooks().length ||
- classSubclasses[i] > header.getCodeBooks().length) {
- throw new VorbisFormatException("There is a class dimension or class subclasses entry higher than the number of codebooks in the setup header.");
- }
- if(classSubclasses[i]!=0) {
- classMasterbooks[i]=source.getInt(8);
- }
- subclassBooks[i]=new int[1<<classSubclasses[i]];
- for(int j=0; j<subclassBooks[i].length; j++) {
- subclassBooks[i][j]=source.getInt(8)-1;
- }
- }
-
- multiplier=source.getInt(2)+1;
- rangeBits=source.getInt(4);
-
- //System.out.println("multiplier: "+multiplier);
- //System.out.println("rangeBits: "+rangeBits);
-
- //System.out.println("xListLength: "+xListLength);
-
- int floorValues=0;
-
- ArrayList alXList=new ArrayList();
-
- alXList.add(new Integer(0));
- alXList.add(new Integer(1<<rangeBits));
-
- //System.out.println("partitions: "+partitions);
- //System.out.println("classDimensions.length: "+classDimensions.length);
-
- for(int i=0; i<partitions; i++) {
- for(int j=0; j<classDimensions[partitionClassList[i]]; j++) {
- alXList.add(new Integer(source.getInt(rangeBits)));
- }
- }
-
- xList=new int[alXList.size()];
- lowNeighbours=new int[xList.length];
- highNeighbours=new int[xList.length];
-
- Iterator iter=alXList.iterator();
- for(int i=0; i<xList.length; i++) {
- xList[i]=((Integer)iter.next()).intValue();
- }
-
- for(int i=0; i<xList.length; i++) {
- lowNeighbours[i]=Util.lowNeighbour(xList, i);
- highNeighbours[i]=Util.highNeighbour(xList, i);
- }
- }
-
- protected int getType() {
- return 1;
- }
-
- protected Floor decodeFloor(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException {
-
- //System.out.println("decodeFloor");
- if(!source.getBit()) {
- //System.out.println("null");
- return null;
- }
-
- Floor1 clone=(Floor1)clone();
-
- clone.yList=new int[xList.length];
-
- int range=RANGES[multiplier-1];
-
- clone.yList[0]=source.getInt(Util.ilog(range-1));
- clone.yList[1]=source.getInt(Util.ilog(range-1));
-
- int offset=2;
-
- for(int i=0; i<partitionClassList.length; i++) {
- int cls=partitionClassList[i];
- int cdim=classDimensions[cls];
- int cbits=classSubclasses[cls];
- int csub=(1<<cbits)-1;
- int cval=0;
- if(cbits>0) {
- cval=source.getInt(vorbis.getSetupHeader().getCodeBooks()[classMasterbooks[cls]].getHuffmanRoot());
- //cval=vorbis.getSetupHeader().getCodeBooks()[classMasterbooks[cls]].readInt(source);
- //System.out.println("cval: "+cval);
- }
- //System.out.println("0: "+cls+" "+cdim+" "+cbits+" "+csub+" "+cval);
- for(int j=0; j<cdim; j++) {
- //System.out.println("a: "+cls+" "+cval+" "+csub);
- int book=subclassBooks[cls][cval&csub];
- cval>>>=cbits;
- if(book>=0) {
- clone.yList[j+offset]=source.getInt(vorbis.getSetupHeader().getCodeBooks()[book].getHuffmanRoot());
- //clone.yList[j+offset]=vorbis.getSetupHeader().getCodeBooks()[book].readInt(source);
- //System.out.println("b: "+(j+offset)+" "+book+" "+clone.yList[j+offset]);
- //System.out.println("");
- }
- else {
- clone.yList[j+offset]=0;
- }
- }
- offset+=cdim;
- }
-
- //System.out.println("");
- //for(int i=0; i<clone.xList.length; i++) {
- // System.out.println(i+" = "+clone.xList[i]);
- //}
-
- //System.out.println("");
- //for(int i=0; i<clone.yList.length; i++) {
- // System.out.println(i+" = "+clone.yList[i]);
- //}
-
- //System.out.println("offset: "+offset);
- //System.out.println("yList.length: "+clone.yList.length);
-
- //System.exit(0);
-
- return clone;
- }
-
- protected void computeFloor(final float[] vector) {
-
- int n=vector.length;
- final int values=xList.length;
- final boolean[] step2Flags=new boolean[values];
-
- final int range=RANGES[multiplier-1];
-
- for(int i=2; i<values; i++) {
- final int lowNeighbourOffset=lowNeighbours[i];//Util.lowNeighbour(xList, i);
- final int highNeighbourOffset=highNeighbours[i];//Util.highNeighbour(xList, i);
- final int predicted=Util.renderPoint(
- xList[lowNeighbourOffset], xList[highNeighbourOffset],
- yList[lowNeighbourOffset], yList[highNeighbourOffset],
- xList[i]);
- final int val=yList[i];
- final int highRoom=range-predicted;
- final int lowRoom=predicted;
- final int room=highRoom<lowRoom?highRoom*2:lowRoom*2;
- if(val!=0) {
- step2Flags[lowNeighbourOffset]=true;
- step2Flags[highNeighbourOffset]=true;
- step2Flags[i]=true;
- if(val>=room) {
- yList[i]=highRoom>lowRoom?
- val-lowRoom+predicted:
- -val+highRoom+predicted-1;
- }
- else {
- yList[i]=(val&1)==1?
- predicted-((val+1)>>1):
- predicted+(val>>1);
- }
- }
- else {
- step2Flags[i]=false;
- yList[i]=predicted;
- }
- }
-
- final int[] xList2=new int[values];
-
- System.arraycopy(xList, 0, xList2, 0, values);
- sort(xList2, yList, step2Flags);
-
- int hx=0, hy=0, lx=0, ly=yList[0]*multiplier;
-
- float[] vector2=new float[vector.length];
- float[] vector3=new float[vector.length];
- Arrays.fill(vector2, 1.0f);
- System.arraycopy(vector, 0, vector3, 0, vector.length);
-
- for(int i=1; i<values; i++) {
- if(step2Flags[i]) {
- hy=yList[i]*multiplier;
- hx=xList2[i];
- Util.renderLine(lx, ly, hx, hy, vector);
- Util.renderLine(lx, ly, hx, hy, vector2);
- lx=hx;
- ly=hy;
- }
- }
-
- final float r=DB_STATIC_TABLE[hy];
- for(; hx<n/2; vector[hx++]=r);
- }
-
- public Object clone() {
- Floor1 clone=new Floor1();
- clone.classDimensions=classDimensions;
- clone.classMasterbooks=classMasterbooks;
- clone.classSubclasses=classSubclasses;
- clone.maximumClass=maximumClass;
- clone.multiplier=multiplier;
- clone.partitionClassList=partitionClassList;
- clone.rangeBits=rangeBits;
- clone.subclassBooks=subclassBooks;
- clone.xList=xList;
- clone.yList=yList;
- clone.lowNeighbours=lowNeighbours;
- clone.highNeighbours=highNeighbours;
- return clone;
- }
-
- private final static void sort(int x[], int y[], boolean b[]) {
- int off=0;
- int len=x.length;
- int lim=len+off;
- int itmp;
- boolean btmp;
- // Insertion sort on smallest arrays
- for (int i=off; i<lim; i++) {
- for (int j=i; j>off && x[j-1]>x[j]; j--) {
- itmp=x[j];
- x[j]=x[j-1];
- x[j-1]=itmp;
- itmp=y[j];
- y[j]=y[j-1];
- y[j-1]=itmp;
- btmp=b[j];
- b[j]=b[j-1];
- b[j-1]=btmp;
- //swap(x, j, j-1);
- //swap(y, j, j-1);
- //swap(b, j, j-1);
- }
- }
- }
-
- private final static void swap(int x[], int a, int b) {
- int t = x[a];
- x[a] = x[b];
- x[b] = t;
- }
-
- private final static void swap(boolean x[], int a, int b) {
- boolean t = x[a];
- x[a] = x[b];
- x[b] = t;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/IdentificationHeader.java b/songdbj/de/jarnbjo/vorbis/IdentificationHeader.java
deleted file mode 100644
index 1e18163385..0000000000
--- a/songdbj/de/jarnbjo/vorbis/IdentificationHeader.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 06:39:06 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/03/31 00:20:16 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-/**
- */
-
-public class IdentificationHeader {
-
- private int version, channels, sampleRate, bitrateMaximum, bitrateNominal, bitrateMinimum, blockSize0, blockSize1;
- private boolean framingFlag;
- private MdctFloat[] mdct=new MdctFloat[2];
- //private MdctLong[] mdctInt=new MdctLong[2];
-
- private static final long HEADER = 0x736962726f76L; // 'vorbis'
-
- public IdentificationHeader(BitInputStream source) throws VorbisFormatException, IOException {
- //equalizer=new Equalizer();
- //equalizer.pack();
- //equalizer.show();
-
- long leading=source.getLong(48);
- if(leading!=HEADER) {
- throw new VorbisFormatException("The identification header has an illegal leading.");
- }
- version=source.getInt(32);
- channels=source.getInt(8);
- sampleRate=source.getInt(32);
- bitrateMaximum=source.getInt(32);
- bitrateNominal=source.getInt(32);
- bitrateMinimum=source.getInt(32);
- int bs=source.getInt(8);
- blockSize0=1<<(bs&0xf);
- blockSize1=1<<(bs>>4);
-
- mdct[0]=new MdctFloat(blockSize0);
- mdct[1]=new MdctFloat(blockSize1);
- //mdctInt[0]=new MdctLong(blockSize0);
- //mdctInt[1]=new MdctLong(blockSize1);
-
- framingFlag=source.getInt(8)!=0;
- }
-
- public int getSampleRate() {
- return sampleRate;
- }
-
- public int getMaximumBitrate() {
- return bitrateMaximum;
- }
-
- public int getNominalBitrate() {
- return bitrateNominal;
- }
-
- public int getMinimumBitrate() {
- return bitrateMinimum;
- }
-
- public int getChannels() {
- return channels;
- }
-
- public int getBlockSize0() {
- return blockSize0;
- }
-
- public int getBlockSize1() {
- return blockSize1;
- }
-
- protected MdctFloat getMdct0() {
- return mdct[0];
- }
-
- protected MdctFloat getMdct1() {
- return mdct[1];
- }
-
- public int getVersion() {
- return version;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Mapping.java b/songdbj/de/jarnbjo/vorbis/Mapping.java
deleted file mode 100644
index 24a2eaa19a..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Mapping.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-abstract class Mapping {
-
- protected static Mapping createInstance(VorbisStream vorbis, BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
-
- int type=source.getInt(16);
- switch(type) {
- case 0:
- //System.out.println("mapping type 0");
- return new Mapping0(vorbis, source, header);
- default:
- throw new VorbisFormatException("Mapping type "+type+" is not supported.");
- }
- }
-
- protected abstract int getType();
- protected abstract int[] getAngles();
- protected abstract int[] getMagnitudes() ;
- protected abstract int[] getMux();
- protected abstract int[] getSubmapFloors();
- protected abstract int[] getSubmapResidues();
- protected abstract int getCouplingSteps();
- protected abstract int getSubmaps();
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Mapping0.java b/songdbj/de/jarnbjo/vorbis/Mapping0.java
deleted file mode 100644
index e8fde4686f..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Mapping0.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-class Mapping0 extends Mapping {
-
- private int[] magnitudes, angles, mux, submapFloors, submapResidues;
-
- protected Mapping0(VorbisStream vorbis, BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
-
- int submaps=1;
-
- if(source.getBit()) {
- submaps=source.getInt(4)+1;
- }
-
- //System.out.println("submaps: "+submaps);
-
- int channels=vorbis.getIdentificationHeader().getChannels();
- int ilogChannels=Util.ilog(channels-1);
-
- //System.out.println("ilogChannels: "+ilogChannels);
-
- if(source.getBit()) {
- int couplingSteps=source.getInt(8)+1;
- magnitudes=new int[couplingSteps];
- angles=new int[couplingSteps];
-
- for(int i=0; i<couplingSteps; i++) {
- magnitudes[i]=source.getInt(ilogChannels);
- angles[i]=source.getInt(ilogChannels);
- if(magnitudes[i]==angles[i] || magnitudes[i]>=channels || angles[i]>=channels) {
- System.err.println(magnitudes[i]);
- System.err.println(angles[i]);
- throw new VorbisFormatException("The channel magnitude and/or angle mismatch.");
- }
- }
- }
- else {
- magnitudes=new int[0];
- angles=new int[0];
- }
-
- if(source.getInt(2)!=0) {
- throw new VorbisFormatException("A reserved mapping field has an invalid value.");
- }
-
- mux=new int[channels];
- if(submaps>1) {
- for(int i=0; i<channels; i++) {
- mux[i]=source.getInt(4);
- if(mux[i]>submaps) {
- throw new VorbisFormatException("A mapping mux value is higher than the number of submaps");
- }
- }
- }
- else {
- for(int i=0; i<channels; i++) {
- mux[i]=0;
- }
- }
-
- submapFloors=new int[submaps];
- submapResidues=new int[submaps];
-
- int floorCount=header.getFloors().length;
- int residueCount=header.getResidues().length;
-
- for(int i=0; i<submaps; i++) {
- source.getInt(8); // discard time placeholder
- submapFloors[i]=source.getInt(8);
- submapResidues[i]=source.getInt(8);
-
- if(submapFloors[i]>floorCount) {
- throw new VorbisFormatException("A mapping floor value is higher than the number of floors.");
- }
-
- if(submapResidues[i]>residueCount) {
- throw new VorbisFormatException("A mapping residue value is higher than the number of residues.");
- }
- }
- }
-
- protected int getType() {
- return 0;
- }
-
- protected int[] getAngles() {
- return angles;
- }
-
- protected int[] getMagnitudes() {
- return magnitudes;
- }
-
- protected int[] getMux() {
- return mux;
- }
-
- protected int[] getSubmapFloors() {
- return submapFloors;
- }
-
- protected int[] getSubmapResidues() {
- return submapResidues;
- }
-
- protected int getCouplingSteps() {
- return angles.length;
- }
-
- protected int getSubmaps() {
- return submapFloors.length;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/MdctFloat.java b/songdbj/de/jarnbjo/vorbis/MdctFloat.java
deleted file mode 100644
index 4f354b259b..0000000000
--- a/songdbj/de/jarnbjo/vorbis/MdctFloat.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 12:09:45 shred
- * *** empty log message ***
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/10 19:49:04 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-class MdctFloat {
- static private final float cPI3_8=0.38268343236508977175f;
- static private final float cPI2_8=0.70710678118654752441f;
- static private final float cPI1_8=0.92387953251128675613f;
-
- private int n;
- private int log2n;
-
- private float[] trig;
- private int[] bitrev;
-
- private float[] equalizer;
-
- private float scale;
-
- private int itmp1, itmp2, itmp3, itmp4, itmp5, itmp6, itmp7, itmp8, itmp9;
- private float dtmp1, dtmp2, dtmp3, dtmp4, dtmp5, dtmp6, dtmp7, dtmp8, dtmp9;
-
- protected MdctFloat(int n) {
- bitrev=new int[n/4];
- trig=new float[n+n/4];
-
- int n2=n>>>1;
- log2n=(int)Math.rint(Math.log(n)/Math.log(2));
- this.n=n;
-
- int AE=0;
- int AO=1;
- int BE=AE+n/2;
- int BO=BE+1;
- int CE=BE+n/2;
- int CO=CE+1;
- // trig lookups...
- for(int i=0;i<n/4;i++){
- trig[AE+i*2]=(float)Math.cos((Math.PI/n)*(4*i));
- trig[AO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i));
- trig[BE+i*2]=(float)Math.cos((Math.PI/(2*n))*(2*i+1));
- trig[BO+i*2]=(float)Math.sin((Math.PI/(2*n))*(2*i+1));
- }
- for(int i=0;i<n/8;i++){
- trig[CE+i*2]=(float)Math.cos((Math.PI/n)*(4*i+2));
- trig[CO+i*2]=(float)-Math.sin((Math.PI/n)*(4*i+2));
- }
-
- {
- int mask=(1<<(log2n-1))-1;
- int msb=1<<(log2n-2);
- for(int i=0;i<n/8;i++){
- int acc=0;
- for(int j=0;msb>>>j!=0;j++)
- if(((msb>>>j)&i)!=0)acc|=1<<j;
- bitrev[i*2]=((~acc)&mask);
-// bitrev[i*2]=((~acc)&mask)-1;
- bitrev[i*2+1]=acc;
- }
- }
- scale=4.f/n;
- }
-
- //void clear(){
- //}
-
- //void forward(float[] in, float[] out){
- //}
-
- private float[] _x=new float[1024];
- private float[] _w=new float[1024];
-
- protected void setEqualizer(float[] equalizer) {
- this.equalizer=equalizer;
- }
-
- protected float[] getEqualizer() {
- return equalizer;
- }
-
- protected synchronized void imdct(final float[] frq, final float[] window, final int[] pcm) {//, float[] out){
-
- float[] in=frq;//, out=buf;
- if(_x.length<n/2){_x=new float[n/2];}
- if(_w.length<n/2){_w=new float[n/2];}
- final float[] x=_x;
- final float[] w=_w;
- int n2=n>>1;
- int n4=n>>2;
- int n8=n>>3;
-
- if(equalizer!=null) {
- for(int i=0; i<n; i++) {
- frq[i]*=equalizer[i];
- }
- }
-
- // rotate + step 1
- {
- int inO=-1;
- int xO=0;
- int A=n2;
-
- int i;
- for(i=0;i<n8;i++) {
- dtmp1=in[inO+=2];
- dtmp2=in[inO+=2];
- dtmp3=trig[--A];
- dtmp4=trig[--A];
- x[xO++]=-dtmp2*dtmp3 - dtmp1*dtmp4;
- x[xO++]= dtmp1*dtmp3 - dtmp2*dtmp4;
- //A-=2;
- //x[xO++]=-in[inO+2]*trig[A+1] - in[inO]*trig[A];
- //x[xO++]= in[inO]*trig[A+1] - in[inO+2]*trig[A];
- //inO+=4;
- }
-
- inO=n2;//-4;
-
- for(i=0;i<n8;i++) {
- dtmp1=in[inO-=2];
- dtmp2=in[inO-=2];
- dtmp3=trig[--A];
- dtmp4=trig[--A];
- x[xO++]=dtmp2*dtmp3 + dtmp1*dtmp4;
- x[xO++]=dtmp2*dtmp4 - dtmp1*dtmp3;
- //A-=2;
- //x[xO++]=in[inO]*trig[A+1] + in[inO+2]*trig[A];
- //x[xO++]=in[inO]*trig[A] - in[inO+2]*trig[A+1];
- //inO-=4;
- }
- }
-
- float[] xxx=kernel(x,w,n,n2,n4,n8);
- int xx=0;
-
- // step 8
-
- {
- int B=n2;
- int o1=n4,o2=o1-1;
- int o3=n4+n2,o4=o3-1;
-
- for(int i=0;i<n4;i++){
- dtmp1=xxx[xx++];
- dtmp2=xxx[xx++];
- dtmp3=trig[B++];
- dtmp4=trig[B++];
-
- float temp1= (dtmp1* dtmp4 - dtmp2 * dtmp3);
- float temp2=-(dtmp1 * dtmp3 + dtmp2 * dtmp4);
-
- /*
- float temp1= (xxx[xx] * trig[B+1] - xxx[xx+1] * trig[B]);//*32767.0f;
- float temp2=-(xxx[xx] * trig[B] + xxx[xx+1] * trig[B+1]);//*32767.0f;
- */
-
- //if(temp1>32767.0f) temp1=32767.0f;
- //if(temp1<-32768.0f) temp1=-32768.0f;
- //if(temp2>32767.0f) temp2=32767.0f;
- //if(temp2<-32768.0f) temp2=-32768.0f;
-
- pcm[o1]=(int)(-temp1*window[o1]);
- pcm[o2]=(int)( temp1*window[o2]);
- pcm[o3]=(int)( temp2*window[o3]);
- pcm[o4]=(int)( temp2*window[o4]);
-
- o1++;
- o2--;
- o3++;
- o4--;
- //xx+=2;
- //B+=2;
- }
- }
- }
-
- private float[] kernel(float[] x, float[] w,
- int n, int n2, int n4, int n8){
- // step 2
-
- int xA=n4;
- int xB=0;
- int w2=n4;
- int A=n2;
-
- for(int i=0;i<n4;){
- float x0=x[xA] - x[xB];
- float x1;
- w[w2+i]=x[xA++]+x[xB++];
-
- x1=x[xA]-x[xB];
- A-=4;
-
- w[i++]= x0 * trig[A] + x1 * trig[A+1];
- w[i]= x1 * trig[A] - x0 * trig[A+1];
-
- w[w2+i]=x[xA++]+x[xB++];
- i++;
- }
-
- // step 3
-
- {
- for(int i=0;i<log2n-3;i++){
- int k0=n>>>(i+2);
- int k1=1<<(i+3);
- int wbase=n2-2;
-
- A=0;
- float[] temp;
-
- for(int r=0;r<(k0>>>2);r++){
- int w1=wbase;
- w2=w1-(k0>>1);
- float AEv= trig[A],wA;
- float AOv= trig[A+1],wB;
- wbase-=2;
-
- k0++;
- for(int s=0;s<(2<<i);s++){
- dtmp1=w[w1];
- dtmp2=w[w2];
- wB=dtmp1-dtmp2;
- x[w1]=dtmp1+dtmp2;
- dtmp1=w[++w1];
- dtmp2=w[++w2];
- wA=dtmp1-dtmp2;
- x[w1]=dtmp1+dtmp2;
- x[w2] =wA*AEv - wB*AOv;
- x[w2-1]=wB*AEv + wA*AOv;
-
- /*
- wB =w[w1] -w[w2];
- x[w1] =w[w1] +w[w2];
-
- wA =w[++w1] -w[++w2];
- x[w1] =w[w1] +w[w2];
-
- x[w2] =wA*AEv - wB*AOv;
- x[w2-1]=wB*AEv + wA*AOv;
- */
-
- w1-=k0;
- w2-=k0;
- }
- k0--;
- A+=k1;
- }
-
- temp=w;
- w=x;
- x=temp;
- }
- }
-
- // step 4, 5, 6, 7
- {
- int C=n;
- int bit=0;
- int x1=0;
- int x2=n2-1;
-
- for(int i=0;i<n8;i++) {
- int t1=bitrev[bit++];
- int t2=bitrev[bit++];
-
- float wA=w[t1]-w[t2+1];
- float wB=w[t1-1]+w[t2];
- float wC=w[t1]+w[t2+1];
- float wD=w[t1-1]-w[t2];
-
- float wACE=wA* trig[C];
- float wBCE=wB* trig[C++];
- float wACO=wA* trig[C];
- float wBCO=wB* trig[C++];
-
- x[x1++]=( wC+wACO+wBCE)*16383.0f;
- x[x2--]=(-wD+wBCO-wACE)*16383.0f;
- x[x1++]=( wD+wBCO-wACE)*16383.0f;
- x[x2--]=( wC-wACO-wBCE)*16383.0f;
- }
- }
- return x;
- }
-
-}
-
diff --git a/songdbj/de/jarnbjo/vorbis/Mode.java b/songdbj/de/jarnbjo/vorbis/Mode.java
deleted file mode 100644
index ab88944a25..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Mode.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.*;
-
-import de.jarnbjo.util.io.*;
-
-class Mode {
-
- private boolean blockFlag;
- private int windowType, transformType, mapping;
-
- protected Mode(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
- blockFlag=source.getBit();
- windowType=source.getInt(16);
- transformType=source.getInt(16);
- mapping=source.getInt(8);
-
- if(windowType!=0) {
- throw new VorbisFormatException("Window type = "+windowType+", != 0");
- }
-
- if(transformType!=0) {
- throw new VorbisFormatException("Transform type = "+transformType+", != 0");
- }
-
- if(mapping>header.getMappings().length) {
- throw new VorbisFormatException("Mode mapping number is higher than total number of mappings.");
- }
- }
-
- protected boolean getBlockFlag() {
- return blockFlag;
- }
-
- protected int getWindowType() {
- return windowType;
- }
-
- protected int getTransformType() {
- return transformType;
- }
-
- protected int getMapping() {
- return mapping;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Residue.java b/songdbj/de/jarnbjo/vorbis/Residue.java
deleted file mode 100644
index 78c28fa5ed..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Residue.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/04 08:33:02 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-import de.jarnbjo.util.io.*;
-
-
-abstract class Residue {
-
- protected int begin, end;
- protected int partitionSize; // grouping
- protected int classifications; // partitions
- protected int classBook; // groupbook
- protected int[] cascade; // secondstages
- protected int[][] books;
- protected HashMap looks=new HashMap();
-
- protected Residue() {
- }
-
- protected Residue(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
- begin=source.getInt(24);
- end=source.getInt(24);
- partitionSize=source.getInt(24)+1;
- classifications=source.getInt(6)+1;
- classBook=source.getInt(8);
-
- cascade=new int[classifications];
-
- int acc=0;
-
- for(int i=0; i<classifications; i++) {
- int highBits=0, lowBits=0;
- lowBits=source.getInt(3);
- if(source.getBit()) {
- highBits=source.getInt(5);
- }
- cascade[i]=(highBits<<3)|lowBits;
- acc+=Util.icount(cascade[i]);
- }
-
- books=new int[classifications][8];
-
- for(int i=0; i<classifications; i++) {
- for(int j=0; j<8; j++) {
- if((cascade[i]&(1<<j))!=0) {
- books[i][j]=source.getInt(8);
- if(books[i][j]>header.getCodeBooks().length) {
- throw new VorbisFormatException("Reference to invalid codebook entry in residue header.");
- }
- }
- }
- }
- }
-
-
- protected static Residue createInstance(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
-
- int type=source.getInt(16);
- switch(type) {
- case 0:
- //System.out.println("residue type 0");
- return new Residue0(source, header);
- case 1:
- //System.out.println("residue type 1");
- return new Residue2(source, header);
- case 2:
- //System.out.println("residue type 2");
- return new Residue2(source, header);
- default:
- throw new VorbisFormatException("Residue type "+type+" is not supported.");
- }
- }
-
- protected abstract int getType();
- protected abstract void decodeResidue(VorbisStream vorbis, BitInputStream source, Mode mode, int ch, boolean[] doNotDecodeFlags, float[][] vectors) throws VorbisFormatException, IOException;
- //public abstract double[][] getDecodedVectors();
-
- protected int getBegin() {
- return begin;
- }
-
- protected int getEnd() {
- return end;
- }
-
- protected int getPartitionSize() {
- return partitionSize;
- }
-
- protected int getClassifications() {
- return classifications;
- }
-
- protected int getClassBook() {
- return classBook;
- }
-
- protected int[] getCascade() {
- return cascade;
- }
-
- protected int[][] getBooks() {
- return books;
- }
-
- protected final void fill(Residue clone) {
- clone.begin=begin;
- clone.books=books;
- clone.cascade=cascade;
- clone.classBook=classBook;
- clone.classifications=classifications;
- clone.end=end;
- clone.partitionSize=partitionSize;
- }
-
- protected Look getLook(VorbisStream source, Mode key) {
- //return new Look(source, key);
- Look look=(Look)looks.get(key);
- if(look==null) {
- look=new Look(source, key);
- looks.put(key, look);
- }
- return look;
- }
-
-
- class Look {
- int map;
- int parts;
- int stages;
- CodeBook[] fullbooks;
- CodeBook phrasebook;
- int[][] partbooks;
- int partvals;
- int[][] decodemap;
- int postbits;
- int phrasebits;
- int frames;
-
- protected Look (VorbisStream source, Mode mode) {
- int dim=0, acc=0, maxstage=0;
-
- map=mode.getMapping();
- parts=Residue.this.getClassifications();
- fullbooks=source.getSetupHeader().getCodeBooks();
- phrasebook=fullbooks[Residue.this.getClassBook()];
- dim=phrasebook.getDimensions();
-
- partbooks=new int[parts][];
-
- for(int j=0;j<parts;j++) {
- int stages=Util.ilog(Residue.this.getCascade()[j]);
- if(stages!=0) {
- if(stages>maxstage) {
- maxstage=stages;
- }
- partbooks[j]=new int[stages];
- for(int k=0; k<stages; k++){
- if((Residue.this.getCascade()[j]&(1<<k))!=0){
- partbooks[j][k]=Residue.this.getBooks()[j][k];
- }
- }
- }
- }
-
- partvals=(int)Math.rint(Math.pow(parts, dim));
- stages=maxstage;
-
- decodemap=new int[partvals][];
-
- for(int j=0;j<partvals;j++){
- int val=j;
- int mult=partvals/parts;
- decodemap[j]=new int[dim];
-
- for(int k=0;k<dim;k++){
- int deco=val/mult;
- val-=deco*mult;
- mult/=parts;
- decodemap[j][k]=deco;
- }
- }
- }
-
- protected int[][] getDecodeMap() {
- return decodemap;
- }
-
- protected int getFrames() {
- return frames;
- }
-
- protected int getMap() {
- return map;
- }
-
- protected int[][] getPartBooks() {
- return partbooks;
- }
-
- protected int getParts() {
- return parts;
- }
-
- protected int getPartVals() {
- return partvals;
- }
-
- protected int getPhraseBits() {
- return phrasebits;
- }
-
- protected CodeBook getPhraseBook() {
- return phrasebook;
- }
-
- protected int getPostBits() {
- return postbits;
- }
-
- protected int getStages() {
- return stages;
- }
- }
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Residue0.java b/songdbj/de/jarnbjo/vorbis/Residue0.java
deleted file mode 100644
index 7dc0dfa765..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Residue0.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 06:39:06 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-class Residue0 extends Residue {
-
- protected Residue0(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
- super(source, header);
- }
-
- protected int getType() {
- return 0;
- }
-
- protected void decodeResidue(VorbisStream vorbis, BitInputStream source, Mode mode, int ch, boolean[] doNotDecodeFlags, float[][] vectors) throws VorbisFormatException, IOException {
- /** @todo implement */
- throw new UnsupportedOperationException();
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Residue1.java b/songdbj/de/jarnbjo/vorbis/Residue1.java
deleted file mode 100644
index f31147c072..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Residue1.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 06:39:06 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-class Residue1 extends Residue {
-
- protected Residue1(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
- super(source, header);
- }
-
- protected int getType() {
- return 1;
- }
-
- protected void decodeResidue(VorbisStream vorbis, BitInputStream source, Mode mode, int ch, boolean[] doNotDecodeFlags, float[][] vectors) throws VorbisFormatException, IOException {
- /** @todo implement */
- throw new UnsupportedOperationException();
- }
-
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Residue2.java b/songdbj/de/jarnbjo/vorbis/Residue2.java
deleted file mode 100644
index 666d2cd017..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Residue2.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 06:39:06 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-import de.jarnbjo.util.io.BitInputStream;
-
-class Residue2 extends Residue {
-
- private double[][] decodedVectors;
-
- private Residue2() {
- }
-
- protected Residue2(BitInputStream source, SetupHeader header) throws VorbisFormatException, IOException {
- super(source, header);
- }
-
- protected int getType() {
- return 2;
- }
-
- protected void decodeResidue(VorbisStream vorbis, BitInputStream source, Mode mode, int ch, boolean[] doNotDecodeFlags, float[][] vectors) throws VorbisFormatException, IOException {
-
- Look look=getLook(vorbis, mode);
-
- CodeBook codeBook=vorbis.getSetupHeader().getCodeBooks()[getClassBook()];
-
- int classvalsPerCodeword=codeBook.getDimensions();
- int nToRead=getEnd()-getBegin();
- int partitionsToRead=nToRead/getPartitionSize(); // partvals
-
- int samplesPerPartition=getPartitionSize();
- int partitionsPerWord=look.getPhraseBook().getDimensions();
-
- int partWords=(partitionsToRead+partitionsPerWord-1)/partitionsPerWord;
-
- int realCh=0;
- for(int i=0; i<doNotDecodeFlags.length; i++) {
- if(!doNotDecodeFlags[i]) {
- realCh++;
- }
- }
-
- float[][] realVectors=new float[realCh][];
-
- realCh=0;
- for(int i=0; i<doNotDecodeFlags.length; i++) {
- if(!doNotDecodeFlags[i]) {
- realVectors[realCh++]=vectors[i];
- }
- }
-
- int[][] partword=new int[partWords][];
- for(int s=0;s<look.getStages();s++){
- for(int i=0,l=0;i<partitionsToRead;l++){
- if(s==0){
- //int temp=look.getPhraseBook().readInt(source);
- int temp=source.getInt(look.getPhraseBook().getHuffmanRoot());
- if(temp==-1){
- throw new VorbisFormatException("");
- }
- partword[l]=look.getDecodeMap()[temp];
- if(partword[l]==null){
- throw new VorbisFormatException("");
- }
- }
-
- for(int k=0;k<partitionsPerWord && i<partitionsToRead;k++,i++){
- int offset=begin+i*samplesPerPartition;
- if((cascade[partword[l][k]]&(1<<s))!=0){
- CodeBook stagebook=vorbis.getSetupHeader().getCodeBooks()[look.getPartBooks()[partword[l][k]][s]];
- if(stagebook!=null){
- stagebook.readVvAdd(realVectors, source, offset, samplesPerPartition);
- }
- }
- }
- }
- }
- }
-
-
- public Object clone() {
- Residue2 clone=new Residue2();
- fill(clone);
- return clone;
- }
-
- protected double[][] getDecodedVectors() {
- return decodedVectors;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/SetupHeader.java b/songdbj/de/jarnbjo/vorbis/SetupHeader.java
deleted file mode 100644
index 56e400f348..0000000000
--- a/songdbj/de/jarnbjo/vorbis/SetupHeader.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.*;
-
-import de.jarnbjo.util.io.*;
-
-class SetupHeader {
-
- private static final long HEADER = 0x736962726f76L; // 'vorbis'
-
- private CodeBook[] codeBooks;
- private Floor[] floors;
- private Residue[] residues;
- private Mapping[] mappings;
- private Mode[] modes;
-
- public SetupHeader(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException {
-
- if(source.getLong(48)!=HEADER) {
- throw new VorbisFormatException("The setup header has an illegal leading.");
- }
-
- // read code books
-
- int codeBookCount=source.getInt(8)+1;
- codeBooks=new CodeBook[codeBookCount];
-
- for(int i=0; i<codeBooks.length; i++) {
- codeBooks[i]=new CodeBook(source);
- }
-
- // read the time domain transformations,
- // these should all be 0
-
- int timeCount=source.getInt(6)+1;
- for(int i=0; i<timeCount; i++) {
- if(source.getInt(16)!=0) {
- throw new VorbisFormatException("Time domain transformation != 0");
- }
- }
-
- // read floor entries
-
- int floorCount=source.getInt(6)+1;
- floors=new Floor[floorCount];
-
- for(int i=0; i<floorCount; i++) {
- floors[i]=Floor.createInstance(source, this);
- }
-
- // read residue entries
-
- int residueCount=source.getInt(6)+1;
- residues=new Residue[residueCount];
-
- for(int i=0; i<residueCount; i++) {
- residues[i]=Residue.createInstance(source, this);
- }
-
- // read mapping entries
-
- int mappingCount=source.getInt(6)+1;
- mappings=new Mapping[mappingCount];
-
- for(int i=0; i<mappingCount; i++) {
- mappings[i]=Mapping.createInstance(vorbis, source, this);
- }
-
- // read mode entries
-
- int modeCount=source.getInt(6)+1;
- modes=new Mode[modeCount];
-
- for(int i=0; i<modeCount; i++) {
- modes[i]=new Mode(source, this);
- }
-
- if(!source.getBit()) {
- throw new VorbisFormatException("The setup header framing bit is incorrect.");
- }
- }
-
- public CodeBook[] getCodeBooks() {
- return codeBooks;
- }
-
- public Floor[] getFloors() {
- return floors;
- }
-
- public Residue[] getResidues() {
- return residues;
- }
-
- public Mapping[] getMappings() {
- return mappings;
- }
-
- public Mode[] getModes() {
- return modes;
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/Util.java b/songdbj/de/jarnbjo/vorbis/Util.java
deleted file mode 100644
index 7e31c9495e..0000000000
--- a/songdbj/de/jarnbjo/vorbis/Util.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.3 2003/04/10 19:49:04 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-final public class Util {
-
- public static final int ilog(int x) {
- int res=0;
- for(; x>0; x>>=1, res++);
- return res;
- }
-
- public static final float float32unpack(int x) {
- float mantissa=x&0x1fffff;
- float e=(x&0x7fe00000)>>21;
- if((x&0x80000000)!=0) {
- mantissa=-mantissa;
- }
- return mantissa*(float)Math.pow(2.0, e-788.0);
- }
-
- public static final int lookup1Values(int a, int b) {
- int res=(int)Math.pow(Math.E, Math.log(a)/b);
- return intPow(res+1, b)<=a?res+1:res;
- }
-
- public static final int intPow(int base, int e) {
- int res=1;
- for(; e>0; e--, res*=base);
- return res;
- }
-
- public static final boolean isBitSet(int value, int bit) {
- return (value&(1<<bit))!=0;
- }
-
- public static final int icount(int value) {
- int res=0;
- while(value>0) {
- res+=value&1;
- value>>=1;
- }
- return res;
- }
-
- public static final int lowNeighbour(int[] v, int x) {
- int max=-1, n=0;
- for(int i=0; i<v.length && i<x; i++) {
- if(v[i]>max && v[i]<v[x]) {
- max=v[i];
- n=i;
- }
- }
- return n;
- }
-
- public static final int highNeighbour(int[] v, int x) {
- int min=Integer.MAX_VALUE, n=0;
- for(int i=0; i<v.length && i<x; i++) {
- if(v[i]<min && v[i]>v[x]) {
- min=v[i];
- n=i;
- }
- }
- return n;
- }
-
- public static final int renderPoint(int x0, int x1, int y0, int y1, int x) {
- int dy=y1-y0;
- int ady=dy<0?-dy:dy;
- int off=(ady*(x-x0))/(x1-x0);
- return dy<0?y0-off:y0+off;
- }
-
- public static final void renderLine(final int x0, final int y0, final int x1, final int y1, final float[] v) {
- final int dy=y1-y0;
- final int adx=x1-x0;
- final int base=dy/adx;
- final int sy=dy<0?base-1:base+1;
- int x=x0;
- int y=y0;
- int err=0;
- final int ady=(dy<0?-dy:dy)-(base>0?base*adx:-base*adx);
-
- v[x]*=Floor.DB_STATIC_TABLE[y];
- for(x=x0+1; x<x1; x++) {
- err+=ady;
- if(err>=adx) {
- err-=adx;
- v[x]*=Floor.DB_STATIC_TABLE[y+=sy];
- }
- else {
- v[x]*=Floor.DB_STATIC_TABLE[y+=base];
- }
- }
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/VorbisAudioFileReader.java b/songdbj/de/jarnbjo/vorbis/VorbisAudioFileReader.java
deleted file mode 100644
index b1bc999947..0000000000
--- a/songdbj/de/jarnbjo/vorbis/VorbisAudioFileReader.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package de.jarnbjo.vorbis;
-
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2004/09/21 06:39:06 shred
- * Importe reorganisiert, damit Eclipse Ruhe gibt. ;-)
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- *
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-import java.net.URL;
-import java.util.Collection;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-import javax.sound.sampled.spi.AudioFileReader;
-
-import de.jarnbjo.ogg.BasicStream;
-import de.jarnbjo.ogg.EndOfOggStreamException;
-import de.jarnbjo.ogg.FileStream;
-import de.jarnbjo.ogg.LogicalOggStream;
-import de.jarnbjo.ogg.OggFormatException;
-import de.jarnbjo.ogg.PhysicalOggStream;
-import de.jarnbjo.ogg.UncachedUrlStream;
-
-public class VorbisAudioFileReader extends AudioFileReader {
-
- public VorbisAudioFileReader() {
- }
-
- public AudioFileFormat getAudioFileFormat(File file) throws IOException, UnsupportedAudioFileException {
- try {
- return getAudioFileFormat(new FileStream(new RandomAccessFile(file, "r")));
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
- public AudioFileFormat getAudioFileFormat(InputStream stream) throws IOException, UnsupportedAudioFileException {
- try {
- return getAudioFileFormat(new BasicStream(stream));
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
- public AudioFileFormat getAudioFileFormat(URL url) throws IOException, UnsupportedAudioFileException {
- try {
- return getAudioFileFormat(new UncachedUrlStream(url));
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
- private AudioFileFormat getAudioFileFormat(PhysicalOggStream oggStream) throws IOException, UnsupportedAudioFileException {
- try {
- Collection streams=oggStream.getLogicalStreams();
- if(streams.size()!=1) {
- throw new UnsupportedAudioFileException("Only Ogg files with one logical Vorbis stream are supported.");
- }
-
- LogicalOggStream los=(LogicalOggStream)streams.iterator().next();
- if(los.getFormat()!=LogicalOggStream.FORMAT_VORBIS) {
- throw new UnsupportedAudioFileException("Only Ogg files with one logical Vorbis stream are supported.");
- }
-
- VorbisStream vs=new VorbisStream(los);
-
- AudioFormat audioFormat=new AudioFormat(
- (float)vs.getIdentificationHeader().getSampleRate(),
- 16,
- vs.getIdentificationHeader().getChannels(),
- true, true);
-
- return new AudioFileFormat(VorbisFormatType.getInstance(), audioFormat, AudioSystem.NOT_SPECIFIED);
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- catch(VorbisFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
-
-
- public AudioInputStream getAudioInputStream(File file) throws IOException, UnsupportedAudioFileException {
- try {
- return getAudioInputStream(new FileStream(new RandomAccessFile(file, "r")));
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
- public AudioInputStream getAudioInputStream(InputStream stream) throws IOException, UnsupportedAudioFileException {
- try {
- return getAudioInputStream(new BasicStream(stream));
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
- public AudioInputStream getAudioInputStream(URL url) throws IOException, UnsupportedAudioFileException {
- try {
- return getAudioInputStream(new UncachedUrlStream(url));
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
- private AudioInputStream getAudioInputStream(PhysicalOggStream oggStream) throws IOException, UnsupportedAudioFileException {
- try {
- Collection streams=oggStream.getLogicalStreams();
- if(streams.size()!=1) {
- throw new UnsupportedAudioFileException("Only Ogg files with one logical Vorbis stream are supported.");
- }
-
- LogicalOggStream los=(LogicalOggStream)streams.iterator().next();
- if(los.getFormat()!=LogicalOggStream.FORMAT_VORBIS) {
- throw new UnsupportedAudioFileException("Only Ogg files with one logical Vorbis stream are supported.");
- }
-
- VorbisStream vs=new VorbisStream(los);
-
- AudioFormat audioFormat=new AudioFormat(
- (float)vs.getIdentificationHeader().getSampleRate(),
- 16,
- vs.getIdentificationHeader().getChannels(),
- true, true);
-
- return new AudioInputStream(new VorbisInputStream(vs), audioFormat, -1);
- }
- catch(OggFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- catch(VorbisFormatException e) {
- throw new UnsupportedAudioFileException(e.getMessage());
- }
- }
-
-
- public static class VorbisFormatType extends AudioFileFormat.Type {
-
- private static final VorbisFormatType instance=new VorbisFormatType();
-
- private VorbisFormatType() {
- super("VORBIS", "ogg");
- }
-
- public static AudioFileFormat.Type getInstance() {
- return instance;
- }
- }
-
- public static class VorbisInputStream extends InputStream {
-
- private VorbisStream source;
- private byte[] buffer=new byte[8192];
-
- public VorbisInputStream(VorbisStream source) {
- this.source=source;
- }
-
- public int read() throws IOException {
- return 0;
- }
-
- public int read(byte[] buffer) throws IOException {
- return read(buffer, 0, buffer.length);
- }
-
- public int read(byte[] buffer, int offset, int length) throws IOException {
- try {
- return source.readPcm(buffer, offset, length);
- }
- catch(EndOfOggStreamException e) {
- return -1;
- }
- }
- }
-
-
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/VorbisFormatException.java b/songdbj/de/jarnbjo/vorbis/VorbisFormatException.java
deleted file mode 100644
index 5214298378..0000000000
--- a/songdbj/de/jarnbjo/vorbis/VorbisFormatException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.2 2005/02/09 23:10:47 shred
- * Serial UID für jarnbjo
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.IOException;
-
-/**
- * Exception thrown when trying to read a corrupted Vorbis stream.
- */
-
-public class VorbisFormatException extends IOException {
- private static final long serialVersionUID = 3616453405694834743L;
-
- public VorbisFormatException() {
- super();
- }
-
- public VorbisFormatException(String message) {
- super(message);
- }
-} \ No newline at end of file
diff --git a/songdbj/de/jarnbjo/vorbis/VorbisStream.java b/songdbj/de/jarnbjo/vorbis/VorbisStream.java
deleted file mode 100644
index 36659c7106..0000000000
--- a/songdbj/de/jarnbjo/vorbis/VorbisStream.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * $ProjectName$
- * $ProjectRevision$
- * -----------------------------------------------------------
- * $Id$
- * -----------------------------------------------------------
- *
- * $Author$
- *
- * Description:
- *
- * Copyright 2002-2003 Tor-Einar Jarnbjo
- * -----------------------------------------------------------
- *
- * Change History
- * -----------------------------------------------------------
- * $Log$
- * Revision 1.1 2005/07/11 15:42:36 hcl
- * Songdb java version, source. only 1.5 compatible
- *
- * Revision 1.1.1.1 2004/04/04 22:09:12 shred
- * First Import
- *
- * Revision 1.4 2003/04/10 19:49:04 jarnbjo
- * no message
- *
- * Revision 1.3 2003/03/31 00:20:16 jarnbjo
- * no message
- *
- * Revision 1.2 2003/03/16 01:11:12 jarnbjo
- * no message
- *
- *
- */
-
-package de.jarnbjo.vorbis;
-
-import java.io.*;
-import java.util.*;
-
-import de.jarnbjo.ogg.*;
-import de.jarnbjo.util.io.*;
-
-/**
- */
-
-public class VorbisStream {
-
- private LogicalOggStream oggStream;
- private IdentificationHeader identificationHeader;
- private CommentHeader commentHeader;
- private SetupHeader setupHeader;
-
- private AudioPacket lastAudioPacket, nextAudioPacket;
- private LinkedList audioPackets=new LinkedList();
- private byte[] currentPcm;
- private int currentPcmIndex;
- private int currentPcmLimit;
-
- private static final int IDENTIFICATION_HEADER = 1;
- private static final int COMMENT_HEADER = 3;
- private static final int SETUP_HEADER = 5;
-
- private int bitIndex=0;
- private byte lastByte=(byte)0;
- private boolean initialized=false;
-
- private Object streamLock=new Object();
- private int pageCounter=0;
-
- private int currentBitRate=0;
-
- private long currentGranulePosition;
-
- public static final int BIG_ENDIAN = 0;
- public static final int LITTLE_ENDIAN = 1;
-
- public VorbisStream() {
- }
-
- public VorbisStream(LogicalOggStream oggStream) throws VorbisFormatException, IOException {
- this.oggStream=oggStream;
-
- for(int i=0; i<3; i++) {
- BitInputStream source=new ByteArrayBitInputStream(oggStream.getNextOggPacket());
- int headerType=source.getInt(8);
- switch(headerType) {
- case IDENTIFICATION_HEADER:
- identificationHeader=new IdentificationHeader(source);
- break;
- case COMMENT_HEADER:
- commentHeader=new CommentHeader(source);
- break;
- case SETUP_HEADER:
- setupHeader=new SetupHeader(this, source);
- break;
- }
- }
-
- if(identificationHeader==null) {
- throw new VorbisFormatException("The file has no identification header.");
- }
-
- if(commentHeader==null) {
- throw new VorbisFormatException("The file has no commentHeader.");
- }
-
- if(setupHeader==null) {
- throw new VorbisFormatException("The file has no setup header.");
- }
-
- //currentPcm=new int[identificationHeader.getChannels()][16384];
- currentPcm=new byte[identificationHeader.getChannels()*identificationHeader.getBlockSize1()*2];
- //new BufferThread().start();
- }
-
- public IdentificationHeader getIdentificationHeader() {
- return identificationHeader;
- }
-
- public CommentHeader getCommentHeader() {
- return commentHeader;
- }
-
- protected SetupHeader getSetupHeader() {
- return setupHeader;
- }
-
- public boolean isOpen() {
- return oggStream.isOpen();
- }
-
- public void close() throws IOException {
- oggStream.close();
- }
-
-
- public int readPcm(byte[] buffer, int offset, int length) throws IOException {
- synchronized (streamLock) {
- final int channels=identificationHeader.getChannels();
-
- if(lastAudioPacket==null) {
- lastAudioPacket=getNextAudioPacket();
- }
- if(currentPcm==null || currentPcmIndex>=currentPcmLimit) {
- AudioPacket ap=getNextAudioPacket();
- try {
- ap.getPcm(lastAudioPacket, currentPcm);
- currentPcmLimit=ap.getNumberOfSamples()*identificationHeader.getChannels()*2;
- }
- catch(ArrayIndexOutOfBoundsException e) {
- return 0;
- }
- currentPcmIndex=0;
- lastAudioPacket=ap;
- }
- int written=0;
- int i=0;
- int arrIx=0;
- for(i=currentPcmIndex; i<currentPcmLimit && arrIx<length; i++) {
- buffer[offset+arrIx++]=currentPcm[i];
- written++;
- }
- currentPcmIndex=i;
- return written;
- }
- }
-
-
- private AudioPacket getNextAudioPacket() throws VorbisFormatException, IOException {
- pageCounter++;
- byte[] data=oggStream.getNextOggPacket();
- AudioPacket res=null;
- while(res==null) {
- try {
- res=new AudioPacket(this, new ByteArrayBitInputStream(data));
- }
- catch(ArrayIndexOutOfBoundsException e) {
- // ignore and continue with next packet
- }
- }
- currentGranulePosition+=res.getNumberOfSamples();
- currentBitRate=data.length*8*identificationHeader.getSampleRate()/res.getNumberOfSamples();
- return res;
- }
-
- public long getCurrentGranulePosition() {
- return currentGranulePosition;
- }
-
- public int getCurrentBitRate() {
- return currentBitRate;
- }
-
- public byte[] processPacket(byte[] packet) throws VorbisFormatException, IOException {
- if(packet.length==0) {
- throw new VorbisFormatException("Cannot decode a vorbis packet with length = 0");
- }
- if(((int)packet[0]&1)==1) {
- // header packet
- BitInputStream source=new ByteArrayBitInputStream(packet);
- switch(source.getInt(8)) {
- case IDENTIFICATION_HEADER:
- identificationHeader=new IdentificationHeader(source);
- break;
- case COMMENT_HEADER:
- commentHeader=new CommentHeader(source);
- break;
- case SETUP_HEADER:
- setupHeader=new SetupHeader(this, source);
- break;
- }
- return null;
- }
- else {
- // audio packet
- if(identificationHeader==null ||
- commentHeader==null ||
- setupHeader==null) {
-
- throw new VorbisFormatException("Cannot decode audio packet before all three header packets have been decoded.");
- }
-
- AudioPacket ap=new AudioPacket(this, new ByteArrayBitInputStream(packet));
- currentGranulePosition+=ap.getNumberOfSamples();
-
- if(lastAudioPacket==null) {
- lastAudioPacket=ap;
- return null;
- }
-
- byte[] res=new byte[identificationHeader.getChannels()*ap.getNumberOfSamples()*2];
-
- try {
- ap.getPcm(lastAudioPacket, res);
- }
- catch(IndexOutOfBoundsException e) {
- java.util.Arrays.fill(res, (byte)0);
- }
-
- lastAudioPacket=ap;
-
- return res;
- }
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/AudioFile.java b/songdbj/entagged/audioformats/AudioFile.java
deleted file mode 100644
index 8ff49c0d84..0000000000
--- a/songdbj/entagged/audioformats/AudioFile.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats;
-
-import entagged.audioformats.exceptions.*;
-import entagged.audioformats.generic.GenericTag;
-
-import java.io.*;
-
-/**
- * <p>This is the main object manipulated by the user representing an audiofile, its properties and its tag.</p>
- * <p>The prefered way to obtain an <code>AudioFile</code> is to use the <code>AudioFileIO.read(File)</code> method.</p>
- * <p>The <code>AudioFile</code> contains every properties associated with the file itself (no meta-data), like the bitrate, the sampling rate, the encoding infos, etc.</p>
- * <p>To get the meta-data contained in this file you have to get the <code>Tag</code> of this <code>AudioFile</code></p>
- *
- *@author Raphael Slinckx
- *@version $Id$
- *@since v0.01
- *@see AudioFileIO
- *@see Tag
- */
-public class AudioFile extends File {
- private static final long serialVersionUID = 3257289136422728502L;
-
- private EncodingInfo info;
- private Tag tag;
-
- /**
- * <p>These constructors are used by the different readers, users should not use them, but use the <code>AudioFileIO.read(File)</code> method instead !.</p>
- * <p>Create the AudioFile representing file denoted by pathname s, the encodinginfos and containing the tag</p>
- *
- *@param s The pathname of the audiofile
- *@param info the encoding infos over this file
- *@param tag the tag contained in this file
- */
- public AudioFile(String s, EncodingInfo info, Tag tag) {
- super(s);
- this.info = info;
- this.tag = tag;
- }
-
- /**
- * <p>These constructors are used by the different readers, users should not use them, but use the <code>AudioFileIO.read(File)</code> method instead !.</p>
- * <p>Create the AudioFile representing file denoted by pathname s, the encodinginfos and containing an empty tag</p>
- *
- *@param s The pathname of the audiofile
- *@param info the encoding infos over this file
- */
- public AudioFile(String s, EncodingInfo info) {
- super(s);
- this.info = info;
- this.tag = new GenericTag();
- }
-
- /**
- * <p>These constructors are used by the different readers, users should not use them, but use the <code>AudioFileIO.read(File)</code> method instead !.</p>
- * <p>Create the AudioFile representing file f, the encodinginfos and containing the tag</p>
- *
- *@param f The file of the audiofile
- *@param info the encoding infos over this file
- *@param tag the tag contained in this file
- */
- public AudioFile(File f, EncodingInfo info, Tag tag) {
- super(f.getAbsolutePath());
- this.info = info;
- this.tag = tag;
- }
-
- /**
- * <p>These constructors are used by the different readers, users should not use them, but use the <code>AudioFileIO.read(File)</code> method instead !.</p>
- * <p>Create the AudioFile representing file f, the encodinginfos and containing an empty tag</p>
- *
- *@param f The file of the audiofile
- *@param info the encoding infos over this file
- */
- public AudioFile(File f, EncodingInfo info) {
- super(f.getAbsolutePath());
- this.info = info;
- this.tag = new GenericTag();
- }
-
- /**
- * <p>Returns the bitrate of this AufioFile in kilobytes per second (KB/s). Example: 192 KB/s</p>
- *
- *@return Returns the bitrate of this AufioFile
- */
- public int getBitrate() {
- return info.getBitrate();
- }
-
- /**
- * <p>Returns the number of audio channels contained in this AudioFile, 2 for example means stereo</p>
- *
- *@return Returns the number of audio channels contained in this AudioFile
- */
- public int getChannelNumber() {
- return info.getChannelNumber();
- }
-
- /**
- * <p>Returns the encoding type of this AudioFile, this needs to be precisely specified in the future</p>
- *
- *@return Returns the encoding type of this AudioFile
- *@todo This method needs to be fully specified
- */
- public String getEncodingType() {
- return info.getEncodingType();
- }
-
- /**
- * <p>Returns the extra encoding infos of this AudioFile, this needs to be precisely specified in the future</p>
- *
- *@return Returns the extra encoding infos of this AudioFile
- *@todo This method needs to be fully specified
- */
- public String getExtraEncodingInfos() {
- return info.getExtraEncodingInfos();
- }
-
- /**
- * <p>Returns the sampling rate of this AudioFile in Hertz (Hz). Example: 44100 Hz for most of the audio files</p>
- *
- *@return Returns the sampling rate of this AudioFile
- */
- public int getSamplingRate() {
- return info.getSamplingRate();
- }
-
- /**
- * <p>Returns the length (duration) in seconds (s) of this AudioFile.Example: 241 seconds</p>
- *
- *@return Returns the length (duration) of this AudioFile
- */
- public int getLength() {
- return info.getLength();
- }
-
- /**
- * <p>Returns the tag contained in this AudioFile, the <code>Tag</code> contains any useful meta-data, like artist, album, title, etc.</p>
- * <p>If the file does not contain any tag, a new empty tag is returned</p>
- *
- *@return Returns the tag contained in this AudioFile, or a new one if file hasn't any tag.
- */
- public Tag getTag() {
- return (tag == null) ? new GenericTag() : tag;
- }
-
- /*
- * <p>Checks if this file is a VBR (variable bitrate) or a Constant Bitrate one</p>
- * <p>True means VBR, false means CBR</p>
- * <p>This has only meaning with MP3 and MPC files, other formats are always VBR
- * since it offers a better compression ratio (and lossless compression is by nature VBR</p>
- */
- public boolean isVbr() {
- return info.isVbr();
- }
-
- /**
- * <p>Returns a multi-line string with the file path, the encoding informations, and the tag contents.</p>
- *
- *@return A multi-line string with the file path, the encoding informations, and the tag contents.
- *@todo Maybe this can be changed ?
- */
- public String toString() {
- return "AudioFile "+getAbsolutePath()+" --------\n"+info.toString()+"\n"+ ( (tag == null) ? "" : tag.toString())+"\n-------------------";
- }
-}
diff --git a/songdbj/entagged/audioformats/EncodingInfo.java b/songdbj/entagged/audioformats/EncodingInfo.java
deleted file mode 100644
index 6f1ff0ff91..0000000000
--- a/songdbj/entagged/audioformats/EncodingInfo.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats;
-
-import java.util.*;
-
-public class EncodingInfo {
-
- private Hashtable content;
-
- public EncodingInfo() {
- content = new Hashtable(6);
- content.put("BITRATE", new Integer(-1) );
- content.put("CHANNB", new Integer(-1) );
- content.put("TYPE", "");
- content.put("INFOS", "");
- content.put("SAMPLING", new Integer(-1) );
- content.put("LENGTH", new Integer(-1) );
- content.put("VBR", new Boolean(true) );
- }
-
- //Sets the bitrate in KByte/s
- public void setBitrate( int bitrate ) {
- content.put("BITRATE", new Integer(bitrate) );
- }
- //Sets the number of channels
- public void setChannelNumber( int chanNb ) {
- content.put("CHANNB", new Integer(chanNb) );
- }
- //Sets the type of the encoding, this is a bit format specific. eg:Layer I/II/II
- public void setEncodingType( String encodingType ) {
- content.put("TYPE", encodingType );
- }
- //A string contianing anything else that might be interesting
- public void setExtraEncodingInfos( String infos ) {
- content.put("INFOS", infos );
- }
- //Sets the Sampling rate in Hz
- public void setSamplingRate( int samplingRate ) {
- content.put("SAMPLING", new Integer(samplingRate) );
- }
- //Sets the length of the song in seconds
- public void setLength( int length ) {
- content.put("LENGTH", new Integer(length) );
- }
- //Is the song vbr or not ?
- public void setVbr( boolean b ) {
- content.put("VBR", new Boolean(b) );
- }
-
-
- //returns the bitrate in KByte/s
- public int getBitrate() {
- return ((Integer) content.get("BITRATE")).intValue();
- }
- //Returns the number of channels
- public int getChannelNumber() {
- return ((Integer) content.get("CHANNB")).intValue();
- }
- //returns the encoding type.
- public String getEncodingType() {
- return (String) content.get("TYPE");
- }
- //returns a string with misc. information about the encoding
- public String getExtraEncodingInfos() {
- return (String) content.get("INFOS");
- }
- //returns the sample rate in Hz
- public int getSamplingRate() {
- return ((Integer) content.get("SAMPLING")).intValue();
- }
- //Returns the length of the song in seconds
- public int getLength() {
- return ((Integer) content.get("LENGTH")).intValue();
- }
- //Is the song vbr ?
- public boolean isVbr() {
- return ((Boolean) content.get("VBR")).booleanValue();
- }
-
- //Pretty prints this encoding info
- public String toString() {
- StringBuffer out = new StringBuffer(50);
- out.append("Encoding infos content:\n");
- Enumeration en = content.keys();
- while(en.hasMoreElements()) {
- Object key = en.nextElement();
- Object val = content.get(key);
- out.append("\t");
- out.append(key);
- out.append(" : ");
- out.append(val);
- out.append("\n");
- }
- return out.toString().substring(0,out.length()-1);
- }
-}
diff --git a/songdbj/entagged/audioformats/Tag.java b/songdbj/entagged/audioformats/Tag.java
deleted file mode 100644
index c1189ec2e3..0000000000
--- a/songdbj/entagged/audioformats/Tag.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package entagged.audioformats;
-
-import java.util.Iterator;
-import java.util.List;
-
-import entagged.audioformats.generic.TagField;
-
-public interface Tag {
- /**
- * This final field contains all the tags that id3v1 supports. The list has
- * the same order as the id3v1 genres. To be perfectly compatible (with
- * id3v1) the genre field should match one of these genre (case ignored).
- * You can also use this list to present a list of basic (modifiable)
- * possible choices for the genre field.
- */
- public static final String[] DEFAULT_GENRES = { "Blues", "Classic Rock",
- "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz",
- "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap",
- "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska",
- "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient",
- "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical",
- "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel",
- "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space",
- "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic",
- "Gothic", "Darkwave", "Techno-Industrial", "Electronic",
- "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy",
- "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle",
- "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave",
- "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk",
- "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll",
- "Hard Rock", "Folk", "Folk-Rock", "National Folk", "Swing",
- "Fast Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass",
- "Avantgarde", "Gothic Rock", "Progressive Rock",
- "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band",
- "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech",
- "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony",
- "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam",
- "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad",
- "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo",
- "A capella", "Euro-House", "Dance Hall" };
-
- public void add(TagField field);
-
- public void addAlbum(String s);
-
- public void addArtist(String s);
-
- public void addComment(String s);
-
- public void addGenre(String s);
-
- public void addTitle(String s);
-
- public void addTrack(String s);
-
- public void addYear(String s);
-
- public List get(String id);
-
- public Iterator getFields();
-
- public List getGenre();
-
- public List getTitle();
-
- public List getTrack();
-
- public List getYear();
- public List getAlbum();
-
- public List getArtist();
-
- public List getComment();
-
- public String getFirstGenre();
-
- public String getFirstTitle();
-
- public String getFirstTrack();
-
- public String getFirstYear();
- public String getFirstAlbum();
-
- public String getFirstArtist();
-
- public String getFirstComment();
-
- public boolean hasCommonFields();
-
- public boolean hasField(String id);
-
- public boolean isEmpty();
-
- //public Iterator getCommonFields();
- //public Iterator getSpecificFields();
-
- public void merge(Tag tag);
-
- public void set(TagField field);
-
- public void setAlbum(String s);
-
- public void setArtist(String s);
-
- public void setComment(String s);
-
- public void setGenre(String s);
-
- public void setTitle(String s);
-
- public void setTrack(String s);
-
- public void setYear(String s);
-
- public String toString();
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/AsfFileReader.java b/songdbj/entagged/audioformats/asf/AsfFileReader.java
deleted file mode 100644
index d408a9fa56..0000000000
--- a/songdbj/entagged/audioformats/asf/AsfFileReader.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-import entagged.audioformats.EncodingInfo;
-import entagged.audioformats.Tag;
-import entagged.audioformats.asf.data.AsfHeader;
-import entagged.audioformats.asf.io.AsfHeaderReader;
-import entagged.audioformats.asf.util.TagConverter;
-import entagged.audioformats.exceptions.CannotReadException;
-import entagged.audioformats.generic.AudioFileReader;
-
-/**
- * This reader can read asf files containing any content (stream type). <br>
- *
- * @author Christian Laireiter
- */
-public class AsfFileReader extends AudioFileReader {
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.AudioFileReader#getEncodingInfo(java.io.RandomAccessFile)
- */
- protected EncodingInfo getEncodingInfo(RandomAccessFile raf)
- throws CannotReadException, IOException {
- raf.seek(0);
- EncodingInfo info = new EncodingInfo();
- try {
- AsfHeader header = AsfHeaderReader.readHeader(raf);
- if (header == null) {
- throw new CannotReadException(
- "Some values must have been "
- + "incorrect for interpretation as asf with wma content.");
- }
- info.setBitrate(header.getAudioStreamChunk().getKbps());
- info.setChannelNumber((int) header.getAudioStreamChunk()
- .getChannelCount());
- info.setEncodingType("ASF (audio): "+header.getAudioStreamChunk()
- .getCodecDescription());
- info.setLength(header.getFileHeader().getDurationInSeconds());
- info.setSamplingRate((int) header.getAudioStreamChunk()
- .getSamplingRate());
-
- } catch (Exception e) {
- if (e instanceof IOException)
- throw (IOException) e;
- else if (e instanceof CannotReadException)
- throw (CannotReadException) e;
- else {
- throw new CannotReadException("Failed to read. Cause: "
- + e.getMessage());
- }
- }
- return info;
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.AudioFileReader#getTag(java.io.RandomAccessFile)
- */
- protected Tag getTag(RandomAccessFile raf) throws CannotReadException,
- IOException {
- raf.seek(0);
- Tag tag = null;
- try {
- AsfHeader header = AsfHeaderReader.readHeader(raf);
- if (header == null) {
- throw new CannotReadException(
- "Some values must have been "
- + "incorrect for interpretation as asf with wma content.");
- }
-
- tag = TagConverter.createTagOf(header);
-
- } catch (Exception e) {
- if (e instanceof IOException)
- throw (IOException) e;
- else if (e instanceof CannotReadException)
- throw (CannotReadException) e;
- else {
- throw new CannotReadException("Failed to read. Cause: "
- + e.getMessage());
- }
- }
- return tag;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/AsfHeader.java b/songdbj/entagged/audioformats/asf/data/AsfHeader.java
deleted file mode 100644
index 3b4feefe87..0000000000
--- a/songdbj/entagged/audioformats/asf/data/AsfHeader.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-
-/**
- * Each asf file starts with a so called header. <br>
- * This header contains other chunks. Each chunk starts with a 16 byte GUID
- * followed by the length (in bytes) of the chunk (including GUID). The length
- * number takes 8 bytes and is unsigned. Finally the chunk's data appears. <br>
- *
- * @author Christian Laireiter
- */
-public class AsfHeader extends Chunk {
-
- /**
- * An asf header contains multiple chunks. <br>
- * The count of those is stored here.
- */
- private final long chunkCount;
-
- /**
- * The content description of the entire file.
- */
- private ContentDescription contentDescription;
-
- /**
- * Stores the encoding chunk.
- */
- private EncodingChunk encodingChunk;
-
- /**
- * Stores the tag header.
- */
- private ExtendedContentDescription extendedContentDescription;
-
- /**
- * Stores the file header.
- */
- private FileHeader fileHeader;
-
- /**
- * This array stores all found stream chunks.
- */
- private StreamChunk[] streamChunks;
-
- /**
- * This field stores all chunks which aren't specified and not represented
- * by a wrapper. <br>
- * However during write operations this position and size of those chunks is
- * useful.
- */
- private Chunk[] unspecifiedChunks;
-
- /**
- * Creates an instance.
- *
- * @param pos
- * see {@link Chunk#position}
- * @param chunkLen
- * see {@link Chunk#chunkLength}
- * @param chunkCnt
- */
- public AsfHeader(long pos, BigInteger chunkLen, long chunkCnt) {
- super(GUID.GUID_HEADER, pos, chunkLen);
- this.chunkCount = chunkCnt;
- this.streamChunks = new StreamChunk[0];
- this.unspecifiedChunks = new Chunk[0];
- }
-
- /**
- * This method appends a StreamChunk to the header. <br>
- *
- * @param toAdd
- * Chunk to add.
- */
- public void addStreamChunk(StreamChunk toAdd) {
- if (toAdd == null) {
- throw new IllegalArgumentException("Argument must not be null.");
- }
- if (!Arrays.asList(this.streamChunks).contains(toAdd)) {
- StreamChunk[] tmp = new StreamChunk[this.streamChunks.length + 1];
- System.arraycopy(this.streamChunks, 0, tmp, 0,
- this.streamChunks.length);
- tmp[tmp.length - 1] = toAdd;
- this.streamChunks = tmp;
- }
- }
-
- /**
- * This method appends the given chunk to the
- * {@linkplain #unspecifiedChunks unspecified}list. <br>
- *
- * @param toAppend
- * The chunk whose use is unknown or of no interest.
- */
- public void addUnspecifiedChunk(Chunk toAppend) {
- if (toAppend == null) {
- throw new IllegalArgumentException("Argument must not be null.");
- }
- if (!Arrays.asList(unspecifiedChunks).contains(toAppend)) {
- Chunk[] tmp = new Chunk[unspecifiedChunks.length + 1];
- System.arraycopy(unspecifiedChunks, 0, tmp, 0,
- unspecifiedChunks.length);
- tmp[tmp.length - 1] = toAppend;
- unspecifiedChunks = tmp;
- }
- }
-
- /**
- * This method returns the first audio stream chunk found in the asf file or
- * stream.
- *
- * @return Returns the audioStreamChunk.
- */
- public AudioStreamChunk getAudioStreamChunk() {
- AudioStreamChunk result = null;
- for (int i = 0; i < getStreamChunkCount() && result == null; i++) {
- StreamChunk tmp = getStreamChunk(i);
- if (tmp instanceof AudioStreamChunk) {
- result = (AudioStreamChunk) tmp;
- }
- }
- return result;
- }
-
- /**
- * @return Returns the chunkCount.
- */
- public long getChunkCount() {
- return chunkCount;
- }
-
- /**
- * @return Returns the contentDescription.
- */
- public ContentDescription getContentDescription() {
- return contentDescription;
- }
-
- /**
- * @return Returns the encodingChunk.
- */
- public EncodingChunk getEncodingChunk() {
- return encodingChunk;
- }
-
- /**
- * @return Returns the tagHeader.
- */
- public ExtendedContentDescription getExtendedContentDescription() {
- return extendedContentDescription;
- }
-
- /**
- * @return Returns the fileHeader.
- */
- public FileHeader getFileHeader() {
- return fileHeader;
- }
-
- /**
- * This method returns the StreamChunk at given index. <br>
- *
- * @param index
- * index of the wanted chunk
- * @return StreamChunk at given index.
- */
- public StreamChunk getStreamChunk(int index) {
- return this.streamChunks[index];
- }
-
- /**
- * This method returns the amount of StreamChunks in this header. <br>
- *
- * @return Number of inserted StreamChunks.
- */
- public int getStreamChunkCount() {
- return this.streamChunks.length;
- }
-
- /**
- * This method returns the unspecified chunk at given position. <br>
- *
- * @param index
- * Index of the wanted chunk
- * @return The chunk at given index.
- */
- public Chunk getUnspecifiedChunk(int index) {
- return this.unspecifiedChunks[index];
- }
-
- /**
- * This method returns the number of {@link Chunk}objects which where
- * inserted using {@link #addUnspecifiedChunk(Chunk)}.
- *
- * @return Number of unspecified chunks.
- */
- public int getUnspecifiedChunkCount() {
- return this.unspecifiedChunks.length;
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.asf.data.Chunk#prettyPrint()
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint());
- result.insert(0, "\nASF Chunk\n");
- result.append(" Contains: \"" + getChunkCount() + "\" chunks\n");
- result.append(getFileHeader());
- result.append(getExtendedContentDescription());
- result.append(getEncodingChunk());
- result.append(getContentDescription());
- for (int i = 0; i < getStreamChunkCount(); i++) {
- result.append(getStreamChunk(i));
- }
- return result.toString();
- }
-
- /**
- * @param contentDesc
- * sets the contentDescription. <code>null</code> deletes the
- * chunk.
- */
- public void setContentDescription(ContentDescription contentDesc) {
- this.contentDescription = contentDesc;
- }
-
- /**
- * @param encChunk
- * The encodingChunk to set.
- */
- public void setEncodingChunk(EncodingChunk encChunk) {
- if (encChunk == null)
- throw new IllegalArgumentException("Argument must not be null.");
- this.encodingChunk = encChunk;
- }
-
- /**
- * @param th
- * sets the extendedContentDescription. <code>null</code>
- * delete the chunk.
- */
- public void setExtendedContentDescription(ExtendedContentDescription th) {
- this.extendedContentDescription = th;
- }
-
- /**
- * @param fh
- */
- public void setFileHeader(FileHeader fh) {
- if (fh == null)
- throw new IllegalArgumentException("Argument must not be null.");
- this.fileHeader = fh;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/AudioStreamChunk.java b/songdbj/entagged/audioformats/asf/data/AudioStreamChunk.java
deleted file mode 100644
index 619f0c2a42..0000000000
--- a/songdbj/entagged/audioformats/asf/data/AudioStreamChunk.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class represents the streamchunk describing an audio stream. <br>
- *
- * @author Christian Laireiter
- */
-public class AudioStreamChunk extends StreamChunk {
-
- /**
- * Stores the hex values of codec identifiers to their descriptions. <br>
- */
- public final static String[][] CODEC_DESCRIPTIONS = {
- { "161", " (Windows Media Audio (ver 7,8,9))" },
- { "162", " (Windows Media Audio 9 series (Professional))" },
- { "163", "(Windows Media Audio 9 series (Lossless))" },
- { "7A21", " (GSM-AMR (CBR))" }, { "7A22", " (GSM-AMR (VBR))" } };
-
- /**
- * Stores the average amount of bytes used by audio stream. <br>
- * This value is a field within type specific data of audio stream. Maybe it
- * could be used to calculate the kbps.
- */
- private long averageBytesPerSec;
-
- /**
- * Amount of bits used per sample. <br>
- */
- private int bitsPerSample;
-
- /**
- * The block alignment of the audio data.
- */
- private long blockAlignment;
-
- /**
- * Number of channels.
- */
- private long channelCount;
-
- /**
- * Some data which needs to be interpreted if the codec is handled.
- */
- private byte[] codecData;
-
- /**
- * The audio compression format code.
- */
- private long compressionFormat;
-
- /**
- * this field stores the error concealment type.
- */
- private GUID errorConcealment;
-
- /**
- * Sampling rate of audio stream.
- */
- private long samplingRate;
-
- /**
- * Creates an instance.
- *
- * @param pos
- * Position of current chunk within asf file or stream.
- * @param chunkLen
- * Length of the entire chunk (including guid and size)
- */
- public AudioStreamChunk(long pos, BigInteger chunkLen) {
- super(pos, chunkLen);
- }
-
- /**
- * @return Returns the averageBytesPerSec.
- */
- public long getAverageBytesPerSec() {
- return averageBytesPerSec;
- }
-
- /**
- * @return Returns the bitsPerSample.
- */
- public int getBitsPerSample() {
- return bitsPerSample;
- }
-
- /**
- * @return Returns the blockAlignment.
- */
- public long getBlockAlignment() {
- return blockAlignment;
- }
-
- /**
- * @return Returns the channelCount.
- */
- public long getChannelCount() {
- return channelCount;
- }
-
- /**
- * @return Returns the codecData.
- */
- public byte[] getCodecData() {
- return codecData;
- }
-
- /**
- * This method will take a look at {@link #compressionFormat}and returns a
- * String with its hex value and if known a textual note on what coded it
- * represents. <br>
- *
- * @return A description for the used codec.
- */
- public String getCodecDescription() {
- StringBuffer result = new StringBuffer(Long
- .toHexString(getCompressionFormat()));
- String furtherDesc = " (Unknown)";
- for (int i = 0; i < CODEC_DESCRIPTIONS.length; i++) {
- if (CODEC_DESCRIPTIONS[i][0].equalsIgnoreCase(result.toString())) {
- furtherDesc = CODEC_DESCRIPTIONS[i][1];
- break;
- }
- }
- if (result.length() % 2 != 0) {
- result.insert(0, "0x0");
- } else {
- result.insert(0, "0x");
- }
- result.append(furtherDesc);
- return result.toString();
- }
-
- /**
- * @return Returns the compressionFormat.
- */
- public long getCompressionFormat() {
- return compressionFormat;
- }
-
- /**
- * @return Returns the errorConcealment.
- */
- public GUID getErrorConcealment() {
- return errorConcealment;
- }
-
- /**
- * This method takes the value of {@link #getAverageBytesPerSec()}and
- * calculates the kbps out of it, by simply multiplying by 8 and dividing by
- * 1000. <br>
- *
- * @return amount of bits per second in kilo bits.
- */
- public int getKbps() {
- return (int) getAverageBytesPerSec() * 8 / 1000;
- }
-
- /**
- * @return Returns the samplingRate.
- */
- public long getSamplingRate() {
- return samplingRate;
- }
-
- /**
- * This mehtod returns whether the audio stream data is error concealed.
- * <br>
- * For now only interleaved concealment is known. <br>
- *
- * @return <code>true</code> if error concealment is used.
- */
- public boolean isErrorConcealed() {
- return getErrorConcealment().equals(
- GUID.GUID_AUDIO_ERROR_CONCEALEMENT_INTERLEAVED);
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.asf.data.StreamChunk#prettyPrint()
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint().replaceAll(
- Utils.LINE_SEPARATOR, Utils.LINE_SEPARATOR + " "));
- result.insert(0, Utils.LINE_SEPARATOR + "AudioStream");
- result.append("Audio info:" + Utils.LINE_SEPARATOR);
- result.append(" Bitrate : " + getKbps() + Utils.LINE_SEPARATOR);
- result.append(" Channels : " + getChannelCount() + " at "
- + getSamplingRate() + " Hz" + Utils.LINE_SEPARATOR);
- result.append(" Bits per Sample: " + getBitsPerSample()
- + Utils.LINE_SEPARATOR);
- result.append(" Formatcode: " + getCodecDescription()
- + Utils.LINE_SEPARATOR);
- return result.toString();
- }
-
- /**
- * @param avgeBytesPerSec
- * The averageBytesPerSec to set.
- */
- public void setAverageBytesPerSec(long avgeBytesPerSec) {
- this.averageBytesPerSec = avgeBytesPerSec;
- }
-
- /**
- * Sets the bitsPerSample
- *
- * @param bps
- */
- public void setBitsPerSample(int bps) {
- this.bitsPerSample = bps;
- }
-
- /**
- * Sets the blockAlignment.
- *
- * @param align
- */
- public void setBlockAlignment(long align) {
- this.blockAlignment = align;
- }
-
- /**
- * @param channels
- * The channelCount to set.
- */
- public void setChannelCount(long channels) {
- this.channelCount = channels;
- }
-
- /**
- * Sets the codecData
- *
- * @param codecSpecificData
- */
- public void setCodecData(byte[] codecSpecificData) {
- this.codecData = codecSpecificData;
- }
-
- /**
- * @param cFormatCode
- * The compressionFormat to set.
- */
- public void setCompressionFormat(long cFormatCode) {
- this.compressionFormat = cFormatCode;
- }
-
- /**
- * This method sets the error concealment type which is given by two GUIDs.
- * <br>
- *
- * @param errConc
- * the type of error concealment the audio stream is stored as.
- */
- public void setErrorConcealment(GUID errConc) {
- this.errorConcealment = errConc;
- }
-
- /**
- * @param sampRate
- * The samplingRate to set.
- */
- public void setSamplingRate(long sampRate) {
- this.samplingRate = sampRate;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/Chunk.java b/songdbj/entagged/audioformats/asf/data/Chunk.java
deleted file mode 100644
index b0da2fc853..0000000000
--- a/songdbj/entagged/audioformats/asf/data/Chunk.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.math.BigInteger;
-
-/**
- * This class represents a chunk within asf streams. <br>
- * Each chunk starts with a 16byte guid identifying the type. After that a
- * number (represented by 8 bytes) follows which shows the size in bytes of the
- * chunk. Finally there is the data of the chunk.
- *
- * @author Christian Laireiter
- */
-public class Chunk {
-
- /**
- * The length of current chunk. <br>
- */
- protected final BigInteger chunkLength;
-
- /**
- * The guid of represented chunk header.
- */
- protected final GUID guid;
-
- /**
- * The position of current header object within file or stream.
- */
- protected final long position;
-
- /**
- * Creates an instance
- *
- * @param headerGuid
- * The GUID of header object.
- * @param pos
- * Position of header object within stream or file.
- * @param chunkLen
- * Length of current chunk.
- */
- public Chunk(GUID headerGuid, long pos, BigInteger chunkLen) {
- if (headerGuid == null) {
- throw new IllegalArgumentException(
- "GUID must not be null nor anything else than "
- + GUID.GUID_LENGTH + " entries long.");
- }
- if (pos < 0) {
- throw new IllegalArgumentException(
- "Position of header can't be negative.");
- }
- if (chunkLen == null || chunkLen.compareTo(BigInteger.ZERO) < 0) {
- throw new IllegalArgumentException(
- "chunkLen must not be null nor negative.");
- }
- this.guid = headerGuid;
- this.position = pos;
- this.chunkLength = chunkLen;
- }
-
- /**
- * This method returns the End of the current chunk introduced by current
- * header object.
- *
- * @return Position after current chunk.
- */
- public long getChunckEnd() {
- return position + chunkLength.longValue();
- }
-
- /**
- * @return Returns the chunkLength.
- */
- public BigInteger getChunkLength() {
- return chunkLength;
- }
-
- /**
- * @return Returns the guid.
- */
- public GUID getGuid() {
- return guid;
- }
-
- /**
- * @return Returns the position.
- */
- public long getPosition() {
- return position;
- }
-
- /**
- * This method creates a String containing usefull information prepared to
- * be printed on stdout. <br>
- * This method is intended to be overwritten by inheriting classes.
- *
- * @return Information of current Chunk Object.
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer();
- result.append("GUID: " + GUID.getGuidDescription(guid));
- result.append("\n Starts at position: " + getPosition() + "\n");
- result.append(" Last byte at: " + (getChunckEnd() - 1) + "\n\n");
- return result.toString();
- }
-
- /**
- * (overridden)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return prettyPrint();
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/ContentDescription.java b/songdbj/entagged/audioformats/asf/data/ContentDescription.java
deleted file mode 100644
index 6601a2ccdc..0000000000
--- a/songdbj/entagged/audioformats/asf/data/ContentDescription.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.io.ByteArrayOutputStream;
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class represents the data of a chunk which contains title, author,
- * copyright, description and the rating of the file. <br>
- * It is optional whithin asf files. But if exists only once.
- *
- * @author Christian Laireiter
- */
-public class ContentDescription extends Chunk {
-
- /**
- * File artist.
- */
- private String author = null;
-
- /**
- * File copyright.
- */
- private String copyRight = null;
-
- /**
- * File comment.
- */
- private String description = null;
-
- /**
- * File rating.
- */
- private String rating = null;
-
- /**
- * File title.
- */
- private String title = null;
-
- /**
- * Creates an instance. <br>
- */
- public ContentDescription() {
- this(0, BigInteger.valueOf(0));
- }
-
- /**
- * Creates an instance.
- *
- * @param pos
- * Position of content description within file or stream
- * @param chunkLen
- * Length of content description.
- */
- public ContentDescription(long pos, BigInteger chunkLen) {
- super(GUID.GUID_CONTENTDESCRIPTION, pos, chunkLen);
- }
-
- /**
- * @return Returns the author.
- */
- public String getAuthor() {
- if (author == null)
- return "";
- return author;
- }
-
- /**
- * This method creates a byte array that could directly be written to an asf
- * file. <br>
- *
- * @return The asf chunk representation of a content description with the
- * values of the current object.
- */
- public byte[] getBytes() {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- try {
- ByteArrayOutputStream tags = new ByteArrayOutputStream();
- String[] toWrite = new String[] { getTitle(), getAuthor(),
- getCopyRight(), getComment(), getRating() };
- byte[][] stringRepresentations = new byte[toWrite.length][];
- // Create byte[] of UTF-16LE encodings
- for (int i = 0; i < toWrite.length; i++) {
- stringRepresentations[i] = toWrite[i].getBytes("UTF-16LE");
- }
- // Write the amount of bytes needed to store the values.
- for (int i = 0; i < stringRepresentations.length; i++) {
- tags.write(Utils.getBytes(stringRepresentations[i].length + 2,
- 2));
- }
- // Write the values themselves.
- for (int i = 0; i < toWrite.length; i++) {
- tags.write(stringRepresentations[i]);
- // Zero term character.
- tags.write(Utils.getBytes(0, 2));
- }
- // Now tags has got the values. The result just needs
- // The GUID, length of the chunk and the tags.
- byte[] tagContent = tags.toByteArray();
- // The guid of the chunk
- result.write(GUID.GUID_CONTENTDESCRIPTION.getBytes());
- /*
- * The length of the chunk. 16 Bytes guid 8 Bytes the length
- * tagContent.length bytes.
- */
- result.write(Utils.getBytes(tagContent.length + 24, 8));
- // The tags.
- result.write(tagContent);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return result.toByteArray();
- }
-
- /**
- * @return Returns the comment.
- */
- public String getComment() {
- if (description == null)
- return "";
- return description;
- }
-
- /**
- * @return Returns the copyRight.
- */
- public String getCopyRight() {
- if (copyRight == null)
- return "";
- return copyRight;
- }
-
- /**
- * @return returns the rating.
- */
- public String getRating() {
- if (rating == null)
- return "";
- return rating;
- }
-
- /**
- * @return Returns the title.
- */
- public String getTitle() {
- if (title == null)
- return "";
- return title;
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.asf.data.Chunk#prettyPrint()
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint());
- result.insert(0, Utils.LINE_SEPARATOR + "Content Description:"
- + Utils.LINE_SEPARATOR);
- result.append(" Title : " + getTitle() + Utils.LINE_SEPARATOR);
- result.append(" Author : " + getAuthor() + Utils.LINE_SEPARATOR);
- result.append(" Copyright : " + getCopyRight()
- + Utils.LINE_SEPARATOR);
- result.append(" Description: " + getComment() + Utils.LINE_SEPARATOR);
- result.append(" Rating :" + getRating() + Utils.LINE_SEPARATOR);
- return result.toString();
- }
-
- /**
- * @param fileAuthor
- * The author to set.
- * @throws IllegalArgumentException
- * If "UTF-16LE"-byte-representation would take more than 65535
- * bytes.
- */
- public void setAuthor(String fileAuthor) throws IllegalArgumentException {
- Utils.checkStringLengthNullSafe(fileAuthor);
- this.author = fileAuthor;
- }
-
- /**
- * @param tagComment
- * The comment to set.
- * @throws IllegalArgumentException
- * If "UTF-16LE"-byte-representation would take more than 65535
- * bytes.
- */
- public void setComment(String tagComment) throws IllegalArgumentException {
- Utils.checkStringLengthNullSafe(tagComment);
- this.description = tagComment;
- }
-
- /**
- * @param cpright
- * The copyRight to set.
- * @throws IllegalArgumentException
- * If "UTF-16LE"-byte-representation would take more than 65535
- * bytes.
- */
- public void setCopyRight(String cpright) throws IllegalArgumentException {
- Utils.checkStringLengthNullSafe(cpright);
- this.copyRight = cpright;
- }
-
- /**
- * @param ratingText
- * The rating to be set.
- * @throws IllegalArgumentException
- * If "UTF-16LE"-byte-representation would take more than 65535
- * bytes.
- */
- public void setRating(String ratingText) throws IllegalArgumentException {
- Utils.checkStringLengthNullSafe(ratingText);
- this.rating = ratingText;
- }
-
- /**
- * @param songTitle
- * The title to set.
- * @throws IllegalArgumentException
- * If "UTF-16LE"-byte-representation would take more than 65535
- * bytes.
- */
- public void setTitle(String songTitle) throws IllegalArgumentException {
- Utils.checkStringLengthNullSafe(songTitle);
- this.title = songTitle;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/ContentDescriptor.java b/songdbj/entagged/audioformats/asf/data/ContentDescriptor.java
deleted file mode 100644
index ddacbd841c..0000000000
--- a/songdbj/entagged/audioformats/asf/data/ContentDescriptor.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.HashSet;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class is a wrapper for properties within a
- * {@link entagged.audioformats.asf.data.ExtendedContentDescription}.<br>
- *
- * @author Christian Laireiter
- */
-public final class ContentDescriptor implements Comparable {
- /**
- * This field stores all values of the "ID_"-constants.
- */
- public final static HashSet COMMON_FIELD_IDS;
-
- /**
- * This constant gives the common id (name) for the "album" field in an asf
- * extended content description.
- */
- public final static String ID_ALBUM = "WM/AlbumTitle";
-
- /**
- * This constant gives the common id (name) for the "artist" field in an asf
- * extended content description.
- */
- public final static String ID_ARTIST ="WM/AlbumArtist";
-
- /**
- * This constant gives the common id (name) for the "genre" field in an asf
- * extended content description.
- */
- public final static String ID_GENRE = "WM/Genre";
-
- /**
- * This constant gives the common id (name) for the "genre Id" field in an
- * asf extended content description.
- */
- public final static String ID_GENREID = "WM/GenreID";
-
- /**
- * This constant gives the common id (name) for the "track number" field in
- * an asf extended content description.
- */
- public final static String ID_TRACKNUMBER = "WM/TrackNumber";
-
- /**
- * This constant gives the common id (name) for the "year" field in an asf
- * extended content description.
- */
- public final static String ID_YEAR = "WM/Year";
-
- /**
- * Constant for the content descriptor-type for binary data.
- */
- public final static int TYPE_BINARY = 1;
-
- /**
- * Constant for the content descriptor-type for booleans.
- */
- public final static int TYPE_BOOLEAN = 2;
-
- /**
- * Constant for the content descriptor-type for integers (32-bit). <br>
- */
- public final static int TYPE_DWORD = 3;
-
- /**
- * Constant for the content descriptor-type for integers (64-bit). <br>
- */
- public final static int TYPE_QWORD = 4;
-
- /**
- * Constant for the content descriptor-type for Strings.
- */
- public final static int TYPE_STRING = 0;
-
- /**
- * Constant for the content descriptor-type for integers (16-bit). <br>
- */
- public final static int TYPE_WORD = 5;
-
- static {
- COMMON_FIELD_IDS = new HashSet();
- COMMON_FIELD_IDS.add(ID_ALBUM);
- COMMON_FIELD_IDS.add(ID_ARTIST);
- COMMON_FIELD_IDS.add(ID_GENRE);
- COMMON_FIELD_IDS.add(ID_GENREID);
- COMMON_FIELD_IDS.add(ID_TRACKNUMBER);
- COMMON_FIELD_IDS.add(ID_YEAR);
- }
-
- /**
- * The binary representation of the value.
- */
- protected byte[] content = new byte[0];
-
- /**
- * This field shows the type of the content descriptor. <br>
- *
- * @see #TYPE_BINARY
- * @see #TYPE_BOOLEAN
- * @see #TYPE_DWORD
- * @see #TYPE_QWORD
- * @see #TYPE_STRING
- * @see #TYPE_WORD
- */
- private int descriptorType;
-
- /**
- * The name of the content descriptor.
- */
- private final String name;
-
- /**
- * Creates an Instance.
- *
- * @param propName
- * Name of the ContentDescriptor.
- * @param propType
- * Type of the content descriptor. See {@link #descriptorType}
- *
- */
- public ContentDescriptor(String propName, int propType) {
- if (propName == null) {
- throw new IllegalArgumentException("Arguments must not be null.");
- }
- Utils.checkStringLengthNullSafe(propName);
- this.name = propName;
- this.descriptorType = propType;
- }
-
- /**
- * (overridden)
- *
- * @see java.lang.Object#clone()
- */
- public Object clone() throws CloneNotSupportedException {
- return createCopy();
- }
-
- /**
- * (overridden)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(Object o) {
- int result = 0;
- if (o instanceof ContentDescriptor) {
- ContentDescriptor other = (ContentDescriptor) o;
- result = getName().compareTo(other.getName());
- }
- return result;
- }
-
- /**
- * This mehtod creates a copy of the current object. <br>
- * All data will be copied, too. <br>
- *
- * @return A new Contentdescriptor containing the same values as the current
- * one.
- */
- public ContentDescriptor createCopy() {
- ContentDescriptor result = new ContentDescriptor(getName(), getType());
- result.content = getRawData();
- return result;
- }
-
- /**
- * (overridden)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- boolean result = false;
- if (obj instanceof ContentDescriptor) {
- if (obj == this) {
- result = true;
- } else {
- ContentDescriptor other = (ContentDescriptor) obj;
- result = other.getName().equals(getName())
- && other.descriptorType == this.descriptorType
- && Arrays.equals(this.content, other.content);
- }
- }
- return result;
- }
-
- /**
- * Returns the value of the ContentDescriptor as a Boolean. <br>
- * If no Conversion is Possible false is returned. <br>
- * <code>true</code> if first byte of {@link #content}is not zero.
- *
- * @return boolean representation of the current value.
- */
- public boolean getBoolean() {
- return content.length > 0 && content[0] != 0;
- }
-
- /**
- * This method will return a byte array, which can directly be written into
- * an "Extended Content Description"-chunk. <br>
- *
- * @return byte[] with the data, that occurs in asf files.
- */
- public byte[] getBytes() {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- try {
- byte[] nameBytes = getName().getBytes("UTF-16LE");
- // Write the number of bytes the name needs. +2 because of the
- // Zero term character.
- result.write(Utils.getBytes(nameBytes.length + 2, 2));
- // Write the name itself
- result.write(nameBytes);
- // Write zero term character
- result.write(Utils.getBytes(0, 2));
- // Write the type of the current descriptor
- result.write(Utils.getBytes(getType(), 2));
- /*
- * Now the content.
- */
- if (this.getType() == TYPE_STRING) {
- // String length +2 for zero termination
- result.write(Utils.getBytes(content.length + 2, 2));
- // Value
- result.write(content);
- // Zero term
- result.write(Utils.getBytes(0, 2));
- } else {
- result.write(Utils.getBytes(content.length, 2));
- result.write(content);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return result.toByteArray();
- }
-
- /**
- * This method returns the name of the content descriptor.
- *
- * @return Name.
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * This method returns the value of the content descriptor as an integer.
- * <br>
- * Converts the needed amount of byte out of {@link #content}to a number.
- * <br>
- * Only possible if {@link #getType()}equals on of the following: <br>
- * <li>
- *
- * @see #TYPE_BOOLEAN</li>
- * <li>
- * @see #TYPE_DWORD</li>
- * <li>
- * @see #TYPE_QWORD</li>
- * <li>
- * @see #TYPE_WORD</li>
- *
- * @return integer value.
- */
- public long getNumber() {
- long result = 0;
- int bytesNeeded = -1;
- switch (getType()) {
- case TYPE_BOOLEAN:
- bytesNeeded = 1;
- break;
- case TYPE_DWORD:
- bytesNeeded = 4;
- break;
- case TYPE_QWORD:
- bytesNeeded = 8;
- break;
- case TYPE_WORD:
- bytesNeeded = 2;
- break;
- default:
- throw new UnsupportedOperationException(
- "The current type doesn't allow an interpretation as a number.");
- }
- if (bytesNeeded > content.length) {
- throw new IllegalStateException(
- "The stored data cannot represent the type of current object.");
- }
- for (int i = 0; i < bytesNeeded; i++) {
- result |= (content[i] << (i * 8));
- }
- return result;
- }
-
- /**
- * This method returns a copy of the content of the descriptor. <br>
- *
- * @return The content in binary representation, as it would be written to
- * asf file. <br>
- */
- public byte[] getRawData() {
- byte[] copy = new byte[this.content.length];
- System.arraycopy(copy, 0, this.content, 0, this.content.length);
- return copy;
- }
-
- /**
- * Returns the value of the ContentDescriptor as a String. <br>
- *
- * @return String - Representation Value
- */
- public String getString() {
- String result = "";
- switch (getType()) {
- case TYPE_BINARY:
- result = "binary data";
- break;
- case TYPE_BOOLEAN:
- result = String.valueOf(getBoolean());
- break;
- case TYPE_QWORD:
- case TYPE_DWORD:
- case TYPE_WORD:
- result = String.valueOf(getNumber());
- break;
- case TYPE_STRING:
- try {
- result = new String(content, "UTF-16LE");
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- default:
- throw new IllegalStateException("Current type is not known.");
- }
- return result;
- }
-
- /**
- * Returns the type of the content descriptor. <br>
- *
- * @see #TYPE_BINARY
- * @see #TYPE_BOOLEAN
- * @see #TYPE_DWORD
- * @see #TYPE_QWORD
- * @see #TYPE_STRING
- * @see #TYPE_WORD
- *
- * @return the value of {@link #descriptorType}
- */
- public int getType() {
- return this.descriptorType;
- }
-
- /**
- * This method checks whether the name of the current field is one of the
- * commonly specified fields. <br>
- *
- * @see #ID_ALBUM
- * @see #ID_GENRE
- * @see #ID_GENREID
- * @see #ID_TRACKNUMBER
- * @see #ID_YEAR
- * @return <code>true</code> if a common field.
- */
- public boolean isCommon() {
- return COMMON_FIELD_IDS.contains(this.getName());
- }
-
- /**
- * This method checks if the binary data is empty. <br>
- * Disregarding the type of the descriptor its content is stored as a byte
- * array.
- *
- * @return <code>true</code> if no value is set.
- */
- public boolean isEmpty() {
- return this.content.length == 0;
- }
-
- /**
- * Sets the Value of the current content descriptor. <br>
- * Using this method will change {@link #descriptorType}to
- * {@link #TYPE_BINARY}.<br>
- *
- * @param data
- * Value to set.
- * @throws IllegalArgumentException
- * If the byte array is greater that 65535 bytes.
- */
- public void setBinaryValue(byte[] data) throws IllegalArgumentException {
- if (data.length > 65535) {
- throw new IllegalArgumentException(
- "Too many bytes. 65535 is maximum.");
- }
- this.content = data;
- this.descriptorType = TYPE_BINARY;
- }
-
- /**
- * Sets the Value of the current content descriptor. <br>
- * Using this method will change {@link #descriptorType}to
- * {@link #TYPE_BOOLEAN}.<br>
- *
- * @param value
- * Value to set.
- */
- public void setBooleanValue(boolean value) {
- this.content = new byte[] { value ? (byte) 1 : 0, 0, 0, 0 };
- this.descriptorType = TYPE_BOOLEAN;
- }
-
- /**
- * Sets the Value of the current content descriptor. <br>
- * Using this method will change {@link #descriptorType}to
- * {@link #TYPE_DWORD}.
- *
- * @param value
- * Value to set.
- */
- public void setDWordValue(long value) {
- this.content = Utils.getBytes(value, 4);
- this.descriptorType = TYPE_DWORD;
- }
-
- /**
- * Sets the Value of the current content descriptor. <br>
- * Using this method will change {@link #descriptorType}to
- * {@link #TYPE_QWORD}
- *
- * @param value
- * Value to set.
- */
- public void setQWordValue(long value) {
- this.content = Utils.getBytes(value, 8);
- this.descriptorType = TYPE_QWORD;
- }
-
- /**
- * Sets the Value of the current content descriptor. <br>
- * Using this method will change {@link #descriptorType}to
- * {@link #TYPE_STRING}.
- *
- * @param value
- * Value to set.
- * @throws IllegalArgumentException
- * If byte representation would take more than 65535 Bytes.
- */
- public void setStringValue(String value) throws IllegalArgumentException {
- try {
- byte[] tmp = value.getBytes("UTF-16LE");
- if (tmp.length > 65535) {
- throw new IllegalArgumentException(
- "Byte representation of String in "
- + "\"UTF-16LE\" is to great. (Maximum is 65535 Bytes)");
- }
- this.content = tmp;
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- this.content = new byte[0];
- }
- this.descriptorType = TYPE_STRING;
- }
-
- /**
- * Sets the Value of the current content descriptor. <br>
- * Using this method will change {@link #descriptorType}to
- * {@link #TYPE_WORD}
- *
- * @param value
- * Value to set.
- */
- public void setWordValue(int value) {
- this.content = Utils.getBytes(value, 2);
- this.descriptorType = TYPE_WORD;
- }
-
- /**
- * (overridden)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return getName()
- + " : "
- + new String[] { "String: ", "Binary: ", "Boolean: ",
- "DWORD: ", "QWORD:", "WORD:" }[this.descriptorType]
- + getString();
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/EncodingChunk.java b/songdbj/entagged/audioformats/asf/data/EncodingChunk.java
deleted file mode 100644
index 32c9e75c8d..0000000000
--- a/songdbj/entagged/audioformats/asf/data/EncodingChunk.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class was intended to store the data of a chunk which contained the
- * encoding parameters in textual form. <br>
- * Since the needed parameters were found in other chunks the implementation of
- * this class was paused. <br>
- * TODO complete analysis.
- *
- * @author Christian Laireiter
- */
-public class EncodingChunk extends Chunk {
-
- /**
- * The read strings.
- */
- private final ArrayList strings;
-
- /**
- * Creates an instance.
- *
- * @param pos
- * Position of the chunk within file or stream
- * @param chunkLen
- * Length of current chunk.
- */
- public EncodingChunk(long pos, BigInteger chunkLen) {
- super(GUID.GUID_ENCODING, pos, chunkLen);
- this.strings = new ArrayList();
- }
-
- /**
- * This method appends a String.
- *
- * @param toAdd
- * String to add.
- */
- public void addString(String toAdd) {
- strings.add(toAdd);
- }
-
- /**
- * This method returns a collection of all {@link String}s which were addid
- * due {@link #addString(String)}.
- *
- * @return Inserted Strings.
- */
- public Collection getStrings() {
- return new ArrayList(strings);
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.asf.data.Chunk#prettyPrint()
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint());
- result.insert(0, Utils.LINE_SEPARATOR + "Encoding:"
- + Utils.LINE_SEPARATOR);
- Iterator iterator = this.strings.iterator();
- while (iterator.hasNext()) {
- result.append(" " + iterator.next() + Utils.LINE_SEPARATOR);
- }
- return result.toString();
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/ExtendedContentDescription.java b/songdbj/entagged/audioformats/asf/data/ExtendedContentDescription.java
deleted file mode 100644
index 6d957df8f3..0000000000
--- a/songdbj/entagged/audioformats/asf/data/ExtendedContentDescription.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.io.ByteArrayOutputStream;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import entagged.audioformats.Tag;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This structure represents the data of a chunk, wich contains extended content
- * description. <br>
- * These properties are simply represented by
- * {@link entagged.audioformats.asf.data.ContentDescriptor}
- *
- * @author Christian Laireiter
- */
-public class ExtendedContentDescription extends Chunk {
-
- /**
- * Contains the properties. <br>
- */
- private final ArrayList descriptors;
-
- /**
- * This map stores the ids (names) of inserted content descriptors. <br>
- * If {@link #getDescriptor(String)}is called this field will be filled if
- * <code>null</code>. Any modification of the contents of this object
- * will set this field to <code>null</code>.
- */
- private HashMap indexMap = null;
-
- /**
- * Creates an instance.
- *
- */
- public ExtendedContentDescription() {
- this(0, BigInteger.valueOf(0));
- }
-
- /**
- * Creates an instance.
- *
- * @param pos
- * Position of header object within file or stream.
- * @param chunkLen
- * Length of the represented chunck.
- */
- public ExtendedContentDescription(long pos, BigInteger chunkLen) {
- super(GUID.GUID_EXTENDED_CONTENT_DESCRIPTION, pos, chunkLen);
- this.descriptors = new ArrayList();
- }
-
- /**
- * This method inserts the given ContentDescriptor.
- *
- * @param toAdd
- * ContentDescriptor to insert.
- */
- public void addDescriptor(ContentDescriptor toAdd) {
- assert toAdd != null : "Argument must not be null.";
- if (getDescriptor(toAdd.getName()) != null) {
- throw new RuntimeException(toAdd.getName() + " is already present");
- }
- this.descriptors.add(toAdd);
- this.indexMap.put(toAdd.getName(), new Integer(descriptors.size() - 1));
- }
-
- /**
- * This method adds or replaces an existing content descriptor.
- *
- * @param descriptor
- * Descriptor to be added or replaced.
- */
- public void addOrReplace(ContentDescriptor descriptor) {
- assert descriptor != null : "Argument must not be null";
- if (getDescriptor(descriptor.getName()) != null) {
- /*
- * Just remove if exists. Will prevent the indexmap being rebuild.
- */
- remove(descriptor.getName());
- }
- addDescriptor(descriptor);
- }
-
- /**
- * Returns the album entered in the content descriptor chunk.
- *
- * @return Album, <code>""</code> if not defined.
- */
- public String getAlbum() {
- ContentDescriptor result = getDescriptor(ContentDescriptor.ID_ALBUM);
- if (result == null)
- return "";
-
- return result.getString();
- }
-
- /**
- * Returns the "WM/AlbumArtist" entered in the extended content description.
- *
- * @return Title, <code>""</code> if not defined.
- */
- public String getArtist() {
- ContentDescriptor result = getDescriptor(ContentDescriptor.ID_ARTIST);
- if (result == null)
- return "";
- return result.getString();
- }
-
- /**
- * This method creates a byte array which can be written to asf files.
- *
- * @return asf file representation of the current object.
- */
- public byte[] getBytes() {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- try {
- ByteArrayOutputStream content = new ByteArrayOutputStream();
- // Write the number of descriptors.
- content.write(Utils.getBytes(this.descriptors.size(), 2));
- Iterator it = this.descriptors.iterator();
- while (it.hasNext()) {
- ContentDescriptor current = (ContentDescriptor) it.next();
- content.write(current.getBytes());
- }
- byte[] contentBytes = content.toByteArray();
- // Write the guid
- result.write(GUID.GUID_EXTENDED_CONTENT_DESCRIPTION.getBytes());
- // Write the length + 24.
- result.write(Utils.getBytes(contentBytes.length + 24, 8));
- // Write the content
- result.write(contentBytes);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return result.toByteArray();
- }
-
- /**
- * Returns a previously inserted content descriptor.
- *
- * @param name
- * name of the content descriptor.
- * @return <code>null</code> if not present.
- */
- public ContentDescriptor getDescriptor(String name) {
- if (this.indexMap == null) {
- this.indexMap = new HashMap();
- for (int i = 0; i < descriptors.size(); i++) {
- ContentDescriptor current = (ContentDescriptor) descriptors
- .get(i);
- indexMap.put(current.getName(), new Integer(i));
- }
- }
- Integer pos = (Integer) indexMap.get(name);
- if (pos != null) {
- return (ContentDescriptor) descriptors.get(pos.intValue());
- }
- return null;
- }
-
- /**
- * @return Returns the descriptorCount.
- */
- public long getDescriptorCount() {
- return descriptors.size();
- }
-
- /**
- * Returns a collection of all {@link ContentDescriptor}objects stored in
- * this extended content description.
- *
- * @return An enumeration of {@link ContentDescriptor}objects.
- */
- public Collection getDescriptors() {
- return new ArrayList(this.descriptors);
- }
-
- /**
- * Returns the Genre entered in the content descriptor chunk.
- *
- * @return Genre, <code>""</code> if not defined.
- */
- public String getGenre() {
- String result = null;
- ContentDescriptor prop = getDescriptor(ContentDescriptor.ID_GENRE);
- if (prop == null) {
- prop = getDescriptor(ContentDescriptor.ID_GENREID);
- if (prop == null)
- result = "";
- else {
- result = prop.getString();
- if (result.startsWith("(") && result.endsWith(")")) {
- result = result.substring(1, result.length() - 1);
- try {
- int genreNum = Integer.parseInt(result);
- if (genreNum >= 0
- && genreNum < Tag.DEFAULT_GENRES.length) {
- result = Tag.DEFAULT_GENRES[genreNum];
- }
- } catch (NumberFormatException e) {
- // Do nothing
- }
- }
- }
- } else {
- result = prop.getString();
- }
- return result;
- }
-
- /**
- * Returns the Track entered in the content descriptor chunk.
- *
- * @return Track, <code>""</code> if not defined.
- */
- public String getTrack() {
- ContentDescriptor result = getDescriptor(ContentDescriptor.ID_TRACKNUMBER);
- if (result == null)
- return "";
-
- return result.getString();
- }
-
- /**
- * Returns the Year entered in the extended content descripion.
- *
- * @return Year, <code>""</code> if not defined.
- */
- public String getYear() {
- ContentDescriptor result = getDescriptor(ContentDescriptor.ID_YEAR);
- if (result == null)
- return "";
-
- return result.getString();
- }
-
- /**
- * This method creates a String containing the tag elements an their values
- * for printing. <br>
- *
- * @return nice string.
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint());
- result.insert(0, "\nExtended Content Description:\n");
- ContentDescriptor[] list = (ContentDescriptor[]) descriptors
- .toArray(new ContentDescriptor[descriptors.size()]);
- Arrays.sort(list);
- for (int i = 0; i < list.length; i++) {
- result.append(" ");
- result.append(list[i]);
- result.append(Utils.LINE_SEPARATOR);
- }
- return result.toString();
- }
-
- /**
- * This method removes the content descriptor with the given name. <br>
- *
- * @param id
- * The id (name) of the descriptor which should be removed.
- * @return The descriptor which is removed. If not present <code>null</code>.
- */
- public ContentDescriptor remove(String id) {
- ContentDescriptor result = getDescriptor(id);
- if (result != null) {
- descriptors.remove(result);
- }
- this.indexMap = null;
- return result;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/FileHeader.java b/songdbj/entagged/audioformats/asf/data/FileHeader.java
deleted file mode 100644
index cdafbeb6be..0000000000
--- a/songdbj/entagged/audioformats/asf/data/FileHeader.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.math.BigInteger;
-import java.util.Date;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class stores the information about the file, which is contained within a
- * special chunk of asf files.<br>
- *
- * @author Christian Laireiter
- */
-public class FileHeader extends Chunk {
-
- /**
- * Duration of the media content in 100ns steps.
- */
- private final BigInteger duration;
-
- /**
- * The time the file was created.
- */
- private final Date fileCreationTime;
-
- /**
- * Size of the file or stream.
- */
- private BigInteger fileSize;
-
- /**
- * Usually contains value of 2.
- */
- private final long flags;
-
- /**
- * Maximum size of stream packages. <br>
- * <b>Warning: </b> must be same size as {@link #minPackageSize}. Its not
- * known how to handle deviating values.
- */
- private final long maxPackageSize;
-
- /**
- * Minimun size of stream packages. <br>
- * <b>Warning: </b> must be same size as {@link #maxPackageSize}. Its not
- * known how to handle deviating values.
- */
- private final long minPackageSize;
-
- /**
- * Number of stream packages within the File.
- */
- private final BigInteger packageCount;
-
- /**
- * No Idea of the Meaning, but stored anyway. <br>
- * Source documentation says it is: "Timestamp of end position"
- */
- private final BigInteger timeEndPos;
-
- /**
- * Like {@link #timeEndPos}no Idea.
- */
- private final BigInteger timeStartPos;
-
- /**
- * Size of an uncompressed video frame.
- */
- private final long uncompressedFrameSize;
-
- /**
- * Creates an instance.
- *
- * @param fileHeaderStart
- * Position in file or stream, where the file header starts.
- * @param chunckLen
- * Length of the file header (chunk)
- * @param size
- * Size of file or stream
- * @param fileTime
- * Time file or stream was created. Time is calculated since 1st
- * january of 1601 in 100ns steps.
- * @param pkgCount
- * Number of stream packages.
- * @param dur
- * Duration of media clip in 100ns steps
- * @param timestampStart
- * Timestamp of start {@link #timeStartPos}
- * @param timestampEnd
- * Timestamp of end {@link #timeEndPos}
- * @param headerFlags
- * some stream related flags.
- * @param minPkgSize
- * minimun size of packages
- * @param maxPkgSize
- * maximum size of packages
- * @param uncmpVideoFrameSize
- * Size of an uncompressed Video Frame.
- */
- public FileHeader(long fileHeaderStart, BigInteger chunckLen,
- BigInteger size, BigInteger fileTime, BigInteger pkgCount,
- BigInteger dur, BigInteger timestampStart, BigInteger timestampEnd,
- long headerFlags, long minPkgSize, long maxPkgSize,
- long uncmpVideoFrameSize) {
- super(GUID.GUID_FILE, fileHeaderStart, chunckLen);
- this.fileSize = size;
- this.packageCount = pkgCount;
- this.duration = dur;
- this.timeStartPos = timestampStart;
- this.timeEndPos = timestampEnd;
- this.flags = headerFlags;
- this.minPackageSize = minPkgSize;
- this.maxPackageSize = maxPkgSize;
- this.uncompressedFrameSize = uncmpVideoFrameSize;
- this.fileCreationTime = Utils.getDateOf(fileTime).getTime();
- }
-
- /**
- * @return Returns the duration.
- */
- public BigInteger getDuration() {
- return duration;
- }
-
- /**
- * This method converts {@link #getDuration()}from 100ns steps to normal
- * seconds.
- *
- * @return Duration of the media in seconds.
- */
- public int getDurationInSeconds() {
- return duration.divide(new BigInteger("10000000")).intValue();
- }
-
- /**
- * @return Returns the fileCreationTime.
- */
- public Date getFileCreationTime() {
- return fileCreationTime;
- }
-
- /**
- * @return Returns the fileSize.
- */
- public BigInteger getFileSize() {
- return fileSize;
- }
-
- /**
- * @return Returns the flags.
- */
- public long getFlags() {
- return flags;
- }
-
- /**
- * @return Returns the maxPackageSize.
- */
- public long getMaxPackageSize() {
- return maxPackageSize;
- }
-
- /**
- * @return Returns the minPackageSize.
- */
- public long getMinPackageSize() {
- return minPackageSize;
- }
-
- /**
- * @return Returns the packageCount.
- */
- public BigInteger getPackageCount() {
- return packageCount;
- }
-
- /**
- * @return Returns the timeEndPos.
- */
- public BigInteger getTimeEndPos() {
- return timeEndPos;
- }
-
- /**
- * @return Returns the timeStartPos.
- */
- public BigInteger getTimeStartPos() {
- return timeStartPos;
- }
-
- /**
- * @return Returns the uncompressedFrameSize.
- */
- public long getUncompressedFrameSize() {
- return uncompressedFrameSize;
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.asf.data.Chunk#prettyPrint()
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint());
- result.insert(0, "\nFileHeader\n");
- result.append(" Filesize = " + getFileSize().toString()
- + " Bytes \n");
- result.append(" Media duration= "
- + getDuration().divide(new BigInteger("10000")).toString()
- + " ms \n");
- result.append(" Created at = " + getFileCreationTime() + "\n");
- return result.toString();
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/GUID.java b/songdbj/entagged/audioformats/asf/data/GUID.java
deleted file mode 100644
index 47c0394cd8..0000000000
--- a/songdbj/entagged/audioformats/asf/data/GUID.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.util.Arrays;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class is used for representation of GUIDs and as a reference list of all
- * Known GUIDs. <br>
- *
- * @author Christian Laireiter
- */
-public class GUID {
-
- /**
- * This constant defines the GUID for stream chunks describing audio
- * streams, indicating the the audio stream has no error concealment. <br>
- */
- public final static GUID GUID_AUDIO_ERROR_CONCEALEMENT_ABSENT = new GUID(
- new int[] { 0x40, 0xA4, 0xF1, 0x49, 0xCE, 0x4E, 0xD0, 0x11, 0xA3,
- 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 },
- "Audio error concealment absent.");
-
- /**
- * This constant defines the GUID for stream chunks describing audio
- * streams, indicating the the audio stream has interleaved error
- * concealment. <br>
- */
- public final static GUID GUID_AUDIO_ERROR_CONCEALEMENT_INTERLEAVED = new GUID(
- new int[] { 0x40, 0xA4, 0xF1, 0x49, 0xCE, 0x4E, 0xD0, 0x11, 0xA3,
- 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 },
- "Interleaved audio error concealment.");
-
- /**
- * This constant stores the GUID indicating that stream type is audio.
- */
- public final static GUID GUID_AUDIOSTREAM = new GUID(new int[] { 0x40,
- 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80,
- 0x5F, 0x5C, 0x44, 0x2B }, " Audio stream");
-
- /**
- * This constant represents the guid for a chunk which contains Title,
- * author, copyright, description and rating.
- */
- public final static GUID GUID_CONTENTDESCRIPTION = new GUID(new int[] {
- 0x33, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9, 0x00,
- 0xAA, 0x00, 0x62, 0xCE, 0x6C }, "Content Description");
-
- /**
- * This constant stores the GUID for Encoding-Info chunks.
- */
- public final static GUID GUID_ENCODING = new GUID(new int[] { 0x40, 0x52,
- 0xD1, 0x86, 0x1D, 0x31, 0xD0, 0x11, 0xA3, 0xA4, 0x00, 0xA0, 0xC9,
- 0x03, 0x48, 0xF6 }, "Encoding description");
-
- /**
- * This constant defines the GUID for a WMA "Extended Content Description"
- * chunk. <br>
- */
- public final static GUID GUID_EXTENDED_CONTENT_DESCRIPTION = new GUID(
- new int[] { 0x40, 0xA4, 0xD0, 0xD2, 0x07, 0xE3, 0xD2, 0x11, 0x97,
- 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50 },
- "Extended Content Description");
-
- /**
- * GUID of ASF file header.
- */
- public final static GUID GUID_FILE = new GUID(new int[] { 0xA1, 0xDC, 0xAB,
- 0x8C, 0x47, 0xA9, 0xCF, 0x11, 0x8E, 0xE4, 0x00, 0xC0, 0x0C, 0x20,
- 0x53, 0x65 }, "File header");
-
- /**
- * This constant defines the GUID of a asf header chunk.
- */
- public final static GUID GUID_HEADER = new GUID(new int[] { 0x30, 0x26,
- 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00,
- 0x62, 0xce, 0x6c }, "Asf header");
-
- /**
- * This constant stores the length of GUIDs used with ASF streams. <br>
- */
- public final static int GUID_LENGTH = 16;
-
- /**
- * This constant stores the GUID indicating a stream object.
- */
- public final static GUID GUID_STREAM = new GUID(new int[] { 0x91, 0x07,
- 0xDC, 0xB7, 0xB7, 0xA9, 0xCF, 0x11, 0x8E, 0xE6, 0x00, 0xC0, 0x0C,
- 0x20, 0x53, 0x65 }, "Stream");
-
- /**
- * This constant stores a GUID whose functionality is unknown.
- */
- public final static GUID GUID_UNKNOWN_1 = new GUID(new int[] { 0xB5, 0x03,
- 0xBF, 0x5F, 0x2E, 0xA9, 0xCF, 0x11, 0x8E, 0xE3, 0x00, 0xC0, 0x0C,
- 0x20, 0x53, 0x65 }, "Unknown 1");
-
- /**
- * This constant stores a GUID whose functionality is unknown.
- */
- public final static GUID GUID_UNKNOWN_2 = new GUID(new int[] { 0xCE, 0x75,
- 0xF8, 0x7B, 0x8D, 0x46, 0xD1, 0x11, 0x8D, 0x82, 0x00, 0x60, 0x97,
- 0xC9, 0xA2, 0xB2 }, "Unknown 2");
-
- /**
- * This constant stores the GUID indicating that stream type is video.
- */
- public final static GUID GUID_VIDEOSTREAM = new GUID(new int[] { 0xC0,
- 0xEF, 0x19, 0xBC, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80,
- 0x5F, 0x5C, 0x44, 0x2B }, "Video stream");
-
- /**
- * This field stores all knwon GUIDs.
- */
- public final static GUID[] KNOWN_GUIDS = new GUID[] {
- GUID_AUDIO_ERROR_CONCEALEMENT_ABSENT,
- GUID_AUDIO_ERROR_CONCEALEMENT_INTERLEAVED, GUID_CONTENTDESCRIPTION,
- GUID_AUDIOSTREAM, GUID_ENCODING, GUID_FILE, GUID_HEADER,
- GUID_STREAM, GUID_EXTENDED_CONTENT_DESCRIPTION, GUID_VIDEOSTREAM,
- GUID_UNKNOWN_1, GUID_UNKNOWN_2 };
-
- /**
- * This method checks if the given <code>value</code> is matching the GUID
- * specification of ASF streams. <br>
- *
- * @param value
- * possible GUID.
- * @return <code>true</code> if <code>value</code> matches the
- * specification of a GUID.
- */
- public static boolean assertGUID(int[] value) {
- boolean result = false;
- if (value != null) {
- if (value.length == GUID.GUID_LENGTH) {
- result = true;
- }
- }
- return result;
- }
-
- /**
- * This method searches a GUID in {@link #KNOWN_GUIDS}which is equal to the
- * given <code>guid</code> and returns its description. <br>
- * This method is useful if a guid was read out of a file and no
- * identification has been done yet.
- *
- * @param guid
- * guid, which description is needed.
- * @return description of the guid if found. Else <code>null</code>
- */
- public static String getGuidDescription(GUID guid) {
- String result = null;
- if (guid == null) {
- throw new IllegalArgumentException("Argument must not be null.");
- }
- for (int i = 0; i < KNOWN_GUIDS.length; i++) {
- if (KNOWN_GUIDS[i].equals(guid)) {
- result = KNOWN_GUIDS[i].getDescription();
- }
- }
- return result;
- }
-
- /**
- * Stores an optionally description of the GUID.
- */
- private String description = "";
-
- /**
- * An isntance of this class stores the value of the wrapped GUID in this
- * field. <br>
- */
- private int[] guid = null;
-
- /**
- * Creates an empty instance.
- *
- */
- public GUID() {
- // Nothing to do
- }
-
- /**
- * Creates an instance and assigns given <code>guid</code>.<br>
- *
- * @param value
- * Guid, which should be assigned.
- */
- public GUID(int[] value) {
- setGUID(value);
- }
-
- /**
- * Creates an instance like {@link #GUID(int[])}and sets the optional
- * description. <br>
- *
- * @param value
- * Guid, which should be assigned.
- * @param desc
- * Description for the guid.
- */
- public GUID(int[] value, String desc) {
- this(value);
- if (desc == null) {
- throw new IllegalArgumentException("Argument must not be null.");
- }
- this.description = desc;
- }
-
- /**
- * This method compares two objects. If the given Object is a {@link GUID},
- * the stored GUID values are compared. <br>
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- boolean result = false;
- if (obj instanceof GUID) {
- GUID other = (GUID) obj;
- result = Arrays.equals(this.getGUID(), other.getGUID());
- } else {
- result = super.equals(obj);
- }
- return result;
- }
-
- /**
- * This method returns the guid as an array of bytes. <br>
- *
- * @see #getGUID()
- * @return The guid as a byte array.
- */
- public byte[] getBytes() {
- byte[] result = new byte[this.guid.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = (byte) (this.guid[i] & 0xFF);
- }
- return result;
- }
-
- /**
- * @return Returns the description.
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * This method returns the GUID of this object. <br>
- *
- * @return stored GUID.
- */
- public int[] getGUID() {
- int[] copy = new int[this.guid.length];
- System.arraycopy(this.guid, 0, copy, 0, this.guid.length);
- return copy;
- }
-
- /**
- * This method checks if the currently stored GUID ({@link #guid}) is
- * correctly filled. <br>
- *
- * @return <code>true</code> if it is.
- */
- public boolean isValid() {
- return assertGUID(getGUID());
- }
-
- /**
- * This method saves a copy of the given <code>value</code> as the
- * represented value of this object. <br>
- * The given value is checked with {@link #assertGUID(int[])}.<br>
- *
- * @param value
- * GUID to assign.
- */
- private void setGUID(int[] value) {
- if (assertGUID(value)) {
- this.guid = new int[GUID_LENGTH];
- System.arraycopy(value, 0, this.guid, 0, GUID_LENGTH);
- } else {
- throw new IllegalArgumentException(
- "The given guid doesn't match the GUID specification.");
- }
- }
-
- /**
- * This method gives a hex formatted representation of {@link #getGUID()}
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- if (getDescription().trim().length() > 0) {
- result.append("Description: " + getDescription()
- + Utils.LINE_SEPARATOR + " ");
- }
- for (int i = 0; i < guid.length; i++) {
- String tmp = Integer.toHexString(guid[i]);
- if (tmp.length() < 2)
- tmp = "0" + tmp;
- if (i > 0)
- result.append(", ");
- result.append("0x" + tmp);
- }
- return result.toString();
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/StreamChunk.java b/songdbj/entagged/audioformats/asf/data/StreamChunk.java
deleted file mode 100644
index 7aafa37c8a..0000000000
--- a/songdbj/entagged/audioformats/asf/data/StreamChunk.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class is the base for all handled stream contents. <br>
- * A Stream chunk delivers information about a audio or video stream. Because of
- * this the stream chunk identifies in one field what type of stream it is
- * describing and so other data is provided. However some information is common
- * to all stream chunks which are stored in this hierarchy of the class tree.
- *
- * @author Christian Laireiter
- */
-public class StreamChunk extends Chunk {
-
- /**
- * If <code>true</code>, the stream data is encrypted.
- */
- private boolean contentEncrypted;
-
- /**
- * This field stores the number of the current stream. <br>
- */
- private int streamNumber;
-
- /**
- * @see #typeSpecificDataSize
- */
- private long streamSpecificDataSize;
-
- /**
- * Something technical. <br>
- * Format time in 100-ns steps.
- */
- private long timeOffset;
-
- /**
- * Stores the size of type specific data structure within chunk.
- */
- private long typeSpecificDataSize;
-
- /**
- * Creates an instance
- *
- * @param pos
- * Position of chunk within file or stream.
- * @param chunkLen
- * length of chunk
- */
- public StreamChunk(long pos, BigInteger chunkLen) {
- super(GUID.GUID_AUDIOSTREAM, pos, chunkLen);
- }
-
- /**
- * @return Returns the streamNumber.
- */
- public int getStreamNumber() {
- return streamNumber;
- }
-
- /**
- * @return Returns the streamSpecificDataSize.
- */
- public long getStreamSpecificDataSize() {
- return streamSpecificDataSize;
- }
-
- /**
- * @return Returns the timeOffset.
- */
- public long getTimeOffset() {
- return timeOffset;
- }
-
- /**
- * @return Returns the typeSpecificDataSize.
- */
- public long getTypeSpecificDataSize() {
- return typeSpecificDataSize;
- }
-
- /**
- * @return Returns the contentEncrypted.
- */
- public boolean isContentEncrypted() {
- return contentEncrypted;
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.asf.data.Chunk#prettyPrint()
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint());
- result.insert(0, Utils.LINE_SEPARATOR + "Stream Data:"
- + Utils.LINE_SEPARATOR);
- result.append(" Stream number: " + getStreamNumber()
- + Utils.LINE_SEPARATOR);
- result.append(" Type specific data size : "
- + getTypeSpecificDataSize() + Utils.LINE_SEPARATOR);
- result.append(" Stream specific data size: "
- + getStreamSpecificDataSize() + Utils.LINE_SEPARATOR);
- result.append(" Time Offset : " + getTimeOffset()
- + Utils.LINE_SEPARATOR);
- result.append(" Content Encryption : " + isContentEncrypted()
- + Utils.LINE_SEPARATOR);
- return result.toString();
- }
-
- /**
- * @param cntEnc
- * The contentEncrypted to set.
- */
- public void setContentEncrypted(boolean cntEnc) {
- this.contentEncrypted = cntEnc;
- }
-
- /**
- * @param streamNum
- * The streamNumber to set.
- */
- public void setStreamNumber(int streamNum) {
- this.streamNumber = streamNum;
- }
-
- /**
- * @param strSpecDataSize
- * The streamSpecificDataSize to set.
- */
- public void setStreamSpecificDataSize(long strSpecDataSize) {
- this.streamSpecificDataSize = strSpecDataSize;
- }
-
- /**
- * @param timeOffs
- * sets the time offset
- */
- public void setTimeOffset(long timeOffs) {
- this.timeOffset = timeOffs;
- }
-
- /**
- * @param typeSpecDataSize
- * The typeSpecificDataSize to set.
- */
- public void setTypeSpecificDataSize(long typeSpecDataSize) {
- this.typeSpecificDataSize = typeSpecDataSize;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/VideoStreamChunk.java b/songdbj/entagged/audioformats/asf/data/VideoStreamChunk.java
deleted file mode 100644
index 2b2c0211cd..0000000000
--- a/songdbj/entagged/audioformats/asf/data/VideoStreamChunk.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data;
-
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.util.Utils;
-
-/**
- *
- *
- * @author Christian Laireiter
- */
-public class VideoStreamChunk extends StreamChunk {
-
- private long pictureHeight;
-
- /**
- * This field stores the width of the video stream.
- */
- private long pictureWidth;
-
- /**
- * Creates an instance.
- *
- * @param pos
- * Position of the current chunk in the asf file or stream.
- * @param chunkLen
- * Length of the entire chunk (including guid and size)
- */
- public VideoStreamChunk(long pos, BigInteger chunkLen) {
- super(pos, chunkLen);
- }
-
- /**
- * @return Returns the pictureHeight.
- */
- public long getPictureHeight() {
- return pictureHeight;
- }
-
- /**
- * @return Returns the pictureWidth.
- */
- public long getPictureWidth() {
- return pictureWidth;
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.asf.data.StreamChunk#prettyPrint()
- */
- public String prettyPrint() {
- StringBuffer result = new StringBuffer(super.prettyPrint().replaceAll(
- Utils.LINE_SEPARATOR, Utils.LINE_SEPARATOR + " "));
- result.insert(0, Utils.LINE_SEPARATOR + "VideoStream");
- result.append("Video info:" + Utils.LINE_SEPARATOR);
- result.append(" Width : " + getPictureWidth()
- + Utils.LINE_SEPARATOR);
- result.append(" Heigth : " + getPictureHeight()
- + Utils.LINE_SEPARATOR);
- return result.toString();
- }
-
- /**
- * @param picHeight
- */
- public void setPictureHeight(long picHeight) {
- this.pictureHeight = picHeight;
- }
-
- /**
- * @param picWidth
- */
- public void setPictureWidth(long picWidth) {
- this.pictureWidth = picWidth;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/data/wrapper/ContentDescriptorTagField.java b/songdbj/entagged/audioformats/asf/data/wrapper/ContentDescriptorTagField.java
deleted file mode 100644
index 454aeb899f..0000000000
--- a/songdbj/entagged/audioformats/asf/data/wrapper/ContentDescriptorTagField.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.data.wrapper;
-
-import java.io.UnsupportedEncodingException;
-
-import entagged.audioformats.asf.data.ContentDescriptor;
-import entagged.audioformats.generic.TagField;
-
-/**
- * This class encapsulates a
- * {@link entagged.audioformats.asf.data.ContentDescriptor}and provides access
- * to it. <br>
- * The content descriptor used for construction is copied.
- *
- * @author Christian Laireiter (liree)
- */
-public class ContentDescriptorTagField implements TagField {
-
- /**
- * This descriptor is wrapped.
- */
- private ContentDescriptor toWrap;
-
- /**
- * Creates an instance.
- *
- * @param source
- * The descriptor which should be represented as a
- * {@link TagField}.
- */
- public ContentDescriptorTagField(ContentDescriptor source) {
- this.toWrap = source.createCopy();
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#copyContent(entagged.audioformats.generic.TagField)
- */
- public void copyContent(TagField field) {
- throw new UnsupportedOperationException("Not implemented yet.");
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#getId()
- */
- public String getId() {
- return toWrap.getName();
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#getRawContent()
- */
- public byte[] getRawContent() throws UnsupportedEncodingException {
- return toWrap.getRawData();
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#isBinary()
- */
- public boolean isBinary() {
- return toWrap.getType() == ContentDescriptor.TYPE_BINARY;
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#isBinary(boolean)
- */
- public void isBinary(boolean b) {
- if (!b && isBinary()) {
- throw new UnsupportedOperationException("No conversion supported.");
- }
- toWrap.setBinaryValue(toWrap.getRawData());
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#isCommon()
- */
- public boolean isCommon() {
- return toWrap.isCommon();
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#isEmpty()
- */
- public boolean isEmpty() {
- return toWrap.isEmpty();
- }
-
- /**
- * (overridden)
- *
- * @see entagged.audioformats.generic.TagField#toString()
- */
- public String toString() {
- return toWrap.getString();
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/io/AsfHeaderReader.java b/songdbj/entagged/audioformats/asf/io/AsfHeaderReader.java
deleted file mode 100644
index 5e82fcbb0b..0000000000
--- a/songdbj/entagged/audioformats/asf/io/AsfHeaderReader.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.io;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import entagged.audioformats.asf.data.AsfHeader;
-import entagged.audioformats.asf.data.ContentDescription;
-import entagged.audioformats.asf.data.Chunk;
-import entagged.audioformats.asf.data.EncodingChunk;
-import entagged.audioformats.asf.data.FileHeader;
-import entagged.audioformats.asf.data.GUID;
-import entagged.audioformats.asf.data.ExtendedContentDescription;
-import entagged.audioformats.asf.data.StreamChunk;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This <i>class </i> reads an Asf header out of an inputstream an creates an
- * {@link entagged.audioformats.asf.data.AsfHeader}object if successfull. <br>
- * For now only ASF ver 1.0 is supported, till ver 2.0 seems not to be used
- * anywhere. <br>
- * Asf headers contains other chunks. As of this other readers of current
- * <b>package </b> are called from within.
- *
- * @author Christian Laireiter
- */
-public class AsfHeaderReader {
-
- /**
- * This method tries to extract an ASF-header out of the given stream. <br>
- * If no header could be extracted <code>null</code> is returned. <br>
- *
- * @param in
- * File which contains the ASF header.
- * @return AsfHeader-Wrapper, or <code>null</code> if no supported Asf
- * header was found.
- * @throws IOException
- * Read errors
- */
- public static AsfHeader readHeader(RandomAccessFile in) throws IOException {
- AsfHeaderReader reader = new AsfHeaderReader();
- return reader.parseData(in);
- }
-
- /**
- * Protected default constructor. <br>
- * At the time no special use.
- *
- */
- protected AsfHeaderReader() {
- // Nothing to do
- }
-
- /**
- * This Method implements the reading of the header block. <br>
- *
- * @param in
- * Stream which contains an Asf header.
- * @return <code>null</code> if no valid data found, else a Wrapper
- * containing all supported data.
- * @throws IOException
- * Read errors.
- */
- private AsfHeader parseData(RandomAccessFile in) throws IOException {
- AsfHeader result = null;
- long chunkStart = in.getFilePointer();
- GUID possibleGuid = Utils.readGUID(in);
-
- if (GUID.GUID_HEADER.equals(possibleGuid)) {
- // For Know the filepointer pointed to an ASF header chunk.
- BigInteger chunkLen = Utils.readBig64(in);
-
- long chunkCount = Utils.readUINT32(in);
- // They are of unknown use.
- in.skipBytes(2);
-
- /*
- * Now reading header of chuncks.
- */
- ArrayList chunks = new ArrayList();
- while (chunkLen.compareTo(BigInteger.valueOf(in.getFilePointer())) > 0) {
- Chunk chunk = ChunkHeaderReader.readChunckHeader(in);
- chunks.add(chunk);
- in.seek(chunk.getChunckEnd());
- }
-
- /*
- * Creating the resulting object because streamchunks will be added.
- */
- result = new AsfHeader(chunkStart, chunkLen, chunkCount);
- /*
- * Now we know all positions and guids of chunks which are contained
- * whithin asf header. Further we need to identify the type of those
- * chunks and parse the interesting ones.
- */
- FileHeader fileHeader = null;
- ExtendedContentDescription extendedDescription = null;
- EncodingChunk encodingChunk = null;
- StreamChunk streamChunk = null;
- ContentDescription contentDescription = null;
-
- Iterator iterator = chunks.iterator();
- while (iterator.hasNext()) {
- Chunk currentChunk = (Chunk) iterator.next();
- if (fileHeader == null
- && (fileHeader = FileHeaderReader
- .read(in, currentChunk)) != null) {
- continue;
- }
- if (extendedDescription == null
- && (extendedDescription = ExtContentDescReader.read(in,
- currentChunk)) != null) {
- continue;
- }
- if (encodingChunk == null
- && (encodingChunk = EncodingChunkReader.read(in,
- currentChunk)) != null) {
- continue;
- }
- if (streamChunk == null
- && (streamChunk = StreamChunkReader.read(in,
- currentChunk)) != null) {
- result.addStreamChunk(streamChunk);
- streamChunk = null;
- continue;
- }
- if (contentDescription == null
- && (contentDescription = ContentDescriptionReader.read(
- in, currentChunk)) != null) {
- continue;
- }
- /*
- * If none of the above statements executed the "continue", this
- * chunk couldn't be interpreted. Despite this the chunk is
- * remembered
- */
- result.addUnspecifiedChunk(currentChunk);
- }
- /*
- * Finally store the parsed chunks in the resulting ASFHeader
- * object.
- */
- result.setFileHeader(fileHeader);
- result.setEncodingChunk(encodingChunk);
- /*
- * Warning, extendedDescription and contentDescription maybe null
- * since they are optional fields.
- */
- result.setExtendedContentDescription(extendedDescription);
- result.setContentDescription(contentDescription);
- }
- return result;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/io/ChunkHeaderReader.java b/songdbj/entagged/audioformats/asf/io/ChunkHeaderReader.java
deleted file mode 100644
index 7d7c8d98a1..0000000000
--- a/songdbj/entagged/audioformats/asf/io/ChunkHeaderReader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.io;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.data.Chunk;
-import entagged.audioformats.asf.data.GUID;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * Default reader, Reads GUID and size out of an inputsream and creates a
- * {@link entagged.audioformats.asf.data.Chunk}object.
- *
- * @author Christian Laireiter
- */
-class ChunkHeaderReader {
-
- /**
- * Interprets current data as a header of a chunk.
- *
- * @param input
- * inputdata
- * @return Chunk.
- * @throws IOException
- * Access errors.
- */
- public static Chunk readChunckHeader(RandomAccessFile input)
- throws IOException {
- long pos = input.getFilePointer();
- GUID guid = Utils.readGUID(input);
- BigInteger chunkLength = Utils.readBig64(input);
- return new Chunk(guid, pos, chunkLength);
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/io/ContentDescriptionReader.java b/songdbj/entagged/audioformats/asf/io/ContentDescriptionReader.java
deleted file mode 100644
index a2b120f7d1..0000000000
--- a/songdbj/entagged/audioformats/asf/io/ContentDescriptionReader.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.io;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.data.ContentDescription;
-import entagged.audioformats.asf.data.Chunk;
-import entagged.audioformats.asf.data.GUID;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * Reads and interprets the data of a asf chunk containing title, author... <br>
- *
- * @see entagged.audioformats.asf.data.ContentDescription
- *
- * @author Christian Laireiter
- */
-public class ContentDescriptionReader {
-
- /**
- * Creates and fills a
- * {@link entagged.audioformats.asf.data.ContentDescription}from given
- * file. <br>
- *
- * @param raf
- * Input
- * @param candidate
- * Chunk which possibly is a file header.
- * @return FileHeader if filepointer of <code>raf</code> is at valid
- * fileheader.
- * @throws IOException
- * Read errors.
- */
- public static ContentDescription read(RandomAccessFile raf, Chunk candidate)
- throws IOException {
- if (raf == null || candidate == null) {
- throw new IllegalArgumentException("Arguments must not be null.");
- }
- if (GUID.GUID_CONTENTDESCRIPTION.equals(candidate.getGuid())) {
- raf.seek(candidate.getPosition());
- return new ContentDescriptionReader().parseData(raf);
- }
- return null;
- }
-
- /**
- * This method reads a UTF-16 encoded String. <br>
- * For the use this method the number of bytes used by current string must
- * be known. <br>
- * The ASF spec recommends that those strings end with a terminating zero.
- * However it also says that it is not always the case.
- *
- * @param raf
- * Input source
- * @param strLen
- * Number of bytes the String may take.
- * @return read String.
- * @throws IOException
- * read errors.
- */
- public static String readFixedSizeUTF16Str(RandomAccessFile raf, int strLen)
- throws IOException {
- byte[] strBytes = new byte[strLen];
- int read = raf.read(strBytes);
- if (read == strBytes.length) {
- if (strBytes.length >= 2) {
- /*
- * Zero termination is recommended but optional.
- * So check and if, remove.
- */
- if (strBytes[strBytes.length-1] == 0 && strBytes[strBytes.length-2] == 0) {
- byte[] copy = new byte[strBytes.length-2];
- System.arraycopy(strBytes, 0, copy, 0, strBytes.length-2);
- strBytes = copy;
- }
- }
- return new String(strBytes, "UTF-16LE");
- }
- throw new IllegalStateException(
- "Couldn't read the necessary amount of bytes.");
- }
-
- /**
- * Should not be used for now.
- *
- */
- protected ContentDescriptionReader() {
- // NOTHING toDo
- }
-
- /**
- * Directly behind the GUID and chunkSize of the current chunck comes 5
- * sizes (16-bit) of string lengths. <br>
- *
- * @param raf
- * input source
- * @return Number and length of Strings, which are directly behind
- * filepointer if method exits.
- * @throws IOException
- * read errors.
- */
- private int[] getStringSizes(RandomAccessFile raf) throws IOException {
- int[] result = new int[5];
- for (int i = 0; i < result.length; i++) {
- result[i] = Utils.readUINT16(raf);
- }
- return result;
- }
-
- /**
- * Does the job of {@link #read(RandomAccessFile, Chunk)}
- *
- * @param raf
- * input source
- * @return Contentdescription
- * @throws IOException
- * read errors.
- */
- private ContentDescription parseData(RandomAccessFile raf)
- throws IOException {
- ContentDescription result = null;
- long chunkStart = raf.getFilePointer();
- GUID guid = Utils.readGUID(raf);
- if (GUID.GUID_CONTENTDESCRIPTION.equals(guid)) {
- BigInteger chunkLen = Utils.readBig64(raf);
- result = new ContentDescription(chunkStart, chunkLen);
- /*
- * Now comes 16-Bit values representing the length of the Strings
- * which follows.
- */
- int[] stringSizes = getStringSizes(raf);
- /*
- * Now we know the String length of each occuring String.
- */
- String[] strings = new String[stringSizes.length];
- for (int i = 0; i < strings.length; i++) {
- if (stringSizes[i] > 0)
- strings[i] = readFixedSizeUTF16Str(raf, stringSizes[i]);
- }
- if (stringSizes[0] > 0)
- result.setTitle(strings[0]);
- if (stringSizes[1] > 0)
- result.setAuthor(strings[1]);
- if (stringSizes[2] > 0)
- result.setCopyRight(strings[2]);
- if (stringSizes[3] > 0)
- result.setComment(strings[3]);
- if (stringSizes[4] > 0)
- result.setRating(strings[4]);
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/io/EncodingChunkReader.java b/songdbj/entagged/audioformats/asf/io/EncodingChunkReader.java
deleted file mode 100644
index 41ee9a49db..0000000000
--- a/songdbj/entagged/audioformats/asf/io/EncodingChunkReader.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.io;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.data.Chunk;
-import entagged.audioformats.asf.data.EncodingChunk;
-import entagged.audioformats.asf.data.GUID;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * This class reads the chunk containing encoding data <br>
- * <b>Warning:<b><br>
- * Implementation is not completed. More analysis of this chunk is needed.
- *
- * @author Christian Laireiter
- */
-public class EncodingChunkReader {
-
- /**
- * This reads the current data and interprets it as an encoding chunk. <br>
- * <b>Warning:<b><br>
- * Implementation is not completed. More analysis of this chunk is needed.
- *
- * @param raf
- * Input source
- * @param candidate
- * Chunk which possibly contains encoding data.
- * @return Encoding info. <code>null</code> if its not a valid encoding
- * chunk. <br>
- * @throws IOException
- * read errors.
- */
- public static EncodingChunk read(RandomAccessFile raf, Chunk candidate)
- throws IOException {
- if (raf == null || candidate == null) {
- throw new IllegalArgumentException("Arguments must not be null.");
- }
- if (GUID.GUID_ENCODING.equals(candidate.getGuid())) {
- raf.seek(candidate.getPosition());
- return new EncodingChunkReader().parseData(raf);
- }
- return null;
- }
-
- /**
- * Should not be used for now.
- *
- */
- protected EncodingChunkReader() {
- // NOTHING toDo
- }
-
- /**
- * see {@link #read(RandomAccessFile, Chunk)}
- *
- * @param raf
- * input source.
- * @return Enconding info. <code>null</code> if its not a valid encoding
- * chunk. <br>
- * @throws IOException
- * read errors.
- */
- private EncodingChunk parseData(RandomAccessFile raf) throws IOException {
- EncodingChunk result = null;
- long chunkStart = raf.getFilePointer();
- GUID guid = Utils.readGUID(raf);
- if (GUID.GUID_ENCODING.equals(guid)) {
- BigInteger chunkLen = Utils.readBig64(raf);
- result = new EncodingChunk(chunkStart, chunkLen);
-
- // Can't be interpreted
- /*
- * What do I think of this data, well it seems to be another GUID.
- * Then followed by a UINT16 indicating a length of data following
- * (by half). My test files just had the length of one and a two
- * bytes zero.
- */
- raf.skipBytes(20);
-
- /*
- * Read the number of strings which will follow
- */
- int stringCount = Utils.readUINT16(raf);
-
- /*
- * Now reading the specified amount of strings.
- */
- for (int i = 0; i < stringCount; i++) {
- result.addString(Utils.readCharacterSizedString(raf));
- }
- }
- return result;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/io/ExtContentDescReader.java b/songdbj/entagged/audioformats/asf/io/ExtContentDescReader.java
deleted file mode 100644
index 0bc57d0c9d..0000000000
--- a/songdbj/entagged/audioformats/asf/io/ExtContentDescReader.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.io;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.data.Chunk;
-import entagged.audioformats.asf.data.ContentDescriptor;
-import entagged.audioformats.asf.data.ExtendedContentDescription;
-import entagged.audioformats.asf.data.GUID;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * Class for reading Tag information out of the extended content description of
- * an asf file. <br>
- *
- * @see entagged.audioformats.asf.data.ExtendedContentDescription
- *
- * @author Christian Laireiter
- */
-public class ExtContentDescReader {
-
- /**
- * Reads the current chunk if it is a matching one.
- *
- * @param raf
- * Input source
- * @param candidate
- * Chunk which possibly contains additional tags
- * @return Wrapper for the extended content description
- * @throws IOException
- * Read errors
- */
- public static ExtendedContentDescription read(RandomAccessFile raf,
- Chunk candidate) throws IOException {
- if (raf == null || candidate == null) {
- throw new IllegalArgumentException("Arguments must not be null.");
- }
- if (GUID.GUID_EXTENDED_CONTENT_DESCRIPTION.equals(candidate.getGuid())) {
- raf.seek(candidate.getPosition());
- return new ExtContentDescReader().parseData(raf);
- }
- return null;
- }
-
- /**
- * Should not be used for now.
- *
- */
- protected ExtContentDescReader() {
- // NOTHING toDo
- }
-
- /**
- * Does the job of {@link #read(RandomAccessFile, Chunk)}
- *
- * @param raf
- * Input source
- * @return Wrapper for properties
- * @throws IOException
- * read errors.
- */
- private ExtendedContentDescription parseData(RandomAccessFile raf)
- throws IOException {
- ExtendedContentDescription result = null;
- long chunkStart = raf.getFilePointer();
- GUID guid = Utils.readGUID(raf);
-
- if (GUID.GUID_EXTENDED_CONTENT_DESCRIPTION.equals(guid)) {
- BigInteger chunkLen = Utils.readBig64(raf);
-
- // Reading Number of Tags.
- long descriptorCount = Utils.readUINT16(raf);
-
- // Create Result object
- result = new ExtendedContentDescription(chunkStart, chunkLen);
-
- for (long i = 0; i < descriptorCount; i++) {
- String tagElement = Utils.readUTF16LEStr(raf);
- int type = Utils.readUINT16(raf);
- ContentDescriptor prop = new ContentDescriptor(tagElement, type);
- switch (type) {
- case ContentDescriptor.TYPE_STRING:
- prop.setStringValue(Utils.readUTF16LEStr(raf));
- break;
- case ContentDescriptor.TYPE_BINARY:
- prop.setBinaryValue(readBinaryData(raf));
- break;
- case ContentDescriptor.TYPE_BOOLEAN:
- prop.setBooleanValue(readBoolean(raf));
- break;
- case ContentDescriptor.TYPE_DWORD:
- raf.skipBytes(2);
- prop.setDWordValue(Utils.readUINT32(raf));
- break;
- case ContentDescriptor.TYPE_WORD:
- raf.skipBytes(2);
- prop.setWordValue(Utils.readUINT16(raf));
- break;
- case ContentDescriptor.TYPE_QWORD:
- raf.skipBytes(2);
- prop.setQWordValue(Utils.readUINT64(raf));
- break;
- default:
- // Unknown, hopefully the convention for the size of the
- // value
- // is given, so we could read it binary
- prop.setStringValue("Invalid datatype: "
- + new String(readBinaryData(raf)));
- }
- result.addDescriptor(prop);
- }
- }
- return result;
- }
-
- /**
- * This method read binary Data. <br>
- *
- * @param raf
- * input source.
- * @return the binary data
- * @throws IOException
- * read errors.
- */
- private byte[] readBinaryData(RandomAccessFile raf) throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- int size = Utils.readUINT16(raf);
- for (int i = 0; i < size; i++) {
- bos.write(raf.read());
- }
- return bos.toByteArray();
- }
-
- /**
- * This Method reads a boolean value out of the tag chunk. <br>
- * A boolean requires 6 bytes. This means we've got 3 16-Bit unsigned
- * numbers. The first number should always be 4 because the other 2 numbers
- * needs them. The second number seems to take the values 0 (for
- * <code>false</code>) and 1 (for <code>true</code>). The third one is
- * zero, maybe indication the end of the value. <br>
- *
- * @param raf
- * input source
- * @return boolean representation.
- * @throws IOException
- * read errors.
- */
- private boolean readBoolean(RandomAccessFile raf) throws IOException {
- int size = Utils.readUINT16(raf);
- if (size != 4)
- throw new IllegalStateException(
- "Boolean value do require 4 Bytes. (Size value is: " + size
- + ")");
- long value = Utils.readUINT32(raf);
- boolean result = value == 1;
- return result;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/io/FileHeaderReader.java b/songdbj/entagged/audioformats/asf/io/FileHeaderReader.java
deleted file mode 100644
index 92dcbe746b..0000000000
--- a/songdbj/entagged/audioformats/asf/io/FileHeaderReader.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.io;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.data.Chunk;
-import entagged.audioformats.asf.data.FileHeader;
-import entagged.audioformats.asf.data.GUID;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * Reads and interprets the data of the file header. <br>
- *
- * @author Christian Laireiter
- */
-public class FileHeaderReader {
-
- /**
- * Creates and fills a {@link FileHeader}from given file. <br>
- *
- * @param raf
- * Input
- * @param candidate
- * Chunk which possibly is a file header.
- * @return FileHeader if filepointer of <code>raf</code> is at valid
- * fileheader.
- * @throws IOException
- * Read errors.
- */
- public static FileHeader read(RandomAccessFile raf, Chunk candidate)
- throws IOException {
- if (raf == null || candidate == null) {
- throw new IllegalArgumentException("Arguments must not be null.");
- }
- if (GUID.GUID_FILE.equals(candidate.getGuid())) {
- raf.seek(candidate.getPosition());
- return new FileHeaderReader().parseData(raf);
- }
- return null;
- }
-
- /**
- * Should not be used for now.
- *
- */
- protected FileHeaderReader() {
- // NOTHING toDo
- }
-
- /**
- * Tries to extract an ASF file header object out of the given input.
- *
- * @param raf
- * @return <code>null</code> if no valid file header object.
- * @throws IOException
- */
- private FileHeader parseData(RandomAccessFile raf) throws IOException {
- FileHeader result = null;
- long fileHeaderStart = raf.getFilePointer();
- GUID guid = Utils.readGUID(raf);
- if (GUID.GUID_FILE.equals(guid)) {
- BigInteger chunckLen = Utils.readBig64(raf);
- // Skip client GUID.
- raf.skipBytes(16);
-
- BigInteger fileSize = Utils.readBig64(raf);
- if (fileSize.intValue() != raf.length()) {
- System.err
- .println("Filesize of file doesn't match len of Fileheader. ("
- + fileSize.toString() + ", file: "+raf.length()+")");
- }
- // fileTime in 100 ns since midnight of 1st january 1601 GMT
- BigInteger fileTime = Utils.readBig64(raf);
-
- BigInteger packageCount = Utils.readBig64(raf);
-
- BigInteger timeEndPos = Utils.readBig64(raf);
- BigInteger duration = Utils.readBig64(raf);
- BigInteger timeStartPos = Utils.readBig64(raf);
-
- long flags = Utils.readUINT32(raf);
-
- long minPkgSize = Utils.readUINT32(raf);
- long maxPkgSize = Utils.readUINT32(raf);
- long uncompressedFrameSize = Utils.readUINT32(raf);
-
- result = new FileHeader(fileHeaderStart, chunckLen, fileSize,
- fileTime, packageCount, duration, timeStartPos, timeEndPos,
- flags, minPkgSize, maxPkgSize, uncompressedFrameSize);
- }
- return result;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/io/StreamChunkReader.java b/songdbj/entagged/audioformats/asf/io/StreamChunkReader.java
deleted file mode 100644
index 97563ca320..0000000000
--- a/songdbj/entagged/audioformats/asf/io/StreamChunkReader.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.io;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.math.BigInteger;
-
-import entagged.audioformats.asf.data.AudioStreamChunk;
-import entagged.audioformats.asf.data.Chunk;
-import entagged.audioformats.asf.data.GUID;
-import entagged.audioformats.asf.data.StreamChunk;
-import entagged.audioformats.asf.data.VideoStreamChunk;
-import entagged.audioformats.asf.util.Utils;
-
-/**
- * Reads and interprets the data of the audio or video stream information chunk.
- * <br>
- *
- * @author Christian Laireiter
- */
-public class StreamChunkReader {
-
- /**
- * Shouldn't be used for now.
- *
- */
- protected StreamChunkReader() {
- // Nothin todo
- }
-
- /**
- * Reads audio and video stream information.
- *
- * @param raf
- * input source.
- * @param candidate
- * possible audio stream chunk
- * @return Audio Stream Information. <code>null</code> if its not an audio
- * stream object.
- * @throws IOException
- * read errors
- */
- public static StreamChunk read(RandomAccessFile raf, Chunk candidate)
- throws IOException {
- if (raf == null || candidate == null) {
- throw new IllegalArgumentException("Arguments must not be null.");
- }
- if (GUID.GUID_STREAM.equals(candidate.getGuid())) {
- raf.seek(candidate.getPosition());
- return new StreamChunkReader().parseData(raf);
- }
- return null;
- }
-
- /**
- * Reads audio and video stream information.
- *
- * @param raf
- * input source.
- * @return Audio Stream Information. <code>null</code> if its not an audio
- * stream object.
- * @throws IOException
- * read errors
- */
- private StreamChunk parseData(RandomAccessFile raf) throws IOException {
- StreamChunk result = null;
- long chunkStart = raf.getFilePointer();
- GUID guid = Utils.readGUID(raf);
- if (GUID.GUID_STREAM.equals(guid)) {
- BigInteger chunkLength = Utils.readBig64(raf);
- // Now comes GUID indicating whether stream content type is audio or
- // video
- GUID streamTypeGUID = Utils.readGUID(raf);
- if (GUID.GUID_AUDIOSTREAM.equals(streamTypeGUID)
- || GUID.GUID_VIDEOSTREAM.equals(streamTypeGUID)) {
-
- // A guid is indicating whether the stream is error
- // concealed
- GUID errorConcealment = Utils.readGUID(raf);
- /*
- * Read the Time Offset
- */
- long timeOffset = Utils.readUINT64(raf);
-
- long typeSpecificDataSize = Utils.readUINT32(raf);
- long streamSpecificDataSize = Utils.readUINT32(raf);
-
- /*
- * Read a bitfield. (Contains streamnumber, and whether
- * the stream content is encrypted.)
- */
- int mask = Utils.readUINT16(raf);
- int streamNumber = mask & 127;
- boolean contentEncrypted = (mask & (1 << 15)) != 0;
-
- /*
- * Skip a reserved field
- */
- raf.skipBytes(4);
-
- if (GUID.GUID_AUDIOSTREAM.equals(streamTypeGUID)) {
- /*
- * Reading audio specific information
- */
- AudioStreamChunk audioStreamChunk = new AudioStreamChunk(
- chunkStart, chunkLength);
- result = audioStreamChunk;
-
- /*
- * read WAVEFORMATEX and format extension.
- */
- long compressionFormat = Utils.readUINT16(raf);
- long channelCount = Utils.readUINT16(raf);
- long samplingRate = Utils.readUINT32(raf);
- long avgBytesPerSec = Utils.readUINT32(raf);
- long blockAlignment = Utils.readUINT16(raf);
- int bitsPerSample = Utils.readUINT16(raf);
- int codecSpecificDataSize = Utils.readUINT16(raf);
- byte[] codecSpecificData = new byte[codecSpecificDataSize];
- raf.readFully(codecSpecificData);
-
- audioStreamChunk.setCompressionFormat(compressionFormat);
- audioStreamChunk.setChannelCount(channelCount);
- audioStreamChunk.setSamplingRate(samplingRate);
- audioStreamChunk.setAverageBytesPerSec(avgBytesPerSec);
- audioStreamChunk.setErrorConcealment(errorConcealment);
- audioStreamChunk.setBlockAlignment(blockAlignment);
- audioStreamChunk.setBitsPerSample (bitsPerSample);
- audioStreamChunk.setCodecData (codecSpecificData);
- } else if (GUID.GUID_VIDEOSTREAM.equals(streamTypeGUID)) {
- /*
- * Reading video specific information
- */
- VideoStreamChunk videoStreamChunk = new VideoStreamChunk(
- chunkStart, chunkLength);
- result = videoStreamChunk;
-
- long pictureWidth = Utils.readUINT32(raf);
- long pictureHeight = Utils.readUINT32(raf);
-
- // Skipt unknown field
- raf.skipBytes(1);
-
- // long bitMapInfoHeaderSize = Utils.readUINT32(raf);
- // bitMapInfoHeaderEnd stores now the end of the
- // bitMapInfoHeader
- // long bitMapInfoHeaderEnd = raf.getFilePointer()
- // + bitMapInfoHeaderSize;
-
- videoStreamChunk.setPictureWidth(pictureWidth);
- videoStreamChunk.setPictureHeight(pictureHeight);
- }
-
- /*
- * Setting common values for audio and video
- */
- result.setStreamNumber(streamNumber);
- result.setStreamSpecificDataSize(streamSpecificDataSize);
- result.setTypeSpecificDataSize(typeSpecificDataSize);
- result.setTimeOffset(timeOffset);
- result.setContentEncrypted(contentEncrypted);
- }
- }
- return result;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/util/ChunkPositionComparator.java b/songdbj/entagged/audioformats/asf/util/ChunkPositionComparator.java
deleted file mode 100644
index 864b6cb432..0000000000
--- a/songdbj/entagged/audioformats/asf/util/ChunkPositionComparator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.util;
-
-import java.util.Comparator;
-
-import entagged.audioformats.asf.data.Chunk;
-
-/**
- * This class is needed for ordering all types of
- * {@link entagged.audioformats.asf.data.Chunk}s ascending by their Position.
- * <br>
- *
- * @author Christian Laireiter
- */
-public class ChunkPositionComparator implements Comparator {
-
- /**
- * (overridden)
- *
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(Object o1, Object o2) {
- int result = 0;
- if (o1 instanceof Chunk && o2 instanceof Chunk) {
- Chunk c1 = (Chunk) o1;
- Chunk c2 = (Chunk) o2;
- result = (int) (c1.getPosition() - c2.getPosition());
- }
- return result;
- }
-
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/util/TagConverter.java b/songdbj/entagged/audioformats/asf/util/TagConverter.java
deleted file mode 100644
index eb12d23586..0000000000
--- a/songdbj/entagged/audioformats/asf/util/TagConverter.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.util;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import entagged.audioformats.Tag;
-import entagged.audioformats.asf.data.AsfHeader;
-import entagged.audioformats.asf.data.ContentDescription;
-import entagged.audioformats.asf.data.ContentDescriptor;
-import entagged.audioformats.asf.data.ExtendedContentDescription;
-import entagged.audioformats.asf.data.wrapper.ContentDescriptorTagField;
-import entagged.audioformats.generic.GenericTag;
-import entagged.audioformats.generic.TagField;
-
-/**
- * This class provides functionality to convert
- * {@link entagged.audioformats.asf.data.AsfHeader}objects into
- * {@link entagged.audioformats.Tag}objects (More extract information and
- * create a {@link entagged.audioformats.generic.GenericTag}).<br>
- *
- *
- * @author Christian Laireiter (liree)
- */
-public class TagConverter {
-
- /**
- * This method assigns those tags of <code>tag</code> which are defined to
- * be common by entagged. <br>
- *
- * @param tag
- * The tag from which the values are gathered. <br>
- * Assigned values are: <br>
- * @see Tag#getAlbum() <br>
- * @see Tag#getTrack() <br>
- * @see Tag#getYear() <br>
- * @see Tag#getGenre() <br>
- * @param description
- * The extended content description which should recieve the
- * values. <br>
- * <b>Warning: </b> the common values will be replaced.
- */
- public static void assignCommonTagValues(Tag tag,
- ExtendedContentDescription description) {
- ContentDescriptor tmp = null;
- if (tag.getFirstAlbum() != null && tag.getFirstAlbum().length() > 0) {
- tmp = new ContentDescriptor(ContentDescriptor.ID_ALBUM,
- ContentDescriptor.TYPE_STRING);
- tmp.setStringValue(tag.getFirstAlbum());
- description.addOrReplace(tmp);
- } else {
- description.remove(ContentDescriptor.ID_ALBUM);
- }
- if (tag.getFirstTrack() != null && tag.getFirstTrack().length() > 0) {
- tmp = new ContentDescriptor(ContentDescriptor.ID_TRACKNUMBER,
- ContentDescriptor.TYPE_STRING);
- tmp.setStringValue(tag.getFirstTrack());
- description.addOrReplace(tmp);
- } else {
- description.remove(ContentDescriptor.ID_TRACKNUMBER);
- }
- if (tag.getFirstYear() != null && tag.getFirstYear().length() > 0) {
- tmp = new ContentDescriptor(ContentDescriptor.ID_YEAR,
- ContentDescriptor.TYPE_STRING);
- tmp.setStringValue(tag.getFirstYear());
- description.addOrReplace(tmp);
- } else {
- description.remove(ContentDescriptor.ID_YEAR);
- }
- if (tag.getFirstGenre() != null && tag.getFirstGenre().length() > 0) {
- tmp = new ContentDescriptor(ContentDescriptor.ID_GENRE,
- ContentDescriptor.TYPE_STRING);
- tmp.setStringValue(tag.getFirstGenre());
- description.addOrReplace(tmp);
- int index = Arrays.asList(Tag.DEFAULT_GENRES).indexOf(
- tag.getFirstGenre());
- if (index != -1) {
- tmp = new ContentDescriptor(ContentDescriptor.ID_GENREID,
- ContentDescriptor.TYPE_STRING);
- tmp.setStringValue("(" + index + ")");
- description.addOrReplace(tmp);
- } else {
- description.remove(ContentDescriptor.ID_GENREID);
- }
- } else {
- description.remove(ContentDescriptor.ID_GENRE);
- description.remove(ContentDescriptor.ID_GENREID);
- }
- }
-
- /**
- * This method will add or replace all values of tag are not defined as
- * common by entagged.
- *
- * @param tag
- * The tag containing the values.
- * @param descriptor
- * the extended content description.
- */
- public static void assignOptionalTagValues(Tag tag,
- ExtendedContentDescription descriptor) {
- Iterator it = tag.getFields();
- ContentDescriptor tmp = null;
- while (it.hasNext()) {
- try {
- TagField currentField = (TagField) it.next();
- if (!currentField.isCommon()) {
- tmp = new ContentDescriptor(currentField.getId(),
- ContentDescriptor.TYPE_STRING);
- if (currentField.isBinary()) {
- tmp.setBinaryValue(currentField.getRawContent());
- } else {
- tmp.setStringValue(currentField.toString());
- }
- descriptor.addOrReplace(tmp);
- }
- } catch (UnsupportedEncodingException uee) {
- uee.printStackTrace();
- }
- }
- }
-
- /**
- * This method creates a new {@link ContentDescription}object, filled with
- * the according values of the given <code>tag</code>.<br>
- * <b>Warning </b>: <br>
- * Only the first values can be stored in asf files, because the content
- * description is limited.
- *
- * @param tag
- * The tag from which the values are taken. <br>
- * @see Tag#getFirstArtist() <br>
- * @see Tag#getFirstTitle() <br>
- * @see Tag#getFirstComment() <br>
- *
- * @return A new content description object filled with <code>tag</code>.
- */
- public static ContentDescription createContentDescription(Tag tag) {
- ContentDescription result = new ContentDescription();
- result.setAuthor(tag.getFirstArtist());
- result.setTitle(tag.getFirstTitle());
- result.setComment(tag.getFirstComment());
- return result;
- }
-
- /**
- * This method creates a new {@link ExtendedContentDescription}object
- * filled with the values of the given <code>tag</code>.<br>
- * Since extended content description of asf files can store name-value
- * pairs, nearly each {@link entagged.audioformats.generic.TagField}can be
- * stored whithin. <br>
- * One constraint is that the strings must be convertable to "UTF-16LE"
- * encoding and don't exceed a length of 65533 in binary representation.
- * <br>
- *
- * @param tag
- * The tag whose values the result will be filled with.
- * @return A new extended content description object.
- */
- public static ExtendedContentDescription createExtendedContentDescription(
- Tag tag) {
- ExtendedContentDescription result = new ExtendedContentDescription();
- assignCommonTagValues(tag, result);
- return result;
- }
-
- /**
- * This method creates a {@link Tag}and fills it with the contents of the
- * given {@link AsfHeader}.<br>
- *
- * @param source
- * The asf header which contains the information. <br>
- * @return A Tag with all its values.
- */
- public static Tag createTagOf(AsfHeader source) {
- GenericTag result = new GenericTag();
- /*
- * It is possible that the file contains no content description, since
- * that some informations aren't available.
- */
- if (source.getContentDescription() != null) {
- result.setArtist(source.getContentDescription().getAuthor());
- result.setComment(source.getContentDescription().getComment());
- result.setTitle(source.getContentDescription().getTitle());
- }
- /*
- * It is possible that the file contains no extended content
- * description. In that case some informations cannot be provided.
- */
- if (source.getExtendedContentDescription() != null) {
- result.setTrack(source.getExtendedContentDescription().getTrack());
- result.setYear(source.getExtendedContentDescription().getYear());
- result.setGenre(source.getExtendedContentDescription().getGenre());
- result.setAlbum(source.getExtendedContentDescription().getAlbum());
-
- /*
- * Now any properties, which don't belong to the common section of
- * entagged.
- */
- ExtendedContentDescription extDesc = source
- .getExtendedContentDescription();
- Iterator it = extDesc.getDescriptors().iterator();
- while (it.hasNext()) {
- ContentDescriptor current = (ContentDescriptor) it.next();
- // If common, it has been added to the result some lines upward.
- if (!current.isCommon()) {
- result.add(new ContentDescriptorTagField(current));
- }
- }
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/asf/util/Utils.java b/songdbj/entagged/audioformats/asf/util/Utils.java
deleted file mode 100644
index bafe82ea6f..0000000000
--- a/songdbj/entagged/audioformats/asf/util/Utils.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.asf.util;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.io.UnsupportedEncodingException;
-import java.math.BigInteger;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-import entagged.audioformats.asf.data.GUID;
-
-/**
- * Some static Methods which are used in several Classes. <br>
- *
- * @author Christian Laireiter
- */
-public class Utils {
-
- /**
- * Stores the default line seperator of the current underlying system.
- */
- public final static String LINE_SEPARATOR = System
- .getProperty("line.separator");
-
- /**
- * Reads chars out of <code>raf</code> until <code>chars</code> is
- * filled.
- *
- * @param chars
- * to be filled
- * @param raf
- * to be read
- * @throws IOException
- * read error, or file at end before <code>chars</code> is
- * filled.
- */
- public static void fillChars(char[] chars, RandomAccessFile raf)
- throws IOException {
- if (chars == null) {
- throw new IllegalArgumentException("Argument must not be null.");
- }
- for (int i = 0; i < chars.length; i++) {
- chars[i] = raf.readChar();
- }
- }
-
- /**
- * This method will create a byte[] at the size of <code>byteCount</code>
- * and insert the bytes of <code>value</code> (starting from lowset byte)
- * into it. <br>
- * You can easily create a Word (16-bit), DWORD (32-bit), QWORD (64 bit) out
- * of the value, ignoring the original type of value, since java
- * automatically performs transformations. <br>
- * <b>Warning: </b> This method works with unsigned numbers only.
- *
- * @param value
- * The value to be written into the result.
- * @param byteCount
- * The number of bytes the array has got.
- * @return A byte[] with the size of <code>byteCount</code> containing the
- * lower byte values of <code>value</code>.
- */
- public static byte[] getBytes(long value, int byteCount) {
- byte[] result = new byte[byteCount];
- for (int i = 0; i < result.length; i++) {
- result[i] = (byte) (value & 0xFF);
- value >>>= 8;
- }
- return result;
- }
-
- /**
- * Since date values in asf files are given in 100 ns steps since first
- * january of 1601 a little conversion must be done. <br>
- * This method converts a date given in described manner to a calendar.
- *
- * @param fileTime
- * Time in 100ns since 1 jan 1601
- * @return Calendar holding the date representation.
- */
- public static GregorianCalendar getDateOf(BigInteger fileTime) {
- GregorianCalendar result = new GregorianCalendar(1601, 0, 1);
- // lose anything beyond milliseconds, because calendar can't handle
- // less value
- fileTime = fileTime.divide(new BigInteger("10000"));
- BigInteger maxInt = new BigInteger(String.valueOf(Integer.MAX_VALUE));
- while (fileTime.compareTo(maxInt) > 0) {
- result.add(Calendar.MILLISECOND, Integer.MAX_VALUE);
- fileTime = fileTime.subtract(maxInt);
- }
- result.add(Calendar.MILLISECOND, fileTime.intValue());
- return result;
- }
-
- /**
- * This method reads one byte from <code>raf</code> and creates an
- * unsigned value of it. <br>
- *
- * @param raf
- * The file to read from.
- * @return next 7 bits as number.
- * @throws IOException
- * read errors.
- */
- public static int read7Bit(RandomAccessFile raf) throws IOException {
- int result = raf.read();
- return result & 127;
- }
-
- /**
- * This method reads 8 bytes, interprets them as an unsigned number and
- * creates a {@link BigInteger}
- *
- * @param raf
- * Input source
- * @return 8 bytes unsigned number
- * @throws IOException
- * read errors.
- */
- public static BigInteger readBig64(RandomAccessFile raf) throws IOException {
- byte[] bytes = new byte[8];
- byte[] oa = new byte[8];
- raf.readFully(bytes);
- for (int i = 0; i < bytes.length; i++) {
- oa[7 - i] = bytes[i];
- }
- BigInteger result = new BigInteger(oa);
- return result;
- }
-
- /**
- * This method reads a UTF-16 String, which legth is given on the number of
- * characters it consits of. <br>
- * The filepointer of <code>raf</code> must be at the number of
- * characters. This number contains the terminating zero character (UINT16).
- *
- * @param raf
- * Input source
- * @return String
- * @throws IOException
- * read errors
- */
- public static String readCharacterSizedString(RandomAccessFile raf)
- throws IOException {
- StringBuffer result = new StringBuffer();
- int strLen = readUINT16(raf);
- int character = raf.read();
- character |= raf.read() << 8;
- do {
- if (character != 0) {
- result.append((char) character);
- character = raf.read();
- character |= raf.read() << 8;
- }
- } while (character != 0 || (result.length() + 1) > strLen);
- if (strLen != (result.length() + 1)) {
- throw new IllegalStateException(
- "Invalid Data for current interpretation");
- }
- return result.toString();
- }
-
- /**
- * This Method reads a GUID (which is a 16 byte long sequence) from the
- * given <code>raf</code> and creates a wrapper. <br>
- * <b>Warning </b>: <br>
- * There is no way of telling if a byte sequence is a guid or not. The next
- * 16 bytes will be interpreted as a guid, whether it is or not.
- *
- * @param raf
- * Input source.
- * @return A class wrapping the guid.
- * @throws IOException
- * happens when the file ends before guid could be extracted.
- */
- public static GUID readGUID(RandomAccessFile raf) throws IOException {
- if (raf == null) {
- throw new IllegalArgumentException("Argument must not be null");
- }
- int[] binaryGuid = new int[GUID.GUID_LENGTH];
- for (int i = 0; i < binaryGuid.length; i++) {
- binaryGuid[i] = raf.read();
- }
- return new GUID(binaryGuid);
- }
-
- /**
- * @see #readUINT64(RandomAccessFile)
- * @param raf
- * @return number
- * @throws IOException
- */
- public static int readUINT16(RandomAccessFile raf) throws IOException {
- int result = raf.read();
- result |= raf.read() << 8;
- return result;
- }
-
- /**
- * @see #readUINT64(RandomAccessFile)
- * @param raf
- * @return number
- * @throws IOException
- */
- public static long readUINT32(RandomAccessFile raf) throws IOException {
- long result = 0;
- for (int i = 0; i <= 24; i += 8)
- result |= raf.read() << i;
- return result;
- }
-
- /**
- * Reads long as little endian.
- *
- * @param raf
- * Data source
- * @return long value
- * @throws IOException
- * read error, or eof is reached before long is completed
- */
- public static long readUINT64(RandomAccessFile raf) throws IOException {
- long result = 0;
- for (int i = 0; i <= 56; i += 8)
- result |= raf.read() << i;
- return result;
- }
-
- /**
- * This method reads a UTF-16 encoded String, beginning with a 16-bit value
- * representing the number of bytes needed. The String is terminated with as
- * 16-bit ZERO. <br>
- *
- * @param raf
- * Input source
- * @return read String.
- * @throws IOException
- * read errors.
- */
- public static String readUTF16LEStr(RandomAccessFile raf)
- throws IOException {
- int strLen = readUINT16(raf);
- byte[] buf = new byte[strLen];
- int read = raf.read(buf);
- if (read == buf.length) {
- /*
- * Check on zero termination
- */
- if (buf.length >= 2) {
- if (buf[buf.length - 1] == 0 && buf[buf.length - 2] == 0) {
- byte[] copy = new byte[buf.length - 2];
- System.arraycopy(buf, 0, copy, 0, buf.length - 2);
- buf = copy;
- }
- }
- return new String(buf, "UTF-16LE");
- }
- throw new IllegalStateException(
- "Invalid Data for current interpretation");
- }
-
- /**
- * This method converts the given string into a byte[] in UTF-16LE encoding
- * and checks whether the length doesn't exceed 65535 bytes. <br>
- *
- * @param value
- * The string to check.
- * @throws IllegalArgumentException
- * If byte representation takes more than 65535 bytes.
- */
- public static void checkStringLengthNullSafe(String value)
- throws IllegalArgumentException {
- if (value != null) {
- try {
- byte[] tmp = value.getBytes("UTF-16LE");
- if (tmp.length > 65533) {
- throw new IllegalArgumentException(
- "\"UTF-16LE\" representation exceeds 65535 bytes."
- + " (Including zero term character)");
- }
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- }
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/exceptions/CannotReadException.java b/songdbj/entagged/audioformats/exceptions/CannotReadException.java
deleted file mode 100644
index 1dc19d4f8e..0000000000
--- a/songdbj/entagged/audioformats/exceptions/CannotReadException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.exceptions;
-
-public class CannotReadException extends Exception {
- private static final long serialVersionUID = 3258128055204460344L;
- public CannotReadException( String message ) {
- super( message );
- }
- public CannotReadException() {
- super();
- }
-}
-
diff --git a/songdbj/entagged/audioformats/exceptions/CannotWriteException.java b/songdbj/entagged/audioformats/exceptions/CannotWriteException.java
deleted file mode 100644
index b7b91d9a69..0000000000
--- a/songdbj/entagged/audioformats/exceptions/CannotWriteException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.exceptions;
-
-public class CannotWriteException extends Exception {
- private static final long serialVersionUID = 3256719572253095479L;
- public CannotWriteException( String message ) {
- super( message );
- }
- public CannotWriteException() {
- super();
- }
-}
-
diff --git a/songdbj/entagged/audioformats/generic/AbstractTag.java b/songdbj/entagged/audioformats/generic/AbstractTag.java
deleted file mode 100644
index 138a39ae62..0000000000
--- a/songdbj/entagged/audioformats/generic/AbstractTag.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.generic;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import entagged.audioformats.Tag;
-
-public abstract class AbstractTag implements Tag {
-
-
- protected HashMap fields = new HashMap();
- protected int commonNumber = 0;
-
- public List getTitle() {
- return get(getTitleId());
- }
- public List getAlbum() {
- return get(getAlbumId());
- }
- public List getArtist() {
- return get(getArtistId());
- }
- public List getGenre() {
- return get(getGenreId());
- }
- public List getTrack() {
- return get(getTrackId());
- }
- public List getYear() {
- return get(getYearId());
- }
- public List getComment() {
- return get(getCommentId());
- }
-
- public String getFirstTitle() {
- List l = get(getTitleId());
- return (l.size() != 0) ? ((TagTextField)l.get(0)).getContent() : "";
- }
- public String getFirstAlbum() {
- List l = get(getAlbumId());
- return (l.size() != 0) ? ((TagTextField)l.get(0)).getContent() : "";
- }
- public String getFirstArtist() {
- List l = get(getArtistId());
- return (l.size() != 0) ? ((TagTextField)l.get(0)).getContent() : "";
- }
- public String getFirstGenre() {
- List l = get(getGenreId());
- return (l.size() != 0) ? ((TagTextField)l.get(0)).getContent() : "";
- }
- public String getFirstTrack() {
- List l = get(getTrackId());
- return (l.size() != 0) ? ((TagTextField)l.get(0)).getContent() : "";
- }
- public String getFirstYear() {
- List l = get(getYearId());
- return (l.size() != 0) ? ((TagTextField)l.get(0)).getContent() : "";
- }
- public String getFirstComment() {
- List l = get(getCommentId());
- return (l.size() != 0) ? ((TagTextField)l.get(0)).getContent() : "";
- }
-
-
- public void setTitle(String s) {
- set(createTitleField(s));
- }
- public void setAlbum(String s) {
- set(createAlbumField(s));
- }
- public void setArtist(String s) {
- set(createArtistField(s));
- }
- public void setGenre(String s) {
- set(createGenreField(s));
- }
- public void setTrack(String s) {
- set(createTrackField(s));
- }
- public void setYear(String s) {
- set(createYearField(s));
- }
- public void setComment(String s) {
- set(createCommentField(s));
- }
-
-
- public void addTitle(String s) {
- add(createTitleField(s));
- }
- public void addAlbum(String s) {
- add(createAlbumField(s));
- }
- public void addArtist(String s) {
- add(createArtistField(s));
- }
- public void addGenre(String s) {
- add(createGenreField(s));
- }
- public void addTrack(String s) {
- add(createTrackField(s));
- }
- public void addYear(String s) {
- add(createYearField(s));
- }
- public void addComment(String s) {
- add(createCommentField(s));
- }
-
-
- public boolean hasField(String id) {
- return get(id).size() != 0;
- }
- public boolean isEmpty() {
- return fields.size() == 0;
- }
- public boolean hasCommonFields() {
- return commonNumber != 0;
- }
-
-
- public Iterator getFields() {
- final Iterator it = this.fields.entrySet().iterator();
- return new Iterator() {
- private Iterator fieldsIt;
-
- public boolean hasNext() {
- if(fieldsIt == null) {
- changeIt();
- }
- return it.hasNext() || (fieldsIt != null && fieldsIt.hasNext());
- }
-
- public Object next() {
- if(!fieldsIt.hasNext())
- changeIt();
-
- return fieldsIt.next();
- }
-
- private void changeIt() {
- if(!it.hasNext())
- return;
-
- List l = (List) ((Map.Entry)it.next()).getValue();
- fieldsIt = l.iterator();
- }
-
- public void remove() {
- /* We don't want to remove */
- }
- };
- }
-
-
- public List get(String id) {
- List list = (List) fields.get(id);
-
- if(list == null)
- return new ArrayList();
-
- return list;
- }
- public void set(TagField field){
- if(field == null)
- return;
-
- //If an empty field is passed, we delete all the previous ones
- if(field.isEmpty()) {
- Object removed = fields.remove(field.getId());
- if(removed != null && field.isCommon())
- commonNumber--;
- return;
- }
-
- //If there is already an existing field with same id
- //and both are TextFields, we update the first element
- List l = (List) fields.get(field.getId());
- if(l != null) {
- TagField f = (TagField) l.get(0);
- f.copyContent(field);
- return;
- }
-
- //Else we put the new field in the fields.
- l = new ArrayList();
- l.add(field);
- fields.put(field.getId(), l);
- if(field.isCommon())
- commonNumber++;
- }
- public void add(TagField field) {
- if(field == null || field.isEmpty())
- return;
-
- List list = (List) fields.get(field.getId());
-
- //There was no previous item
- if(list == null) {
- list = new ArrayList();
- list.add(field);
- fields.put(field.getId(), list);
- if(field.isCommon())
- commonNumber++;
- }
- else {
- //We append to existing list
- list.add(field);
- }
- }
-
- public String toString() {
- StringBuffer out = new StringBuffer();
- out.append("Tag content:\n");
- Iterator it = getFields();
- while(it.hasNext()) {
- TagField field = (TagField) it.next();
- out.append("\t");
- out.append(field.getId());
- out.append(" : ");
- out.append(field.toString());
- out.append("\n");
- }
- return out.toString().substring(0,out.length()-1);
- }
-
- public void merge(Tag tag) {
- //FIXME: Improve me, for the moment,
- //it overwrites this tag with other values
- //FIXME: TODO: an abstract method that merges particular things for each
- //format
- if( getTitle().size() == 0)
- setTitle(tag.getFirstTitle());
- if( getArtist().size() == 0 )
- setArtist(tag.getFirstArtist());
- if( getAlbum().size() == 0 )
- setAlbum(tag.getFirstAlbum());
- if( getYear().size() == 0 )
- setYear(tag.getFirstYear());
- if( getComment().size() == 0 )
- setComment(tag.getFirstComment());
- if( getTrack().size() == 0 )
- setTrack(tag.getFirstTrack());
- if( getGenre().size() == 0 )
- setGenre(tag.getFirstGenre());
- }
-
- /*public boolean setEncoding(String enc) {
- if(!isAllowedEncoding(enc)) {
- return false;
- }
-
- Iterator it = getFields();
- while(it.hasNext()) {
- TagField field = (TagField) it.next();
- if(field instanceof TagTextField) {
- ((TagTextField)field).setEncoding(enc);
- }
- }
-
- return true;
- }*/
- //--------------------------------
- protected abstract String getArtistId();
- protected abstract String getAlbumId();
- protected abstract String getTitleId();
- protected abstract String getTrackId();
- protected abstract String getYearId();
- protected abstract String getCommentId();
- protected abstract String getGenreId();
-
- protected abstract TagField createArtistField(String content);
- protected abstract TagField createAlbumField(String content);
- protected abstract TagField createTitleField(String content);
- protected abstract TagField createTrackField(String content);
- protected abstract TagField createYearField(String content);
- protected abstract TagField createCommentField(String content);
- protected abstract TagField createGenreField(String content);
-
- protected abstract boolean isAllowedEncoding(String enc);
- //---------------------------------------
-}
-
diff --git a/songdbj/entagged/audioformats/generic/AbstractTagCreator.java b/songdbj/entagged/audioformats/generic/AbstractTagCreator.java
deleted file mode 100644
index bdc8236c99..0000000000
--- a/songdbj/entagged/audioformats/generic/AbstractTagCreator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package entagged.audioformats.generic;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import entagged.audioformats.Tag;
-
-public abstract class AbstractTagCreator {
-
- public ByteBuffer convert(Tag tag) throws UnsupportedEncodingException {
- return convert(tag, 0);
- }
-
- public ByteBuffer convert(Tag tag, int padding) throws UnsupportedEncodingException {
- Tag compatibleTag = getCompatibleTag(tag);
-
- List fields = createFields(compatibleTag);
- int tagSize = computeTagLength(compatibleTag, fields);
-
- ByteBuffer buf = ByteBuffer.allocate( tagSize + padding );
- create(compatibleTag, buf, fields, tagSize, padding);
-
- buf.rewind();
- return buf;
- }
-
- protected List createFields(Tag tag) throws UnsupportedEncodingException {
- List fields = new LinkedList();
-
- Iterator it = tag.getFields();
- while(it.hasNext()) {
- TagField frame = (TagField) it.next();
- fields.add(frame.getRawContent());
- }
-
- return fields;
- }
-
- //Compute the number of bytes the tag will be.
- protected int computeTagLength(Tag tag, List l) throws UnsupportedEncodingException {
- int length = getFixedTagLength(tag);
-
- Iterator it = l.iterator();
- while(it.hasNext())
- length += ((byte[])it.next()).length;
-
- return length;
- }
-
- public int getTagLength(Tag tag) throws UnsupportedEncodingException {
- Tag compatibleTag = getCompatibleTag(tag);
- List fields = createFields(compatibleTag);
- return computeTagLength(compatibleTag, fields);
- }
-
- //This method is always called with a compatible tag, as returned from getCompatibleTag()
- protected abstract int getFixedTagLength(Tag tag) throws UnsupportedEncodingException;
-
- protected abstract Tag getCompatibleTag(Tag tag);
-
- //This method is always called with a compatible tag, as returned from getCompatibleTag()
- protected abstract void create(Tag tag, ByteBuffer buf, List fields, int tagSize, int padding) throws UnsupportedEncodingException;
-}
diff --git a/songdbj/entagged/audioformats/generic/AudioFileReader.java b/songdbj/entagged/audioformats/generic/AudioFileReader.java
deleted file mode 100644
index 5560f29d8b..0000000000
--- a/songdbj/entagged/audioformats/generic/AudioFileReader.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.generic;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-import entagged.audioformats.AudioFile;
-import entagged.audioformats.Tag;
-import entagged.audioformats.EncodingInfo;
-import entagged.audioformats.exceptions.CannotReadException;
-
-/*
- * This abstract class is the skeleton for tag readers. It handles the creation/closing of
- * the randomaccessfile objects and then call the subclass method getEncodingInfo and getTag.
- * These two method have to be implemented in te subclass.
- *
- *@author Raphael Slinckx
- *@version $Id$
- *@since v0.02
- */
-public abstract class AudioFileReader {
-
- /*
- * Returns the encoding info object associated wih the current File.
- * The subclass can assume the RAF pointer is at the first byte of the file.
- * The RandomAccessFile must be kept open after this function, but can point
- * at any offset in the file.
- *
- * @param raf The RandomAccessFile associtaed with the current file
- * @exception IOException is thrown when the RandomAccessFile operations throw it (you should never throw them manually)
- * @exception CannotReadException when an error occured during the parsing of the encoding infos
- */
- protected abstract EncodingInfo getEncodingInfo( RandomAccessFile raf ) throws CannotReadException, IOException;
-
- /*
- * Same as above but returns the Tag contained in the file, or a new one.
- *
- * @param raf The RandomAccessFile associted with the current file
- * @exception IOException is thrown when the RandomAccessFile operations throw it (you should never throw them manually)
- * @exception CannotReadException when an error occured during the parsing of the tag
- */
- protected abstract Tag getTag( RandomAccessFile raf ) throws CannotReadException, IOException;
-
- /*
- * Reads the given file, and return an AudioFile object containing the Tag
- * and the encoding infos present in the file. If the file has no tag, an
- * empty one is returned. If the encodinginfo is not valid , an error is thrown.
- *
- * @param f The file to read
- * @exception CannotReadException If anything went bad during the read of this file
- */
- public AudioFile read(File f) throws CannotReadException {
- if (!f.canRead())
- throw new CannotReadException("Can't read file \""+f.getAbsolutePath()+"\"");
-
- if(f.length() <= 150)
- throw new CannotReadException("Less than 150 byte \""+f.getAbsolutePath()+"\"");
-
- RandomAccessFile raf = null;
- try{
- raf = new RandomAccessFile( f, "r" );
- return read( f, raf );
- } catch ( Exception e ) {
- throw new CannotReadException("\""+f+"\" :"+e);
- }
- finally {
- try{
- if(raf != null)
- raf.close();
- }catch(Exception ex){
- System.err.println("\""+f+"\" :"+ex);
- }
- }
- }
-
- /*
- * Reads the given file, and return an AudioFile object containing the Tag
- * and the encoding infos present in the file. If the file has no tag, an
- * empty one is returned. If the encodinginfo is not valid , an error is thrown.
- *
- * @param f The RandomAccessFile to read
- * @exception CannotReadException If anything went bad during the read of this file
- */
- public AudioFile read(File f, RandomAccessFile raf) throws CannotReadException {
- try{
- raf.seek( 0 );
-
- EncodingInfo info = getEncodingInfo(raf);
-
- Tag tag;
- try {
- raf.seek( 0 );
- tag = getTag(raf);
- } catch (CannotReadException e) {
- System.err.println(e.getMessage());
- tag = new GenericTag();
- }
-
- return new AudioFile(f, info, tag);
-
- } catch ( Exception e ) {
- throw new CannotReadException("\""+f+"\" :"+e);
- }
- }
-}
diff --git a/songdbj/entagged/audioformats/generic/GenericTag.java b/songdbj/entagged/audioformats/generic/GenericTag.java
deleted file mode 100644
index fb2ff43f37..0000000000
--- a/songdbj/entagged/audioformats/generic/GenericTag.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package entagged.audioformats.generic;
-
-
-public class GenericTag extends AbstractTag {
- private final static String[] keys =
- {
- "ARTIST",
- "ALBUM",
- "TITLE",
- "TRACK",
- "YEAR",
- "GENRE",
- "COMMENT",
- };
-
- public static final int ARTIST = 0;
- public static final int ALBUM = 1;
- public static final int TITLE = 2;
- public static final int TRACK = 3;
- public static final int YEAR = 4;
- public static final int GENRE = 5;
- public static final int COMMENT = 6;
-
- protected String getArtistId() {
- return keys[ARTIST];
- }
- protected String getAlbumId() {
- return keys[ALBUM];
- }
- protected String getTitleId() {
- return keys[TITLE];
- }
- protected String getTrackId() {
- return keys[TRACK];
- }
- protected String getYearId() {
- return keys[YEAR];
- }
- protected String getCommentId() {
- return keys[COMMENT];
- }
- protected String getGenreId() {
- return keys[GENRE];
- }
-
- protected TagField createArtistField(String content) {
- return new GenericTagTextField(keys[ARTIST], content);
- }
- protected TagField createAlbumField(String content) {
- return new GenericTagTextField(keys[ALBUM], content);
- }
- protected TagField createTitleField(String content) {
- return new GenericTagTextField(keys[TITLE], content);
- }
- protected TagField createTrackField(String content) {
- return new GenericTagTextField(keys[TRACK], content);
- }
- protected TagField createYearField(String content) {
- return new GenericTagTextField(keys[YEAR], content);
- }
- protected TagField createCommentField(String content) {
- return new GenericTagTextField(keys[COMMENT], content);
- }
- protected TagField createGenreField(String content) {
- return new GenericTagTextField(keys[GENRE], content);
- }
-
- protected boolean isAllowedEncoding(String enc) {
- return true;
- }
-
- private class GenericTagTextField implements TagTextField {
-
- private String id;
- private String content;
-
- public GenericTagTextField(String id, String content) {
- this.id = id;
- this.content = content;
- }
-
- public String getContent() {
- return this.content;
- }
-
- public String getEncoding() {
- return "ISO-8859-1";
- }
-
- public void setContent(String s) {
- this.content = s;
- }
-
- public void setEncoding(String s) {
- /* Not allowed */
- }
-
- public String getId() {
- return id;
- }
-
- public byte[] getRawContent() {
- /* FIXME: What to do here ? not supported */
- return new byte[] {};
- }
-
- public boolean isBinary() {
- return false;
- }
-
- public void isBinary(boolean b) {
- /* not supported */
- }
-
- public boolean isCommon() {
- return true;
- }
-
- public boolean isEmpty() {
- return this.content.equals("");
- }
-
- public String toString() {
- return getId() + " : " + getContent();
- }
-
- public void copyContent(TagField field) {
- if(field instanceof TagTextField) {
- this.content = ((TagTextField)field).getContent();
- }
- }
- }
-}
diff --git a/songdbj/entagged/audioformats/generic/OldTag.java b/songdbj/entagged/audioformats/generic/OldTag.java
deleted file mode 100644
index a4f19cbbc9..0000000000
--- a/songdbj/entagged/audioformats/generic/OldTag.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.generic;
-
-import java.util.*;
-
-import entagged.audioformats.Tag;
-
-/**
- * <p>This class stores all the meta-data (artist, album, ..) contained in an AudioFile.</p>
- * <p>All the <code>set</code> operation are not "real-time", they only apply to this object. To commit the modification, either the <code>AudioFile</code>'s <code>commit()</code> or the <code>AudioFileIO.write(AudioFile)</code> have to be called</p>
- * <p>There are two types of fields contained in a <code>Tag</code>. The most commonly used (the <em>common fields</em>) are accessible through get/set methods, like the artist, tha album, the track number, etc.</p>
- * <p>Each tag format has then <em>specific fields</em> (eg. graphics, urls, etc) that do not exist in the other formats, or that cannot be mapped to <em>common fields</em></p>
- * <p>To retreive the content of these <em>specific fields</em>, the <code>getSpecificields()</code> can be called giving the names of the <em>specific fields</em> stored in this tag</p>
- * <p>This ensures that all the old meta-data contained in a tag read from <code>AudioFileIO</code> is kept and rewritten when the tag is updated</p>
- *
- *@author Raphael Slinckx
- *@version $Id$
- *@since v0.01
- *@see AudioFile
- */
-public class OldTag {
- /**
- * This final field contains all the tags that id3v1 supports. The list has
- * the same order as the id3v1 genres. To be perfectly compatible (with id3v1)
- * the genre field should match one of these genre (case ignored). You can also use
- * this list to present a list of basic (modifiable) possible choices for the genre field.
- */
- public static final String[] DEFAULT_GENRES = {"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz",
- "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative",
- "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion",
- "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock",
- "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic",
- "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy",
- "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave",
- "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro",
- "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival",
- "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock",
- "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata",
- "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad",
- "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall"};
-
-
- //Contains all the fields found in a tag
- protected Hashtable fields;
-
- /**
- * <p>Creates a new empty tag, all the common fields are initialized to the empty string, and no specific fields exists.</p>
- */
- public OldTag() {
- fields = new Hashtable();
- fields.put("TITLE" ,"");
- fields.put("ALBUM" ,"");
- fields.put("ARTIST" ,"");
- fields.put("GENRE" ,"");
- fields.put("TRACK" ,"");
- fields.put("YEAR" ,"");
- fields.put("COMMENT","");
- }
-
- /**
- * <p>Returns the title of this song, eg: "Stairway to Heaven".</p>
- * <p>If there wasn't such a field in the AudioFile, an empty String is returned</p>
- *
- *@return Returns the title of this song
- */
- public String getTitle() {
- return (String) fields.get("TITLE");
- }
-
- /**
- * <p>Returns the album of this song, eg: "Led Zeppelin IV".</p>
- * <p>If there wasn't such a field in the AudioFile, an empty String is returned</p>
- *
- *@return Returns the album of this song
- */
- public String getAlbum() {
- return (String) fields.get("ALBUM");
- }
-
- /**
- * <p>Returns the artist of this song, eg: "Led Zeppelin".</p>
- * <p>If there wasn't such a field in the AudioFile, an empty String is returned</p>
- *
- *@return Returns the artist of this song
- */
- public String getArtist() {
- return (String) fields.get("ARTIST");
- }
-
- /**
- * <p>Returns the genre of this song, eg: "Classic Rock".</p>
- * <p>If there wasn't such a field in the AudioFile, an empty String is returned</p>
- *
- *@return Returns the genre of this song
- */
- public String getGenre() {
- return (String) fields.get("GENRE");
- }
-
- /**
- * <p>Returns the track number of this song.</p>
- * <p>The String can be anything, so don't expect a simple number, it could be "10" but also "10 / 15"</p>
- * <p>If there wasn't such a field in the AudioFile, an empty String is returned</p>
- *
- *@return Returns the track number of this song
- */
- public String getTrack() {
- return (String) fields.get("TRACK");
- }
-
- /**
- * <p>Returns the date of this song.</p>
- * <p>Most of the time the year of release of the album eg: "1970", but this can also be an arbitrary string like "19 december 1934"</p>
- * <p>If there wasn't such a field in the AudioFile, an empty String is returned</p>
- *
- *@return Returns the date of this song
- */
- public String getYear() {
- return (String) fields.get("YEAR");
- }
-
- /**
- * <p>Returns the comment associated with this song, eg: "Recorded live at the Royal Albert Hall".</p>
- * <p>Some tag format allow multi-line comments, line are separated with "\n" strings ("\\n" in java not "\n"). That means the String returned may have to be parsed to transform those strings in newline characters ("\n" in java)</p>
- * <p>If there wasn't such a field in the AudioFile, an empty String is returned</p>
- *
- *@return Returns the comment associated with this song
- *@todo Parse the returned string to replace \\n by \n for multiline comments
- */
- public String getComment() {
- return (String) fields.get("COMMENT");
- }
-
- /**
- * <p>Sets the title for this song, replacing the previous one.</p>
- * <p><code>s</code> can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if <code>s</code> is too long, it will be cut at the maximum length allowed by the tag format</p>
- * <p>If a null string is passed, it is converted to an empty String</p>
- *
- *@param s the new title of this song
- */
- public void setTitle(String s) {
- if(s == null)
- fields.put("TITLE","");
- else
- fields.put("TITLE",s);
- }
-
- /**
- * <p>Sets the new album for this song, replacing the previous one.</p>
- * <p><code>s</code> can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if <code>s</code> is too long, it will be cut at the maximum length allowed by the tag format</p>
- * <p>If a null string is passed, it is converted to an empty String</p>
- *
- *@param s the new album for this song
- */
- public void setAlbum(String s) {
- if(s == null)
- fields.put("ALBUM","");
- else
- fields.put("ALBUM",s);
- }
-
- /**
- * <p>Sets the new artist for this song, replacing the previous one.</p>
- * <p><code>s</code> can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if <code>s</code> is too long, it will be cut at the maximum length allowed by the tag format</p>
- * <p>If a null string is passed, it is converted to an empty String</p>
- *
- *@param s the new artist for this song
- */
- public void setArtist(String s) {
- if(s == null)
- fields.put("ARTIST","");
- else
- fields.put("ARTIST",s);
- }
-
- /**
- * <p>Sets the new genre for this song, replacing the previous one.</p>
- * <p>Some formats does not support an arbitrary string as genre and use a predefined list of genres, with an index. If this is the case, the given genre will be matched against a predefined list, if a correspondance is found, that index is used, if not, a "no genre" or equivalent will be used instead</p>
- * <p><code>s</code> can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if <code>s</code> is too long, it will be cut at the maximum length allowed by the tag format</p>
- * <p>If a null string is passed, it is converted to an empty String</p>
- *
- *@param s the new genre for this song
- */
- public void setGenre(String s) {
- if(s == null)
- fields.put("GENRE","");
- else
- fields.put("GENRE",s);
- }
-
- /**
- * <p>Sets the new track number for this song, replacing the previous one.</p>
- * <p>Some formats use a single byte track encoding, allowing tracks to be only a number from 0 to 255. If this is the case, and the track number is not a simple number (like "19/30"), the track number is set to 0</p>
- * <p><code>s</code> can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if <code>s</code> is too long, it will be cut at the maximum length allowed by the tag format</p>
- * <p>If a null string is passed, it is converted to an empty String</p>
- *
- *@param s the new track number for this song
- */
- public void setTrack(String s) {
- if(s == null)
- fields.put("TRACK","");
- else
- fields.put("TRACK",s);
- }
-
- /**
- * <p>Sets the new date for this song, replacing the previous one.</p>
- * <p><code>s</code> can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if <code>s</code> is too long, it will be cut at the maximum length allowed by the tag format</p>
- * <p>If a null string is passed, it is converted to an empty String</p>
- *
- *@param s the new date for this song
- */
- public void setYear(String s) {
- if(s == null)
- fields.put("YEAR","");
- else
- fields.put("YEAR",s);
- }
-
- /**
- * <p>Sets the new comment of this song, replacing the previous one.</p>
- * <p>Some tag allow multi-line formats, using the "\n" string ("\\n" in java) but not the newline character ("\n" in java)</p>
- * <p><code>s</code> can be an arbitrary string, but keep in mind that some tag formats have limited space to store informations, if <code>s</code> is too long, it will be cut at the maximum length allowed by the tag format</p>
- * <p>If a null string is passed, it is converted to an empty String</p>
- *
- *@param s the new comment for this song
- *@todo Parse the given string to replace \n by \\n for multiline comments
- */
- public void setComment(String s) {
- if(s == null)
- fields.put("COMMENT","");
- else
- fields.put("COMMENT",s);
- }
-
-
- /**
- * <p>This creates an iterator over the specific fields for this tag. Specific fields are tag-format specific fields (other than artist, album, etc).</p>
- * <p>If this tag was created by <code>new Tag()</code>, the iterator will be empty</p>
- * <p>To retreive the value associated to a specific field use the <code>getSpecificField(String)</code> method in this class</p>
- * <p>Example: an ogg file can contain an arbitrary number of arbitrary fields, so a field like MYCUSTOMFIELD cannot be mapped to artist, album, or other common field, it is instead stored as a specific field that can be retreived using this iterator</p>
- *@return an iterator over the specific fields of this tag
- */
- public Iterator getSpecificFields() {
- //Those fileds are created by subclasses of this class
- //And begin with a "-", the iterator contains the fields without the leading "-"
- List l = new LinkedList();
- Enumeration en = fields.keys();
- while(en.hasMoreElements()) {
- String key = (String) en.nextElement();
- if( key.startsWith("-") )
- l.add(key.substring(1));
- }
-
- return l.iterator();
- }
-
- /**
- * <p>Returns the specific field's content.</p>
- * <p>if <code>s</code> is not a valid specific field, the empty string is returned</p>
- * <p>Valid specific fields are returned by the iterator created by <code>getSpecificFields()</code> method</p>
- * <p>Note that some specific fields can have binary value (not a human readable string), the binary data can be obtained back using the <code>getBytes()</code> method on the String</p>
- *
- *@param s the specific field to retreive
- *@return the value associated to this specific field, or the empty string if the field wasn't valid
- *@todo binary strings ??
- */
- public String getSpecificField(String s) {
- //Return the value associated with a specific field
- //User must ensure that the field actually exists, otherwise an empty string will be returned !
- //The given field must not contain the leading "-", it is appended here !
- String content = (String) fields.get("-"+s);
- if(content == null)
- return "";
- return content;
- }
-
-
- /**
- * <p>Checks wether all the common fields (artist, genre, ..) are empty, that is: contains the empty string or only spaces.</p>
- * <p>Specific fields can exist even if this returns true, use the <code>isSpecificEmpty()</code> to check if the specific fields are also empty</p>
- *
- *@return a boolean indicating if the common fields of this tag are empty or not
- */
- public boolean isEmpty() {
- Enumeration en = fields.keys();
- while(en.hasMoreElements()) {
- String key = (String) en.nextElement();
- String val = (String) fields.get(key);
- if( !key.startsWith("-") && !val.trim().equals("") )
- return false;
- }
-
- return true;
- }
-
-
- /**
- * <p>Checks wether all the specific fields (other than artist, genre, ..) are empty, that is: contains the empty string or only spaces.</p>
- * <p>Common fields can exist even if this returns true, use the <code>isEmpty()</code> to check if the common fields are also empty</p>
- *
- *@return a boolean indicating if the specific fields of this tag are empty or not
- */
- public boolean isSpecificEmpty() {
- Enumeration en = fields.keys();
- while(en.hasMoreElements()) {
- String key = (String) en.nextElement();
- String val = (String) fields.get(key);
- if( key.startsWith("-") && !val.trim().equals("") )
- return false;
- }
-
- return true;
- }
-
- /*
- * Merge the content of the given tag with the content of this tag.
- * It keeps this tag fields, but if one field is empty, it looks for a
- * non-empty value in the given tag and place it's value in this tag.
- * Note that it only looks in the "common" fields (artist, album).
- *
- * @param tag The tag to use if one of this tag's field is empty.
- */
- /*public void merge(Tag tag) {
- if( getTitle().trim().equals("") )
- setTitle(tag.getTitle());
- if( getArtist().trim().equals("") )
- setArtist(tag.getArtist());
- if( getAlbum().trim().equals("") )
- setAlbum(tag.getAlbum());
- if( getYear().trim().equals("") )
- setYear(tag.getYear());
- if( getComment().trim().equals("") )
- setComment(tag.getComment());
- if( getTrack().trim().equals("") )
- setTrack(tag.getTrack());
- if( getGenre().trim().equals("") )
- setGenre(tag.getGenre());
- }*/
-
- /**
- * <p>Returns a multi-line string showing all the meta-data of this tag (the common fields, and any specific field).</p>
- * <p>Specific fields are denoted with a "-" appended to the field name</p>
- *
- *@return the contents of this tag
- */
- public String toString() {
- StringBuffer out = new StringBuffer(50);
- out.append("Tag content:\n");
- Enumeration en = fields.keys();
- while(en.hasMoreElements()) {
- Object field = en.nextElement();
- Object content = fields.get(field);
- out.append("\t");
- out.append(field);
- out.append(" : ");
- out.append(content);
- out.append("\n");
- }
- return out.toString().substring(0,out.length()-1);
- }
-}
diff --git a/songdbj/entagged/audioformats/generic/TagField.java b/songdbj/entagged/audioformats/generic/TagField.java
deleted file mode 100644
index 435bec8b19..0000000000
--- a/songdbj/entagged/audioformats/generic/TagField.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.generic;
-
-import java.io.UnsupportedEncodingException;
-
-public interface TagField {
-
- public String getId();
-
- public byte[] getRawContent() throws UnsupportedEncodingException;
-
- public boolean isBinary();
-
- public void isBinary(boolean b);
-
- public boolean isCommon();
-
- public boolean isEmpty();
-
- public String toString();
-
- public void copyContent(TagField field);
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/generic/TagTextField.java b/songdbj/entagged/audioformats/generic/TagTextField.java
deleted file mode 100644
index b54f8c96ca..0000000000
--- a/songdbj/entagged/audioformats/generic/TagTextField.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.generic;
-
-public interface TagTextField extends TagField {
-
- public String getContent();
-
- public String getEncoding();
-
- public void setContent(String s);
-
- public void setEncoding(String s);
-} \ No newline at end of file
diff --git a/songdbj/entagged/audioformats/generic/Utils.java b/songdbj/entagged/audioformats/generic/Utils.java
deleted file mode 100644
index dd2ccd06db..0000000000
--- a/songdbj/entagged/audioformats/generic/Utils.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ******************************************************************** **
- * Copyright notice **
- * ** **
- * (c) 2003 Entagged Developpement Team **
- * http://www.sourceforge.net/projects/entagged **
- * ** **
- * All rights reserved **
- * ** **
- * This script is part of the Entagged project. The Entagged **
- * project 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. **
- * ** **
- * The GNU General Public License can be found at **
- * http://www.gnu.org/copyleft/gpl.html. **
- * ** **
- * This copyright notice MUST APPEAR in all copies of the file! **
- * ********************************************************************
- */
-package entagged.audioformats.generic;
-
-import java.io.*;
-
-/*
- * Contains various frequently used static functions in the different tag formats
- *
- *@author Raphael Slinckx
- *@version $Id$
- *@since v0.02
- */
-public class Utils {
- /*
- * Returns the extension of the given file.
- * The extension is empty if there is no extension
- * The extension is the string after the last "."
- *
- * @param f The file whose extension is requested
- * @return The extension of the given file
- */
- public static String getExtension(File f) {
- String name = f.getName().toLowerCase();
- int i = name.lastIndexOf( "." );
- if(i == -1)
- return "";
-
- return name.substring( i + 1 );
- }
-
- /*
- * Tries to convert a string into an UTF8 array of bytes
- * If the conversion fails, return the string converted with the default
- * encoding.
- *
- * @param s The string to convert
- * @return The byte array representation of this string in UTF8 encoding
- */
- public static byte[] getUTF8Bytes(String s) throws UnsupportedEncodingException {
- return s.getBytes("UTF-8");
- }
-
- /*
- * Computes a number composed of (end-start) bytes in the b array.
- *
- * @param b The byte array
- * @param start The starting offset in b (b[offset]). The less significant byte
- * @param end The end index (included) in b (b[end]). The most significant byte
- * @return a long number represented by the byte sequence.
- */
- public static long getLongNumber(byte[] b, int start, int end) {
- long number = 0;
- for(int i = 0; i<(end-start+1); i++) {
- number += ((b[start+i]&0xFF) << i*8);
- }
-
- return number;
- }
-
- /*
- * same as above, but returns an int instead of a long
- * @param b The byte array
- * @param start The starting offset in b (b[offset]). The less significant byte
- * @param end The end index (included) in b (b[end]). The most significant byte
- * @return a int number represented by the byte sequence.
- */
- public static int getNumber( byte[] b, int start, int end) {
- int number = 0;
- for(int i = 0; i<(end-start+1); i++) {
- number += ((b[start+i]&0xFF) << i*8);
- }
-
- return number;
- }
-}
diff --git a/songdbj/javazoom/jl/converter/Converter.java b/songdbj/javazoom/jl/converter/Converter.java
deleted file mode 100644
index 845082e626..0000000000
--- a/songdbj/javazoom/jl/converter/Converter.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Original verion. mdm@techie.com.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.converter;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-
-import javazoom.jl.decoder.Bitstream;
-import javazoom.jl.decoder.Decoder;
-import javazoom.jl.decoder.Header;
-import javazoom.jl.decoder.JavaLayerException;
-import javazoom.jl.decoder.Obuffer;
-
-/**
- * The <code>Converter</code> class implements the conversion of
- * an MPEG audio file to a .WAV file. To convert an MPEG audio stream,
- * just create an instance of this class and call the convert()
- * method, passing in the names of the input and output files. You can
- * pass in optional <code>ProgressListener</code> and
- * <code>Decoder.Params</code> objects also to customize the conversion.
- *
- * @author MDM 12/12/99
- * @since 0.0.7
- */
-public class Converter
-{
- /**
- * Creates a new converter instance.
- */
- public Converter()
- {
- }
-
- public synchronized void convert(String sourceName, String destName)
- throws JavaLayerException
- {
- convert(sourceName, destName, null, null);
- }
-
- public synchronized void convert(String sourceName, String destName,
- ProgressListener progressListener)
- throws JavaLayerException
- {
- convert(sourceName, destName, progressListener, null);
- }
-
-
- public void convert(String sourceName, String destName,
- ProgressListener progressListener, Decoder.Params decoderParams)
- throws JavaLayerException
- {
- if (destName.length()==0)
- destName = null;
- try {
- InputStream in = openInput(sourceName);
- convert(in, destName, progressListener, decoderParams);
- in.close();
- } catch(IOException ioe) {
- throw new JavaLayerException(ioe.getLocalizedMessage(), ioe);
- }
- }
-
- public synchronized void convert(InputStream sourceStream, String destName,
- ProgressListener progressListener, Decoder.Params decoderParams)
- throws JavaLayerException
- {
- if (progressListener==null)
- progressListener = PrintWriterProgressListener.newStdOut(
- PrintWriterProgressListener.NO_DETAIL);
- try {
- if (!(sourceStream instanceof BufferedInputStream))
- sourceStream = new BufferedInputStream(sourceStream);
- int frameCount = -1;
- if (sourceStream.markSupported()) {
- sourceStream.mark(-1);
- frameCount = countFrames(sourceStream);
- sourceStream.reset();
- }
- progressListener.converterUpdate(ProgressListener.UPDATE_FRAME_COUNT, frameCount, 0);
-
-
- Obuffer output = null;
- Decoder decoder = new Decoder(decoderParams);
- Bitstream stream = new Bitstream(sourceStream);
-
- if (frameCount==-1)
- frameCount = Integer.MAX_VALUE;
-
- int frame = 0;
- long startTime = System.currentTimeMillis();
-
- try
- {
- for (; frame<frameCount; frame++)
- {
- try
- {
- Header header = stream.readFrame();
- if (header==null)
- break;
-
- progressListener.readFrame(frame, header);
-
- if (output==null)
- {
- // REVIEW: Incorrect functionality.
- // the decoder should provide decoded
- // frequency and channels output as it may differ from
- // the source (e.g. when downmixing stereo to mono.)
- int channels = (header.mode()==Header.SINGLE_CHANNEL) ? 1 : 2;
- int freq = header.frequency();
- output = new WaveFileObuffer(channels, freq, destName);
- decoder.setOutputBuffer(output);
- }
-
- Obuffer decoderOutput = decoder.decodeFrame(header, stream);
-
- // REVIEW: the way the output buffer is set
- // on the decoder is a bit dodgy. Even though
- // this exception should never happen, we test to be sure.
- if (decoderOutput!=output)
- throw new InternalError("Output buffers are different.");
-
-
- progressListener.decodedFrame(frame, header, output);
-
- stream.closeFrame();
-
- }
- catch (Exception ex)
- {
- boolean stop = !progressListener.converterException(ex);
-
- if (stop)
- {
- throw new JavaLayerException(ex.getLocalizedMessage(), ex);
- }
- }
- }
-
- }
- finally
- {
-
- if (output!=null)
- output.close();
- }
-
- int time = (int)(System.currentTimeMillis()-startTime);
- progressListener.converterUpdate(ProgressListener.UPDATE_CONVERT_COMPLETE,
- time, frame);
- }
- catch (IOException ex)
- {
- throw new JavaLayerException(ex.getLocalizedMessage(), ex);
- }
- }
-
-
- protected int countFrames(InputStream in)
- {
- return -1;
- }
-
-
- protected InputStream openInput(String fileName)
- throws IOException
- {
- // ensure name is abstract path name
- File file = new File(fileName);
- InputStream fileIn = new FileInputStream(file);
- BufferedInputStream bufIn = new BufferedInputStream(fileIn);
-
- return bufIn;
- }
-
-
- /**
- * This interface is used by the Converter to provide
- * notification of tasks being carried out by the converter,
- * and to provide new information as it becomes available.
- */
-
- static public interface ProgressListener
- {
- public static final int UPDATE_FRAME_COUNT = 1;
-
- /**
- * Conversion is complete. Param1 contains the time
- * to convert in milliseconds. Param2 contains the number
- * of MPEG audio frames converted.
- */
- public static final int UPDATE_CONVERT_COMPLETE = 2;
-
-
- /**
- * Notifies the listener that new information is available.
- *
- * @param updateID Code indicating the information that has been
- * updated.
- *
- * @param param1 Parameter whose value depends upon the update code.
- * @param param2 Parameter whose value depends upon the update code.
- *
- * The <code>updateID</code> parameter can take these values:
- *
- * UPDATE_FRAME_COUNT: param1 is the frame count, or -1 if not known.
- * UPDATE_CONVERT_COMPLETE: param1 is the conversion time, param2
- * is the number of frames converted.
- */
- public void converterUpdate(int updateID, int param1, int param2);
-
- /**
- * If the converter wishes to make a first pass over the
- * audio frames, this is called as each frame is parsed.
- */
- public void parsedFrame(int frameNo, Header header);
-
- /**
- * This method is called after each frame has been read,
- * but before it has been decoded.
- *
- * @param frameNo The 0-based sequence number of the frame.
- * @param header The Header rerpesenting the frame just read.
- */
- public void readFrame(int frameNo, Header header);
-
- /**
- * This method is called after a frame has been decoded.
- *
- * @param frameNo The 0-based sequence number of the frame.
- * @param header The Header rerpesenting the frame just read.
- * @param o The Obuffer the deocded data was written to.
- */
- public void decodedFrame(int frameNo, Header header, Obuffer o);
-
- /**
- * Called when an exception is thrown during while converting
- * a frame.
- *
- * @param t The <code>Throwable</code> instance that
- * was thrown.
- *
- * @return <code>true</code> to continue processing, or false
- * to abort conversion.
- *
- * If this method returns <code>false</code>, the exception
- * is propagated to the caller of the convert() method. If
- * <code>true</code> is returned, the exception is silently
- * ignored and the converter moves onto the next frame.
- */
- public boolean converterException(Throwable t);
-
- }
-
-
- /**
- * Implementation of <code>ProgressListener</code> that writes
- * notification text to a <code>PrintWriter</code>.
- */
- // REVIEW: i18n of text and order required.
- static public class PrintWriterProgressListener implements ProgressListener
- {
- static public final int NO_DETAIL = 0;
-
- /**
- * Level of detail typically expected of expert
- * users.
- */
- static public final int EXPERT_DETAIL = 1;
-
- /**
- * Verbose detail.
- */
- static public final int VERBOSE_DETAIL = 2;
-
- /**
- * Debug detail. All frame read notifications are shown.
- */
- static public final int DEBUG_DETAIL = 7;
-
- static public final int MAX_DETAIL = 10;
-
- private PrintWriter pw;
-
- private int detailLevel;
-
- static public PrintWriterProgressListener newStdOut(int detail)
- {
- return new PrintWriterProgressListener(
- new PrintWriter(System.out, true), detail);
- }
-
- public PrintWriterProgressListener(PrintWriter writer, int detailLevel)
- {
- this.pw = writer;
- this.detailLevel = detailLevel;
- }
-
-
- public boolean isDetail(int detail)
- {
- return (this.detailLevel >= detail);
- }
-
- public void converterUpdate(int updateID, int param1, int param2)
- {
- if (isDetail(VERBOSE_DETAIL))
- {
- switch (updateID)
- {
- case UPDATE_CONVERT_COMPLETE:
- // catch divide by zero errors.
- if (param2==0)
- param2 = 1;
-
- pw.println();
- pw.println("Converted "+param2+" frames in "+param1+" ms ("+
- (param1/param2)+" ms per frame.)");
- }
- }
- }
-
- public void parsedFrame(int frameNo, Header header)
- {
- if ((frameNo==0) && isDetail(VERBOSE_DETAIL))
- {
- String headerString = header.toString();
- pw.println("File is a "+headerString);
- }
- else if (isDetail(MAX_DETAIL))
- {
- String headerString = header.toString();
- pw.println("Prased frame "+frameNo+": "+headerString);
- }
- }
-
- public void readFrame(int frameNo, Header header)
- {
- if ((frameNo==0) && isDetail(VERBOSE_DETAIL))
- {
- String headerString = header.toString();
- pw.println("File is a "+headerString);
- }
- else if (isDetail(MAX_DETAIL))
- {
- String headerString = header.toString();
- pw.println("Read frame "+frameNo+": "+headerString);
- }
- }
-
- public void decodedFrame(int frameNo, Header header, Obuffer o)
- {
- if (isDetail(MAX_DETAIL))
- {
- String headerString = header.toString();
- pw.println("Decoded frame "+frameNo+": "+headerString);
- pw.println("Output: "+o);
- }
- else if (isDetail(VERBOSE_DETAIL))
- {
- if (frameNo==0)
- {
- pw.print("Converting.");
- pw.flush();
- }
-
- if ((frameNo % 10)==0)
- {
- pw.print('.');
- pw.flush();
- }
- }
- }
-
- public boolean converterException(Throwable t)
- {
- if (this.detailLevel>NO_DETAIL)
- {
- t.printStackTrace(pw);
- pw.flush();
- }
- return false;
- }
-
- }
-
-
-} \ No newline at end of file
diff --git a/songdbj/javazoom/jl/converter/RiffFile.java b/songdbj/javazoom/jl/converter/RiffFile.java
deleted file mode 100644
index fb5d9e53c6..0000000000
--- a/songdbj/javazoom/jl/converter/RiffFile.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 02/23/99 JavaConversion by E.B
- * Don Cross, April 1993.
- * RIFF file format classes.
- * See Chapter 8 of "Multimedia Programmer's Reference" in
- * the Microsoft Windows SDK.
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.converter;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-
-/**
- * Class to manage RIFF files
- */
-public class RiffFile
-{
- class RiffChunkHeader
- {
- public int ckID = 0; // Four-character chunk ID
- public int ckSize = 0; // Length of data in chunk
- public RiffChunkHeader()
- {}
- }
-
-
- // DDCRET
- public static final int DDC_SUCCESS = 0; // The operation succeded
- public static final int DDC_FAILURE = 1; // The operation failed for unspecified reasons
- public static final int DDC_OUT_OF_MEMORY = 2; // Operation failed due to running out of memory
- public static final int DDC_FILE_ERROR = 3; // Operation encountered file I/O error
- public static final int DDC_INVALID_CALL = 4; // Operation was called with invalid parameters
- public static final int DDC_USER_ABORT = 5; // Operation was aborted by the user
- public static final int DDC_INVALID_FILE = 6; // File format does not match
-
- // RiffFileMode
- public static final int RFM_UNKNOWN = 0; // undefined type (can use to mean "N/A" or "not open")
- public static final int RFM_WRITE = 1; // open for write
- public static final int RFM_READ = 2; // open for read
-
- private RiffChunkHeader riff_header; // header for whole file
- protected int fmode; // current file I/O mode
- protected RandomAccessFile file; // I/O stream to use
-
- /**
- * Dummy Constructor
- */
- public RiffFile()
- {
- file = null;
- fmode = RFM_UNKNOWN;
- riff_header = new RiffChunkHeader();
-
- riff_header.ckID = FourCC("RIFF");
- riff_header.ckSize = 0;
- }
-
- /**
- * Return File Mode.
- */
- public int CurrentFileMode()
- {return fmode;}
-
- /**
- * Open a RIFF file.
- */
- public int Open(String Filename, int NewMode)
- {
- int retcode = DDC_SUCCESS;
-
- if ( fmode != RFM_UNKNOWN )
- {
- retcode = Close();
- }
-
- if ( retcode == DDC_SUCCESS )
- {
- switch ( NewMode )
- {
- case RFM_WRITE:
- try
- {
- file = new RandomAccessFile(Filename,"rw");
-
- try
- {
- // Write the RIFF header...
- // We will have to come back later and patch it!
- byte[] br = new byte[8];
- br[0] = (byte) ((riff_header.ckID >>> 24) & 0x000000FF);
- br[1] = (byte) ((riff_header.ckID >>> 16) & 0x000000FF);
- br[2] = (byte) ((riff_header.ckID >>> 8) & 0x000000FF);
- br[3] = (byte) (riff_header.ckID & 0x000000FF);
-
- byte br4 = (byte) ((riff_header.ckSize >>> 24)& 0x000000FF);
- byte br5 = (byte) ((riff_header.ckSize >>> 16)& 0x000000FF);
- byte br6 = (byte) ((riff_header.ckSize >>> 8)& 0x000000FF);
- byte br7 = (byte) (riff_header.ckSize & 0x000000FF);
-
- br[4] = br7;
- br[5] = br6;
- br[6] = br5;
- br[7] = br4;
-
- file.write(br,0,8);
- fmode = RFM_WRITE;
- } catch (IOException ioe)
- {
- file.close();
- fmode = RFM_UNKNOWN;
- }
- } catch (IOException ioe)
- {
- fmode = RFM_UNKNOWN;
- retcode = DDC_FILE_ERROR;
- }
- break;
-
- case RFM_READ:
- try
- {
- file = new RandomAccessFile(Filename,"r");
- try
- {
- // Try to read the RIFF header...
- byte[] br = new byte[8];
- file.read(br,0,8);
- fmode = RFM_READ;
- riff_header.ckID = ((br[0]<<24)& 0xFF000000) | ((br[1]<<16)&0x00FF0000) | ((br[2]<<8)&0x0000FF00) | (br[3]&0x000000FF);
- riff_header.ckSize = ((br[4]<<24)& 0xFF000000) | ((br[5]<<16)&0x00FF0000) | ((br[6]<<8)&0x0000FF00) | (br[7]&0x000000FF);
- } catch (IOException ioe)
- {
- file.close();
- fmode = RFM_UNKNOWN;
- }
- } catch (IOException ioe)
- {
- fmode = RFM_UNKNOWN;
- retcode = DDC_FILE_ERROR;
- }
- break;
- default:
- retcode = DDC_INVALID_CALL;
- }
- }
- return retcode;
- }
-
- /**
- * Write NumBytes data.
- */
- public int Write(byte[] Data, int NumBytes )
- {
- if ( fmode != RFM_WRITE )
- {
- return DDC_INVALID_CALL;
- }
- try
- {
- file.write(Data,0,NumBytes);
- fmode = RFM_WRITE;
- }
- catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- riff_header.ckSize += NumBytes;
- return DDC_SUCCESS;
- }
-
-
-
- /**
- * Write NumBytes data.
- */
- public int Write(short[] Data, int NumBytes )
- {
- byte[] theData = new byte[NumBytes];
- int yc = 0;
- for (int y = 0;y<NumBytes;y=y+2)
- {
- theData[y] = (byte) (Data[yc] & 0x00FF);
- theData[y+1] =(byte) ((Data[yc++] >>> 8) & 0x00FF);
- }
- if ( fmode != RFM_WRITE )
- {
- return DDC_INVALID_CALL;
- }
- try
- {
- file.write(theData,0,NumBytes);
- fmode = RFM_WRITE;
- }
- catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- riff_header.ckSize += NumBytes;
- return DDC_SUCCESS;
- }
-
- /**
- * Write NumBytes data.
- */
- public int Write(RiffChunkHeader Triff_header, int NumBytes )
- {
- byte[] br = new byte[8];
- br[0] = (byte) ((Triff_header.ckID >>> 24) & 0x000000FF);
- br[1] = (byte) ((Triff_header.ckID >>> 16) & 0x000000FF);
- br[2] = (byte) ((Triff_header.ckID >>> 8) & 0x000000FF);
- br[3] = (byte) (Triff_header.ckID & 0x000000FF);
-
- byte br4 = (byte) ((Triff_header.ckSize >>> 24)& 0x000000FF);
- byte br5 = (byte) ((Triff_header.ckSize >>> 16)& 0x000000FF);
- byte br6 = (byte) ((Triff_header.ckSize >>> 8)& 0x000000FF);
- byte br7 = (byte) (Triff_header.ckSize & 0x000000FF);
-
- br[4] = br7;
- br[5] = br6;
- br[6] = br5;
- br[7] = br4;
-
- if ( fmode != RFM_WRITE )
- {
- return DDC_INVALID_CALL;
- }
- try
- {
- file.write(br,0,NumBytes);
- fmode = RFM_WRITE;
- } catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- riff_header.ckSize += NumBytes;
- return DDC_SUCCESS;
- }
-
- /**
- * Write NumBytes data.
- */
- public int Write(short Data, int NumBytes )
- {
- short theData = (short) ( ((Data>>>8)&0x00FF) | ((Data<<8)&0xFF00) );
- if ( fmode != RFM_WRITE )
- {
- return DDC_INVALID_CALL;
- }
- try
- {
- file.writeShort(theData);
- fmode = RFM_WRITE;
- } catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- riff_header.ckSize += NumBytes;
- return DDC_SUCCESS;
- }
- /**
- * Write NumBytes data.
- */
- public int Write(int Data, int NumBytes )
- {
- short theDataL = (short) ((Data>>>16)&0x0000FFFF);
- short theDataR = (short) (Data&0x0000FFFF);
- short theDataLI = (short) ( ((theDataL>>>8)&0x00FF) | ((theDataL<<8)&0xFF00) );
- short theDataRI = (short) ( ((theDataR>>>8)&0x00FF) | ((theDataR<<8)&0xFF00) );
- int theData = ((theDataRI<<16)&0xFFFF0000) | (theDataLI&0x0000FFFF);
- if ( fmode != RFM_WRITE )
- {
- return DDC_INVALID_CALL;
- }
- try
- {
- file.writeInt(theData);
- fmode = RFM_WRITE;
- } catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- riff_header.ckSize += NumBytes;
- return DDC_SUCCESS;
- }
-
-
-
- /**
- * Read NumBytes data.
- */
- public int Read (byte[] Data, int NumBytes)
- {
- int retcode = DDC_SUCCESS;
- try
- {
- file.read(Data,0,NumBytes);
- } catch (IOException ioe)
- {
- retcode = DDC_FILE_ERROR;
- }
- return retcode;
- }
-
- /**
- * Expect NumBytes data.
- */
- public int Expect(String Data, int NumBytes )
- {
- byte target = 0;
- int cnt = 0;
- try
- {
- while ((NumBytes--) != 0)
- {
- target = file.readByte();
- if (target != Data.charAt(cnt++)) return DDC_FILE_ERROR;
- }
- } catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- return DDC_SUCCESS;
- }
-
- /**
- * Close Riff File.
- * Length is written too.
- */
- public int Close()
- {
- int retcode = DDC_SUCCESS;
-
- switch ( fmode )
- {
- case RFM_WRITE:
- try
- {
- file.seek(0);
- try
- {
- byte[] br = new byte[8];
- br[0] = (byte) ((riff_header.ckID >>> 24) & 0x000000FF);
- br[1] = (byte) ((riff_header.ckID >>> 16) & 0x000000FF);
- br[2] = (byte) ((riff_header.ckID >>> 8) & 0x000000FF);
- br[3] = (byte) (riff_header.ckID & 0x000000FF);
-
- br[7] = (byte) ((riff_header.ckSize >>> 24)& 0x000000FF);
- br[6] = (byte) ((riff_header.ckSize >>> 16)& 0x000000FF);
- br[5] = (byte) ((riff_header.ckSize >>> 8)& 0x000000FF);
- br[4] = (byte) (riff_header.ckSize & 0x000000FF);
- file.write(br,0,8);
- file.close();
- } catch (IOException ioe)
- {
- retcode = DDC_FILE_ERROR;
- }
- } catch (IOException ioe)
- {
- retcode = DDC_FILE_ERROR;
- }
- break;
-
- case RFM_READ:
- try
- {
- file.close();
- } catch (IOException ioe)
- {
- retcode = DDC_FILE_ERROR;
- }
- break;
- }
- file = null;
- fmode = RFM_UNKNOWN;
- return retcode;
- }
-
- /**
- * Return File Position.
- */
- public long CurrentFilePosition()
- {
- long position;
- try
- {
- position = file.getFilePointer();
- } catch (IOException ioe)
- {
- position = -1;
- }
- return position;
- }
-
- /**
- * Write Data to specified offset.
- */
- public int Backpatch (long FileOffset, RiffChunkHeader Data, int NumBytes )
- {
- if (file == null)
- {
- return DDC_INVALID_CALL;
- }
- try
- {
- file.seek(FileOffset);
- } catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- return Write ( Data, NumBytes );
- }
-
- public int Backpatch (long FileOffset, byte[] Data, int NumBytes )
- {
- if (file == null)
- {
- return DDC_INVALID_CALL;
- }
- try
- {
- file.seek(FileOffset);
- } catch (IOException ioe)
- {
- return DDC_FILE_ERROR;
- }
- return Write ( Data, NumBytes );
- }
-
-
- /**
- * Seek in the File.
- */
- protected int Seek(long offset)
- {
- int rc;
- try
- {
- file.seek(offset);
- rc = DDC_SUCCESS;
- } catch (IOException ioe)
- {
- rc = DDC_FILE_ERROR;
- }
- return rc;
- }
-
- /**
- * Error Messages.
- */
- private String DDCRET_String(int retcode)
- {
- switch ( retcode )
- {
- case DDC_SUCCESS: return "DDC_SUCCESS";
- case DDC_FAILURE: return "DDC_FAILURE";
- case DDC_OUT_OF_MEMORY: return "DDC_OUT_OF_MEMORY";
- case DDC_FILE_ERROR: return "DDC_FILE_ERROR";
- case DDC_INVALID_CALL: return "DDC_INVALID_CALL";
- case DDC_USER_ABORT: return "DDC_USER_ABORT";
- case DDC_INVALID_FILE: return "DDC_INVALID_FILE";
- }
- return "Unknown Error";
- }
-
- /**
- * Fill the header.
- */
- public static int FourCC(String ChunkName)
- {
- byte[] p = {0x20,0x20,0x20,0x20};
- ChunkName.getBytes(0,4,p,0);
- int ret = (((p[0] << 24)& 0xFF000000) | ((p[1] << 16)&0x00FF0000) | ((p[2] << 8)&0x0000FF00) | (p[3]&0x000000FF));
- return ret;
- }
-
-}
diff --git a/songdbj/javazoom/jl/converter/WaveFile.java b/songdbj/javazoom/jl/converter/WaveFile.java
deleted file mode 100644
index f158d7a39a..0000000000
--- a/songdbj/javazoom/jl/converter/WaveFile.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 02/23/99 JavaConversion by E.B
- * Don Cross, April 1993.
- * RIFF file format classes.
- * See Chapter 8 of "Multimedia Programmer's Reference" in
- * the Microsoft Windows SDK.
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.converter;
-
-/**
- * Class allowing WaveFormat Access
- */
-public class WaveFile extends RiffFile
-{
- public static final int MAX_WAVE_CHANNELS = 2;
-
- class WaveFormat_ChunkData
- {
- public short wFormatTag = 0; // Format category (PCM=1)
- public short nChannels = 0; // Number of channels (mono=1, stereo=2)
- public int nSamplesPerSec = 0; // Sampling rate [Hz]
- public int nAvgBytesPerSec = 0;
- public short nBlockAlign = 0;
- public short nBitsPerSample = 0;
-
- public WaveFormat_ChunkData()
- {
- wFormatTag = 1; // PCM
- Config(44100,(short)16,(short)1);
- }
-
- public void Config (int NewSamplingRate, short NewBitsPerSample, short NewNumChannels)
- {
- nSamplesPerSec = NewSamplingRate;
- nChannels = NewNumChannels;
- nBitsPerSample = NewBitsPerSample;
- nAvgBytesPerSec = (nChannels * nSamplesPerSec * nBitsPerSample) / 8;
- nBlockAlign = (short) ((nChannels * nBitsPerSample) / 8);
- }
- }
-
-
- class WaveFormat_Chunk
- {
- public RiffChunkHeader header;
- public WaveFormat_ChunkData data;
-
- public WaveFormat_Chunk()
- {
- header = new RiffChunkHeader();
- data = new WaveFormat_ChunkData();
- header.ckID = FourCC("fmt ");
- header.ckSize = 16;
- }
-
- public int VerifyValidity()
- {
- boolean ret = header.ckID == FourCC("fmt ") &&
-
- (data.nChannels == 1 || data.nChannels == 2) &&
-
- data.nAvgBytesPerSec == ( data.nChannels *
- data.nSamplesPerSec *
- data.nBitsPerSample ) / 8 &&
-
- data.nBlockAlign == ( data.nChannels *
- data.nBitsPerSample ) / 8;
- if (ret == true) return 1;
- else return 0;
- }
- }
-
- public class WaveFileSample
- {
- public short[] chan;
-
- public WaveFileSample()
- {chan = new short[WaveFile.MAX_WAVE_CHANNELS];}
- }
-
- private WaveFormat_Chunk wave_format;
- private RiffChunkHeader pcm_data;
- private long pcm_data_offset = 0; // offset of 'pcm_data' in output file
- private int num_samples = 0;
-
-
- /**
- * Constructs a new WaveFile instance.
- */
- public WaveFile()
- {
- pcm_data = new RiffChunkHeader();
- wave_format = new WaveFormat_Chunk();
- pcm_data.ckID = FourCC("data");
- pcm_data.ckSize = 0;
- num_samples = 0;
- }
-
- /**
- *
- *
- public int OpenForRead (String Filename)
- {
- // Verify filename parameter as best we can...
- if (Filename == null)
- {
- return DDC_INVALID_CALL;
- }
- int retcode = Open ( Filename, RFM_READ );
-
- if ( retcode == DDC_SUCCESS )
- {
- retcode = Expect ( "WAVE", 4 );
-
- if ( retcode == DDC_SUCCESS )
- {
- retcode = Read(wave_format,24);
-
- if ( retcode == DDC_SUCCESS && !wave_format.VerifyValidity() )
- {
- // This isn't standard PCM, so we don't know what it is!
- retcode = DDC_FILE_ERROR;
- }
-
- if ( retcode == DDC_SUCCESS )
- {
- pcm_data_offset = CurrentFilePosition();
-
- // Figure out number of samples from
- // file size, current file position, and
- // WAVE header.
- retcode = Read (pcm_data, 8 );
- num_samples = filelength(fileno(file)) - CurrentFilePosition();
- num_samples /= NumChannels();
- num_samples /= (BitsPerSample() / 8);
- }
- }
- }
- return retcode;
- }*/
-
- /**
- *
- */
- public int OpenForWrite (String Filename, int SamplingRate, short BitsPerSample, short NumChannels)
- {
- // Verify parameters...
- if ( (Filename==null) ||
- (BitsPerSample != 8 && BitsPerSample != 16) ||
- NumChannels < 1 || NumChannels > 2 )
- {
- return DDC_INVALID_CALL;
- }
-
- wave_format.data.Config ( SamplingRate, BitsPerSample, NumChannels );
-
- int retcode = Open ( Filename, RFM_WRITE );
-
- if ( retcode == DDC_SUCCESS )
- {
- byte [] theWave = {(byte)'W',(byte)'A',(byte)'V',(byte)'E'};
- retcode = Write ( theWave, 4 );
-
- if ( retcode == DDC_SUCCESS )
- {
- // Ecriture de wave_format
- retcode = Write (wave_format.header, 8);
- retcode = Write (wave_format.data.wFormatTag, 2);
- retcode = Write (wave_format.data.nChannels, 2);
- retcode = Write (wave_format.data.nSamplesPerSec, 4);
- retcode = Write (wave_format.data.nAvgBytesPerSec, 4);
- retcode = Write (wave_format.data.nBlockAlign, 2);
- retcode = Write (wave_format.data.nBitsPerSample, 2);
- /* byte[] br = new byte[16];
- br[0] = (byte) ((wave_format.data.wFormatTag >> 8) & 0x00FF);
- br[1] = (byte) (wave_format.data.wFormatTag & 0x00FF);
-
- br[2] = (byte) ((wave_format.data.nChannels >> 8) & 0x00FF);
- br[3] = (byte) (wave_format.data.nChannels & 0x00FF);
-
- br[4] = (byte) ((wave_format.data.nSamplesPerSec >> 24)& 0x000000FF);
- br[5] = (byte) ((wave_format.data.nSamplesPerSec >> 16)& 0x000000FF);
- br[6] = (byte) ((wave_format.data.nSamplesPerSec >> 8)& 0x000000FF);
- br[7] = (byte) (wave_format.data.nSamplesPerSec & 0x000000FF);
-
- br[8] = (byte) ((wave_format.data.nAvgBytesPerSec>> 24)& 0x000000FF);
- br[9] = (byte) ((wave_format.data.nAvgBytesPerSec >> 16)& 0x000000FF);
- br[10] = (byte) ((wave_format.data.nAvgBytesPerSec >> 8)& 0x000000FF);
- br[11] = (byte) (wave_format.data.nAvgBytesPerSec & 0x000000FF);
-
- br[12] = (byte) ((wave_format.data.nBlockAlign >> 8) & 0x00FF);
- br[13] = (byte) (wave_format.data.nBlockAlign & 0x00FF);
-
- br[14] = (byte) ((wave_format.data.nBitsPerSample >> 8) & 0x00FF);
- br[15] = (byte) (wave_format.data.nBitsPerSample & 0x00FF);
- retcode = Write (br, 16); */
-
-
- if ( retcode == DDC_SUCCESS )
- {
- pcm_data_offset = CurrentFilePosition();
- retcode = Write ( pcm_data, 8 );
- }
- }
- }
-
- return retcode;
- }
-
- /**
- *
- *
- public int ReadSample ( short[] Sample )
- {
-
- }*/
-
- /**
- *
- *
- public int WriteSample( short[] Sample )
- {
- int retcode = DDC_SUCCESS;
- switch ( wave_format.data.nChannels )
- {
- case 1:
- switch ( wave_format.data.nBitsPerSample )
- {
- case 8:
- pcm_data.ckSize += 1;
- retcode = Write ( Sample, 1 );
- break;
-
- case 16:
- pcm_data.ckSize += 2;
- retcode = Write ( Sample, 2 );
- break;
-
- default:
- retcode = DDC_INVALID_CALL;
- }
- break;
-
- case 2:
- switch ( wave_format.data.nBitsPerSample )
- {
- case 8:
- retcode = Write ( Sample, 1 );
- if ( retcode == DDC_SUCCESS )
- {
- // &Sample[1]
- retcode = Write (Sample, 1 );
- if ( retcode == DDC_SUCCESS )
- {
- pcm_data.ckSize += 2;
- }
- }
- break;
-
- case 16:
- retcode = Write ( Sample, 2 );
- if ( retcode == DDC_SUCCESS )
- {
- // &Sample[1]
- retcode = Write (Sample, 2 );
- if ( retcode == DDC_SUCCESS )
- {
- pcm_data.ckSize += 4;
- }
- }
- break;
-
- default:
- retcode = DDC_INVALID_CALL;
- }
- break;
-
- default:
- retcode = DDC_INVALID_CALL;
- }
-
- return retcode;
- }*/
-
- /**
- *
- *
- public int SeekToSample ( long SampleIndex )
- {
- if ( SampleIndex >= NumSamples() )
- {
- return DDC_INVALID_CALL;
- }
- int SampleSize = (BitsPerSample() + 7) / 8;
- int rc = Seek ( pcm_data_offset + 8 +
- SampleSize * NumChannels() * SampleIndex );
- return rc;
- }*/
-
- /**
- * Write 16-bit audio
- */
- public int WriteData ( short[] data, int numData )
- {
- int extraBytes = numData * 2;
- pcm_data.ckSize += extraBytes;
- return super.Write ( data, extraBytes );
- }
-
- /**
- * Read 16-bit audio.
- *
- public int ReadData (short[] data, int numData)
- {return super.Read ( data, numData * 2);} */
-
- /**
- * Write 8-bit audio.
- *
- public int WriteData ( byte[] data, int numData )
- {
- pcm_data.ckSize += numData;
- return super.Write ( data, numData );
- }*/
-
- /**
- * Read 8-bit audio.
- *
- public int ReadData ( byte[] data, int numData )
- {return super.Read ( data, numData );} */
-
-
- /**
- *
- *
- public int ReadSamples (int num, int [] WaveFileSample)
- {
-
- }*/
-
- /**
- *
- *
- public int WriteMonoSample ( short[] SampleData )
- {
- switch ( wave_format.data.nBitsPerSample )
- {
- case 8:
- pcm_data.ckSize += 1;
- return Write ( SampleData, 1 );
-
- case 16:
- pcm_data.ckSize += 2;
- return Write ( SampleData, 2 );
- }
- return DDC_INVALID_CALL;
- }*/
-
- /**
- *
- *
- public int WriteStereoSample ( short[] LeftSample, short[] RightSample )
- {
- int retcode = DDC_SUCCESS;
- switch ( wave_format.data.nBitsPerSample )
- {
- case 8:
- retcode = Write ( LeftSample, 1 );
- if ( retcode == DDC_SUCCESS )
- {
- retcode = Write ( RightSample, 1 );
- if ( retcode == DDC_SUCCESS )
- {
- pcm_data.ckSize += 2;
- }
- }
- break;
-
- case 16:
- retcode = Write ( LeftSample, 2 );
- if ( retcode == DDC_SUCCESS )
- {
- retcode = Write ( RightSample, 2 );
- if ( retcode == DDC_SUCCESS )
- {
- pcm_data.ckSize += 4;
- }
- }
- break;
-
- default:
- retcode = DDC_INVALID_CALL;
- }
- return retcode;
- }*/
-
- /**
- *
- *
- public int ReadMonoSample ( short[] Sample )
- {
- int retcode = DDC_SUCCESS;
- switch ( wave_format.data.nBitsPerSample )
- {
- case 8:
- byte[] x = {0};
- retcode = Read ( x, 1 );
- Sample[0] = (short)(x[0]);
- break;
-
- case 16:
- retcode = Read ( Sample, 2 );
- break;
-
- default:
- retcode = DDC_INVALID_CALL;
- }
- return retcode;
- }*/
-
- /**
- *
- *
- public int ReadStereoSample ( short[] LeftSampleData, short[] RightSampleData )
- {
- int retcode = DDC_SUCCESS;
- byte[] x = new byte[2];
- short[] y = new short[2];
- switch ( wave_format.data.nBitsPerSample )
- {
- case 8:
- retcode = Read ( x, 2 );
- L[0] = (short) ( x[0] );
- R[0] = (short) ( x[1] );
- break;
-
- case 16:
- retcode = Read ( y, 4 );
- L[0] = (short) ( y[0] );
- R[0] = (short) ( y[1] );
- break;
-
- default:
- retcode = DDC_INVALID_CALL;
- }
- return retcode;
- }*/
-
-
- /**
- *
- */
- public int Close()
- {
- int rc = DDC_SUCCESS;
-
- if ( fmode == RFM_WRITE )
- rc = Backpatch ( pcm_data_offset, pcm_data, 8 );
- if ( rc == DDC_SUCCESS )
- rc = super.Close();
- return rc;
- }
-
- // [Hz]
- public int SamplingRate()
- {return wave_format.data.nSamplesPerSec;}
-
- public short BitsPerSample()
- {return wave_format.data.nBitsPerSample;}
-
- public short NumChannels()
- {return wave_format.data.nChannels;}
-
- public int NumSamples()
- {return num_samples;}
-
-
- /**
- * Open for write using another wave file's parameters...
- */
- public int OpenForWrite (String Filename, WaveFile OtherWave )
- {
- return OpenForWrite ( Filename,
- OtherWave.SamplingRate(),
- OtherWave.BitsPerSample(),
- OtherWave.NumChannels() );
- }
-
- /**
- *
- */
- public long CurrentFilePosition()
- {
- return super.CurrentFilePosition();
- }
-
- /* public int FourCC(String ChunkName)
- {
- byte[] p = {0x20,0x20,0x20,0x20};
- ChunkName.getBytes(0,4,p,0);
- int ret = (((p[0] << 24)& 0xFF000000) | ((p[1] << 16)&0x00FF0000) | ((p[2] << 8)&0x0000FF00) | (p[3]&0x000000FF));
- return ret;
- }*/
-
-} \ No newline at end of file
diff --git a/songdbj/javazoom/jl/converter/WaveFileObuffer.java b/songdbj/javazoom/jl/converter/WaveFileObuffer.java
deleted file mode 100644
index eaa1dd46d4..0000000000
--- a/songdbj/javazoom/jl/converter/WaveFileObuffer.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 12/12/99 0.0.7 Renamed class, additional constructor arguments
- * and larger write buffers. mdm@techie.com.
- *
- * 15/02/99 Java Conversion by E.B ,javalayer@javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.converter;
-
-import javazoom.jl.decoder.Obuffer;
-
-/**
- * Implements an Obuffer by writing the data to
- * a file in RIFF WAVE format.
- *
- * @since 0.0
- */
-
-
-public class WaveFileObuffer extends Obuffer
-{
- private short[] buffer;
- private short[] bufferp;
- private int channels;
- private WaveFile outWave;
-
- /**
- * Creates a new WareFileObuffer instance.
- *
- * @param number_of_channels
- * The number of channels of audio data
- * this buffer will receive.
- *
- * @param freq The sample frequency of the samples in the buffer.
- *
- * @param fileName The filename to write the data to.
- */
- public WaveFileObuffer(int number_of_channels, int freq, String FileName)
- {
- if (FileName==null)
- throw new NullPointerException("FileName");
-
- buffer = new short[OBUFFERSIZE];
- bufferp = new short[MAXCHANNELS];
- channels = number_of_channels;
-
- for (int i = 0; i < number_of_channels; ++i)
- bufferp[i] = (short)i;
-
- outWave = new WaveFile();
-
- int rc = outWave.OpenForWrite (FileName,freq,(short)16,(short)channels);
- }
-
- /**
- * Takes a 16 Bit PCM sample.
- */
- public void append(int channel, short value)
- {
- buffer[bufferp[channel]] = value;
- bufferp[channel] += channels;
- }
-
- /**
- * Write the samples to the file (Random Acces).
- */
- short[] myBuffer = new short[2];
- public void write_buffer(int val)
- {
-
- int k = 0;
- int rc = 0;
-
- rc = outWave.WriteData(buffer, bufferp[0]);
- // REVIEW: handle RiffFile errors.
- /*
- for (int j=0;j<bufferp[0];j=j+2)
- {
-
- //myBuffer[0] = (short)(((buffer[j]>>8)&0x000000FF) | ((buffer[j]<<8)&0x0000FF00));
- //myBuffer[1] = (short) (((buffer[j+1]>>8)&0x000000FF) | ((buffer[j+1]<<8)&0x0000FF00));
- myBuffer[0] = buffer[j];
- myBuffer[1] = buffer[j+1];
- rc = outWave.WriteData (myBuffer,2);
- }
- */
- for (int i = 0; i < channels; ++i) bufferp[i] = (short)i;
- }
-
- public void close()
- {
- outWave.Close();
- }
-
- /**
- *
- */
- public void clear_buffer()
- {}
-
- /**
- *
- */
- public void set_stop_flag()
- {}
-
- /*
- * Create STDOUT buffer
- *
- *
- public static Obuffer create_stdout_obuffer(MPEG_Args maplay_args)
- {
- Obuffer thebuffer = null;
- int mode = maplay_args.MPEGheader.mode();
- int which_channels = maplay_args.which_c;
- if (mode == Header.single_channel || which_channels != MPEG_Args.both)
- thebuffer = new FileObuffer(1,maplay_args.output_filename);
- else
- thebuffer = new FileObuffer(2,maplay_args.output_filename);
- return(thebuffer);
- }
- */
-}
diff --git a/songdbj/javazoom/jl/converter/jlc.java b/songdbj/javazoom/jl/converter/jlc.java
deleted file mode 100644
index 57c84eba4a..0000000000
--- a/songdbj/javazoom/jl/converter/jlc.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 29/01/00 Initial version. mdm@techie.com
- *
- * 12/12/99 JavaLayer 0.0.7 mdm@techie.com
- *
- * 14/02/99 MPEG_Args Based Class - E.B
- * Adapted from javalayer and MPEG_Args.
- * Doc'ed and integerated with JL converter. Removed
- * Win32 specifics from original Maplay code.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.converter;
-
-import java.io.PrintWriter;
-
-import javazoom.jl.decoder.Crc16;
-import javazoom.jl.decoder.JavaLayerException;
-import javazoom.jl.decoder.OutputChannels;
-
-/**
- * The <code>jlc</code> class presents the JavaLayer
- * Conversion functionality as a command-line program.
- *
- * @since 0.0.7
- */
-public class jlc
-{
-
- static public void main(String args[])
- {
- String[] argv;
- long start = System.currentTimeMillis();
- int argc = args.length + 1;
- argv = new String[argc];
- argv[0] = "jlc";
- for(int i=0;i<args.length;i++)
- argv[i+1] = args[i];
-
- jlcArgs ma = new jlcArgs();
- if (!ma.processArgs(argv))
- System.exit(1);
-
- Converter conv = new Converter();
-
- int detail = (ma.verbose_mode ?
- ma.verbose_level :
- Converter.PrintWriterProgressListener.NO_DETAIL);
-
- Converter.ProgressListener listener =
- new Converter.PrintWriterProgressListener(
- new PrintWriter(System.out, true), detail);
-
- try
- {
- conv.convert(ma.filename, ma.output_filename, listener);
- }
- catch (JavaLayerException ex)
- {
- System.err.println("Convertion failure: "+ex);
- }
-
- System.exit(0);
- }
-
-
- /**
- * Class to contain arguments for maplay.
- */
- static class jlcArgs
- {
- // channel constants moved into OutputChannels class.
- //public static final int both = 0;
- //public static final int left = 1;
- //public static final int right = 2;
- //public static final int downmix = 3;
-
- public int which_c;
- public int output_mode;
- public boolean use_own_scalefactor;
- public float scalefactor;
- public String output_filename;
- public String filename;
- //public boolean stdout_mode;
- public boolean verbose_mode;
- public int verbose_level = 3;
-
- public jlcArgs()
- {
- which_c = OutputChannels.BOTH_CHANNELS;
- use_own_scalefactor = false;
- scalefactor = (float) 32768.0;
- //stdout_mode = false;
- verbose_mode = false;
- }
-
- /**
- * Process user arguments.
- *
- * Returns true if successful.
- */
- public boolean processArgs(String[] argv)
- {
- filename = null;
- Crc16[] crc;
- crc = new Crc16[1];
- int i;
- int argc = argv.length;
-
- //stdout_mode = false;
- verbose_mode = false;
- output_mode = OutputChannels.BOTH_CHANNELS;
- output_filename = "";
- if (argc < 2 || argv[1].equals("-h"))
- return Usage();
-
- i = 1;
- while (i < argc)
- {
- /* System.out.println("Option = "+argv[i]);*/
- if (argv[i].charAt(0) == '-')
- {
- if (argv[i].startsWith("-v"))
- {
- verbose_mode = true;
- if (argv[i].length()>2)
- {
- try
- {
- String level = argv[i].substring(2);
- verbose_level = Integer.parseInt(level);
- }
- catch (NumberFormatException ex)
- {
- System.err.println("Invalid verbose level. Using default.");
- }
- }
- System.out.println("Verbose Activated (level "+verbose_level+")");
- }
- /* else if (argv[i].equals("-s"))
- ma.stdout_mode = true; */
- else if (argv[i].equals("-p"))
- {
- if (++i == argc)
- {
- System.out.println("Please specify an output filename after the -p option!");
- System.exit (1);
- }
- //output_mode = O_WAVEFILE;
- output_filename = argv[i];
- }
- /*else if (argv[i].equals("-f"))
- {
- if (++i == argc)
- {
- System.out.println("Please specify a new scalefactor after the -f option!");
- System.exit(1);
- }
- ma.use_own_scalefactor = true;
- // ma.scalefactor = argv[i];
- }*/
- else return Usage();
- }
- else
- {
- filename = argv[i];
- System.out.println("FileName = "+argv[i]);
- if (filename == null) return Usage();
- }
- i++;
- }
- if (filename == null)
- return Usage();
-
- return true;
- }
-
-
- /**
- * Usage of JavaLayer.
- */
- public boolean Usage()
- {
- System.out.println("JavaLayer Converter :");
- System.out.println(" -v[x] verbose mode. ");
- System.out.println(" default = 2");
- /* System.out.println(" -s write u-law samples at 8 kHz rate to stdout");
- System.out.println(" -l decode only the left channel");
- System.out.println(" -r decode only the right channel");
- System.out.println(" -d downmix mode (layer III only)");
- System.out.println(" -s write pcm samples to stdout");
- System.out.println(" -d downmix mode (layer III only)");*/
- System.out.println(" -p name output as a PCM wave file");
- System.out.println("");
- System.out.println(" More info on http://www.javazoom.net");
- /* System.out.println(" -f ushort use this scalefactor instead of the default value 32768");*/
- return false;
- }
- };
-}; \ No newline at end of file
diff --git a/songdbj/javazoom/jl/decoder/BitReserve.java b/songdbj/javazoom/jl/decoder/BitReserve.java
deleted file mode 100644
index a5d3056d61..0000000000
--- a/songdbj/javazoom/jl/decoder/BitReserve.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 12/12/99 0.0.7 Implementation stores single bits
- * as ints for better performance. mdm@techie.com.
- *
- * 02/28/99 0.0 Java Conversion by E.B, javalayer@javazoom.net
- *
- * Adapted from the public c code by Jeff Tsay.
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Implementation of Bit Reservoir for Layer III.
- * <p>
- * The implementation stores single bits as a word in the buffer. If
- * a bit is set, the corresponding word in the buffer will be non-zero.
- * If a bit is clear, the corresponding word is zero. Although this
- * may seem waseful, this can be a factor of two quicker than
- * packing 8 bits to a byte and extracting.
- * <p>
- */
-
-// REVIEW: there is no range checking, so buffer underflow or overflow
-// can silently occur.
-final class BitReserve
-{
- /**
- * Size of the internal buffer to store the reserved bits.
- * Must be a power of 2. And x8, as each bit is stored as a single
- * entry.
- */
- private static final int BUFSIZE = 4096*8;
-
- /**
- * Mask that can be used to quickly implement the
- * modulus operation on BUFSIZE.
- */
- private static final int BUFSIZE_MASK = BUFSIZE-1;
-
- private int offset, totbit, buf_byte_idx;
- private final int[] buf = new int[BUFSIZE];
- private int buf_bit_idx;
-
- BitReserve()
- {
-
- offset = 0;
- totbit = 0;
- buf_byte_idx = 0;
- }
-
-
- /**
- * Return totbit Field.
- */
- public int hsstell()
- {
- return(totbit);
- }
-
- /**
- * Read a number bits from the bit stream.
- * @param N the number of
- */
- public int hgetbits(int N)
- {
- totbit += N;
-
- int val = 0;
-
- int pos = buf_byte_idx;
- if (pos+N < BUFSIZE)
- {
- while (N-- > 0)
- {
- val <<= 1;
- val |= ((buf[pos++]!=0) ? 1 : 0);
- }
- }
- else
- {
- while (N-- > 0)
- {
- val <<= 1;
- val |= ((buf[pos]!=0) ? 1 : 0);
- pos = (pos+1) & BUFSIZE_MASK;
- }
- }
- buf_byte_idx = pos;
- return val;
- }
-
-
-
- /**
- * Read 1 bit from the bit stream.
- */
-/*
- public int hget1bit_old()
- {
- int val;
- totbit++;
- if (buf_bit_idx == 0)
- {
- buf_bit_idx = 8;
- buf_byte_idx++;
- }
- // BUFSIZE = 4096 = 2^12, so
- // buf_byte_idx%BUFSIZE == buf_byte_idx & 0xfff
- val = buf[buf_byte_idx & BUFSIZE_MASK] & putmask[buf_bit_idx];
- buf_bit_idx--;
- val = val >>> buf_bit_idx;
- return val;
- }
- */
- /**
- * Returns next bit from reserve.
- * @returns 0 if next bit is reset, or 1 if next bit is set.
- */
- public int hget1bit()
- {
- totbit++;
- int val = buf[buf_byte_idx];
- buf_byte_idx = (buf_byte_idx+1) & BUFSIZE_MASK;
- return val;
- }
-
- /**
- * Retrieves bits from the reserve.
- */
-/*
- public int readBits(int[] out, int len)
- {
- if (buf_bit_idx == 0)
- {
- buf_bit_idx = 8;
- buf_byte_idx++;
- current = buf[buf_byte_idx & BUFSIZE_MASK];
- }
-
-
-
- // save total number of bits returned
- len = buf_bit_idx;
- buf_bit_idx = 0;
-
- int b = current;
- int count = len-1;
-
- while (count >= 0)
- {
- out[count--] = (b & 0x1);
- b >>>= 1;
- }
-
- totbit += len;
- return len;
- }
- */
-
- /**
- * Write 8 bits into the bit stream.
- */
- public void hputbuf(int val)
- {
- int ofs = offset;
- buf[ofs++] = val & 0x80;
- buf[ofs++] = val & 0x40;
- buf[ofs++] = val & 0x20;
- buf[ofs++] = val & 0x10;
- buf[ofs++] = val & 0x08;
- buf[ofs++] = val & 0x04;
- buf[ofs++] = val & 0x02;
- buf[ofs++] = val & 0x01;
-
- if (ofs==BUFSIZE)
- offset = 0;
- else
- offset = ofs;
-
- }
-
- /**
- * Rewind N bits in Stream.
- */
- public void rewindNbits(int N)
- {
- totbit -= N;
- buf_byte_idx -= N;
- if (buf_byte_idx<0)
- buf_byte_idx += BUFSIZE;
- }
-
- /**
- * Rewind N bytes in Stream.
- */
- public void rewindNbytes(int N)
- {
- int bits = (N << 3);
- totbit -= bits;
- buf_byte_idx -= bits;
- if (buf_byte_idx<0)
- buf_byte_idx += BUFSIZE;
- }
-}
diff --git a/songdbj/javazoom/jl/decoder/Bitstream.java b/songdbj/javazoom/jl/decoder/Bitstream.java
deleted file mode 100644
index cebbd5b03b..0000000000
--- a/songdbj/javazoom/jl/decoder/Bitstream.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 11/17/04 Uncomplete frames discarded. E.B, javalayer@javazoom.net
- *
- * 12/05/03 ID3v2 tag returned. E.B, javalayer@javazoom.net
- *
- * 12/12/99 Based on Ibitstream. Exceptions thrown on errors,
- * Temporary removed seek functionality. mdm@techie.com
- *
- * 02/12/99 : Java Conversion by E.B , javalayer@javazoom.net
- *
- * 04/14/97 : Added function prototypes for new syncing and seeking
- * mechanisms. Also made this file portable. Changes made by Jeff Tsay
- *
- * @(#) ibitstream.h 1.5, last edit: 6/15/94 16:55:34
- * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
- * @(#) Berlin University of Technology
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-
-
-/**
- * The <code>Bistream</code> class is responsible for parsing
- * an MPEG audio bitstream.
- *
- * <b>REVIEW:</b> much of the parsing currently occurs in the
- * various decoders. This should be moved into this class and associated
- * inner classes.
- */
-public final class Bitstream implements BitstreamErrors
-{
- /**
- * Synchronization control constant for the initial
- * synchronization to the start of a frame.
- */
- static byte INITIAL_SYNC = 0;
-
- /**
- * Synchronization control constant for non-initial frame
- * synchronizations.
- */
- static byte STRICT_SYNC = 1;
-
- // max. 1730 bytes per frame: 144 * 384kbit/s / 32000 Hz + 2 Bytes CRC
- /**
- * Maximum size of the frame buffer.
- */
- private static final int BUFFER_INT_SIZE = 433;
-
- /**
- * The frame buffer that holds the data for the current frame.
- */
- private final int[] framebuffer = new int[BUFFER_INT_SIZE];
-
- /**
- * Number of valid bytes in the frame buffer.
- */
- private int framesize;
-
- /**
- * The bytes read from the stream.
- */
- private byte[] frame_bytes = new byte[BUFFER_INT_SIZE*4];
-
- /**
- * Index into <code>framebuffer</code> where the next bits are
- * retrieved.
- */
- private int wordpointer;
-
- /**
- * Number (0-31, from MSB to LSB) of next bit for get_bits()
- */
- private int bitindex;
-
- /**
- * The current specified syncword
- */
- private int syncword;
-
- /**
- * Audio header position in stream.
- */
- private int header_pos = 0;
-
- /**
- *
- */
- private boolean single_ch_mode;
- //private int current_frame_number;
- //private int last_frame_number;
-
- private final int bitmask[] = {0, // dummy
- 0x00000001, 0x00000003, 0x00000007, 0x0000000F,
- 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF,
- 0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF,
- 0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF,
- 0x0001FFFF };
-
- private final PushbackInputStream source;
-
- private final Header header = new Header();
-
- private final byte syncbuf[] = new byte[4];
-
- private Crc16[] crc = new Crc16[1];
-
- private byte[] rawid3v2 = null;
-
- private boolean firstframe = true;
-
-
- /**
- * Construct a IBitstream that reads data from a
- * given InputStream.
- *
- * @param in The InputStream to read from.
- */
- public Bitstream(InputStream in)
- {
- if (in==null) throw new NullPointerException("in");
- in = new BufferedInputStream(in);
- loadID3v2(in);
- firstframe = true;
- //source = new PushbackInputStream(in, 1024);
- source = new PushbackInputStream(in, BUFFER_INT_SIZE*4);
-
- closeFrame();
- //current_frame_number = -1;
- //last_frame_number = -1;
- }
-
- /**
- * Return position of the first audio header.
- * @return size of ID3v2 tag frames.
- */
- public int header_pos()
- {
- return header_pos;
- }
-
- /**
- * Load ID3v2 frames.
- * @param in MP3 InputStream.
- * @author JavaZOOM
- */
- private void loadID3v2(InputStream in)
- {
- int size = -1;
- try
- {
- // Read ID3v2 header (10 bytes).
- in.mark(10);
- size = readID3v2Header(in);
- header_pos = size;
- }
- catch (IOException e)
- {}
- finally
- {
- try
- {
- // Unread ID3v2 header (10 bytes).
- in.reset();
- }
- catch (IOException e)
- {}
- }
- // Load ID3v2 tags.
- try
- {
- if (size > 0)
- {
- rawid3v2 = new byte[size];
- in.read(rawid3v2,0,rawid3v2.length);
- }
- }
- catch (IOException e)
- {}
- }
-
- /**
- * Parse ID3v2 tag header to find out size of ID3v2 frames.
- * @param in MP3 InputStream
- * @return size of ID3v2 frames + header
- * @throws IOException
- * @author JavaZOOM
- */
- private int readID3v2Header(InputStream in) throws IOException
- {
- byte[] id3header = new byte[4];
- int size = -10;
- in.read(id3header,0,3);
- // Look for ID3v2
- if ( (id3header[0]=='I') && (id3header[1]=='D') && (id3header[2]=='3'))
- {
- in.read(id3header,0,3);
- int majorVersion = id3header[0];
- int revision = id3header[1];
- in.read(id3header,0,4);
- size = (int) (id3header[0] << 21) + (id3header[1] << 14) + (id3header[2] << 7) + (id3header[3]);
- }
- return (size+10);
- }
-
- /**
- * Return raw ID3v2 frames + header.
- * @return ID3v2 InputStream or null if ID3v2 frames are not available.
- */
- public InputStream getRawID3v2()
- {
- if (rawid3v2 == null) return null;
- else
- {
- ByteArrayInputStream bain = new ByteArrayInputStream(rawid3v2);
- return bain;
- }
- }
-
- /**
- * Close the Bitstream.
- * @throws BitstreamException
- */
- public void close() throws BitstreamException
- {
- try
- {
- source.close();
- }
- catch (IOException ex)
- {
- throw newBitstreamException(STREAM_ERROR, ex);
- }
- }
-
- /**
- * Reads and parses the next frame from the input source.
- * @return the Header describing details of the frame read,
- * or null if the end of the stream has been reached.
- */
- public Header readFrame() throws BitstreamException
- {
- Header result = null;
- try
- {
- result = readNextFrame();
- // E.B, Parse VBR (if any) first frame.
- if (firstframe == true)
- {
- result.parseVBR(frame_bytes);
- firstframe = false;
- }
- }
- catch (BitstreamException ex)
- {
- if ((ex.getErrorCode()==INVALIDFRAME))
- {
- // Try to skip this frame.
- //System.out.println("INVALIDFRAME");
- try
- {
- closeFrame();
- result = readNextFrame();
- }
- catch (BitstreamException e)
- {
- if ((e.getErrorCode()!=STREAM_EOF))
- {
- // wrap original exception so stack trace is maintained.
- throw newBitstreamException(e.getErrorCode(), e);
- }
- }
- }
- else if ((ex.getErrorCode()!=STREAM_EOF))
- {
- // wrap original exception so stack trace is maintained.
- throw newBitstreamException(ex.getErrorCode(), ex);
- }
- }
- return result;
- }
-
- /**
- * Read next MP3 frame.
- * @return MP3 frame header.
- * @throws BitstreamException
- */
- private Header readNextFrame() throws BitstreamException
- {
- if (framesize == -1)
- {
- nextFrame();
- }
- return header;
- }
-
-
- /**
- * Read next MP3 frame.
- * @throws BitstreamException
- */
- private void nextFrame() throws BitstreamException
- {
- // entire frame is read by the header class.
- header.read_header(this, crc);
- }
-
- /**
- * Unreads the bytes read from the frame.
- * @throws BitstreamException
- */
- // REVIEW: add new error codes for this.
- public void unreadFrame() throws BitstreamException
- {
- if (wordpointer==-1 && bitindex==-1 && (framesize>0))
- {
- try
- {
- source.unread(frame_bytes, 0, framesize);
- }
- catch (IOException ex)
- {
- throw newBitstreamException(STREAM_ERROR);
- }
- }
- }
-
- /**
- * Close MP3 frame.
- */
- public void closeFrame()
- {
- framesize = -1;
- wordpointer = -1;
- bitindex = -1;
- }
-
- /**
- * Determines if the next 4 bytes of the stream represent a
- * frame header.
- */
- public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException
- {
- int read = readBytes(syncbuf, 0, 4);
- int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF);
-
- try
- {
- source.unread(syncbuf, 0, read);
- }
- catch (IOException ex)
- {
- }
-
- boolean sync = false;
- switch (read)
- {
- case 0:
- sync = true;
- break;
- case 4:
- sync = isSyncMark(headerstring, syncmode, syncword);
- break;
- }
-
- return sync;
- }
-
-
- // REVIEW: this class should provide inner classes to
- // parse the frame contents. Eventually, readBits will
- // be removed.
- public int readBits(int n)
- {
- return get_bits(n);
- }
-
- public int readCheckedBits(int n)
- {
- // REVIEW: implement CRC check.
- return get_bits(n);
- }
-
- protected BitstreamException newBitstreamException(int errorcode)
- {
- return new BitstreamException(errorcode, null);
- }
- protected BitstreamException newBitstreamException(int errorcode, Throwable throwable)
- {
- return new BitstreamException(errorcode, throwable);
- }
-
- /**
- * Get next 32 bits from bitstream.
- * They are stored in the headerstring.
- * syncmod allows Synchro flag ID
- * The returned value is False at the end of stream.
- */
-
- int syncHeader(byte syncmode) throws BitstreamException
- {
- boolean sync;
- int headerstring;
- // read additional 2 bytes
- int bytesRead = readBytes(syncbuf, 0, 3);
-
- if (bytesRead!=3) throw newBitstreamException(STREAM_EOF, null);
-
- headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2] << 0) & 0x000000FF);
-
- do
- {
- headerstring <<= 8;
-
- if (readBytes(syncbuf, 3, 1)!=1)
- throw newBitstreamException(STREAM_EOF, null);
-
- headerstring |= (syncbuf[3] & 0x000000FF);
-
- sync = isSyncMark(headerstring, syncmode, syncword);
- }
- while (!sync);
-
- //current_frame_number++;
- //if (last_frame_number < current_frame_number) last_frame_number = current_frame_number;
-
- return headerstring;
- }
-
- public boolean isSyncMark(int headerstring, int syncmode, int word)
- {
- boolean sync = false;
-
- if (syncmode == INITIAL_SYNC)
- {
- //sync = ((headerstring & 0xFFF00000) == 0xFFF00000);
- sync = ((headerstring & 0xFFE00000) == 0xFFE00000); // SZD: MPEG 2.5
- }
- else
- {
- sync = ((headerstring & 0xFFF80C00) == word) &&
- (((headerstring & 0x000000C0) == 0x000000C0) == single_ch_mode);
- }
-
- // filter out invalid sample rate
- if (sync)
- sync = (((headerstring >>> 10) & 3)!=3);
- // filter out invalid layer
- if (sync)
- sync = (((headerstring >>> 17) & 3)!=0);
- // filter out invalid version
- if (sync)
- sync = (((headerstring >>> 19) & 3)!=1);
-
- return sync;
- }
-
- /**
- * Reads the data for the next frame. The frame is not parsed
- * until parse frame is called.
- */
- int read_frame_data(int bytesize) throws BitstreamException
- {
- int numread = 0;
- numread = readFully(frame_bytes, 0, bytesize);
- framesize = bytesize;
- wordpointer = -1;
- bitindex = -1;
- return numread;
- }
-
- /**
- * Parses the data previously read with read_frame_data().
- */
- void parse_frame() throws BitstreamException
- {
- // Convert Bytes read to int
- int b=0;
- byte[] byteread = frame_bytes;
- int bytesize = framesize;
-
- // Check ID3v1 TAG (True only if last frame).
- //for (int t=0;t<(byteread.length)-2;t++)
- //{
- // if ((byteread[t]=='T') && (byteread[t+1]=='A') && (byteread[t+2]=='G'))
- // {
- // System.out.println("ID3v1 detected at offset "+t);
- // throw newBitstreamException(INVALIDFRAME, null);
- // }
- //}
-
- for (int k=0;k<bytesize;k=k+4)
- {
- int convert = 0;
- byte b0 = 0;
- byte b1 = 0;
- byte b2 = 0;
- byte b3 = 0;
- b0 = byteread[k];
- if (k+1<bytesize) b1 = byteread[k+1];
- if (k+2<bytesize) b2 = byteread[k+2];
- if (k+3<bytesize) b3 = byteread[k+3];
- framebuffer[b++] = ((b0 << 24) &0xFF000000) | ((b1 << 16) & 0x00FF0000) | ((b2 << 8) & 0x0000FF00) | (b3 & 0x000000FF);
- }
- wordpointer = 0;
- bitindex = 0;
- }
-
- /**
- * Read bits from buffer into the lower bits of an unsigned int.
- * The LSB contains the latest read bit of the stream.
- * (1 <= number_of_bits <= 16)
- */
- public int get_bits(int number_of_bits)
- {
- int returnvalue = 0;
- int sum = bitindex + number_of_bits;
-
- // E.B
- // There is a problem here, wordpointer could be -1 ?!
- if (wordpointer < 0) wordpointer = 0;
- // E.B : End.
-
- if (sum <= 32)
- {
- // all bits contained in *wordpointer
- returnvalue = (framebuffer[wordpointer] >>> (32 - sum)) & bitmask[number_of_bits];
- // returnvalue = (wordpointer[0] >> (32 - sum)) & bitmask[number_of_bits];
- if ((bitindex += number_of_bits) == 32)
- {
- bitindex = 0;
- wordpointer++; // added by me!
- }
- return returnvalue;
- }
-
- // E.B : Check that ?
- //((short[])&returnvalue)[0] = ((short[])wordpointer + 1)[0];
- //wordpointer++; // Added by me!
- //((short[])&returnvalue + 1)[0] = ((short[])wordpointer)[0];
- int Right = (framebuffer[wordpointer] & 0x0000FFFF);
- wordpointer++;
- int Left = (framebuffer[wordpointer] & 0xFFFF0000);
- returnvalue = ((Right << 16) & 0xFFFF0000) | ((Left >>> 16)& 0x0000FFFF);
-
- returnvalue >>>= 48 - sum; // returnvalue >>= 16 - (number_of_bits - (32 - bitindex))
- returnvalue &= bitmask[number_of_bits];
- bitindex = sum - 32;
- return returnvalue;
-}
-
- /**
- * Set the word we want to sync the header to.
- * In Big-Endian byte order
- */
- void set_syncword(int syncword0)
- {
- syncword = syncword0 & 0xFFFFFF3F;
- single_ch_mode = ((syncword0 & 0x000000C0) == 0x000000C0);
- }
- /**
- * Reads the exact number of bytes from the source
- * input stream into a byte array.
- *
- * @param b The byte array to read the specified number
- * of bytes into.
- * @param offs The index in the array where the first byte
- * read should be stored.
- * @param len the number of bytes to read.
- *
- * @exception BitstreamException is thrown if the specified
- * number of bytes could not be read from the stream.
- */
- private int readFully(byte[] b, int offs, int len)
- throws BitstreamException
- {
- int nRead = 0;
- try
- {
- while (len > 0)
- {
- int bytesread = source.read(b, offs, len);
- if (bytesread == -1)
- {
- while (len-->0)
- {
- b[offs++] = 0;
- }
- break;
- //throw newBitstreamException(UNEXPECTED_EOF, new EOFException());
- }
- nRead = nRead + bytesread;
- offs += bytesread;
- len -= bytesread;
- }
- }
- catch (IOException ex)
- {
- throw newBitstreamException(STREAM_ERROR, ex);
- }
- return nRead;
- }
-
- /**
- * Simlar to readFully, but doesn't throw exception when
- * EOF is reached.
- */
- private int readBytes(byte[] b, int offs, int len)
- throws BitstreamException
- {
- int totalBytesRead = 0;
- try
- {
- while (len > 0)
- {
- int bytesread = source.read(b, offs, len);
- if (bytesread == -1)
- {
- break;
- }
- totalBytesRead += bytesread;
- offs += bytesread;
- len -= bytesread;
- }
- }
- catch (IOException ex)
- {
- throw newBitstreamException(STREAM_ERROR, ex);
- }
- return totalBytesRead;
- }
-}
diff --git a/songdbj/javazoom/jl/decoder/BitstreamErrors.java b/songdbj/javazoom/jl/decoder/BitstreamErrors.java
deleted file mode 100644
index 2bdee6d797..0000000000
--- a/songdbj/javazoom/jl/decoder/BitstreamErrors.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 11/17/04 INVALIDFRAME code added. javalayer@javazoom.net
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * This interface describes all error codes that can be thrown
- * in <code>BistreamException</code>s.
- *
- * @see BitstreamException
- *
- * @author MDM 12/12/99
- * @since 0.0.6
- */
-
-public interface BitstreamErrors extends JavaLayerErrors
-{
-
- /**
- * An undeterminable error occurred.
- */
- static public final int UNKNOWN_ERROR = BITSTREAM_ERROR + 0;
-
- /**
- * The header describes an unknown sample rate.
- */
- static public final int UNKNOWN_SAMPLE_RATE = BITSTREAM_ERROR + 1;
-
- /**
- * A problem occurred reading from the stream.
- */
- static public final int STREAM_ERROR = BITSTREAM_ERROR + 2;
-
- /**
- * The end of the stream was reached prematurely.
- */
- static public final int UNEXPECTED_EOF = BITSTREAM_ERROR + 3;
-
- /**
- * The end of the stream was reached.
- */
- static public final int STREAM_EOF = BITSTREAM_ERROR + 4;
-
- /**
- * Frame data are missing.
- */
- static public final int INVALIDFRAME = BITSTREAM_ERROR + 5;
-
- /**
- *
- */
- static public final int BITSTREAM_LAST = 0x1ff;
-
-}
diff --git a/songdbj/javazoom/jl/decoder/BitstreamException.java b/songdbj/javazoom/jl/decoder/BitstreamException.java
deleted file mode 100644
index 99faa8962d..0000000000
--- a/songdbj/javazoom/jl/decoder/BitstreamException.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Instances of <code>BitstreamException</code> are thrown
- * when operations on a <code>Bitstream</code> fail.
- * <p>
- * The exception provides details of the exception condition
- * in two ways:
- * <ol><li>
- * as an error-code describing the nature of the error
- * </li><br></br><li>
- * as the <code>Throwable</code> instance, if any, that was thrown
- * indicating that an exceptional condition has occurred.
- * </li></ol></p>
- *
- * @since 0.0.6
- * @author MDM 12/12/99
- */
-
-public class BitstreamException extends JavaLayerException
- implements BitstreamErrors
-{
- private int errorcode = UNKNOWN_ERROR;
-
- public BitstreamException(String msg, Throwable t)
- {
- super(msg, t);
- }
-
- public BitstreamException(int errorcode, Throwable t)
- {
- this(getErrorString(errorcode), t);
- this.errorcode = errorcode;
- }
-
- public int getErrorCode()
- {
- return errorcode;
- }
-
-
- static public String getErrorString(int errorcode)
- {
- // REVIEW: use resource bundle to map error codes
- // to locale-sensitive strings.
-
- return "Bitstream errorcode "+Integer.toHexString(errorcode);
- }
-
-
-}
diff --git a/songdbj/javazoom/jl/decoder/Control.java b/songdbj/javazoom/jl/decoder/Control.java
deleted file mode 100644
index 080ed5215e..0000000000
--- a/songdbj/javazoom/jl/decoder/Control.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Work in progress.
- */
-
-public interface Control
-{
-
- /**
- * Starts playback of the media presented by this control.
- */
- public void start();
-
- /**
- * Stops playback of the media presented by this control.
- */
- public void stop();
-
- public boolean isPlaying();
-
- public void pause();
-
-
- public boolean isRandomAccess();
-
- /**
- * Retrieves the current position.
- */
- public double getPosition();
-
- /**
- *
- */
- public void setPosition(double d);
-
-
-}
diff --git a/songdbj/javazoom/jl/decoder/Crc16.java b/songdbj/javazoom/jl/decoder/Crc16.java
deleted file mode 100644
index c35cc19341..0000000000
--- a/songdbj/javazoom/jl/decoder/Crc16.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 11/19/04 : 1.0 moved to LGPL.
- *
- * 02/12/99 : Java Conversion by E.B , javalayer@javazoom.net
- *
- * @(#) crc.h 1.5, last edit: 6/15/94 16:55:32
- * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
- * @(#) Berlin University of Technology
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-package javazoom.jl.decoder;
-
-/**
- * 16-Bit CRC checksum
- */
-public final class Crc16
-{
- private static short polynomial=(short)0x8005;
- private short crc;
-
- /**
- * Dummy Constructor
- */
- public Crc16()
- {
- crc = (short) 0xFFFF;
- }
-
- /**
- * Feed a bitstring to the crc calculation (0 < length <= 32).
- */
- public void add_bits (int bitstring, int length)
- {
- int bitmask = 1 << (length - 1);
- do
- if (((crc & 0x8000) == 0) ^ ((bitstring & bitmask) == 0 ))
- {
- crc <<= 1;
- crc ^= polynomial;
- }
- else
- crc <<= 1;
- while ((bitmask >>>= 1) != 0);
- }
-
- /**
- * Return the calculated checksum.
- * Erase it for next calls to add_bits().
- */
- public short checksum()
- {
- short sum = crc;
- crc = (short) 0xFFFF;
- return sum;
- }
-}
diff --git a/songdbj/javazoom/jl/decoder/Decoder.java b/songdbj/javazoom/jl/decoder/Decoder.java
deleted file mode 100644
index 076f9dea27..0000000000
--- a/songdbj/javazoom/jl/decoder/Decoder.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 01/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * The <code>Decoder</code> class encapsulates the details of
- * decoding an MPEG audio frame.
- *
- * @author MDM
- * @version 0.0.7 12/12/99
- * @since 0.0.5
- */
-public class Decoder implements DecoderErrors
-{
- static private final Params DEFAULT_PARAMS = new Params();
-
- /**
- * The Bistream from which the MPEG audio frames are read.
- */
- //private Bitstream stream;
-
- /**
- * The Obuffer instance that will receive the decoded
- * PCM samples.
- */
- private Obuffer output;
-
- /**
- * Synthesis filter for the left channel.
- */
- private SynthesisFilter filter1;
-
- /**
- * Sythesis filter for the right channel.
- */
- private SynthesisFilter filter2;
-
- /**
- * The decoder used to decode layer III frames.
- */
- private LayerIIIDecoder l3decoder;
- private LayerIIDecoder l2decoder;
- private LayerIDecoder l1decoder;
-
- private int outputFrequency;
- private int outputChannels;
-
- private Equalizer equalizer = new Equalizer();
-
- private Params params;
-
- private boolean initialized;
-
-
- /**
- * Creates a new <code>Decoder</code> instance with default
- * parameters.
- */
-
- public Decoder()
- {
- this(null);
- }
-
- /**
- * Creates a new <code>Decoder</code> instance with default
- * parameters.
- *
- * @param params The <code>Params</code> instance that describes
- * the customizable aspects of the decoder.
- */
- public Decoder(Params params0)
- {
- if (params0==null)
- params0 = DEFAULT_PARAMS;
-
- params = params0;
-
- Equalizer eq = params.getInitialEqualizerSettings();
- if (eq!=null)
- {
- equalizer.setFrom(eq);
- }
- }
-
- static public Params getDefaultParams()
- {
- return (Params)DEFAULT_PARAMS.clone();
- }
-
- public void setEqualizer(Equalizer eq)
- {
- if (eq==null)
- eq = Equalizer.PASS_THRU_EQ;
-
- equalizer.setFrom(eq);
-
- float[] factors = equalizer.getBandFactors();
-
- if (filter1!=null)
- filter1.setEQ(factors);
-
- if (filter2!=null)
- filter2.setEQ(factors);
- }
-
- /**
- * Decodes one frame from an MPEG audio bitstream.
- *
- * @param header The header describing the frame to decode.
- * @param bitstream The bistream that provides the bits for te body of the frame.
- *
- * @return A SampleBuffer containing the decoded samples.
- */
- public Obuffer decodeFrame(Header header, Bitstream stream)
- throws DecoderException
- {
- if (!initialized)
- {
- initialize(header);
- }
-
- int layer = header.layer();
-
- output.clear_buffer();
-
- FrameDecoder decoder = retrieveDecoder(header, stream, layer);
-
- decoder.decodeFrame();
-
- output.write_buffer(1);
-
- return output;
- }
-
- /**
- * Changes the output buffer. This will take effect the next time
- * decodeFrame() is called.
- */
- public void setOutputBuffer(Obuffer out)
- {
- output = out;
- }
-
- /**
- * Retrieves the sample frequency of the PCM samples output
- * by this decoder. This typically corresponds to the sample
- * rate encoded in the MPEG audio stream.
- *
- * @param the sample rate (in Hz) of the samples written to the
- * output buffer when decoding.
- */
- public int getOutputFrequency()
- {
- return outputFrequency;
- }
-
- /**
- * Retrieves the number of channels of PCM samples output by
- * this decoder. This usually corresponds to the number of
- * channels in the MPEG audio stream, although it may differ.
- *
- * @return The number of output channels in the decoded samples: 1
- * for mono, or 2 for stereo.
- *
- */
- public int getOutputChannels()
- {
- return outputChannels;
- }
-
- /**
- * Retrieves the maximum number of samples that will be written to
- * the output buffer when one frame is decoded. This can be used to
- * help calculate the size of other buffers whose size is based upon
- * the number of samples written to the output buffer. NB: this is
- * an upper bound and fewer samples may actually be written, depending
- * upon the sample rate and number of channels.
- *
- * @return The maximum number of samples that are written to the
- * output buffer when decoding a single frame of MPEG audio.
- */
- public int getOutputBlockSize()
- {
- return Obuffer.OBUFFERSIZE;
- }
-
-
- protected DecoderException newDecoderException(int errorcode)
- {
- return new DecoderException(errorcode, null);
- }
-
- protected DecoderException newDecoderException(int errorcode, Throwable throwable)
- {
- return new DecoderException(errorcode, throwable);
- }
-
- protected FrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer)
- throws DecoderException
- {
- FrameDecoder decoder = null;
-
- // REVIEW: allow channel output selection type
- // (LEFT, RIGHT, BOTH, DOWNMIX)
- switch (layer)
- {
- case 3:
- if (l3decoder==null)
- {
- l3decoder = new LayerIIIDecoder(stream,
- header, filter1, filter2,
- output, OutputChannels.BOTH_CHANNELS);
- }
-
- decoder = l3decoder;
- break;
- case 2:
- if (l2decoder==null)
- {
- l2decoder = new LayerIIDecoder();
- l2decoder.create(stream,
- header, filter1, filter2,
- output, OutputChannels.BOTH_CHANNELS);
- }
- decoder = l2decoder;
- break;
- case 1:
- if (l1decoder==null)
- {
- l1decoder = new LayerIDecoder();
- l1decoder.create(stream,
- header, filter1, filter2,
- output, OutputChannels.BOTH_CHANNELS);
- }
- decoder = l1decoder;
- break;
- }
-
- if (decoder==null)
- {
- throw newDecoderException(UNSUPPORTED_LAYER, null);
- }
-
- return decoder;
- }
-
- private void initialize(Header header)
- throws DecoderException
- {
-
- // REVIEW: allow customizable scale factor
- float scalefactor = 32700.0f;
-
- int mode = header.mode();
- int layer = header.layer();
- int channels = mode==Header.SINGLE_CHANNEL ? 1 : 2;
-
-
- // set up output buffer if not set up by client.
- if (output==null)
- output = new SampleBuffer(header.frequency(), channels);
-
- float[] factors = equalizer.getBandFactors();
- filter1 = new SynthesisFilter(0, scalefactor, factors);
-
- // REVIEW: allow mono output for stereo
- if (channels==2)
- filter2 = new SynthesisFilter(1, scalefactor, factors);
-
- outputChannels = channels;
- outputFrequency = header.frequency();
-
- initialized = true;
- }
-
- /**
- * The <code>Params</code> class presents the customizable
- * aspects of the decoder.
- * <p>
- * Instances of this class are not thread safe.
- */
- public static class Params implements Cloneable
- {
- private OutputChannels outputChannels = OutputChannels.BOTH;
-
- private Equalizer equalizer = new Equalizer();
-
- public Params()
- {
- }
-
- public Object clone()
- {
- try
- {
- return super.clone();
- }
- catch (CloneNotSupportedException ex)
- {
- throw new InternalError(this+": "+ex);
- }
- }
-
- public void setOutputChannels(OutputChannels out)
- {
- if (out==null)
- throw new NullPointerException("out");
-
- outputChannels = out;
- }
-
- public OutputChannels getOutputChannels()
- {
- return outputChannels;
- }
-
- /**
- * Retrieves the equalizer settings that the decoder's equalizer
- * will be initialized from.
- * <p>
- * The <code>Equalizer</code> instance returned
- * cannot be changed in real time to affect the
- * decoder output as it is used only to initialize the decoders
- * EQ settings. To affect the decoder's output in realtime,
- * use the Equalizer returned from the getEqualizer() method on
- * the decoder.
- *
- * @return The <code>Equalizer</code> used to initialize the
- * EQ settings of the decoder.
- */
- public Equalizer getInitialEqualizerSettings()
- {
- return equalizer;
- }
-
- };
-}
-
diff --git a/songdbj/javazoom/jl/decoder/DecoderErrors.java b/songdbj/javazoom/jl/decoder/DecoderErrors.java
deleted file mode 100644
index 66c1935051..0000000000
--- a/songdbj/javazoom/jl/decoder/DecoderErrors.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 01/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * This interface provides constants describing the error
- * codes used by the Decoder to indicate errors.
- *
- * @author MDM
- */
-public interface DecoderErrors extends JavaLayerErrors
-{
-
- static public final int UNKNOWN_ERROR = DECODER_ERROR + 0;
-
- /**
- * Layer not supported by the decoder.
- */
- static public final int UNSUPPORTED_LAYER = DECODER_ERROR + 1;
-}
diff --git a/songdbj/javazoom/jl/decoder/DecoderException.java b/songdbj/javazoom/jl/decoder/DecoderException.java
deleted file mode 100644
index b75710870f..0000000000
--- a/songdbj/javazoom/jl/decoder/DecoderException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 01/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * The <code>DecoderException</code> represents the class of
- * errors that can occur when decoding MPEG audio.
- *
- * @author MDM
- */
-public class DecoderException extends JavaLayerException
- implements DecoderErrors
-{
- private int errorcode = UNKNOWN_ERROR;
-
- public DecoderException(String msg, Throwable t)
- {
- super(msg, t);
- }
-
- public DecoderException(int errorcode, Throwable t)
- {
- this(getErrorString(errorcode), t);
- this.errorcode = errorcode;
- }
-
- public int getErrorCode()
- {
- return errorcode;
- }
-
-
- static public String getErrorString(int errorcode)
- {
- // REVIEW: use resource file to map error codes
- // to locale-sensitive strings.
-
- return "Decoder errorcode "+Integer.toHexString(errorcode);
- }
-
-
-}
-
diff --git a/songdbj/javazoom/jl/decoder/Equalizer.java b/songdbj/javazoom/jl/decoder/Equalizer.java
deleted file mode 100644
index 57545a939d..0000000000
--- a/songdbj/javazoom/jl/decoder/Equalizer.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-
-package javazoom.jl.decoder;
-
-/**
- * The <code>Equalizer</code> class can be used to specify
- * equalization settings for the MPEG audio decoder.
- * <p>
- * The equalizer consists of 32 band-pass filters.
- * Each band of the equalizer can take on a fractional value between
- * -1.0 and +1.0.
- * At -1.0, the input signal is attenuated by 6dB, at +1.0 the signal is
- * amplified by 6dB.
- *
- * @see Decoder
- *
- * @author MDM
- */
-public final class Equalizer
-{
- /**
- * Equalizer setting to denote that a given band will not be
- * present in the output signal.
- */
- static public final float BAND_NOT_PRESENT = Float.NEGATIVE_INFINITY;
-
- static public final Equalizer PASS_THRU_EQ = new Equalizer();
-
- private static final int BANDS = 32;
-
- private final float[] settings = new float[BANDS];
-
- /**
- * Creates a new <code>Equalizer</code> instance.
- */
- public Equalizer()
- {
- }
-
-// private Equalizer(float b1, float b2, float b3, float b4, float b5,
-// float b6, float b7, float b8, float b9, float b10, float b11,
-// float b12, float b13, float b14, float b15, float b16,
-// float b17, float b18, float b19, float b20);
-
- public Equalizer(float[] settings)
- {
- setFrom(settings);
- }
-
- public Equalizer(EQFunction eq)
- {
- setFrom(eq);
- }
-
- public void setFrom(float[] eq)
- {
- reset();
- int max = (eq.length > BANDS) ? BANDS : eq.length;
-
- for (int i=0; i<max; i++)
- {
- settings[i] = limit(eq[i]);
- }
- }
-
- public void setFrom(EQFunction eq)
- {
- reset();
- int max = BANDS;
-
- for (int i=0; i<max; i++)
- {
- settings[i] = limit(eq.getBand(i));
- }
- }
-
- /**
- * Sets the bands of this equalizer to the value the bands of
- * another equalizer. Bands that are not present in both equalizers are ignored.
- */
- public void setFrom(Equalizer eq)
- {
- if (eq!=this)
- {
- setFrom(eq.settings);
- }
- }
-
-
-
-
- /**
- * Sets all bands to 0.0
- */
- public void reset()
- {
- for (int i=0; i<BANDS; i++)
- {
- settings[i] = 0.0f;
- }
- }
-
-
- /**
- * Retrieves the number of bands present in this equalizer.
- */
- public int getBandCount()
- {
- return settings.length;
- }
-
- public float setBand(int band, float neweq)
- {
- float eq = 0.0f;
-
- if ((band>=0) && (band<BANDS))
- {
- eq = settings[band];
- settings[band] = limit(neweq);
- }
-
- return eq;
- }
-
-
-
- /**
- * Retrieves the eq setting for a given band.
- */
- public float getBand(int band)
- {
- float eq = 0.0f;
-
- if ((band>=0) && (band<BANDS))
- {
- eq = settings[band];
- }
-
- return eq;
- }
-
- private float limit(float eq)
- {
- if (eq==BAND_NOT_PRESENT)
- return eq;
- if (eq > 1.0f)
- return 1.0f;
- if (eq < -1.0f)
- return -1.0f;
-
- return eq;
- }
-
- /**
- * Retrieves an array of floats whose values represent a
- * scaling factor that can be applied to linear samples
- * in each band to provide the equalization represented by
- * this instance.
- *
- * @return an array of factors that can be applied to the
- * subbands.
- */
- float[] getBandFactors()
- {
- float[] factors = new float[BANDS];
- for (int i=0, maxCount=BANDS; i<maxCount; i++)
- {
- factors[i] = getBandFactor(settings[i]);
- }
-
- return factors;
- }
-
- /**
- * Converts an equalizer band setting to a sample factor.
- * The factor is determined by the function f = 2^n where
- * n is the equalizer band setting in the range [-1.0,1.0].
- *
- */
- float getBandFactor(float eq)
- {
- if (eq==BAND_NOT_PRESENT)
- return 0.0f;
-
- float f = (float)Math.pow(2.0, eq);
- return f;
- }
-
-
- static abstract public class EQFunction
- {
- /**
- * Returns the setting of a band in the equalizer.
- *
- * @param band The index of the band to retrieve the setting
- * for.
- *
- * @return the setting of the specified band. This is a value between
- * -1 and +1.
- */
- public float getBand(int band)
- {
- return 0.0f;
- }
-
- }
-
-}
diff --git a/songdbj/javazoom/jl/decoder/FrameDecoder.java b/songdbj/javazoom/jl/decoder/FrameDecoder.java
deleted file mode 100644
index eec6ac6a22..0000000000
--- a/songdbj/javazoom/jl/decoder/FrameDecoder.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Implementations of FrameDecoder are responsible for decoding
- * an MPEG audio frame.
- *
- */
-//REVIEW: the interface currently is too thin. There should be
-// methods to specify the output buffer, the synthesis filters and
-// possibly other objects used by the decoder.
-public interface FrameDecoder
-{
- /**
- * Decodes one frame of MPEG audio.
- */
- public void decodeFrame();
-
-}
diff --git a/songdbj/javazoom/jl/decoder/Header.java b/songdbj/javazoom/jl/decoder/Header.java
deleted file mode 100644
index e85fe19f64..0000000000
--- a/songdbj/javazoom/jl/decoder/Header.java
+++ /dev/null
@@ -1,762 +0,0 @@
-/*
- * 11/19/04 : 1.0 moved to LGPL.
- * VBRI header support added, E.B javalayer@javazoom.net
- *
- * 12/04/03 : VBR (XING) header support added, E.B javalayer@javazoom.net
- *
- * 02/13/99 : Java Conversion by JavaZOOM , E.B javalayer@javazoom.net
- *
- * Declarations for MPEG header class
- * A few layer III, MPEG-2 LSF, and seeking modifications made by Jeff Tsay.
- * Last modified : 04/19/97
- *
- * @(#) header.h 1.7, last edit: 6/15/94 16:55:33
- * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
- * @(#) Berlin University of Technology
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-package javazoom.jl.decoder;
-
-/**
- * Class for extracting information from a frame header.
- */
-public final class Header
-{
- public static final int[][] frequencies =
- {{22050, 24000, 16000, 1},
- {44100, 48000, 32000, 1},
- {11025, 12000, 8000, 1}}; // SZD: MPEG25
-
- /**
- * Constant for MPEG-2 LSF version
- */
- public static final int MPEG2_LSF = 0;
- public static final int MPEG25_LSF = 2; // SZD
-
- /**
- * Constant for MPEG-1 version
- */
- public static final int MPEG1 = 1;
-
- public static final int STEREO = 0;
- public static final int JOINT_STEREO = 1;
- public static final int DUAL_CHANNEL = 2;
- public static final int SINGLE_CHANNEL = 3;
- public static final int FOURTYFOUR_POINT_ONE = 0;
- public static final int FOURTYEIGHT=1;
- public static final int THIRTYTWO=2;
-
- private int h_layer, h_protection_bit, h_bitrate_index,
- h_padding_bit, h_mode_extension;
- private int h_version;
- private int h_mode;
- private int h_sample_frequency;
- private int h_number_of_subbands, h_intensity_stereo_bound;
- private boolean h_copyright, h_original;
- // VBR support added by E.B
- private double[] h_vbr_time_per_frame = {-1, 384, 1152, 1152};
- private boolean h_vbr;
- private int h_vbr_frames;
- private int h_vbr_scale;
- private int h_vbr_bytes;
- private byte[] h_vbr_toc;
-
- private byte syncmode = Bitstream.INITIAL_SYNC;
- private Crc16 crc;
-
- public short checksum;
- public int framesize;
- public int nSlots;
-
- private int _headerstring = -1; // E.B
-
- Header()
- {
- }
- public String toString()
- {
- StringBuffer buffer = new StringBuffer(200);
- buffer.append("Layer ");
- buffer.append(layer_string());
- buffer.append(" frame ");
- buffer.append(mode_string());
- buffer.append(' ');
- buffer.append(version_string());
- if (!checksums())
- buffer.append(" no");
- buffer.append(" checksums");
- buffer.append(' ');
- buffer.append(sample_frequency_string());
- buffer.append(',');
- buffer.append(' ');
- buffer.append(bitrate_string());
-
- String s = buffer.toString();
- return s;
- }
-
- /**
- * Read a 32-bit header from the bitstream.
- */
- void read_header(Bitstream stream, Crc16[] crcp) throws BitstreamException
- {
- int headerstring;
- int channel_bitrate;
- boolean sync = false;
- do
- {
- headerstring = stream.syncHeader(syncmode);
- _headerstring = headerstring; // E.B
- if (syncmode == Bitstream.INITIAL_SYNC)
- {
- h_version = ((headerstring >>> 19) & 1);
- if (((headerstring >>> 20) & 1) == 0) // SZD: MPEG2.5 detection
- if (h_version == MPEG2_LSF)
- h_version = MPEG25_LSF;
- else
- throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);
- if ((h_sample_frequency = ((headerstring >>> 10) & 3)) == 3)
- {
- throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);
- }
- }
- h_layer = 4 - (headerstring >>> 17) & 3;
- h_protection_bit = (headerstring >>> 16) & 1;
- h_bitrate_index = (headerstring >>> 12) & 0xF;
- h_padding_bit = (headerstring >>> 9) & 1;
- h_mode = ((headerstring >>> 6) & 3);
- h_mode_extension = (headerstring >>> 4) & 3;
- if (h_mode == JOINT_STEREO)
- h_intensity_stereo_bound = (h_mode_extension << 2) + 4;
- else
- h_intensity_stereo_bound = 0; // should never be used
- if (((headerstring >>> 3) & 1) == 1)
- h_copyright = true;
- if (((headerstring >>> 2) & 1) == 1)
- h_original = true;
- // calculate number of subbands:
- if (h_layer == 1)
- h_number_of_subbands = 32;
- else
- {
- channel_bitrate = h_bitrate_index;
- // calculate bitrate per channel:
- if (h_mode != SINGLE_CHANNEL)
- if (channel_bitrate == 4)
- channel_bitrate = 1;
- else
- channel_bitrate -= 4;
- if ((channel_bitrate == 1) || (channel_bitrate == 2))
- if (h_sample_frequency == THIRTYTWO)
- h_number_of_subbands = 12;
- else
- h_number_of_subbands = 8;
- else if ((h_sample_frequency == FOURTYEIGHT) || ((channel_bitrate >= 3) && (channel_bitrate <= 5)))
- h_number_of_subbands = 27;
- else
- h_number_of_subbands = 30;
- }
- if (h_intensity_stereo_bound > h_number_of_subbands)
- h_intensity_stereo_bound = h_number_of_subbands;
- // calculate framesize and nSlots
- calculate_framesize();
- // read framedata:
- int framesizeloaded = stream.read_frame_data(framesize);
- if ((framesize >=0) && (framesizeloaded != framesize))
- {
- // Data loaded does not match to expected framesize,
- // it might be an ID3v1 TAG. (Fix 11/17/04).
- throw stream.newBitstreamException(Bitstream.INVALIDFRAME);
- }
- if (stream.isSyncCurrentPosition(syncmode))
- {
- if (syncmode == Bitstream.INITIAL_SYNC)
- {
- syncmode = Bitstream.STRICT_SYNC;
- stream.set_syncword(headerstring & 0xFFF80CC0);
- }
- sync = true;
- }
- else
- {
- stream.unreadFrame();
- }
- }
- while (!sync);
- stream.parse_frame();
- if (h_protection_bit == 0)
- {
- // frame contains a crc checksum
- checksum = (short) stream.get_bits(16);
- if (crc == null)
- crc = new Crc16();
- crc.add_bits(headerstring, 16);
- crcp[0] = crc;
- }
- else
- crcp[0] = null;
- if (h_sample_frequency == FOURTYFOUR_POINT_ONE)
- {
- /*
- if (offset == null)
- {
- int max = max_number_of_frames(stream);
- offset = new int[max];
- for(int i=0; i<max; i++) offset[i] = 0;
- }
- // E.B : Investigate more
- int cf = stream.current_frame();
- int lf = stream.last_frame();
- if ((cf > 0) && (cf == lf))
- {
- offset[cf] = offset[cf-1] + h_padding_bit;
- }
- else
- {
- offset[0] = h_padding_bit;
- }
- */
- }
- }
-
- /**
- * Parse frame to extract optionnal VBR frame.
- * @param firstframe
- * @author E.B (javalayer@javazoom.net)
- */
- void parseVBR(byte[] firstframe) throws BitstreamException
- {
- // Trying Xing header.
- String xing = "Xing";
- byte tmp[] = new byte[4];
- int offset = 0;
- // Compute "Xing" offset depending on MPEG version and channels.
- if (h_version == MPEG1)
- {
- if (h_mode == SINGLE_CHANNEL) offset=21-4;
- else offset=36-4;
- }
- else
- {
- if (h_mode == SINGLE_CHANNEL) offset=13-4;
- else offset = 21-4;
- }
- try
- {
- System.arraycopy(firstframe, offset, tmp, 0, 4);
- // Is "Xing" ?
- if (xing.equals(new String(tmp)))
- {
- //Yes.
- h_vbr = true;
- h_vbr_frames = -1;
- h_vbr_bytes = -1;
- h_vbr_scale = -1;
- h_vbr_toc = new byte[100];
-
- int length = 4;
- // Read flags.
- byte flags[] = new byte[4];
- System.arraycopy(firstframe, offset + length, flags, 0, flags.length);
- length += flags.length;
- // Read number of frames (if available).
- if ((flags[3] & (byte) (1 << 0)) != 0)
- {
- System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
- h_vbr_frames = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;
- length += 4;
- }
- // Read size (if available).
- if ((flags[3] & (byte) (1 << 1)) != 0)
- {
- System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
- h_vbr_bytes = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;
- length += 4;
- }
- // Read TOC (if available).
- if ((flags[3] & (byte) (1 << 2)) != 0)
- {
- System.arraycopy(firstframe, offset + length, h_vbr_toc, 0, h_vbr_toc.length);
- length += h_vbr_toc.length;
- }
- // Read scale (if available).
- if ((flags[3] & (byte) (1 << 3)) != 0)
- {
- System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
- h_vbr_scale = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;
- length += 4;
- }
- //System.out.println("VBR:"+xing+" Frames:"+ h_vbr_frames +" Size:"+h_vbr_bytes);
- }
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- throw new BitstreamException("XingVBRHeader Corrupted",e);
- }
-
- // Trying VBRI header.
- String vbri = "VBRI";
- offset = 36-4;
- try
- {
- System.arraycopy(firstframe, offset, tmp, 0, 4);
- // Is "VBRI" ?
- if (vbri.equals(new String(tmp)))
- {
- //Yes.
- h_vbr = true;
- h_vbr_frames = -1;
- h_vbr_bytes = -1;
- h_vbr_scale = -1;
- h_vbr_toc = new byte[100];
- // Bytes.
- int length = 4 + 6;
- System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
- h_vbr_bytes = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;
- length += 4;
- // Frames.
- System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
- h_vbr_frames = (tmp[0] << 24)&0xFF000000 | (tmp[1] << 16)&0x00FF0000 | (tmp[2] << 8)&0x0000FF00 | tmp[3]&0x000000FF;
- length += 4;
- //System.out.println("VBR:"+vbri+" Frames:"+ h_vbr_frames +" Size:"+h_vbr_bytes);
- // TOC
- // TODO
- }
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- throw new BitstreamException("VBRIVBRHeader Corrupted",e);
- }
- }
-
- // Functions to query header contents:
- /**
- * Returns version.
- */
- public int version() { return h_version; }
-
- /**
- * Returns Layer ID.
- */
- public int layer() { return h_layer; }
-
- /**
- * Returns bitrate index.
- */
- public int bitrate_index() { return h_bitrate_index; }
-
- /**
- * Returns Sample Frequency.
- */
- public int sample_frequency() { return h_sample_frequency; }
-
- /**
- * Returns Frequency.
- */
- public int frequency() {return frequencies[h_version][h_sample_frequency];}
-
- /**
- * Returns Mode.
- */
- public int mode() { return h_mode; }
-
- /**
- * Returns Protection bit.
- */
- public boolean checksums()
- {
- if (h_protection_bit == 0) return true;
- else return false;
- }
-
- /**
- * Returns Copyright.
- */
- public boolean copyright() { return h_copyright; }
-
- /**
- * Returns Original.
- */
- public boolean original() { return h_original; }
-
- /**
- * Return VBR.
- * @return true if VBR header is found
- */
- public boolean vbr() { return h_vbr; }
-
- /**
- * Return VBR scale.
- * @return scale of -1 if not available
- */
- public int vbr_scale() { return h_vbr_scale; }
-
- /**
- * Return VBR TOC.
- * @return vbr toc ot null if not available
- */
- public byte[] vbr_toc() { return h_vbr_toc; }
-
- /**
- * Returns Checksum flag.
- * Compares computed checksum with stream checksum.
- */
- public boolean checksum_ok () { return (checksum == crc.checksum()); }
-
- // Seeking and layer III stuff
- /**
- * Returns Layer III Padding bit.
- */
- public boolean padding()
- {
- if (h_padding_bit == 0) return false;
- else return true;
- }
-
- /**
- * Returns Slots.
- */
- public int slots() { return nSlots; }
-
- /**
- * Returns Mode Extension.
- */
- public int mode_extension() { return h_mode_extension; }
-
- // E.B -> private to public
- public static final int bitrates[][][] = {
- {{0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,
- 112000, 128000, 144000, 160000, 176000, 192000 ,224000, 256000, 0},
- {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
- 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0},
- {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
- 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0}},
-
- {{0 /*free format*/, 32000, 64000, 96000, 128000, 160000, 192000,
- 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000, 0},
- {0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,
- 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000, 0},
- {0 /*free format*/, 32000, 40000, 48000, 56000, 64000, 80000,
- 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 0}},
- // SZD: MPEG2.5
- {{0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,
- 112000, 128000, 144000, 160000, 176000, 192000 ,224000, 256000, 0},
- {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
- 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0},
- {0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
- 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0}},
-
- };
-
- // E.B -> private to public
- /**
- * Calculate Frame size.
- * Calculates framesize in bytes excluding header size.
- */
- public int calculate_framesize()
- {
-
- if (h_layer == 1)
- {
- framesize = (12 * bitrates[h_version][0][h_bitrate_index]) /
- frequencies[h_version][h_sample_frequency];
- if (h_padding_bit != 0 ) framesize++;
- framesize <<= 2; // one slot is 4 bytes long
- nSlots = 0;
- }
- else
- {
- framesize = (144 * bitrates[h_version][h_layer - 1][h_bitrate_index]) /
- frequencies[h_version][h_sample_frequency];
- if (h_version == MPEG2_LSF || h_version == MPEG25_LSF) framesize >>= 1; // SZD
- if (h_padding_bit != 0) framesize++;
- // Layer III slots
- if (h_layer == 3)
- {
- if (h_version == MPEG1)
- {
- nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ? 17 : 32) // side info size
- - ((h_protection_bit!=0) ? 0 : 2) // CRC size
- - 4; // header size
- }
- else
- { // MPEG-2 LSF, SZD: MPEG-2.5 LSF
- nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ? 9 : 17) // side info size
- - ((h_protection_bit!=0) ? 0 : 2) // CRC size
- - 4; // header size
- }
- }
- else
- {
- nSlots = 0;
- }
- }
- framesize -= 4; // subtract header size
- return framesize;
- }
-
- /**
- * Returns the maximum number of frames in the stream.
- * @param streamsize
- * @return number of frames
- */
- public int max_number_of_frames(int streamsize) // E.B
- {
- if (h_vbr == true) return h_vbr_frames;
- else
- {
- if ((framesize + 4 - h_padding_bit) == 0) return 0;
- else return(streamsize / (framesize + 4 - h_padding_bit));
- }
- }
-
- /**
- * Returns the maximum number of frames in the stream.
- * @param streamsize
- * @return number of frames
- */
- public int min_number_of_frames(int streamsize) // E.B
- {
- if (h_vbr == true) return h_vbr_frames;
- else
- {
- if ((framesize + 5 - h_padding_bit) == 0) return 0;
- else return(streamsize / (framesize + 5 - h_padding_bit));
- }
- }
-
-
- /**
- * Returns ms/frame.
- * @return milliseconds per frame
- */
- public float ms_per_frame() // E.B
- {
- if (h_vbr == true)
- {
- double tpf = h_vbr_time_per_frame[layer()] / frequency();
- if ((h_version == MPEG2_LSF) || (h_version == MPEG25_LSF)) tpf /= 2;
- return ((float) (tpf * 1000));
- }
- else
- {
- float ms_per_frame_array[][] = {{8.707483f, 8.0f, 12.0f},
- {26.12245f, 24.0f, 36.0f},
- {26.12245f, 24.0f, 36.0f}};
- return(ms_per_frame_array[h_layer-1][h_sample_frequency]);
- }
- }
-
- /**
- * Returns total ms.
- * @param streamsize
- * @return total milliseconds
- */
- public float total_ms(int streamsize) // E.B
- {
- return(max_number_of_frames(streamsize) * ms_per_frame());
- }
-
- /**
- * Returns synchronized header.
- */
- public int getSyncHeader() // E.B
- {
- return _headerstring;
- }
-
- // functions which return header informations as strings:
- /**
- * Return Layer version.
- */
- public String layer_string()
- {
- switch (h_layer)
- {
- case 1:
- return "I";
- case 2:
- return "II";
- case 3:
- return "III";
- }
- return null;
- }
-
- // E.B -> private to public
- public static final String bitrate_str[][][] = {
- {{"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",
- "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s",
- "160 kbit/s", "176 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s",
- "forbidden"},
- {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
- "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
- "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
- "forbidden"},
- {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
- "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
- "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
- "forbidden"}},
-
- {{"free format", "32 kbit/s", "64 kbit/s", "96 kbit/s", "128 kbit/s",
- "160 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s", "288 kbit/s",
- "320 kbit/s", "352 kbit/s", "384 kbit/s", "416 kbit/s", "448 kbit/s",
- "forbidden"},
- {"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",
- "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "160 kbit/s",
- "192 kbit/s", "224 kbit/s", "256 kbit/s", "320 kbit/s", "384 kbit/s",
- "forbidden"},
- {"free format", "32 kbit/s", "40 kbit/s", "48 kbit/s", "56 kbit/s",
- "64 kbit/s", "80 kbit/s" , "96 kbit/s", "112 kbit/s", "128 kbit/s",
- "160 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s", "320 kbit/s",
- "forbidden"}},
- // SZD: MPEG2.5
- {{"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",
- "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s",
- "160 kbit/s", "176 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s",
- "forbidden"},
- {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
- "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
- "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
- "forbidden"},
- {"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
- "40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
- "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
- "forbidden"}},
- };
-
- /**
- * Return Bitrate.
- * @return bitrate in bps
- */
- public String bitrate_string()
- {
- if (h_vbr == true)
- {
- return Integer.toString(bitrate()/1000)+" kb/s";
- }
- else return bitrate_str[h_version][h_layer - 1][h_bitrate_index];
- }
-
- /**
- * Return Bitrate.
- * @return bitrate in bps and average bitrate for VBR header
- */
- public int bitrate()
- {
- if (h_vbr == true)
- {
- return ((int) ((h_vbr_bytes * 8) / (ms_per_frame() * h_vbr_frames)))*1000;
- }
- else return bitrates[h_version][h_layer - 1][h_bitrate_index];
- }
-
- /**
- * Return Instant Bitrate.
- * Bitrate for VBR is not constant.
- * @return bitrate in bps
- */
- public int bitrate_instant()
- {
- return bitrates[h_version][h_layer - 1][h_bitrate_index];
- }
-
- /**
- * Returns Frequency
- * @return frequency string in kHz
- */
- public String sample_frequency_string()
- {
- switch (h_sample_frequency)
- {
- case THIRTYTWO:
- if (h_version == MPEG1)
- return "32 kHz";
- else if (h_version == MPEG2_LSF)
- return "16 kHz";
- else // SZD
- return "8 kHz";
- case FOURTYFOUR_POINT_ONE:
- if (h_version == MPEG1)
- return "44.1 kHz";
- else if (h_version == MPEG2_LSF)
- return "22.05 kHz";
- else // SZD
- return "11.025 kHz";
- case FOURTYEIGHT:
- if (h_version == MPEG1)
- return "48 kHz";
- else if (h_version == MPEG2_LSF)
- return "24 kHz";
- else // SZD
- return "12 kHz";
- }
- return(null);
- }
-
- /**
- * Returns Mode.
- */
- public String mode_string()
- {
- switch (h_mode)
- {
- case STEREO:
- return "Stereo";
- case JOINT_STEREO:
- return "Joint stereo";
- case DUAL_CHANNEL:
- return "Dual channel";
- case SINGLE_CHANNEL:
- return "Single channel";
- }
- return null;
- }
-
- /**
- * Returns Version.
- * @return MPEG-1 or MPEG-2 LSF or MPEG-2.5 LSF
- */
- public String version_string()
- {
- switch (h_version)
- {
- case MPEG1:
- return "MPEG-1";
- case MPEG2_LSF:
- return "MPEG-2 LSF";
- case MPEG25_LSF: // SZD
- return "MPEG-2.5 LSF";
- }
- return(null);
- }
-
- /**
- * Returns the number of subbands in the current frame.
- * @return number of subbands
- */
- public int number_of_subbands() {return h_number_of_subbands;}
-
- /**
- * Returns Intensity Stereo.
- * (Layer II joint stereo only).
- * Returns the number of subbands which are in stereo mode,
- * subbands above that limit are in intensity stereo mode.
- * @return intensity
- */
- public int intensity_stereo_bound() {return h_intensity_stereo_bound;}
-}
diff --git a/songdbj/javazoom/jl/decoder/InputStreamSource.java b/songdbj/javazoom/jl/decoder/InputStreamSource.java
deleted file mode 100644
index 5c62947049..0000000000
--- a/songdbj/javazoom/jl/decoder/InputStreamSource.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * <i>Work In Progress.</i>
- *
- * An instance of <code>InputStreamSource</code> implements a
- * <code>Source</code> that provides data from an <code>InputStream
- * </code>. Seeking functionality is not supported.
- *
- * @author MDM
- */
-public class InputStreamSource implements Source
-{
- private final InputStream in;
-
- public InputStreamSource(InputStream in)
- {
- if (in==null)
- throw new NullPointerException("in");
-
- this.in = in;
- }
-
- public int read(byte[] b, int offs, int len)
- throws IOException
- {
- int read = in.read(b, offs, len);
- return read;
- }
-
- public boolean willReadBlock()
- {
- return true;
- //boolean block = (in.available()==0);
- //return block;
- }
-
- public boolean isSeekable()
- {
- return false;
- }
-
- public long tell()
- {
- return -1;
- }
-
- public long seek(long to)
- {
- return -1;
- }
-
- public long length()
- {
- return -1;
- }
-}
diff --git a/songdbj/javazoom/jl/decoder/JavaLayerError.java b/songdbj/javazoom/jl/decoder/JavaLayerError.java
deleted file mode 100644
index d9910bcc71..0000000000
--- a/songdbj/javazoom/jl/decoder/JavaLayerError.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Work in progress.
- *
- * API usage errors may be handled by throwing an instance of this
- * class, as per JMF 2.0.
- */
-public class JavaLayerError extends Error
-{
-}
diff --git a/songdbj/javazoom/jl/decoder/JavaLayerErrors.java b/songdbj/javazoom/jl/decoder/JavaLayerErrors.java
deleted file mode 100644
index 3b9c2ff9d7..0000000000
--- a/songdbj/javazoom/jl/decoder/JavaLayerErrors.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Exception erorr codes for components of the JavaLayer API.
- */
-public interface JavaLayerErrors
-{
- /**
- * The first bitstream error code. See the {@link DecoderErrors DecoderErrors}
- * interface for other bitstream error codes.
- */
- static public final int BITSTREAM_ERROR = 0x100;
-
- /**
- * The first decoder error code. See the {@link DecoderErrors DecoderErrors}
- * interface for other decoder error codes.
- */
- static public final int DECODER_ERROR = 0x200;
-
-}
diff --git a/songdbj/javazoom/jl/decoder/JavaLayerException.java b/songdbj/javazoom/jl/decoder/JavaLayerException.java
deleted file mode 100644
index e7a50a8340..0000000000
--- a/songdbj/javazoom/jl/decoder/JavaLayerException.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-import java.io.PrintStream;
-
-
-/**
- * The JavaLayerException is the base class for all API-level
- * exceptions thrown by JavaLayer. To facilitate conversion and
- * common handling of exceptions from other domains, the class
- * can delegate some functionality to a contained Throwable instance.
- * <p>
- *
- * @author MDM
- */
-public class JavaLayerException extends Exception
-{
-
- private Throwable exception;
-
-
- public JavaLayerException()
- {
- }
-
- public JavaLayerException(String msg)
- {
- super(msg);
- }
-
- public JavaLayerException(String msg, Throwable t)
- {
- super(msg);
- exception = t;
- }
-
- public Throwable getException()
- {
- return exception;
- }
-
-
- public void printStackTrace()
- {
- printStackTrace(System.err);
- }
-
- public void printStackTrace(PrintStream ps)
- {
- if (this.exception==null)
- {
- super.printStackTrace(ps);
- }
- else
- {
- exception.printStackTrace();
- }
- }
-
-
-}
diff --git a/songdbj/javazoom/jl/decoder/JavaLayerHook.java b/songdbj/javazoom/jl/decoder/JavaLayerHook.java
deleted file mode 100644
index 352059433d..0000000000
--- a/songdbj/javazoom/jl/decoder/JavaLayerHook.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-import java.io.InputStream;
-
-/**
- * The <code>JavaLayerHooks</code> class allows developers to change
- * the way the JavaLayer library uses Resources.
- */
-
-public interface JavaLayerHook
-{
- /**
- * Retrieves the named resource. This allows resources to be
- * obtained without specifying how they are retrieved.
- */
- public InputStream getResourceAsStream(String name);
-}
diff --git a/songdbj/javazoom/jl/decoder/JavaLayerUtils.java b/songdbj/javazoom/jl/decoder/JavaLayerUtils.java
deleted file mode 100644
index c9ce3838e5..0000000000
--- a/songdbj/javazoom/jl/decoder/JavaLayerUtils.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InvalidClassException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Array;
-
-/**
- * The JavaLayerUtils class is not strictly part of the JavaLayer API.
- * It serves to provide useful methods and system-wide hooks.
- *
- * @author MDM
- */
-public class JavaLayerUtils
-{
- static private JavaLayerHook hook = null;
-
- /**
- * Deserializes the object contained in the given input stream.
- * @param in The input stream to deserialize an object from.
- * @param cls The expected class of the deserialized object.
- */
- static public Object deserialize(InputStream in, Class cls)
- throws IOException
- {
- if (cls==null)
- throw new NullPointerException("cls");
-
- Object obj = deserialize(in, cls);
- if (!cls.isInstance(obj))
- {
- throw new InvalidObjectException("type of deserialized instance not of required class.");
- }
-
- return obj;
- }
-
- /**
- * Deserializes an object from the given <code>InputStream</code>.
- * The deserialization is delegated to an <code>
- * ObjectInputStream</code> instance.
- *
- * @param in The <code>InputStream</code> to deserialize an object
- * from.
- *
- * @return The object deserialized from the stream.
- * @exception IOException is thrown if there was a problem reading
- * the underlying stream, or an object could not be deserialized
- * from the stream.
- *
- * @see java.io.ObjectInputStream
- */
- static public Object deserialize(InputStream in)
- throws IOException
- {
- if (in==null)
- throw new NullPointerException("in");
-
- ObjectInputStream objIn = new ObjectInputStream(in);
-
- Object obj;
-
- try
- {
- obj = objIn.readObject();
- }
- catch (ClassNotFoundException ex)
- {
- throw new InvalidClassException(ex.toString());
- }
-
- return obj;
- }
-
- /**
- * Deserializes an array from a given <code>InputStream</code>.
- *
- * @param in The <code>InputStream</code> to
- * deserialize an object from.
- *
- * @param elemType The class denoting the type of the array
- * elements.
- * @param length The expected length of the array, or -1 if
- * any length is expected.
- */
- static public Object deserializeArray(InputStream in, Class elemType, int length)
- throws IOException
- {
- if (elemType==null)
- throw new NullPointerException("elemType");
-
- if (length<-1)
- throw new IllegalArgumentException("length");
-
- Object obj = deserialize(in);
-
- Class cls = obj.getClass();
-
-
- if (!cls.isArray())
- throw new InvalidObjectException("object is not an array");
-
- Class arrayElemType = cls.getComponentType();
- if (arrayElemType!=elemType)
- throw new InvalidObjectException("unexpected array component type");
-
- if (length != -1)
- {
- int arrayLength = Array.getLength(obj);
- if (arrayLength!=length)
- throw new InvalidObjectException("array length mismatch");
- }
-
- return obj;
- }
-
- static public Object deserializeArrayResource(String name, Class elemType, int length)
- throws IOException
- {
- InputStream str = getResourceAsStream(name);
- if (str==null)
- throw new IOException("unable to load resource '"+name+"'");
-
- Object obj = deserializeArray(str, elemType, length);
-
- return obj;
- }
-
- static public void serialize(OutputStream out, Object obj)
- throws IOException
- {
- if (out==null)
- throw new NullPointerException("out");
-
- if (obj==null)
- throw new NullPointerException("obj");
-
- ObjectOutputStream objOut = new ObjectOutputStream(out);
- objOut.writeObject(obj);
-
- }
-
- /**
- * Sets the system-wide JavaLayer hook.
- */
- static synchronized public void setHook(JavaLayerHook hook0)
- {
- hook = hook0;
- }
-
- static synchronized public JavaLayerHook getHook()
- {
- return hook;
- }
-
- /**
- * Retrieves an InputStream for a named resource.
- *
- * @param name The name of the resource. This must be a simple
- * name, and not a qualified package name.
- *
- * @return The InputStream for the named resource, or null if
- * the resource has not been found. If a hook has been
- * provided, its getResourceAsStream() method is called
- * to retrieve the resource.
- */
- static synchronized public InputStream getResourceAsStream(String name)
- {
- InputStream is = null;
-
- if (hook!=null)
- {
- is = hook.getResourceAsStream(name);
- }
- else
- {
- Class cls = JavaLayerUtils.class;
- is = cls.getResourceAsStream(name);
- }
-
- return is;
- }
-}
diff --git a/songdbj/javazoom/jl/decoder/LayerIDecoder.java b/songdbj/javazoom/jl/decoder/LayerIDecoder.java
deleted file mode 100644
index b633dd2403..0000000000
--- a/songdbj/javazoom/jl/decoder/LayerIDecoder.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 12/12/99 Initial version. Adapted from javalayer.java
- * and Subband*.java. mdm@techie.com
- *
- * 02/28/99 Initial version : javalayer.java by E.B
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Implements decoding of MPEG Audio Layer I frames.
- */
-class LayerIDecoder implements FrameDecoder
-{
- protected Bitstream stream;
- protected Header header;
- protected SynthesisFilter filter1, filter2;
- protected Obuffer buffer;
- protected int which_channels;
- protected int mode;
-
- protected int num_subbands;
- protected Subband[] subbands;
- protected Crc16 crc = null; // new Crc16[1] to enable CRC checking.
-
- public LayerIDecoder()
- {
- crc = new Crc16();
- }
-
- public void create(Bitstream stream0, Header header0,
- SynthesisFilter filtera, SynthesisFilter filterb,
- Obuffer buffer0, int which_ch0)
- {
- stream = stream0;
- header = header0;
- filter1 = filtera;
- filter2 = filterb;
- buffer = buffer0;
- which_channels = which_ch0;
-
- }
-
-
-
- public void decodeFrame()
- {
-
- num_subbands = header.number_of_subbands();
- subbands = new Subband[32];
- mode = header.mode();
-
- createSubbands();
-
- readAllocation();
- readScaleFactorSelection();
-
- if ((crc != null) || header.checksum_ok())
- {
- readScaleFactors();
-
- readSampleData();
- }
-
- }
-
- protected void createSubbands()
- {
- int i;
- if (mode == Header.SINGLE_CHANNEL)
- for (i = 0; i < num_subbands; ++i)
- subbands[i] = new SubbandLayer1(i);
- else if (mode == Header.JOINT_STEREO)
- {
- for (i = 0; i < header.intensity_stereo_bound(); ++i)
- subbands[i] = new SubbandLayer1Stereo(i);
- for (; i < num_subbands; ++i)
- subbands[i] = new SubbandLayer1IntensityStereo(i);
- }
- else
- {
- for (i = 0; i < num_subbands; ++i)
- subbands[i] = new SubbandLayer1Stereo(i);
- }
- }
-
- protected void readAllocation()
- {
- // start to read audio data:
- for (int i = 0; i < num_subbands; ++i)
- subbands[i].read_allocation(stream, header, crc);
-
- }
-
- protected void readScaleFactorSelection()
- {
- // scale factor selection not present for layer I.
- }
-
- protected void readScaleFactors()
- {
- for (int i = 0; i < num_subbands; ++i)
- subbands[i].read_scalefactor(stream, header);
- }
-
- protected void readSampleData()
- {
- boolean read_ready = false;
- boolean write_ready = false;
- int mode = header.mode();
- int i;
- do
- {
- for (i = 0; i < num_subbands; ++i)
- read_ready = subbands[i].read_sampledata(stream);
- do
- {
- for (i = 0; i < num_subbands; ++i)
- write_ready = subbands[i].put_next_sample(which_channels,filter1, filter2);
-
- filter1.calculate_pcm_samples(buffer);
- if ((which_channels == OutputChannels.BOTH_CHANNELS) && (mode != Header.SINGLE_CHANNEL))
- filter2.calculate_pcm_samples(buffer);
- } while (!write_ready);
- } while (!read_ready);
-
- }
-
- /**
- * Abstract base class for subband classes of layer I and II
- */
- static abstract class Subband
- {
- /*
- * Changes from version 1.1 to 1.2:
- * - array size increased by one, although a scalefactor with index 63
- * is illegal (to prevent segmentation faults)
- */
- // Scalefactors for layer I and II, Annex 3-B.1 in ISO/IEC DIS 11172:
- public static final float scalefactors[] =
- {
- 2.00000000000000f, 1.58740105196820f, 1.25992104989487f, 1.00000000000000f,
- 0.79370052598410f, 0.62996052494744f, 0.50000000000000f, 0.39685026299205f,
- 0.31498026247372f, 0.25000000000000f, 0.19842513149602f, 0.15749013123686f,
- 0.12500000000000f, 0.09921256574801f, 0.07874506561843f, 0.06250000000000f,
- 0.04960628287401f, 0.03937253280921f, 0.03125000000000f, 0.02480314143700f,
- 0.01968626640461f, 0.01562500000000f, 0.01240157071850f, 0.00984313320230f,
- 0.00781250000000f, 0.00620078535925f, 0.00492156660115f, 0.00390625000000f,
- 0.00310039267963f, 0.00246078330058f, 0.00195312500000f, 0.00155019633981f,
- 0.00123039165029f, 0.00097656250000f, 0.00077509816991f, 0.00061519582514f,
- 0.00048828125000f, 0.00038754908495f, 0.00030759791257f, 0.00024414062500f,
- 0.00019377454248f, 0.00015379895629f, 0.00012207031250f, 0.00009688727124f,
- 0.00007689947814f, 0.00006103515625f, 0.00004844363562f, 0.00003844973907f,
- 0.00003051757813f, 0.00002422181781f, 0.00001922486954f, 0.00001525878906f,
- 0.00001211090890f, 0.00000961243477f, 0.00000762939453f, 0.00000605545445f,
- 0.00000480621738f, 0.00000381469727f, 0.00000302772723f, 0.00000240310869f,
- 0.00000190734863f, 0.00000151386361f, 0.00000120155435f, 0.00000000000000f /* illegal scalefactor */
- };
-
- public abstract void read_allocation (Bitstream stream, Header header, Crc16 crc);
- public abstract void read_scalefactor (Bitstream stream, Header header);
- public abstract boolean read_sampledata (Bitstream stream);
- public abstract boolean put_next_sample (int channels, SynthesisFilter filter1, SynthesisFilter filter2);
- };
-
- /**
- * Class for layer I subbands in single channel mode.
- * Used for single channel mode
- * and in derived class for intensity stereo mode
- */
- static class SubbandLayer1 extends Subband
- {
-
- // Factors and offsets for sample requantization
- public static final float table_factor[] = {
- 0.0f, (1.0f/2.0f) * (4.0f/3.0f), (1.0f/4.0f) * (8.0f/7.0f), (1.0f/8.0f) * (16.0f/15.0f),
- (1.0f/16.0f) * (32.0f/31.0f), (1.0f/32.0f) * (64.0f/63.0f), (1.0f/64.0f) * (128.0f/127.0f),
- (1.0f/128.0f) * (256.0f/255.0f), (1.0f/256.0f) * (512.0f/511.0f),
- (1.0f/512.0f) * (1024.0f/1023.0f), (1.0f/1024.0f) * (2048.0f/2047.0f),
- (1.0f/2048.0f) * (4096.0f/4095.0f), (1.0f/4096.0f) * (8192.0f/8191.0f),
- (1.0f/8192.0f) * (16384.0f/16383.0f), (1.0f/16384.0f) * (32768.0f/32767.0f)
- };
-
- public static final float table_offset[] = {
- 0.0f, ((1.0f/2.0f)-1.0f) * (4.0f/3.0f), ((1.0f/4.0f)-1.0f) * (8.0f/7.0f), ((1.0f/8.0f)-1.0f) * (16.0f/15.0f),
- ((1.0f/16.0f)-1.0f) * (32.0f/31.0f), ((1.0f/32.0f)-1.0f) * (64.0f/63.0f), ((1.0f/64.0f)-1.0f) * (128.0f/127.0f),
- ((1.0f/128.0f)-1.0f) * (256.0f/255.0f), ((1.0f/256.0f)-1.0f) * (512.0f/511.0f),
- ((1.0f/512.0f)-1.0f) * (1024.0f/1023.0f), ((1.0f/1024.0f)-1.0f) * (2048.0f/2047.0f),
- ((1.0f/2048.0f)-1.0f) * (4096.0f/4095.0f), ((1.0f/4096.0f)-1.0f) * (8192.0f/8191.0f),
- ((1.0f/8192.0f)-1.0f) * (16384.0f/16383.0f), ((1.0f/16384.0f)-1.0f) * (32768.0f/32767.0f)
- };
-
- protected int subbandnumber;
- protected int samplenumber;
- protected int allocation;
- protected float scalefactor;
- protected int samplelength;
- protected float sample;
- protected float factor, offset;
-
- /**
- * Construtor.
- */
- public SubbandLayer1(int subbandnumber)
- {
- this.subbandnumber = subbandnumber;
- samplenumber = 0;
- }
-
- /**
- *
- */
- public void read_allocation(Bitstream stream, Header header, Crc16 crc)
- {
- if ((allocation = stream.get_bits (4)) == 15) ;
- // cerr << "WARNING: stream contains an illegal allocation!\n";
- // MPEG-stream is corrupted!
- if (crc != null)
- crc.add_bits (allocation, 4);
- if (allocation != 0)
- {
- samplelength = allocation + 1;
- factor = table_factor[allocation];
- offset = table_offset[allocation];
- }
- }
-
- /**
- *
- */
- public void read_scalefactor(Bitstream stream, Header header)
- {
- if (allocation != 0) scalefactor = scalefactors[stream.get_bits(6)];
- }
-
- /**
- *
- */
- public boolean read_sampledata(Bitstream stream)
- {
- if (allocation != 0)
- {
- sample = (float) (stream.get_bits(samplelength));
- }
- if (++samplenumber == 12)
- {
- samplenumber = 0;
- return true;
- }
- return false;
- }
-
- /**
- *
- */
- public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
- {
- if ((allocation !=0) && (channels != OutputChannels.RIGHT_CHANNEL))
- {
- float scaled_sample = (sample * factor + offset) * scalefactor;
- filter1.input_sample (scaled_sample, subbandnumber);
- }
- return true;
- }
- };
-
- /**
- * Class for layer I subbands in joint stereo mode.
- */
- static class SubbandLayer1IntensityStereo extends SubbandLayer1
- {
- protected float channel2_scalefactor;
-
- /**
- * Constructor
- */
- public SubbandLayer1IntensityStereo(int subbandnumber)
- {
- super(subbandnumber);
- }
-
- /**
- *
- */
- public void read_allocation(Bitstream stream, Header header, Crc16 crc)
- {
- super.read_allocation (stream, header, crc);
- }
-
- /**
- *
- */
- public void read_scalefactor (Bitstream stream, Header header)
- {
- if (allocation != 0)
- {
- scalefactor = scalefactors[stream.get_bits(6)];
- channel2_scalefactor = scalefactors[stream.get_bits(6)];
- }
- }
-
- /**
- *
- */
- public boolean read_sampledata(Bitstream stream)
- {
- return super.read_sampledata (stream);
- }
-
- /**
- *
- */
- public boolean put_next_sample (int channels, SynthesisFilter filter1, SynthesisFilter filter2)
- {
- if (allocation !=0 )
- {
- sample = sample * factor + offset; // requantization
- if (channels == OutputChannels.BOTH_CHANNELS)
- {
- float sample1 = sample * scalefactor,
- sample2 = sample * channel2_scalefactor;
- filter1.input_sample(sample1, subbandnumber);
- filter2.input_sample(sample2, subbandnumber);
- }
- else if (channels == OutputChannels.LEFT_CHANNEL)
- {
- float sample1 = sample * scalefactor;
- filter1.input_sample(sample1, subbandnumber);
- }
- else
- {
- float sample2 = sample * channel2_scalefactor;
- filter1.input_sample(sample2, subbandnumber);
- }
- }
- return true;
- }
- };
-
- /**
- * Class for layer I subbands in stereo mode.
- */
- static class SubbandLayer1Stereo extends SubbandLayer1
- {
- protected int channel2_allocation;
- protected float channel2_scalefactor;
- protected int channel2_samplelength;
- protected float channel2_sample;
- protected float channel2_factor, channel2_offset;
-
-
- /**
- * Constructor
- */
- public SubbandLayer1Stereo(int subbandnumber)
- {
- super(subbandnumber);
- }
-
- /**
- *
- */
- public void read_allocation (Bitstream stream, Header header, Crc16 crc)
- {
- allocation = stream.get_bits(4);
- channel2_allocation = stream.get_bits(4);
- if (crc != null)
- {
- crc.add_bits (allocation, 4);
- crc.add_bits (channel2_allocation, 4);
- }
- if (allocation != 0)
- {
- samplelength = allocation + 1;
- factor = table_factor[allocation];
- offset = table_offset[allocation];
- }
- if (channel2_allocation != 0)
- {
- channel2_samplelength = channel2_allocation + 1;
- channel2_factor = table_factor[channel2_allocation];
- channel2_offset = table_offset[channel2_allocation];
- }
- }
-
- /**
- *
- */
- public void read_scalefactor(Bitstream stream, Header header)
- {
- if (allocation != 0) scalefactor = scalefactors[stream.get_bits(6)];
- if (channel2_allocation != 0) channel2_scalefactor = scalefactors[stream.get_bits(6)];
- }
-
- /**
- *
- */
- public boolean read_sampledata (Bitstream stream)
- {
- boolean returnvalue = super.read_sampledata(stream);
- if (channel2_allocation != 0)
- {
- channel2_sample = (float) (stream.get_bits(channel2_samplelength));
- }
- return(returnvalue);
- }
-
- /**
- *
- */
- public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
- {
- super.put_next_sample (channels, filter1, filter2);
- if ((channel2_allocation != 0) && (channels != OutputChannels.LEFT_CHANNEL))
- {
- float sample2 = (channel2_sample * channel2_factor + channel2_offset) *
- channel2_scalefactor;
- if (channels == OutputChannels.BOTH_CHANNELS)
- filter2.input_sample (sample2, subbandnumber);
- else
- filter1.input_sample (sample2, subbandnumber);
- }
- return true;
- }
- };
-
-}
diff --git a/songdbj/javazoom/jl/decoder/LayerIIDecoder.java b/songdbj/javazoom/jl/decoder/LayerIIDecoder.java
deleted file mode 100644
index 7265b1f8fa..0000000000
--- a/songdbj/javazoom/jl/decoder/LayerIIDecoder.java
+++ /dev/null
@@ -1,1064 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 29/05/01 Michael Scheerer, Fixed some C++ to Java porting bugs.
- *
- * 16/07/01 Michael Scheerer, Catched a bug in method
- * read_sampledata, which causes an outOfIndexException.
- *
- * 12/12/99 Initial version. Adapted from javalayer.java
- * and Subband*.java. mdm@techie.com
- *
- * 02/28/99 Initial version : javalayer.java by E.B
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Implements decoding of MPEG Audio Layer II frames.
- */
-class LayerIIDecoder extends LayerIDecoder implements FrameDecoder
-{
-
- public LayerIIDecoder()
- {
- }
-
-
- protected void createSubbands()
- {
- int i;
- if (mode == Header.SINGLE_CHANNEL)
- for (i = 0; i < num_subbands; ++i)
- subbands[i] = new SubbandLayer2(i);
- else if (mode == Header.JOINT_STEREO)
- {
- for (i = 0; i < header.intensity_stereo_bound(); ++i)
- subbands[i] = new SubbandLayer2Stereo(i);
- for (; i < num_subbands; ++i)
- subbands[i] = new SubbandLayer2IntensityStereo(i);
- }
- else
- {
- for (i = 0; i < num_subbands; ++i)
- subbands[i] = new SubbandLayer2Stereo(i);
- }
-
- }
-
- protected void readScaleFactorSelection()
- {
- for (int i = 0; i < num_subbands; ++i)
- ((SubbandLayer2)subbands[i]).read_scalefactor_selection(stream, crc);
- }
-
-
-
- /**
- * Class for layer II subbands in single channel mode.
- */
- static class SubbandLayer2 extends Subband
- {
- // this table contains 3 requantized samples for each legal codeword
- // when grouped in 5 bits, i.e. 3 quantizationsteps per sample
- public static final float grouping_5bits[] = new float[]
- {
- -2.0f/3.0f, -2.0f/3.0f, -2.0f/3.0f,
- 0.0f, -2.0f/3.0f, -2.0f/3.0f,
- 2.0f/3.0f, -2.0f/3.0f, -2.0f/3.0f,
- -2.0f/3.0f, 0.0f, -2.0f/3.0f,
- 0.0f, 0.0f, -2.0f/3.0f,
- 2.0f/3.0f, 0.0f, -2.0f/3.0f,
- -2.0f/3.0f, 2.0f/3.0f, -2.0f/3.0f,
- 0.0f, 2.0f/3.0f, -2.0f/3.0f,
- 2.0f/3.0f, 2.0f/3.0f, -2.0f/3.0f,
- -2.0f/3.0f, -2.0f/3.0f, 0.0f,
- 0.0f, -2.0f/3.0f, 0.0f,
- 2.0f/3.0f, -2.0f/3.0f, 0.0f,
- -2.0f/3.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f,
- 2.0f/3.0f, 0.0f, 0.0f,
- -2.0f/3.0f, 2.0f/3.0f, 0.0f,
- 0.0f, 2.0f/3.0f, 0.0f,
- 2.0f/3.0f, 2.0f/3.0f, 0.0f,
- -2.0f/3.0f, -2.0f/3.0f, 2.0f/3.0f,
- 0.0f, -2.0f/3.0f, 2.0f/3.0f,
- 2.0f/3.0f, -2.0f/3.0f, 2.0f/3.0f,
- -2.0f/3.0f, 0.0f, 2.0f/3.0f,
- 0.0f, 0.0f, 2.0f/3.0f,
- 2.0f/3.0f, 0.0f, 2.0f/3.0f,
- -2.0f/3.0f, 2.0f/3.0f, 2.0f/3.0f,
- 0.0f, 2.0f/3.0f, 2.0f/3.0f,
- 2.0f/3.0f, 2.0f/3.0f, 2.0f/3.0f
- };
-
- // this table contains 3 requantized samples for each legal codeword
- // when grouped in 7 bits, i.e. 5 quantizationsteps per sample
- public static final float grouping_7bits[] = new float[]
- {
- -0.8f, -0.8f, -0.8f, -0.4f, -0.8f, -0.8f, 0.0f, -0.8f, -0.8f, 0.4f, -0.8f, -0.8f, 0.8f, -0.8f, -0.8f,
- -0.8f, -0.4f, -0.8f, -0.4f, -0.4f, -0.8f, 0.0f, -0.4f, -0.8f, 0.4f, -0.4f, -0.8f, 0.8f, -0.4f, -0.8f,
- -0.8f, 0.0f, -0.8f, -0.4f, 0.0f, -0.8f, 0.0f, 0.0f, -0.8f, 0.4f, 0.0f, -0.8f, 0.8f, 0.0f, -0.8f,
- -0.8f, 0.4f, -0.8f, -0.4f, 0.4f, -0.8f, 0.0f, 0.4f, -0.8f, 0.4f, 0.4f, -0.8f, 0.8f, 0.4f, -0.8f,
- -0.8f, 0.8f, -0.8f, -0.4f, 0.8f, -0.8f, 0.0f, 0.8f, -0.8f, 0.4f, 0.8f, -0.8f, 0.8f, 0.8f, -0.8f,
- -0.8f, -0.8f, -0.4f, -0.4f, -0.8f, -0.4f, 0.0f, -0.8f, -0.4f, 0.4f, -0.8f, -0.4f, 0.8f, -0.8f, -0.4f,
- -0.8f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, 0.0f, -0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.8f, -0.4f, -0.4f,
- -0.8f, 0.0f, -0.4f, -0.4f, 0.0f, -0.4f, 0.0f, 0.0f, -0.4f, 0.4f, 0.0f, -0.4f, 0.8f, 0.0f, -0.4f,
- -0.8f, 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.0f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, 0.8f, 0.4f, -0.4f,
- -0.8f, 0.8f, -0.4f, -0.4f, 0.8f, -0.4f, 0.0f, 0.8f, -0.4f, 0.4f, 0.8f, -0.4f, 0.8f, 0.8f, -0.4f,
- -0.8f, -0.8f, 0.0f, -0.4f, -0.8f, 0.0f, 0.0f, -0.8f, 0.0f, 0.4f, -0.8f, 0.0f, 0.8f, -0.8f, 0.0f,
- -0.8f, -0.4f, 0.0f, -0.4f, -0.4f, 0.0f, 0.0f, -0.4f, 0.0f, 0.4f, -0.4f, 0.0f, 0.8f, -0.4f, 0.0f,
- -0.8f, 0.0f, 0.0f, -0.4f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f,
- -0.8f, 0.4f, 0.0f, -0.4f, 0.4f, 0.0f, 0.0f, 0.4f, 0.0f, 0.4f, 0.4f, 0.0f, 0.8f, 0.4f, 0.0f,
- -0.8f, 0.8f, 0.0f, -0.4f, 0.8f, 0.0f, 0.0f, 0.8f, 0.0f, 0.4f, 0.8f, 0.0f, 0.8f, 0.8f, 0.0f,
- -0.8f, -0.8f, 0.4f, -0.4f, -0.8f, 0.4f, 0.0f, -0.8f, 0.4f, 0.4f, -0.8f, 0.4f, 0.8f, -0.8f, 0.4f,
- -0.8f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.0f, -0.4f, 0.4f, 0.4f, -0.4f, 0.4f, 0.8f, -0.4f, 0.4f,
- -0.8f, 0.0f, 0.4f, -0.4f, 0.0f, 0.4f, 0.0f, 0.0f, 0.4f, 0.4f, 0.0f, 0.4f, 0.8f, 0.0f, 0.4f,
- -0.8f, 0.4f, 0.4f, -0.4f, 0.4f, 0.4f, 0.0f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.8f, 0.4f, 0.4f,
- -0.8f, 0.8f, 0.4f, -0.4f, 0.8f, 0.4f, 0.0f, 0.8f, 0.4f, 0.4f, 0.8f, 0.4f, 0.8f, 0.8f, 0.4f,
- -0.8f, -0.8f, 0.8f, -0.4f, -0.8f, 0.8f, 0.0f, -0.8f, 0.8f, 0.4f, -0.8f, 0.8f, 0.8f, -0.8f, 0.8f,
- -0.8f, -0.4f, 0.8f, -0.4f, -0.4f, 0.8f, 0.0f, -0.4f, 0.8f, 0.4f, -0.4f, 0.8f, 0.8f, -0.4f, 0.8f,
- -0.8f, 0.0f, 0.8f, -0.4f, 0.0f, 0.8f, 0.0f, 0.0f, 0.8f, 0.4f, 0.0f, 0.8f, 0.8f, 0.0f, 0.8f,
- -0.8f, 0.4f, 0.8f, -0.4f, 0.4f, 0.8f, 0.0f, 0.4f, 0.8f, 0.4f, 0.4f, 0.8f, 0.8f, 0.4f, 0.8f,
- -0.8f, 0.8f, 0.8f, -0.4f, 0.8f, 0.8f, 0.0f, 0.8f, 0.8f, 0.4f, 0.8f, 0.8f, 0.8f, 0.8f, 0.8f
- };
-
- // this table contains 3 requantized samples for each legal codeword
- // when grouped in 10 bits, i.e. 9 quantizationsteps per sample
- public static final float grouping_10bits[] =
- {
- -8.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f, 0.0f, -8.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, 0.0f, -6.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, 0.0f, -4.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f, 0.0f, -2.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, 0.0f, -8.0f/9.0f, -6.0f/9.0f, 0.0f, -8.0f/9.0f, -4.0f/9.0f, 0.0f, -8.0f/9.0f,
- -2.0f/9.0f, 0.0f, -8.0f/9.0f, 0.0f, 0.0f, -8.0f/9.0f, 2.0f/9.0f, 0.0f, -8.0f/9.0f,
- 4.0f/9.0f, 0.0f, -8.0f/9.0f, 6.0f/9.0f, 0.0f, -8.0f/9.0f, 8.0f/9.0f, 0.0f, -8.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, 0.0f, 2.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f, 0.0f, 4.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, 0.0f, 6.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, 0.0f, 8.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f,
- -8.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, 0.0f, -8.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 0.0f, -6.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 0.0f, -4.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, 0.0f, -2.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, 0.0f, -6.0f/9.0f, -6.0f/9.0f, 0.0f, -6.0f/9.0f, -4.0f/9.0f, 0.0f, -6.0f/9.0f,
- -2.0f/9.0f, 0.0f, -6.0f/9.0f, 0.0f, 0.0f, -6.0f/9.0f, 2.0f/9.0f, 0.0f, -6.0f/9.0f,
- 4.0f/9.0f, 0.0f, -6.0f/9.0f, 6.0f/9.0f, 0.0f, -6.0f/9.0f, 8.0f/9.0f, 0.0f, -6.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 0.0f, 2.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, 0.0f, 4.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 0.0f, 6.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 0.0f, 8.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f,
- -8.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, 0.0f, -8.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 0.0f, -6.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 0.0f, -4.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, 0.0f, -2.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, 0.0f, -4.0f/9.0f, -6.0f/9.0f, 0.0f, -4.0f/9.0f, -4.0f/9.0f, 0.0f, -4.0f/9.0f,
- -2.0f/9.0f, 0.0f, -4.0f/9.0f, 0.0f, 0.0f, -4.0f/9.0f, 2.0f/9.0f, 0.0f, -4.0f/9.0f,
- 4.0f/9.0f, 0.0f, -4.0f/9.0f, 6.0f/9.0f, 0.0f, -4.0f/9.0f, 8.0f/9.0f, 0.0f, -4.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 0.0f, 2.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, 0.0f, 4.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 0.0f, 6.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 0.0f, 8.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f,
- -8.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f, 0.0f, -8.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, 0.0f, -6.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, 0.0f, -4.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f, 0.0f, -2.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, 0.0f, -2.0f/9.0f, -6.0f/9.0f, 0.0f, -2.0f/9.0f, -4.0f/9.0f, 0.0f, -2.0f/9.0f,
- -2.0f/9.0f, 0.0f, -2.0f/9.0f, 0.0f, 0.0f, -2.0f/9.0f, 2.0f/9.0f, 0.0f, -2.0f/9.0f,
- 4.0f/9.0f, 0.0f, -2.0f/9.0f, 6.0f/9.0f, 0.0f, -2.0f/9.0f, 8.0f/9.0f, 0.0f, -2.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, 0.0f, 2.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f, 0.0f, 4.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, 0.0f, 6.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, 0.0f, 8.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f,
- -8.0f/9.0f, -8.0f/9.0f, 0.0f, -6.0f/9.0f, -8.0f/9.0f, 0.0f, -4.0f/9.0f, -8.0f/9.0f, 0.0f,
- -2.0f/9.0f, -8.0f/9.0f, 0.0f, 0.0f, -8.0f/9.0f, 0.0f, 2.0f/9.0f, -8.0f/9.0f, 0.0f,
- 4.0f/9.0f, -8.0f/9.0f, 0.0f, 6.0f/9.0f, -8.0f/9.0f, 0.0f, 8.0f/9.0f, -8.0f/9.0f, 0.0f,
- -8.0f/9.0f, -6.0f/9.0f, 0.0f, -6.0f/9.0f, -6.0f/9.0f, 0.0f, -4.0f/9.0f, -6.0f/9.0f, 0.0f,
- -2.0f/9.0f, -6.0f/9.0f, 0.0f, 0.0f, -6.0f/9.0f, 0.0f, 2.0f/9.0f, -6.0f/9.0f, 0.0f,
- 4.0f/9.0f, -6.0f/9.0f, 0.0f, 6.0f/9.0f, -6.0f/9.0f, 0.0f, 8.0f/9.0f, -6.0f/9.0f, 0.0f,
- -8.0f/9.0f, -4.0f/9.0f, 0.0f, -6.0f/9.0f, -4.0f/9.0f, 0.0f, -4.0f/9.0f, -4.0f/9.0f, 0.0f,
- -2.0f/9.0f, -4.0f/9.0f, 0.0f, 0.0f, -4.0f/9.0f, 0.0f, 2.0f/9.0f, -4.0f/9.0f, 0.0f,
- 4.0f/9.0f, -4.0f/9.0f, 0.0f, 6.0f/9.0f, -4.0f/9.0f, 0.0f, 8.0f/9.0f, -4.0f/9.0f, 0.0f,
- -8.0f/9.0f, -2.0f/9.0f, 0.0f, -6.0f/9.0f, -2.0f/9.0f, 0.0f, -4.0f/9.0f, -2.0f/9.0f, 0.0f,
- -2.0f/9.0f, -2.0f/9.0f, 0.0f, 0.0f, -2.0f/9.0f, 0.0f, 2.0f/9.0f, -2.0f/9.0f, 0.0f,
- 4.0f/9.0f, -2.0f/9.0f, 0.0f, 6.0f/9.0f, -2.0f/9.0f, 0.0f, 8.0f/9.0f, -2.0f/9.0f, 0.0f,
- -8.0f/9.0f, 0.0f, 0.0f, -6.0f/9.0f, 0.0f, 0.0f, -4.0f/9.0f, 0.0f, 0.0f,
- -2.0f/9.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f/9.0f, 0.0f, 0.0f,
- 4.0f/9.0f, 0.0f, 0.0f, 6.0f/9.0f, 0.0f, 0.0f, 8.0f/9.0f, 0.0f, 0.0f,
- -8.0f/9.0f, 2.0f/9.0f, 0.0f, -6.0f/9.0f, 2.0f/9.0f, 0.0f, -4.0f/9.0f, 2.0f/9.0f, 0.0f,
- -2.0f/9.0f, 2.0f/9.0f, 0.0f, 0.0f, 2.0f/9.0f, 0.0f, 2.0f/9.0f, 2.0f/9.0f, 0.0f,
- 4.0f/9.0f, 2.0f/9.0f, 0.0f, 6.0f/9.0f, 2.0f/9.0f, 0.0f, 8.0f/9.0f, 2.0f/9.0f, 0.0f,
- -8.0f/9.0f, 4.0f/9.0f, 0.0f, -6.0f/9.0f, 4.0f/9.0f, 0.0f, -4.0f/9.0f, 4.0f/9.0f, 0.0f,
- -2.0f/9.0f, 4.0f/9.0f, 0.0f, 0.0f, 4.0f/9.0f, 0.0f, 2.0f/9.0f, 4.0f/9.0f, 0.0f,
- 4.0f/9.0f, 4.0f/9.0f, 0.0f, 6.0f/9.0f, 4.0f/9.0f, 0.0f, 8.0f/9.0f, 4.0f/9.0f, 0.0f,
- -8.0f/9.0f, 6.0f/9.0f, 0.0f, -6.0f/9.0f, 6.0f/9.0f, 0.0f, -4.0f/9.0f, 6.0f/9.0f, 0.0f,
- -2.0f/9.0f, 6.0f/9.0f, 0.0f, 0.0f, 6.0f/9.0f, 0.0f, 2.0f/9.0f, 6.0f/9.0f, 0.0f,
- 4.0f/9.0f, 6.0f/9.0f, 0.0f, 6.0f/9.0f, 6.0f/9.0f, 0.0f, 8.0f/9.0f, 6.0f/9.0f, 0.0f,
- -8.0f/9.0f, 8.0f/9.0f, 0.0f, -6.0f/9.0f, 8.0f/9.0f, 0.0f, -4.0f/9.0f, 8.0f/9.0f, 0.0f,
- -2.0f/9.0f, 8.0f/9.0f, 0.0f, 0.0f, 8.0f/9.0f, 0.0f, 2.0f/9.0f, 8.0f/9.0f, 0.0f,
- 4.0f/9.0f, 8.0f/9.0f, 0.0f, 6.0f/9.0f, 8.0f/9.0f, 0.0f, 8.0f/9.0f, 8.0f/9.0f, 0.0f,
- -8.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, 0.0f, -8.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 0.0f, -6.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 0.0f, -4.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, 0.0f, -2.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, 0.0f, 2.0f/9.0f, -6.0f/9.0f, 0.0f, 2.0f/9.0f, -4.0f/9.0f, 0.0f, 2.0f/9.0f,
- -2.0f/9.0f, 0.0f, 2.0f/9.0f, 0.0f, 0.0f, 2.0f/9.0f, 2.0f/9.0f, 0.0f, 2.0f/9.0f,
- 4.0f/9.0f, 0.0f, 2.0f/9.0f, 6.0f/9.0f, 0.0f, 2.0f/9.0f, 8.0f/9.0f, 0.0f, 2.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 0.0f, 2.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, 0.0f, 4.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 0.0f, 6.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 0.0f, 8.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f,
- -8.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f, 0.0f, -8.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, 0.0f, -6.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, 0.0f, -4.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f, 0.0f, -2.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, 0.0f, 4.0f/9.0f, -6.0f/9.0f, 0.0f, 4.0f/9.0f, -4.0f/9.0f, 0.0f, 4.0f/9.0f,
- -2.0f/9.0f, 0.0f, 4.0f/9.0f, 0.0f, 0.0f, 4.0f/9.0f, 2.0f/9.0f, 0.0f, 4.0f/9.0f,
- 4.0f/9.0f, 0.0f, 4.0f/9.0f, 6.0f/9.0f, 0.0f, 4.0f/9.0f, 8.0f/9.0f, 0.0f, 4.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, 0.0f, 2.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f, 0.0f, 4.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, 0.0f, 6.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, 0.0f, 8.0f/9.0f, 4.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f,
- -8.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, 0.0f, -8.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 0.0f, -6.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 0.0f, -4.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, 0.0f, -2.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, 0.0f, 6.0f/9.0f, -6.0f/9.0f, 0.0f, 6.0f/9.0f, -4.0f/9.0f, 0.0f, 6.0f/9.0f,
- -2.0f/9.0f, 0.0f, 6.0f/9.0f, 0.0f, 0.0f, 6.0f/9.0f, 2.0f/9.0f, 0.0f, 6.0f/9.0f,
- 4.0f/9.0f, 0.0f, 6.0f/9.0f, 6.0f/9.0f, 0.0f, 6.0f/9.0f, 8.0f/9.0f, 0.0f, 6.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 0.0f, 2.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, 0.0f, 4.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 0.0f, 6.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 0.0f, 8.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f,
- -8.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, 0.0f, -8.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -8.0f/9.0f, 8.0f/9.0f,
- -8.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 0.0f, -6.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f,
- -8.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 0.0f, -4.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f,
- -8.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, 0.0f, -2.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -2.0f/9.0f, 8.0f/9.0f,
- -8.0f/9.0f, 0.0f, 8.0f/9.0f, -6.0f/9.0f, 0.0f, 8.0f/9.0f, -4.0f/9.0f, 0.0f, 8.0f/9.0f,
- -2.0f/9.0f, 0.0f, 8.0f/9.0f, 0.0f, 0.0f, 8.0f/9.0f, 2.0f/9.0f, 0.0f, 8.0f/9.0f,
- 4.0f/9.0f, 0.0f, 8.0f/9.0f, 6.0f/9.0f, 0.0f, 8.0f/9.0f, 8.0f/9.0f, 0.0f, 8.0f/9.0f,
- -8.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 0.0f, 2.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f,
- -8.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, 0.0f, 4.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 4.0f/9.0f, 8.0f/9.0f,
- -8.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 0.0f, 6.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f,
- -8.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -6.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, -4.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f,
- -2.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 0.0f, 8.0f/9.0f, 8.0f/9.0f, 2.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f,
- 4.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 6.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f, 8.0f/9.0f
- };
-
- // data taken from ISO/IEC DIS 11172, Annexes 3-B.2[abcd] and 3-B.4:
-
- // subbands 0-2 in tables 3-B.2a and 2b: (index is allocation)
- public static final int table_ab1_codelength[] =
- // bits per codeword
- { 0, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
-
- public static final float table_ab1_groupingtables[][] =
- // pointer to sample grouping table, or NULL-pointer if ungrouped
- { null, grouping_5bits, null, null, null, null, null, null, null, null, null, null, null, null, null, null };
-
- public static final float table_ab1_factor[] =
- // factor for requantization: (real)sample * factor - 1.0 gives requantized sample
- { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/16.0f, 1.0f/32.0f, 1.0f/64.0f,
- 1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f, 1.0f/1024.0f, 1.0f/2048.0f,
- 1.0f/4096.0f, 1.0f/8192.0f, 1.0f/16384.0f, 1.0f/32768.0f };
-
- public static final float table_ab1_c[] =
- // factor c for requantization from table 3-B.4
- { 0.0f, 1.33333333333f, 1.14285714286f, 1.06666666666f, 1.03225806452f,
- 1.01587301587f, 1.00787401575f, 1.00392156863f, 1.00195694716f, 1.00097751711f,
- 1.00048851979f, 1.00024420024f, 1.00012208522f, 1.00006103888f, 1.00003051851f,
- 1.00001525902f };
-
- public static final float table_ab1_d[] =
- // addend d for requantization from table 3-B.4
- { 0.0f, 0.50000000000f, 0.25000000000f, 0.12500000000f, 0.06250000000f,
- 0.03125000000f, 0.01562500000f, 0.00781250000f, 0.00390625000f, 0.00195312500f,
- 0.00097656250f, 0.00048828125f, 0.00024414063f, 0.00012207031f, 0.00006103516f,
- 0.00003051758f };
-
- // subbands 3-... tables 3-B.2a and 2b:
- public static final float[] table_ab234_groupingtables[] =
- { null, grouping_5bits, grouping_7bits, null, grouping_10bits, null, null, null, null, null, null, null, null, null, null, null };
-
- // subbands 3-10 in tables 3-B.2a and 2b:
- public static final int table_ab2_codelength[] =
- { 0, 5, 7, 3, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 };
- public static final float table_ab2_factor[] =
- { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/8.0f, 1.0f/16.0f,
- 1.0f/32.0f, 1.0f/64.0f, 1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f,
- 1.0f/1024.0f, 1.0f/2048.0f, 1.0f/4096.0f, 1.0f/32768.0f };
- public static final float table_ab2_c[] =
- { 0.0f, 1.33333333333f, 1.60000000000f, 1.14285714286f, 1.77777777777f,
- 1.06666666666f, 1.03225806452f, 1.01587301587f, 1.00787401575f, 1.00392156863f,
- 1.00195694716f, 1.00097751711f, 1.00048851979f, 1.00024420024f, 1.00012208522f,
- 1.00001525902f };
- public static final float table_ab2_d[] =
- { 0.0f, 0.50000000000f, 0.50000000000f, 0.25000000000f, 0.50000000000f,
- 0.12500000000f, 0.06250000000f, 0.03125000000f, 0.01562500000f, 0.00781250000f,
- 0.00390625000f, 0.00195312500f, 0.00097656250f, 0.00048828125f, 0.00024414063f,
- 0.00003051758f };
-
- // subbands 11-22 in tables 3-B.2a and 2b:
- public static final int table_ab3_codelength[] = { 0, 5, 7, 3, 10, 4, 5, 16 };
- public static final float table_ab3_factor[] =
- { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/8.0f, 1.0f/16.0f, 1.0f/32768.0f };
- public static final float table_ab3_c[] =
- { 0.0f, 1.33333333333f, 1.60000000000f, 1.14285714286f, 1.77777777777f,
- 1.06666666666f, 1.03225806452f, 1.00001525902f };
- public static final float table_ab3_d[] =
- { 0.0f, 0.50000000000f, 0.50000000000f, 0.25000000000f, 0.50000000000f,
- 0.12500000000f, 0.06250000000f, 0.00003051758f };
-
- // subbands 23-... in tables 3-B.2a and 2b:
- public static final int table_ab4_codelength[] = { 0, 5, 7, 16 };
- public static final float table_ab4_factor[] = { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/32768.0f };
- public static final float table_ab4_c[] = { 0.0f, 1.33333333333f, 1.60000000000f, 1.00001525902f };
- public static final float table_ab4_d[] = { 0.0f, 0.50000000000f, 0.50000000000f, 0.00003051758f };
-
- // subbands in tables 3-B.2c and 2d:
- public static final int table_cd_codelength[] =
- { 0, 5, 7, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
- public static final float table_cd_groupingtables[][] =
- { null, grouping_5bits, grouping_7bits, grouping_10bits, null, null, null, null, null, null, null, null, null, null, null, null };
- public static final float table_cd_factor[] =
- { 0.0f, 1.0f/2.0f, 1.0f/4.0f, 1.0f/8.0f, 1.0f/8.0f, 1.0f/16.0f, 1.0f/32.0f, 1.0f/64.0f,
- 1.0f/128.0f, 1.0f/256.0f, 1.0f/512.0f, 1.0f/1024.0f, 1.0f/2048.0f, 1.0f/4096.0f,
- 1.0f/8192.0f, 1.0f/16384.0f };
- public static final float table_cd_c[] =
- { 0.0f, 1.33333333333f, 1.60000000000f, 1.77777777777f, 1.06666666666f,
- 1.03225806452f, 1.01587301587f, 1.00787401575f, 1.00392156863f, 1.00195694716f,
- 1.00097751711f, 1.00048851979f, 1.00024420024f, 1.00012208522f, 1.00006103888f,
- 1.00003051851f };
- public static final float table_cd_d[] =
- { 0.0f, 0.50000000000f, 0.50000000000f, 0.50000000000f, 0.12500000000f,
- 0.06250000000f, 0.03125000000f, 0.01562500000f, 0.00781250000f, 0.00390625000f,
- 0.00195312500f, 0.00097656250f, 0.00048828125f, 0.00024414063f, 0.00012207031f,
- 0.00006103516f };
-
-
-
- protected int subbandnumber;
- protected int allocation;
- protected int scfsi;
- protected float scalefactor1, scalefactor2, scalefactor3;
- protected int[] codelength = {0};
- protected float groupingtable[][] = new float[2][];
- //protected float[][] groupingtable = {{0},{0}} ;
- protected float[] factor = {0.0f};
- protected int groupnumber;
- protected int samplenumber;
- protected float[] samples = new float[3];
- protected float[] c = {0};
- protected float[] d = {0};
- /**
- * Constructor
- */
- public SubbandLayer2(int subbandnumber)
- {
- this.subbandnumber = subbandnumber;
- groupnumber = samplenumber = 0;
- }
-
-
- /**
- *
- */
- protected int get_allocationlength (Header header)
- {
- if (header.version() == Header.MPEG1)
- {
- int channel_bitrate = header.bitrate_index();
-
- // calculate bitrate per channel:
- if (header.mode() != Header.SINGLE_CHANNEL)
- if (channel_bitrate == 4)
- channel_bitrate = 1;
- else
- channel_bitrate -= 4;
-
- if (channel_bitrate == 1 || channel_bitrate == 2)
- // table 3-B.2c or 3-B.2d
- if (subbandnumber <= 1)
- return 4;
- else
- return 3;
- else
- // tables 3-B.2a or 3-B.2b
- if (subbandnumber <= 10)
- return 4;
- else if (subbandnumber <= 22)
- return 3;
- else
- return 2;
- }
- else
- { // MPEG-2 LSF -- Jeff
-
- // table B.1 of ISO/IEC 13818-3
- if (subbandnumber <= 3)
- return 4;
- else if (subbandnumber <= 10)
- return 3;
- else
- return 2;
- }
- }
-
- /**
- *
- */
- protected void prepare_sample_reading(Header header, int allocation,
- //float[][] groupingtable,
- int channel,
- float[] factor, int[] codelength,
- float[] c, float[] d)
- {
- int channel_bitrate = header.bitrate_index();
- // calculate bitrate per channel:
- if (header.mode() != Header.SINGLE_CHANNEL)
- if (channel_bitrate == 4)
- channel_bitrate = 1;
- else
- channel_bitrate -= 4;
-
- if (channel_bitrate == 1 || channel_bitrate == 2)
- {
- // table 3-B.2c or 3-B.2d
- groupingtable[channel] = table_cd_groupingtables[allocation];
- factor[0] = table_cd_factor[allocation];
- codelength[0] = table_cd_codelength[allocation];
- c[0] = table_cd_c[allocation];
- d[0] = table_cd_d[allocation];
- }
- else
- {
- // tables 3-B.2a or 3-B.2b
- if (subbandnumber <= 2)
- {
- groupingtable[channel] = table_ab1_groupingtables[allocation];
- factor[0] = table_ab1_factor[allocation];
- codelength[0] = table_ab1_codelength[allocation];
- c[0] = table_ab1_c[allocation];
- d[0] = table_ab1_d[allocation];
- }
- else
- {
- groupingtable[channel] = table_ab234_groupingtables[allocation];
- if (subbandnumber <= 10)
- {
- factor[0] = table_ab2_factor[allocation];
- codelength[0] = table_ab2_codelength[allocation];
- c[0] = table_ab2_c[allocation];
- d[0] = table_ab2_d[allocation];
- }
- else if (subbandnumber <= 22)
- {
- factor[0] = table_ab3_factor[allocation];
- codelength[0] = table_ab3_codelength[allocation];
- c[0] = table_ab3_c[allocation];
- d[0] = table_ab3_d[allocation];
- }
- else
- {
- factor[0] = table_ab4_factor[allocation];
- codelength[0] = table_ab4_codelength[allocation];
- c[0] = table_ab4_c[allocation];
- d[0] = table_ab4_d[allocation];
- }
- }
- }
- }
-
-
- /**
- *
- */
- public void read_allocation(Bitstream stream, Header header, Crc16 crc)
- {
- int length = get_allocationlength(header);
- allocation = stream.get_bits(length);
- if (crc != null)
- crc.add_bits(allocation, length);
- }
-
- /**
- *
- */
- public void read_scalefactor_selection (Bitstream stream, Crc16 crc)
- {
- if (allocation != 0)
- {
- scfsi = stream.get_bits(2);
- if (crc != null) crc.add_bits(scfsi, 2);
- }
- }
-
- /**
- *
- */
- public void read_scalefactor (Bitstream stream, Header header)
- {
- if (allocation != 0)
- {
- switch (scfsi)
- {
- case 0:
- scalefactor1 = scalefactors[stream.get_bits(6)];
- scalefactor2 = scalefactors[stream.get_bits(6)];
- scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
- case 1:
- scalefactor1 = scalefactor2 = scalefactors[stream.get_bits(6)];
- scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
- case 2:
- scalefactor1 = scalefactor2 = scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
- case 3:
- scalefactor1 = scalefactors[stream.get_bits(6)];
- scalefactor2 = scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
- }
- prepare_sample_reading(header, allocation, 0,
- factor, codelength, c, d);
- }
- }
-
- /**
- *
- */
- public boolean read_sampledata (Bitstream stream)
- {
- if (allocation != 0)
- if (groupingtable[0] != null)
- {
- int samplecode = stream.get_bits(codelength[0]);
- // create requantized samples:
- samplecode += samplecode << 1;
- float[] target = samples;
- float[] source = groupingtable[0];
- /*
- int tmp = 0;
- int temp = 0;
- target[tmp++] = source[samplecode + temp];
- temp++;
- target[tmp++] = source[samplecode + temp];
- temp++;
- target[tmp] = source[samplecode + temp];
- */
- //Bugfix:
- int tmp = 0;
- int temp = samplecode;
-
- if(temp > source.length - 3) temp = source.length - 3;
-
- target[tmp] = source[temp];
- temp++;tmp++;
- target[tmp] = source[temp];
- temp++;tmp++;
- target[tmp] = source[temp];
-
- // memcpy (samples, groupingtable + samplecode, 3 * sizeof (real));
- }
- else
- {
- samples[0] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0);
- samples[1] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0);
- samples[2] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0);
- }
-
- samplenumber = 0;
- if (++groupnumber == 12)
- return true;
- else
- return false;
- }
-
- /**
- *
- */
- public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
- {
- if ((allocation != 0) && (channels != OutputChannels.RIGHT_CHANNEL))
- {
- float sample = samples[samplenumber];
-
- if (groupingtable[0] == null)
- sample = (sample + d[0]) * c[0];
- if (groupnumber <= 4)
- sample *= scalefactor1;
- else if (groupnumber <= 8)
- sample *= scalefactor2;
- else
- sample *= scalefactor3;
- filter1.input_sample(sample, subbandnumber);
- }
-
- if (++samplenumber == 3)
- return true;
- else
- return false;
- }
- };
-
- /**
- * Class for layer II subbands in joint stereo mode.
- */
- static class SubbandLayer2IntensityStereo extends SubbandLayer2
- {
- protected int channel2_scfsi;
- protected float channel2_scalefactor1, channel2_scalefactor2, channel2_scalefactor3;
-
- /**
- * Constructor
- */
- public SubbandLayer2IntensityStereo (int subbandnumber)
- {
- super(subbandnumber);
- }
-
- /**
- *
- */
- public void read_allocation(Bitstream stream, Header header, Crc16 crc)
- {
- super.read_allocation (stream, header, crc);
- }
-
- /**
- *
- */
- public void read_scalefactor_selection(Bitstream stream, Crc16 crc)
- {
- if (allocation != 0)
- {
- scfsi = stream.get_bits(2);
- channel2_scfsi = stream.get_bits(2);
- if (crc != null)
- {
- crc.add_bits(scfsi, 2);
- crc.add_bits(channel2_scfsi, 2);
- }
- }
- }
-
- /**
- *
- */
- public void read_scalefactor(Bitstream stream, Header header)
- {
- if (allocation != 0)
- {
- super.read_scalefactor(stream, header);
- switch (channel2_scfsi)
- {
- case 0:
- channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
- channel2_scalefactor2 = scalefactors[stream.get_bits(6)];
- channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
-
- case 1:
- channel2_scalefactor1 = channel2_scalefactor2 = scalefactors[stream.get_bits (6)];
- channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
-
- case 2:
- channel2_scalefactor1 = channel2_scalefactor2 =
- channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
-
- case 3:
- channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
- channel2_scalefactor2 = channel2_scalefactor3 = scalefactors[stream.get_bits (6)];
- break;
- }
- }
-
- }
-
- /**
- *
- */
- public boolean read_sampledata(Bitstream stream)
- {
- return super.read_sampledata (stream);
- }
-
- /**
- *
- */
- public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
- {
- if (allocation != 0)
- {
- float sample = samples[samplenumber];
-
- if (groupingtable[0] == null)
- sample = (sample + d[0]) * c[0];
- if (channels == OutputChannels.BOTH_CHANNELS)
- {
- float sample2 = sample;
- if (groupnumber <= 4)
- {
- sample *= scalefactor1;
- sample2 *= channel2_scalefactor1;
- }
- else if (groupnumber <= 8)
- {
- sample *= scalefactor2;
- sample2 *= channel2_scalefactor2;
- }
- else
- {
- sample *= scalefactor3;
- sample2 *= channel2_scalefactor3;
- }
- filter1.input_sample(sample, subbandnumber);
- filter2.input_sample(sample2, subbandnumber);
- }
- else if (channels == OutputChannels.LEFT_CHANNEL)
- {
- if (groupnumber <= 4)
- sample *= scalefactor1;
- else if (groupnumber <= 8)
- sample *= scalefactor2;
- else
- sample *= scalefactor3;
- filter1.input_sample(sample, subbandnumber);
- }
- else
- {
- if (groupnumber <= 4)
- sample *= channel2_scalefactor1;
- else if (groupnumber <= 8)
- sample *= channel2_scalefactor2;
- else
- sample *= channel2_scalefactor3;
- filter1.input_sample(sample, subbandnumber);
- }
- }
-
- if (++samplenumber == 3)
- return true;
- else
- return false;
- }
- };
-
- /**
- * Class for layer II subbands in stereo mode.
- */
- static class SubbandLayer2Stereo extends SubbandLayer2
- {
- protected int channel2_allocation;
- protected int channel2_scfsi;
- protected float channel2_scalefactor1, channel2_scalefactor2, channel2_scalefactor3;
- //protected boolean channel2_grouping; ???? Never used!
- protected int[] channel2_codelength = {0};
- //protected float[][] channel2_groupingtable = {{0},{0}};
- protected float[] channel2_factor = {0};
- protected float[] channel2_samples;
- protected float[] channel2_c = {0};
- protected float[] channel2_d = {0};
-
- /**
- * Constructor
- */
- public SubbandLayer2Stereo(int subbandnumber)
- {
- super(subbandnumber);
- channel2_samples = new float[3];
- }
-
- /**
- *
- */
- public void read_allocation (Bitstream stream, Header header, Crc16 crc)
- {
- int length = get_allocationlength(header);
- allocation = stream.get_bits(length);
- channel2_allocation = stream.get_bits(length);
- if (crc != null)
- {
- crc.add_bits(allocation, length);
- crc.add_bits(channel2_allocation, length);
- }
- }
-
- /**
- *
- */
- public void read_scalefactor_selection(Bitstream stream, Crc16 crc)
- {
- if (allocation != 0)
- {
- scfsi = stream.get_bits(2);
- if (crc != null)
- crc.add_bits(scfsi, 2);
- }
- if (channel2_allocation != 0)
- {
- channel2_scfsi = stream.get_bits(2);
- if (crc != null)
- crc.add_bits(channel2_scfsi, 2);
- }
- }
-
- /**
- *
- */
- public void read_scalefactor(Bitstream stream, Header header)
- {
- super.read_scalefactor(stream, header);
- if (channel2_allocation != 0)
- {
- switch (channel2_scfsi)
- {
- case 0:
- channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
- channel2_scalefactor2 = scalefactors[stream.get_bits(6)];
- channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
-
- case 1:
- channel2_scalefactor1 = channel2_scalefactor2 =
- scalefactors[stream.get_bits(6)];
- channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
-
- case 2:
- channel2_scalefactor1 = channel2_scalefactor2 =
- channel2_scalefactor3 = scalefactors[stream.get_bits(6)];
- break;
-
- case 3:
- channel2_scalefactor1 = scalefactors[stream.get_bits(6)];
- channel2_scalefactor2 = channel2_scalefactor3 =
- scalefactors[stream.get_bits(6)];
- break;
- }
- prepare_sample_reading(header, channel2_allocation, 1,
- channel2_factor, channel2_codelength, channel2_c,
- channel2_d);
- }
- }
-
- /**
- *
- */
- public boolean read_sampledata (Bitstream stream)
- {
- boolean returnvalue = super.read_sampledata(stream);
-
- if (channel2_allocation != 0)
- if (groupingtable[1] != null)
- {
- int samplecode = stream.get_bits(channel2_codelength[0]);
- // create requantized samples:
- samplecode += samplecode << 1;
- /*
- float[] target = channel2_samples;
- float[] source = channel2_groupingtable[0];
- int tmp = 0;
- int temp = 0;
- target[tmp++] = source[samplecode + temp];
- temp++;
- target[tmp++] = source[samplecode + temp];
- temp++;
- target[tmp] = source[samplecode + temp];
- // memcpy (channel2_samples, channel2_groupingtable + samplecode, 3 * sizeof (real));
- */
- float[] target = channel2_samples;
- float[] source = groupingtable[1];
- int tmp = 0;
- int temp = samplecode;
- target[tmp] = source[temp];
- temp++;tmp++;
- target[tmp] = source[temp];
- temp++;tmp++;
- target[tmp] = source[temp];
-
- }
- else
- {
- channel2_samples[0] = (float) ((stream.get_bits(channel2_codelength[0])) *
- channel2_factor[0] - 1.0);
- channel2_samples[1] = (float) ((stream.get_bits(channel2_codelength[0])) *
- channel2_factor[0] - 1.0);
- channel2_samples[2] = (float) ((stream.get_bits(channel2_codelength[0])) *
- channel2_factor[0] - 1.0);
- }
- return returnvalue;
- }
-
- /**
- *
- */
- public boolean put_next_sample(int channels, SynthesisFilter filter1, SynthesisFilter filter2)
- {
- boolean returnvalue = super.put_next_sample(channels, filter1, filter2);
- if ((channel2_allocation != 0) && (channels != OutputChannels.LEFT_CHANNEL))
- {
- float sample = channel2_samples[samplenumber - 1];
-
- if (groupingtable[1] == null)
- sample = (sample + channel2_d[0]) * channel2_c[0];
-
- if (groupnumber <= 4)
- sample *= channel2_scalefactor1;
- else if (groupnumber <= 8)
- sample *= channel2_scalefactor2;
- else
- sample *= channel2_scalefactor3;
- if (channels == OutputChannels.BOTH_CHANNELS)
- filter2.input_sample(sample, subbandnumber);
- else
- filter1.input_sample(sample, subbandnumber);
- }
- return returnvalue;
- }
- }
-}
diff --git a/songdbj/javazoom/jl/decoder/LayerIIIDecoder.java b/songdbj/javazoom/jl/decoder/LayerIIIDecoder.java
deleted file mode 100644
index 602badf0f2..0000000000
--- a/songdbj/javazoom/jl/decoder/LayerIIIDecoder.java
+++ /dev/null
@@ -1,2439 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 18/06/01 Michael Scheerer, Fixed bugs which causes
- * negative indexes in method huffmann_decode and in method
- * dequanisize_sample.
- *
- * 16/07/01 Michael Scheerer, Catched a bug in method
- * huffmann_decode, which causes an outOfIndexException.
- * Cause : Indexnumber of 24 at SfBandIndex,
- * which has only a length of 22. I have simply and dirty
- * fixed the index to <= 22, because I'm not really be able
- * to fix the bug. The Indexnumber is taken from the MP3
- * file and the origin Ma-Player with the same code works
- * well.
- *
- * 02/19/99 Java Conversion by E.B, javalayer@javazoom.net
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Class Implementing Layer 3 Decoder.
- *
- * @since 0.0
- */
-final class LayerIIIDecoder implements FrameDecoder
-{
- final double d43 = (4.0/3.0);
-
- public int[] scalefac_buffer;
-
- // MDM: removed, as this wasn't being used.
- //private float CheckSumOut1d = 0.0f;
- private int CheckSumHuff = 0;
- private int[] is_1d;
- private float[][][] ro;
- private float[][][] lr;
- private float[] out_1d;
- private float[][] prevblck;
- private float[][] k;
- private int[] nonzero;
- private Bitstream stream;
- private Header header;
- private SynthesisFilter filter1, filter2;
- private Obuffer buffer;
- private int which_channels;
- private BitReserve br;
- private III_side_info_t si;
-
- private temporaire2[] III_scalefac_t;
- private temporaire2[] scalefac;
- // private III_scalefac_t scalefac;
-
- private int max_gr;
- private int frame_start;
- private int part2_start;
- private int channels;
- private int first_channel;
- private int last_channel;
- private int sfreq;
-
-
- /**
- * Constructor.
- */
- // REVIEW: these constructor arguments should be moved to the
- // decodeFrame() method, where possible, so that one
- public LayerIIIDecoder(Bitstream stream0, Header header0,
- SynthesisFilter filtera, SynthesisFilter filterb,
- Obuffer buffer0, int which_ch0)
- {
- huffcodetab.inithuff();
- is_1d = new int[SBLIMIT*SSLIMIT+4];
- ro = new float[2][SBLIMIT][SSLIMIT];
- lr = new float[2][SBLIMIT][SSLIMIT];
- out_1d = new float[SBLIMIT*SSLIMIT];
- prevblck = new float[2][SBLIMIT*SSLIMIT];
- k = new float[2][SBLIMIT*SSLIMIT];
- nonzero = new int[2];
-
- //III_scalefact_t
- III_scalefac_t = new temporaire2[2];
- III_scalefac_t[0] = new temporaire2();
- III_scalefac_t[1] = new temporaire2();
- scalefac = III_scalefac_t;
- // L3TABLE INIT
-
- sfBandIndex = new SBI[9]; // SZD: MPEG2.5 +3 indices
- int[] l0 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};
- int[] s0 = {0,4,8,12,18,24,32,42,56,74,100,132,174,192};
- int[] l1 = {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576};
- int[] s1 = {0,4,8,12,18,26,36,48,62,80,104,136,180,192};
- int[] l2 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};
- int[] s2 = {0,4,8,12,18,26,36,48,62,80,104,134,174,192};
-
- int[] l3 = {0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576};
- int[] s3 = {0,4,8,12,16,22,30,40,52,66,84,106,136,192};
- int[] l4 = {0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576};
- int[] s4 = {0,4,8,12,16,22,28,38,50,64,80,100,126,192};
- int[] l5 = {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576};
- int[] s5 = {0,4,8,12,16,22,30,42,58,78,104,138,180,192};
- // SZD: MPEG2.5
- int[] l6 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};
- int[] s6 = {0,4,8,12,18,26,36,48,62,80,104,134,174,192};
- int[] l7 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};
- int[] s7 = {0,4,8,12,18,26,36,48,62,80,104,134,174,192};
- int[] l8 = {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576};
- int[] s8 = {0,8,16,24,36,52,72,96,124,160,162,164,166,192};
-
- sfBandIndex[0]= new SBI(l0,s0);
- sfBandIndex[1]= new SBI(l1,s1);
- sfBandIndex[2]= new SBI(l2,s2);
-
- sfBandIndex[3]= new SBI(l3,s3);
- sfBandIndex[4]= new SBI(l4,s4);
- sfBandIndex[5]= new SBI(l5,s5);
- //SZD: MPEG2.5
- sfBandIndex[6]= new SBI(l6,s6);
- sfBandIndex[7]= new SBI(l7,s7);
- sfBandIndex[8]= new SBI(l8,s8);
- // END OF L3TABLE INIT
-
- if(reorder_table == null) { // SZD: generate LUT
- reorder_table = new int[9][];
- for(int i = 0; i < 9; i++)
- reorder_table[i] = reorder(sfBandIndex[i].s);
- }
-
- // Sftable
- int[] ll0 = {0, 6, 11, 16, 21};
- int[] ss0 = {0, 6, 12};
- sftable = new Sftable(ll0,ss0);
- // END OF Sftable
-
- // scalefac_buffer
- scalefac_buffer = new int[54];
- // END OF scalefac_buffer
-
- stream = stream0;
- header = header0;
- filter1 = filtera;
- filter2 = filterb;
- buffer = buffer0;
- which_channels = which_ch0;
-
- frame_start = 0;
- channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;
- max_gr = (header.version() == Header.MPEG1) ? 2 : 1;
-
- sfreq = header.sample_frequency() +
- ((header.version() == Header.MPEG1) ? 3 :
- (header.version() == Header.MPEG25_LSF) ? 6 : 0); // SZD
-
- if (channels == 2)
- {
- switch (which_channels)
- {
- case OutputChannels.LEFT_CHANNEL:
- case OutputChannels.DOWNMIX_CHANNELS:
- first_channel = last_channel = 0;
- break;
-
- case OutputChannels.RIGHT_CHANNEL:
- first_channel = last_channel = 1;
- break;
-
- case OutputChannels.BOTH_CHANNELS:
- default:
- first_channel = 0;
- last_channel = 1;
- break;
- }
- }
- else
- {
- first_channel = last_channel = 0;
- }
-
- for(int ch=0;ch<2;ch++)
- for (int j=0; j<576; j++)
- prevblck[ch][j] = 0.0f;
-
- nonzero[0] = nonzero[1] = 576;
-
- br = new BitReserve();
- si = new III_side_info_t();
- }
-
- /**
- * Notify decoder that a seek is being made.
- */
- public void seek_notify()
- {
- frame_start = 0;
- for(int ch=0;ch<2;ch++)
- for (int j=0; j<576; j++)
- prevblck[ch][j] = 0.0f;
- br = new BitReserve();
- }
-
- public void decodeFrame()
- {
- decode();
- }
-
- /**
- * Decode one frame, filling the buffer with the output samples.
- */
-
- // subband samples are buffered and passed to the
- // SynthesisFilter in one go.
- private float[] samples1 = new float[32];
- private float[] samples2 = new float[32];
-
- public void decode()
- {
- int nSlots = header.slots();
- int flush_main;
- int gr, ch, ss, sb, sb18;
- int main_data_end;
- int bytes_to_discard;
- int i;
-
- get_side_info();
-
- for (i=0; i<nSlots; i++)
- br.hputbuf(stream.get_bits(8));
-
- main_data_end = br.hsstell() >>> 3; // of previous frame
-
- if ((flush_main = (br.hsstell() & 7)) != 0) {
- br.hgetbits(8 - flush_main);
- main_data_end++;
- }
-
- bytes_to_discard = frame_start - main_data_end
- - si.main_data_begin;
-
- frame_start += nSlots;
-
- if (bytes_to_discard < 0)
- return;
-
- if (main_data_end > 4096) {
- frame_start -= 4096;
- br.rewindNbytes(4096);
- }
-
- for (; bytes_to_discard > 0; bytes_to_discard--)
- br.hgetbits(8);
-
- for (gr=0;gr<max_gr;gr++) {
-
- for (ch=0; ch<channels; ch++) {
- part2_start = br.hsstell();
-
- if (header.version() == Header.MPEG1)
- get_scale_factors(ch, gr);
- else // MPEG-2 LSF, SZD: MPEG-2.5 LSF
- get_LSF_scale_factors(ch, gr);
-
- huffman_decode(ch, gr);
- // System.out.println("CheckSum HuffMan = " + CheckSumHuff);
- dequantize_sample(ro[ch], ch, gr);
- }
-
- stereo(gr);
-
- if ((which_channels == OutputChannels.DOWNMIX_CHANNELS) && (channels > 1))
- do_downmix();
-
- for (ch=first_channel; ch<=last_channel; ch++) {
-
- reorder(lr[ch], ch, gr);
- antialias(ch, gr);
- //for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + out_1d[hb];
- //System.out.println("CheckSumOut1d = "+CheckSumOut1d);
-
- hybrid(ch, gr);
-
- //for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + out_1d[hb];
- //System.out.println("CheckSumOut1d = "+CheckSumOut1d);
-
- for (sb18=18;sb18<576;sb18+=36) // Frequency inversion
- for (ss=1;ss<SSLIMIT;ss+=2)
- out_1d[sb18 + ss] = -out_1d[sb18 + ss];
-
- if ((ch == 0) || (which_channels == OutputChannels.RIGHT_CHANNEL)) {
- for (ss=0;ss<SSLIMIT;ss++) { // Polyphase synthesis
- sb = 0;
- for (sb18=0; sb18<576; sb18+=18) {
- samples1[sb] = out_1d[sb18+ss];
- //filter1.input_sample(out_1d[sb18+ss], sb);
- sb++;
- }
- filter1.input_samples(samples1);
- filter1.calculate_pcm_samples(buffer);
- }
- } else {
- for (ss=0;ss<SSLIMIT;ss++) { // Polyphase synthesis
- sb = 0;
- for (sb18=0; sb18<576; sb18+=18) {
- samples2[sb] = out_1d[sb18+ss];
- //filter2.input_sample(out_1d[sb18+ss], sb);
- sb++;
- }
- filter2.input_samples(samples2);
- filter2.calculate_pcm_samples(buffer);
- }
-
- }
- } // channels
- } // granule
-
-
- // System.out.println("Counter = ................................."+counter);
- //if (counter < 609)
- //{
- counter++;
- buffer.write_buffer(1);
- //}
- //else if (counter == 609)
- //{
- // buffer.close();
- // counter++;
- //}
- //else
- //{
- //}
-
- }
-
- /**
- * Reads the side info from the stream, assuming the entire.
- * frame has been read already.
- * Mono : 136 bits (= 17 bytes)
- * Stereo : 256 bits (= 32 bytes)
- */
- private boolean get_side_info()
- {
- int ch, gr;
- if (header.version() == Header.MPEG1)
- {
-
- si.main_data_begin = stream.get_bits(9);
- if (channels == 1)
- si.private_bits = stream.get_bits(5);
- else si.private_bits = stream.get_bits(3);
-
- for (ch=0; ch<channels; ch++) {
- si.ch[ch].scfsi[0] = stream.get_bits(1);
- si.ch[ch].scfsi[1] = stream.get_bits(1);
- si.ch[ch].scfsi[2] = stream.get_bits(1);
- si.ch[ch].scfsi[3] = stream.get_bits(1);
- }
-
- for (gr=0; gr<2; gr++) {
- for (ch=0; ch<channels; ch++) {
- si.ch[ch].gr[gr].part2_3_length = stream.get_bits(12);
- si.ch[ch].gr[gr].big_values = stream.get_bits(9);
- si.ch[ch].gr[gr].global_gain = stream.get_bits(8);
- si.ch[ch].gr[gr].scalefac_compress = stream.get_bits(4);
- si.ch[ch].gr[gr].window_switching_flag = stream.get_bits(1);
- if ((si.ch[ch].gr[gr].window_switching_flag) != 0) {
- si.ch[ch].gr[gr].block_type = stream.get_bits(2);
- si.ch[ch].gr[gr].mixed_block_flag = stream.get_bits(1);
-
- si.ch[ch].gr[gr].table_select[0] = stream.get_bits(5);
- si.ch[ch].gr[gr].table_select[1] = stream.get_bits(5);
-
- si.ch[ch].gr[gr].subblock_gain[0] = stream.get_bits(3);
- si.ch[ch].gr[gr].subblock_gain[1] = stream.get_bits(3);
- si.ch[ch].gr[gr].subblock_gain[2] = stream.get_bits(3);
-
- // Set region_count parameters since they are implicit in this case.
-
- if (si.ch[ch].gr[gr].block_type == 0) {
- // Side info bad: block_type == 0 in split block
- return false;
- } else if (si.ch[ch].gr[gr].block_type == 2
- && si.ch[ch].gr[gr].mixed_block_flag == 0) {
- si.ch[ch].gr[gr].region0_count = 8;
- } else {
- si.ch[ch].gr[gr].region0_count = 7;
- }
- si.ch[ch].gr[gr].region1_count = 20 -
- si.ch[ch].gr[gr].region0_count;
- } else {
- si.ch[ch].gr[gr].table_select[0] = stream.get_bits(5);
- si.ch[ch].gr[gr].table_select[1] = stream.get_bits(5);
- si.ch[ch].gr[gr].table_select[2] = stream.get_bits(5);
- si.ch[ch].gr[gr].region0_count = stream.get_bits(4);
- si.ch[ch].gr[gr].region1_count = stream.get_bits(3);
- si.ch[ch].gr[gr].block_type = 0;
- }
- si.ch[ch].gr[gr].preflag = stream.get_bits(1);
- si.ch[ch].gr[gr].scalefac_scale = stream.get_bits(1);
- si.ch[ch].gr[gr].count1table_select = stream.get_bits(1);
- }
- }
-
- } else { // MPEG-2 LSF, SZD: MPEG-2.5 LSF
-
- si.main_data_begin = stream.get_bits(8);
- if (channels == 1)
- si.private_bits = stream.get_bits(1);
- else si.private_bits = stream.get_bits(2);
-
- for (ch=0; ch<channels; ch++) {
-
- si.ch[ch].gr[0].part2_3_length = stream.get_bits(12);
- si.ch[ch].gr[0].big_values = stream.get_bits(9);
- si.ch[ch].gr[0].global_gain = stream.get_bits(8);
- si.ch[ch].gr[0].scalefac_compress = stream.get_bits(9);
- si.ch[ch].gr[0].window_switching_flag = stream.get_bits(1);
-
- if ((si.ch[ch].gr[0].window_switching_flag) != 0) {
-
- si.ch[ch].gr[0].block_type = stream.get_bits(2);
- si.ch[ch].gr[0].mixed_block_flag = stream.get_bits(1);
- si.ch[ch].gr[0].table_select[0] = stream.get_bits(5);
- si.ch[ch].gr[0].table_select[1] = stream.get_bits(5);
-
- si.ch[ch].gr[0].subblock_gain[0] = stream.get_bits(3);
- si.ch[ch].gr[0].subblock_gain[1] = stream.get_bits(3);
- si.ch[ch].gr[0].subblock_gain[2] = stream.get_bits(3);
-
- // Set region_count parameters since they are implicit in this case.
-
- if (si.ch[ch].gr[0].block_type == 0) {
- // Side info bad: block_type == 0 in split block
- return false;
- } else if (si.ch[ch].gr[0].block_type == 2
- && si.ch[ch].gr[0].mixed_block_flag == 0) {
- si.ch[ch].gr[0].region0_count = 8;
- } else {
- si.ch[ch].gr[0].region0_count = 7;
- si.ch[ch].gr[0].region1_count = 20 -
- si.ch[ch].gr[0].region0_count;
- }
-
- } else {
- si.ch[ch].gr[0].table_select[0] = stream.get_bits(5);
- si.ch[ch].gr[0].table_select[1] = stream.get_bits(5);
- si.ch[ch].gr[0].table_select[2] = stream.get_bits(5);
- si.ch[ch].gr[0].region0_count = stream.get_bits(4);
- si.ch[ch].gr[0].region1_count = stream.get_bits(3);
- si.ch[ch].gr[0].block_type = 0;
- }
-
- si.ch[ch].gr[0].scalefac_scale = stream.get_bits(1);
- si.ch[ch].gr[0].count1table_select = stream.get_bits(1);
- } // for(ch=0; ch<channels; ch++)
- } // if (header.version() == MPEG1)
- return true;
- }
-
- /**
- *
- */
- private void get_scale_factors(int ch, int gr)
- {
- int sfb, window;
- gr_info_s gr_info = (si.ch[ch].gr[gr]);
- int scale_comp = gr_info.scalefac_compress;
- int length0 = slen[0][scale_comp];
- int length1 = slen[1][scale_comp];
-
- if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {
- if ((gr_info.mixed_block_flag) != 0) { // MIXED
- for (sfb = 0; sfb < 8; sfb++)
- scalefac[ch].l[sfb] = br.hgetbits(
- slen[0][gr_info.scalefac_compress]);
- for (sfb = 3; sfb < 6; sfb++)
- for (window=0; window<3; window++)
- scalefac[ch].s[window][sfb] = br.hgetbits(
- slen[0][gr_info.scalefac_compress]);
- for (sfb = 6; sfb < 12; sfb++)
- for (window=0; window<3; window++)
- scalefac[ch].s[window][sfb] = br.hgetbits(
- slen[1][gr_info.scalefac_compress]);
- for (sfb=12,window=0; window<3; window++)
- scalefac[ch].s[window][sfb] = 0;
-
- } else { // SHORT
-
- scalefac[ch].s[0][0] = br.hgetbits(length0);
- scalefac[ch].s[1][0] = br.hgetbits(length0);
- scalefac[ch].s[2][0] = br.hgetbits(length0);
- scalefac[ch].s[0][1] = br.hgetbits(length0);
- scalefac[ch].s[1][1] = br.hgetbits(length0);
- scalefac[ch].s[2][1] = br.hgetbits(length0);
- scalefac[ch].s[0][2] = br.hgetbits(length0);
- scalefac[ch].s[1][2] = br.hgetbits(length0);
- scalefac[ch].s[2][2] = br.hgetbits(length0);
- scalefac[ch].s[0][3] = br.hgetbits(length0);
- scalefac[ch].s[1][3] = br.hgetbits(length0);
- scalefac[ch].s[2][3] = br.hgetbits(length0);
- scalefac[ch].s[0][4] = br.hgetbits(length0);
- scalefac[ch].s[1][4] = br.hgetbits(length0);
- scalefac[ch].s[2][4] = br.hgetbits(length0);
- scalefac[ch].s[0][5] = br.hgetbits(length0);
- scalefac[ch].s[1][5] = br.hgetbits(length0);
- scalefac[ch].s[2][5] = br.hgetbits(length0);
- scalefac[ch].s[0][6] = br.hgetbits(length1);
- scalefac[ch].s[1][6] = br.hgetbits(length1);
- scalefac[ch].s[2][6] = br.hgetbits(length1);
- scalefac[ch].s[0][7] = br.hgetbits(length1);
- scalefac[ch].s[1][7] = br.hgetbits(length1);
- scalefac[ch].s[2][7] = br.hgetbits(length1);
- scalefac[ch].s[0][8] = br.hgetbits(length1);
- scalefac[ch].s[1][8] = br.hgetbits(length1);
- scalefac[ch].s[2][8] = br.hgetbits(length1);
- scalefac[ch].s[0][9] = br.hgetbits(length1);
- scalefac[ch].s[1][9] = br.hgetbits(length1);
- scalefac[ch].s[2][9] = br.hgetbits(length1);
- scalefac[ch].s[0][10] = br.hgetbits(length1);
- scalefac[ch].s[1][10] = br.hgetbits(length1);
- scalefac[ch].s[2][10] = br.hgetbits(length1);
- scalefac[ch].s[0][11] = br.hgetbits(length1);
- scalefac[ch].s[1][11] = br.hgetbits(length1);
- scalefac[ch].s[2][11] = br.hgetbits(length1);
- scalefac[ch].s[0][12] = 0;
- scalefac[ch].s[1][12] = 0;
- scalefac[ch].s[2][12] = 0;
- } // SHORT
-
- } else { // LONG types 0,1,3
-
- if ((si.ch[ch].scfsi[0] == 0) || (gr == 0)) {
- scalefac[ch].l[0] = br.hgetbits(length0);
- scalefac[ch].l[1] = br.hgetbits(length0);
- scalefac[ch].l[2] = br.hgetbits(length0);
- scalefac[ch].l[3] = br.hgetbits(length0);
- scalefac[ch].l[4] = br.hgetbits(length0);
- scalefac[ch].l[5] = br.hgetbits(length0);
- }
- if ((si.ch[ch].scfsi[1] == 0) || (gr == 0)) {
- scalefac[ch].l[6] = br.hgetbits(length0);
- scalefac[ch].l[7] = br.hgetbits(length0);
- scalefac[ch].l[8] = br.hgetbits(length0);
- scalefac[ch].l[9] = br.hgetbits(length0);
- scalefac[ch].l[10] = br.hgetbits(length0);
- }
- if ((si.ch[ch].scfsi[2] == 0) || (gr == 0)) {
- scalefac[ch].l[11] = br.hgetbits(length1);
- scalefac[ch].l[12] = br.hgetbits(length1);
- scalefac[ch].l[13] = br.hgetbits(length1);
- scalefac[ch].l[14] = br.hgetbits(length1);
- scalefac[ch].l[15] = br.hgetbits(length1);
- }
- if ((si.ch[ch].scfsi[3] == 0) || (gr == 0)) {
- scalefac[ch].l[16] = br.hgetbits(length1);
- scalefac[ch].l[17] = br.hgetbits(length1);
- scalefac[ch].l[18] = br.hgetbits(length1);
- scalefac[ch].l[19] = br.hgetbits(length1);
- scalefac[ch].l[20] = br.hgetbits(length1);
- }
-
- scalefac[ch].l[21] = 0;
- scalefac[ch].l[22] = 0;
- }
- }
-
- /**
- *
- */
- // MDM: new_slen is fully initialized before use, no need
- // to reallocate array.
- private final int[] new_slen = new int[4];
-
- private void get_LSF_scale_data(int ch, int gr)
- {
-
- int scalefac_comp, int_scalefac_comp;
- int mode_ext = header.mode_extension();
- int m;
- int blocktypenumber;
- int blocknumber = 0;
-
- gr_info_s gr_info = (si.ch[ch].gr[gr]);
-
- scalefac_comp = gr_info.scalefac_compress;
-
- if (gr_info.block_type == 2) {
- if (gr_info.mixed_block_flag == 0)
- blocktypenumber = 1;
- else if (gr_info.mixed_block_flag == 1)
- blocktypenumber = 2;
- else
- blocktypenumber = 0;
- } else {
- blocktypenumber = 0;
- }
-
- if(!(((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {
-
- if(scalefac_comp < 400) {
-
- new_slen[0] = (scalefac_comp >>> 4) / 5 ;
- new_slen[1] = (scalefac_comp >>> 4) % 5 ;
- new_slen[2] = (scalefac_comp & 0xF) >>> 2 ;
- new_slen[3] = (scalefac_comp & 3);
- si.ch[ch].gr[gr].preflag = 0;
- blocknumber = 0;
-
- } else if (scalefac_comp < 500) {
-
- new_slen[0] = ((scalefac_comp - 400) >>> 2) / 5 ;
- new_slen[1] = ((scalefac_comp - 400) >>> 2) % 5 ;
- new_slen[2] = (scalefac_comp - 400 ) & 3 ;
- new_slen[3] = 0;
- si.ch[ch].gr[gr].preflag = 0;
- blocknumber = 1;
-
- } else if (scalefac_comp < 512) {
-
- new_slen[0] = (scalefac_comp - 500 ) / 3 ;
- new_slen[1] = (scalefac_comp - 500) % 3 ;
- new_slen[2] = 0;
- new_slen[3] = 0;
- si.ch[ch].gr[gr].preflag = 1;
- blocknumber = 2;
- }
- }
-
- if((((mode_ext == 1) || (mode_ext == 3)) && (ch == 1)))
- {
- int_scalefac_comp = scalefac_comp >>> 1;
-
- if (int_scalefac_comp < 180)
- {
- new_slen[0] = int_scalefac_comp / 36 ;
- new_slen[1] = (int_scalefac_comp % 36 ) / 6 ;
- new_slen[2] = (int_scalefac_comp % 36) % 6;
- new_slen[3] = 0;
- si.ch[ch].gr[gr].preflag = 0;
- blocknumber = 3;
- } else if (int_scalefac_comp < 244) {
- new_slen[0] = ((int_scalefac_comp - 180 ) & 0x3F) >>> 4 ;
- new_slen[1] = ((int_scalefac_comp - 180) & 0xF) >>> 2 ;
- new_slen[2] = (int_scalefac_comp - 180 ) & 3 ;
- new_slen[3] = 0;
- si.ch[ch].gr[gr].preflag = 0;
- blocknumber = 4;
- } else if (int_scalefac_comp < 255) {
- new_slen[0] = (int_scalefac_comp - 244 ) / 3 ;
- new_slen[1] = (int_scalefac_comp - 244 ) % 3 ;
- new_slen[2] = 0 ;
- new_slen[3] = 0;
- si.ch[ch].gr[gr].preflag = 0;
- blocknumber = 5;
- }
- }
-
- for (int x=0; x<45; x++) // why 45, not 54?
- scalefac_buffer[x] = 0;
-
- m = 0;
- for (int i=0; i<4;i++) {
- for (int j = 0; j < nr_of_sfb_block[blocknumber][blocktypenumber][i];
- j++)
- {
- scalefac_buffer[m] = (new_slen[i] == 0) ? 0 :
- br.hgetbits(new_slen[i]);
- m++;
-
- } // for (unint32 j ...
- } // for (uint32 i ...
- }
-
- /**
- *
- */
- private void get_LSF_scale_factors(int ch, int gr)
- {
- int m = 0;
- int sfb, window;
- gr_info_s gr_info = (si.ch[ch].gr[gr]);
-
- get_LSF_scale_data(ch, gr);
-
- if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {
- if (gr_info.mixed_block_flag != 0) { // MIXED
- for (sfb = 0; sfb < 8; sfb++)
- {
- scalefac[ch].l[sfb] = scalefac_buffer[m];
- m++;
- }
- for (sfb = 3; sfb < 12; sfb++) {
- for (window=0; window<3; window++)
- {
- scalefac[ch].s[window][sfb] = scalefac_buffer[m];
- m++;
- }
- }
- for (window=0; window<3; window++)
- scalefac[ch].s[window][12] = 0;
-
- } else { // SHORT
-
- for (sfb = 0; sfb < 12; sfb++) {
- for (window=0; window<3; window++)
- {
- scalefac[ch].s[window][sfb] = scalefac_buffer[m];
- m++;
- }
- }
-
- for (window=0; window<3; window++)
- scalefac[ch].s[window][12] = 0;
- }
- } else { // LONG types 0,1,3
-
- for (sfb = 0; sfb < 21; sfb++) {
- scalefac[ch].l[sfb] = scalefac_buffer[m];
- m++;
- }
- scalefac[ch].l[21] = 0; // Jeff
- scalefac[ch].l[22] = 0;
- }
- }
-
- /**
- *
- */
- int[] x = {0};
- int[] y = {0};
- int[] v = {0};
- int[] w = {0};
- private void huffman_decode(int ch, int gr)
- {
- x[0] = 0;
- y[0] = 0;
- v[0] = 0;
- w[0] = 0;
-
- int part2_3_end = part2_start + si.ch[ch].gr[gr].part2_3_length;
- int num_bits;
- int region1Start;
- int region2Start;
- int index;
-
- int buf, buf1;
-
- huffcodetab h;
-
- // Find region boundary for short block case
-
- if ( ((si.ch[ch].gr[gr].window_switching_flag) != 0) &&
- (si.ch[ch].gr[gr].block_type == 2) ) {
-
- // Region2.
- //MS: Extrahandling for 8KHZ
- region1Start = (sfreq == 8) ? 72 : 36; // sfb[9/3]*3=36 or in case 8KHZ = 72
- region2Start = 576; // No Region2 for short block case
-
- } else { // Find region boundary for long block case
-
- buf = si.ch[ch].gr[gr].region0_count + 1;
- buf1 = buf + si.ch[ch].gr[gr].region1_count + 1;
-
- if(buf1 > sfBandIndex[sfreq].l.length - 1) buf1 = sfBandIndex[sfreq].l.length - 1;
-
- region1Start = sfBandIndex[sfreq].l[buf];
- region2Start = sfBandIndex[sfreq].l[buf1]; /* MI */
- }
-
- index = 0;
- // Read bigvalues area
- for (int i=0; i<(si.ch[ch].gr[gr].big_values<<1); i+=2) {
- if (i<region1Start) h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[0]];
- else if (i<region2Start) h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[1]];
- else h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[2]];
-
- huffcodetab.huffman_decoder(h, x, y, v, w, br);
- //if (index >= is_1d.length) System.out.println("i0="+i+"/"+(si.ch[ch].gr[gr].big_values<<1)+" Index="+index+" is_1d="+is_1d.length);
-
- is_1d[index++] = x[0];
- is_1d[index++] = y[0];
-
- CheckSumHuff = CheckSumHuff + x[0] + y[0];
- // System.out.println("x = "+x[0]+" y = "+y[0]);
- }
-
- // Read count1 area
- h = huffcodetab.ht[si.ch[ch].gr[gr].count1table_select+32];
- num_bits = br.hsstell();
-
- while ((num_bits < part2_3_end) && (index < 576)) {
-
- huffcodetab.huffman_decoder(h, x, y, v, w, br);
-
- is_1d[index++] = v[0];
- is_1d[index++] = w[0];
- is_1d[index++] = x[0];
- is_1d[index++] = y[0];
- CheckSumHuff = CheckSumHuff + v[0] + w[0] + x[0] + y[0];
- // System.out.println("v = "+v[0]+" w = "+w[0]);
- // System.out.println("x = "+x[0]+" y = "+y[0]);
- num_bits = br.hsstell();
- }
-
- if (num_bits > part2_3_end) {
- br.rewindNbits(num_bits - part2_3_end);
- index-=4;
- }
-
- num_bits = br.hsstell();
-
- // Dismiss stuffing bits
- if (num_bits < part2_3_end)
- br.hgetbits(part2_3_end - num_bits);
-
- // Zero out rest
-
- if (index < 576)
- nonzero[ch] = index;
- else
- nonzero[ch] = 576;
-
- if (index < 0) index = 0;
-
- // may not be necessary
- for (; index<576; index++)
- is_1d[index] = 0;
- }
-
- /**
- *
- */
- private void i_stereo_k_values(int is_pos, int io_type, int i)
- {
- if (is_pos == 0) {
- k[0][i] = 1.0f;
- k[1][i] = 1.0f;
- } else if ((is_pos & 1) != 0) {
- k[0][i] = io[io_type][(is_pos + 1) >>> 1];
- k[1][i] = 1.0f;
- } else {
- k[0][i] = 1.0f;
- k[1][i] = io[io_type][is_pos >>> 1];
- }
- }
-
- /**
- *
- */
- private void dequantize_sample(float xr[][], int ch, int gr)
- {
- gr_info_s gr_info = (si.ch[ch].gr[gr]);
- int cb=0;
- int next_cb_boundary;
- int cb_begin = 0;
- int cb_width = 0;
- int index=0, t_index, j;
- float g_gain;
- float[][] xr_1d = xr;
-
- // choose correct scalefactor band per block type, initalize boundary
-
- if ((gr_info.window_switching_flag !=0 ) && (gr_info.block_type == 2) ) {
- if (gr_info.mixed_block_flag != 0)
- next_cb_boundary=sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3
- else {
- cb_width = sfBandIndex[sfreq].s[1];
- next_cb_boundary = (cb_width << 2) - cb_width;
- cb_begin = 0;
- }
- } else {
- next_cb_boundary=sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3
- }
-
- // Compute overall (global) scaling.
-
- g_gain = (float) Math.pow(2.0 , (0.25 * (gr_info.global_gain - 210.0)));
-
- for (j=0; j<nonzero[ch]; j++)
- {
- // Modif E.B 02/22/99
- int reste = j % SSLIMIT;
- int quotien = (int) ((j-reste)/SSLIMIT);
- if (is_1d[j] == 0) xr_1d[quotien][reste] = 0.0f;
- else
- {
- int abv = is_1d[j];
- // Pow Array fix (11/17/04)
- if (abv < t_43.length)
- {
- if (is_1d[j] > 0) xr_1d[quotien][reste] = g_gain * t_43[abv];
- else
- {
- if (-abv < t_43.length) xr_1d[quotien][reste] = -g_gain * t_43[-abv];
- else xr_1d[quotien][reste] = -g_gain * (float)Math.pow(-abv, d43);
- }
- }
- else
- {
- if (is_1d[j] > 0) xr_1d[quotien][reste] = g_gain * (float)Math.pow(abv, d43);
- else xr_1d[quotien][reste] = -g_gain * (float)Math.pow(-abv, d43);
- }
- }
- }
-
- // apply formula per block type
- for (j=0; j<nonzero[ch]; j++)
- {
- // Modif E.B 02/22/99
- int reste = j % SSLIMIT;
- int quotien = (int) ((j-reste)/SSLIMIT);
-
- if (index == next_cb_boundary) { /* Adjust critical band boundary */
- if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {
- if (gr_info.mixed_block_flag != 0) {
-
- if (index == sfBandIndex[sfreq].l[8]) {
- next_cb_boundary = sfBandIndex[sfreq].s[4];
- next_cb_boundary = (next_cb_boundary << 2) -
- next_cb_boundary;
- cb = 3;
- cb_width = sfBandIndex[sfreq].s[4] -
- sfBandIndex[sfreq].s[3];
-
- cb_begin = sfBandIndex[sfreq].s[3];
- cb_begin = (cb_begin << 2) - cb_begin;
-
- } else if (index < sfBandIndex[sfreq].l[8]) {
-
- next_cb_boundary = sfBandIndex[sfreq].l[(++cb)+1];
-
- } else {
-
- next_cb_boundary = sfBandIndex[sfreq].s[(++cb)+1];
- next_cb_boundary = (next_cb_boundary << 2) -
- next_cb_boundary;
-
- cb_begin = sfBandIndex[sfreq].s[cb];
- cb_width = sfBandIndex[sfreq].s[cb+1] -
- cb_begin;
- cb_begin = (cb_begin << 2) - cb_begin;
- }
-
- } else {
-
- next_cb_boundary = sfBandIndex[sfreq].s[(++cb)+1];
- next_cb_boundary = (next_cb_boundary << 2) -
- next_cb_boundary;
-
- cb_begin = sfBandIndex[sfreq].s[cb];
- cb_width = sfBandIndex[sfreq].s[cb+1] -
- cb_begin;
- cb_begin = (cb_begin << 2) - cb_begin;
- }
-
- } else { // long blocks
-
- next_cb_boundary = sfBandIndex[sfreq].l[(++cb)+1];
-
- }
- }
-
- // Do long/short dependent scaling operations
-
- if ((gr_info.window_switching_flag !=0)&&
- (((gr_info.block_type == 2) && (gr_info.mixed_block_flag == 0)) ||
- ((gr_info.block_type == 2) && (gr_info.mixed_block_flag!=0) && (j >= 36)) ))
- {
-
- t_index = (index - cb_begin) / cb_width;
- /* xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info.subblock_gain[t_index])
- -(0.5 * (1.0 + gr_info.scalefac_scale)
- * scalefac[ch].s[t_index][cb]))); */
- int idx = scalefac[ch].s[t_index][cb]
- << gr_info.scalefac_scale;
- idx += (gr_info.subblock_gain[t_index] << 2);
-
- xr_1d[quotien][reste] *= two_to_negative_half_pow[idx];
-
- } else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks
- /* xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info.scalefac_scale)
- * (scalefac[ch].l[cb]
- + gr_info.preflag * pretab[cb])); */
- int idx = scalefac[ch].l[cb];
-
- if (gr_info.preflag != 0)
- idx += pretab[cb];
-
- idx = idx << gr_info.scalefac_scale;
- xr_1d[quotien][reste] *= two_to_negative_half_pow[idx];
- }
- index++;
- }
-
- for (j=nonzero[ch]; j<576; j++)
- {
- // Modif E.B 02/22/99
- int reste = j % SSLIMIT;
- int quotien = (int) ((j-reste)/SSLIMIT);
- if(reste < 0) reste = 0;
- if(quotien < 0) quotien = 0;
- xr_1d[quotien][reste] = 0.0f;
- }
-
- return;
- }
-
- /**
- *
- */
- private void reorder(float xr[][], int ch, int gr)
- {
- gr_info_s gr_info = (si.ch[ch].gr[gr]);
- int freq, freq3;
- int index;
- int sfb, sfb_start, sfb_lines;
- int src_line, des_line;
- float[][] xr_1d = xr;
-
- if ((gr_info.window_switching_flag !=0) && (gr_info.block_type == 2)) {
-
- for(index=0; index<576; index++)
- out_1d[index] = 0.0f;
-
- if (gr_info.mixed_block_flag !=0 ) {
- // NO REORDER FOR LOW 2 SUBBANDS
- for (index = 0; index < 36; index++)
- {
- // Modif E.B 02/22/99
- int reste = index % SSLIMIT;
- int quotien = (int) ((index-reste)/SSLIMIT);
- out_1d[index] = xr_1d[quotien][reste];
- }
- // REORDERING FOR REST SWITCHED SHORT
- /*for( sfb=3,sfb_start=sfBandIndex[sfreq].s[3],
- sfb_lines=sfBandIndex[sfreq].s[4] - sfb_start;
- sfb < 13; sfb++,sfb_start = sfBandIndex[sfreq].s[sfb],
- sfb_lines = sfBandIndex[sfreq].s[sfb+1] - sfb_start )
- {*/
- for( sfb=3; sfb < 13; sfb++)
- {
- //System.out.println("sfreq="+sfreq+" sfb="+sfb+" sfBandIndex="+sfBandIndex.length+" sfBandIndex[sfreq].s="+sfBandIndex[sfreq].s.length);
- sfb_start = sfBandIndex[sfreq].s[sfb];
- sfb_lines = sfBandIndex[sfreq].s[sfb+1] - sfb_start;
-
- int sfb_start3 = (sfb_start << 2) - sfb_start;
-
- for(freq=0, freq3=0; freq<sfb_lines;
- freq++, freq3+=3) {
-
- src_line = sfb_start3 + freq;
- des_line = sfb_start3 + freq3;
- // Modif E.B 02/22/99
- int reste = src_line % SSLIMIT;
- int quotien = (int) ((src_line-reste)/SSLIMIT);
-
- out_1d[des_line] = xr_1d[quotien][reste];
- src_line += sfb_lines;
- des_line++;
-
- reste = src_line % SSLIMIT;
- quotien = (int) ((src_line-reste)/SSLIMIT);
-
- out_1d[des_line] = xr_1d[quotien][reste];
- src_line += sfb_lines;
- des_line++;
-
- reste = src_line % SSLIMIT;
- quotien = (int) ((src_line-reste)/SSLIMIT);
-
- out_1d[des_line] = xr_1d[quotien][reste];
- }
- }
-
- } else { // pure short
- for(index=0;index<576;index++)
- {
- int j = reorder_table[sfreq][index];
- int reste = j % SSLIMIT;
- int quotien = (int) ((j-reste)/SSLIMIT);
- out_1d[index] = xr_1d[quotien][reste];
- }
- }
- }
- else { // long blocks
- for(index=0; index<576; index++)
- {
- // Modif E.B 02/22/99
- int reste = index % SSLIMIT;
- int quotien = (int) ((index-reste)/SSLIMIT);
- out_1d[index] = xr_1d[quotien][reste];
- }
- }
- }
-
- /**
- *
- */
-
- int[] is_pos = new int[576];
- float[] is_ratio = new float[576];
-
- private void stereo(int gr)
- {
- int sb, ss;
-
- if (channels == 1) { // mono , bypass xr[0][][] to lr[0][][]
-
- for(sb=0;sb<SBLIMIT;sb++)
- for(ss=0;ss<SSLIMIT;ss+=3) {
- lr[0][sb][ss] = ro[0][sb][ss];
- lr[0][sb][ss+1] = ro[0][sb][ss+1];
- lr[0][sb][ss+2] = ro[0][sb][ss+2];
- }
-
- } else {
-
- gr_info_s gr_info = (si.ch[0].gr[gr]);
- int mode_ext = header.mode_extension();
- int sfb;
- int i;
- int lines, temp, temp2;
-
- boolean ms_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x2)!=0));
- boolean i_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x1)!=0));
- boolean lsf = ((header.version() == Header.MPEG2_LSF || header.version() == Header.MPEG25_LSF )); // SZD
-
- int io_type = (gr_info.scalefac_compress & 1);
-
- // initialization
-
- for (i=0; i<576; i++)
- {
- is_pos[i] = 7;
-
- is_ratio[i] = 0.0f;
- }
-
- if (i_stereo) {
- if ((gr_info.window_switching_flag !=0 )&& (gr_info.block_type == 2)) {
- if (gr_info.mixed_block_flag != 0) {
-
- int max_sfb = 0;
-
- for (int j=0; j<3; j++) {
- int sfbcnt;
- sfbcnt = 2;
- for( sfb=12; sfb >=3; sfb-- ) {
- i = sfBandIndex[sfreq].s[sfb];
- lines = sfBandIndex[sfreq].s[sfb+1] - i;
- i = (i << 2) - i + (j+1) * lines - 1;
-
- while (lines > 0) {
- if (ro[1][i/18][i%18] != 0.0f) {
- // MDM: in java, array access is very slow.
- // Is quicker to compute div and mod values.
- //if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {
- sfbcnt = sfb;
- sfb = -10;
- lines = -10;
- }
-
- lines--;
- i--;
-
- } // while (lines > 0)
-
- } // for (sfb=12 ...
- sfb = sfbcnt + 1;
-
- if (sfb > max_sfb)
- max_sfb = sfb;
-
- while(sfb < 12) {
- temp = sfBandIndex[sfreq].s[sfb];
- sb = sfBandIndex[sfreq].s[sfb+1] - temp;
- i = (temp << 2) - temp + j * sb;
-
- for ( ; sb > 0; sb--) {
- is_pos[i] = scalefac[1].s[j][sfb];
- if (is_pos[i] != 7)
- if (lsf)
- i_stereo_k_values(is_pos[i], io_type, i);
- else
- is_ratio[i] = TAN12[is_pos[i]];
-
- i++;
- } // for (; sb>0...
- sfb++;
- } // while (sfb < 12)
- sfb = sfBandIndex[sfreq].s[10];
- sb = sfBandIndex[sfreq].s[11] - sfb;
- sfb = (sfb << 2) - sfb + j * sb;
- temp = sfBandIndex[sfreq].s[11];
- sb = sfBandIndex[sfreq].s[12] - temp;
- i = (temp << 2) - temp + j * sb;
-
- for (; sb > 0; sb--) {
- is_pos[i] = is_pos[sfb];
-
- if (lsf) {
- k[0][i] = k[0][sfb];
- k[1][i] = k[1][sfb];
- } else {
- is_ratio[i] = is_ratio[sfb];
- }
- i++;
- } // for (; sb > 0 ...
- }
- if (max_sfb <= 3) {
- i = 2;
- ss = 17;
- sb = -1;
- while (i >= 0) {
- if (ro[1][i][ss] != 0.0f) {
- sb = (i<<4) + (i<<1) + ss;
- i = -1;
- } else {
- ss--;
- if (ss < 0) {
- i--;
- ss = 17;
- }
- } // if (ro ...
- } // while (i>=0)
- i = 0;
- while (sfBandIndex[sfreq].l[i] <= sb)
- i++;
- sfb = i;
- i = sfBandIndex[sfreq].l[i];
- for (; sfb<8; sfb++) {
- sb = sfBandIndex[sfreq].l[sfb+1]-sfBandIndex[sfreq].l[sfb];
- for (; sb>0; sb--) {
- is_pos[i] = scalefac[1].l[sfb];
- if (is_pos[i] != 7)
- if (lsf)
- i_stereo_k_values(is_pos[i], io_type, i);
- else
- is_ratio[i] = TAN12[is_pos[i]];
- i++;
- } // for (; sb>0 ...
- } // for (; sfb<8 ...
- } // for (j=0 ...
- } else { // if (gr_info.mixed_block_flag)
- for (int j=0; j<3; j++) {
- int sfbcnt;
- sfbcnt = -1;
- for( sfb=12; sfb >=0; sfb-- )
- {
- temp = sfBandIndex[sfreq].s[sfb];
- lines = sfBandIndex[sfreq].s[sfb+1] - temp;
- i = (temp << 2) - temp + (j+1) * lines - 1;
-
- while (lines > 0) {
- if (ro[1][i/18][i%18] != 0.0f) {
- // MDM: in java, array access is very slow.
- // Is quicker to compute div and mod values.
- //if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {
- sfbcnt = sfb;
- sfb = -10;
- lines = -10;
- }
- lines--;
- i--;
- } // while (lines > 0) */
-
- } // for (sfb=12 ...
- sfb = sfbcnt + 1;
- while(sfb<12) {
- temp = sfBandIndex[sfreq].s[sfb];
- sb = sfBandIndex[sfreq].s[sfb+1] - temp;
- i = (temp << 2) - temp + j * sb;
- for ( ; sb > 0; sb--) {
- is_pos[i] = scalefac[1].s[j][sfb];
- if (is_pos[i] != 7)
- if (lsf)
- i_stereo_k_values(is_pos[i], io_type, i);
- else
- is_ratio[i] = TAN12[is_pos[i]];
- i++;
- } // for (; sb>0 ...
- sfb++;
- } // while (sfb<12)
-
- temp = sfBandIndex[sfreq].s[10];
- temp2= sfBandIndex[sfreq].s[11];
- sb = temp2 - temp;
- sfb = (temp << 2) - temp + j * sb;
- sb = sfBandIndex[sfreq].s[12] - temp2;
- i = (temp2 << 2) - temp2 + j * sb;
-
- for (; sb>0; sb--) {
- is_pos[i] = is_pos[sfb];
-
- if (lsf) {
- k[0][i] = k[0][sfb];
- k[1][i] = k[1][sfb];
- } else {
- is_ratio[i] = is_ratio[sfb];
- }
- i++;
- } // for (; sb>0 ...
- } // for (sfb=12
- } // for (j=0 ...
- } else { // if (gr_info.window_switching_flag ...
- i = 31;
- ss = 17;
- sb = 0;
- while (i >= 0) {
- if (ro[1][i][ss] != 0.0f) {
- sb = (i<<4) + (i<<1) + ss;
- i = -1;
- } else {
- ss--;
- if (ss < 0) {
- i--;
- ss = 17;
- }
- }
- }
- i = 0;
- while (sfBandIndex[sfreq].l[i] <= sb)
- i++;
-
- sfb = i;
- i = sfBandIndex[sfreq].l[i];
- for (; sfb<21; sfb++) {
- sb = sfBandIndex[sfreq].l[sfb+1] - sfBandIndex[sfreq].l[sfb];
- for (; sb > 0; sb--) {
- is_pos[i] = scalefac[1].l[sfb];
- if (is_pos[i] != 7)
- if (lsf)
- i_stereo_k_values(is_pos[i], io_type, i);
- else
- is_ratio[i] = TAN12[is_pos[i]];
- i++;
- }
- }
- sfb = sfBandIndex[sfreq].l[20];
- for (sb = 576 - sfBandIndex[sfreq].l[21]; (sb > 0) && (i<576); sb--)
- {
- is_pos[i] = is_pos[sfb]; // error here : i >=576
-
- if (lsf) {
- k[0][i] = k[0][sfb];
- k[1][i] = k[1][sfb];
- } else {
- is_ratio[i] = is_ratio[sfb];
- }
- i++;
- } // if (gr_info.mixed_block_flag)
- } // if (gr_info.window_switching_flag ...
- } // if (i_stereo)
-
- i = 0;
- for(sb=0;sb<SBLIMIT;sb++)
- for(ss=0;ss<SSLIMIT;ss++) {
- if (is_pos[i] == 7) {
- if (ms_stereo) {
- lr[0][sb][ss] = (ro[0][sb][ss]+ro[1][sb][ss]) * 0.707106781f;
- lr[1][sb][ss] = (ro[0][sb][ss]-ro[1][sb][ss]) * 0.707106781f;
- } else {
- lr[0][sb][ss] = ro[0][sb][ss];
- lr[1][sb][ss] = ro[1][sb][ss];
- }
- }
- else if (i_stereo) {
-
- if (lsf) {
- lr[0][sb][ss] = ro[0][sb][ss] * k[0][i];
- lr[1][sb][ss] = ro[0][sb][ss] * k[1][i];
- } else {
- lr[1][sb][ss] = ro[0][sb][ss] / (float) (1 + is_ratio[i]);
- lr[0][sb][ss] = lr[1][sb][ss] * is_ratio[i];
- }
- }
- /* else {
- System.out.println("Error in stereo processing\n");
- } */
- i++;
- }
-
- } // channels == 2
-
- }
-
- /**
- *
- */
- private void antialias(int ch, int gr)
- {
- int sb18, ss, sb18lim;
- gr_info_s gr_info = (si.ch[ch].gr[gr]);
- // 31 alias-reduction operations between each pair of sub-bands
- // with 8 butterflies between each pair
-
- if ((gr_info.window_switching_flag !=0) && (gr_info.block_type == 2) &&
- !(gr_info.mixed_block_flag != 0) )
- return;
-
- if ((gr_info.window_switching_flag !=0) && (gr_info.mixed_block_flag != 0)&&
- (gr_info.block_type == 2)) {
- sb18lim = 18;
- } else {
- sb18lim = 558;
- }
-
- for (sb18=0; sb18 < sb18lim; sb18+=18) {
- for (ss=0;ss<8;ss++) {
- int src_idx1 = sb18 + 17 - ss;
- int src_idx2 = sb18 + 18 + ss;
- float bu = out_1d[src_idx1];
- float bd = out_1d[src_idx2];
- out_1d[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);
- out_1d[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);
- }
- }
- }
-
- /**
- *
- */
-
- // MDM: tsOutCopy and rawout do not need initializing, so the arrays
- // can be reused.
- float[] tsOutCopy = new float[18];
- float[] rawout = new float[36];
-
- private void hybrid(int ch, int gr)
- {
- int bt;
- int sb18;
- gr_info_s gr_info = (si.ch[ch].gr[gr]);
- float[] tsOut;
-
- float[][] prvblk;
-
- for(sb18=0;sb18<576;sb18+=18)
- {
- bt = ((gr_info.window_switching_flag !=0 ) && (gr_info.mixed_block_flag !=0) &&
- (sb18 < 36)) ? 0 : gr_info.block_type;
-
- tsOut = out_1d;
- // Modif E.B 02/22/99
- for (int cc = 0;cc<18;cc++)
- tsOutCopy[cc] = tsOut[cc+sb18];
-
- inv_mdct(tsOutCopy, rawout, bt);
-
-
- for (int cc = 0;cc<18;cc++)
- tsOut[cc+sb18] = tsOutCopy[cc];
- // Fin Modif
-
- // overlap addition
- prvblk = prevblck;
-
- tsOut[0 + sb18] = rawout[0] + prvblk[ch][sb18 + 0];
- prvblk[ch][sb18 + 0] = rawout[18];
- tsOut[1 + sb18] = rawout[1] + prvblk[ch][sb18 + 1];
- prvblk[ch][sb18 + 1] = rawout[19];
- tsOut[2 + sb18] = rawout[2] + prvblk[ch][sb18 + 2];
- prvblk[ch][sb18 + 2] = rawout[20];
- tsOut[3 + sb18] = rawout[3] + prvblk[ch][sb18 + 3];
- prvblk[ch][sb18 + 3] = rawout[21];
- tsOut[4 + sb18] = rawout[4] + prvblk[ch][sb18 + 4];
- prvblk[ch][sb18 + 4] = rawout[22];
- tsOut[5 + sb18] = rawout[5] + prvblk[ch][sb18 + 5];
- prvblk[ch][sb18 + 5] = rawout[23];
- tsOut[6 + sb18] = rawout[6] + prvblk[ch][sb18 + 6];
- prvblk[ch][sb18 + 6] = rawout[24];
- tsOut[7 + sb18] = rawout[7] + prvblk[ch][sb18 + 7];
- prvblk[ch][sb18 + 7] = rawout[25];
- tsOut[8 + sb18] = rawout[8] + prvblk[ch][sb18 + 8];
- prvblk[ch][sb18 + 8] = rawout[26];
- tsOut[9 + sb18] = rawout[9] + prvblk[ch][sb18 + 9];
- prvblk[ch][sb18 + 9] = rawout[27];
- tsOut[10 + sb18] = rawout[10] + prvblk[ch][sb18 + 10];
- prvblk[ch][sb18 + 10] = rawout[28];
- tsOut[11 + sb18] = rawout[11] + prvblk[ch][sb18 + 11];
- prvblk[ch][sb18 + 11] = rawout[29];
- tsOut[12 + sb18] = rawout[12] + prvblk[ch][sb18 + 12];
- prvblk[ch][sb18 + 12] = rawout[30];
- tsOut[13 + sb18] = rawout[13] + prvblk[ch][sb18 + 13];
- prvblk[ch][sb18 + 13] = rawout[31];
- tsOut[14 + sb18] = rawout[14] + prvblk[ch][sb18 + 14];
- prvblk[ch][sb18 + 14] = rawout[32];
- tsOut[15 + sb18] = rawout[15] + prvblk[ch][sb18 + 15];
- prvblk[ch][sb18 + 15] = rawout[33];
- tsOut[16 + sb18] = rawout[16] + prvblk[ch][sb18 + 16];
- prvblk[ch][sb18 + 16] = rawout[34];
- tsOut[17 + sb18] = rawout[17] + prvblk[ch][sb18 + 17];
- prvblk[ch][sb18 + 17] = rawout[35];
- }
- }
-
- /**
- *
- */
- private void do_downmix()
- {
- for (int sb=0; sb<SSLIMIT; sb++) {
- for (int ss=0; ss<SSLIMIT; ss+=3) {
- lr[0][sb][ss] = (lr[0][sb][ss] + lr[1][sb][ss]) * 0.5f;
- lr[0][sb][ss+1] = (lr[0][sb][ss+1] + lr[1][sb][ss+1]) * 0.5f;
- lr[0][sb][ss+2] = (lr[0][sb][ss+2] + lr[1][sb][ss+2]) * 0.5f;
- }
- }
- }
-
- /**
- * Fast INV_MDCT.
- */
-
- public void inv_mdct(float[] in, float[] out, int block_type)
- {
- float[] win_bt;
- int i;
-
- float tmpf_0, tmpf_1, tmpf_2, tmpf_3, tmpf_4, tmpf_5, tmpf_6, tmpf_7, tmpf_8, tmpf_9;
- float tmpf_10, tmpf_11, tmpf_12, tmpf_13, tmpf_14, tmpf_15, tmpf_16, tmpf_17;
-
- tmpf_0 = tmpf_1 = tmpf_2 = tmpf_3 = tmpf_4 = tmpf_5 = tmpf_6 = tmpf_7 = tmpf_8 = tmpf_9 =
- tmpf_10 = tmpf_11 = tmpf_12 = tmpf_13 = tmpf_14 = tmpf_15 = tmpf_16 = tmpf_17 = 0.0f;
-
-
-
- if(block_type == 2)
- {
-
- /*
- *
- * Under MicrosoftVM 2922, This causes a GPF, or
- * At best, an ArrayIndexOutOfBoundsExceptin.
- for(int p=0;p<36;p+=9)
- {
- out[p] = out[p+1] = out[p+2] = out[p+3] =
- out[p+4] = out[p+5] = out[p+6] = out[p+7] =
- out[p+8] = 0.0f;
- }
- */
- out[0] = 0.0f;
- out[1] = 0.0f;
- out[2] = 0.0f;
- out[3] = 0.0f;
- out[4] = 0.0f;
- out[5] = 0.0f;
- out[6] = 0.0f;
- out[7] = 0.0f;
- out[8] = 0.0f;
- out[9] = 0.0f;
- out[10] = 0.0f;
- out[11] = 0.0f;
- out[12] = 0.0f;
- out[13] = 0.0f;
- out[14] = 0.0f;
- out[15] = 0.0f;
- out[16] = 0.0f;
- out[17] = 0.0f;
- out[18] = 0.0f;
- out[19] = 0.0f;
- out[20] = 0.0f;
- out[21] = 0.0f;
- out[22] = 0.0f;
- out[23] = 0.0f;
- out[24] = 0.0f;
- out[25] = 0.0f;
- out[26] = 0.0f;
- out[27] = 0.0f;
- out[28] = 0.0f;
- out[29] = 0.0f;
- out[30] = 0.0f;
- out[31] = 0.0f;
- out[32] = 0.0f;
- out[33] = 0.0f;
- out[34] = 0.0f;
- out[35] = 0.0f;
-
- int six_i = 0;
-
- for(i=0;i<3;i++)
- {
- // 12 point IMDCT
- // Begin 12 point IDCT
- // Input aliasing for 12 pt IDCT
- in[15+i] += in[12+i]; in[12+i] += in[9+i]; in[9+i] += in[6+i];
- in[6+i] += in[3+i]; in[3+i] += in[0+i];
-
- // Input aliasing on odd indices (for 6 point IDCT)
- in[15+i] += in[9+i]; in[9+i] += in[3+i];
-
- // 3 point IDCT on even indices
- float pp1, pp2, sum;
- pp2 = in[12+i] * 0.500000000f;
- pp1 = in[ 6+i] * 0.866025403f;
- sum = in[0+i] + pp2;
- tmpf_1 = in[0+i] - in[12+i];
- tmpf_0 = sum + pp1;
- tmpf_2 = sum - pp1;
-
- // End 3 point IDCT on even indices
- // 3 point IDCT on odd indices (for 6 point IDCT)
- pp2 = in[15+i] * 0.500000000f;
- pp1 = in[ 9+i] * 0.866025403f;
- sum = in[ 3+i] + pp2;
- tmpf_4 = in[3+i] - in[15+i];
- tmpf_5 = sum + pp1;
- tmpf_3 = sum - pp1;
- // End 3 point IDCT on odd indices
- // Twiddle factors on odd indices (for 6 point IDCT)
-
- tmpf_3 *= 1.931851653f;
- tmpf_4 *= 0.707106781f;
- tmpf_5 *= 0.517638090f;
-
- // Output butterflies on 2 3 point IDCT's (for 6 point IDCT)
- float save = tmpf_0;
- tmpf_0 += tmpf_5;
- tmpf_5 = save - tmpf_5;
- save = tmpf_1;
- tmpf_1 += tmpf_4;
- tmpf_4 = save - tmpf_4;
- save = tmpf_2;
- tmpf_2 += tmpf_3;
- tmpf_3 = save - tmpf_3;
-
- // End 6 point IDCT
- // Twiddle factors on indices (for 12 point IDCT)
-
- tmpf_0 *= 0.504314480f;
- tmpf_1 *= 0.541196100f;
- tmpf_2 *= 0.630236207f;
- tmpf_3 *= 0.821339815f;
- tmpf_4 *= 1.306562965f;
- tmpf_5 *= 3.830648788f;
-
- // End 12 point IDCT
-
- // Shift to 12 point modified IDCT, multiply by window type 2
- tmpf_8 = -tmpf_0 * 0.793353340f;
- tmpf_9 = -tmpf_0 * 0.608761429f;
- tmpf_7 = -tmpf_1 * 0.923879532f;
- tmpf_10 = -tmpf_1 * 0.382683432f;
- tmpf_6 = -tmpf_2 * 0.991444861f;
- tmpf_11 = -tmpf_2 * 0.130526192f;
-
- tmpf_0 = tmpf_3;
- tmpf_1 = tmpf_4 * 0.382683432f;
- tmpf_2 = tmpf_5 * 0.608761429f;
-
- tmpf_3 = -tmpf_5 * 0.793353340f;
- tmpf_4 = -tmpf_4 * 0.923879532f;
- tmpf_5 = -tmpf_0 * 0.991444861f;
-
- tmpf_0 *= 0.130526192f;
-
- out[six_i + 6] += tmpf_0;
- out[six_i + 7] += tmpf_1;
- out[six_i + 8] += tmpf_2;
- out[six_i + 9] += tmpf_3;
- out[six_i + 10] += tmpf_4;
- out[six_i + 11] += tmpf_5;
- out[six_i + 12] += tmpf_6;
- out[six_i + 13] += tmpf_7;
- out[six_i + 14] += tmpf_8;
- out[six_i + 15] += tmpf_9;
- out[six_i + 16] += tmpf_10;
- out[six_i + 17] += tmpf_11;
-
- six_i += 6;
- }
- }
- else
- {
- // 36 point IDCT
- // input aliasing for 36 point IDCT
- in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14]; in[14]+=in[13];
- in[13]+=in[12]; in[12]+=in[11]; in[11]+=in[10]; in[10]+=in[9];
- in[9] +=in[8]; in[8] +=in[7]; in[7] +=in[6]; in[6] +=in[5];
- in[5] +=in[4]; in[4] +=in[3]; in[3] +=in[2]; in[2] +=in[1];
- in[1] +=in[0];
-
- // 18 point IDCT for odd indices
- // input aliasing for 18 point IDCT
- in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9];
- in[9] +=in[7]; in[7] +=in[5]; in[5] +=in[3]; in[3] +=in[1];
-
- float tmp0,tmp1,tmp2,tmp3,tmp4,tmp0_,tmp1_,tmp2_,tmp3_;
- float tmp0o,tmp1o,tmp2o,tmp3o,tmp4o,tmp0_o,tmp1_o,tmp2_o,tmp3_o;
-
- // Fast 9 Point Inverse Discrete Cosine Transform
- //
- // By Francois-Raymond Boyer
- // mailto:boyerf@iro.umontreal.ca
- // http://www.iro.umontreal.ca/~boyerf
- //
- // The code has been optimized for Intel processors
- // (takes a lot of time to convert float to and from iternal FPU representation)
- //
- // It is a simple "factorization" of the IDCT matrix.
-
- // 9 point IDCT on even indices
-
- // 5 points on odd indices (not realy an IDCT)
- float i00 = in[0]+in[0];
- float iip12 = i00 + in[12];
-
- tmp0 = iip12 + in[4]*1.8793852415718f + in[8]*1.532088886238f + in[16]*0.34729635533386f;
- tmp1 = i00 + in[4] - in[8] - in[12] - in[12] - in[16];
- tmp2 = iip12 - in[4]*0.34729635533386f - in[8]*1.8793852415718f + in[16]*1.532088886238f;
- tmp3 = iip12 - in[4]*1.532088886238f + in[8]*0.34729635533386f - in[16]*1.8793852415718f;
- tmp4 = in[0] - in[4] + in[8] - in[12] + in[16];
-
- // 4 points on even indices
- float i66_ = in[6]*1.732050808f; // Sqrt[3]
-
- tmp0_ = in[2]*1.9696155060244f + i66_ + in[10]*1.2855752193731f + in[14]*0.68404028665134f;
- tmp1_ = (in[2] - in[10] - in[14])*1.732050808f;
- tmp2_ = in[2]*1.2855752193731f - i66_ - in[10]*0.68404028665134f + in[14]*1.9696155060244f;
- tmp3_ = in[2]*0.68404028665134f - i66_ + in[10]*1.9696155060244f - in[14]*1.2855752193731f;
-
- // 9 point IDCT on odd indices
- // 5 points on odd indices (not realy an IDCT)
- float i0 = in[0+1]+in[0+1];
- float i0p12 = i0 + in[12+1];
-
- tmp0o = i0p12 + in[4+1]*1.8793852415718f + in[8+1]*1.532088886238f + in[16+1]*0.34729635533386f;
- tmp1o = i0 + in[4+1] - in[8+1] - in[12+1] - in[12+1] - in[16+1];
- tmp2o = i0p12 - in[4+1]*0.34729635533386f - in[8+1]*1.8793852415718f + in[16+1]*1.532088886238f;
- tmp3o = i0p12 - in[4+1]*1.532088886238f + in[8+1]*0.34729635533386f - in[16+1]*1.8793852415718f;
- tmp4o = (in[0+1] - in[4+1] + in[8+1] - in[12+1] + in[16+1])*0.707106781f; // Twiddled
-
- // 4 points on even indices
- float i6_ = in[6+1]*1.732050808f; // Sqrt[3]
-
- tmp0_o = in[2+1]*1.9696155060244f + i6_ + in[10+1]*1.2855752193731f + in[14+1]*0.68404028665134f;
- tmp1_o = (in[2+1] - in[10+1] - in[14+1])*1.732050808f;
- tmp2_o = in[2+1]*1.2855752193731f - i6_ - in[10+1]*0.68404028665134f + in[14+1]*1.9696155060244f;
- tmp3_o = in[2+1]*0.68404028665134f - i6_ + in[10+1]*1.9696155060244f - in[14+1]*1.2855752193731f;
-
- // Twiddle factors on odd indices
- // and
- // Butterflies on 9 point IDCT's
- // and
- // twiddle factors for 36 point IDCT
-
- float e, o;
- e = tmp0 + tmp0_; o = (tmp0o + tmp0_o)*0.501909918f; tmpf_0 = e + o; tmpf_17 = e - o;
- e = tmp1 + tmp1_; o = (tmp1o + tmp1_o)*0.517638090f; tmpf_1 = e + o; tmpf_16 = e - o;
- e = tmp2 + tmp2_; o = (tmp2o + tmp2_o)*0.551688959f; tmpf_2 = e + o; tmpf_15 = e - o;
- e = tmp3 + tmp3_; o = (tmp3o + tmp3_o)*0.610387294f; tmpf_3 = e + o; tmpf_14 = e - o;
- tmpf_4 = tmp4 + tmp4o; tmpf_13 = tmp4 - tmp4o;
- e = tmp3 - tmp3_; o = (tmp3o - tmp3_o)*0.871723397f; tmpf_5 = e + o; tmpf_12 = e - o;
- e = tmp2 - tmp2_; o = (tmp2o - tmp2_o)*1.183100792f; tmpf_6 = e + o; tmpf_11 = e - o;
- e = tmp1 - tmp1_; o = (tmp1o - tmp1_o)*1.931851653f; tmpf_7 = e + o; tmpf_10 = e - o;
- e = tmp0 - tmp0_; o = (tmp0o - tmp0_o)*5.736856623f; tmpf_8 = e + o; tmpf_9 = e - o;
-
- // end 36 point IDCT */
- // shift to modified IDCT
- win_bt = win[block_type];
-
- out[0] =-tmpf_9 * win_bt[0];
- out[1] =-tmpf_10 * win_bt[1];
- out[2] =-tmpf_11 * win_bt[2];
- out[3] =-tmpf_12 * win_bt[3];
- out[4] =-tmpf_13 * win_bt[4];
- out[5] =-tmpf_14 * win_bt[5];
- out[6] =-tmpf_15 * win_bt[6];
- out[7] =-tmpf_16 * win_bt[7];
- out[8] =-tmpf_17 * win_bt[8];
- out[9] = tmpf_17 * win_bt[9];
- out[10]= tmpf_16 * win_bt[10];
- out[11]= tmpf_15 * win_bt[11];
- out[12]= tmpf_14 * win_bt[12];
- out[13]= tmpf_13 * win_bt[13];
- out[14]= tmpf_12 * win_bt[14];
- out[15]= tmpf_11 * win_bt[15];
- out[16]= tmpf_10 * win_bt[16];
- out[17]= tmpf_9 * win_bt[17];
- out[18]= tmpf_8 * win_bt[18];
- out[19]= tmpf_7 * win_bt[19];
- out[20]= tmpf_6 * win_bt[20];
- out[21]= tmpf_5 * win_bt[21];
- out[22]= tmpf_4 * win_bt[22];
- out[23]= tmpf_3 * win_bt[23];
- out[24]= tmpf_2 * win_bt[24];
- out[25]= tmpf_1 * win_bt[25];
- out[26]= tmpf_0 * win_bt[26];
- out[27]= tmpf_0 * win_bt[27];
- out[28]= tmpf_1 * win_bt[28];
- out[29]= tmpf_2 * win_bt[29];
- out[30]= tmpf_3 * win_bt[30];
- out[31]= tmpf_4 * win_bt[31];
- out[32]= tmpf_5 * win_bt[32];
- out[33]= tmpf_6 * win_bt[33];
- out[34]= tmpf_7 * win_bt[34];
- out[35]= tmpf_8 * win_bt[35];
- }
- }
-
- private int counter = 0;
- private static final int SSLIMIT=18;
- private static final int SBLIMIT=32;
- // Size of the table of whole numbers raised to 4/3 power.
- // This may be adjusted for performance without any problems.
- //public static final int POW_TABLE_LIMIT=512;
-
- /************************************************************/
- /* L3TABLE */
- /************************************************************/
-
- static class SBI
- {
- public int[] l;
- public int[] s;
-
- public SBI()
- {
- l = new int[23];
- s = new int[14];
- }
- public SBI(int[] thel, int[] thes)
- {
- l = thel;
- s = thes;
- }
- }
-
- static class gr_info_s
- {
- public int part2_3_length = 0;
- public int big_values = 0;
- public int global_gain = 0;
- public int scalefac_compress = 0;
- public int window_switching_flag = 0;
- public int block_type = 0;
- public int mixed_block_flag = 0;
- public int[] table_select;
- public int[] subblock_gain;
- public int region0_count = 0;
- public int region1_count = 0;
- public int preflag = 0;
- public int scalefac_scale = 0;
- public int count1table_select = 0;
-
- /**
- * Dummy Constructor
- */
- public gr_info_s()
- {
- table_select = new int[3];
- subblock_gain = new int[3];
- }
- }
-
- static class temporaire
- {
- public int[] scfsi;
- public gr_info_s[] gr;
-
- /**
- * Dummy Constructor
- */
- public temporaire()
- {
- scfsi = new int[4];
- gr = new gr_info_s[2];
- gr[0] = new gr_info_s();
- gr[1] = new gr_info_s();
- }
- }
-
- static class III_side_info_t
- {
-
- public int main_data_begin = 0;
- public int private_bits = 0;
- public temporaire[] ch;
- /**
- * Dummy Constructor
- */
- public III_side_info_t()
- {
- ch = new temporaire[2];
- ch[0] = new temporaire();
- ch[1] = new temporaire();
- }
- }
-
- static class temporaire2
- {
- public int[] l; /* [cb] */
- public int[][] s; /* [window][cb] */
-
- /**
- * Dummy Constructor
- */
- public temporaire2()
- {
- l = new int[23];
- s = new int[3][13];
- }
- }
- //class III_scalefac_t
- //{
- // public temporaire2[] tab;
- // /**
- // * Dummy Constructor
- // */
- // public III_scalefac_t()
- // {
- // tab = new temporaire2[2];
- // }
- //}
-
- private static final int slen[][] =
- {
- {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
- {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}
- };
-
- public static final int pretab[] =
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0};
-
- private SBI[] sfBandIndex; // Init in the constructor.
-
- public static final float two_to_negative_half_pow[] =
- { 1.0000000000E+00f, 7.0710678119E-01f, 5.0000000000E-01f, 3.5355339059E-01f,
- 2.5000000000E-01f, 1.7677669530E-01f, 1.2500000000E-01f, 8.8388347648E-02f,
- 6.2500000000E-02f, 4.4194173824E-02f, 3.1250000000E-02f, 2.2097086912E-02f,
- 1.5625000000E-02f, 1.1048543456E-02f, 7.8125000000E-03f, 5.5242717280E-03f,
- 3.9062500000E-03f, 2.7621358640E-03f, 1.9531250000E-03f, 1.3810679320E-03f,
- 9.7656250000E-04f, 6.9053396600E-04f, 4.8828125000E-04f, 3.4526698300E-04f,
- 2.4414062500E-04f, 1.7263349150E-04f, 1.2207031250E-04f, 8.6316745750E-05f,
- 6.1035156250E-05f, 4.3158372875E-05f, 3.0517578125E-05f, 2.1579186438E-05f,
- 1.5258789062E-05f, 1.0789593219E-05f, 7.6293945312E-06f, 5.3947966094E-06f,
- 3.8146972656E-06f, 2.6973983047E-06f, 1.9073486328E-06f, 1.3486991523E-06f,
- 9.5367431641E-07f, 6.7434957617E-07f, 4.7683715820E-07f, 3.3717478809E-07f,
- 2.3841857910E-07f, 1.6858739404E-07f, 1.1920928955E-07f, 8.4293697022E-08f,
- 5.9604644775E-08f, 4.2146848511E-08f, 2.9802322388E-08f, 2.1073424255E-08f,
- 1.4901161194E-08f, 1.0536712128E-08f, 7.4505805969E-09f, 5.2683560639E-09f,
- 3.7252902985E-09f, 2.6341780319E-09f, 1.8626451492E-09f, 1.3170890160E-09f,
- 9.3132257462E-10f, 6.5854450798E-10f, 4.6566128731E-10f, 3.2927225399E-10f
- };
-
-
- public static final float t_43[] = create_t_43();
-
- static private float[] create_t_43()
- {
- float[] t43 = new float[8192];
- final double d43 = (4.0/3.0);
-
- for (int i=0; i<8192; i++)
- {
- t43[i] = (float)Math.pow(i, d43);
- }
- return t43;
- }
-
- public static final float io[][] =
- {
- { 1.0000000000E+00f, 8.4089641526E-01f, 7.0710678119E-01f, 5.9460355751E-01f,
- 5.0000000001E-01f, 4.2044820763E-01f, 3.5355339060E-01f, 2.9730177876E-01f,
- 2.5000000001E-01f, 2.1022410382E-01f, 1.7677669530E-01f, 1.4865088938E-01f,
- 1.2500000000E-01f, 1.0511205191E-01f, 8.8388347652E-02f, 7.4325444691E-02f,
- 6.2500000003E-02f, 5.2556025956E-02f, 4.4194173826E-02f, 3.7162722346E-02f,
- 3.1250000002E-02f, 2.6278012978E-02f, 2.2097086913E-02f, 1.8581361173E-02f,
- 1.5625000001E-02f, 1.3139006489E-02f, 1.1048543457E-02f, 9.2906805866E-03f,
- 7.8125000006E-03f, 6.5695032447E-03f, 5.5242717285E-03f, 4.6453402934E-03f },
- { 1.0000000000E+00f, 7.0710678119E-01f, 5.0000000000E-01f, 3.5355339060E-01f,
- 2.5000000000E-01f, 1.7677669530E-01f, 1.2500000000E-01f, 8.8388347650E-02f,
- 6.2500000001E-02f, 4.4194173825E-02f, 3.1250000001E-02f, 2.2097086913E-02f,
- 1.5625000000E-02f, 1.1048543456E-02f, 7.8125000002E-03f, 5.5242717282E-03f,
- 3.9062500001E-03f, 2.7621358641E-03f, 1.9531250001E-03f, 1.3810679321E-03f,
- 9.7656250004E-04f, 6.9053396603E-04f, 4.8828125002E-04f, 3.4526698302E-04f,
- 2.4414062501E-04f, 1.7263349151E-04f, 1.2207031251E-04f, 8.6316745755E-05f,
- 6.1035156254E-05f, 4.3158372878E-05f, 3.0517578127E-05f, 2.1579186439E-05f }
- };
-
-
-
- public static final float TAN12[] =
- {
- 0.0f, 0.26794919f, 0.57735027f, 1.0f,
- 1.73205081f, 3.73205081f, 9.9999999e10f, -3.73205081f,
- -1.73205081f, -1.0f, -0.57735027f, -0.26794919f,
- 0.0f, 0.26794919f, 0.57735027f, 1.0f
- };
-
- // REVIEW: in java, the array lookup may well be slower than
- // the actual calculation
- // 576 / 18
-/*
- private static final int ss_div[] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31
- };
-
- // 576 % 18
- private static final int ss_mod[] =
- {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
- };
-*/
- private static /*final*/ int reorder_table[][]/* = loadReorderTable()*/; // SZD: will be generated on demand
-
- /**
- * Loads the data for the reorder
- */
- /*private static int[][] loadReorderTable() // SZD: table will be generated
- {
- try
- {
- Class elemType = int[][].class.getComponentType();
- Object o = JavaLayerUtils.deserializeArrayResource("l3reorder.ser", elemType, 6);
- return (int[][])o;
- }
- catch (IOException ex)
- {
- throw new ExceptionInInitializerError(ex);
- }
- }*/
-
- static int[] reorder(int scalefac_band[]) { // SZD: converted from LAME
- int j = 0;
- int ix[] = new int[576];
- for(int sfb = 0; sfb < 13; sfb++) {
- int start = scalefac_band[sfb];
- int end = scalefac_band[sfb + 1];
- for(int window = 0; window < 3; window++)
- for(int i = start; i < end; i++)
- ix[3 * i + window] = j++;
- }
- return ix;
- }
-
- /*static final int reorder_table_data[][]; =
- {
- { 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,
- 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,
- 34, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45, 51,
- 40, 46, 52, 41, 47, 53, 54, 60, 66, 55, 61, 67, 56, 62, 68, 57,
- 63, 69, 58, 64, 70, 59, 65, 71, 72, 80, 88, 73, 81, 89, 74, 82,
- 90, 75, 83, 91, 76, 84, 92, 77, 85, 93, 78, 86, 94, 79, 87, 95,
- 96,106,116, 97,107,117, 98,108,118, 99,109,119,100,110,120,101,
- 111,121,102,112,122,103,113,123,104,114,124,105,115,125,126,140,
- 154,127,141,155,128,142,156,129,143,157,130,144,158,131,145,159,
- 132,146,160,133,147,161,134,148,162,135,149,163,136,150,164,137,
- 151,165,138,152,166,139,153,167,168,186,204,169,187,205,170,188,
- 206,171,189,207,172,190,208,173,191,209,174,192,210,175,193,211,
- 176,194,212,177,195,213,178,196,214,179,197,215,180,198,216,181,
- 199,217,182,200,218,183,201,219,184,202,220,185,203,221,222,248,
- 274,223,249,275,224,250,276,225,251,277,226,252,278,227,253,279,
- 228,254,280,229,255,281,230,256,282,231,257,283,232,258,284,233,
- 259,285,234,260,286,235,261,287,236,262,288,237,263,289,238,264,
- 290,239,265,291,240,266,292,241,267,293,242,268,294,243,269,295,
- 244,270,296,245,271,297,246,272,298,247,273,299,300,332,364,301,
- 333,365,302,334,366,303,335,367,304,336,368,305,337,369,306,338,
- 370,307,339,371,308,340,372,309,341,373,310,342,374,311,343,375,
- 312,344,376,313,345,377,314,346,378,315,347,379,316,348,380,317,
- 349,381,318,350,382,319,351,383,320,352,384,321,353,385,322,354,
- 386,323,355,387,324,356,388,325,357,389,326,358,390,327,359,391,
- 328,360,392,329,361,393,330,362,394,331,363,395,396,438,480,397,
- 439,481,398,440,482,399,441,483,400,442,484,401,443,485,402,444,
- 486,403,445,487,404,446,488,405,447,489,406,448,490,407,449,491,
- 408,450,492,409,451,493,410,452,494,411,453,495,412,454,496,413,
- 455,497,414,456,498,415,457,499,416,458,500,417,459,501,418,460,
- 502,419,461,503,420,462,504,421,463,505,422,464,506,423,465,507,
- 424,466,508,425,467,509,426,468,510,427,469,511,428,470,512,429,
- 471,513,430,472,514,431,473,515,432,474,516,433,475,517,434,476,
- 518,435,477,519,436,478,520,437,479,521,522,540,558,523,541,559,
- 524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,
- 547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,
- 570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575},
- { 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,
- 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,
- 34, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45, 51,
- 40, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56, 64, 72, 57,
- 65, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,
- 98, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103,
- 84, 94,104, 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,
- 121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,
- 138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,
- 144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,
- 163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,
- 182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,
- 188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,
- 211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,
- 234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,
- 240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,
- 269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,
- 298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,
- 256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,
- 285,309,262,286,310,263,287,311,312,344,376,313,345,377,314,346,
- 378,315,347,379,316,348,380,317,349,381,318,350,382,319,351,383,
- 320,352,384,321,353,385,322,354,386,323,355,387,324,356,388,325,
- 357,389,326,358,390,327,359,391,328,360,392,329,361,393,330,362,
- 394,331,363,395,332,364,396,333,365,397,334,366,398,335,367,399,
- 336,368,400,337,369,401,338,370,402,339,371,403,340,372,404,341,
- 373,405,342,374,406,343,375,407,408,452,496,409,453,497,410,454,
- 498,411,455,499,412,456,500,413,457,501,414,458,502,415,459,503,
- 416,460,504,417,461,505,418,462,506,419,463,507,420,464,508,421,
- 465,509,422,466,510,423,467,511,424,468,512,425,469,513,426,470,
- 514,427,471,515,428,472,516,429,473,517,430,474,518,431,475,519,
- 432,476,520,433,477,521,434,478,522,435,479,523,436,480,524,437,
- 481,525,438,482,526,439,483,527,440,484,528,441,485,529,442,486,
- 530,443,487,531,444,488,532,445,489,533,446,490,534,447,491,535,
- 448,492,536,449,493,537,450,494,538,451,495,539,540,552,564,541,
- 553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,
- 570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575},
- { 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,
- 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,
- 34, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45, 51,
- 40, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56, 64, 72, 57,
- 65, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,
- 98, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103,
- 84, 94,104, 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,
- 121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,
- 138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,
- 144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,
- 163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,
- 182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,
- 188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,
- 211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,
- 234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,
- 240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,
- 269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,
- 298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,
- 256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,
- 285,309,262,286,310,263,287,311,312,342,372,313,343,373,314,344,
- 374,315,345,375,316,346,376,317,347,377,318,348,378,319,349,379,
- 320,350,380,321,351,381,322,352,382,323,353,383,324,354,384,325,
- 355,385,326,356,386,327,357,387,328,358,388,329,359,389,330,360,
- 390,331,361,391,332,362,392,333,363,393,334,364,394,335,365,395,
- 336,366,396,337,367,397,338,368,398,339,369,399,340,370,400,341,
- 371,401,402,442,482,403,443,483,404,444,484,405,445,485,406,446,
- 486,407,447,487,408,448,488,409,449,489,410,450,490,411,451,491,
- 412,452,492,413,453,493,414,454,494,415,455,495,416,456,496,417,
- 457,497,418,458,498,419,459,499,420,460,500,421,461,501,422,462,
- 502,423,463,503,424,464,504,425,465,505,426,466,506,427,467,507,
- 428,468,508,429,469,509,430,470,510,431,471,511,432,472,512,433,
- 473,513,434,474,514,435,475,515,436,476,516,437,477,517,438,478,
- 518,439,479,519,440,480,520,441,481,521,522,540,558,523,541,559,
- 524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,
- 547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,
- 570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575},
- { 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,
- 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,
- 34, 27, 31, 35, 36, 40, 44, 37, 41, 45, 38, 42, 46, 39, 43, 47,
- 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52, 58, 64, 53,
- 59, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,
- 86, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,100,110, 91,101,111,
- 92,102,112, 93,103,113, 94,104,114, 95,105,115, 96,106,116, 97,
- 107,117, 98,108,118, 99,109,119,120,132,144,121,133,145,122,134,
- 146,123,135,147,124,136,148,125,137,149,126,138,150,127,139,151,
- 128,140,152,129,141,153,130,142,154,131,143,155,156,170,184,157,
- 171,185,158,172,186,159,173,187,160,174,188,161,175,189,162,176,
- 190,163,177,191,164,178,192,165,179,193,166,180,194,167,181,195,
- 168,182,196,169,183,197,198,216,234,199,217,235,200,218,236,201,
- 219,237,202,220,238,203,221,239,204,222,240,205,223,241,206,224,
- 242,207,225,243,208,226,244,209,227,245,210,228,246,211,229,247,
- 212,230,248,213,231,249,214,232,250,215,233,251,252,274,296,253,
- 275,297,254,276,298,255,277,299,256,278,300,257,279,301,258,280,
- 302,259,281,303,260,282,304,261,283,305,262,284,306,263,285,307,
- 264,286,308,265,287,309,266,288,310,267,289,311,268,290,312,269,
- 291,313,270,292,314,271,293,315,272,294,316,273,295,317,318,348,
- 378,319,349,379,320,350,380,321,351,381,322,352,382,323,353,383,
- 324,354,384,325,355,385,326,356,386,327,357,387,328,358,388,329,
- 359,389,330,360,390,331,361,391,332,362,392,333,363,393,334,364,
- 394,335,365,395,336,366,396,337,367,397,338,368,398,339,369,399,
- 340,370,400,341,371,401,342,372,402,343,373,403,344,374,404,345,
- 375,405,346,376,406,347,377,407,408,464,520,409,465,521,410,466,
- 522,411,467,523,412,468,524,413,469,525,414,470,526,415,471,527,
- 416,472,528,417,473,529,418,474,530,419,475,531,420,476,532,421,
- 477,533,422,478,534,423,479,535,424,480,536,425,481,537,426,482,
- 538,427,483,539,428,484,540,429,485,541,430,486,542,431,487,543,
- 432,488,544,433,489,545,434,490,546,435,491,547,436,492,548,437,
- 493,549,438,494,550,439,495,551,440,496,552,441,497,553,442,498,
- 554,443,499,555,444,500,556,445,501,557,446,502,558,447,503,559,
- 448,504,560,449,505,561,450,506,562,451,507,563,452,508,564,453,
- 509,565,454,510,566,455,511,567,456,512,568,457,513,569,458,514,
- 570,459,515,571,460,516,572,461,517,573,462,518,574,463,519,575},
- { 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,
- 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,
- 34, 27, 31, 35, 36, 40, 44, 37, 41, 45, 38, 42, 46, 39, 43, 47,
- 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52, 58, 64, 53,
- 59, 65, 66, 72, 78, 67, 73, 79, 68, 74, 80, 69, 75, 81, 70, 76,
- 82, 71, 77, 83, 84, 94,104, 85, 95,105, 86, 96,106, 87, 97,107,
- 88, 98,108, 89, 99,109, 90,100,110, 91,101,111, 92,102,112, 93,
- 103,113,114,126,138,115,127,139,116,128,140,117,129,141,118,130,
- 142,119,131,143,120,132,144,121,133,145,122,134,146,123,135,147,
- 124,136,148,125,137,149,150,164,178,151,165,179,152,166,180,153,
- 167,181,154,168,182,155,169,183,156,170,184,157,171,185,158,172,
- 186,159,173,187,160,174,188,161,175,189,162,176,190,163,177,191,
- 192,208,224,193,209,225,194,210,226,195,211,227,196,212,228,197,
- 213,229,198,214,230,199,215,231,200,216,232,201,217,233,202,218,
- 234,203,219,235,204,220,236,205,221,237,206,222,238,207,223,239,
- 240,260,280,241,261,281,242,262,282,243,263,283,244,264,284,245,
- 265,285,246,266,286,247,267,287,248,268,288,249,269,289,250,270,
- 290,251,271,291,252,272,292,253,273,293,254,274,294,255,275,295,
- 256,276,296,257,277,297,258,278,298,259,279,299,300,326,352,301,
- 327,353,302,328,354,303,329,355,304,330,356,305,331,357,306,332,
- 358,307,333,359,308,334,360,309,335,361,310,336,362,311,337,363,
- 312,338,364,313,339,365,314,340,366,315,341,367,316,342,368,317,
- 343,369,318,344,370,319,345,371,320,346,372,321,347,373,322,348,
- 374,323,349,375,324,350,376,325,351,377,378,444,510,379,445,511,
- 380,446,512,381,447,513,382,448,514,383,449,515,384,450,516,385,
- 451,517,386,452,518,387,453,519,388,454,520,389,455,521,390,456,
- 522,391,457,523,392,458,524,393,459,525,394,460,526,395,461,527,
- 396,462,528,397,463,529,398,464,530,399,465,531,400,466,532,401,
- 467,533,402,468,534,403,469,535,404,470,536,405,471,537,406,472,
- 538,407,473,539,408,474,540,409,475,541,410,476,542,411,477,543,
- 412,478,544,413,479,545,414,480,546,415,481,547,416,482,548,417,
- 483,549,418,484,550,419,485,551,420,486,552,421,487,553,422,488,
- 554,423,489,555,424,490,556,425,491,557,426,492,558,427,493,559,
- 428,494,560,429,495,561,430,496,562,431,497,563,432,498,564,433,
- 499,565,434,500,566,435,501,567,436,502,568,437,503,569,438,504,
- 570,439,505,571,440,506,572,441,507,573,442,508,574,443,509,575},
- { 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,
- 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,
- 34, 27, 31, 35, 36, 40, 44, 37, 41, 45, 38, 42, 46, 39, 43, 47,
- 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52, 58, 64, 53,
- 59, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,
- 86, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,102,114, 91,103,115,
- 92,104,116, 93,105,117, 94,106,118, 95,107,119, 96,108,120, 97,
- 109,121, 98,110,122, 99,111,123,100,112,124,101,113,125,126,142,
- 158,127,143,159,128,144,160,129,145,161,130,146,162,131,147,163,
- 132,148,164,133,149,165,134,150,166,135,151,167,136,152,168,137,
- 153,169,138,154,170,139,155,171,140,156,172,141,157,173,174,194,
- 214,175,195,215,176,196,216,177,197,217,178,198,218,179,199,219,
- 180,200,220,181,201,221,182,202,222,183,203,223,184,204,224,185,
- 205,225,186,206,226,187,207,227,188,208,228,189,209,229,190,210,
- 230,191,211,231,192,212,232,193,213,233,234,260,286,235,261,287,
- 236,262,288,237,263,289,238,264,290,239,265,291,240,266,292,241,
- 267,293,242,268,294,243,269,295,244,270,296,245,271,297,246,272,
- 298,247,273,299,248,274,300,249,275,301,250,276,302,251,277,303,
- 252,278,304,253,279,305,254,280,306,255,281,307,256,282,308,257,
- 283,309,258,284,310,259,285,311,312,346,380,313,347,381,314,348,
- 382,315,349,383,316,350,384,317,351,385,318,352,386,319,353,387,
- 320,354,388,321,355,389,322,356,390,323,357,391,324,358,392,325,
- 359,393,326,360,394,327,361,395,328,362,396,329,363,397,330,364,
- 398,331,365,399,332,366,400,333,367,401,334,368,402,335,369,403,
- 336,370,404,337,371,405,338,372,406,339,373,407,340,374,408,341,
- 375,409,342,376,410,343,377,411,344,378,412,345,379,413,414,456,
- 498,415,457,499,416,458,500,417,459,501,418,460,502,419,461,503,
- 420,462,504,421,463,505,422,464,506,423,465,507,424,466,508,425,
- 467,509,426,468,510,427,469,511,428,470,512,429,471,513,430,472,
- 514,431,473,515,432,474,516,433,475,517,434,476,518,435,477,519,
- 436,478,520,437,479,521,438,480,522,439,481,523,440,482,524,441,
- 483,525,442,484,526,443,485,527,444,486,528,445,487,529,446,488,
- 530,447,489,531,448,490,532,449,491,533,450,492,534,451,493,535,
- 452,494,536,453,495,537,454,496,538,455,497,539,540,552,564,541,
- 553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,
- 570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575}
- };
-*/
-
- private static final float cs[] =
- {
- 0.857492925712f, 0.881741997318f, 0.949628649103f, 0.983314592492f,
- 0.995517816065f, 0.999160558175f, 0.999899195243f, 0.999993155067f
- };
-
- private static final float ca[] =
- {
- -0.5144957554270f, -0.4717319685650f, -0.3133774542040f, -0.1819131996110f,
- -0.0945741925262f, -0.0409655828852f, -0.0141985685725f, -0.00369997467375f
- };
-
- /************************************************************/
- /* END OF L3TABLE */
- /************************************************************/
-
- /************************************************************/
- /* L3TYPE */
- /************************************************************/
-
-
- /***************************************************************/
- /* END OF L3TYPE */
- /***************************************************************/
-
- /***************************************************************/
- /* INV_MDCT */
- /***************************************************************/
- public static final float win[][] =
- {
- { -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,
- -4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,
- -3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,
- -7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,
- -4.0715656898E-01f, -3.6969460527E-01f, -3.3876269197E-01f, -3.1242222492E-01f,
- -2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,
- -2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,
- -1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,
- -8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f },
-
- { -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,
- -4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,
- -3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,
- -7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,
- -4.0715656898E-01f, -3.6969460527E-01f, -3.3908542600E-01f, -3.1511810350E-01f,
- -2.9642226150E-01f, -2.8184548650E-01f, -5.4119610000E-01f, -2.6213228100E-01f,
- -2.5387916537E-01f, -2.3296291359E-01f, -1.9852728987E-01f, -1.5233534808E-01f,
- -9.6496400054E-02f, -3.3423828516E-02f, 0.0000000000E+00f, 0.0000000000E+00f,
- 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },
-
- { -4.8300800645E-02f, -1.5715656932E-01f, -2.8325045177E-01f, -4.2953747763E-01f,
- -1.2071067795E+00f, -8.2426483178E-01f, -1.1451749106E+00f, -1.7695290101E+00f,
- -4.5470225061E+00f, -3.4890531002E+00f, -7.3296292804E-01f, -1.5076514758E-01f,
- 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
- 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
- 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
- 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
- 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
- 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },
-
- { 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
- 0.0000000000E+00f, 0.0000000000E+00f, -1.5076513660E-01f, -7.3296291107E-01f,
- -3.4890530566E+00f, -4.5470224727E+00f, -1.7695290031E+00f, -1.1451749092E+00f,
- -8.3137738100E-01f, -1.3065629650E+00f, -5.4142014250E-01f, -4.6528974900E-01f,
- -4.1066990750E-01f, -3.7004680800E-01f, -3.3876269197E-01f, -3.1242222492E-01f,
- -2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,
- -2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,
- -1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,
- -8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f }
- };
- /***************************************************************/
- /* END OF INV_MDCT */
- /***************************************************************/
-
- class Sftable
- {
- public int[] l;
- public int[] s;
-
- public Sftable()
- {
- l = new int[5];
- s = new int[3];
- }
-
- public Sftable(int[] thel, int[] thes)
- {
- l = thel;
- s = thes;
- }
- }
-
- public Sftable sftable;
-
- public static final int nr_of_sfb_block[][][] =
- {{{ 6, 5, 5, 5} , { 9, 9, 9, 9} , { 6, 9, 9, 9}},
- {{ 6, 5, 7, 3} , { 9, 9,12, 6} , { 6, 9,12, 6}},
- {{11,10, 0, 0} , {18,18, 0, 0} , {15,18, 0, 0}},
- {{ 7, 7, 7, 0} , {12,12,12, 0} , { 6,15,12, 0}},
- {{ 6, 6, 6, 3} , {12, 9, 9, 6} , { 6,12, 9, 6}},
- {{ 8, 8, 5, 0} , {15,12, 9, 0} , { 6,18, 9, 0}}};
-
-
-}
diff --git a/songdbj/javazoom/jl/decoder/Manager.java b/songdbj/javazoom/jl/decoder/Manager.java
deleted file mode 100644
index f566a232e7..0000000000
--- a/songdbj/javazoom/jl/decoder/Manager.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Work in progress.
- *
- * Manages a number of controls.
- */
-public class Manager //implements Control
-{
- public void addControl(Control c)
- {
-
- }
-
- public void removeControl(Control c)
- {
-
- }
-
- public void removeAll()
- {
-
- }
-
- // control interface delegates to a managed control
-
-}
diff --git a/songdbj/javazoom/jl/decoder/Obuffer.java b/songdbj/javazoom/jl/decoder/Obuffer.java
deleted file mode 100644
index 45a71a9baf..0000000000
--- a/songdbj/javazoom/jl/decoder/Obuffer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Added appendSamples() method for efficiency. MDM.
- * 15/02/99 ,Java Conversion by E.B ,ebsp@iname.com, JavaLayer
- *
- * Declarations for output buffer, includes operating system
- * implementation of the virtual Obuffer. Optional routines
- * enabling seeks and stops added by Jeff Tsay.
- *
- * @(#) obuffer.h 1.8, last edit: 6/15/94 16:51:56
- * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
- * @(#) Berlin University of Technology
- *
- * Idea and first implementation for u-law output with fast downsampling by
- * Jim Boucher (jboucher@flash.bu.edu)
- *
- * LinuxObuffer class written by
- * Louis P. Kruger (lpkruger@phoenix.princeton.edu)
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-package javazoom.jl.decoder;
-
-/**
- * Base Class for audio output.
- */
-public abstract class Obuffer
-{
- public static final int OBUFFERSIZE = 2 * 1152; // max. 2 * 1152 samples per frame
- public static final int MAXCHANNELS = 2; // max. number of channels
-
- /**
- * Takes a 16 Bit PCM sample.
- */
- public abstract void append(int channel, short value);
-
- /**
- * Accepts 32 new PCM samples.
- */
- public void appendSamples(int channel, float[] f)
- {
- short s;
- for (int i=0; i<32;)
- {
- s = clip(f[i++]);
- append(channel, s);
- }
- }
-
- /**
- * Clip Sample to 16 Bits
- */
- private final short clip(float sample)
- {
- return ((sample > 32767.0f) ? 32767 :
- ((sample < -32768.0f) ? -32768 :
- (short) sample));
- }
-
- /**
- * Write the samples to the file or directly to the audio hardware.
- */
- public abstract void write_buffer(int val);
- public abstract void close();
-
- /**
- * Clears all data in the buffer (for seeking).
- */
- public abstract void clear_buffer();
-
- /**
- * Notify the buffer that the user has stopped the stream.
- */
- public abstract void set_stop_flag();
-}
diff --git a/songdbj/javazoom/jl/decoder/OutputChannels.java b/songdbj/javazoom/jl/decoder/OutputChannels.java
deleted file mode 100644
index 58c8310de7..0000000000
--- a/songdbj/javazoom/jl/decoder/OutputChannels.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 12/12/99 Initial implementation. mdm@techie.com.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-
-/**
- * A Type-safe representation of the the supported output channel
- * constants.
- *
- * This class is immutable and, hence, is thread safe.
- *
- * @author Mat McGowan 12/12/99
- * @since 0.0.7
- */
-public class OutputChannels
-{
- /**
- * Flag to indicate output should include both channels.
- */
- public static final int BOTH_CHANNELS = 0;
-
- /**
- * Flag to indicate output should include the left channel only.
- */
- public static final int LEFT_CHANNEL = 1;
-
- /**
- * Flag to indicate output should include the right channel only.
- */
- public static final int RIGHT_CHANNEL = 2;
-
- /**
- * Flag to indicate output is mono.
- */
- public static final int DOWNMIX_CHANNELS = 3;
-
-
- public static final OutputChannels LEFT = new OutputChannels(LEFT_CHANNEL);
- public static final OutputChannels RIGHT = new OutputChannels(RIGHT_CHANNEL);
- public static final OutputChannels BOTH = new OutputChannels(BOTH_CHANNELS);
- public static final OutputChannels DOWNMIX = new OutputChannels(DOWNMIX_CHANNELS);
-
-
- private /*final*/ int outputChannels;
-
- /**
- * Creates an <code>OutputChannels</code> instance
- * corresponding to the given channel code.
- *
- * @param code one of the OutputChannels channel code constants.
- *
- * @throws IllegalArgumentException if code is not a valid
- * channel code.
- */
- static public OutputChannels fromInt(int code)
- {
- switch (code)
- {
- case LEFT_CHANNEL:
- return LEFT;
- case RIGHT_CHANNEL:
- return RIGHT;
- case BOTH_CHANNELS:
- return BOTH;
- case DOWNMIX_CHANNELS:
- return DOWNMIX;
- default:
- throw new IllegalArgumentException("Invalid channel code: "+code);
- }
- }
-
- private OutputChannels(int channels)
- {
- outputChannels = channels;
-
- if (channels<0 || channels>3)
- throw new IllegalArgumentException("channels");
- }
-
- /**
- * Retrieves the code representing the desired output channels.
- * Will be one of LEFT_CHANNEL, RIGHT_CHANNEL, BOTH_CHANNELS
- * or DOWNMIX_CHANNELS.
- *
- * @return the channel code represented by this instance.
- */
- public int getChannelsOutputCode()
- {
- return outputChannels;
- }
-
- /**
- * Retrieves the number of output channels represented
- * by this channel output type.
- *
- * @return The number of output channels for this channel output
- * type. This will be 2 for BOTH_CHANNELS only, and 1
- * for all other types.
- */
- public int getChannelCount()
- {
- int count = (outputChannels==BOTH_CHANNELS) ? 2 : 1;
- return count;
- }
-
-
- public boolean equals(Object o)
- {
- boolean equals = false;
-
- if (o instanceof OutputChannels)
- {
- OutputChannels oc = (OutputChannels)o;
- equals = (oc.outputChannels == outputChannels);
- }
-
- return equals;
- }
-
- public int hashCode()
- {
- return outputChannels;
- }
-
-}
diff --git a/songdbj/javazoom/jl/decoder/SampleBuffer.java b/songdbj/javazoom/jl/decoder/SampleBuffer.java
deleted file mode 100644
index ba4bfa060f..0000000000
--- a/songdbj/javazoom/jl/decoder/SampleBuffer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 12/12/99 Initial Version based on FileObuffer. mdm@techie.com.
- *
- * FileObuffer:
- * 15/02/99 Java Conversion by E.B ,javalayer@javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * The <code>SampleBuffer</code> class implements an output buffer
- * that provides storage for a fixed size block of samples.
- */
-public class SampleBuffer extends Obuffer
-{
- private short[] buffer;
- private int[] bufferp;
- private int channels;
- private int frequency;
-
- /**
- * Constructor
- */
- public SampleBuffer(int sample_frequency, int number_of_channels)
- {
- buffer = new short[OBUFFERSIZE];
- bufferp = new int[MAXCHANNELS];
- channels = number_of_channels;
- frequency = sample_frequency;
-
- for (int i = 0; i < number_of_channels; ++i)
- bufferp[i] = (short)i;
-
- }
-
- public int getChannelCount()
- {
- return this.channels;
- }
-
- public int getSampleFrequency()
- {
- return this.frequency;
- }
-
- public short[] getBuffer()
- {
- return this.buffer;
- }
-
- public int getBufferLength()
- {
- return bufferp[0];
- }
-
- /**
- * Takes a 16 Bit PCM sample.
- */
- public void append(int channel, short value)
- {
- buffer[bufferp[channel]] = value;
- bufferp[channel] += channels;
- }
-
- public void appendSamples(int channel, float[] f)
- {
- int pos = bufferp[channel];
-
- short s;
- float fs;
- for (int i=0; i<32;)
- {
- fs = f[i++];
- fs = (fs>32767.0f ? 32767.0f
- : (fs < -32767.0f ? -32767.0f : fs));
-
- s = (short)fs;
- buffer[pos] = s;
- pos += channels;
- }
-
- bufferp[channel] = pos;
- }
-
-
- /**
- * Write the samples to the file (Random Acces).
- */
- public void write_buffer(int val)
- {
-
- //for (int i = 0; i < channels; ++i)
- // bufferp[i] = (short)i;
-
- }
-
- public void close()
- {}
-
- /**
- *
- */
- public void clear_buffer()
- {
- for (int i = 0; i < channels; ++i)
- bufferp[i] = (short)i;
- }
-
- /**
- *
- */
- public void set_stop_flag()
- {}
-}
diff --git a/songdbj/javazoom/jl/decoder/Source.java b/songdbj/javazoom/jl/decoder/Source.java
deleted file mode 100644
index 9d6a5d732e..0000000000
--- a/songdbj/javazoom/jl/decoder/Source.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-import java.io.IOException;
-
-/**
- * Work in progress.
- *
- * Class to describe a seekable data source.
- *
- */
-public interface Source
-{
-
- public static final long LENGTH_UNKNOWN = -1;
-
- public int read(byte[] b, int offs, int len)
- throws IOException;
-
-
- public boolean willReadBlock();
-
- public boolean isSeekable();
-
- public long length();
-
- public long tell();
-
- public long seek(long pos);
-
-}
diff --git a/songdbj/javazoom/jl/decoder/SynthesisFilter.java b/songdbj/javazoom/jl/decoder/SynthesisFilter.java
deleted file mode 100644
index 581ab03cc2..0000000000
--- a/songdbj/javazoom/jl/decoder/SynthesisFilter.java
+++ /dev/null
@@ -1,1817 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 04/01/00 Fixes for running under build 23xx Microsoft JVM. mdm.
- *
- * 19/12/99 Performance improvements to compute_pcm_samples().
- * Mat McGowan. mdm@techie.com.
- *
- * 16/02/99 Java Conversion by E.B , javalayer@javazoom.net
- *
- * @(#) synthesis_filter.h 1.8, last edit: 6/15/94 16:52:00
- * @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
- * @(#) Berlin University of Technology
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-package javazoom.jl.decoder;
-
-import java.io.IOException;
-
-/**
- * A class for the synthesis filter bank.
- * This class does a fast downsampling from 32, 44.1 or 48 kHz to 8 kHz, if ULAW is defined.
- * Frequencies above 4 kHz are removed by ignoring higher subbands.
- */
-final class SynthesisFilter
-{
- private float[] v1;
- private float[] v2;
- private float[] actual_v; // v1 or v2
- private int actual_write_pos; // 0-15
- private float[] samples; // 32 new subband samples
- private int channel;
- private float scalefactor;
- private float[] eq;
-
- /**
- * Quality value for controlling CPU usage/quality tradeoff.
- */
- /*
- private int quality;
-
- private int v_inc;
-
-
-
- public static final int HIGH_QUALITY = 1;
- public static final int MEDIUM_QUALITY = 2;
- public static final int LOW_QUALITY = 4;
- */
-
- /**
- * Contructor.
- * The scalefactor scales the calculated float pcm samples to short values
- * (raw pcm samples are in [-1.0, 1.0], if no violations occur).
- */
- public SynthesisFilter(int channelnumber, float factor, float[] eq0)
- {
- if (d==null)
- {
- d = load_d();
- d16 = splitArray(d, 16);
- }
-
- v1 = new float[512];
- v2 = new float[512];
- samples = new float[32];
- channel = channelnumber;
- scalefactor = factor;
- setEQ(eq);
- //setQuality(HIGH_QUALITY);
-
- reset();
- }
-
- public void setEQ(float[] eq0)
- {
- this.eq = eq0;
- if (eq==null)
- {
- eq = new float[32];
- for (int i=0; i<32; i++)
- eq[i] = 1.0f;
- }
- if (eq.length<32)
- {
- throw new IllegalArgumentException("eq0");
- }
-
- }
-
- /*
- private void setQuality(int quality0)
- {
- switch (quality0)
- {
- case HIGH_QUALITY:
- case MEDIUM_QUALITY:
- case LOW_QUALITY:
- v_inc = 16 * quality0;
- quality = quality0;
- break;
- default :
- throw new IllegalArgumentException("Unknown quality value");
- }
- }
-
- public int getQuality()
- {
- return quality;
- }
- */
-
- /**
- * Reset the synthesis filter.
- */
- public void reset()
- {
- //float[] floatp;
- // float[] floatp2;
-
- // initialize v1[] and v2[]:
- //for (floatp = v1 + 512, floatp2 = v2 + 512; floatp > v1; )
- // *--floatp = *--floatp2 = 0.0;
- for (int p=0;p<512;p++)
- v1[p] = v2[p] = 0.0f;
-
- // initialize samples[]:
- //for (floatp = samples + 32; floatp > samples; )
- // *--floatp = 0.0;
- for (int p2=0;p2<32;p2++)
- samples[p2] = 0.0f;
-
- actual_v = v1;
- actual_write_pos = 15;
- }
-
-
- /**
- * Inject Sample.
- */
- public void input_sample(float sample, int subbandnumber)
- {
- samples[subbandnumber] = eq[subbandnumber]*sample;
- }
-
- public void input_samples(float[] s)
- {
- for (int i=31; i>=0; i--)
- {
- samples[i] = s[i]*eq[i];
- }
- }
-
- /**
- * Compute new values via a fast cosine transform.
- */
- private void compute_new_v()
- {
- // p is fully initialized from x1
- //float[] p = _p;
- // pp is fully initialized from p
- //float[] pp = _pp;
-
- //float[] new_v = _new_v;
-
- //float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
- //float[] p = new float[16];
- //float[] pp = new float[16];
-
- /*
- for (int i=31; i>=0; i--)
- {
- new_v[i] = 0.0f;
- }
- */
-
- float new_v0, new_v1, new_v2, new_v3, new_v4, new_v5, new_v6, new_v7, new_v8, new_v9;
- float new_v10, new_v11, new_v12, new_v13, new_v14, new_v15, new_v16, new_v17, new_v18, new_v19;
- float new_v20, new_v21, new_v22, new_v23, new_v24, new_v25, new_v26, new_v27, new_v28, new_v29;
- float new_v30, new_v31;
-
- new_v0 = new_v1 = new_v2 = new_v3 = new_v4 = new_v5 = new_v6 = new_v7 = new_v8 = new_v9 =
- new_v10 = new_v11 = new_v12 = new_v13 = new_v14 = new_v15 = new_v16 = new_v17 = new_v18 = new_v19 =
- new_v20 = new_v21 = new_v22 = new_v23 = new_v24 = new_v25 = new_v26 = new_v27 = new_v28 = new_v29 =
- new_v30 = new_v31 = 0.0f;
-
-
-// float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
-// float[] p = new float[16];
-// float[] pp = new float[16];
-
- float[] s = samples;
-
- float s0 = s[0];
- float s1 = s[1];
- float s2 = s[2];
- float s3 = s[3];
- float s4 = s[4];
- float s5 = s[5];
- float s6 = s[6];
- float s7 = s[7];
- float s8 = s[8];
- float s9 = s[9];
- float s10 = s[10];
- float s11 = s[11];
- float s12 = s[12];
- float s13 = s[13];
- float s14 = s[14];
- float s15 = s[15];
- float s16 = s[16];
- float s17 = s[17];
- float s18 = s[18];
- float s19 = s[19];
- float s20 = s[20];
- float s21 = s[21];
- float s22 = s[22];
- float s23 = s[23];
- float s24 = s[24];
- float s25 = s[25];
- float s26 = s[26];
- float s27 = s[27];
- float s28 = s[28];
- float s29 = s[29];
- float s30 = s[30];
- float s31 = s[31];
-
- float p0 = s0 + s31;
- float p1 = s1 + s30;
- float p2 = s2 + s29;
- float p3 = s3 + s28;
- float p4 = s4 + s27;
- float p5 = s5 + s26;
- float p6 = s6 + s25;
- float p7 = s7 + s24;
- float p8 = s8 + s23;
- float p9 = s9 + s22;
- float p10 = s10 + s21;
- float p11 = s11 + s20;
- float p12 = s12 + s19;
- float p13 = s13 + s18;
- float p14 = s14 + s17;
- float p15 = s15 + s16;
-
- float pp0 = p0 + p15;
- float pp1 = p1 + p14;
- float pp2 = p2 + p13;
- float pp3 = p3 + p12;
- float pp4 = p4 + p11;
- float pp5 = p5 + p10;
- float pp6 = p6 + p9;
- float pp7 = p7 + p8;
- float pp8 = (p0 - p15) * cos1_32;
- float pp9 = (p1 - p14) * cos3_32;
- float pp10 = (p2 - p13) * cos5_32;
- float pp11 = (p3 - p12) * cos7_32;
- float pp12 = (p4 - p11) * cos9_32;
- float pp13 = (p5 - p10) * cos11_32;
- float pp14 = (p6 - p9) * cos13_32;
- float pp15 = (p7 - p8) * cos15_32;
-
- p0 = pp0 + pp7;
- p1 = pp1 + pp6;
- p2 = pp2 + pp5;
- p3 = pp3 + pp4;
- p4 = (pp0 - pp7) * cos1_16;
- p5 = (pp1 - pp6) * cos3_16;
- p6 = (pp2 - pp5) * cos5_16;
- p7 = (pp3 - pp4) * cos7_16;
- p8 = pp8 + pp15;
- p9 = pp9 + pp14;
- p10 = pp10 + pp13;
- p11 = pp11 + pp12;
- p12 = (pp8 - pp15) * cos1_16;
- p13 = (pp9 - pp14) * cos3_16;
- p14 = (pp10 - pp13) * cos5_16;
- p15 = (pp11 - pp12) * cos7_16;
-
-
- pp0 = p0 + p3;
- pp1 = p1 + p2;
- pp2 = (p0 - p3) * cos1_8;
- pp3 = (p1 - p2) * cos3_8;
- pp4 = p4 + p7;
- pp5 = p5 + p6;
- pp6 = (p4 - p7) * cos1_8;
- pp7 = (p5 - p6) * cos3_8;
- pp8 = p8 + p11;
- pp9 = p9 + p10;
- pp10 = (p8 - p11) * cos1_8;
- pp11 = (p9 - p10) * cos3_8;
- pp12 = p12 + p15;
- pp13 = p13 + p14;
- pp14 = (p12 - p15) * cos1_8;
- pp15 = (p13 - p14) * cos3_8;
-
- p0 = pp0 + pp1;
- p1 = (pp0 - pp1) * cos1_4;
- p2 = pp2 + pp3;
- p3 = (pp2 - pp3) * cos1_4;
- p4 = pp4 + pp5;
- p5 = (pp4 - pp5) * cos1_4;
- p6 = pp6 + pp7;
- p7 = (pp6 - pp7) * cos1_4;
- p8 = pp8 + pp9;
- p9 = (pp8 - pp9) * cos1_4;
- p10 = pp10 + pp11;
- p11 = (pp10 - pp11) * cos1_4;
- p12 = pp12 + pp13;
- p13 = (pp12 - pp13) * cos1_4;
- p14 = pp14 + pp15;
- p15 = (pp14 - pp15) * cos1_4;
-
- // this is pretty insane coding
- float tmp1;
- new_v19/*36-17*/ = -(new_v4 = (new_v12 = p7) + p5) - p6;
- new_v27/*44-17*/ = -p6 - p7 - p4;
- new_v6 = (new_v10 = (new_v14 = p15) + p11) + p13;
- new_v17/*34-17*/ = -(new_v2 = p15 + p13 + p9) - p14;
- new_v21/*38-17*/ = (tmp1 = -p14 - p15 - p10 - p11) - p13;
- new_v29/*46-17*/ = -p14 - p15 - p12 - p8;
- new_v25/*42-17*/ = tmp1 - p12;
- new_v31/*48-17*/ = -p0;
- new_v0 = p1;
- new_v23/*40-17*/ = -(new_v8 = p3) - p2;
-
- p0 = (s0 - s31) * cos1_64;
- p1 = (s1 - s30) * cos3_64;
- p2 = (s2 - s29) * cos5_64;
- p3 = (s3 - s28) * cos7_64;
- p4 = (s4 - s27) * cos9_64;
- p5 = (s5 - s26) * cos11_64;
- p6 = (s6 - s25) * cos13_64;
- p7 = (s7 - s24) * cos15_64;
- p8 = (s8 - s23) * cos17_64;
- p9 = (s9 - s22) * cos19_64;
- p10 = (s10 - s21) * cos21_64;
- p11 = (s11 - s20) * cos23_64;
- p12 = (s12 - s19) * cos25_64;
- p13 = (s13 - s18) * cos27_64;
- p14 = (s14 - s17) * cos29_64;
- p15 = (s15 - s16) * cos31_64;
-
-
- pp0 = p0 + p15;
- pp1 = p1 + p14;
- pp2 = p2 + p13;
- pp3 = p3 + p12;
- pp4 = p4 + p11;
- pp5 = p5 + p10;
- pp6 = p6 + p9;
- pp7 = p7 + p8;
- pp8 = (p0 - p15) * cos1_32;
- pp9 = (p1 - p14) * cos3_32;
- pp10 = (p2 - p13) * cos5_32;
- pp11 = (p3 - p12) * cos7_32;
- pp12 = (p4 - p11) * cos9_32;
- pp13 = (p5 - p10) * cos11_32;
- pp14 = (p6 - p9) * cos13_32;
- pp15 = (p7 - p8) * cos15_32;
-
-
- p0 = pp0 + pp7;
- p1 = pp1 + pp6;
- p2 = pp2 + pp5;
- p3 = pp3 + pp4;
- p4 = (pp0 - pp7) * cos1_16;
- p5 = (pp1 - pp6) * cos3_16;
- p6 = (pp2 - pp5) * cos5_16;
- p7 = (pp3 - pp4) * cos7_16;
- p8 = pp8 + pp15;
- p9 = pp9 + pp14;
- p10 = pp10 + pp13;
- p11 = pp11 + pp12;
- p12 = (pp8 - pp15) * cos1_16;
- p13 = (pp9 - pp14) * cos3_16;
- p14 = (pp10 - pp13) * cos5_16;
- p15 = (pp11 - pp12) * cos7_16;
-
-
- pp0 = p0 + p3;
- pp1 = p1 + p2;
- pp2 = (p0 - p3) * cos1_8;
- pp3 = (p1 - p2) * cos3_8;
- pp4 = p4 + p7;
- pp5 = p5 + p6;
- pp6 = (p4 - p7) * cos1_8;
- pp7 = (p5 - p6) * cos3_8;
- pp8 = p8 + p11;
- pp9 = p9 + p10;
- pp10 = (p8 - p11) * cos1_8;
- pp11 = (p9 - p10) * cos3_8;
- pp12 = p12 + p15;
- pp13 = p13 + p14;
- pp14 = (p12 - p15) * cos1_8;
- pp15 = (p13 - p14) * cos3_8;
-
-
- p0 = pp0 + pp1;
- p1 = (pp0 - pp1) * cos1_4;
- p2 = pp2 + pp3;
- p3 = (pp2 - pp3) * cos1_4;
- p4 = pp4 + pp5;
- p5 = (pp4 - pp5) * cos1_4;
- p6 = pp6 + pp7;
- p7 = (pp6 - pp7) * cos1_4;
- p8 = pp8 + pp9;
- p9 = (pp8 - pp9) * cos1_4;
- p10 = pp10 + pp11;
- p11 = (pp10 - pp11) * cos1_4;
- p12 = pp12 + pp13;
- p13 = (pp12 - pp13) * cos1_4;
- p14 = pp14 + pp15;
- p15 = (pp14 - pp15) * cos1_4;
-
-
- // manually doing something that a compiler should handle sucks
- // coding like this is hard to read
- float tmp2;
- new_v5 = (new_v11 = (new_v13 = (new_v15 = p15) + p7) + p11)
- + p5 + p13;
- new_v7 = (new_v9 = p15 + p11 + p3) + p13;
- new_v16/*33-17*/ = -(new_v1 = (tmp1 = p13 + p15 + p9) + p1) - p14;
- new_v18/*35-17*/ = -(new_v3 = tmp1 + p5 + p7) - p6 - p14;
-
- new_v22/*39-17*/ = (tmp1 = -p10 - p11 - p14 - p15)
- - p13 - p2 - p3;
- new_v20/*37-17*/ = tmp1 - p13 - p5 - p6 - p7;
- new_v24/*41-17*/ = tmp1 - p12 - p2 - p3;
- new_v26/*43-17*/ = tmp1 - p12 - (tmp2 = p4 + p6 + p7);
- new_v30/*47-17*/ = (tmp1 = -p8 - p12 - p14 - p15) - p0;
- new_v28/*45-17*/ = tmp1 - tmp2;
-
- // insert V[0-15] (== new_v[0-15]) into actual v:
- // float[] x2 = actual_v + actual_write_pos;
- float dest[] = actual_v;
-
- int pos = actual_write_pos;
-
- dest[0 + pos] = new_v0;
- dest[16 + pos] = new_v1;
- dest[32 + pos] = new_v2;
- dest[48 + pos] = new_v3;
- dest[64 + pos] = new_v4;
- dest[80 + pos] = new_v5;
- dest[96 + pos] = new_v6;
- dest[112 + pos] = new_v7;
- dest[128 + pos] = new_v8;
- dest[144 + pos] = new_v9;
- dest[160 + pos] = new_v10;
- dest[176 + pos] = new_v11;
- dest[192 + pos] = new_v12;
- dest[208 + pos] = new_v13;
- dest[224 + pos] = new_v14;
- dest[240 + pos] = new_v15;
-
- // V[16] is always 0.0:
- dest[256 + pos] = 0.0f;
-
- // insert V[17-31] (== -new_v[15-1]) into actual v:
- dest[272 + pos] = -new_v15;
- dest[288 + pos] = -new_v14;
- dest[304 + pos] = -new_v13;
- dest[320 + pos] = -new_v12;
- dest[336 + pos] = -new_v11;
- dest[352 + pos] = -new_v10;
- dest[368 + pos] = -new_v9;
- dest[384 + pos] = -new_v8;
- dest[400 + pos] = -new_v7;
- dest[416 + pos] = -new_v6;
- dest[432 + pos] = -new_v5;
- dest[448 + pos] = -new_v4;
- dest[464 + pos] = -new_v3;
- dest[480 + pos] = -new_v2;
- dest[496 + pos] = -new_v1;
-
- // insert V[32] (== -new_v[0]) into other v:
- dest = (actual_v==v1) ? v2 : v1;
-
- dest[0 + pos] = -new_v0;
- // insert V[33-48] (== new_v[16-31]) into other v:
- dest[16 + pos] = new_v16;
- dest[32 + pos] = new_v17;
- dest[48 + pos] = new_v18;
- dest[64 + pos] = new_v19;
- dest[80 + pos] = new_v20;
- dest[96 + pos] = new_v21;
- dest[112 + pos] = new_v22;
- dest[128 + pos] = new_v23;
- dest[144 + pos] = new_v24;
- dest[160 + pos] = new_v25;
- dest[176 + pos] = new_v26;
- dest[192 + pos] = new_v27;
- dest[208 + pos] = new_v28;
- dest[224 + pos] = new_v29;
- dest[240 + pos] = new_v30;
- dest[256 + pos] = new_v31;
-
- // insert V[49-63] (== new_v[30-16]) into other v:
- dest[272 + pos] = new_v30;
- dest[288 + pos] = new_v29;
- dest[304 + pos] = new_v28;
- dest[320 + pos] = new_v27;
- dest[336 + pos] = new_v26;
- dest[352 + pos] = new_v25;
- dest[368 + pos] = new_v24;
- dest[384 + pos] = new_v23;
- dest[400 + pos] = new_v22;
- dest[416 + pos] = new_v21;
- dest[432 + pos] = new_v20;
- dest[448 + pos] = new_v19;
- dest[464 + pos] = new_v18;
- dest[480 + pos] = new_v17;
- dest[496 + pos] = new_v16;
-/*
- }
- else
- {
- v1[0 + actual_write_pos] = -new_v0;
- // insert V[33-48] (== new_v[16-31]) into other v:
- v1[16 + actual_write_pos] = new_v16;
- v1[32 + actual_write_pos] = new_v17;
- v1[48 + actual_write_pos] = new_v18;
- v1[64 + actual_write_pos] = new_v19;
- v1[80 + actual_write_pos] = new_v20;
- v1[96 + actual_write_pos] = new_v21;
- v1[112 + actual_write_pos] = new_v22;
- v1[128 + actual_write_pos] = new_v23;
- v1[144 + actual_write_pos] = new_v24;
- v1[160 + actual_write_pos] = new_v25;
- v1[176 + actual_write_pos] = new_v26;
- v1[192 + actual_write_pos] = new_v27;
- v1[208 + actual_write_pos] = new_v28;
- v1[224 + actual_write_pos] = new_v29;
- v1[240 + actual_write_pos] = new_v30;
- v1[256 + actual_write_pos] = new_v31;
-
- // insert V[49-63] (== new_v[30-16]) into other v:
- v1[272 + actual_write_pos] = new_v30;
- v1[288 + actual_write_pos] = new_v29;
- v1[304 + actual_write_pos] = new_v28;
- v1[320 + actual_write_pos] = new_v27;
- v1[336 + actual_write_pos] = new_v26;
- v1[352 + actual_write_pos] = new_v25;
- v1[368 + actual_write_pos] = new_v24;
- v1[384 + actual_write_pos] = new_v23;
- v1[400 + actual_write_pos] = new_v22;
- v1[416 + actual_write_pos] = new_v21;
- v1[432 + actual_write_pos] = new_v20;
- v1[448 + actual_write_pos] = new_v19;
- v1[464 + actual_write_pos] = new_v18;
- v1[480 + actual_write_pos] = new_v17;
- v1[496 + actual_write_pos] = new_v16;
- }
-*/
- }
-
- /**
- * Compute new values via a fast cosine transform.
- */
- private void compute_new_v_old()
- {
- // p is fully initialized from x1
- //float[] p = _p;
- // pp is fully initialized from p
- //float[] pp = _pp;
-
- //float[] new_v = _new_v;
-
- float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
- float[] p = new float[16];
- float[] pp = new float[16];
-
-
- for (int i=31; i>=0; i--)
- {
- new_v[i] = 0.0f;
- }
-
-// float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
-// float[] p = new float[16];
-// float[] pp = new float[16];
-
- float[] x1 = samples;
-
- p[0] = x1[0] + x1[31];
- p[1] = x1[1] + x1[30];
- p[2] = x1[2] + x1[29];
- p[3] = x1[3] + x1[28];
- p[4] = x1[4] + x1[27];
- p[5] = x1[5] + x1[26];
- p[6] = x1[6] + x1[25];
- p[7] = x1[7] + x1[24];
- p[8] = x1[8] + x1[23];
- p[9] = x1[9] + x1[22];
- p[10] = x1[10] + x1[21];
- p[11] = x1[11] + x1[20];
- p[12] = x1[12] + x1[19];
- p[13] = x1[13] + x1[18];
- p[14] = x1[14] + x1[17];
- p[15] = x1[15] + x1[16];
-
- pp[0] = p[0] + p[15];
- pp[1] = p[1] + p[14];
- pp[2] = p[2] + p[13];
- pp[3] = p[3] + p[12];
- pp[4] = p[4] + p[11];
- pp[5] = p[5] + p[10];
- pp[6] = p[6] + p[9];
- pp[7] = p[7] + p[8];
- pp[8] = (p[0] - p[15]) * cos1_32;
- pp[9] = (p[1] - p[14]) * cos3_32;
- pp[10] = (p[2] - p[13]) * cos5_32;
- pp[11] = (p[3] - p[12]) * cos7_32;
- pp[12] = (p[4] - p[11]) * cos9_32;
- pp[13] = (p[5] - p[10]) * cos11_32;
- pp[14] = (p[6] - p[9]) * cos13_32;
- pp[15] = (p[7] - p[8]) * cos15_32;
-
- p[0] = pp[0] + pp[7];
- p[1] = pp[1] + pp[6];
- p[2] = pp[2] + pp[5];
- p[3] = pp[3] + pp[4];
- p[4] = (pp[0] - pp[7]) * cos1_16;
- p[5] = (pp[1] - pp[6]) * cos3_16;
- p[6] = (pp[2] - pp[5]) * cos5_16;
- p[7] = (pp[3] - pp[4]) * cos7_16;
- p[8] = pp[8] + pp[15];
- p[9] = pp[9] + pp[14];
- p[10] = pp[10] + pp[13];
- p[11] = pp[11] + pp[12];
- p[12] = (pp[8] - pp[15]) * cos1_16;
- p[13] = (pp[9] - pp[14]) * cos3_16;
- p[14] = (pp[10] - pp[13]) * cos5_16;
- p[15] = (pp[11] - pp[12]) * cos7_16;
-
-
- pp[0] = p[0] + p[3];
- pp[1] = p[1] + p[2];
- pp[2] = (p[0] - p[3]) * cos1_8;
- pp[3] = (p[1] - p[2]) * cos3_8;
- pp[4] = p[4] + p[7];
- pp[5] = p[5] + p[6];
- pp[6] = (p[4] - p[7]) * cos1_8;
- pp[7] = (p[5] - p[6]) * cos3_8;
- pp[8] = p[8] + p[11];
- pp[9] = p[9] + p[10];
- pp[10] = (p[8] - p[11]) * cos1_8;
- pp[11] = (p[9] - p[10]) * cos3_8;
- pp[12] = p[12] + p[15];
- pp[13] = p[13] + p[14];
- pp[14] = (p[12] - p[15]) * cos1_8;
- pp[15] = (p[13] - p[14]) * cos3_8;
-
- p[0] = pp[0] + pp[1];
- p[1] = (pp[0] - pp[1]) * cos1_4;
- p[2] = pp[2] + pp[3];
- p[3] = (pp[2] - pp[3]) * cos1_4;
- p[4] = pp[4] + pp[5];
- p[5] = (pp[4] - pp[5]) * cos1_4;
- p[6] = pp[6] + pp[7];
- p[7] = (pp[6] - pp[7]) * cos1_4;
- p[8] = pp[8] + pp[9];
- p[9] = (pp[8] - pp[9]) * cos1_4;
- p[10] = pp[10] + pp[11];
- p[11] = (pp[10] - pp[11]) * cos1_4;
- p[12] = pp[12] + pp[13];
- p[13] = (pp[12] - pp[13]) * cos1_4;
- p[14] = pp[14] + pp[15];
- p[15] = (pp[14] - pp[15]) * cos1_4;
-
- // this is pretty insane coding
- float tmp1;
- new_v[36-17] = -(new_v[4] = (new_v[12] = p[7]) + p[5]) - p[6];
- new_v[44-17] = -p[6] - p[7] - p[4];
- new_v[6] = (new_v[10] = (new_v[14] = p[15]) + p[11]) + p[13];
- new_v[34-17] = -(new_v[2] = p[15] + p[13] + p[9]) - p[14];
- new_v[38-17] = (tmp1 = -p[14] - p[15] - p[10] - p[11]) - p[13];
- new_v[46-17] = -p[14] - p[15] - p[12] - p[8];
- new_v[42-17] = tmp1 - p[12];
- new_v[48-17] = -p[0];
- new_v[0] = p[1];
- new_v[40-17] = -(new_v[8] = p[3]) - p[2];
-
- p[0] = (x1[0] - x1[31]) * cos1_64;
- p[1] = (x1[1] - x1[30]) * cos3_64;
- p[2] = (x1[2] - x1[29]) * cos5_64;
- p[3] = (x1[3] - x1[28]) * cos7_64;
- p[4] = (x1[4] - x1[27]) * cos9_64;
- p[5] = (x1[5] - x1[26]) * cos11_64;
- p[6] = (x1[6] - x1[25]) * cos13_64;
- p[7] = (x1[7] - x1[24]) * cos15_64;
- p[8] = (x1[8] - x1[23]) * cos17_64;
- p[9] = (x1[9] - x1[22]) * cos19_64;
- p[10] = (x1[10] - x1[21]) * cos21_64;
- p[11] = (x1[11] - x1[20]) * cos23_64;
- p[12] = (x1[12] - x1[19]) * cos25_64;
- p[13] = (x1[13] - x1[18]) * cos27_64;
- p[14] = (x1[14] - x1[17]) * cos29_64;
- p[15] = (x1[15] - x1[16]) * cos31_64;
-
-
- pp[0] = p[0] + p[15];
- pp[1] = p[1] + p[14];
- pp[2] = p[2] + p[13];
- pp[3] = p[3] + p[12];
- pp[4] = p[4] + p[11];
- pp[5] = p[5] + p[10];
- pp[6] = p[6] + p[9];
- pp[7] = p[7] + p[8];
- pp[8] = (p[0] - p[15]) * cos1_32;
- pp[9] = (p[1] - p[14]) * cos3_32;
- pp[10] = (p[2] - p[13]) * cos5_32;
- pp[11] = (p[3] - p[12]) * cos7_32;
- pp[12] = (p[4] - p[11]) * cos9_32;
- pp[13] = (p[5] - p[10]) * cos11_32;
- pp[14] = (p[6] - p[9]) * cos13_32;
- pp[15] = (p[7] - p[8]) * cos15_32;
-
-
- p[0] = pp[0] + pp[7];
- p[1] = pp[1] + pp[6];
- p[2] = pp[2] + pp[5];
- p[3] = pp[3] + pp[4];
- p[4] = (pp[0] - pp[7]) * cos1_16;
- p[5] = (pp[1] - pp[6]) * cos3_16;
- p[6] = (pp[2] - pp[5]) * cos5_16;
- p[7] = (pp[3] - pp[4]) * cos7_16;
- p[8] = pp[8] + pp[15];
- p[9] = pp[9] + pp[14];
- p[10] = pp[10] + pp[13];
- p[11] = pp[11] + pp[12];
- p[12] = (pp[8] - pp[15]) * cos1_16;
- p[13] = (pp[9] - pp[14]) * cos3_16;
- p[14] = (pp[10] - pp[13]) * cos5_16;
- p[15] = (pp[11] - pp[12]) * cos7_16;
-
-
- pp[0] = p[0] + p[3];
- pp[1] = p[1] + p[2];
- pp[2] = (p[0] - p[3]) * cos1_8;
- pp[3] = (p[1] - p[2]) * cos3_8;
- pp[4] = p[4] + p[7];
- pp[5] = p[5] + p[6];
- pp[6] = (p[4] - p[7]) * cos1_8;
- pp[7] = (p[5] - p[6]) * cos3_8;
- pp[8] = p[8] + p[11];
- pp[9] = p[9] + p[10];
- pp[10] = (p[8] - p[11]) * cos1_8;
- pp[11] = (p[9] - p[10]) * cos3_8;
- pp[12] = p[12] + p[15];
- pp[13] = p[13] + p[14];
- pp[14] = (p[12] - p[15]) * cos1_8;
- pp[15] = (p[13] - p[14]) * cos3_8;
-
-
- p[0] = pp[0] + pp[1];
- p[1] = (pp[0] - pp[1]) * cos1_4;
- p[2] = pp[2] + pp[3];
- p[3] = (pp[2] - pp[3]) * cos1_4;
- p[4] = pp[4] + pp[5];
- p[5] = (pp[4] - pp[5]) * cos1_4;
- p[6] = pp[6] + pp[7];
- p[7] = (pp[6] - pp[7]) * cos1_4;
- p[8] = pp[8] + pp[9];
- p[9] = (pp[8] - pp[9]) * cos1_4;
- p[10] = pp[10] + pp[11];
- p[11] = (pp[10] - pp[11]) * cos1_4;
- p[12] = pp[12] + pp[13];
- p[13] = (pp[12] - pp[13]) * cos1_4;
- p[14] = pp[14] + pp[15];
- p[15] = (pp[14] - pp[15]) * cos1_4;
-
-
- // manually doing something that a compiler should handle sucks
- // coding like this is hard to read
- float tmp2;
- new_v[5] = (new_v[11] = (new_v[13] = (new_v[15] = p[15]) + p[7]) + p[11])
- + p[5] + p[13];
- new_v[7] = (new_v[9] = p[15] + p[11] + p[3]) + p[13];
- new_v[33-17] = -(new_v[1] = (tmp1 = p[13] + p[15] + p[9]) + p[1]) - p[14];
- new_v[35-17] = -(new_v[3] = tmp1 + p[5] + p[7]) - p[6] - p[14];
-
- new_v[39-17] = (tmp1 = -p[10] - p[11] - p[14] - p[15])
- - p[13] - p[2] - p[3];
- new_v[37-17] = tmp1 - p[13] - p[5] - p[6] - p[7];
- new_v[41-17] = tmp1 - p[12] - p[2] - p[3];
- new_v[43-17] = tmp1 - p[12] - (tmp2 = p[4] + p[6] + p[7]);
- new_v[47-17] = (tmp1 = -p[8] - p[12] - p[14] - p[15]) - p[0];
- new_v[45-17] = tmp1 - tmp2;
-
- // insert V[0-15] (== new_v[0-15]) into actual v:
- x1 = new_v;
- // float[] x2 = actual_v + actual_write_pos;
- float[] dest = actual_v;
-
- dest[0 + actual_write_pos] = x1[0];
- dest[16 + actual_write_pos] = x1[1];
- dest[32 + actual_write_pos] = x1[2];
- dest[48 + actual_write_pos] = x1[3];
- dest[64 + actual_write_pos] = x1[4];
- dest[80 + actual_write_pos] = x1[5];
- dest[96 + actual_write_pos] = x1[6];
- dest[112 + actual_write_pos] = x1[7];
- dest[128 + actual_write_pos] = x1[8];
- dest[144 + actual_write_pos] = x1[9];
- dest[160 + actual_write_pos] = x1[10];
- dest[176 + actual_write_pos] = x1[11];
- dest[192 + actual_write_pos] = x1[12];
- dest[208 + actual_write_pos] = x1[13];
- dest[224 + actual_write_pos] = x1[14];
- dest[240 + actual_write_pos] = x1[15];
-
- // V[16] is always 0.0:
- dest[256 + actual_write_pos] = 0.0f;
-
- // insert V[17-31] (== -new_v[15-1]) into actual v:
- dest[272 + actual_write_pos] = -x1[15];
- dest[288 + actual_write_pos] = -x1[14];
- dest[304 + actual_write_pos] = -x1[13];
- dest[320 + actual_write_pos] = -x1[12];
- dest[336 + actual_write_pos] = -x1[11];
- dest[352 + actual_write_pos] = -x1[10];
- dest[368 + actual_write_pos] = -x1[9];
- dest[384 + actual_write_pos] = -x1[8];
- dest[400 + actual_write_pos] = -x1[7];
- dest[416 + actual_write_pos] = -x1[6];
- dest[432 + actual_write_pos] = -x1[5];
- dest[448 + actual_write_pos] = -x1[4];
- dest[464 + actual_write_pos] = -x1[3];
- dest[480 + actual_write_pos] = -x1[2];
- dest[496 + actual_write_pos] = -x1[1];
-
- // insert V[32] (== -new_v[0]) into other v:
-
- }
-
- /**
- * Compute PCM Samples.
- */
-
- private float[] _tmpOut = new float[32];
-
-
- private void compute_pcm_samples0(Obuffer buffer)
- {
- final float[] vp = actual_v;
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- float pcm_sample;
- final float[] dp = d16[i];
- pcm_sample = (float)(((vp[0 + dvp] * dp[0]) +
- (vp[15 + dvp] * dp[1]) +
- (vp[14 + dvp] * dp[2]) +
- (vp[13 + dvp] * dp[3]) +
- (vp[12 + dvp] * dp[4]) +
- (vp[11 + dvp] * dp[5]) +
- (vp[10 + dvp] * dp[6]) +
- (vp[9 + dvp] * dp[7]) +
- (vp[8 + dvp] * dp[8]) +
- (vp[7 + dvp] * dp[9]) +
- (vp[6 + dvp] * dp[10]) +
- (vp[5 + dvp] * dp[11]) +
- (vp[4 + dvp] * dp[12]) +
- (vp[3 + dvp] * dp[13]) +
- (vp[2 + dvp] * dp[14]) +
- (vp[1 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples1(Obuffer buffer)
- {
- final float[] vp = actual_v;
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[1 + dvp] * dp[0]) +
- (vp[0 + dvp] * dp[1]) +
- (vp[15 + dvp] * dp[2]) +
- (vp[14 + dvp] * dp[3]) +
- (vp[13 + dvp] * dp[4]) +
- (vp[12 + dvp] * dp[5]) +
- (vp[11 + dvp] * dp[6]) +
- (vp[10 + dvp] * dp[7]) +
- (vp[9 + dvp] * dp[8]) +
- (vp[8 + dvp] * dp[9]) +
- (vp[7 + dvp] * dp[10]) +
- (vp[6 + dvp] * dp[11]) +
- (vp[5 + dvp] * dp[12]) +
- (vp[4 + dvp] * dp[13]) +
- (vp[3 + dvp] * dp[14]) +
- (vp[2 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
- private void compute_pcm_samples2(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[2 + dvp] * dp[0]) +
- (vp[1 + dvp] * dp[1]) +
- (vp[0 + dvp] * dp[2]) +
- (vp[15 + dvp] * dp[3]) +
- (vp[14 + dvp] * dp[4]) +
- (vp[13 + dvp] * dp[5]) +
- (vp[12 + dvp] * dp[6]) +
- (vp[11 + dvp] * dp[7]) +
- (vp[10 + dvp] * dp[8]) +
- (vp[9 + dvp] * dp[9]) +
- (vp[8 + dvp] * dp[10]) +
- (vp[7 + dvp] * dp[11]) +
- (vp[6 + dvp] * dp[12]) +
- (vp[5 + dvp] * dp[13]) +
- (vp[4 + dvp] * dp[14]) +
- (vp[3 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples3(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- int idx = 0;
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[3 + dvp] * dp[0]) +
- (vp[2 + dvp] * dp[1]) +
- (vp[1 + dvp] * dp[2]) +
- (vp[0 + dvp] * dp[3]) +
- (vp[15 + dvp] * dp[4]) +
- (vp[14 + dvp] * dp[5]) +
- (vp[13 + dvp] * dp[6]) +
- (vp[12 + dvp] * dp[7]) +
- (vp[11 + dvp] * dp[8]) +
- (vp[10 + dvp] * dp[9]) +
- (vp[9 + dvp] * dp[10]) +
- (vp[8 + dvp] * dp[11]) +
- (vp[7 + dvp] * dp[12]) +
- (vp[6 + dvp] * dp[13]) +
- (vp[5 + dvp] * dp[14]) +
- (vp[4 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples4(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[4 + dvp] * dp[0]) +
- (vp[3 + dvp] * dp[1]) +
- (vp[2 + dvp] * dp[2]) +
- (vp[1 + dvp] * dp[3]) +
- (vp[0 + dvp] * dp[4]) +
- (vp[15 + dvp] * dp[5]) +
- (vp[14 + dvp] * dp[6]) +
- (vp[13 + dvp] * dp[7]) +
- (vp[12 + dvp] * dp[8]) +
- (vp[11 + dvp] * dp[9]) +
- (vp[10 + dvp] * dp[10]) +
- (vp[9 + dvp] * dp[11]) +
- (vp[8 + dvp] * dp[12]) +
- (vp[7 + dvp] * dp[13]) +
- (vp[6 + dvp] * dp[14]) +
- (vp[5 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples5(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[5 + dvp] * dp[0]) +
- (vp[4 + dvp] * dp[1]) +
- (vp[3 + dvp] * dp[2]) +
- (vp[2 + dvp] * dp[3]) +
- (vp[1 + dvp] * dp[4]) +
- (vp[0 + dvp] * dp[5]) +
- (vp[15 + dvp] * dp[6]) +
- (vp[14 + dvp] * dp[7]) +
- (vp[13 + dvp] * dp[8]) +
- (vp[12 + dvp] * dp[9]) +
- (vp[11 + dvp] * dp[10]) +
- (vp[10 + dvp] * dp[11]) +
- (vp[9 + dvp] * dp[12]) +
- (vp[8 + dvp] * dp[13]) +
- (vp[7 + dvp] * dp[14]) +
- (vp[6 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples6(Obuffer buffer)
- {
- final float[] vp = actual_v;
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[6 + dvp] * dp[0]) +
- (vp[5 + dvp] * dp[1]) +
- (vp[4 + dvp] * dp[2]) +
- (vp[3 + dvp] * dp[3]) +
- (vp[2 + dvp] * dp[4]) +
- (vp[1 + dvp] * dp[5]) +
- (vp[0 + dvp] * dp[6]) +
- (vp[15 + dvp] * dp[7]) +
- (vp[14 + dvp] * dp[8]) +
- (vp[13 + dvp] * dp[9]) +
- (vp[12 + dvp] * dp[10]) +
- (vp[11 + dvp] * dp[11]) +
- (vp[10 + dvp] * dp[12]) +
- (vp[9 + dvp] * dp[13]) +
- (vp[8 + dvp] * dp[14]) +
- (vp[7 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples7(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[7 + dvp] * dp[0]) +
- (vp[6 + dvp] * dp[1]) +
- (vp[5 + dvp] * dp[2]) +
- (vp[4 + dvp] * dp[3]) +
- (vp[3 + dvp] * dp[4]) +
- (vp[2 + dvp] * dp[5]) +
- (vp[1 + dvp] * dp[6]) +
- (vp[0 + dvp] * dp[7]) +
- (vp[15 + dvp] * dp[8]) +
- (vp[14 + dvp] * dp[9]) +
- (vp[13 + dvp] * dp[10]) +
- (vp[12 + dvp] * dp[11]) +
- (vp[11 + dvp] * dp[12]) +
- (vp[10 + dvp] * dp[13]) +
- (vp[9 + dvp] * dp[14]) +
- (vp[8 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
- private void compute_pcm_samples8(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[8 + dvp] * dp[0]) +
- (vp[7 + dvp] * dp[1]) +
- (vp[6 + dvp] * dp[2]) +
- (vp[5 + dvp] * dp[3]) +
- (vp[4 + dvp] * dp[4]) +
- (vp[3 + dvp] * dp[5]) +
- (vp[2 + dvp] * dp[6]) +
- (vp[1 + dvp] * dp[7]) +
- (vp[0 + dvp] * dp[8]) +
- (vp[15 + dvp] * dp[9]) +
- (vp[14 + dvp] * dp[10]) +
- (vp[13 + dvp] * dp[11]) +
- (vp[12 + dvp] * dp[12]) +
- (vp[11 + dvp] * dp[13]) +
- (vp[10 + dvp] * dp[14]) +
- (vp[9 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples9(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[9 + dvp] * dp[0]) +
- (vp[8 + dvp] * dp[1]) +
- (vp[7 + dvp] * dp[2]) +
- (vp[6 + dvp] * dp[3]) +
- (vp[5 + dvp] * dp[4]) +
- (vp[4 + dvp] * dp[5]) +
- (vp[3 + dvp] * dp[6]) +
- (vp[2 + dvp] * dp[7]) +
- (vp[1 + dvp] * dp[8]) +
- (vp[0 + dvp] * dp[9]) +
- (vp[15 + dvp] * dp[10]) +
- (vp[14 + dvp] * dp[11]) +
- (vp[13 + dvp] * dp[12]) +
- (vp[12 + dvp] * dp[13]) +
- (vp[11 + dvp] * dp[14]) +
- (vp[10 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
-
- private void compute_pcm_samples10(Obuffer buffer)
- {
- final float[] vp = actual_v;
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[10 + dvp] * dp[0]) +
- (vp[9 + dvp] * dp[1]) +
- (vp[8 + dvp] * dp[2]) +
- (vp[7 + dvp] * dp[3]) +
- (vp[6 + dvp] * dp[4]) +
- (vp[5 + dvp] * dp[5]) +
- (vp[4 + dvp] * dp[6]) +
- (vp[3 + dvp] * dp[7]) +
- (vp[2 + dvp] * dp[8]) +
- (vp[1 + dvp] * dp[9]) +
- (vp[0 + dvp] * dp[10]) +
- (vp[15 + dvp] * dp[11]) +
- (vp[14 + dvp] * dp[12]) +
- (vp[13 + dvp] * dp[13]) +
- (vp[12 + dvp] * dp[14]) +
- (vp[11 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
- private void compute_pcm_samples11(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[11 + dvp] * dp[0]) +
- (vp[10 + dvp] * dp[1]) +
- (vp[9 + dvp] * dp[2]) +
- (vp[8 + dvp] * dp[3]) +
- (vp[7 + dvp] * dp[4]) +
- (vp[6 + dvp] * dp[5]) +
- (vp[5 + dvp] * dp[6]) +
- (vp[4 + dvp] * dp[7]) +
- (vp[3 + dvp] * dp[8]) +
- (vp[2 + dvp] * dp[9]) +
- (vp[1 + dvp] * dp[10]) +
- (vp[0 + dvp] * dp[11]) +
- (vp[15 + dvp] * dp[12]) +
- (vp[14 + dvp] * dp[13]) +
- (vp[13 + dvp] * dp[14]) +
- (vp[12 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
- private void compute_pcm_samples12(Obuffer buffer)
- {
- final float[] vp = actual_v;
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[12 + dvp] * dp[0]) +
- (vp[11 + dvp] * dp[1]) +
- (vp[10 + dvp] * dp[2]) +
- (vp[9 + dvp] * dp[3]) +
- (vp[8 + dvp] * dp[4]) +
- (vp[7 + dvp] * dp[5]) +
- (vp[6 + dvp] * dp[6]) +
- (vp[5 + dvp] * dp[7]) +
- (vp[4 + dvp] * dp[8]) +
- (vp[3 + dvp] * dp[9]) +
- (vp[2 + dvp] * dp[10]) +
- (vp[1 + dvp] * dp[11]) +
- (vp[0 + dvp] * dp[12]) +
- (vp[15 + dvp] * dp[13]) +
- (vp[14 + dvp] * dp[14]) +
- (vp[13 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
- private void compute_pcm_samples13(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[13 + dvp] * dp[0]) +
- (vp[12 + dvp] * dp[1]) +
- (vp[11 + dvp] * dp[2]) +
- (vp[10 + dvp] * dp[3]) +
- (vp[9 + dvp] * dp[4]) +
- (vp[8 + dvp] * dp[5]) +
- (vp[7 + dvp] * dp[6]) +
- (vp[6 + dvp] * dp[7]) +
- (vp[5 + dvp] * dp[8]) +
- (vp[4 + dvp] * dp[9]) +
- (vp[3 + dvp] * dp[10]) +
- (vp[2 + dvp] * dp[11]) +
- (vp[1 + dvp] * dp[12]) +
- (vp[0 + dvp] * dp[13]) +
- (vp[15 + dvp] * dp[14]) +
- (vp[14 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
- private void compute_pcm_samples14(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- final float[] dp = d16[i];
- float pcm_sample;
-
- pcm_sample = (float)(((vp[14 + dvp] * dp[0]) +
- (vp[13 + dvp] * dp[1]) +
- (vp[12 + dvp] * dp[2]) +
- (vp[11 + dvp] * dp[3]) +
- (vp[10 + dvp] * dp[4]) +
- (vp[9 + dvp] * dp[5]) +
- (vp[8 + dvp] * dp[6]) +
- (vp[7 + dvp] * dp[7]) +
- (vp[6 + dvp] * dp[8]) +
- (vp[5 + dvp] * dp[9]) +
- (vp[4 + dvp] * dp[10]) +
- (vp[3 + dvp] * dp[11]) +
- (vp[2 + dvp] * dp[12]) +
- (vp[1 + dvp] * dp[13]) +
- (vp[0 + dvp] * dp[14]) +
- (vp[15 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
-
- dvp += 16;
- } // for
- }
- private void compute_pcm_samples15(Obuffer buffer)
- {
- final float[] vp = actual_v;
-
- //int inc = v_inc;
- final float[] tmpOut = _tmpOut;
- int dvp =0;
-
- // fat chance of having this loop unroll
- for( int i=0; i<32; i++)
- {
- float pcm_sample;
- final float dp[] = d16[i];
- pcm_sample = (float)(((vp[15 + dvp] * dp[0]) +
- (vp[14 + dvp] * dp[1]) +
- (vp[13 + dvp] * dp[2]) +
- (vp[12 + dvp] * dp[3]) +
- (vp[11 + dvp] * dp[4]) +
- (vp[10 + dvp] * dp[5]) +
- (vp[9 + dvp] * dp[6]) +
- (vp[8 + dvp] * dp[7]) +
- (vp[7 + dvp] * dp[8]) +
- (vp[6 + dvp] * dp[9]) +
- (vp[5 + dvp] * dp[10]) +
- (vp[4 + dvp] * dp[11]) +
- (vp[3 + dvp] * dp[12]) +
- (vp[2 + dvp] * dp[13]) +
- (vp[1 + dvp] * dp[14]) +
- (vp[0 + dvp] * dp[15])
- ) * scalefactor);
-
- tmpOut[i] = pcm_sample;
- dvp += 16;
- } // for
- }
-
-private void compute_pcm_samples(Obuffer buffer)
-{
-
- switch (actual_write_pos)
- {
- case 0:
- compute_pcm_samples0(buffer);
- break;
- case 1:
- compute_pcm_samples1(buffer);
- break;
- case 2:
- compute_pcm_samples2(buffer);
- break;
- case 3:
- compute_pcm_samples3(buffer);
- break;
- case 4:
- compute_pcm_samples4(buffer);
- break;
- case 5:
- compute_pcm_samples5(buffer);
- break;
- case 6:
- compute_pcm_samples6(buffer);
- break;
- case 7:
- compute_pcm_samples7(buffer);
- break;
- case 8:
- compute_pcm_samples8(buffer);
- break;
- case 9:
- compute_pcm_samples9(buffer);
- break;
- case 10:
- compute_pcm_samples10(buffer);
- break;
- case 11:
- compute_pcm_samples11(buffer);
- break;
- case 12:
- compute_pcm_samples12(buffer);
- break;
- case 13:
- compute_pcm_samples13(buffer);
- break;
- case 14:
- compute_pcm_samples14(buffer);
- break;
- case 15:
- compute_pcm_samples15(buffer);
- break;
- }
-
- if (buffer!=null)
- {
- buffer.appendSamples(channel, _tmpOut);
- }
-
-/*
- // MDM: I was considering putting in quality control for
- // low-spec CPUs, but the performance gain (about 10-15%)
- // did not justify the considerable drop in audio quality.
- switch (inc)
- {
- case 16:
- buffer.appendSamples(channel, tmpOut);
- break;
- case 32:
- for (int i=0; i<16; i++)
- {
- buffer.append(channel, (short)tmpOut[i]);
- buffer.append(channel, (short)tmpOut[i]);
- }
- break;
- case 64:
- for (int i=0; i<8; i++)
- {
- buffer.append(channel, (short)tmpOut[i]);
- buffer.append(channel, (short)tmpOut[i]);
- buffer.append(channel, (short)tmpOut[i]);
- buffer.append(channel, (short)tmpOut[i]);
- }
- break;
-
- }
-*/
- }
-
- /**
- * Calculate 32 PCM samples and put the into the Obuffer-object.
- */
-
- public void calculate_pcm_samples(Obuffer buffer)
- {
- compute_new_v();
- compute_pcm_samples(buffer);
-
- actual_write_pos = (actual_write_pos + 1) & 0xf;
- actual_v = (actual_v == v1) ? v2 : v1;
-
- // initialize samples[]:
- //for (register float *floatp = samples + 32; floatp > samples; )
- // *--floatp = 0.0f;
-
- // MDM: this may not be necessary. The Layer III decoder always
- // outputs 32 subband samples, but I haven't checked layer I & II.
- for (int p=0;p<32;p++)
- samples[p] = 0.0f;
- }
-
-
- private static final double MY_PI = 3.14159265358979323846;
- private static final float cos1_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI / 64.0)));
- private static final float cos3_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 64.0)));
- private static final float cos5_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 5.0 / 64.0)));
- private static final float cos7_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 7.0 / 64.0)));
- private static final float cos9_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 9.0 / 64.0)));
- private static final float cos11_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 11.0 / 64.0)));
- private static final float cos13_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 13.0 / 64.0)));
- private static final float cos15_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 15.0 / 64.0)));
- private static final float cos17_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 17.0 / 64.0)));
- private static final float cos19_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 19.0 / 64.0)));
- private static final float cos21_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 21.0 / 64.0)));
- private static final float cos23_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 23.0 / 64.0)));
- private static final float cos25_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 25.0 / 64.0)));
- private static final float cos27_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 27.0 / 64.0)));
- private static final float cos29_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 29.0 / 64.0)));
- private static final float cos31_64 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 31.0 / 64.0)));
- private static final float cos1_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI / 32.0)));
- private static final float cos3_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 32.0)));
- private static final float cos5_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 5.0 / 32.0)));
- private static final float cos7_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 7.0 / 32.0)));
- private static final float cos9_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 9.0 / 32.0)));
- private static final float cos11_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 11.0 / 32.0)));
- private static final float cos13_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 13.0 / 32.0)));
- private static final float cos15_32 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 15.0 / 32.0)));
- private static final float cos1_16 =(float) (1.0 / (2.0 * Math.cos(MY_PI / 16.0)));
- private static final float cos3_16 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 16.0)));
- private static final float cos5_16 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 5.0 / 16.0)));
- private static final float cos7_16 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 7.0 / 16.0)));
- private static final float cos1_8 =(float) (1.0 / (2.0 * Math.cos(MY_PI / 8.0)));
- private static final float cos3_8 =(float) (1.0 / (2.0 * Math.cos(MY_PI * 3.0 / 8.0)));
- private static final float cos1_4 =(float) (1.0 / (2.0 * Math.cos(MY_PI / 4.0)));
-
- // Note: These values are not in the same order
- // as in Annex 3-B.3 of the ISO/IEC DIS 11172-3
- // private float d[] = {0.000000000, -4.000442505};
-
- private static float d[] = null;
-
- /**
- * d[] split into subarrays of length 16. This provides for
- * more faster access by allowing a block of 16 to be addressed
- * with constant offset.
- **/
- private static float d16[][] = null;
-
- /**
- * Loads the data for the d[] from the resource SFd.ser.
- * @return the loaded values for d[].
- */
- static private float[] load_d()
- {
- try
- {
- Class elemType = Float.TYPE;
- Object o = JavaLayerUtils.deserializeArrayResource("sfd.ser", elemType, 512);
- return (float[])o;
- }
- catch (IOException ex)
- {
- throw new ExceptionInInitializerError(ex);
- }
- }
-
- /**
- * Converts a 1D array into a number of smaller arrays. This is used
- * to achieve offset + constant indexing into an array. Each sub-array
- * represents a block of values of the original array.
- * @param array The array to split up into blocks.
- * @param blockSize The size of the blocks to split the array
- * into. This must be an exact divisor of
- * the length of the array, or some data
- * will be lost from the main array.
- *
- * @return An array of arrays in which each element in the returned
- * array will be of length <code>blockSize</code>.
- */
- static private float[][] splitArray(final float[] array, final int blockSize)
- {
- int size = array.length / blockSize;
- float[][] split = new float[size][];
- for (int i=0; i<size; i++)
- {
- split[i] = subArray(array, i*blockSize, blockSize);
- }
- return split;
- }
-
- /**
- * Returns a subarray of an existing array.
- *
- * @param array The array to retrieve a subarra from.
- * @param offs The offset in the array that corresponds to
- * the first index of the subarray.
- * @param len The number of indeces in the subarray.
- * @return The subarray, which may be of length 0.
- */
- static private float[] subArray(final float[] array, final int offs, int len)
- {
- if (offs+len > array.length)
- {
- len = array.length-offs;
- }
-
- if (len < 0)
- len = 0;
-
- float[] subarray = new float[len];
- for (int i=0; i<len; i++)
- {
- subarray[i] = array[offs+i];
- }
-
- return subarray;
- }
-
- // The original data for d[]. This data is loaded from a file
- // to reduce the overall package size and to improve performance.
-/*
- static final float d_data[] = {
- 0.000000000f, -0.000442505f, 0.003250122f, -0.007003784f,
- 0.031082153f, -0.078628540f, 0.100311279f, -0.572036743f,
- 1.144989014f, 0.572036743f, 0.100311279f, 0.078628540f,
- 0.031082153f, 0.007003784f, 0.003250122f, 0.000442505f,
- -0.000015259f, -0.000473022f, 0.003326416f, -0.007919312f,
- 0.030517578f, -0.084182739f, 0.090927124f, -0.600219727f,
- 1.144287109f, 0.543823242f, 0.108856201f, 0.073059082f,
- 0.031478882f, 0.006118774f, 0.003173828f, 0.000396729f,
- -0.000015259f, -0.000534058f, 0.003387451f, -0.008865356f,
- 0.029785156f, -0.089706421f, 0.080688477f, -0.628295898f,
- 1.142211914f, 0.515609741f, 0.116577148f, 0.067520142f,
- 0.031738281f, 0.005294800f, 0.003082275f, 0.000366211f,
- -0.000015259f, -0.000579834f, 0.003433228f, -0.009841919f,
- 0.028884888f, -0.095169067f, 0.069595337f, -0.656219482f,
- 1.138763428f, 0.487472534f, 0.123474121f, 0.061996460f,
- 0.031845093f, 0.004486084f, 0.002990723f, 0.000320435f,
- -0.000015259f, -0.000625610f, 0.003463745f, -0.010848999f,
- 0.027801514f, -0.100540161f, 0.057617188f, -0.683914185f,
- 1.133926392f, 0.459472656f, 0.129577637f, 0.056533813f,
- 0.031814575f, 0.003723145f, 0.002899170f, 0.000289917f,
- -0.000015259f, -0.000686646f, 0.003479004f, -0.011886597f,
- 0.026535034f, -0.105819702f, 0.044784546f, -0.711318970f,
- 1.127746582f, 0.431655884f, 0.134887695f, 0.051132202f,
- 0.031661987f, 0.003005981f, 0.002792358f, 0.000259399f,
- -0.000015259f, -0.000747681f, 0.003479004f, -0.012939453f,
- 0.025085449f, -0.110946655f, 0.031082153f, -0.738372803f,
- 1.120223999f, 0.404083252f, 0.139450073f, 0.045837402f,
- 0.031387329f, 0.002334595f, 0.002685547f, 0.000244141f,
- -0.000030518f, -0.000808716f, 0.003463745f, -0.014022827f,
- 0.023422241f, -0.115921021f, 0.016510010f, -0.765029907f,
- 1.111373901f, 0.376800537f, 0.143264771f, 0.040634155f,
- 0.031005859f, 0.001693726f, 0.002578735f, 0.000213623f,
- -0.000030518f, -0.000885010f, 0.003417969f, -0.015121460f,
- 0.021575928f, -0.120697021f, 0.001068115f, -0.791213989f,
- 1.101211548f, 0.349868774f, 0.146362305f, 0.035552979f,
- 0.030532837f, 0.001098633f, 0.002456665f, 0.000198364f,
- -0.000030518f, -0.000961304f, 0.003372192f, -0.016235352f,
- 0.019531250f, -0.125259399f, -0.015228271f, -0.816864014f,
- 1.089782715f, 0.323318481f, 0.148773193f, 0.030609131f,
- 0.029937744f, 0.000549316f, 0.002349854f, 0.000167847f,
- -0.000030518f, -0.001037598f, 0.003280640f, -0.017349243f,
- 0.017257690f, -0.129562378f, -0.032379150f, -0.841949463f,
- 1.077117920f, 0.297210693f, 0.150497437f, 0.025817871f,
- 0.029281616f, 0.000030518f, 0.002243042f, 0.000152588f,
- -0.000045776f, -0.001113892f, 0.003173828f, -0.018463135f,
- 0.014801025f, -0.133590698f, -0.050354004f, -0.866363525f,
- 1.063217163f, 0.271591187f, 0.151596069f, 0.021179199f,
- 0.028533936f, -0.000442505f, 0.002120972f, 0.000137329f,
- -0.000045776f, -0.001205444f, 0.003051758f, -0.019577026f,
- 0.012115479f, -0.137298584f, -0.069168091f, -0.890090942f,
- 1.048156738f, 0.246505737f, 0.152069092f, 0.016708374f,
- 0.027725220f, -0.000869751f, 0.002014160f, 0.000122070f,
- -0.000061035f, -0.001296997f, 0.002883911f, -0.020690918f,
- 0.009231567f, -0.140670776f, -0.088775635f, -0.913055420f,
- 1.031936646f, 0.221984863f, 0.151962280f, 0.012420654f,
- 0.026840210f, -0.001266479f, 0.001907349f, 0.000106812f,
- -0.000061035f, -0.001388550f, 0.002700806f, -0.021789551f,
- 0.006134033f, -0.143676758f, -0.109161377f, -0.935195923f,
- 1.014617920f, 0.198059082f, 0.151306152f, 0.008316040f,
- 0.025909424f, -0.001617432f, 0.001785278f, 0.000106812f,
- -0.000076294f, -0.001480103f, 0.002487183f, -0.022857666f,
- 0.002822876f, -0.146255493f, -0.130310059f, -0.956481934f,
- 0.996246338f, 0.174789429f, 0.150115967f, 0.004394531f,
- 0.024932861f, -0.001937866f, 0.001693726f, 0.000091553f,
- -0.000076294f, -0.001586914f, 0.002227783f, -0.023910522f,
- -0.000686646f, -0.148422241f, -0.152206421f, -0.976852417f,
- 0.976852417f, 0.152206421f, 0.148422241f, 0.000686646f,
- 0.023910522f, -0.002227783f, 0.001586914f, 0.000076294f,
- -0.000091553f, -0.001693726f, 0.001937866f, -0.024932861f,
- -0.004394531f, -0.150115967f, -0.174789429f, -0.996246338f,
- 0.956481934f, 0.130310059f, 0.146255493f, -0.002822876f,
- 0.022857666f, -0.002487183f, 0.001480103f, 0.000076294f,
- -0.000106812f, -0.001785278f, 0.001617432f, -0.025909424f,
- -0.008316040f, -0.151306152f, -0.198059082f, -1.014617920f,
- 0.935195923f, 0.109161377f, 0.143676758f, -0.006134033f,
- 0.021789551f, -0.002700806f, 0.001388550f, 0.000061035f,
- -0.000106812f, -0.001907349f, 0.001266479f, -0.026840210f,
- -0.012420654f, -0.151962280f, -0.221984863f, -1.031936646f,
- 0.913055420f, 0.088775635f, 0.140670776f, -0.009231567f,
- 0.020690918f, -0.002883911f, 0.001296997f, 0.000061035f,
- -0.000122070f, -0.002014160f, 0.000869751f, -0.027725220f,
- -0.016708374f, -0.152069092f, -0.246505737f, -1.048156738f,
- 0.890090942f, 0.069168091f, 0.137298584f, -0.012115479f,
- 0.019577026f, -0.003051758f, 0.001205444f, 0.000045776f,
- -0.000137329f, -0.002120972f, 0.000442505f, -0.028533936f,
- -0.021179199f, -0.151596069f, -0.271591187f, -1.063217163f,
- 0.866363525f, 0.050354004f, 0.133590698f, -0.014801025f,
- 0.018463135f, -0.003173828f, 0.001113892f, 0.000045776f,
- -0.000152588f, -0.002243042f, -0.000030518f, -0.029281616f,
- -0.025817871f, -0.150497437f, -0.297210693f, -1.077117920f,
- 0.841949463f, 0.032379150f, 0.129562378f, -0.017257690f,
- 0.017349243f, -0.003280640f, 0.001037598f, 0.000030518f,
- -0.000167847f, -0.002349854f, -0.000549316f, -0.029937744f,
- -0.030609131f, -0.148773193f, -0.323318481f, -1.089782715f,
- 0.816864014f, 0.015228271f, 0.125259399f, -0.019531250f,
- 0.016235352f, -0.003372192f, 0.000961304f, 0.000030518f,
- -0.000198364f, -0.002456665f, -0.001098633f, -0.030532837f,
- -0.035552979f, -0.146362305f, -0.349868774f, -1.101211548f,
- 0.791213989f, -0.001068115f, 0.120697021f, -0.021575928f,
- 0.015121460f, -0.003417969f, 0.000885010f, 0.000030518f,
- -0.000213623f, -0.002578735f, -0.001693726f, -0.031005859f,
- -0.040634155f, -0.143264771f, -0.376800537f, -1.111373901f,
- 0.765029907f, -0.016510010f, 0.115921021f, -0.023422241f,
- 0.014022827f, -0.003463745f, 0.000808716f, 0.000030518f,
- -0.000244141f, -0.002685547f, -0.002334595f, -0.031387329f,
- -0.045837402f, -0.139450073f, -0.404083252f, -1.120223999f,
- 0.738372803f, -0.031082153f, 0.110946655f, -0.025085449f,
- 0.012939453f, -0.003479004f, 0.000747681f, 0.000015259f,
- -0.000259399f, -0.002792358f, -0.003005981f, -0.031661987f,
- -0.051132202f, -0.134887695f, -0.431655884f, -1.127746582f,
- 0.711318970f, -0.044784546f, 0.105819702f, -0.026535034f,
- 0.011886597f, -0.003479004f, 0.000686646f, 0.000015259f,
- -0.000289917f, -0.002899170f, -0.003723145f, -0.031814575f,
- -0.056533813f, -0.129577637f, -0.459472656f, -1.133926392f,
- 0.683914185f, -0.057617188f, 0.100540161f, -0.027801514f,
- 0.010848999f, -0.003463745f, 0.000625610f, 0.000015259f,
- -0.000320435f, -0.002990723f, -0.004486084f, -0.031845093f,
- -0.061996460f, -0.123474121f, -0.487472534f, -1.138763428f,
- 0.656219482f, -0.069595337f, 0.095169067f, -0.028884888f,
- 0.009841919f, -0.003433228f, 0.000579834f, 0.000015259f,
- -0.000366211f, -0.003082275f, -0.005294800f, -0.031738281f,
- -0.067520142f, -0.116577148f, -0.515609741f, -1.142211914f,
- 0.628295898f, -0.080688477f, 0.089706421f, -0.029785156f,
- 0.008865356f, -0.003387451f, 0.000534058f, 0.000015259f,
- -0.000396729f, -0.003173828f, -0.006118774f, -0.031478882f,
- -0.073059082f, -0.108856201f, -0.543823242f, -1.144287109f,
- 0.600219727f, -0.090927124f, 0.084182739f, -0.030517578f,
- 0.007919312f, -0.003326416f, 0.000473022f, 0.000015259f
- };
- */
-
-}
diff --git a/songdbj/javazoom/jl/decoder/au2lin.ser b/songdbj/javazoom/jl/decoder/au2lin.ser
deleted file mode 100644
index de0d1f62d9..0000000000
--- a/songdbj/javazoom/jl/decoder/au2lin.ser
+++ /dev/null
Binary files differ
diff --git a/songdbj/javazoom/jl/decoder/huffcodetab.java b/songdbj/javazoom/jl/decoder/huffcodetab.java
deleted file mode 100644
index 86975646f0..0000000000
--- a/songdbj/javazoom/jl/decoder/huffcodetab.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 16/11/99 Renamed class, added javadoc, and changed table
- * name from String to 3 chars. mdm@techie.com
- * 02/15/99 Java Conversion by E.B, javalayer@javazoom.net
- *
- * 04/19/97 : Adapted from the ISO MPEG Audio Subgroup Software Simulation
- * Group's public c source for its MPEG audio decoder. Miscellaneous
- * changes by Jeff Tsay (ctsay@pasteur.eecs.berkeley.edu).
- *-----------------------------------------------------------------------
- * Copyright (c) 1991 MPEG/audio software simulation group, All Rights Reserved
- * MPEG/audio coding/decoding software, work in progress
- * NOT for public distribution until verified and approved by the
- * MPEG/audio committee. For further information, please contact
- * Davis Pan, 508-493-2241, e-mail: pan@3d.enet.dec.com
- *
- * VERSION 4.1
- * changes made since last update:
- * date programmers comment
- * 27.2.92 F.O.Witte (ITT Intermetall)
- * 8/24/93 M. Iwadare Changed for 1 pass decoding.
- * 7/14/94 J. Koller useless 'typedef' before huffcodetab removed
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.decoder;
-
-/**
- * Class to implements Huffman decoder.
- */
-final class huffcodetab
-{
- private static final int MXOFF=250;
- private static final int HTN=34;
-
- private char tablename0 = ' '; /* string, containing table_description */
- private char tablename1 = ' '; /* string, containing table_description */
- private char tablename2 = ' '; /* string, containing table_description */
-
- private int xlen; /* max. x-index+ */
- private int ylen; /* max. y-index+ */
- private int linbits; /* number of linbits */
- private int linmax; /* max number to be stored in linbits */
- private int ref; /* a positive value indicates a reference */
- private int[] table=null; /* pointer to array[xlen][ylen] */
- private int[] hlen=null; /* pointer to array[xlen][ylen] */
- private int[][] val=null; /* decoder tree */
- private int treelen; /* length of decoder tree */
-
- private static int ValTab0[][] = {
- {0,0} // dummy
- };
-
- private static int ValTab1[][] = {
- {2,1},{0,0},{2,1},{0,16},{2,1},{0,1},{0,17},
- };
-
- private static int ValTab2[][] = {
- {2,1},{0,0},{4,1},{2,1},{0,16},{0,1},{2,1},{0,17},{4,1},{2,1},
- {0,32},{0,33},{2,1},{0,18},{2,1},{0,2},{0,34},
- };
-
- private static int ValTab3[][] = {
- {4,1},{2,1},{0,0},{0,1},{2,1},{0,17},{2,1},{0,16},{4,1},{2,1},
- {0,32},{0,33},{2,1},{0,18},{2,1},{0,2},{0,34},
- };
-
- private static int ValTab4[][] = {{0,0}}; // dummy
-
- private static int ValTab5[][] = {
- {2,1},{0,0},{4,1},{2,1},{0,16},{0,1},{2,1},{0,17},{8,1},{4,1},
- {2,1},{0,32},{0,2},{2,1},{0,33},{0,18},{8,1},{4,1},{2,1},{0,34},
- {0,48},{2,1},{0,3},{0,19},{2,1},{0,49},{2,1},{0,50},{2,1},{0,35},
- {0,51},
- };
-
- private static int ValTab6[][] = {
- {6,1},{4,1},{2,1},{0,0},{0,16},{0,17},{6,1},{2,1},{0,1},{2,1},
- {0,32},{0,33},{6,1},{2,1},{0,18},{2,1},{0,2},{0,34},{4,1},{2,1},
- {0,49},{0,19},{4,1},{2,1},{0,48},{0,50},{2,1},{0,35},{2,1},{0,3},
- {0,51},
- };
-
- private static int ValTab7[][] = {
- {2,1},{0,0},{4,1},{2,1},{0,16},{0,1},{8,1},{2,1},{0,17},{4,1},
- {2,1},{0,32},{0,2},{0,33},{18,1},{6,1},{2,1},{0,18},{2,1},{0,34},
- {0,48},{4,1},{2,1},{0,49},{0,19},{4,1},{2,1},{0,3},{0,50},{2,1},
- {0,35},{0,4},{10,1},{4,1},{2,1},{0,64},{0,65},{2,1},{0,20},{2,1},
- {0,66},{0,36},{12,1},{6,1},{4,1},{2,1},{0,51},{0,67},{0,80},{4,1},
- {2,1},{0,52},{0,5},{0,81},{6,1},{2,1},{0,21},{2,1},{0,82},{0,37},
- {4,1},{2,1},{0,68},{0,53},{4,1},{2,1},{0,83},{0,84},{2,1},{0,69},
- {0,85},
- };
-
- private static int ValTab8[][] = {
- {6,1},{2,1},{0,0},{2,1},{0,16},{0,1},{2,1},{0,17},{4,1},{2,1},
- {0,33},{0,18},{14,1},{4,1},{2,1},{0,32},{0,2},{2,1},{0,34},{4,1},
- {2,1},{0,48},{0,3},{2,1},{0,49},{0,19},{14,1},{8,1},{4,1},{2,1},
- {0,50},{0,35},{2,1},{0,64},{0,4},{2,1},{0,65},{2,1},{0,20},{0,66},
- {12,1},{6,1},{2,1},{0,36},{2,1},{0,51},{0,80},{4,1},{2,1},{0,67},
- {0,52},{0,81},{6,1},{2,1},{0,21},{2,1},{0,5},{0,82},{6,1},{2,1},
- {0,37},{2,1},{0,68},{0,53},{2,1},{0,83},{2,1},{0,69},{2,1},{0,84},
- {0,85},
- };
-
- private static int ValTab9[][] = {
- {8,1},{4,1},{2,1},{0,0},{0,16},{2,1},{0,1},{0,17},{10,1},{4,1},
- {2,1},{0,32},{0,33},{2,1},{0,18},{2,1},{0,2},{0,34},{12,1},{6,1},
- {4,1},{2,1},{0,48},{0,3},{0,49},{2,1},{0,19},{2,1},{0,50},{0,35},
- {12,1},{4,1},{2,1},{0,65},{0,20},{4,1},{2,1},{0,64},{0,51},{2,1},
- {0,66},{0,36},{10,1},{6,1},{4,1},{2,1},{0,4},{0,80},{0,67},{2,1},
- {0,52},{0,81},{8,1},{4,1},{2,1},{0,21},{0,82},{2,1},{0,37},{0,68},
- {6,1},{4,1},{2,1},{0,5},{0,84},{0,83},{2,1},{0,53},{2,1},{0,69},
- {0,85},
- };
-
- private static int ValTab10[][] = {
- {2,1},{0,0},{4,1},{2,1},{0,16},{0,1},{10,1},{2,1},{0,17},{4,1},
- {2,1},{0,32},{0,2},{2,1},{0,33},{0,18},{28,1},{8,1},{4,1},{2,1},
- {0,34},{0,48},{2,1},{0,49},{0,19},{8,1},{4,1},{2,1},{0,3},{0,50},
- {2,1},{0,35},{0,64},{4,1},{2,1},{0,65},{0,20},{4,1},{2,1},{0,4},
- {0,51},{2,1},{0,66},{0,36},{28,1},{10,1},{6,1},{4,1},{2,1},{0,80},
- {0,5},{0,96},{2,1},{0,97},{0,22},{12,1},{6,1},{4,1},{2,1},{0,67},
- {0,52},{0,81},{2,1},{0,21},{2,1},{0,82},{0,37},{4,1},{2,1},{0,38},
- {0,54},{0,113},{20,1},{8,1},{2,1},{0,23},{4,1},{2,1},{0,68},{0,83},
- {0,6},{6,1},{4,1},{2,1},{0,53},{0,69},{0,98},{2,1},{0,112},{2,1},
- {0,7},{0,100},{14,1},{4,1},{2,1},{0,114},{0,39},{6,1},{2,1},{0,99},
- {2,1},{0,84},{0,85},{2,1},{0,70},{0,115},{8,1},{4,1},{2,1},{0,55},
- {0,101},{2,1},{0,86},{0,116},{6,1},{2,1},{0,71},{2,1},{0,102},{0,117},
- {4,1},{2,1},{0,87},{0,118},{2,1},{0,103},{0,119},
- };
-
- private static int ValTab11[][] = {
- {6,1},{2,1},{0,0},{2,1},{0,16},{0,1},{8,1},{2,1},{0,17},{4,1},
- {2,1},{0,32},{0,2},{0,18},{24,1},{8,1},{2,1},{0,33},{2,1},{0,34},
- {2,1},{0,48},{0,3},{4,1},{2,1},{0,49},{0,19},{4,1},{2,1},{0,50},
- {0,35},{4,1},{2,1},{0,64},{0,4},{2,1},{0,65},{0,20},{30,1},{16,1},
- {10,1},{4,1},{2,1},{0,66},{0,36},{4,1},{2,1},{0,51},{0,67},{0,80},
- {4,1},{2,1},{0,52},{0,81},{0,97},{6,1},{2,1},{0,22},{2,1},{0,6},
- {0,38},{2,1},{0,98},{2,1},{0,21},{2,1},{0,5},{0,82},{16,1},{10,1},
- {6,1},{4,1},{2,1},{0,37},{0,68},{0,96},{2,1},{0,99},{0,54},{4,1},
- {2,1},{0,112},{0,23},{0,113},{16,1},{6,1},{4,1},{2,1},{0,7},{0,100},
- {0,114},{2,1},{0,39},{4,1},{2,1},{0,83},{0,53},{2,1},{0,84},{0,69},
- {10,1},{4,1},{2,1},{0,70},{0,115},{2,1},{0,55},{2,1},{0,101},{0,86},
- {10,1},{6,1},{4,1},{2,1},{0,85},{0,87},{0,116},{2,1},{0,71},{0,102},
- {4,1},{2,1},{0,117},{0,118},{2,1},{0,103},{0,119},
- };
-
- private static int ValTab12[][] = {
- {12,1},{4,1},{2,1},{0,16},{0,1},{2,1},{0,17},{2,1},{0,0},{2,1},
- {0,32},{0,2},{16,1},{4,1},{2,1},{0,33},{0,18},{4,1},{2,1},{0,34},
- {0,49},{2,1},{0,19},{2,1},{0,48},{2,1},{0,3},{0,64},{26,1},{8,1},
- {4,1},{2,1},{0,50},{0,35},{2,1},{0,65},{0,51},{10,1},{4,1},{2,1},
- {0,20},{0,66},{2,1},{0,36},{2,1},{0,4},{0,80},{4,1},{2,1},{0,67},
- {0,52},{2,1},{0,81},{0,21},{28,1},{14,1},{8,1},{4,1},{2,1},{0,82},
- {0,37},{2,1},{0,83},{0,53},{4,1},{2,1},{0,96},{0,22},{0,97},{4,1},
- {2,1},{0,98},{0,38},{6,1},{4,1},{2,1},{0,5},{0,6},{0,68},{2,1},
- {0,84},{0,69},{18,1},{10,1},{4,1},{2,1},{0,99},{0,54},{4,1},{2,1},
- {0,112},{0,7},{0,113},{4,1},{2,1},{0,23},{0,100},{2,1},{0,70},{0,114},
- {10,1},{6,1},{2,1},{0,39},{2,1},{0,85},{0,115},{2,1},{0,55},{0,86},
- {8,1},{4,1},{2,1},{0,101},{0,116},{2,1},{0,71},{0,102},{4,1},{2,1},
- {0,117},{0,87},{2,1},{0,118},{2,1},{0,103},{0,119},
- };
-
- private static int ValTab13[][] = {
- {2,1},{0,0},{6,1},{2,1},{0,16},{2,1},{0,1},{0,17},{28,1},{8,1},
- {4,1},{2,1},{0,32},{0,2},{2,1},{0,33},{0,18},{8,1},{4,1},{2,1},
- {0,34},{0,48},{2,1},{0,3},{0,49},{6,1},{2,1},{0,19},{2,1},{0,50},
- {0,35},{4,1},{2,1},{0,64},{0,4},{0,65},{70,1},{28,1},{14,1},{6,1},
- {2,1},{0,20},{2,1},{0,51},{0,66},{4,1},{2,1},{0,36},{0,80},{2,1},
- {0,67},{0,52},{4,1},{2,1},{0,81},{0,21},{4,1},{2,1},{0,5},{0,82},
- {2,1},{0,37},{2,1},{0,68},{0,83},{14,1},{8,1},{4,1},{2,1},{0,96},
- {0,6},{2,1},{0,97},{0,22},{4,1},{2,1},{0,128},{0,8},{0,129},{16,1},
- {8,1},{4,1},{2,1},{0,53},{0,98},{2,1},{0,38},{0,84},{4,1},{2,1},
- {0,69},{0,99},{2,1},{0,54},{0,112},{6,1},{4,1},{2,1},{0,7},{0,85},
- {0,113},{2,1},{0,23},{2,1},{0,39},{0,55},{72,1},{24,1},{12,1},{4,1},
- {2,1},{0,24},{0,130},{2,1},{0,40},{4,1},{2,1},{0,100},{0,70},{0,114},
- {8,1},{4,1},{2,1},{0,132},{0,72},{2,1},{0,144},{0,9},{2,1},{0,145},
- {0,25},{24,1},{14,1},{8,1},{4,1},{2,1},{0,115},{0,101},{2,1},{0,86},
- {0,116},{4,1},{2,1},{0,71},{0,102},{0,131},{6,1},{2,1},{0,56},{2,1},
- {0,117},{0,87},{2,1},{0,146},{0,41},{14,1},{8,1},{4,1},{2,1},{0,103},
- {0,133},{2,1},{0,88},{0,57},{2,1},{0,147},{2,1},{0,73},{0,134},{6,1},
- {2,1},{0,160},{2,1},{0,104},{0,10},{2,1},{0,161},{0,26},{68,1},{24,1},
- {12,1},{4,1},{2,1},{0,162},{0,42},{4,1},{2,1},{0,149},{0,89},{2,1},
- {0,163},{0,58},{8,1},{4,1},{2,1},{0,74},{0,150},{2,1},{0,176},{0,11},
- {2,1},{0,177},{0,27},{20,1},{8,1},{2,1},{0,178},{4,1},{2,1},{0,118},
- {0,119},{0,148},{6,1},{4,1},{2,1},{0,135},{0,120},{0,164},{4,1},{2,1},
- {0,105},{0,165},{0,43},{12,1},{6,1},{4,1},{2,1},{0,90},{0,136},{0,179},
- {2,1},{0,59},{2,1},{0,121},{0,166},{6,1},{4,1},{2,1},{0,106},{0,180},
- {0,192},{4,1},{2,1},{0,12},{0,152},{0,193},{60,1},{22,1},{10,1},{6,1},
- {2,1},{0,28},{2,1},{0,137},{0,181},{2,1},{0,91},{0,194},{4,1},{2,1},
- {0,44},{0,60},{4,1},{2,1},{0,182},{0,107},{2,1},{0,196},{0,76},{16,1},
- {8,1},{4,1},{2,1},{0,168},{0,138},{2,1},{0,208},{0,13},{2,1},{0,209},
- {2,1},{0,75},{2,1},{0,151},{0,167},{12,1},{6,1},{2,1},{0,195},{2,1},
- {0,122},{0,153},{4,1},{2,1},{0,197},{0,92},{0,183},{4,1},{2,1},{0,29},
- {0,210},{2,1},{0,45},{2,1},{0,123},{0,211},{52,1},{28,1},{12,1},{4,1},
- {2,1},{0,61},{0,198},{4,1},{2,1},{0,108},{0,169},{2,1},{0,154},{0,212},
- {8,1},{4,1},{2,1},{0,184},{0,139},{2,1},{0,77},{0,199},{4,1},{2,1},
- {0,124},{0,213},{2,1},{0,93},{0,224},{10,1},{4,1},{2,1},{0,225},{0,30},
- {4,1},{2,1},{0,14},{0,46},{0,226},{8,1},{4,1},{2,1},{0,227},{0,109},
- {2,1},{0,140},{0,228},{4,1},{2,1},{0,229},{0,186},{0,240},{38,1},{16,1},
- {4,1},{2,1},{0,241},{0,31},{6,1},{4,1},{2,1},{0,170},{0,155},{0,185},
- {2,1},{0,62},{2,1},{0,214},{0,200},{12,1},{6,1},{2,1},{0,78},{2,1},
- {0,215},{0,125},{2,1},{0,171},{2,1},{0,94},{0,201},{6,1},{2,1},{0,15},
- {2,1},{0,156},{0,110},{2,1},{0,242},{0,47},{32,1},{16,1},{6,1},{4,1},
- {2,1},{0,216},{0,141},{0,63},{6,1},{2,1},{0,243},{2,1},{0,230},{0,202},
- {2,1},{0,244},{0,79},{8,1},{4,1},{2,1},{0,187},{0,172},{2,1},{0,231},
- {0,245},{4,1},{2,1},{0,217},{0,157},{2,1},{0,95},{0,232},{30,1},{12,1},
- {6,1},{2,1},{0,111},{2,1},{0,246},{0,203},{4,1},{2,1},{0,188},{0,173},
- {0,218},{8,1},{2,1},{0,247},{4,1},{2,1},{0,126},{0,127},{0,142},{6,1},
- {4,1},{2,1},{0,158},{0,174},{0,204},{2,1},{0,248},{0,143},{18,1},{8,1},
- {4,1},{2,1},{0,219},{0,189},{2,1},{0,234},{0,249},{4,1},{2,1},{0,159},
- {0,235},{2,1},{0,190},{2,1},{0,205},{0,250},{14,1},{4,1},{2,1},{0,221},
- {0,236},{6,1},{4,1},{2,1},{0,233},{0,175},{0,220},{2,1},{0,206},{0,251},
- {8,1},{4,1},{2,1},{0,191},{0,222},{2,1},{0,207},{0,238},{4,1},{2,1},
- {0,223},{0,239},{2,1},{0,255},{2,1},{0,237},{2,1},{0,253},{2,1},{0,252},
- {0,254},
- };
-
- private static int ValTab14[][] = {
- {0,0} // dummy
- };
-
- private static int ValTab15[][] = {
- {16,1},{6,1},{2,1},{0,0},{2,1},{0,16},{0,1},{2,1},{0,17},{4,1},
- {2,1},{0,32},{0,2},{2,1},{0,33},{0,18},{50,1},{16,1},{6,1},{2,1},
- {0,34},{2,1},{0,48},{0,49},{6,1},{2,1},{0,19},{2,1},{0,3},{0,64},
- {2,1},{0,50},{0,35},{14,1},{6,1},{4,1},{2,1},{0,4},{0,20},{0,65},
- {4,1},{2,1},{0,51},{0,66},{2,1},{0,36},{0,67},{10,1},{6,1},{2,1},
- {0,52},{2,1},{0,80},{0,5},{2,1},{0,81},{0,21},{4,1},{2,1},{0,82},
- {0,37},{4,1},{2,1},{0,68},{0,83},{0,97},{90,1},{36,1},{18,1},{10,1},
- {6,1},{2,1},{0,53},{2,1},{0,96},{0,6},{2,1},{0,22},{0,98},{4,1},
- {2,1},{0,38},{0,84},{2,1},{0,69},{0,99},{10,1},{6,1},{2,1},{0,54},
- {2,1},{0,112},{0,7},{2,1},{0,113},{0,85},{4,1},{2,1},{0,23},{0,100},
- {2,1},{0,114},{0,39},{24,1},{16,1},{8,1},{4,1},{2,1},{0,70},{0,115},
- {2,1},{0,55},{0,101},{4,1},{2,1},{0,86},{0,128},{2,1},{0,8},{0,116},
- {4,1},{2,1},{0,129},{0,24},{2,1},{0,130},{0,40},{16,1},{8,1},{4,1},
- {2,1},{0,71},{0,102},{2,1},{0,131},{0,56},{4,1},{2,1},{0,117},{0,87},
- {2,1},{0,132},{0,72},{6,1},{4,1},{2,1},{0,144},{0,25},{0,145},{4,1},
- {2,1},{0,146},{0,118},{2,1},{0,103},{0,41},{92,1},{36,1},{18,1},{10,1},
- {4,1},{2,1},{0,133},{0,88},{4,1},{2,1},{0,9},{0,119},{0,147},{4,1},
- {2,1},{0,57},{0,148},{2,1},{0,73},{0,134},{10,1},{6,1},{2,1},{0,104},
- {2,1},{0,160},{0,10},{2,1},{0,161},{0,26},{4,1},{2,1},{0,162},{0,42},
- {2,1},{0,149},{0,89},{26,1},{14,1},{6,1},{2,1},{0,163},{2,1},{0,58},
- {0,135},{4,1},{2,1},{0,120},{0,164},{2,1},{0,74},{0,150},{6,1},{4,1},
- {2,1},{0,105},{0,176},{0,177},{4,1},{2,1},{0,27},{0,165},{0,178},{14,1},
- {8,1},{4,1},{2,1},{0,90},{0,43},{2,1},{0,136},{0,151},{2,1},{0,179},
- {2,1},{0,121},{0,59},{8,1},{4,1},{2,1},{0,106},{0,180},{2,1},{0,75},
- {0,193},{4,1},{2,1},{0,152},{0,137},{2,1},{0,28},{0,181},{80,1},{34,1},
- {16,1},{6,1},{4,1},{2,1},{0,91},{0,44},{0,194},{6,1},{4,1},{2,1},
- {0,11},{0,192},{0,166},{2,1},{0,167},{0,122},{10,1},{4,1},{2,1},{0,195},
- {0,60},{4,1},{2,1},{0,12},{0,153},{0,182},{4,1},{2,1},{0,107},{0,196},
- {2,1},{0,76},{0,168},{20,1},{10,1},{4,1},{2,1},{0,138},{0,197},{4,1},
- {2,1},{0,208},{0,92},{0,209},{4,1},{2,1},{0,183},{0,123},{2,1},{0,29},
- {2,1},{0,13},{0,45},{12,1},{4,1},{2,1},{0,210},{0,211},{4,1},{2,1},
- {0,61},{0,198},{2,1},{0,108},{0,169},{6,1},{4,1},{2,1},{0,154},{0,184},
- {0,212},{4,1},{2,1},{0,139},{0,77},{2,1},{0,199},{0,124},{68,1},{34,1},
- {18,1},{10,1},{4,1},{2,1},{0,213},{0,93},{4,1},{2,1},{0,224},{0,14},
- {0,225},{4,1},{2,1},{0,30},{0,226},{2,1},{0,170},{0,46},{8,1},{4,1},
- {2,1},{0,185},{0,155},{2,1},{0,227},{0,214},{4,1},{2,1},{0,109},{0,62},
- {2,1},{0,200},{0,140},{16,1},{8,1},{4,1},{2,1},{0,228},{0,78},{2,1},
- {0,215},{0,125},{4,1},{2,1},{0,229},{0,186},{2,1},{0,171},{0,94},{8,1},
- {4,1},{2,1},{0,201},{0,156},{2,1},{0,241},{0,31},{6,1},{4,1},{2,1},
- {0,240},{0,110},{0,242},{2,1},{0,47},{0,230},{38,1},{18,1},{8,1},{4,1},
- {2,1},{0,216},{0,243},{2,1},{0,63},{0,244},{6,1},{2,1},{0,79},{2,1},
- {0,141},{0,217},{2,1},{0,187},{0,202},{8,1},{4,1},{2,1},{0,172},{0,231},
- {2,1},{0,126},{0,245},{8,1},{4,1},{2,1},{0,157},{0,95},{2,1},{0,232},
- {0,142},{2,1},{0,246},{0,203},{34,1},{18,1},{10,1},{6,1},{4,1},{2,1},
- {0,15},{0,174},{0,111},{2,1},{0,188},{0,218},{4,1},{2,1},{0,173},{0,247},
- {2,1},{0,127},{0,233},{8,1},{4,1},{2,1},{0,158},{0,204},{2,1},{0,248},
- {0,143},{4,1},{2,1},{0,219},{0,189},{2,1},{0,234},{0,249},{16,1},{8,1},
- {4,1},{2,1},{0,159},{0,220},{2,1},{0,205},{0,235},{4,1},{2,1},{0,190},
- {0,250},{2,1},{0,175},{0,221},{14,1},{6,1},{4,1},{2,1},{0,236},{0,206},
- {0,251},{4,1},{2,1},{0,191},{0,237},{2,1},{0,222},{0,252},{6,1},{4,1},
- {2,1},{0,207},{0,253},{0,238},{4,1},{2,1},{0,223},{0,254},{2,1},{0,239},
- {0,255},
- };
-
- private static int ValTab16[][] = {
- {2,1},{0,0},{6,1},{2,1},{0,16},{2,1},{0,1},{0,17},{42,1},{8,1},
- {4,1},{2,1},{0,32},{0,2},{2,1},{0,33},{0,18},{10,1},{6,1},{2,1},
- {0,34},{2,1},{0,48},{0,3},{2,1},{0,49},{0,19},{10,1},{4,1},{2,1},
- {0,50},{0,35},{4,1},{2,1},{0,64},{0,4},{0,65},{6,1},{2,1},{0,20},
- {2,1},{0,51},{0,66},{4,1},{2,1},{0,36},{0,80},{2,1},{0,67},{0,52},
- {138,1},{40,1},{16,1},{6,1},{4,1},{2,1},{0,5},{0,21},{0,81},{4,1},
- {2,1},{0,82},{0,37},{4,1},{2,1},{0,68},{0,53},{0,83},{10,1},{6,1},
- {4,1},{2,1},{0,96},{0,6},{0,97},{2,1},{0,22},{0,98},{8,1},{4,1},
- {2,1},{0,38},{0,84},{2,1},{0,69},{0,99},{4,1},{2,1},{0,54},{0,112},
- {0,113},{40,1},{18,1},{8,1},{2,1},{0,23},{2,1},{0,7},{2,1},{0,85},
- {0,100},{4,1},{2,1},{0,114},{0,39},{4,1},{2,1},{0,70},{0,101},{0,115},
- {10,1},{6,1},{2,1},{0,55},{2,1},{0,86},{0,8},{2,1},{0,128},{0,129},
- {6,1},{2,1},{0,24},{2,1},{0,116},{0,71},{2,1},{0,130},{2,1},{0,40},
- {0,102},{24,1},{14,1},{8,1},{4,1},{2,1},{0,131},{0,56},{2,1},{0,117},
- {0,132},{4,1},{2,1},{0,72},{0,144},{0,145},{6,1},{2,1},{0,25},{2,1},
- {0,9},{0,118},{2,1},{0,146},{0,41},{14,1},{8,1},{4,1},{2,1},{0,133},
- {0,88},{2,1},{0,147},{0,57},{4,1},{2,1},{0,160},{0,10},{0,26},{8,1},
- {2,1},{0,162},{2,1},{0,103},{2,1},{0,87},{0,73},{6,1},{2,1},{0,148},
- {2,1},{0,119},{0,134},{2,1},{0,161},{2,1},{0,104},{0,149},{220,1},{126,1},
- {50,1},{26,1},{12,1},{6,1},{2,1},{0,42},{2,1},{0,89},{0,58},{2,1},
- {0,163},{2,1},{0,135},{0,120},{8,1},{4,1},{2,1},{0,164},{0,74},{2,1},
- {0,150},{0,105},{4,1},{2,1},{0,176},{0,11},{0,177},{10,1},{4,1},{2,1},
- {0,27},{0,178},{2,1},{0,43},{2,1},{0,165},{0,90},{6,1},{2,1},{0,179},
- {2,1},{0,166},{0,106},{4,1},{2,1},{0,180},{0,75},{2,1},{0,12},{0,193},
- {30,1},{14,1},{6,1},{4,1},{2,1},{0,181},{0,194},{0,44},{4,1},{2,1},
- {0,167},{0,195},{2,1},{0,107},{0,196},{8,1},{2,1},{0,29},{4,1},{2,1},
- {0,136},{0,151},{0,59},{4,1},{2,1},{0,209},{0,210},{2,1},{0,45},{0,211},
- {18,1},{6,1},{4,1},{2,1},{0,30},{0,46},{0,226},{6,1},{4,1},{2,1},
- {0,121},{0,152},{0,192},{2,1},{0,28},{2,1},{0,137},{0,91},{14,1},{6,1},
- {2,1},{0,60},{2,1},{0,122},{0,182},{4,1},{2,1},{0,76},{0,153},{2,1},
- {0,168},{0,138},{6,1},{2,1},{0,13},{2,1},{0,197},{0,92},{4,1},{2,1},
- {0,61},{0,198},{2,1},{0,108},{0,154},{88,1},{86,1},{36,1},{16,1},{8,1},
- {4,1},{2,1},{0,139},{0,77},{2,1},{0,199},{0,124},{4,1},{2,1},{0,213},
- {0,93},{2,1},{0,224},{0,14},{8,1},{2,1},{0,227},{4,1},{2,1},{0,208},
- {0,183},{0,123},{6,1},{4,1},{2,1},{0,169},{0,184},{0,212},{2,1},{0,225},
- {2,1},{0,170},{0,185},{24,1},{10,1},{6,1},{4,1},{2,1},{0,155},{0,214},
- {0,109},{2,1},{0,62},{0,200},{6,1},{4,1},{2,1},{0,140},{0,228},{0,78},
- {4,1},{2,1},{0,215},{0,229},{2,1},{0,186},{0,171},{12,1},{4,1},{2,1},
- {0,156},{0,230},{4,1},{2,1},{0,110},{0,216},{2,1},{0,141},{0,187},{8,1},
- {4,1},{2,1},{0,231},{0,157},{2,1},{0,232},{0,142},{4,1},{2,1},{0,203},
- {0,188},{0,158},{0,241},{2,1},{0,31},{2,1},{0,15},{0,47},{66,1},{56,1},
- {2,1},{0,242},{52,1},{50,1},{20,1},{8,1},{2,1},{0,189},{2,1},{0,94},
- {2,1},{0,125},{0,201},{6,1},{2,1},{0,202},{2,1},{0,172},{0,126},{4,1},
- {2,1},{0,218},{0,173},{0,204},{10,1},{6,1},{2,1},{0,174},{2,1},{0,219},
- {0,220},{2,1},{0,205},{0,190},{6,1},{4,1},{2,1},{0,235},{0,237},{0,238},
- {6,1},{4,1},{2,1},{0,217},{0,234},{0,233},{2,1},{0,222},{4,1},{2,1},
- {0,221},{0,236},{0,206},{0,63},{0,240},{4,1},{2,1},{0,243},{0,244},{2,1},
- {0,79},{2,1},{0,245},{0,95},{10,1},{2,1},{0,255},{4,1},{2,1},{0,246},
- {0,111},{2,1},{0,247},{0,127},{12,1},{6,1},{2,1},{0,143},{2,1},{0,248},
- {0,249},{4,1},{2,1},{0,159},{0,250},{0,175},{8,1},{4,1},{2,1},{0,251},
- {0,191},{2,1},{0,252},{0,207},{4,1},{2,1},{0,253},{0,223},{2,1},{0,254},
- {0,239},
- };
-
- private static int ValTab24[][] = {
- {60,1},{8,1},{4,1},{2,1},{0,0},{0,16},{2,1},{0,1},{0,17},{14,1},
- {6,1},{4,1},{2,1},{0,32},{0,2},{0,33},{2,1},{0,18},{2,1},{0,34},
- {2,1},{0,48},{0,3},{14,1},{4,1},{2,1},{0,49},{0,19},{4,1},{2,1},
- {0,50},{0,35},{4,1},{2,1},{0,64},{0,4},{0,65},{8,1},{4,1},{2,1},
- {0,20},{0,51},{2,1},{0,66},{0,36},{6,1},{4,1},{2,1},{0,67},{0,52},
- {0,81},{6,1},{4,1},{2,1},{0,80},{0,5},{0,21},{2,1},{0,82},{0,37},
- {250,1},{98,1},{34,1},{18,1},{10,1},{4,1},{2,1},{0,68},{0,83},{2,1},
- {0,53},{2,1},{0,96},{0,6},{4,1},{2,1},{0,97},{0,22},{2,1},{0,98},
- {0,38},{8,1},{4,1},{2,1},{0,84},{0,69},{2,1},{0,99},{0,54},{4,1},
- {2,1},{0,113},{0,85},{2,1},{0,100},{0,70},{32,1},{14,1},{6,1},{2,1},
- {0,114},{2,1},{0,39},{0,55},{2,1},{0,115},{4,1},{2,1},{0,112},{0,7},
- {0,23},{10,1},{4,1},{2,1},{0,101},{0,86},{4,1},{2,1},{0,128},{0,8},
- {0,129},{4,1},{2,1},{0,116},{0,71},{2,1},{0,24},{0,130},{16,1},{8,1},
- {4,1},{2,1},{0,40},{0,102},{2,1},{0,131},{0,56},{4,1},{2,1},{0,117},
- {0,87},{2,1},{0,132},{0,72},{8,1},{4,1},{2,1},{0,145},{0,25},{2,1},
- {0,146},{0,118},{4,1},{2,1},{0,103},{0,41},{2,1},{0,133},{0,88},{92,1},
- {34,1},{16,1},{8,1},{4,1},{2,1},{0,147},{0,57},{2,1},{0,148},{0,73},
- {4,1},{2,1},{0,119},{0,134},{2,1},{0,104},{0,161},{8,1},{4,1},{2,1},
- {0,162},{0,42},{2,1},{0,149},{0,89},{4,1},{2,1},{0,163},{0,58},{2,1},
- {0,135},{2,1},{0,120},{0,74},{22,1},{12,1},{4,1},{2,1},{0,164},{0,150},
- {4,1},{2,1},{0,105},{0,177},{2,1},{0,27},{0,165},{6,1},{2,1},{0,178},
- {2,1},{0,90},{0,43},{2,1},{0,136},{0,179},{16,1},{10,1},{6,1},{2,1},
- {0,144},{2,1},{0,9},{0,160},{2,1},{0,151},{0,121},{4,1},{2,1},{0,166},
- {0,106},{0,180},{12,1},{6,1},{2,1},{0,26},{2,1},{0,10},{0,176},{2,1},
- {0,59},{2,1},{0,11},{0,192},{4,1},{2,1},{0,75},{0,193},{2,1},{0,152},
- {0,137},{67,1},{34,1},{16,1},{8,1},{4,1},{2,1},{0,28},{0,181},{2,1},
- {0,91},{0,194},{4,1},{2,1},{0,44},{0,167},{2,1},{0,122},{0,195},{10,1},
- {6,1},{2,1},{0,60},{2,1},{0,12},{0,208},{2,1},{0,182},{0,107},{4,1},
- {2,1},{0,196},{0,76},{2,1},{0,153},{0,168},{16,1},{8,1},{4,1},{2,1},
- {0,138},{0,197},{2,1},{0,92},{0,209},{4,1},{2,1},{0,183},{0,123},{2,1},
- {0,29},{0,210},{9,1},{4,1},{2,1},{0,45},{0,211},{2,1},{0,61},{0,198},
- {85,250},{4,1},{2,1},{0,108},{0,169},{2,1},{0,154},{0,212},{32,1},{16,1},
- {8,1},{4,1},{2,1},{0,184},{0,139},{2,1},{0,77},{0,199},{4,1},{2,1},
- {0,124},{0,213},{2,1},{0,93},{0,225},{8,1},{4,1},{2,1},{0,30},{0,226},
- {2,1},{0,170},{0,185},{4,1},{2,1},{0,155},{0,227},{2,1},{0,214},{0,109},
- {20,1},{10,1},{6,1},{2,1},{0,62},{2,1},{0,46},{0,78},{2,1},{0,200},
- {0,140},{4,1},{2,1},{0,228},{0,215},{4,1},{2,1},{0,125},{0,171},{0,229},
- {10,1},{4,1},{2,1},{0,186},{0,94},{2,1},{0,201},{2,1},{0,156},{0,110},
- {8,1},{2,1},{0,230},{2,1},{0,13},{2,1},{0,224},{0,14},{4,1},{2,1},
- {0,216},{0,141},{2,1},{0,187},{0,202},{74,1},{2,1},{0,255},{64,1},{58,1},
- {32,1},{16,1},{8,1},{4,1},{2,1},{0,172},{0,231},{2,1},{0,126},{0,217},
- {4,1},{2,1},{0,157},{0,232},{2,1},{0,142},{0,203},{8,1},{4,1},{2,1},
- {0,188},{0,218},{2,1},{0,173},{0,233},{4,1},{2,1},{0,158},{0,204},{2,1},
- {0,219},{0,189},{16,1},{8,1},{4,1},{2,1},{0,234},{0,174},{2,1},{0,220},
- {0,205},{4,1},{2,1},{0,235},{0,190},{2,1},{0,221},{0,236},{8,1},{4,1},
- {2,1},{0,206},{0,237},{2,1},{0,222},{0,238},{0,15},{4,1},{2,1},{0,240},
- {0,31},{0,241},{4,1},{2,1},{0,242},{0,47},{2,1},{0,243},{0,63},{18,1},
- {8,1},{4,1},{2,1},{0,244},{0,79},{2,1},{0,245},{0,95},{4,1},{2,1},
- {0,246},{0,111},{2,1},{0,247},{2,1},{0,127},{0,143},{10,1},{4,1},{2,1},
- {0,248},{0,249},{4,1},{2,1},{0,159},{0,175},{0,250},{8,1},{4,1},{2,1},
- {0,251},{0,191},{2,1},{0,252},{0,207},{4,1},{2,1},{0,253},{0,223},{2,1},
- {0,254},{0,239},
- };
-
- private static int ValTab32[][] = {
- {2,1},{0,0},{8,1},{4,1},{2,1},{0,8},{0,4},{2,1},{0,1},{0,2},
- {8,1},{4,1},{2,1},{0,12},{0,10},{2,1},{0,3},{0,6},{6,1},{2,1},
- {0,9},{2,1},{0,5},{0,7},{4,1},{2,1},{0,14},{0,13},{2,1},{0,15},
- {0,11},
- };
-
- private static int ValTab33[][] = {
- {16,1},{8,1},{4,1},{2,1},{0,0},{0,1},{2,1},{0,2},{0,3},{4,1},
- {2,1},{0,4},{0,5},{2,1},{0,6},{0,7},{8,1},{4,1},{2,1},{0,8},
- {0,9},{2,1},{0,10},{0,11},{4,1},{2,1},{0,12},{0,13},{2,1},{0,14},
- {0,15},
- };
-
-
- public static huffcodetab[] ht = null; /* Simulate extern struct */
-
- private static int[] bitbuf = new int[32];
-
- /**
- * Big Constructor : Computes all Huffman Tables.
- */
- private huffcodetab(String S,int XLEN, int YLEN, int LINBITS, int LINMAX, int REF,
- int[] TABLE, int[] HLEN, int[][] VAL, int TREELEN)
- {
- tablename0 = S.charAt(0);
- tablename1 = S.charAt(1);
- tablename2 = S.charAt(2);
- xlen = XLEN;
- ylen = YLEN;
- linbits = LINBITS;
- linmax = LINMAX;
- ref = REF;
- table = TABLE;
- hlen = HLEN;
- val = VAL;
- treelen = TREELEN;
- }
-
-
-
- /**
- * Do the huffman-decoding.
- * note! for counta,countb -the 4 bit value is returned in y,
- * discard x.
- */
- public static int huffman_decoder(huffcodetab h, int[] x, int[] y, int[] v, int[] w, BitReserve br)
- {
- // array of all huffcodtable headers
- // 0..31 Huffman code table 0..31
- // 32,33 count1-tables
-
- int dmask = 1 << ((4 * 8) - 1);
- int hs = 4 * 8;
- int level;
- int point = 0;
- int error = 1;
- level = dmask;
-
- if (h.val == null) return 2;
-
- /* table 0 needs no bits */
- if ( h.treelen == 0)
- {
- x[0] = y[0] = 0;
- return 0;
- }
-
- /* Lookup in Huffman table. */
-
- /*int bitsAvailable = 0;
- int bitIndex = 0;
-
- int bits[] = bitbuf;*/
- do
- {
- if (h.val[point][0]==0)
- { /*end of tree*/
- x[0] = h.val[point][1] >>> 4;
- y[0] = h.val[point][1] & 0xf;
- error = 0;
- break;
- }
-
- // hget1bit() is called thousands of times, and so needs to be
- // ultra fast.
- /*
- if (bitIndex==bitsAvailable)
- {
- bitsAvailable = br.readBits(bits, 32);
- bitIndex = 0;
- }
- */
- //if (bits[bitIndex++]!=0)
- if (br.hget1bit()!=0)
- {
- while (h.val[point][1] >= MXOFF) point += h.val[point][1];
- point += h.val[point][1];
- }
- else
- {
- while (h.val[point][0] >= MXOFF) point += h.val[point][0];
- point += h.val[point][0];
- }
- level >>>= 1;
- // MDM: ht[0] is always 0;
- } while ((level !=0 ) || (point < 0 /*ht[0].treelen*/) );
-
- // put back any bits not consumed
- /*
- int unread = (bitsAvailable-bitIndex);
- if (unread>0)
- br.rewindNbits(unread);
- */
- /* Process sign encodings for quadruples tables. */
- // System.out.println(h.tablename);
- if (h.tablename0 == '3' && (h.tablename1 == '2' || h.tablename1 == '3'))
- {
- v[0] = (y[0]>>3) & 1;
- w[0] = (y[0]>>2) & 1;
- x[0] = (y[0]>>1) & 1;
- y[0] = y[0] & 1;
-
- /* v, w, x and y are reversed in the bitstream.
- switch them around to make test bistream work. */
-
- if (v[0]!=0)
- if (br.hget1bit() != 0) v[0] = -v[0];
- if (w[0]!=0)
- if (br.hget1bit() != 0) w[0] = -w[0];
- if (x[0]!=0)
- if (br.hget1bit() != 0) x[0] = -x[0];
- if (y[0]!=0)
- if (br.hget1bit() != 0) y[0] = -y[0];
- }
- else
- {
- // Process sign and escape encodings for dual tables.
- // x and y are reversed in the test bitstream.
- // Reverse x and y here to make test bitstream work.
-
- if (h.linbits != 0)
- if ((h.xlen-1) == x[0])
- x[0] += br.hgetbits(h.linbits);
- if (x[0] != 0)
- if (br.hget1bit() != 0) x[0] = -x[0];
- if (h.linbits != 0)
- if ((h.ylen-1) == y[0])
- y[0] += br.hgetbits(h.linbits);
- if (y[0] != 0)
- if (br.hget1bit() != 0) y[0] = -y[0];
- }
- return error;
- }
-
- public static void inithuff()
- {
-
- if (ht!=null)
- return;
-
- ht = new huffcodetab[HTN];
- ht[0] = new huffcodetab("0 ",0,0,0,0,-1,null,null,ValTab0,0);
- ht[1] = new huffcodetab("1 ",2,2,0,0,-1,null,null,ValTab1,7);
- ht[2] = new huffcodetab("2 ",3,3,0,0,-1,null,null,ValTab2,17);
- ht[3] = new huffcodetab("3 ",3,3,0,0,-1,null,null,ValTab3,17);
- ht[4] = new huffcodetab("4 ",0,0,0,0,-1,null,null,ValTab4,0);
- ht[5] = new huffcodetab("5 ",4,4,0,0,-1,null,null,ValTab5,31);
- ht[6] = new huffcodetab("6 ",4,4,0,0,-1,null,null,ValTab6,31);
- ht[7] = new huffcodetab("7 ",6,6,0,0,-1,null,null,ValTab7,71);
- ht[8] = new huffcodetab("8 ",6,6,0,0,-1,null,null,ValTab8,71);
- ht[9] = new huffcodetab("9 ",6,6,0,0,-1,null,null,ValTab9,71);
- ht[10] = new huffcodetab("10 ",8,8,0,0,-1,null,null,ValTab10,127);
- ht[11] = new huffcodetab("11 ",8,8,0,0,-1,null,null,ValTab11,127);
- ht[12] = new huffcodetab("12 ",8,8,0,0,-1,null,null,ValTab12,127);
- ht[13] = new huffcodetab("13 ",16,16,0,0,-1,null,null,ValTab13,511);
- ht[14] = new huffcodetab("14 ",0,0,0,0,-1,null,null,ValTab14,0);
- ht[15] = new huffcodetab("15 ",16,16,0,0,-1,null,null,ValTab15,511);
- ht[16] = new huffcodetab("16 ",16,16,1,1,-1,null,null,ValTab16,511);
- ht[17] = new huffcodetab("17 ",16,16,2,3,16,null,null,ValTab16,511);
- ht[18] = new huffcodetab("18 ",16,16,3,7,16,null,null,ValTab16,511);
- ht[19] = new huffcodetab("19 ",16,16,4,15,16,null,null,ValTab16,511);
- ht[20] = new huffcodetab("20 ",16,16,6,63,16,null,null,ValTab16,511);
- ht[21] = new huffcodetab("21 ",16,16,8,255,16,null,null,ValTab16,511);
- ht[22] = new huffcodetab("22 ",16,16,10,1023,16,null,null,ValTab16,511);
- ht[23] = new huffcodetab("23 ",16,16,13,8191,16,null,null,ValTab16,511);
- ht[24] = new huffcodetab("24 ",16,16,4,15,-1,null,null,ValTab24,512);
- ht[25] = new huffcodetab("25 ",16,16,5,31,24,null,null,ValTab24,512);
- ht[26] = new huffcodetab("26 ",16,16,6,63,24,null,null,ValTab24,512);
- ht[27] = new huffcodetab("27 ",16,16,7,127,24,null,null,ValTab24,512);
- ht[28] = new huffcodetab("28 ",16,16,8,255,24,null,null,ValTab24,512);
- ht[29] = new huffcodetab("29 ",16,16,9,511,24,null,null,ValTab24,512);
- ht[30] = new huffcodetab("30 ",16,16,11,2047,24,null,null,ValTab24,512);
- ht[31] = new huffcodetab("31 ",16,16,13,8191,24,null,null,ValTab24,512);
- ht[32] = new huffcodetab("32 ",1,16,0,0,-1,null,null,ValTab32,31);
- ht[33] = new huffcodetab("33 ",1,16,0,0,-1,null,null,ValTab33,31);
- }
-}
diff --git a/songdbj/javazoom/jl/decoder/l3reorder.ser b/songdbj/javazoom/jl/decoder/l3reorder.ser
deleted file mode 100644
index d7e3e0fa61..0000000000
--- a/songdbj/javazoom/jl/decoder/l3reorder.ser
+++ /dev/null
Binary files differ
diff --git a/songdbj/javazoom/jl/decoder/lin2au.ser b/songdbj/javazoom/jl/decoder/lin2au.ser
deleted file mode 100644
index 258231516e..0000000000
--- a/songdbj/javazoom/jl/decoder/lin2au.ser
+++ /dev/null
Binary files differ
diff --git a/songdbj/javazoom/jl/decoder/readme.txt b/songdbj/javazoom/jl/decoder/readme.txt
deleted file mode 100644
index 7a765ec7dc..0000000000
--- a/songdbj/javazoom/jl/decoder/readme.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-
-TODO:
-
-
-Implement high-level Player and Converter classes.
-
-Add MP1 and MP2 support and test.
-
-Add option to run each "stage" on own thread.
-E.g. read & parse input, decode subbands, subband synthesis, audio output.
-
-Retrofit seek support (temporarily removed when reworking classes.)
-
-
-Document and give example code. \ No newline at end of file
diff --git a/songdbj/javazoom/jl/decoder/sfd.ser b/songdbj/javazoom/jl/decoder/sfd.ser
deleted file mode 100644
index e65b782f36..0000000000
--- a/songdbj/javazoom/jl/decoder/sfd.ser
+++ /dev/null
Binary files differ
diff --git a/songdbj/javazoom/jl/player/AudioDevice.java b/songdbj/javazoom/jl/player/AudioDevice.java
deleted file mode 100644
index 45c28600e6..0000000000
--- a/songdbj/javazoom/jl/player/AudioDevice.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import javazoom.jl.decoder.Decoder;
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * The <code>AudioDevice</code> interface provides an abstraction for
- * a device capable of sounding audio samples. Samples are written to
- * the device wia the write() method. The device assumes
- * that these samples are signed 16-bit samples taken at the output frequency
- * of the decoder. If the decoder outputs more than one channel, the samples for
- * each channel are assumed to appear consecutively, with the lower numbered
- * channels preceeding higher-numbered channels. E.g. if there are two
- * channels, the samples will appear in this order:
- * <pre><code>
- *
- * l0, r0, l1, r1, l2, r2...
- *
- * where
- * l<i>x</i> indicates the <i>x</i>th sample on channel 0
- * r<i>x</i> indicates the <i>x</i>th sample on channel 1
- * </code></pre>
- *
- * @since 0.0.8
- * @author Mat McGowan
- */
-public interface AudioDevice
-{
- /**
- * Prepares the AudioDevice for playback of audio samples.
- * @param decoder The decoder that will be providing the audio
- * samples.
- *
- * If the audio device is already open, this method returns silently.
- *
- */
- public void open(Decoder decoder) throws JavaLayerException;
-
- /**
- * Retrieves the open state of this audio device.
- *
- * @return <code>true</code> if this audio device is open and playing
- * audio samples, or <code>false</code> otherwise.
- */
- public boolean isOpen();
-
- /**
- * Writes a number of samples to this <code>AudioDevice</code>.
- *
- * @param samples The array of signed 16-bit samples to write
- * to the audio device.
- * @param offs The offset of the first sample.
- * @param len The number of samples to write.
- *
- * This method may return prior to the samples actually being played
- * by the audio device.
- */
- public void write(short[] samples, int offs, int len) throws JavaLayerException;
-
-
- /**
- * Closes this audio device. Any currently playing audio is stopped
- * as soon as possible. Any previously written audio data that has not been heard
- * is discarded.
- *
- * The implementation should ensure that any threads currently blocking
- * on the device (e.g. during a <code>write</code> or <code>flush</code>
- * operation should be unblocked by this method.
- */
- public void close();
-
-
- /**
- * Blocks until all audio samples previously written to this audio device have
- * been heard.
- */
- public void flush();
-
- /**
- * Retrieves the current playback position in milliseconds.
- */
- public int getPosition();
-}
diff --git a/songdbj/javazoom/jl/player/AudioDeviceBase.java b/songdbj/javazoom/jl/player/AudioDeviceBase.java
deleted file mode 100644
index d9c84f08e7..0000000000
--- a/songdbj/javazoom/jl/player/AudioDeviceBase.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import javazoom.jl.decoder.Decoder;
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * The <code>AudioDeviceBase</code> class provides a simple thread-safe
- * implementation of the <code>AudioDevice</code> interface.
- * Template methods are provided for subclasses to override and
- * in doing so provide the implementation for the main operations
- * of the <code>AudioDevice</code> interface.
- *
- * @since 0.0.8
- * @author Mat McGowan
- */
-/*
- * REVIEW: It is desirable to be able to use the decoder whe
- * in the implementation of open(), but the decoder
- * has not yet read a frame, and so much of the
- * desired information (sample rate, channels etc.)
- * are not available.
- */
-public abstract class AudioDeviceBase implements AudioDevice
-{
- private boolean open = false;
-
- private Decoder decoder = null;
-
- /**
- * Opens this audio device.
- *
- * @param decoder The decoder that will provide audio data
- * to this audio device.
- */
- public synchronized void open(Decoder decoder) throws JavaLayerException
- {
- if (!isOpen())
- {
- this.decoder = decoder;
- openImpl();
- setOpen(true);
- }
- }
-
- /**
- * Template method to provide the
- * implementation for the opening of the audio device.
- */
- protected void openImpl() throws JavaLayerException
- {
- }
-
- /**
- * Sets the open state for this audio device.
- */
- protected void setOpen(boolean open)
- {
- this.open = open;
- }
-
- /**
- * Determines if this audio device is open or not.
- *
- * @return <code>true</code> if the audio device is open,
- * <code>false</code> if it is not.
- */
- public synchronized boolean isOpen()
- {
- return open;
- }
-
- /**
- * Closes this audio device. If the device is currently playing
- * audio, playback is stopped immediately without flushing
- * any buffered audio data.
- */
- public synchronized void close()
- {
- if (isOpen())
- {
- closeImpl();
- setOpen(false);
- decoder = null;
- }
- }
-
- /**
- * Template method to provide the implementation for
- * closing the audio device.
- */
- protected void closeImpl()
- {
- }
-
- /**
- * Writes audio data to this audio device. Audio data is
- * assumed to be in the output format of the decoder. This
- * method may return before the data has actually been sounded
- * by the device if the device buffers audio samples.
- *
- * @param samples The samples to write to the audio device.
- * @param offs The offset into the array of the first sample to write.
- * @param len The number of samples from the array to write.
- * @throws JavaLayerException if the audio data could not be
- * written to the audio device.
- * If the audio device is not open, this method does nthing.
- */
- public void write(short[] samples, int offs, int len)
- throws JavaLayerException
- {
- if (isOpen())
- {
- writeImpl(samples, offs, len);
- }
- }
-
- /**
- * Template method to provide the implementation for
- * writing audio samples to the audio device.
- */
- protected void writeImpl(short[] samples, int offs, int len)
- throws JavaLayerException
- {
- }
-
- /**
- * Waits for any buffered audio samples to be played by the
- * audio device. This method should only be called prior
- * to closing the device.
- */
- public void flush()
- {
- if (isOpen())
- {
- flushImpl();
- }
- }
-
- /**
- * Template method to provide the implementation for
- * flushing any buffered audio data.
- */
- protected void flushImpl()
- {
- }
-
- /**
- * Retrieves the decoder that provides audio data to this
- * audio device.
- *
- * @return The associated decoder.
- */
- protected Decoder getDecoder()
- {
- return decoder;
- }
-}
diff --git a/songdbj/javazoom/jl/player/AudioDeviceFactory.java b/songdbj/javazoom/jl/player/AudioDeviceFactory.java
deleted file mode 100644
index 2d502d2aad..0000000000
--- a/songdbj/javazoom/jl/player/AudioDeviceFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * An <code>AudioDeviceFactory</code> class is responsible for creating
- * a specific <code>AudioDevice</code> implementation. A factory implementation
- * can be as simple or complex as desired and may support just one implementation
- * or may return several implementations depending upon the execution
- * environment.
- * <p>
- * When implementing a factory that provides an AudioDevice that uses
- * class that may not be present, the factory should dynamically link to any
- * specific implementation classes required to instantiate or test the audio
- * implementation. This is so that the application as a whole
- * can run without these classes being present. The audio
- * device implementation, however, will usually statically link to the classes
- * required. (See the JavaSound deivce and factory for an example
- * of this.)
- *
- * @see FactoryRegistry
- *
- * @since 0.0.8
- * @author Mat McGowan
- */
-public abstract class AudioDeviceFactory
-{
- /**
- * Creates a new <code>AudioDevice</code>.
- *
- * @return a new instance of a specific class of <code>AudioDevice</code>.
- * @throws JavaLayerException if an instance of AudioDevice could not
- * be created.
- */
- public abstract AudioDevice createAudioDevice() throws JavaLayerException;
-
- /**
- * Creates an instance of an AudioDevice implementation.
- * @param loader The <code>ClassLoader</code> to use to
- * load the named class, or null to use the
- * system class loader.
- * @param name The name of the class to load.
- * @return A newly-created instance of the audio device class.
- */
- protected AudioDevice instantiate(ClassLoader loader, String name)
- throws ClassNotFoundException,
- IllegalAccessException,
- InstantiationException
- {
- AudioDevice dev = null;
-
- Class cls = null;
- if (loader==null)
- {
- cls = Class.forName(name);
- }
- else
- {
- cls = loader.loadClass(name);
- }
-
- Object o = cls.newInstance();
- dev = (AudioDevice)o;
-
- return dev;
- }
-}
diff --git a/songdbj/javazoom/jl/player/FactoryRegistry.java b/songdbj/javazoom/jl/player/FactoryRegistry.java
deleted file mode 100644
index 8919995802..0000000000
--- a/songdbj/javazoom/jl/player/FactoryRegistry.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * The <code>FactoryRegistry</code> class stores the factories
- * for all the audio device implementations available in the system.
- * <p>
- * Instances of this class are thread-safe.
- *
- * @since 0.0.8
- * @author Mat McGowan
- */
-
-public class FactoryRegistry extends AudioDeviceFactory
-{
- static private FactoryRegistry instance = null;
-
- static synchronized public FactoryRegistry systemRegistry()
- {
- if (instance==null)
- {
- instance = new FactoryRegistry();
- instance.registerDefaultFactories();
- }
- return instance;
- }
-
-
- protected Hashtable factories = new Hashtable();
-
- /**
- * Registers an <code>AudioDeviceFactory</code> instance
- * with this registry.
- */
- public void addFactory(AudioDeviceFactory factory)
- {
- factories.put(factory.getClass(), factory);
- }
-
- public void removeFactoryType(Class cls)
- {
- factories.remove(cls);
- }
-
- public void removeFactory(AudioDeviceFactory factory)
- {
- factories.remove(factory.getClass());
- }
-
- public AudioDevice createAudioDevice() throws JavaLayerException
- {
- AudioDevice device = null;
- AudioDeviceFactory[] factories = getFactoriesPriority();
-
- if (factories==null)
- throw new JavaLayerException(this+": no factories registered");
-
- JavaLayerException lastEx = null;
- for (int i=0; (device==null) && (i<factories.length); i++)
- {
- try
- {
- device = factories[i].createAudioDevice();
- }
- catch (JavaLayerException ex)
- {
- lastEx = ex;
- }
- }
-
- if (device==null && lastEx!=null)
- {
- throw new JavaLayerException("Cannot create AudioDevice", lastEx);
- }
-
- return device;
- }
-
-
- protected AudioDeviceFactory[] getFactoriesPriority()
- {
- AudioDeviceFactory[] fa = null;
- synchronized (factories)
- {
- int size = factories.size();
- if (size!=0)
- {
- fa = new AudioDeviceFactory[size];
- int idx = 0;
- Enumeration e = factories.elements();
- while (e.hasMoreElements())
- {
- AudioDeviceFactory factory = (AudioDeviceFactory)e.nextElement();
- fa[idx++] = factory;
- }
- }
- }
- return fa;
- }
-
- protected void registerDefaultFactories()
- {
- addFactory(new JavaSoundAudioDeviceFactory());
- }
-}
diff --git a/songdbj/javazoom/jl/player/JavaSoundAudioDevice.java b/songdbj/javazoom/jl/player/JavaSoundAudioDevice.java
deleted file mode 100644
index caa92cd6fc..0000000000
--- a/songdbj/javazoom/jl/player/JavaSoundAudioDevice.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 11/26/04 Buffer size modified to support JRE 1.5 optimizations.
- * (CPU usage < 1% under P4/2Ghz, RAM < 12MB).
- * jlayer@javazoom.net
- * 11/19/04 1.0 moved to LGPL.
- * 06/04/01 Too fast playback fixed. mdm@techie.com
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.DataLine;
-import javax.sound.sampled.Line;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.SourceDataLine;
-
-import javazoom.jl.decoder.Decoder;
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * The <code>JavaSoundAudioDevice</code> implements an audio
- * device by using the JavaSound API.
- *
- * @since 0.0.8
- * @author Mat McGowan
- */
-public class JavaSoundAudioDevice extends AudioDeviceBase
-{
- private SourceDataLine source = null;
-
- private AudioFormat fmt = null;
-
- private byte[] byteBuf = new byte[4096];
-
- protected void setAudioFormat(AudioFormat fmt0)
- {
- fmt = fmt0;
- }
-
- protected AudioFormat getAudioFormat()
- {
- if (fmt==null)
- {
- Decoder decoder = getDecoder();
- fmt = new AudioFormat(decoder.getOutputFrequency(),
- 16,
- decoder.getOutputChannels(),
- true,
- false);
- }
- return fmt;
- }
-
- protected DataLine.Info getSourceLineInfo()
- {
- AudioFormat fmt = getAudioFormat();
- //DataLine.Info info = new DataLine.Info(SourceDataLine.class, fmt, 4000);
- DataLine.Info info = new DataLine.Info(SourceDataLine.class, fmt);
- return info;
- }
-
- public void open(AudioFormat fmt) throws JavaLayerException
- {
- if (!isOpen())
- {
- setAudioFormat(fmt);
- openImpl();
- setOpen(true);
- }
- }
-
- protected void openImpl()
- throws JavaLayerException
- {
- }
-
-
- // createSource fix.
- protected void createSource() throws JavaLayerException
- {
- Throwable t = null;
- try
- {
- Line line = AudioSystem.getLine(getSourceLineInfo());
- if (line instanceof SourceDataLine)
- {
- source = (SourceDataLine)line;
- //source.open(fmt, millisecondsToBytes(fmt, 2000));
- source.open(fmt);
- /*
- if (source.isControlSupported(FloatControl.Type.MASTER_GAIN))
- {
- FloatControl c = (FloatControl)source.getControl(FloatControl.Type.MASTER_GAIN);
- c.setValue(c.getMaximum());
- }*/
- source.start();
-
- }
- } catch (RuntimeException ex)
- {
- t = ex;
- }
- catch (LinkageError ex)
- {
- t = ex;
- }
- catch (LineUnavailableException ex)
- {
- t = ex;
- }
- if (source==null) throw new JavaLayerException("cannot obtain source audio line", t);
- }
-
- public int millisecondsToBytes(AudioFormat fmt, int time)
- {
- return (int)(time*(fmt.getSampleRate()*fmt.getChannels()*fmt.getSampleSizeInBits())/8000.0);
- }
-
- protected void closeImpl()
- {
- if (source!=null)
- {
- source.close();
- }
- }
-
- protected void writeImpl(short[] samples, int offs, int len)
- throws JavaLayerException
- {
- if (source==null)
- createSource();
-
- byte[] b = toByteArray(samples, offs, len);
- source.write(b, 0, len*2);
- }
-
- protected byte[] getByteArray(int length)
- {
- if (byteBuf.length < length)
- {
- byteBuf = new byte[length+1024];
- }
- return byteBuf;
- }
-
- protected byte[] toByteArray(short[] samples, int offs, int len)
- {
- byte[] b = getByteArray(len*2);
- int idx = 0;
- short s;
- while (len-- > 0)
- {
- s = samples[offs++];
- b[idx++] = (byte)s;
- b[idx++] = (byte)(s>>>8);
- }
- return b;
- }
-
- protected void flushImpl()
- {
- if (source!=null)
- {
- source.drain();
- }
- }
-
- public int getPosition()
- {
- int pos = 0;
- if (source!=null)
- {
- pos = (int)(source.getMicrosecondPosition()/1000);
- }
- return pos;
- }
-
- /**
- * Runs a short test by playing a short silent sound.
- */
- public void test()
- throws JavaLayerException
- {
- try
- {
- open(new AudioFormat(22050, 16, 1, true, false));
- short[] data = new short[22050/10];
- write(data, 0, data.length);
- flush();
- close();
- }
- catch (RuntimeException ex)
- {
- throw new JavaLayerException("Device test failed: "+ex);
- }
-
- }
-}
diff --git a/songdbj/javazoom/jl/player/JavaSoundAudioDeviceFactory.java b/songdbj/javazoom/jl/player/JavaSoundAudioDeviceFactory.java
deleted file mode 100644
index 92af492f65..0000000000
--- a/songdbj/javazoom/jl/player/JavaSoundAudioDeviceFactory.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * This class is responsible for creating instances of the
- * JavaSoundAudioDevice. The audio device implementation is loaded
- * and tested dynamically as not all systems will have support
- * for JavaSound, or they may have the incorrect version.
- */
-public class JavaSoundAudioDeviceFactory extends AudioDeviceFactory
-{
- private boolean tested = false;
-
- static private final String DEVICE_CLASS_NAME = "javazoom.jl.player.JavaSoundAudioDevice";
-
- public synchronized AudioDevice createAudioDevice()
- throws JavaLayerException
- {
- if (!tested)
- {
- testAudioDevice();
- tested = true;
- }
-
- try
- {
- return createAudioDeviceImpl();
- }
- catch (Exception ex)
- {
- throw new JavaLayerException("unable to create JavaSound device: "+ex);
- }
- catch (LinkageError ex)
- {
- throw new JavaLayerException("unable to create JavaSound device: "+ex);
- }
- }
-
- protected JavaSoundAudioDevice createAudioDeviceImpl()
- throws JavaLayerException
- {
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- JavaSoundAudioDevice dev = (JavaSoundAudioDevice)instantiate(loader, DEVICE_CLASS_NAME);
- return dev;
- }
- catch (Exception ex)
- {
- throw new JavaLayerException("Cannot create JavaSound device", ex);
- }
- catch (LinkageError ex)
- {
- throw new JavaLayerException("Cannot create JavaSound device", ex);
- }
-
- }
-
- public void testAudioDevice() throws JavaLayerException
- {
- JavaSoundAudioDevice dev = createAudioDeviceImpl();
- dev.test();
- }
-}
diff --git a/songdbj/javazoom/jl/player/NullAudioDevice.java b/songdbj/javazoom/jl/player/NullAudioDevice.java
deleted file mode 100644
index 4145feecd4..0000000000
--- a/songdbj/javazoom/jl/player/NullAudioDevice.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 11/19/04 1.0 moved o LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-/**
- * The <code>NullAudioDevice</code> implements a silent, no-op
- * audio device. This is useful for testing purposes.
- *
- * @since 0.0.8
- * @author Mat McGowan
- */
-public class NullAudioDevice extends AudioDeviceBase
-{
-
- public int getPosition()
- {
- return 0;
- }
-}
diff --git a/songdbj/javazoom/jl/player/Player.java b/songdbj/javazoom/jl/player/Player.java
deleted file mode 100644
index 32fb1f3051..0000000000
--- a/songdbj/javazoom/jl/player/Player.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import java.io.InputStream;
-
-import javazoom.jl.decoder.Bitstream;
-import javazoom.jl.decoder.BitstreamException;
-import javazoom.jl.decoder.Decoder;
-import javazoom.jl.decoder.Header;
-import javazoom.jl.decoder.JavaLayerException;
-import javazoom.jl.decoder.SampleBuffer;
-
-/**
- * The <code>Player</code> class implements a simple player for playback
- * of an MPEG audio stream.
- *
- * @author Mat McGowan
- * @since 0.0.8
- */
-
-// REVIEW: the audio device should not be opened until the
-// first MPEG audio frame has been decoded.
-public class Player
-{
- /**
- * The current frame number.
- */
- private int frame = 0;
-
- /**
- * The MPEG audio bitstream.
- */
- // javac blank final bug.
- /*final*/ private Bitstream bitstream;
-
- /**
- * The MPEG audio decoder.
- */
- /*final*/ private Decoder decoder;
-
- /**
- * The AudioDevice the audio samples are written to.
- */
- private AudioDevice audio;
-
- /**
- * Has the player been closed?
- */
- private boolean closed = false;
-
- /**
- * Has the player played back all frames from the stream?
- */
- private boolean complete = false;
-
- private int lastPosition = 0;
-
- /**
- * Creates a new <code>Player</code> instance.
- */
- public Player(InputStream stream) throws JavaLayerException
- {
- this(stream, null);
- }
-
- public Player(InputStream stream, AudioDevice device) throws JavaLayerException
- {
- bitstream = new Bitstream(stream);
- decoder = new Decoder();
-
- if (device!=null)
- {
- audio = device;
- }
- else
- {
- FactoryRegistry r = FactoryRegistry.systemRegistry();
- audio = r.createAudioDevice();
- }
- audio.open(decoder);
- }
-
- public void play() throws JavaLayerException
- {
- play(Integer.MAX_VALUE);
- }
-
- /**
- * Plays a number of MPEG audio frames.
- *
- * @param frames The number of frames to play.
- * @return true if the last frame was played, or false if there are
- * more frames.
- */
- public boolean play(int frames) throws JavaLayerException
- {
- boolean ret = true;
-
- while (frames-- > 0 && ret)
- {
- ret = decodeFrame();
- }
-
- if (!ret)
- {
- // last frame, ensure all data flushed to the audio device.
- AudioDevice out = audio;
- if (out!=null)
- {
- out.flush();
- synchronized (this)
- {
- complete = (!closed);
- close();
- }
- }
- }
- return ret;
- }
-
- /**
- * Cloases this player. Any audio currently playing is stopped
- * immediately.
- */
- public synchronized void close()
- {
- AudioDevice out = audio;
- if (out!=null)
- {
- closed = true;
- audio = null;
- // this may fail, so ensure object state is set up before
- // calling this method.
- out.close();
- lastPosition = out.getPosition();
- try
- {
- bitstream.close();
- }
- catch (BitstreamException ex)
- {
- }
- }
- }
-
- /**
- * Returns the completed status of this player.
- *
- * @return true if all available MPEG audio frames have been
- * decoded, or false otherwise.
- */
- public synchronized boolean isComplete()
- {
- return complete;
- }
-
- /**
- * Retrieves the position in milliseconds of the current audio
- * sample being played. This method delegates to the <code>
- * AudioDevice</code> that is used by this player to sound
- * the decoded audio samples.
- */
- public int getPosition()
- {
- int position = lastPosition;
-
- AudioDevice out = audio;
- if (out!=null)
- {
- position = out.getPosition();
- }
- return position;
- }
-
- /**
- * Decodes a single frame.
- *
- * @return true if there are no more frames to decode, false otherwise.
- */
- protected boolean decodeFrame() throws JavaLayerException
- {
- try
- {
- AudioDevice out = audio;
- if (out==null)
- return false;
-
- Header h = bitstream.readFrame();
-
- if (h==null)
- return false;
-
- // sample buffer set when decoder constructed
- SampleBuffer output = (SampleBuffer)decoder.decodeFrame(h, bitstream);
-
- synchronized (this)
- {
- out = audio;
- if (out!=null)
- {
- out.write(output.getBuffer(), 0, output.getBufferLength());
- }
- }
-
- bitstream.closeFrame();
- }
- catch (RuntimeException ex)
- {
- throw new JavaLayerException("Exception decoding audio frame", ex);
- }
-/*
- catch (IOException ex)
- {
- System.out.println("exception decoding audio frame: "+ex);
- return false;
- }
- catch (BitstreamException bitex)
- {
- System.out.println("exception decoding audio frame: "+bitex);
- return false;
- }
- catch (DecoderException decex)
- {
- System.out.println("exception decoding audio frame: "+decex);
- return false;
- }
-*/
- return true;
- }
-
-
-}
diff --git a/songdbj/javazoom/jl/player/PlayerApplet.java b/songdbj/javazoom/jl/player/PlayerApplet.java
deleted file mode 100644
index d7c7dc2ffc..0000000000
--- a/songdbj/javazoom/jl/player/PlayerApplet.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import java.applet.Applet;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * A simple applet that plays an MPEG audio file.
- * The URL (relative to the document base)
- * is passed as the "audioURL" parameter.
- *
- * @author Mat McGowan
- * @since 0.0.8
- */
-public class PlayerApplet extends Applet implements Runnable
-{
- static public final String AUDIO_PARAMETER = "audioURL";
-
- /**
- * The Player used to play the MPEG audio file.
- */
- private Player player = null;
-
- /**
- * The thread that runs the player.
- */
- private Thread playerThread = null;
-
- private String fileName = null;
-
-
- /**
- * Retrieves the <code>AudioDevice</code> instance that will
- * be used to sound the audio data.
- *
- * @return an audio device instance that will be used to
- * sound the audio stream.
- */
- protected AudioDevice getAudioDevice() throws JavaLayerException
- {
- return FactoryRegistry.systemRegistry().createAudioDevice();
- }
-
- /**
- * Retrieves the InputStream that provides the MPEG audio
- * stream data.
- *
- * @return an InputStream from which the MPEG audio data
- * is read, or null if an error occurs.
- */
- protected InputStream getAudioStream()
- {
- InputStream in = null;
-
- try
- {
- URL url = getAudioURL();
- if (url!=null)
- in = url.openStream();
- }
- catch (IOException ex)
- {
- System.err.println(ex);
- }
- return in;
- }
-
- protected String getAudioFileName()
- {
- String urlString = fileName;
- if (urlString==null)
- {
- urlString = getParameter(AUDIO_PARAMETER);
- }
- return urlString;
- }
-
- protected URL getAudioURL()
- {
- String urlString = getAudioFileName();
- URL url = null;
- if (urlString!=null)
- {
- try
- {
- url = new URL(getDocumentBase(), urlString);
- }
- catch (Exception ex)
- {
- System.err.println(ex);
- }
- }
- return url;
- }
-
- /**
- * Sets the URL of the audio stream to play.
- */
- public void setFileName(String name)
- {
- fileName = name;
- }
-
- public String getFileName()
- {
- return fileName;
- }
-
- /**
- * Stops the audio player. If the player is already stopped
- * this method is a no-op.
- */
- protected void stopPlayer() throws JavaLayerException
- {
- if (player!=null)
- {
- player.close();
- player = null;
- playerThread = null;
- }
- }
-
- /**
- * Decompresses audio data from an InputStream and plays it
- * back through an AudioDevice. The playback is run on a newly
- * created thread.
- *
- * @param in The InputStream that provides the MPEG audio data.
- * @param dev The AudioDevice to use to sound the decompressed data.
- *
- * @throws JavaLayerException if there was a problem decoding
- * or playing the audio data.
- */
- protected void play(InputStream in, AudioDevice dev) throws JavaLayerException
- {
- stopPlayer();
-
- if (in!=null && dev!=null)
- {
- player = new Player(in, dev);
- playerThread = createPlayerThread();
- playerThread.start();
- }
- }
-
- /**
- * Creates a new thread used to run the audio player.
- * @return A new Thread that, once started, runs the audio player.
- */
- protected Thread createPlayerThread()
- {
- return new Thread(this, "Audio player thread");
- }
-
- /**
- * Initializes this applet.
- */
- public void init()
- {
- }
-
- /**
- * Starts this applet. An input stream and audio device
- * are created and passed to the play() method.
- */
- public void start()
- {
- String name = getAudioFileName();
- try
- {
- InputStream in = getAudioStream();
- AudioDevice dev = getAudioDevice();
- play(in, dev);
- }
- catch (JavaLayerException ex)
- {
- synchronized (System.err)
- {
- System.err.println("Unable to play "+name);
- ex.printStackTrace(System.err);
- }
- }
- }
-
- /**
- * Stops this applet. If audio is currently playing, it is
- * stopped.
- */
- public void stop()
- {
- try
- {
- stopPlayer();
- }
- catch (JavaLayerException ex)
- {
- System.err.println(ex);
- }
- }
-
- public void destroy()
- {
- }
-
- /**
- * The run method for the audio player thread. Simply calls
- * play() on the player to play the entire stream.
- */
- public void run()
- {
- if (player!=null)
- {
- try
- {
- player.play();
- }
- catch (JavaLayerException ex)
- {
- System.err.println("Problem playing audio: "+ex);
- }
- }
- }
-}
diff --git a/songdbj/javazoom/jl/player/advanced/AdvancedPlayer.java b/songdbj/javazoom/jl/player/advanced/AdvancedPlayer.java
deleted file mode 100644
index 45a31e46e1..0000000000
--- a/songdbj/javazoom/jl/player/advanced/AdvancedPlayer.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player.advanced;
-
-import java.io.InputStream;
-
-import javazoom.jl.decoder.Bitstream;
-import javazoom.jl.decoder.BitstreamException;
-import javazoom.jl.decoder.Decoder;
-import javazoom.jl.decoder.Header;
-import javazoom.jl.decoder.JavaLayerException;
-import javazoom.jl.decoder.SampleBuffer;
-import javazoom.jl.player.AudioDevice;
-import javazoom.jl.player.FactoryRegistry;
-
-/**
- * a hybrid of javazoom.jl.player.Player tweeked to include <code>play(startFrame, endFrame)</code>
- * hopefully this will be included in the api
- */
-public class AdvancedPlayer
-{
- /** The MPEG audio bitstream.*/
- private Bitstream bitstream;
- /** The MPEG audio decoder. */
- private Decoder decoder;
- /** The AudioDevice the audio samples are written to. */
- private AudioDevice audio;
- /** Has the player been closed? */
- private boolean closed = false;
- /** Has the player played back all frames from the stream? */
- private boolean complete = false;
- private int lastPosition = 0;
- /** Listener for the playback process */
- private PlaybackListener listener;
-
- /**
- * Creates a new <code>Player</code> instance.
- */
- public AdvancedPlayer(InputStream stream) throws JavaLayerException
- {
- this(stream, null);
- }
-
- public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException
- {
- bitstream = new Bitstream(stream);
-
- if (device!=null) audio = device;
- else audio = FactoryRegistry.systemRegistry().createAudioDevice();
- audio.open(decoder = new Decoder());
- }
-
- public void play() throws JavaLayerException
- {
- play(Integer.MAX_VALUE);
- }
-
- /**
- * Plays a number of MPEG audio frames.
- *
- * @param frames The number of frames to play.
- * @return true if the last frame was played, or false if there are
- * more frames.
- */
- public boolean play(int frames) throws JavaLayerException
- {
- boolean ret = true;
-
- // report to listener
- if(listener != null) listener.playbackStarted(createEvent(PlaybackEvent.STARTED));
-
- while (frames-- > 0 && ret)
- {
- ret = decodeFrame();
- }
-
-// if (!ret)
- {
- // last frame, ensure all data flushed to the audio device.
- AudioDevice out = audio;
- if (out != null)
- {
-// System.out.println(audio.getPosition());
- out.flush();
-// System.out.println(audio.getPosition());
- synchronized (this)
- {
- complete = (!closed);
- close();
- }
-
- // report to listener
- if(listener != null) listener.playbackFinished(createEvent(out, PlaybackEvent.STOPPED));
- }
- }
- return ret;
- }
-
- /**
- * Cloases this player. Any audio currently playing is stopped
- * immediately.
- */
- public synchronized void close()
- {
- AudioDevice out = audio;
- if (out != null)
- {
- closed = true;
- audio = null;
- // this may fail, so ensure object state is set up before
- // calling this method.
- out.close();
- lastPosition = out.getPosition();
- try
- {
- bitstream.close();
- }
- catch (BitstreamException ex)
- {}
- }
- }
-
- /**
- * Decodes a single frame.
- *
- * @return true if there are no more frames to decode, false otherwise.
- */
- protected boolean decodeFrame() throws JavaLayerException
- {
- try
- {
- AudioDevice out = audio;
- if (out == null) return false;
-
- Header h = bitstream.readFrame();
- if (h == null) return false;
-
- // sample buffer set when decoder constructed
- SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);
-
- synchronized (this)
- {
- out = audio;
- if(out != null)
- {
- out.write(output.getBuffer(), 0, output.getBufferLength());
- }
- }
-
- bitstream.closeFrame();
- }
- catch (RuntimeException ex)
- {
- throw new JavaLayerException("Exception decoding audio frame", ex);
- }
- return true;
- }
-
- /**
- * skips over a single frame
- * @return false if there are no more frames to decode, true otherwise.
- */
- protected boolean skipFrame() throws JavaLayerException
- {
- Header h = bitstream.readFrame();
- if (h == null) return false;
- bitstream.closeFrame();
- return true;
- }
-
- /**
- * Plays a range of MPEG audio frames
- * @param start The first frame to play
- * @param end The last frame to play
- * @return true if the last frame was played, or false if there are more frames.
- */
- public boolean play(final int start, final int end) throws JavaLayerException
- {
- boolean ret = true;
- int offset = start;
- while (offset-- > 0 && ret) ret = skipFrame();
- return play(end - start);
- }
-
- /**
- * Constructs a <code>PlaybackEvent</code>
- */
- private PlaybackEvent createEvent(int id)
- {
- return createEvent(audio, id);
- }
-
- /**
- * Constructs a <code>PlaybackEvent</code>
- */
- private PlaybackEvent createEvent(AudioDevice dev, int id)
- {
- return new PlaybackEvent(this, id, dev.getPosition());
- }
-
- /**
- * sets the <code>PlaybackListener</code>
- */
- public void setPlayBackListener(PlaybackListener listener)
- {
- this.listener = listener;
- }
-
- /**
- * gets the <code>PlaybackListener</code>
- */
- public PlaybackListener getPlayBackListener()
- {
- return listener;
- }
-
- /**
- * closes the player and notifies <code>PlaybackListener</code>
- */
- public void stop()
- {
- listener.playbackFinished(createEvent(PlaybackEvent.STOPPED));
- close();
- }
-} \ No newline at end of file
diff --git a/songdbj/javazoom/jl/player/advanced/PlaybackEvent.java b/songdbj/javazoom/jl/player/advanced/PlaybackEvent.java
deleted file mode 100644
index 08e3cae958..0000000000
--- a/songdbj/javazoom/jl/player/advanced/PlaybackEvent.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player.advanced;
-
-/**
- * An event which indicates a <code>Player</code> has performed an 'playback action'
- * @author Paul Stanton (http://wanto.f2o.org/)
- */
-public class PlaybackEvent
-{
- public static int STOPPED = 1;
- public static int STARTED = 2;
-
- private AdvancedPlayer source;
- private int frame;
- private int id;
-
- public PlaybackEvent(AdvancedPlayer source, int id, int frame)
- {
- this.id = id;
- this.source = source;
- this.frame = frame;
- }
-
- public int getId(){return id;}
- public void setId(int id){this.id = id;}
-
- public int getFrame(){return frame;}
- public void setFrame(int frame){this.frame = frame;}
-
- public AdvancedPlayer getSource(){return source;}
- public void setSource(AdvancedPlayer source){this.source = source;}
-
-}
diff --git a/songdbj/javazoom/jl/player/advanced/PlaybackListener.java b/songdbj/javazoom/jl/player/advanced/PlaybackListener.java
deleted file mode 100644
index 9b042988b8..0000000000
--- a/songdbj/javazoom/jl/player/advanced/PlaybackListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player.advanced;
-
-/**
- * Listener for javalayer Player playback
- * @author Paul Stanton (http://wanto.f2o.org/)
- */
-public abstract class PlaybackListener
-{
- public void playbackStarted(PlaybackEvent evt){}
- public void playbackFinished(PlaybackEvent evt){}
-}
diff --git a/songdbj/javazoom/jl/player/advanced/jlap.java b/songdbj/javazoom/jl/player/advanced/jlap.java
deleted file mode 100644
index beedea6716..0000000000
--- a/songdbj/javazoom/jl/player/advanced/jlap.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player.advanced;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * This class implements a sample player using Playback listener.
- */
-public class jlap
-{
-
- public static void main(String[] args)
- {
- jlap test = new jlap();
- if (args.length != 1)
- {
- test.showUsage();
- System.exit(0);
- }
- else
- {
- try
- {
- test.play(args[0]);
- }
- catch (Exception ex)
- {
- System.err.println(ex.getMessage());
- System.exit(0);
- }
- }
- }
-
- public void play(String filename) throws JavaLayerException, IOException
- {
- InfoListener lst = new InfoListener();
- playMp3(new File(filename), lst);
- }
-
- public void showUsage()
- {
- System.out.println("Usage: jla <filename>");
- System.out.println("");
- System.out.println(" e.g. : java javazoom.jl.player.advanced.jlap localfile.mp3");
- }
-
- public static AdvancedPlayer playMp3(File mp3, PlaybackListener listener) throws IOException, JavaLayerException
- {
- return playMp3(mp3, 0, Integer.MAX_VALUE, listener);
- }
-
- public static AdvancedPlayer playMp3(File mp3, int start, int end, PlaybackListener listener) throws IOException, JavaLayerException
- {
- return playMp3(new BufferedInputStream(new FileInputStream(mp3)), start, end, listener);
- }
-
- public static AdvancedPlayer playMp3(final InputStream is, final int start, final int end, PlaybackListener listener) throws JavaLayerException
- {
- final AdvancedPlayer player = new AdvancedPlayer(is);
- player.setPlayBackListener(listener);
- // run in new thread
- new Thread()
- {
- public void run()
- {
- try
- {
- player.play(start, end);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage());
- }
- }
- }.start();
- return player;
- }
-
- public class InfoListener extends PlaybackListener
- {
- public void playbackStarted(PlaybackEvent evt)
- {
- System.out.println("Play started from frame " + evt.getFrame());
- }
-
- public void playbackFinished(PlaybackEvent evt)
- {
- System.out.println("Play completed at frame " + evt.getFrame());
- System.exit(0);
- }
- }
-} \ No newline at end of file
diff --git a/songdbj/javazoom/jl/player/jlp.java b/songdbj/javazoom/jl/player/jlp.java
deleted file mode 100644
index ddb3d5ecca..0000000000
--- a/songdbj/javazoom/jl/player/jlp.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 11/19/04 1.0 moved to LGPL.
- *
- * 06/04/01 Streaming support added. javalayer@javazoom.net
- *
- * 29/01/00 Initial version. mdm@techie.com
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.jl.player;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import javazoom.jl.decoder.JavaLayerException;
-
-/**
- * The <code>jlp</code> class implements a simple command-line
- * player for MPEG audio files.
- *
- * @author Mat McGowan (mdm@techie.com)
- */
-public class jlp
-{
- private String fFilename = null;
- private boolean remote = false;
-
- public static void main(String[] args)
- {
- int retval = 0;
- try
- {
- jlp player = createInstance(args);
- if (player!=null)
- player.play();
- }
- catch (Exception ex)
- {
- System.err.println(ex);
- ex.printStackTrace(System.err);
- retval = 1;
- }
- System.exit(retval);
- }
-
- static public jlp createInstance(String[] args)
- {
- jlp player = new jlp();
- if (!player.parseArgs(args))
- player = null;
- return player;
- }
-
- private jlp()
- {
- }
-
- public jlp(String filename)
- {
- init(filename);
- }
-
- protected void init(String filename)
- {
- fFilename = filename;
- }
-
- protected boolean parseArgs(String[] args)
- {
- boolean parsed = false;
- if (args.length == 1)
- {
- init(args[0]);
- parsed = true;
- remote = false;
- }
- else if (args.length == 2)
- {
- if (!(args[0].equals("-url")))
- {
- showUsage();
- }
- else
- {
- init(args[1]);
- parsed = true;
- remote = true;
- }
- }
- else
- {
- showUsage();
- }
- return parsed;
- }
-
- public void showUsage()
- {
- System.out.println("Usage: jlp [-url] <filename>");
- System.out.println("");
- System.out.println(" e.g. : java javazoom.jl.player.jlp localfile.mp3");
- System.out.println(" java javazoom.jl.player.jlp -url http://www.server.com/remotefile.mp3");
- System.out.println(" java javazoom.jl.player.jlp -url http://www.shoutcastserver.com:8000");
- }
-
- public void play()
- throws JavaLayerException
- {
- try
- {
- System.out.println("playing "+fFilename+"...");
- InputStream in = null;
- if (remote == true) in = getURLInputStream();
- else in = getInputStream();
- AudioDevice dev = getAudioDevice();
- Player player = new Player(in, dev);
- player.play();
- }
- catch (IOException ex)
- {
- throw new JavaLayerException("Problem playing file "+fFilename, ex);
- }
- catch (Exception ex)
- {
- throw new JavaLayerException("Problem playing file "+fFilename, ex);
- }
- }
-
- /**
- * Playing file from URL (Streaming).
- */
- protected InputStream getURLInputStream()
- throws Exception
- {
-
- URL url = new URL(fFilename);
- InputStream fin = url.openStream();
- BufferedInputStream bin = new BufferedInputStream(fin);
- return bin;
- }
-
- /**
- * Playing file from FileInputStream.
- */
- protected InputStream getInputStream()
- throws IOException
- {
- FileInputStream fin = new FileInputStream(fFilename);
- BufferedInputStream bin = new BufferedInputStream(fin);
- return bin;
- }
-
- protected AudioDevice getAudioDevice()
- throws JavaLayerException
- {
- return FactoryRegistry.systemRegistry().createAudioDevice();
- }
-
-}
diff --git a/songdbj/javazoom/spi/PropertiesContainer.java b/songdbj/javazoom/spi/PropertiesContainer.java
deleted file mode 100644
index 27ed85f904..0000000000
--- a/songdbj/javazoom/spi/PropertiesContainer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * PropertiesContainer.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi;
-
-import java.util.Map;
-
-public interface PropertiesContainer
-{
- public Map properties();
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/convert/DecodedMpegAudioInputStream.java b/songdbj/javazoom/spi/mpeg/sampled/convert/DecodedMpegAudioInputStream.java
deleted file mode 100644
index e4e6fed00a..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/convert/DecodedMpegAudioInputStream.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * DecodedMpegAudioInputStream.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *------------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.convert;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-
-import javazoom.jl.decoder.Bitstream;
-import javazoom.jl.decoder.BitstreamException;
-import javazoom.jl.decoder.Decoder;
-import javazoom.jl.decoder.DecoderException;
-import javazoom.jl.decoder.Equalizer;
-import javazoom.jl.decoder.Header;
-import javazoom.jl.decoder.Obuffer;
-import javazoom.spi.PropertiesContainer;
-import javazoom.spi.mpeg.sampled.file.IcyListener;
-import javazoom.spi.mpeg.sampled.file.tag.TagParseEvent;
-import javazoom.spi.mpeg.sampled.file.tag.TagParseListener;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.convert.TAsynchronousFilteredAudioInputStream;
-
-/**
- * Main decoder.
- */
-public class DecodedMpegAudioInputStream extends TAsynchronousFilteredAudioInputStream implements PropertiesContainer, TagParseListener
-{
- private InputStream m_encodedStream;
- private Bitstream m_bitstream;
- private Decoder m_decoder;
- private Equalizer m_equalizer;
- private float[] m_equalizer_values;
- private Header m_header;
- private DMAISObuffer m_oBuffer;
-
- // Bytes info.
- private long byteslength = -1;
- private long currentByte = 0;
- // Frame info.
- private int frameslength = -1;
- private long currentFrame = 0;
- private int currentFramesize = 0;
- private int currentBitrate = -1;
- // Time info.
- private long currentMicrosecond = 0;
- // Shoutcast stream info
- private IcyListener shoutlst = null;
-
-
- private HashMap properties = null;
-
- public DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream inputStream)
- {
- super(outputFormat, -1);
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(">DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream inputStream)");
- }
- try
- {
- // Try to find out inputstream length to allow skip.
- byteslength = inputStream.available();
- }
- catch (IOException e)
- {
- TDebug.out("DecodedMpegAudioInputStream : Cannot run inputStream.available() : "+e.getMessage());
- byteslength = -1;
- }
- m_encodedStream = inputStream;
- shoutlst = IcyListener.getInstance();
- shoutlst.reset();
- m_bitstream = new Bitstream(inputStream);
- m_decoder = new Decoder(null);
- m_equalizer = new Equalizer();
- m_equalizer_values = new float[32];
- for (int b=0;b<m_equalizer.getBandCount();b++)
- {
- m_equalizer_values[b] = m_equalizer.getBand(b);
- }
- m_decoder.setEqualizer(m_equalizer);
- m_oBuffer = new DMAISObuffer(outputFormat.getChannels());
- m_decoder.setOutputBuffer(m_oBuffer);
- try
- {
- m_header = m_bitstream.readFrame();
- if ((m_header != null) && (frameslength == -1) && (byteslength > 0)) frameslength = m_header.max_number_of_frames((int)byteslength);
- }
- catch (BitstreamException e)
- {
- TDebug.out("DecodedMpegAudioInputStream : Cannot read first frame : "+e.getMessage());
- byteslength = -1;
- }
- properties = new HashMap();
- }
-
- /**
- * Return dynamic properties.
- *
- * <ul>
- * <li><b>mp3.frame</b> [Long], current frame position.
- * <li><b>mp3.frame.bitrate</b> [Integer], bitrate of the current frame.
- * <li><b>mp3.frame.size.bytes</b> [Integer], size in bytes of the current frame.
- * <li><b>mp3.position.byte</b> [Long], current position in bytes in the stream.
- * <li><b>mp3.position.microseconds</b> [Long], elapsed microseconds.
- * <li><b>mp3.equalizer</b> float[32], interactive equalizer array, values could be in [-1.0, +1.0].
- * <li><b>mp3.shoutcast.metadata.key</b> [String], Shoutcast meta key with matching value.
- * <br>For instance :
- * <br>mp3.shoutcast.metadata.StreamTitle=Current song playing in stream.
- * <br>mp3.shoutcast.metadata.StreamUrl=Url info.
- * </ul>
- */
- public Map properties()
- {
- properties.put("mp3.frame",new Long(currentFrame));
- properties.put("mp3.frame.bitrate",new Integer(currentBitrate));
- properties.put("mp3.frame.size.bytes",new Integer(currentFramesize));
- properties.put("mp3.position.byte",new Long(currentByte));
- properties.put("mp3.position.microseconds",new Long(currentMicrosecond));
- properties.put("mp3.equalizer",m_equalizer_values);
- // Optionnal shoutcast stream meta-data.
- if (shoutlst != null)
- {
- String surl = shoutlst.getStreamUrl();
- String stitle = shoutlst.getStreamTitle();
- if ((stitle != null) && (stitle.trim().length()>0)) properties.put("mp3.shoutcast.metadata.StreamTitle",stitle);
- if ((surl != null) && (surl.trim().length()>0)) properties.put("mp3.shoutcast.metadata.StreamUrl",surl);
- }
- return properties;
- }
-
- public void execute()
- {
- if (TDebug.TraceAudioConverter) TDebug.out("execute() : begin");
- try
- {
- // Following line hangs when FrameSize is available in AudioFormat.
- Header header = null;
- if (m_header == null) header = m_bitstream.readFrame();
- else header = m_header;
- if (TDebug.TraceAudioConverter) TDebug.out("execute() : header = "+header);
- if (header == null)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out("header is null (end of mpeg stream)");
- }
- getCircularBuffer().close();
- return;
- }
- currentFrame++;
- currentBitrate = header.bitrate_instant();
- currentFramesize = header.calculate_framesize();
- currentByte = currentByte + currentFramesize;
- currentMicrosecond = (long) (currentFrame* header.ms_per_frame()*1000.0f);
- for (int b=0;b<m_equalizer_values.length;b++)
- {
- m_equalizer.setBand(b,m_equalizer_values[b]);
- }
- m_decoder.setEqualizer(m_equalizer);
- Obuffer decoderOutput = m_decoder.decodeFrame(header, m_bitstream);
- m_bitstream.closeFrame();
- getCircularBuffer().write(m_oBuffer.getBuffer(), 0, m_oBuffer.getCurrentBufferSize());
- m_oBuffer.reset();
- if (m_header != null) m_header = null;
- }
- catch (BitstreamException e)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(e);
- }
- }
- catch (DecoderException e)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(e);
- }
- }
- if (TDebug.TraceAudioConverter) TDebug.out("execute() : end");
- }
-
- public long skip(long bytes)
- {
- if ((byteslength > 0) && (frameslength > 0))
- {
- float ratio = bytes*1.0f/byteslength*1.0f;
- long bytesread = skipFrames((long) (ratio*frameslength));
- currentByte = currentByte + bytesread;
- return bytesread;
- }
- else return -1;
- }
-
- /**
- * Skip frames.
- * You don't need to call it severals times, it will exactly skip given frames number.
- * @param frames
- * @return bytes length skipped matching to frames skipped.
- */
- public long skipFrames(long frames)
- {
- if (TDebug.TraceAudioConverter) TDebug.out("skip(long frames) : begin");
- int framesRead = 0;
- int bytesReads = 0;
- try
- {
- for (int i=0;i<frames;i++)
- {
- Header header = m_bitstream.readFrame();
- if (header != null)
- {
- int fsize = header.calculate_framesize();
- bytesReads = bytesReads + fsize;
- }
- m_bitstream.closeFrame();
- framesRead++;
- }
- }
- catch (BitstreamException e)
- {
- if (TDebug.TraceAudioConverter) TDebug.out(e);
- }
- if (TDebug.TraceAudioConverter) TDebug.out("skip(long frames) : end");
- currentFrame = currentFrame + framesRead;
- return bytesReads;
- }
-
- private boolean isBigEndian()
- {
- return getFormat().isBigEndian();
- }
-
- public void close() throws IOException
- {
- super.close();
- m_encodedStream.close();
- }
-
- private class DMAISObuffer extends Obuffer
- {
- private int m_nChannels;
- private byte[] m_abBuffer;
- private int[] m_anBufferPointers;
- private boolean m_bIsBigEndian;
- public DMAISObuffer(int nChannels)
- {
- m_nChannels = nChannels;
- m_abBuffer = new byte[OBUFFERSIZE * nChannels];
- m_anBufferPointers = new int[nChannels];
- reset();
- m_bIsBigEndian = DecodedMpegAudioInputStream.this.isBigEndian();
- }
- public void append(int nChannel, short sValue)
- {
- byte bFirstByte;
- byte bSecondByte;
- if (m_bIsBigEndian)
- {
- bFirstByte = (byte) ((sValue >>> 8) & 0xFF);
- bSecondByte = (byte) (sValue & 0xFF);
- }
- else // little endian
- {
- bFirstByte = (byte) (sValue & 0xFF);
- bSecondByte = (byte) ((sValue >>> 8) & 0xFF);
- }
- m_abBuffer[m_anBufferPointers[nChannel]] = bFirstByte;
- m_abBuffer[m_anBufferPointers[nChannel] + 1] = bSecondByte;
- m_anBufferPointers[nChannel] += m_nChannels * 2;
- }
- public void set_stop_flag()
- {
- }
- public void close()
- {
- }
- public void write_buffer(int nValue)
- {
- }
- public void clear_buffer()
- {
- }
- public byte[] getBuffer()
- {
- return m_abBuffer;
- }
- public int getCurrentBufferSize()
- {
- return m_anBufferPointers[0];
- }
- public void reset()
- {
- for (int i = 0; i < m_nChannels; i++)
- {
- /* Points to byte location,
- * implicitely assuming 16 bit
- * samples.
- */
- m_anBufferPointers[i] = i * 2;
- }
- }
- }
-
- public void tagParsed(TagParseEvent tpe)
- {
- System.out.println("TAG:"+tpe.getTag());
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/convert/MpegFormatConversionProvider.java b/songdbj/javazoom/spi/mpeg/sampled/convert/MpegFormatConversionProvider.java
deleted file mode 100644
index 1a3d51d9ad..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/convert/MpegFormatConversionProvider.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * MpegFormatConversionProvider.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- * ---------------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- * --------------------------------------------------------------------------
- */
-
-
-package javazoom.spi.mpeg.sampled.convert;
-
-
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-
-import javazoom.spi.mpeg.sampled.file.MpegEncoding;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.Encodings;
-import org.tritonus.share.sampled.convert.TEncodingFormatConversionProvider;
-
-/**
- * ConversionProvider for MPEG files.
- */
-public class MpegFormatConversionProvider extends TEncodingFormatConversionProvider
-{
- private static final AudioFormat.Encoding MP3 = Encodings.getEncoding("MP3");
- private static final AudioFormat.Encoding PCM_SIGNED = Encodings.getEncoding("PCM_SIGNED");
-
- private static final AudioFormat[] INPUT_FORMATS =
- {
- // mono
- new AudioFormat(MP3, -1.0F, -1, 1, -1, -1.0F, false),
- new AudioFormat(MP3, -1.0F, -1, 1, -1, -1.0F, true),
- // stereo
- new AudioFormat(MP3, -1.0F, -1, 2, -1, -1.0F, false),
- new AudioFormat(MP3, -1.0F, -1, 2, -1, -1.0F, true),
- };
-
-
- private static final AudioFormat[] OUTPUT_FORMATS =
- {
- // mono, 16 bit signed
- new AudioFormat(PCM_SIGNED, -1.0F, 16, 1, 2, -1.0F, false),
- new AudioFormat(PCM_SIGNED, -1.0F, 16, 1, 2, -1.0F, true),
- // stereo, 16 bit signed
- new AudioFormat(PCM_SIGNED, -1.0F, 16, 2, 4, -1.0F, false),
- new AudioFormat(PCM_SIGNED, -1.0F, 16, 2, 4, -1.0F, true),
- };
-
- /**
- * Constructor.
- */
- public MpegFormatConversionProvider()
- {
- super(Arrays.asList(INPUT_FORMATS), Arrays.asList(OUTPUT_FORMATS));
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(">MpegFormatConversionProvider()");
- }
- }
-
- public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(">MpegFormatConversionProvider.getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream):");
- }
- return new DecodedMpegAudioInputStream(targetFormat, audioInputStream);
- }
-
- /**
- * Add conversion support for any MpegEncoding source with FrameRate or FrameSize not empty.
- * @param targetFormat
- * @param sourceFormat
- * @return
- */
- public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(">MpegFormatConversionProvider.isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat):");
- TDebug.out("checking if conversion possible");
- TDebug.out("from: " + sourceFormat);
- TDebug.out("to: " + targetFormat);
- }
-
- boolean conversion = super.isConversionSupported(targetFormat, sourceFormat);
- if (conversion == false)
- {
- AudioFormat.Encoding enc = sourceFormat.getEncoding();
- if (enc instanceof MpegEncoding)
- {
- if ((sourceFormat.getFrameRate() != AudioSystem.NOT_SPECIFIED) || (sourceFormat.getFrameSize() != AudioSystem.NOT_SPECIFIED))
- {
- conversion = true;
- }
- }
- }
- return conversion;
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/IcyListener.java b/songdbj/javazoom/spi/mpeg/sampled/file/IcyListener.java
deleted file mode 100644
index 8e49e6e2ef..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/IcyListener.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * IcyListener.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file;
-
-import javazoom.spi.mpeg.sampled.file.tag.MP3Tag;
-import javazoom.spi.mpeg.sampled.file.tag.TagParseEvent;
-import javazoom.spi.mpeg.sampled.file.tag.TagParseListener;
-
-/**
- * This class (singleton) allow to be notified on shoutcast meta data
- * while playing the stream (such as song title).
- */
-public class IcyListener implements TagParseListener
-{
- private static IcyListener instance = null;
- private MP3Tag lastTag = null;
- private String streamTitle = null;
- private String streamUrl = null;
-
-
- private IcyListener()
- {
- super();
- }
-
- public static synchronized IcyListener getInstance()
- {
- if (instance == null)
- {
- instance = new IcyListener();
- }
- return instance;
- }
-
- /* (non-Javadoc)
- * @see javazoom.spi.mpeg.sampled.file.tag.TagParseListener#tagParsed(javazoom.spi.mpeg.sampled.file.tag.TagParseEvent)
- */
- public void tagParsed(TagParseEvent tpe)
- {
- lastTag = tpe.getTag();
- String name = lastTag.getName();
- if ((name != null) && (name.equalsIgnoreCase("streamtitle")))
- {
- streamTitle = (String) lastTag.getValue();
- }
- else if ((name != null) && (name.equalsIgnoreCase("streamurl")))
- {
- streamUrl = (String) lastTag.getValue();
- }
- }
-
- /**
- * @return
- */
- public MP3Tag getLastTag()
- {
- return lastTag;
- }
-
- /**
- * @param tag
- */
- public void setLastTag(MP3Tag tag)
- {
- lastTag = tag;
- }
-
- /**
- * @return
- */
- public String getStreamTitle()
- {
- return streamTitle;
- }
-
- /**
- * @return
- */
- public String getStreamUrl()
- {
- return streamUrl;
- }
-
- /**
- * @param string
- */
- public void setStreamTitle(String string)
- {
- streamTitle = string;
- }
-
- /**
- * @param string
- */
- public void setStreamUrl(String string)
- {
- streamUrl = string;
- }
-
- /**
- * Reset all properties.
- */
- public void reset()
- {
- lastTag = null;
- streamTitle = null;
- streamUrl = null;
- }
-
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileFormat.java b/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileFormat.java
deleted file mode 100644
index afdc4c5e9c..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileFormat.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * MpegAudioFileFormat.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-package javazoom.spi.mpeg.sampled.file;
-
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-
-/**
- * @author JavaZOOM
- */
-public class MpegAudioFileFormat extends TAudioFileFormat
-{
- /**
- * Contructor.
- * @param type
- * @param audioFormat
- * @param nLengthInFrames
- * @param nLengthInBytes
- */
- public MpegAudioFileFormat(Type type, AudioFormat audioFormat, int nLengthInFrames, int nLengthInBytes, Map properties)
- {
- super(type, audioFormat, nLengthInFrames, nLengthInBytes, properties);
- }
-
- /**
- * MP3 audio file format parameters.
- * Some parameters might be unavailable. So availability test is required before reading any parameter.
- *
- * <br>AudioFileFormat parameters.
- * <ul>
- * <li><b>duration</b> [Long], duration in microseconds.
- * <li><b>title</b> [String], Title of the stream.
- * <li><b>author</b> [String], Name of the artist of the stream.
- * <li><b>album</b> [String], Name of the album of the stream.
- * <li><b>date</b> [String], The date (year) of the recording or release of the stream.
- * <li><b>copyright</b> [String], Copyright message of the stream.
- * <li><b>comment</b> [String], Comment of the stream.
- * </ul>
- * <br>MP3 parameters.
- * <ul>
- * <li><b>mp3.version.mpeg</b> [String], mpeg version : 1,2 or 2.5
- * <li><b>mp3.version.layer</b> [String], layer version 1, 2 or 3
- * <li><b>mp3.version.encoding</b> [String], mpeg encoding : MPEG1, MPEG2-LSF, MPEG2.5-LSF
- * <li><b>mp3.channels</b> [Integer], number of channels 1 : mono, 2 : stereo.
- * <li><b>mp3.frequency.hz</b> [Integer], sampling rate in hz.
- * <li><b>mp3.bitrate.nominal.bps</b> [Integer], nominal bitrate in bps.
- * <li><b>mp3.length.bytes</b> [Integer], length in bytes.
- * <li><b>mp3.length.frames</b> [Integer], length in frames.
- * <li><b>mp3.framesize.bytes</b> [Integer], framesize of the first frame. framesize is not constant for VBR streams.
- * <li><b>mp3.framerate.fps</b> [Float], framerate in frames per seconds.
- * <li><b>mp3.header.pos</b> [Integer], position of first audio header (or ID3v2 size).
- * <li><b>mp3.vbr</b> [Boolean], vbr flag.
- * <li><b>mp3.vbr.scale</b> [Integer], vbr scale.
- * <li><b>mp3.crc</b> [Boolean], crc flag.
- * <li><b>mp3.original</b> [Boolean], original flag.
- * <li><b>mp3.copyright</b> [Boolean], copyright flag.
- * <li><b>mp3.padding</b> [Boolean], padding flag.
- * <li><b>mp3.mode</b> [Integer], mode 0:STEREO 1:JOINT_STEREO 2:DUAL_CHANNEL 3:SINGLE_CHANNEL
- * <li><b>mp3.id3tag.genre</b> [String], ID3 tag (v1 or v2) genre.
- * <li><b>mp3.id3tag.track</b> [String], ID3 tag (v1 or v2) track info.
- * <li><b>mp3.id3tag.encoded</b> [String], ID3 tag v2 encoded by info.
- * <li><b>mp3.id3tag.composer</b> [String], ID3 tag v2 composer info.
- * <li><b>mp3.id3tag.grouping</b> [String], ID3 tag v2 grouping info.
- * <li><b>mp3.id3tag.disc</b> [String], ID3 tag v2 track info.
- * <li><b>mp3.id3tag.v2</b> [InputStream], ID3v2 frames.
- * <li><b>mp3.id3tag.v2.version</b> [String], ID3v2 major version (2=v2.2.0, 3=v2.3.0, 4=v2.4.0).
- * <li><b>mp3.shoutcast.metadata.key</b> [String], Shoutcast meta key with matching value.
- * <br>For instance :
- * <br>mp3.shoutcast.metadata.icy-irc=#shoutcast
- * <br>mp3.shoutcast.metadata.icy-metaint=8192
- * <br>mp3.shoutcast.metadata.icy-genre=Trance Techno Dance
- * <br>mp3.shoutcast.metadata.icy-url=http://www.di.fm
- * <br>and so on ...
- * </ul>
- */
- public Map properties()
- {
- return super.properties();
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileReader.java b/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileReader.java
deleted file mode 100644
index 54440551a1..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFileReader.java
+++ /dev/null
@@ -1,772 +0,0 @@
-/*
- * MpegAudioFileReader.
- *
- * 12/31/04 : mp3spi.weak system property added to skip controls.
- *
- * 11/29/04 : ID3v2.2, v2.3 & v2.4 support improved.
- * "mp3.id3tag.composer" (TCOM/TCM) added
- * "mp3.id3tag.grouping" (TIT1/TT1) added
- * "mp3.id3tag.disc" (TPA/TPOS) added
- * "mp3.id3tag.encoded" (TEN/TENC) added
- * "mp3.id3tag.v2.version" added
- *
- * 11/28/04 : String encoding bug fix in chopSubstring method.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file;
-
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.AccessControlException;
-import java.util.HashMap;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import javazoom.jl.decoder.Bitstream;
-import javazoom.jl.decoder.Header;
-import javazoom.spi.mpeg.sampled.file.tag.IcyInputStream;
-import javazoom.spi.mpeg.sampled.file.tag.MP3Tag;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-/**
- * This class implements AudioFileReader for MP3 SPI.
- */
-public class MpegAudioFileReader extends TAudioFileReader
-{
- private final int SYNC = 0xFFE00000;
- private String weak = null;
- private final AudioFormat.Encoding[][] sm_aEncodings =
- {
- {MpegEncoding.MPEG2L1, MpegEncoding.MPEG2L2, MpegEncoding.MPEG2L3},
- {MpegEncoding.MPEG1L1, MpegEncoding.MPEG1L2, MpegEncoding.MPEG1L3},
- {MpegEncoding.MPEG2DOT5L1, MpegEncoding.MPEG2DOT5L2, MpegEncoding.MPEG2DOT5L3},
-
- };
-
- private static final int INITAL_READ_LENGTH = 64000;
- private static final int MARK_LIMIT = INITAL_READ_LENGTH + 1;
-
- private static final String[] id3v1genres = {
- "Blues"
- , "Classic Rock"
- , "Country"
- , "Dance"
- , "Disco"
- , "Funk"
- , "Grunge"
- , "Hip-Hop"
- , "Jazz"
- , "Metal"
- , "New Age"
- , "Oldies"
- , "Other"
- , "Pop"
- , "R&B"
- , "Rap"
- , "Reggae"
- , "Rock"
- , "Techno"
- , "Industrial"
- , "Alternative"
- , "Ska"
- , "Death Metal"
- , "Pranks"
- , "Soundtrack"
- , "Euro-Techno"
- , "Ambient"
- , "Trip-Hop"
- , "Vocal"
- , "Jazz+Funk"
- , "Fusion"
- , "Trance"
- , "Classical"
- , "Instrumental"
- , "Acid"
- , "House"
- , "Game"
- , "Sound Clip"
- , "Gospel"
- , "Noise"
- , "AlternRock"
- , "Bass"
- , "Soul"
- , "Punk"
- , "Space"
- , "Meditative"
- , "Instrumental Pop"
- , "Instrumental Rock"
- , "Ethnic"
- , "Gothic"
- , "Darkwave"
- , "Techno-Industrial"
- , "Electronic"
- , "Pop-Folk"
- , "Eurodance"
- , "Dream"
- , "Southern Rock"
- , "Comedy"
- , "Cult"
- , "Gangsta"
- , "Top 40"
- , "Christian Rap"
- , "Pop/Funk"
- , "Jungle"
- , "Native American"
- , "Cabaret"
- , "New Wave"
- , "Psychadelic"
- , "Rave"
- , "Showtunes"
- , "Trailer"
- , "Lo-Fi"
- , "Tribal"
- , "Acid Punk"
- , "Acid Jazz"
- , "Polka"
- , "Retro"
- , "Musical"
- , "Rock & Roll"
- , "Hard Rock"
- , "Folk"
- , "Folk-Rock"
- , "National Folk"
- , "Swing"
- , "Fast Fusion"
- , "Bebob"
- , "Latin"
- , "Revival"
- , "Celtic"
- , "Bluegrass"
- , "Avantgarde"
- , "Gothic Rock"
- , "Progressive Rock"
- , "Psychedelic Rock"
- , "Symphonic Rock"
- , "Slow Rock"
- , "Big Band"
- , "Chorus"
- , "Easy Listening"
- , "Acoustic"
- , "Humour"
- , "Speech"
- , "Chanson"
- , "Opera"
- , "Chamber Music"
- , "Sonata"
- , "Symphony"
- , "Booty Brass"
- , "Primus"
- , "Porn Groove"
- , "Satire"
- , "Slow Jam"
- , "Club"
- , "Tango"
- , "Samba"
- , "Folklore"
- , "Ballad"
- , "Power Ballad"
- , "Rhythmic Soul"
- , "Freestyle"
- , "Duet"
- , "Punk Rock"
- , "Drum Solo"
- , "A Capela"
- , "Euro-House"
- , "Dance Hall"
- , "Goa"
- , "Drum & Bass"
- , "Club-House"
- , "Hardcore"
- , "Terror"
- , "Indie"
- , "BritPop"
- , "Negerpunk"
- , "Polsk Punk"
- , "Beat"
- , "Christian Gangsta Rap"
- , "Heavy Metal"
- , "Black Metal"
- , "Crossover"
- , "Contemporary Christian"
- , "Christian Rock"
- , "Merengue"
- , "Salsa"
- , "Thrash Metal"
- , "Anime"
- , "JPop"
- , "SynthPop"
- };
-
- public MpegAudioFileReader()
- {
- super(MARK_LIMIT, true);
- if (TDebug.TraceAudioFileReader) TDebug.out(">MpegAudioFileReader(1.9.2-FINAL)");
- try
- {
- weak = System.getProperty("mp3spi.weak");
- }
- catch(AccessControlException e)
- {}
- }
-
- /**
- * Returns AudioFileFormat from File.
- */
- public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException
- {
- return super.getAudioFileFormat(file);
- }
-
- /**
- * Returns AudioFileFormat from URL.
- */
- public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("MpegAudioFileReader.getAudioFileFormat(URL): begin"); }
- long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
- URLConnection conn = url.openConnection();
- // Tell shoucast server (if any) that SPI support shoutcast stream.
- conn.setRequestProperty ("Icy-Metadata", "1");
- InputStream inputStream = conn.getInputStream();
- AudioFileFormat audioFileFormat = null;
- try
- {
- audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
- }
- finally
- {
- inputStream.close();
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("MpegAudioFileReader.getAudioFileFormat(URL): end"); }
- return audioFileFormat;
- }
-
- /**
- * Returns AudioFileFormat from inputstream and medialength.
- */
- public AudioFileFormat getAudioFileFormat(InputStream inputStream, long mediaLength) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out(">MpegAudioFileReader.getAudioFileFormat(InputStream inputStream, long mediaLength): begin");
- HashMap aff_properties = new HashMap();
- HashMap af_properties = new HashMap();
- int mLength = (int) mediaLength;
- int size = inputStream.available();
- PushbackInputStream pis = new PushbackInputStream(inputStream, MARK_LIMIT);
- byte head[] = new byte[12];
- pis.read(head);
- if (TDebug.TraceAudioFileReader)
- {
- TDebug.out("InputStream : "+inputStream + " =>" + new String(head));
- }
- /*
- * Check for WAV, AU, and AIFF file formats.
- *
- * Next check for Shoutcast (supported) and OGG (unsupported) streams.
- *
- * Note -- the check for WAV files will reject Broadcast WAV files.
- * This may be incorrect as broadcast WAV files may contain MPEG data.
- * Need to investigate.
- *
- */
- if ((head[0] == 'R') && (head[1] == 'I') && (head[2] == 'F') && (head[3] == 'F') && (head[8] == 'W') && (head[9] == 'A') && (head[10] == 'V') && (head[11] == 'E'))
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("WAV stream found");
- if (weak == null) throw new UnsupportedAudioFileException("WAV stream found");
- }
- else if ((head[0] == '.') && (head[1] == 's') && (head[2] == 'n') && (head[3] == 'd'))
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("AU stream found");
- if (weak == null) throw new UnsupportedAudioFileException("AU stream found");
- }
- else if ((head[0] == 'F') && (head[1] == 'O') && (head[2] == 'R') && (head[3] == 'M') && (head[8] == 'A') && (head[9] == 'I') && (head[10] == 'F') && (head[11] == 'F'))
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("AIFF stream found");
- if (weak == null) throw new UnsupportedAudioFileException("AIFF stream found");
- }
- // Shoutcast stream ?
- else if (((head[0] == 'I') | (head[0] == 'i')) && ((head[1] == 'C') | (head[1] == 'c')) && ((head[2] == 'Y') | (head[2] == 'y')))
- {
- pis.unread(head);
- // Load shoutcast meta data.
- loadShoutcastInfo(pis, aff_properties);
- }
- // Ogg stream ?
- else if (((head[0] == 'O') | (head[0] == 'o')) && ((head[1] == 'G') | (head[1] == 'g')) && ((head[2] == 'G') | (head[2] == 'g')))
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("Ogg stream found");
- if (weak == null) throw new UnsupportedAudioFileException("Ogg stream found");
- }
- // No, so pushback.
- else
- {
- pis.unread(head);
- }
- // MPEG header info.
- int nVersion = AudioSystem.NOT_SPECIFIED;
- int nLayer = AudioSystem.NOT_SPECIFIED;
- int nSFIndex = AudioSystem.NOT_SPECIFIED;
- int nMode = AudioSystem.NOT_SPECIFIED;
- int FrameSize = AudioSystem.NOT_SPECIFIED;
- int nFrameSize = AudioSystem.NOT_SPECIFIED;
- int nFrequency = AudioSystem.NOT_SPECIFIED;
- int nTotalFrames = AudioSystem.NOT_SPECIFIED;
- float FrameRate = AudioSystem.NOT_SPECIFIED;
- int BitRate = AudioSystem.NOT_SPECIFIED;
- int nChannels = AudioSystem.NOT_SPECIFIED;
- int nHeader = AudioSystem.NOT_SPECIFIED;
- int nTotalMS = AudioSystem.NOT_SPECIFIED;
- boolean nVBR = false;
- AudioFormat.Encoding encoding = null;
- try
- {
- Bitstream m_bitstream = new Bitstream(pis);
- aff_properties.put("mp3.header.pos",new Integer(m_bitstream.header_pos()));
- Header m_header = m_bitstream.readFrame();
- // nVersion = 0 => MPEG2-LSF (Including MPEG2.5), nVersion = 1 => MPEG1
- nVersion = m_header.version();
- if (nVersion == 2) aff_properties.put("mp3.version.mpeg",Float.toString(2.5f));
- else aff_properties.put("mp3.version.mpeg",Integer.toString(2-nVersion));
- // nLayer = 1,2,3
- nLayer = m_header.layer();
- aff_properties.put("mp3.version.layer",Integer.toString(nLayer));
- nSFIndex = m_header.sample_frequency();
- nMode = m_header.mode();
- aff_properties.put("mp3.mode",new Integer(nMode));
- nChannels = nMode == 3 ? 1 : 2;
- aff_properties.put("mp3.channels",new Integer(nChannels));
- nVBR = m_header.vbr();
- af_properties.put("vbr",new Boolean(nVBR));
- aff_properties.put("mp3.vbr",new Boolean(nVBR));
- aff_properties.put("mp3.vbr.scale",new Integer(m_header.vbr_scale()));
- FrameSize = m_header.calculate_framesize();
- aff_properties.put("mp3.framesize.bytes",new Integer(FrameSize));
- if (FrameSize < 0) throw new UnsupportedAudioFileException("Invalid FrameSize : " + FrameSize);
- nFrequency = m_header.frequency();
- aff_properties.put("mp3.frequency.hz",new Integer(nFrequency));
- FrameRate = (float) ((1.0 / (m_header.ms_per_frame())) * 1000.0);
- aff_properties.put("mp3.framerate.fps",new Float(FrameRate));
- if (FrameRate < 0) throw new UnsupportedAudioFileException("Invalid FrameRate : " + FrameRate);
- if (mLength != AudioSystem.NOT_SPECIFIED)
- {
- aff_properties.put("mp3.length.bytes",new Integer(mLength));
- nTotalFrames = m_header.max_number_of_frames(mLength);
- aff_properties.put("mp3.length.frames",new Integer(nTotalFrames));
- }
- BitRate = m_header.bitrate();
- af_properties.put("bitrate",new Integer(BitRate));
- aff_properties.put("mp3.bitrate.nominal.bps",new Integer(BitRate));
- nHeader = m_header.getSyncHeader();
- encoding = sm_aEncodings[nVersion][nLayer - 1];
- aff_properties.put("mp3.version.encoding",encoding.toString());
- if (mLength != AudioSystem.NOT_SPECIFIED)
- {
- nTotalMS = Math.round(m_header.total_ms(mLength));
- aff_properties.put("duration",new Long((long)nTotalMS*1000L));
- }
- aff_properties.put("mp3.copyright",new Boolean(m_header.copyright()));
- aff_properties.put("mp3.original",new Boolean(m_header.original()));
- aff_properties.put("mp3.crc",new Boolean(m_header.checksums()));
- aff_properties.put("mp3.padding",new Boolean(m_header.padding()));
- InputStream id3v2 = m_bitstream.getRawID3v2();
- if (id3v2 != null)
- {
- aff_properties.put("mp3.id3tag.v2",id3v2);
- parseID3v2Frames(id3v2,aff_properties);
- }
- if (TDebug.TraceAudioFileReader) TDebug.out(m_header.toString());
- }
- catch (Exception e)
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream:" + e.getMessage());
- throw new UnsupportedAudioFileException("not a MPEG stream:" + e.getMessage());
- }
-
- // Deeper checks ?
- int cVersion = (nHeader >> 19) & 0x3;
- if (cVersion == 1)
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream: wrong version");
- throw new UnsupportedAudioFileException("not a MPEG stream: wrong version");
- }
-
- int cSFIndex = (nHeader >> 10) & 0x3;
- if (cSFIndex == 3)
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream: wrong sampling rate");
- throw new UnsupportedAudioFileException("not a MPEG stream: wrong sampling rate");
- }
-
- // Look up for ID3v1 tag
- if ((size == mediaLength) && (mediaLength != AudioSystem.NOT_SPECIFIED))
- {
- FileInputStream fis = (FileInputStream) inputStream;
- byte[] id3v1 = new byte[128];
- long bytesSkipped = fis.skip(inputStream.available()-id3v1.length);
- int read = fis.read(id3v1,0,id3v1.length);
- if ((id3v1[0]=='T') && (id3v1[1]=='A') && (id3v1[2]=='G'))
- {
- parseID3v1Frames(id3v1, aff_properties);
- }
- }
-
- AudioFormat format = new MpegAudioFormat(encoding, (float) nFrequency, AudioSystem.NOT_SPECIFIED // SampleSizeInBits - The size of a sample
- , nChannels // Channels - The number of channels
- , -1 // The number of bytes in each frame
- , FrameRate // FrameRate - The number of frames played or recorded per second
- , true
- , af_properties);
- return new MpegAudioFileFormat(MpegFileFormatType.MP3, format, nTotalFrames, mLength,aff_properties);
- }
-
- /**
- * Returns AudioInputStream from file.
- */
- public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(File file)");
- InputStream inputStream = new FileInputStream(file);
- try
- {
- return getAudioInputStream(inputStream);
- }
- catch (UnsupportedAudioFileException e)
- {
- if (inputStream != null) inputStream.close();
- throw e;
- }
- catch (IOException e)
- {
- if (inputStream != null) inputStream.close();
- throw e;
- }
- }
-
- /**
- * Returns AudioInputStream from url.
- */
- public AudioInputStream getAudioInputStream(URL url)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("MpegAudioFileReader.getAudioInputStream(URL): begin"); }
- long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
- URLConnection conn = url.openConnection();
- // Tell shoucast server (if any) that SPI support shoutcast stream.
- boolean isShout = false;
- int toRead=4;
- byte[] head = new byte[toRead];
-
- conn.setRequestProperty ("Icy-Metadata", "1");
- BufferedInputStream bInputStream = new BufferedInputStream(conn.getInputStream());
- bInputStream.mark(toRead);
- int read = bInputStream.read(head,0,toRead);
- if ((read>2) && (((head[0] == 'I') | (head[0] == 'i')) && ((head[1] == 'C') | (head[1] == 'c')) && ((head[2] == 'Y') | (head[2] == 'y')))) isShout = true;
- bInputStream.reset();
- InputStream inputStream = null;
- // Is is a shoutcast server ?
- if (isShout == true)
- {
- // Yes
- IcyInputStream icyStream = new IcyInputStream(bInputStream);
- icyStream.addTagParseListener(IcyListener.getInstance());
- inputStream = icyStream;
- }
- else
- {
- // No, is Icecast 2 ?
- String metaint = conn.getHeaderField("icy-metaint");
- if (metaint != null)
- {
- // Yes, it might be icecast 2 mp3 stream.
- IcyInputStream icyStream = new IcyInputStream(bInputStream,metaint);
- icyStream.addTagParseListener(IcyListener.getInstance());
- inputStream = icyStream;
- }
- else
- {
- // No
- inputStream = bInputStream;
- }
- }
- AudioInputStream audioInputStream = null;
- try
- {
- audioInputStream = getAudioInputStream(inputStream, lFileLengthInBytes);
- }
- catch (UnsupportedAudioFileException e)
- {
- inputStream.close();
- throw e;
- }
- catch (IOException e)
- {
- inputStream.close();
- throw e;
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("MpegAudioFileReader.getAudioInputStream(URL): end"); }
- return audioInputStream;
- }
-
- /**
- * Return the AudioInputStream from the given InputStream.
- */
- public AudioInputStream getAudioInputStream(InputStream inputStream) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("MpegAudioFileReader.getAudioInputStream(InputStream inputStream)");
- if (!inputStream.markSupported()) inputStream = new BufferedInputStream(inputStream);
- return super.getAudioInputStream(inputStream);
- }
-
- /**
- * Parser ID3v1 frames
- * @param frames
- * @param props
- */
- protected void parseID3v1Frames(byte[] frames, HashMap props)
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("Parsing ID3v1");
- String tag = null;
- try
- {
- tag = new String(frames, 0, frames.length, "ISO-8859-1");
- }
- catch (UnsupportedEncodingException e)
- {
- tag = new String(frames, 0, frames.length);
- if (TDebug.TraceAudioFileReader) TDebug.out("Cannot use ISO-8859-1");
- }
- if (TDebug.TraceAudioFileReader) TDebug.out("ID3v1 frame dump='"+tag+"'");
- int start = 3;
- String titlev1 = chopSubstring(tag, start, start += 30);
- String titlev2 = (String) props.get("title");
- if (((titlev2==null) || (titlev2.length()==0)) && (titlev1 != null)) props.put("title",titlev1);
- String artistv1 = chopSubstring(tag, start, start += 30);
- String artistv2 = (String) props.get("author");
- if (((artistv2==null) || (artistv2.length()==0)) && (artistv1 != null)) props.put("author",artistv1);
- String albumv1 = chopSubstring(tag, start, start += 30);
- String albumv2 = (String) props.get("album");
- if (((albumv2==null) || (albumv2.length()==0)) && (albumv1 != null)) props.put("album",albumv1);
- String yearv1 = chopSubstring(tag, start, start += 4);
- String yearv2 = (String) props.get("year");
- if (((yearv2==null) || (yearv2.length()==0)) && (yearv1 != null)) props.put("date",yearv1);
- String commentv1 = chopSubstring(tag, start, start += 28);
- String commentv2 = (String) props.get("comment");
- if (((commentv2==null) || (commentv2.length()==0)) && (commentv1 != null)) props.put("comment",commentv1);
- String trackv1 = ""+((int) (frames[126] & 0xff));
- String trackv2 = (String) props.get("mp3.id3tag.track");
- if (((trackv2==null) || (trackv2.length()==0)) && (trackv1 != null)) props.put("mp3.id3tag.track",trackv1);
-
- int genrev1 = (int) (frames[127] & 0xff);
- if ((genrev1 >=0) && (genrev1<id3v1genres.length))
- {
- String genrev2 = (String) props.get("mp3.id3tag.genre");
- if (((genrev2==null) || (genrev2.length()==0))) props.put("mp3.id3tag.genre",id3v1genres[genrev1]);
- }
- if (TDebug.TraceAudioFileReader) TDebug.out("ID3v1 parsed");
- }
-
- /**
- * Extract
- * @param s
- * @param start
- * @param end
- * @return
- */
- private String chopSubstring(String s, int start, int end)
- {
- String str = null;
- // 11/28/04 - String encoding bug fix.
- try
- {
- str = s.substring(start, end);
- int loc = str.indexOf('\0');
- if (loc != -1) str = str.substring(0, loc);
- }
- catch (StringIndexOutOfBoundsException e)
- {
- // Skip encoding issues.
- if (TDebug.TraceAudioFileReader) TDebug.out("Cannot chopSubString "+e.getMessage());
- }
- return str;
- }
- /**
- * Parse ID3v2 frames to add album (TALB), title (TIT2), date (TYER), author (TPE1), copyright (TCOP), comment (COMM) ...
- * @param frames
- * @param props
- */
- protected void parseID3v2Frames(InputStream frames, HashMap props)
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("Parsing ID3v2");
- byte[] bframes = null;
- int size = -1;
- try
- {
- size = frames.available();
- bframes = new byte[size];
- frames.mark(size);
- frames.read(bframes);
- frames.reset();
- }
- catch (IOException e)
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("Cannot parse ID3v2 :"+e.getMessage());
- }
-
- try
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("ID3v2 frame dump='"+new String(bframes,0,bframes.length)+"'");
- /* ID3 tags : http://www.unixgods.org/~tilo/ID3/docs/ID3_comparison.html */
- String value = null;
- for (int i=0;i<bframes.length-4;i++)
- {
- String code = new String(bframes,i,4);
- String scode = new String(bframes,i,3);
- // ID3v2.3 & v2.4
- if ((code.equals("TALB")) || (code.equals("TIT2")) || (code.equals("TYER")) || (code.equals("TPE1")) || (code.equals("TCOP")) || (code.equals("COMM")) || (code.equals("TCON")) || (code.equals("TRCK")) || (code.equals("TPOS")) || (code.equals("TDRC")) || (code.equals("TCOM")) || (code.equals("TIT1")) || (code.equals("TENC")))
- {
- i=i+10;
- size = (int) (bframes[i-6] << 24) + (bframes[i-5] << 16) + (bframes[i-4] << 8) + (bframes[i-3]);
- if (code.equals("COMM")) value = parseText(bframes, i, size, 5);
- else value = parseText(bframes,i, size, 1);
- if ((value != null) && (value.length()>0))
- {
- if (code.equals("TALB")) props.put("album",value);
- else if (code.equals("TIT2")) props.put("title",value);
- else if (code.equals("TYER")) props.put("date",value);
- // ID3v2.4 date fix.
- else if (code.equals("TDRC")) props.put("date",value);
- else if (code.equals("TPE1")) props.put("author",value);
- else if (code.equals("TCOP")) props.put("copyright",value);
- else if (code.equals("COMM")) props.put("comment",value);
- else if (code.equals("TCON")) props.put("mp3.id3tag.genre",value);
- else if (code.equals("TRCK")) props.put("mp3.id3tag.track",value);
- else if (code.equals("TPOS")) props.put("mp3.id3tag.disc",value);
- else if (code.equals("TCOM")) props.put("mp3.id3tag.composer",value);
- else if (code.equals("TIT1")) props.put("mp3.id3tag.grouping",value);
- else if (code.equals("TENC")) props.put("mp3.id3tag.encoded",value);
- }
- i=i+size-1;
- }
- // ID3v2.2.
- else if ((scode.equals("TAL")) || (scode.equals("TT2")) || (scode.equals("TP1")) || (scode.equals("TYE")) || (scode.equals("TRK")) || (scode.equals("TPA")) || (scode.equals("TCR")) || (scode.equals("TCO")) || (scode.equals("TCM")) || (scode.equals("COM")) || (scode.equals("TT1")) || (scode.equals("TEN")))
- {
- i=i+6;
- size = (int) (0x00000000) + (bframes[i-3] << 16) + (bframes[i-2] << 8) + (bframes[i-1]);
- if (scode.equals("COM")) value = parseText(bframes, i, size, 5);
- else value = parseText(bframes,i, size, 1);
- if ((value != null) && (value.length()>0))
- {
- if (scode.equals("TAL")) props.put("album",value);
- else if (scode.equals("TT2")) props.put("title",value);
- else if (scode.equals("TYE")) props.put("date",value);
- else if (scode.equals("TP1")) props.put("author",value);
- else if (scode.equals("TCR")) props.put("copyright",value);
- else if (scode.equals("COM")) props.put("comment",value);
- else if (scode.equals("TCO")) props.put("mp3.id3tag.genre",value);
- else if (scode.equals("TRK")) props.put("mp3.id3tag.track",value);
- else if (scode.equals("TPA")) props.put("mp3.id3tag.disc",value);
- else if (scode.equals("TCM")) props.put("mp3.id3tag.composer",value);
- else if (scode.equals("TT1")) props.put("mp3.id3tag.grouping",value);
- else if (scode.equals("TEN")) props.put("mp3.id3tag.encoded",value);
- }
- i=i+size-1;
- }
- else if (code.startsWith("ID3"))
- {
- // ID3v2 Header.
- int v2version = (int) (bframes[3] & 0xFF);
- props.put("mp3.id3tag.v2.version",String.valueOf(v2version));
- i=i+4;
- }
- }
- }
- catch (RuntimeException e)
- {
- // Ignore all parsing errors.
- if (TDebug.TraceAudioFileReader) TDebug.out("Cannot parse ID3v2 :"+e.getMessage());
- }
- if (TDebug.TraceAudioFileReader) TDebug.out("ID3v2 parsed");
- }
-
- /**
- * Parse Text Frames.
- * @param bframes
- * @param offset
- * @param size
- * @param skip
- * @return
- */
- protected String parseText(byte[] bframes, int offset, int size, int skip)
- {
- String value = null;
- try
- {
- String[] ENC_TYPES = {"ISO-8859-1", "UTF16","UTF-16BE", "UTF-8"};
- value = new String(bframes,offset+skip,size-skip,ENC_TYPES[bframes[offset]]);
- value = chopSubstring(value,0,value.length());
- }
- catch (UnsupportedEncodingException e)
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("ID3v2 Encoding error :"+e.getMessage());
- }
- return value;
- }
-
- /**
- * Load shoutcast (ICY) info.
- * @param input
- * @param props
- * @throws IOException
- */
- protected void loadShoutcastInfo(InputStream input, HashMap props) throws IOException
- {
- IcyInputStream icy = new IcyInputStream(new BufferedInputStream(input));
- HashMap metadata = icy.getTagHash();
- MP3Tag titleMP3Tag = icy.getTag("icy-name");
- if (titleMP3Tag != null) props.put("title",((String) titleMP3Tag.getValue()).trim());
- MP3Tag[] meta = icy.getTags();
- if (meta != null)
- {
- StringBuffer metaStr = new StringBuffer();
- for (int i=0;i<meta.length;i++)
- {
- String key = meta[i].getName();
- String value = ((String) icy.getTag(key).getValue()).trim();
- props.put("mp3.shoutcast.metadata."+key, value);
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFormat.java b/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFormat.java
deleted file mode 100644
index 29a66a3d93..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/MpegAudioFormat.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * MpegAudioFormat.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file;
-
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.sampled.TAudioFormat;
-
-/**
- * @author JavaZOOM
- */
-public class MpegAudioFormat extends TAudioFormat
-{
- /**
- * Constructor.
- * @param encoding
- * @param nFrequency
- * @param SampleSizeInBits
- * @param nChannels
- * @param FrameSize
- * @param FrameRate
- * @param isBigEndian
- * @param properties
- */
- public MpegAudioFormat(AudioFormat.Encoding encoding, float nFrequency, int SampleSizeInBits, int nChannels, int FrameSize, float FrameRate, boolean isBigEndian, Map properties)
- {
- super(encoding, nFrequency, SampleSizeInBits, nChannels, FrameSize, FrameRate, isBigEndian, properties);
- }
-
- /**
- * MP3 audio format parameters.
- * Some parameters might be unavailable. So availability test is required before reading any parameter.
- *
- * <br>AudioFormat parameters.
- * <ul>
- * <li><b>bitrate</b> [Integer], bitrate in bits per seconds, average bitrate for VBR enabled stream.
- * <li><b>vbr</b> [Boolean], VBR flag.
- * </ul>
- */
- public Map properties()
- {
- return super.properties();
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/MpegEncoding.java b/songdbj/javazoom/spi/mpeg/sampled/file/MpegEncoding.java
deleted file mode 100644
index 6306d9ec80..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/MpegEncoding.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * MpegEncoding.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file;
-
-import javax.sound.sampled.AudioFormat;
-
-/**
- * Encodings used by the MPEG audio decoder.
- */
-public class MpegEncoding extends AudioFormat.Encoding
-{
- public static final AudioFormat.Encoding MPEG1L1 = new MpegEncoding("MPEG1L1");
- public static final AudioFormat.Encoding MPEG1L2 = new MpegEncoding("MPEG1L2");
- public static final AudioFormat.Encoding MPEG1L3 = new MpegEncoding("MPEG1L3");
- public static final AudioFormat.Encoding MPEG2L1 = new MpegEncoding("MPEG2L1");
- public static final AudioFormat.Encoding MPEG2L2 = new MpegEncoding("MPEG2L2");
- public static final AudioFormat.Encoding MPEG2L3 = new MpegEncoding("MPEG2L3");
- public static final AudioFormat.Encoding MPEG2DOT5L1 = new MpegEncoding("MPEG2DOT5L1");
- public static final AudioFormat.Encoding MPEG2DOT5L2 = new MpegEncoding("MPEG2DOT5L2");
- public static final AudioFormat.Encoding MPEG2DOT5L3 = new MpegEncoding("MPEG2DOT5L3");
-
- public MpegEncoding(String strName)
- {
- super(strName);
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/MpegFileFormatType.java b/songdbj/javazoom/spi/mpeg/sampled/file/MpegFileFormatType.java
deleted file mode 100644
index 2c59ad8621..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/MpegFileFormatType.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * MpegFileFormatType.
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file;
-
-import javax.sound.sampled.AudioFileFormat;
-
-/**
- * FileFormatTypes used by the MPEG audio decoder.
- */
-public class MpegFileFormatType extends AudioFileFormat.Type
-{
- public static final AudioFileFormat.Type MPEG = new MpegFileFormatType("MPEG", "mpeg");
- public static final AudioFileFormat.Type MP3 = new MpegFileFormatType("MP3", "mp3");
-
- public MpegFileFormatType(String strName, String strExtension)
- {
- super(strName, strExtension);
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyInputStream.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyInputStream.java
deleted file mode 100644
index 22aa4439fe..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyInputStream.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * IcyInputStream.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-
-/** An BufferedInputStream that parses Shoutcast's "icy" metadata
- from the stream. Gets headers at the beginning and if the
- "icy-metaint" tag is found, it parses and strips in-stream
- metadata.
- <p>
- <b>The deal with metaint</b>: Icy streams don't try to put
- tags between MP3 frames the way that ID3 does. Instead, it
- requires the client to strip metadata from the stream before
- it hits the decoder. You get an
- <code>icy-metaint</code> name/val in the beginning of the
- stream iff you sent "Icy-Metadata" with value "1" in the
- request headers (SimpleMP3DataSource does this if the
- "parseStreamMetadata" boolean is true). If this is the case
- then the value of icy-metaint is the amount of real data
- between metadata blocks. Each block begins with an int
- indicating how much metadata there is -- the block is this
- value times 16 (it can be, and often is, 0).
- <p>
- Originally thought that "icy" implied Icecast, but this is
- completely wrong -- real Icecast servers, found through
- www.icecast.net and typified by URLs with a trailing directory
- (like CalArts School of Music - http://65.165.174.100:8000/som)
- do not have the "ICY 200 OK" magic string or any of the
- CRLF-separated headers. Apparently, "icy" means "Shoutcast".
- Yep, that's weird.
- @author Chris Adamson, invalidname@mac.com
- */
-public class IcyInputStream
- extends BufferedInputStream
- implements MP3MetadataParser {
-
- public static boolean DEBUG = false;
-
- MP3TagParseSupport tagParseSupport;
- /** inline tags are delimited by ';', also filter out
- null bytes
- */
- protected static final String INLINE_TAG_SEPARATORS = ";\u0000";
- /* looks like icy streams start start with
- ICY 200 OK\r\n
- then the tags are like
- icy-notice1:<BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>\r\n
- icy-notice2:SHOUTcast Distributed Network Audio Server/win32 v1.8.2<BR>\r\n
- icy-name:Core-upt Radio\r\n
- icy-genre:Punk Ska Emo\r\n
- icy-url:http://www.core-uptrecords.com\r\n
- icy-pub:1\r\n
- icy-metaint:8192\r\n
- icy-br:56\r\n
- \r\n (signifies end of headers)
- we only get icy-metaint if the http request that created
- this stream sent the header "icy-metadata:1"
- //
- in in-line metadata, we read a byte that tells us how
- many 16-byte blocks there are (presumably, we still use
- \r\n for the separator... the block is padded out with
- 0x00's that we can ignore)
-
- // when server is full/down/etc, we get the following for
- // one of the notice lines:
- icy-notice2:This server has reached its user limit<BR>
- or
- icy-notice2:The resource requested is currently unavailable<BR>
- */
- /** Tags that have been discovered in the stream.
- */
- HashMap tags;
- /** Buffer for readCRLF line... note this limits lines to
- 1024 chars (I've read that WinAmp barfs at 128, so
- this is generous)
- */
- protected byte[] crlfBuffer = new byte[1024];
- /** value of the "metaint" tag, which tells us how many bytes
- of real data are between the metadata tags. if -1, this stream
- does not have metadata after the header.
- */
- protected int metaint = -1;
- /** how many bytes of real data remain before the next
- block of metadata. Only meaningful if metaint != -1.
- */
- protected int bytesUntilNextMetadata = -1;
- // TODO: comment for constructor
- /** Reads the initial headers of the stream and adds
- tags appropriatly. Gets set up to find, read,
- and strip blocks of in-line metadata if the
- <code>icy-metaint</code> header is found.
- */
- public IcyInputStream(InputStream in) throws IOException {
- super(in);
- tags = new HashMap();
- tagParseSupport = new MP3TagParseSupport();
- // read the initial tags here, including the metaint
- // and set the counter for how far we read until
- // the next metadata block (if any).
- readInitialHeaders();
- IcyTag metaIntTag = (IcyTag) getTag("icy-metaint");
- if (DEBUG) System.out.println("METATAG:"+metaIntTag);
- if (metaIntTag != null) {
- String metaIntString = metaIntTag.getValueAsString();
- try {
- metaint = Integer.parseInt(metaIntString.trim());
- if (DEBUG) System.out.println("METAINT:"+metaint);
- bytesUntilNextMetadata = metaint;
- }
- catch (NumberFormatException nfe) {
- }
- }
- }
-
- /**
- * IcyInputStream constructor for know meta-interval (Icecast 2)
- * @param in
- * @param metaint
- * @throws IOException
- */
- public IcyInputStream(InputStream in, String metaIntString) throws IOException {
- super(in);
- tags = new HashMap();
- tagParseSupport = new MP3TagParseSupport();
- try
- {
- metaint = Integer.parseInt(metaIntString.trim());
- if (DEBUG) System.out.println("METAINT:"+metaint);
- bytesUntilNextMetadata = metaint;
- }
- catch (NumberFormatException nfe) {
- }
- }
-
- /** Assuming we're at the top of the stream, read lines one
- by one until we hit a completely blank \r\n. Parse the
- data as IcyTags.
- */
- protected void readInitialHeaders() throws IOException {
- String line = null;
- while (!((line = readCRLFLine()).equals(""))) {
- int colonIndex = line.indexOf(':');
- // does it have a ':' separator
- if (colonIndex == -1)
- continue;
- IcyTag tag =
- new IcyTag(
- line.substring(0, colonIndex),
- line.substring(colonIndex + 1));
- //System.out.println(tag);
- addTag(tag);
- }
- }
- /** Read everything up to the next CRLF, return it as
- a String.
- */
- protected String readCRLFLine() throws IOException {
- int i = 0;
- for (; i < crlfBuffer.length; i++) {
- byte aByte = (byte) read();
- if (aByte == '\r') {
- // possible end of line
- byte anotherByte = (byte) read();
- i++; // since we read again
- if (anotherByte == '\n') {
- break; // break out of while
- }
- else {
- // oops, not end of line - put these in array
- crlfBuffer[i - 1] = aByte;
- crlfBuffer[i] = anotherByte;
- }
- }
- else {
- // if not \r
- crlfBuffer[i] = aByte;
- }
- } // for
- // get the string from the byte[]. i is 1 too high because of
- // read-ahead in crlf block
- return new String(crlfBuffer, 0, i - 1);
- }
- /** Reads and returns a single byte.
- If the next byte is a metadata block, then that
- block is read, stripped, and parsed before reading
- and returning the first byte after the metadata block.
- */
- public int read() throws IOException {
- if (bytesUntilNextMetadata > 0) {
- bytesUntilNextMetadata--;
- return super.read();
- }
- else if (bytesUntilNextMetadata == 0) {
- // we need to read next metadata block
- readMetadata();
- bytesUntilNextMetadata = metaint - 1;
- // -1 because we read byte on next line
- return super.read();
- }
- else {
- // no metadata in this stream
- return super.read();
- }
- }
- /** Reads a block of bytes. If the next byte is known
- to be a block of metadata, then that is read, parsed,
- and stripped, and then a block of bytes is read and
- returned.
- Otherwise, it may read up to but
- not into the next metadata block if
- <code>bytesUntilNextMetadata &lt; length</code>
- */
- public int read(byte[] buf, int offset, int length) throws IOException {
- // if not on metadata, do the usual read so long as we
- // don't read past metadata
- if (bytesUntilNextMetadata > 0) {
- int adjLength = Math.min(length, bytesUntilNextMetadata);
- int got = super.read(buf, offset, adjLength);
- bytesUntilNextMetadata -= got;
- return got;
- }
- else if (bytesUntilNextMetadata == 0) {
- // read/parse the metadata
- readMetadata();
- // now as above, except that we reset
- // bytesUntilNextMetadata differently
-
- //int adjLength = Math.min(length, bytesUntilNextMetadata);
- //int got = super.read(buf, offset, adjLength);
- //bytesUntilNextMetadata = metaint - got;
-
- // Chop Fix - JavaZOOM (3 lines above seem buggy)
- bytesUntilNextMetadata = metaint;
- int adjLength = Math.min(length, bytesUntilNextMetadata);
- int got = super.read(buf, offset, adjLength);
- bytesUntilNextMetadata -= got;
- // End fix - JavaZOOM
-
-
- return got;
- }
- else {
- // not even reading metadata
- return super.read(buf, offset, length);
- }
- }
- /** trivial <code>return read (buf, 0, buf.length)</code>
- */
- public int read(byte[] buf) throws IOException {
- return read(buf, 0, buf.length);
- }
- /** Read the next segment of metadata. The stream <b>must</b>
- be right on the segment, ie, the next byte to read is
- the metadata block count. The metadata is parsed and
- new tags are added with addTag(), which fires events
- */
- protected void readMetadata() throws IOException {
- int blockCount = super.read();
- if (DEBUG) System.out.println("BLOCKCOUNT:"+blockCount);
- // System.out.println ("blocks to read: " + blockCount);
- int byteCount = (blockCount * 16); // 16 bytes per block
- if (byteCount < 0)
- return; // WTF?!
- byte[] metadataBlock = new byte[byteCount];
- int index = 0;
- // build an array of this metadata
- while (byteCount > 0) {
- int bytesRead = super.read(metadataBlock, index, byteCount);
- index += bytesRead;
- byteCount -= bytesRead;
- }
- // now parse it
- if (blockCount > 0)
- parseInlineIcyTags(metadataBlock);
- } // readMetadata
- /** Parse metadata from an in-stream "block" of bytes, add
- a tag for each one.
- <p>
- Hilariously, the inline data format is totally different
- than the top-of-stream header. For example, here's a
- block I saw on "Final Fantasy Radio":
- <pre>
- StreamTitle='Final Fantasy 8 - Nobuo Uematsu - Blue Fields';StreamUrl='';
- </pre>
- In other words:
- <ol>
- <li>Tags are delimited by semicolons
- <li>Keys/values are delimited by equals-signs
- <li>Values are wrapped in single-quotes
- <li>Key names are in SentenceCase, not lowercase-dashed
- </ol>
- */
- protected void parseInlineIcyTags(byte[] tagBlock) {
- String blockString = new String(tagBlock);
- if (DEBUG) System.out.println("BLOCKSTR:"+blockString);
- StringTokenizer izer =
- new StringTokenizer(blockString, INLINE_TAG_SEPARATORS);
- int i = 0;
- while (izer.hasMoreTokens()) {
- String tagString = izer.nextToken();
- int separatorIdx = tagString.indexOf('=');
- if (separatorIdx == -1)
- continue; // bogus tagString if no '='
- // try to strip single-quotes around value, if present
- int valueStartIdx =
- (tagString.charAt(separatorIdx + 1) == '\'')
- ? separatorIdx + 2
- : separatorIdx + 1;
- int valueEndIdx =
- (tagString.charAt(tagString.length() - 1)) == '\''
- ? tagString.length() - 1
- : tagString.length();
- String name = tagString.substring(0, separatorIdx);
- String value = tagString.substring(valueStartIdx, valueEndIdx);
- // System.out.println (i++ + " " + name + ":" + value);
- IcyTag tag = new IcyTag(name, value);
- addTag(tag);
- }
- }
- /** adds the tag to the HashMap of tags we have encountered
- either in-stream or as headers, replacing any previous
- tag with this name.
- */
- protected void addTag(IcyTag tag) {
- tags.put(tag.getName(), tag);
- // fire this as an event too
- tagParseSupport.fireTagParsed(this, tag);
- }
- /** Get the named tag from the HashMap of headers and
- in-line tags. Null if no such tag has been encountered.
- */
- public MP3Tag getTag(String tagName) {
- return (MP3Tag) tags.get(tagName);
- }
- /** Get all tags (headers or in-stream) encountered thus far.
- */
- public MP3Tag[] getTags() {
- return (MP3Tag[]) tags.values().toArray(new MP3Tag[0]);
- }
- /** Returns a HashMap of all headers and in-stream tags
- parsed so far.
- */
- public HashMap getTagHash() {
- return tags;
- }
- /** Adds a TagParseListener to be notified when this stream
- parses MP3Tags.
- */
- public void addTagParseListener(TagParseListener tpl) {
- tagParseSupport.addTagParseListener(tpl);
- }
- /** Removes a TagParseListener, so it won't be notified when
- this stream parses MP3Tags.
- */
- public void removeTagParseListener(TagParseListener tpl) {
- tagParseSupport.removeTagParseListener(tpl);
- }
- /** Quickie unit-test.
- */
- public static void main(String args[]) {
- byte[] chow = new byte[200];
- if (args.length != 1) {
- //System.out.println("Usage: IcyInputStream <url>");
- return;
- }
- try {
- URL url = new URL(args[0]);
- URLConnection conn = url.openConnection();
- conn.setRequestProperty("Icy-Metadata", "1");
- IcyInputStream icy =
- new IcyInputStream(
- new BufferedInputStream(conn.getInputStream()));
- while (icy.available() > -1) {
- // icy.read();
- icy.read(chow, 0, chow.length);
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyTag.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyTag.java
deleted file mode 100644
index bbe70f1f3c..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/IcyTag.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * IcyTag.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-/**
- * A tag parsed from an icecast tag.
- */
-public class IcyTag extends MP3Tag implements StringableTag {
- /** Create a new tag, from the parsed name and (String) value.
- It looks like all Icecast tags are Strings (safe to assume
- this going forward?)
- */
- public IcyTag(String name, String stringValue) {
- super(name, stringValue);
- }
- // so far as I know, all Icecast tags are strings
- public String getValueAsString() {
- return (String) getValue();
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3MetadataParser.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3MetadataParser.java
deleted file mode 100644
index 81511064b8..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3MetadataParser.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * MP3MetadataParser.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-
-/** An object that fires off TagParseEvents as they are parsed
- from a stream, ServerSocket, or other metadata source
- */
-public interface MP3MetadataParser {
- /** Adds a TagParseListener to be notified when this object
- parses MP3Tags.
- */
- public void addTagParseListener(TagParseListener tpl);
- /** Removes a TagParseListener, so it won't be notified when
- this object parses MP3Tags.
- */
- public void removeTagParseListener(TagParseListener tpl);
- /** Get all tags (headers or in-stream) encountered thusfar.
- This is included in this otherwise Listener-like scheme
- because most standards are a mix of start-of-stream
- metadata tags (like the http headers or the stuff at the
- top of an ice stream) and inline data. Implementations should
- hang onto all tags they parse and provide them with this
- call. Callers should first use this call to get initial
- tags, then subscribe for events as the stream continues.
- */
- public MP3Tag[] getTags();
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3Tag.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3Tag.java
deleted file mode 100644
index b545356240..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3Tag.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * MP3Tag.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-
-/** An individual piece of mp3 metadata, as a name/value pair.
- Abstract just so that subclasses will indicate their
- tagging scheme (Icy, ID3, etc.).
- */
-public abstract class MP3Tag extends Object {
- protected String name;
- protected Object value;
- public MP3Tag(String name, Object value) {
- this.name = name;
- this.value = value;
- }
- public String getName() {
- return name;
- }
- public Object getValue() {
- return value;
- }
- public String toString() {
- return getClass().getName()
- + " -- "
- + getName()
- + ":"
- + getValue().toString();
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3TagParseSupport.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3TagParseSupport.java
deleted file mode 100644
index 1ab6525512..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/MP3TagParseSupport.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * MP3TagParseSupport.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-
-import java.util.ArrayList;
-/**
-*/
-public class MP3TagParseSupport extends Object {
- ArrayList tagParseListeners;
- /** trivial constructor, sets up listeners list.
- */
- public MP3TagParseSupport() {
- super();
- tagParseListeners = new ArrayList();
- }
- /** Adds a TagParseListener to be notified when a stream
- parses MP3Tags.
- */
- public void addTagParseListener(TagParseListener tpl) {
- tagParseListeners.add(tpl);
- }
- /** Removes a TagParseListener, so it won't be notified when
- a stream parses MP3Tags.
- */
- public void removeTagParseListener(TagParseListener tpl) {
- tagParseListeners.add(tpl);
- }
- /** Fires the given event to all registered listeners
- */
- public void fireTagParseEvent(TagParseEvent tpe) {
- for (int i = 0; i < tagParseListeners.size(); i++) {
- TagParseListener l = (TagParseListener) tagParseListeners.get(i);
- l.tagParsed(tpe);
- }
- }
- public void fireTagParsed(Object source, MP3Tag tag) {
- fireTagParseEvent(new TagParseEvent(source, tag));
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/StringableTag.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/StringableTag.java
deleted file mode 100644
index 685c5207f9..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/StringableTag.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * StringableTag.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-
-/** Indicates that the value of a tag is a string, and
- provides a getValueAsString() method to get it.
- Appropriate for tags like artist, title, etc.
- */
-public interface StringableTag {
- /** Return the value of this tag as a string.
- */
- public String getValueAsString();
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseEvent.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseEvent.java
deleted file mode 100644
index 97e9ec1e19..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * TagParseEvent.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-
-import java.util.EventObject;
-/** Event to indicate that an MP3 tag was received through
- some means (parsed in stream, received via UDP, whatever)
- and converted into an MP3Tag object.
- */
-public class TagParseEvent extends EventObject {
- protected MP3Tag tag;
- public TagParseEvent(Object source, MP3Tag tag) {
- super(source);
- this.tag = tag;
- }
- /** Get the tag that was parsed.
- */
- public MP3Tag getTag() {
- return tag;
- }
-}
diff --git a/songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseListener.java b/songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseListener.java
deleted file mode 100644
index a630827297..0000000000
--- a/songdbj/javazoom/spi/mpeg/sampled/file/tag/TagParseListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * TagParseListener.
- *
- * jicyshout : http://sourceforge.net/projects/jicyshout/
- *
- * JavaZOOM : mp3spi@javazoom.net
- * http://www.javazoom.net
- *
- *-----------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *----------------------------------------------------------------------
- */
-
-package javazoom.spi.mpeg.sampled.file.tag;
-
-import java.util.EventListener;
-/** EventListener to be implemented by objects that want to
- get callbacks when MP3 tags are received.
- */
-public interface TagParseListener extends EventListener {
- /** Called when a tag is found (parsed from the stream,
- received via UDP, etc.)
- */
- public void tagParsed(TagParseEvent tpe);
-}
diff --git a/songdbj/javazoom/spi/vorbis/sampled/convert/DecodedVorbisAudioInputStream.java b/songdbj/javazoom/spi/vorbis/sampled/convert/DecodedVorbisAudioInputStream.java
deleted file mode 100644
index b8e8577e13..0000000000
--- a/songdbj/javazoom/spi/vorbis/sampled/convert/DecodedVorbisAudioInputStream.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * DecodedVorbisAudioInputStream
- *
- * JavaZOOM : vorbisspi@javazoom.net
- * http://www.javazoom.net
- *
- * ----------------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- * ----------------------------------------------------------------------------
- */
-
-package javazoom.spi.vorbis.sampled.convert;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-
-import javazoom.spi.PropertiesContainer;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.convert.TAsynchronousFilteredAudioInputStream;
-
-import com.jcraft.jogg.Packet;
-import com.jcraft.jogg.Page;
-import com.jcraft.jogg.StreamState;
-import com.jcraft.jogg.SyncState;
-import com.jcraft.jorbis.Block;
-import com.jcraft.jorbis.Comment;
-import com.jcraft.jorbis.DspState;
-import com.jcraft.jorbis.Info;
-
-/**
- * This class implements the Vorbis decoding.
- */
-public class DecodedVorbisAudioInputStream extends TAsynchronousFilteredAudioInputStream implements PropertiesContainer
-{
- private InputStream oggBitStream_ = null;
-
- private SyncState oggSyncState_ = null;
- private StreamState oggStreamState_ = null;
- private Page oggPage_ = null;
- private Packet oggPacket_ = null;
- private Info vorbisInfo = null;
- private Comment vorbisComment = null;
- private DspState vorbisDspState = null;
- private Block vorbisBlock = null;
-
- static final int playState_NeedHeaders = 0;
- static final int playState_ReadData = 1;
- static final int playState_WriteData = 2;
- static final int playState_Done = 3;
- static final int playState_BufferFull = 4;
- static final int playState_Corrupt = -1;
- private int playState;
-
- private int bufferMultiple_ = 4;
- private int bufferSize_ = bufferMultiple_ * 256 * 2;
- private int convsize = bufferSize_ * 2;
- private byte[] convbuffer = new byte[convsize];
- private byte[] buffer = null;
- private int bytes = 0;
- private float[][][] _pcmf = null;
- private int[] _index = null;
- private int index = 0;
- private int i = 0;
- // bout is now a global so that we can continue from when we have a buffer full.
- int bout = 0;
-
- private HashMap properties = null;
- private long currentBytes = 0;
-
- /**
- * Constructor.
- */
- public DecodedVorbisAudioInputStream(AudioFormat outputFormat, AudioInputStream bitStream)
- {
- super(outputFormat, -1);
- this.oggBitStream_ = bitStream;
- init_jorbis();
- index = 0;
- playState = playState_NeedHeaders;
- properties = new HashMap();
- }
-
- /**
- * Initializes all the jOrbis and jOgg vars that are used for song playback.
- */
- private void init_jorbis()
- {
- oggSyncState_ = new SyncState();
- oggStreamState_ = new StreamState();
- oggPage_ = new Page();
- oggPacket_ = new Packet();
- vorbisInfo = new Info();
- vorbisComment = new Comment();
- vorbisDspState = new DspState();
- vorbisBlock = new Block(vorbisDspState);
- buffer = null;
- bytes = 0;
- currentBytes = 0L;
- oggSyncState_.init();
- }
-
- /**
- * Return dynamic properties.
- *
- * <ul>
- * <li><b>ogg.position.byte</b> [Long], current position in bytes in the stream.
- *</ul>
- */
- public Map properties()
- {
- properties.put("ogg.position.byte",new Long(currentBytes));
- return properties;
- }
- /**
- * Main loop.
- */
- public void execute()
- {
- if(TDebug.TraceAudioConverter)
- {
- switch(playState)
- {
- case playState_NeedHeaders:
- TDebug.out("playState = playState_NeedHeaders");
- break;
- case playState_ReadData:
- TDebug.out("playState = playState_ReadData");
- break;
- case playState_WriteData:
- TDebug.out("playState = playState_WriteData");
- break;
- case playState_Done:
- TDebug.out("playState = playState_Done");
- break;
- case playState_BufferFull:
- TDebug.out("playState = playState_BufferFull");
- break;
- case playState_Corrupt:
- TDebug.out("playState = playState_Corrupt");
- break;
- }
- }
- // This code was developed by the jCraft group, as JOrbisPlayer.java, slightly
- // modified by jOggPlayer developer and adapted by JavaZOOM to suit the JavaSound
- // SPI. Then further modified by Tom Kimpton to correctly play ogg files that
- // would hang the player.
- switch(playState)
- {
- case playState_NeedHeaders:
- try
- {
- // Headers (+ Comments).
- readHeaders();
- }
- catch(IOException ioe)
- {
- playState = playState_Corrupt;
- return;
- }
- playState = playState_ReadData;
- break;
-
- case playState_ReadData:
- int result;
- index = oggSyncState_.buffer(bufferSize_);
- buffer = oggSyncState_.data;
- bytes = readFromStream(buffer, index, bufferSize_);
- if(TDebug.TraceAudioConverter) TDebug.out("More data : " + bytes);
- if(bytes == -1)
- {
- playState = playState_Done;
- if(TDebug.TraceAudioConverter) TDebug.out("Ogg Stream empty. Settings playState to playState_Done.");
- break;
- }
- else
- {
- oggSyncState_.wrote(bytes);
- if(bytes == 0)
- {
- if((oggPage_.eos() != 0) || (oggStreamState_.e_o_s != 0) || (oggPacket_.e_o_s != 0))
- {
- if(TDebug.TraceAudioConverter) TDebug.out("oggSyncState wrote 0 bytes: settings playState to playState_Done.");
- playState = playState_Done;
- }
- if(TDebug.TraceAudioConverter) TDebug.out("oggSyncState wrote 0 bytes: but stream not yet empty.");
- break;
- }
- }
-
- result = oggSyncState_.pageout(oggPage_);
- if(result == 0)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Setting playState to playState_ReadData.");
- playState = playState_ReadData;
- break;
- } // need more data
- if(result == -1)
- { // missing or corrupt data at this page position
- if(TDebug.TraceAudioConverter) TDebug.out("Corrupt or missing data in bitstream; setting playState to playState_ReadData");
- playState = playState_ReadData;
- break;
- }
-
- oggStreamState_.pagein(oggPage_);
-
- if(TDebug.TraceAudioConverter) TDebug.out("Setting playState to playState_WriteData.");
- playState = playState_WriteData;
- break;
-
- case playState_WriteData:
- // Decoding !
- if(TDebug.TraceAudioConverter) TDebug.out("Decoding");
- while(true)
- {
- result = oggStreamState_.packetout(oggPacket_);
- if(result == 0)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Packetout returned 0, going to read state.");
- playState = playState_ReadData;
- break;
- } // need more data
- else if(result == -1)
- {
- // missing or corrupt data at this page position
- // no reason to complain; already complained above
- if(TDebug.TraceAudioConverter) TDebug.out("Corrupt or missing data in packetout bitstream; going to read state...");
- // playState = playState_ReadData;
- // break;
- continue;
- }
- else
- {
- // we have a packet. Decode it
- if(vorbisBlock.synthesis(oggPacket_) == 0)
- { // test for success!
- vorbisDspState.synthesis_blockin(vorbisBlock);
- }
- else
- {
- //if(TDebug.TraceAudioConverter) TDebug.out("vorbisBlock.synthesis() returned !0, going to read state");
- if(TDebug.TraceAudioConverter) TDebug.out("VorbisBlock.synthesis() returned !0, continuing.");
- continue;
- }
-
- outputSamples();
- if(playState == playState_BufferFull)
- return;
-
- } // else result != -1
- } // while(true)
- if(oggPage_.eos() != 0)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Settings playState to playState_Done.");
- playState = playState_Done;
- }
- break;
- case playState_BufferFull:
- continueFromBufferFull();
- break;
-
- case playState_Corrupt:
- if(TDebug.TraceAudioConverter) TDebug.out("Corrupt Song.");
- // drop through to playState_Done...
- case playState_Done:
- oggStreamState_.clear();
- vorbisBlock.clear();
- vorbisDspState.clear();
- vorbisInfo.clear();
- oggSyncState_.clear();
- if(TDebug.TraceAudioConverter) TDebug.out("Done Song.");
- try
- {
- if(oggBitStream_ != null)
- {
- oggBitStream_.close();
- }
- getCircularBuffer().close();
- }
- catch(Exception e)
- {
- if(TDebug.TraceAudioConverter) TDebug.out(e.getMessage());
- }
- break;
- } // switch
- }
-
- /**
- * This routine was extracted so that when the output buffer fills up,
- * we can break out of the loop, let the music channel drain, then
- * continue from where we were.
- */
- private void outputSamples()
- {
- int samples;
- while((samples = vorbisDspState.synthesis_pcmout(_pcmf, _index)) > 0)
- {
- float[][] pcmf = _pcmf[0];
- bout = (samples < convsize ? samples : convsize);
- double fVal = 0.0;
- // convert doubles to 16 bit signed ints (host order) and
- // interleave
- for(i = 0; i < vorbisInfo.channels; i++)
- {
- int pointer = i * 2;
- //int ptr=i;
- int mono = _index[i];
- for(int j = 0; j < bout; j++)
- {
- fVal = pcmf[i][mono + j] * 32767.;
- int val = (int) (fVal);
- if(val > 32767)
- {
- val = 32767;
- }
- if(val < -32768)
- {
- val = -32768;
- }
- if(val < 0)
- {
- val = val | 0x8000;
- }
- convbuffer[pointer] = (byte) (val);
- convbuffer[pointer + 1] = (byte) (val >>> 8);
- pointer += 2 * (vorbisInfo.channels);
- }
- }
- if(TDebug.TraceAudioConverter) TDebug.out("about to write: " + 2 * vorbisInfo.channels * bout);
- if(getCircularBuffer().availableWrite() < 2 * vorbisInfo.channels * bout)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Too much data in this data packet, better return, let the channel drain, and try again...");
- playState = playState_BufferFull;
- return;
- }
- getCircularBuffer().write(convbuffer, 0, 2 * vorbisInfo.channels * bout);
- if(bytes < bufferSize_)
- if(TDebug.TraceAudioConverter) TDebug.out("Finished with final buffer of music?");
- if(vorbisDspState.synthesis_read(bout) != 0)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("VorbisDspState.synthesis_read returned -1.");
- }
- } // while(samples...)
- playState = playState_ReadData;
- }
-
- private void continueFromBufferFull()
- {
- if(getCircularBuffer().availableWrite() < 2 * vorbisInfo.channels * bout)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Too much data in this data packet, better return, let the channel drain, and try again...");
- // Don't change play state.
- return;
- }
- getCircularBuffer().write(convbuffer, 0, 2 * vorbisInfo.channels * bout);
- // Don't change play state. Let outputSamples change play state, if necessary.
- outputSamples();
- }
- /**
- * Reads headers and comments.
- */
- private void readHeaders() throws IOException
- {
- if(TDebug.TraceAudioConverter) TDebug.out("readHeaders(");
- index = oggSyncState_.buffer(bufferSize_);
- buffer = oggSyncState_.data;
- bytes = readFromStream(buffer, index, bufferSize_);
- if(bytes == -1)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Cannot get any data from selected Ogg bitstream.");
- throw new IOException("Cannot get any data from selected Ogg bitstream.");
- }
- oggSyncState_.wrote(bytes);
- if(oggSyncState_.pageout(oggPage_) != 1)
- {
- if(bytes < bufferSize_)
- {
- throw new IOException("EOF");
- }
- if(TDebug.TraceAudioConverter) TDebug.out("Input does not appear to be an Ogg bitstream.");
- throw new IOException("Input does not appear to be an Ogg bitstream.");
- }
- oggStreamState_.init(oggPage_.serialno());
- vorbisInfo.init();
- vorbisComment.init();
- if(oggStreamState_.pagein(oggPage_) < 0)
- {
- // error; stream version mismatch perhaps
- if(TDebug.TraceAudioConverter) TDebug.out("Error reading first page of Ogg bitstream data.");
- throw new IOException("Error reading first page of Ogg bitstream data.");
- }
- if(oggStreamState_.packetout(oggPacket_) != 1)
- {
- // no page? must not be vorbis
- if(TDebug.TraceAudioConverter) TDebug.out("Error reading initial header packet.");
- throw new IOException("Error reading initial header packet.");
- }
- if(vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_) < 0)
- {
- // error case; not a vorbis header
- if(TDebug.TraceAudioConverter) TDebug.out("This Ogg bitstream does not contain Vorbis audio data.");
- throw new IOException("This Ogg bitstream does not contain Vorbis audio data.");
- }
- //int i = 0;
- i = 0;
- while(i < 2)
- {
- while(i < 2)
- {
- int result = oggSyncState_.pageout(oggPage_);
- if(result == 0)
- {
- break;
- } // Need more data
- if(result == 1)
- {
- oggStreamState_.pagein(oggPage_);
- while(i < 2)
- {
- result = oggStreamState_.packetout(oggPacket_);
- if(result == 0)
- {
- break;
- }
- if(result == -1)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Corrupt secondary header. Exiting.");
- throw new IOException("Corrupt secondary header. Exiting.");
- }
- vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_);
- i++;
- }
- }
- }
- index = oggSyncState_.buffer(bufferSize_);
- buffer = oggSyncState_.data;
- bytes = readFromStream(buffer, index, bufferSize_);
- if(bytes == -1)
- {
- break;
- }
- if(bytes == 0 && i < 2)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("End of file before finding all Vorbis headers!");
- throw new IOException("End of file before finding all Vorbis headers!");
- }
- oggSyncState_.wrote(bytes);
- }
-
- byte[][] ptr = vorbisComment.user_comments;
- String currComment = "";
-
- for(int j = 0; j < ptr.length; j++)
- {
- if(ptr[j] == null)
- {
- break;
- }
- currComment = (new String(ptr[j], 0, ptr[j].length - 1)).trim();
- if(TDebug.TraceAudioConverter) TDebug.out("Comment: " + currComment);
- }
- convsize = bufferSize_ / vorbisInfo.channels;
- vorbisDspState.synthesis_init(vorbisInfo);
- vorbisBlock.init(vorbisDspState);
- _pcmf = new float[1][][];
- _index = new int[vorbisInfo.channels];
- }
-
- /**
- * Reads from the oggBitStream_ a specified number of Bytes(bufferSize_) worth
- * starting at index and puts them in the specified buffer[].
- *
- * @param buffer
- * @param index
- * @param bufferSize_
- * @return the number of bytes read or -1 if error.
- */
- private int readFromStream(byte[] buffer, int index, int bufferSize_)
- {
- int bytes = 0;
- try
- {
- bytes = oggBitStream_.read(buffer, index, bufferSize_);
- }
- catch(Exception e)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Cannot Read Selected Song");
- bytes = -1;
- }
- currentBytes = currentBytes + bytes;
- return bytes;
- }
-
- /**
- * Close the stream.
- */
- public void close() throws IOException
- {
- super.close();
- oggBitStream_.close();
- }
-}
diff --git a/songdbj/javazoom/spi/vorbis/sampled/convert/VorbisFormatConversionProvider.java b/songdbj/javazoom/spi/vorbis/sampled/convert/VorbisFormatConversionProvider.java
deleted file mode 100644
index d1321f2590..0000000000
--- a/songdbj/javazoom/spi/vorbis/sampled/convert/VorbisFormatConversionProvider.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * VorbisFormatConversionProvider.
- *
- * JavaZOOM : vorbisspi@javazoom.net
- * http://www.javazoom.net
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-package javazoom.spi.vorbis.sampled.convert;
-
-import java.util.Arrays;
-import javazoom.spi.vorbis.sampled.file.VorbisEncoding;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-
-import org.tritonus.share.sampled.convert.TMatrixFormatConversionProvider;
-
-/**
- * ConversionProvider for VORBIS files.
- */
-public class VorbisFormatConversionProvider extends TMatrixFormatConversionProvider
-{
- private static final AudioFormat[] INPUT_FORMATS =
- {
- new AudioFormat(VorbisEncoding.VORBISENC, 32000.0F, -1, 1, -1, -1, false), // 0
- new AudioFormat(VorbisEncoding.VORBISENC, 32000.0F, -1, 2, -1, -1, false), // 1
- new AudioFormat(VorbisEncoding.VORBISENC, 44100.0F, -1, 1, -1, -1, false), // 2
- new AudioFormat(VorbisEncoding.VORBISENC, 44100.0F, -1, 2, -1, -1, false), // 3
- new AudioFormat(VorbisEncoding.VORBISENC, 48000.0F, -1, 1, -1, -1, false), // 4
- new AudioFormat(VorbisEncoding.VORBISENC, 48000.0F, -1, 2, -1, -1, false), // 5
-
- new AudioFormat(VorbisEncoding.VORBISENC, 16000.0F, -1, 1, -1, -1, false), // 18
- new AudioFormat(VorbisEncoding.VORBISENC, 16000.0F, -1, 2, -1, -1, false), // 19
- new AudioFormat(VorbisEncoding.VORBISENC, 22050.0F, -1, 1, -1, -1, false), // 20
- new AudioFormat(VorbisEncoding.VORBISENC, 22050.0F, -1, 2, -1, -1, false), // 21
- new AudioFormat(VorbisEncoding.VORBISENC, 24000.0F, -1, 1, -1, -1, false), // 22
- new AudioFormat(VorbisEncoding.VORBISENC, 24000.0F, -1, 2, -1, -1, false), // 23
-
- new AudioFormat(VorbisEncoding.VORBISENC, 8000.0F, -1, 1, -1, -1, false), // 36
- new AudioFormat(VorbisEncoding.VORBISENC, 8000.0F, -1, 2, -1, -1, false), // 37
- new AudioFormat(VorbisEncoding.VORBISENC, 11025.0F, -1, 1, -1, -1, false), // 38
- new AudioFormat(VorbisEncoding.VORBISENC, 11025.0F, -1, 2, -1, -1, false), // 39
- new AudioFormat(VorbisEncoding.VORBISENC, 12000.0F, -1, 1, -1, -1, false), // 40
- new AudioFormat(VorbisEncoding.VORBISENC, 12000.0F, -1, 2, -1, -1, false), // 41
- };
-
- private static final AudioFormat[] OUTPUT_FORMATS =
- {
- new AudioFormat(8000.0F, 16, 1, true, false), // 0
- new AudioFormat(8000.0F, 16, 1, true, true), // 1
- new AudioFormat(8000.0F, 16, 2, true, false), // 2
- new AudioFormat(8000.0F, 16, 2, true, true), // 3
- /* 24 and 32 bit not yet possible
- new AudioFormat(8000.0F, 24, 1, true, false),
- new AudioFormat(8000.0F, 24, 1, true, true),
- new AudioFormat(8000.0F, 24, 2, true, false),
- new AudioFormat(8000.0F, 24, 2, true, true),
- new AudioFormat(8000.0F, 32, 1, true, false),
- new AudioFormat(8000.0F, 32, 1, true, true),
- new AudioFormat(8000.0F, 32, 2, true, false),
- new AudioFormat(8000.0F, 32, 2, true, true),
- */
- new AudioFormat(11025.0F, 16, 1, true, false), // 4
- new AudioFormat(11025.0F, 16, 1, true, true), // 5
- new AudioFormat(11025.0F, 16, 2, true, false), // 6
- new AudioFormat(11025.0F, 16, 2, true, true), // 7
- /* 24 and 32 bit not yet possible
- new AudioFormat(11025.0F, 24, 1, true, false),
- new AudioFormat(11025.0F, 24, 1, true, true),
- new AudioFormat(11025.0F, 24, 2, true, false),
- new AudioFormat(11025.0F, 24, 2, true, true),
- new AudioFormat(11025.0F, 32, 1, true, false),
- new AudioFormat(11025.0F, 32, 1, true, true),
- new AudioFormat(11025.0F, 32, 2, true, false),
- new AudioFormat(11025.0F, 32, 2, true, true),
- */
- new AudioFormat(12000.0F, 16, 1, true, false), // 8
- new AudioFormat(12000.0F, 16, 1, true, true), // 9
- new AudioFormat(12000.0F, 16, 2, true, false), // 10
- new AudioFormat(12000.0F, 16, 2, true, true), // 11
- /* 24 and 32 bit not yet possible
- new AudioFormat(12000.0F, 24, 1, true, false),
- new AudioFormat(12000.0F, 24, 1, true, true),
- new AudioFormat(12000.0F, 24, 2, true, false),
- new AudioFormat(12000.0F, 24, 2, true, true),
- new AudioFormat(12000.0F, 32, 1, true, false),
- new AudioFormat(12000.0F, 32, 1, true, true),
- new AudioFormat(12000.0F, 32, 2, true, false),
- new AudioFormat(12000.0F, 32, 2, true, true),
- */
- new AudioFormat(16000.0F, 16, 1, true, false), // 12
- new AudioFormat(16000.0F, 16, 1, true, true), // 13
- new AudioFormat(16000.0F, 16, 2, true, false), // 14
- new AudioFormat(16000.0F, 16, 2, true, true), // 15
- /* 24 and 32 bit not yet possible
- new AudioFormat(16000.0F, 24, 1, true, false),
- new AudioFormat(16000.0F, 24, 1, true, true),
- new AudioFormat(16000.0F, 24, 2, true, false),
- new AudioFormat(16000.0F, 24, 2, true, true),
- new AudioFormat(16000.0F, 32, 1, true, false),
- new AudioFormat(16000.0F, 32, 1, true, true),
- new AudioFormat(16000.0F, 32, 2, true, false),
- new AudioFormat(16000.0F, 32, 2, true, true),
- */
- new AudioFormat(22050.0F, 16, 1, true, false), // 16
- new AudioFormat(22050.0F, 16, 1, true, true), // 17
- new AudioFormat(22050.0F, 16, 2, true, false), // 18
- new AudioFormat(22050.0F, 16, 2, true, true), // 19
- /* 24 and 32 bit not yet possible
- new AudioFormat(22050.0F, 24, 1, true, false),
- new AudioFormat(22050.0F, 24, 1, true, true),
- new AudioFormat(22050.0F, 24, 2, true, false),
- new AudioFormat(22050.0F, 24, 2, true, true),
- new AudioFormat(22050.0F, 32, 1, true, false),
- new AudioFormat(22050.0F, 32, 1, true, true),
- new AudioFormat(22050.0F, 32, 2, true, false),
- new AudioFormat(22050.0F, 32, 2, true, true),
- */
- new AudioFormat(24000.0F, 16, 1, true, false), // 20
- new AudioFormat(24000.0F, 16, 1, true, true), // 21
- new AudioFormat(24000.0F, 16, 2, true, false), // 22
- new AudioFormat(24000.0F, 16, 2, true, true), // 23
- /* 24 and 32 bit not yet possible
- new AudioFormat(24000.0F, 24, 1, true, false),
- new AudioFormat(24000.0F, 24, 1, true, true),
- new AudioFormat(24000.0F, 24, 2, true, false),
- new AudioFormat(24000.0F, 24, 2, true, true),
- new AudioFormat(24000.0F, 32, 1, true, false),
- new AudioFormat(24000.0F, 32, 1, true, true),
- new AudioFormat(24000.0F, 32, 2, true, false),
- new AudioFormat(24000.0F, 32, 2, true, true),
- */
- new AudioFormat(32000.0F, 16, 1, true, false), // 24
- new AudioFormat(32000.0F, 16, 1, true, true), // 25
- new AudioFormat(32000.0F, 16, 2, true, false), // 26
- new AudioFormat(32000.0F, 16, 2, true, true), // 27
- /* 24 and 32 bit not yet possible
- new AudioFormat(32000.0F, 24, 1, true, false),
- new AudioFormat(32000.0F, 24, 1, true, true),
- new AudioFormat(32000.0F, 24, 2, true, false),
- new AudioFormat(32000.0F, 24, 2, true, true),
- new AudioFormat(32000.0F, 32, 1, true, false),
- new AudioFormat(32000.0F, 32, 1, true, true),
- new AudioFormat(32000.0F, 32, 2, true, false),
- new AudioFormat(32000.0F, 32, 2, true, true),
- */
- new AudioFormat(44100.0F, 16, 1, true, false), // 28
- new AudioFormat(44100.0F, 16, 1, true, true), // 29
- new AudioFormat(44100.0F, 16, 2, true, false), // 30
- new AudioFormat(44100.0F, 16, 2, true, true), // 31
- /* 24 and 32 bit not yet possible
- new AudioFormat(44100.0F, 24, 1, true, false),
- new AudioFormat(44100.0F, 24, 1, true, true),
- new AudioFormat(44100.0F, 24, 2, true, false),
- new AudioFormat(44100.0F, 24, 2, true, true),
- new AudioFormat(44100.0F, 32, 1, true, false),
- new AudioFormat(44100.0F, 32, 1, true, true),
- new AudioFormat(44100.0F, 32, 2, true, false),
- new AudioFormat(44100.0F, 32, 2, true, true),
- */
- new AudioFormat(48000.0F, 16, 1, true, false), // 32
- new AudioFormat(48000.0F, 16, 1, true, true), // 33
- new AudioFormat(48000.0F, 16, 2, true, false), // 34
- new AudioFormat(48000.0F, 16, 2, true, true), // 35
- /* 24 and 32 bit not yet possible
- new AudioFormat(48000.0F, 24, 1, true, false),
- new AudioFormat(48000.0F, 24, 1, true, true),
- new AudioFormat(48000.0F, 24, 2, true, false),
- new AudioFormat(48000.0F, 24, 2, true, true),
- new AudioFormat(48000.0F, 32, 1, true, false),
- new AudioFormat(48000.0F, 32, 1, true, true),
- new AudioFormat(48000.0F, 32, 2, true, false),
- new AudioFormat(48000.0F, 32, 2, true, true),
- */
- };
-
- private static final boolean t = true;
- private static final boolean f = false;
-
- /*
- * One row for each source format.
- */
- private static final boolean[][] CONVERSIONS =
- {
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,t,t,f,f,f,f, f,f,f,f,f,f}, // 0
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,t,t,f,f, f,f,f,f,f,f}, // 1
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,t,t, f,f,f,f,f,f}, // 2
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, t,t,f,f,f,f}, // 3
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,t,t,f,f}, // 4
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,t,t}, // 5
-
- {f,f,f,f,f,f,f,f,f,f, f,f,t,t,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 18
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,t,t,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 19
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,t,t,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 20
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,t,t, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 21
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, t,t,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 22
- {f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,t,t,f,f,f,f,f,f, f,f,f,f,f,f}, // 23
-
- {t,t,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 36
- {f,f,t,t,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 37
- {f,f,f,f,t,t,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 38
- {f,f,f,f,f,f,t,t,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 39
- {f,f,f,f,f,f,f,f,t,t, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 40
- {f,f,f,f,f,f,f,f,f,f, t,t,f,f,f,f,f,f,f,f, f,f,f,f,f,f,f,f,f,f, f,f,f,f,f,f}, // 41
-
- };
-
- /**
- * Constructor.
- */
- public VorbisFormatConversionProvider()
- {
- super(Arrays.asList(INPUT_FORMATS), Arrays.asList(OUTPUT_FORMATS), CONVERSIONS);
- }
-
- /**
- * Returns converted AudioInputStream.
- */
- public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream)
- {
- if (isConversionSupported(targetFormat, audioInputStream.getFormat()))
- {
- return new DecodedVorbisAudioInputStream(targetFormat, audioInputStream);
- }
- else
- {
- throw new IllegalArgumentException("conversion not supported");
- }
- }
-}
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileFormat.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileFormat.java
deleted file mode 100644
index 28b7c92a2a..0000000000
--- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileFormat.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * VorbisAudioFileFormat.
- *
- * JavaZOOM : vorbisspi@javazoom.net
- * http://www.javazoom.net
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-package javazoom.spi.vorbis.sampled.file;
-
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-
-/**
- * @author JavaZOOM
- */
-public class VorbisAudioFileFormat extends TAudioFileFormat
-{
- /**
- * Contructor.
- * @param type
- * @param audioFormat
- * @param nLengthInFrames
- * @param nLengthInBytes
- */
- public VorbisAudioFileFormat(Type type, AudioFormat audioFormat, int nLengthInFrames, int nLengthInBytes, Map properties)
- {
- super(type, audioFormat, nLengthInFrames, nLengthInBytes, properties);
- }
-
- /**
- * Ogg Vorbis audio file format parameters.
- * Some parameters might be unavailable. So availability test is required before reading any parameter.
- *
- * <br>AudioFileFormat parameters.
- * <ul>
- * <li><b>duration</b> [Long], duration in microseconds.
- * <li><b>title</b> [String], Title of the stream.
- * <li><b>author</b> [String], Name of the artist of the stream.
- * <li><b>album</b> [String], Name of the album of the stream.
- * <li><b>date</b> [String], The date (year) of the recording or release of the stream.
- * <li><b>copyright</b> [String], Copyright message of the stream.
- * <li><b>comment</b> [String], Comment of the stream.
- * </ul>
- * <br>Ogg Vorbis parameters.
- * <ul>
- * <li><b>ogg.length.bytes</b> [Integer], length in bytes.
- * <li><b>ogg.bitrate.min.bps</b> [Integer], minimum bitrate.
- * <li><b>ogg.bitrate.nominal.bps</b> [Integer], nominal bitrate.
- * <li><b>ogg.bitrate.max.bps</b> [Integer], maximum bitrate.
- * <li><b>ogg.channels</b> [Integer], number of channels 1 : mono, 2 : stereo.
- * <li><b>ogg.frequency.hz</b> [Integer], sampling rate in hz.
- * <li><b>ogg.version</b> [Integer], version.
- * <li><b>ogg.serial</b> [Integer], serial number.
- * <li><b>ogg.comment.track</b> [String], track number.
- * <li><b>ogg.comment.genre</b> [String], genre field.
- * <li><b>ogg.comment.encodedby</b> [String], encoded by field.
- * <li><b>ogg.comment.ext</b> [String], extended comments (indexed):
- * <br>For instance :
- * <br>ogg.comment.ext.1=Something
- * <br>ogg.comment.ext.2=Another comment
- * </ul>
- */
- public Map properties()
- {
- return super.properties();
- }
-}
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileReader.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileReader.java
deleted file mode 100644
index 40bc9cadee..0000000000
--- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFileReader.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * VorbisAudioFileReader.
- *
- * JavaZOOM : vorbisspi@javazoom.net
- * http://www.javazoom.net
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-package javazoom.spi.vorbis.sampled.file;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-import com.jcraft.jogg.Packet;
-import com.jcraft.jogg.Page;
-import com.jcraft.jogg.StreamState;
-import com.jcraft.jogg.SyncState;
-import com.jcraft.jorbis.Block;
-import com.jcraft.jorbis.Comment;
-import com.jcraft.jorbis.DspState;
-import com.jcraft.jorbis.Info;
-import com.jcraft.jorbis.JOrbisException;
-import com.jcraft.jorbis.VorbisFile;
-
-/**
- * This class implements the AudioFileReader class and provides an
- * Ogg Vorbis file reader for use with the Java Sound Service Provider Interface.
- */
-public class VorbisAudioFileReader extends TAudioFileReader
-{
- private SyncState oggSyncState_ = null;
- private StreamState oggStreamState_ = null;
- private Page oggPage_ = null;
- private Packet oggPacket_ = null;
- private Info vorbisInfo = null;
- private Comment vorbisComment = null;
- private DspState vorbisDspState = null;
- private Block vorbisBlock = null;
- private int bufferMultiple_ = 4;
- private int bufferSize_ = bufferMultiple_ * 256 * 2;
- private int convsize = bufferSize_ * 2;
- private byte[] convbuffer = new byte[convsize];
- private byte[] buffer = null;
- private int bytes = 0;
- private int rate = 0;
- private int channels = 0;
-
- private int index = 0;
- private InputStream oggBitStream_ = null;
-
- private static final int INITAL_READ_LENGTH = 64000;
- private static final int MARK_LIMIT = INITAL_READ_LENGTH + 1;
-
- public VorbisAudioFileReader()
- {
- super(MARK_LIMIT, true);
- }
-
- /**
- * Return the AudioFileFormat from the given file.
- */
- public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioFileFormat(File file)");
- InputStream inputStream = null;
- try
- {
- inputStream = new BufferedInputStream(new FileInputStream(file));
- inputStream.mark(MARK_LIMIT);
- AudioFileFormat aff = getAudioFileFormat(inputStream);
- inputStream.reset();
- // Get Vorbis file info such as length in seconds.
- VorbisFile vf = new VorbisFile(file.getAbsolutePath());
- return getAudioFileFormat(inputStream,(int) file.length(), (int) Math.round((vf.time_total(-1))*1000));
- }
- catch (JOrbisException e)
- {
- throw new IOException(e.getMessage());
- }
- finally
- {
- if (inputStream != null) inputStream.close();
- }
- }
-
- /**
- * Return the AudioFileFormat from the given URL.
- */
- public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioFileFormat(URL url)");
- InputStream inputStream = url.openStream();
- try
- {
- return getAudioFileFormat(inputStream);
- }
- finally
- {
- if (inputStream != null) inputStream.close();
- }
- }
-
- /**
- * Return the AudioFileFormat from the given InputStream.
- */
- public AudioFileFormat getAudioFileFormat(InputStream inputStream) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioFileFormat(InputStream inputStream)");
- try
- {
- if (!inputStream.markSupported()) inputStream = new BufferedInputStream(inputStream);
- inputStream.mark(MARK_LIMIT);
- return getAudioFileFormat(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED);
- }
- finally
- {
- inputStream.reset();
- }
- }
-
- /**
- * Return the AudioFileFormat from the given InputStream and length in bytes.
- */
- public AudioFileFormat getAudioFileFormat(InputStream inputStream, long medialength) throws UnsupportedAudioFileException, IOException
- {
- return getAudioFileFormat(inputStream, (int) medialength, AudioSystem.NOT_SPECIFIED);
- }
-
-
- /**
- * Return the AudioFileFormat from the given InputStream, length in bytes and length in milliseconds.
- */
- protected AudioFileFormat getAudioFileFormat(InputStream bitStream, int mediaLength, int totalms) throws UnsupportedAudioFileException, IOException
- {
- HashMap aff_properties = new HashMap();
- HashMap af_properties = new HashMap();
- if (totalms == AudioSystem.NOT_SPECIFIED)
- {
- totalms = 0;
- }
- if (totalms <= 0)
- {
- totalms = 0;
- }
- else
- {
- aff_properties.put("duration",new Long(totalms*1000));
- }
- oggBitStream_ = bitStream;
- init_jorbis();
- index = 0;
- try
- {
- readHeaders(aff_properties, af_properties);
- }
- catch (IOException ioe)
- {
- if (TDebug.TraceAudioFileReader)
- {
- TDebug.out(ioe.getMessage());
- }
- throw new UnsupportedAudioFileException(ioe.getMessage());
- }
-
- String dmp = vorbisInfo.toString();
- if (TDebug.TraceAudioFileReader)
- {
- TDebug.out(dmp);
- }
- int ind = dmp.lastIndexOf("bitrate:");
- int minbitrate = -1;
- int nominalbitrate = -1;
- int maxbitrate = -1;
- if (ind != -1)
- {
- dmp = dmp.substring(ind + 8, dmp.length());
- StringTokenizer st = new StringTokenizer(dmp, ",");
- if (st.hasMoreTokens())
- {
- minbitrate = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens())
- {
- nominalbitrate = Integer.parseInt(st.nextToken());
- }
- if (st.hasMoreTokens())
- {
- maxbitrate = Integer.parseInt(st.nextToken());
- }
- }
- if (nominalbitrate > 0) af_properties.put("bitrate",new Integer(nominalbitrate));
- af_properties.put("vbr",new Boolean(true));
-
- if (minbitrate > 0) aff_properties.put("ogg.bitrate.min.bps",new Integer(minbitrate));
- if (maxbitrate > 0) aff_properties.put("ogg.bitrate.max.bps",new Integer(maxbitrate));
- if (nominalbitrate > 0) aff_properties.put("ogg.bitrate.nominal.bps",new Integer(nominalbitrate));
- if (vorbisInfo.channels > 0) aff_properties.put("ogg.channels",new Integer(vorbisInfo.channels));
- if (vorbisInfo.rate > 0) aff_properties.put("ogg.frequency.hz",new Integer(vorbisInfo.rate));
- if (mediaLength > 0) aff_properties.put("ogg.length.bytes",new Integer(mediaLength));
- aff_properties.put("ogg.version",new Integer(vorbisInfo.version));
-
- AudioFormat.Encoding encoding = VorbisEncoding.VORBISENC;
- AudioFormat format = new VorbisAudioFormat(encoding, vorbisInfo.rate, AudioSystem.NOT_SPECIFIED, vorbisInfo.channels, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, true,af_properties);
- AudioFileFormat.Type type = VorbisFileFormatType.OGG;
- return new VorbisAudioFileFormat(VorbisFileFormatType.OGG, format, AudioSystem.NOT_SPECIFIED, mediaLength,aff_properties);
- }
-
- /**
- * Return the AudioInputStream from the given InputStream.
- */
- public AudioInputStream getAudioInputStream(InputStream inputStream) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(InputStream inputStream)");
- return getAudioInputStream(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED);
- }
-
- /**
- * Return the AudioInputStream from the given InputStream.
- */
- public AudioInputStream getAudioInputStream(InputStream inputStream, int medialength, int totalms) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(InputStream inputStreamint medialength, int totalms)");
- try
- {
- if (!inputStream.markSupported()) inputStream = new BufferedInputStream(inputStream);
- inputStream.mark(MARK_LIMIT);
- AudioFileFormat audioFileFormat = getAudioFileFormat(inputStream, medialength, totalms);
- inputStream.reset();
- return new AudioInputStream(inputStream, audioFileFormat.getFormat(), audioFileFormat.getFrameLength());
- }
- catch (UnsupportedAudioFileException e)
- {
- inputStream.reset();
- throw e;
- }
- catch (IOException e)
- {
- inputStream.reset();
- throw e;
- }
- }
-
- /**
- * Return the AudioInputStream from the given File.
- */
- public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(File file)");
- InputStream inputStream = new FileInputStream(file);
- try
- {
- return getAudioInputStream(inputStream);
- }
- catch (UnsupportedAudioFileException e)
- {
- if (inputStream != null) inputStream.close();
- throw e;
- }
- catch (IOException e)
- {
- if (inputStream != null) inputStream.close();
- throw e;
- }
- }
-
- /**
- * Return the AudioInputStream from the given URL.
- */
- public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(URL url)");
- InputStream inputStream = url.openStream();
- try
- {
- return getAudioInputStream(inputStream);
- }
- catch (UnsupportedAudioFileException e)
- {
- if (inputStream != null) inputStream.close();
- throw e;
- }
- catch (IOException e)
- {
- if (inputStream != null) inputStream.close();
- throw e;
- }
- }
-
- /**
- * Reads headers and comments.
- */
- private void readHeaders(HashMap aff_properties, HashMap af_properties) throws IOException
- {
- if(TDebug.TraceAudioConverter) TDebug.out("readHeaders(");
- index = oggSyncState_.buffer(bufferSize_);
- buffer = oggSyncState_.data;
- bytes = readFromStream(buffer, index, bufferSize_);
- if(bytes == -1)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Cannot get any data from selected Ogg bitstream.");
- throw new IOException("Cannot get any data from selected Ogg bitstream.");
- }
- oggSyncState_.wrote(bytes);
- if(oggSyncState_.pageout(oggPage_) != 1)
- {
- if(bytes < bufferSize_)
- {
- throw new IOException("EOF");
- }
- if(TDebug.TraceAudioConverter) TDebug.out("Input does not appear to be an Ogg bitstream.");
- throw new IOException("Input does not appear to be an Ogg bitstream.");
- }
- oggStreamState_.init(oggPage_.serialno());
- vorbisInfo.init();
- vorbisComment.init();
- aff_properties.put("ogg.serial",new Integer(oggPage_.serialno()));
- if(oggStreamState_.pagein(oggPage_) < 0)
- {
- // error; stream version mismatch perhaps
- if(TDebug.TraceAudioConverter) TDebug.out("Error reading first page of Ogg bitstream data.");
- throw new IOException("Error reading first page of Ogg bitstream data.");
- }
- if(oggStreamState_.packetout(oggPacket_) != 1)
- {
- // no page? must not be vorbis
- if(TDebug.TraceAudioConverter) TDebug.out("Error reading initial header packet.");
- throw new IOException("Error reading initial header packet.");
- }
- if(vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_) < 0)
- {
- // error case; not a vorbis header
- if(TDebug.TraceAudioConverter) TDebug.out("This Ogg bitstream does not contain Vorbis audio data.");
- throw new IOException("This Ogg bitstream does not contain Vorbis audio data.");
- }
- int i = 0;
- while(i < 2)
- {
- while(i < 2)
- {
- int result = oggSyncState_.pageout(oggPage_);
- if(result == 0)
- {
- break;
- } // Need more data
- if(result == 1)
- {
- oggStreamState_.pagein(oggPage_);
- while(i < 2)
- {
- result = oggStreamState_.packetout(oggPacket_);
- if(result == 0)
- {
- break;
- }
- if(result == -1)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("Corrupt secondary header. Exiting.");
- throw new IOException("Corrupt secondary header. Exiting.");
- }
- vorbisInfo.synthesis_headerin(vorbisComment, oggPacket_);
- i++;
- }
- }
- }
- index = oggSyncState_.buffer(bufferSize_);
- buffer = oggSyncState_.data;
- bytes = readFromStream(buffer, index, bufferSize_);
- if(bytes == -1)
- {
- break;
- }
- if(bytes == 0 && i < 2)
- {
- if(TDebug.TraceAudioConverter) TDebug.out("End of file before finding all Vorbis headers!");
- throw new IOException("End of file before finding all Vorbis headers!");
- }
- oggSyncState_.wrote(bytes);
- }
- // Read Ogg Vorbis comments.
- byte[][] ptr = vorbisComment.user_comments;
- String currComment = "";
- int c = 0;
- for(int j = 0; j < ptr.length; j++)
- {
- if(ptr[j] == null)
- {
- break;
- }
- currComment = (new String(ptr[j], 0, ptr[j].length - 1)).trim();
- if(TDebug.TraceAudioConverter) TDebug.out(currComment);
- if (currComment.toLowerCase().startsWith("artist"))
- {
- aff_properties.put("author",currComment.substring(7));
- }
- else if (currComment.toLowerCase().startsWith("title"))
- {
- aff_properties.put("title",currComment.substring(6));
- }
- else if (currComment.toLowerCase().startsWith("album"))
- {
- aff_properties.put("album",currComment.substring(6));
- }
- else if (currComment.toLowerCase().startsWith("date"))
- {
- aff_properties.put("date",currComment.substring(5));
- }
- else if (currComment.toLowerCase().startsWith("copyright"))
- {
- aff_properties.put("copyright",currComment.substring(10));
- }
- else if (currComment.toLowerCase().startsWith("comment"))
- {
- aff_properties.put("comment",currComment.substring(8));
- }
- else if (currComment.toLowerCase().startsWith("genre"))
- {
- aff_properties.put("ogg.comment.genre",currComment.substring(6));
- }
- else if (currComment.toLowerCase().startsWith("tracknumber"))
- {
- aff_properties.put("ogg.comment.track",currComment.substring(12));
- }
- else
- {
- c++;
- aff_properties.put("ogg.comment.ext."+c,currComment);
- }
- aff_properties.put("ogg.comment.encodedby",new String(vorbisComment.vendor, 0, vorbisComment.vendor.length - 1));
- }
- }
-
- /**
- * Reads from the oggBitStream_ a specified number of Bytes(bufferSize_) worth
- * starting at index and puts them in the specified buffer[].
- *
- * @return the number of bytes read or -1 if error.
- */
- private int readFromStream(byte[] buffer, int index, int bufferSize_)
- {
- int bytes = 0;
- try
- {
- bytes = oggBitStream_.read(buffer, index, bufferSize_);
- }
- catch (Exception e)
- {
- if (TDebug.TraceAudioFileReader)
- {
- TDebug.out("Cannot Read Selected Song");
- }
- bytes = -1;
- }
- return bytes;
- }
-
- /**
- * Initializes all the jOrbis and jOgg vars that are used for song playback.
- */
- private void init_jorbis()
- {
- oggSyncState_ = new SyncState();
- oggStreamState_ = new StreamState();
- oggPage_ = new Page();
- oggPacket_ = new Packet();
- vorbisInfo = new Info();
- vorbisComment = new Comment();
- vorbisDspState = new DspState();
- vorbisBlock = new Block(vorbisDspState);
- buffer = null;
- bytes = 0;
- oggSyncState_.init();
- }
-}
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFormat.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFormat.java
deleted file mode 100644
index 829ab2f8cd..0000000000
--- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisAudioFormat.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * VorbisAudioFormat.
- *
- * JavaZOOM : vorbisspi@javazoom.net
- * http://www.javazoom.net
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-package javazoom.spi.vorbis.sampled.file;
-
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.sampled.TAudioFormat;
-
-/**
- * @author JavaZOOM
- */
-public class VorbisAudioFormat extends TAudioFormat
-{
- /**
- * Constructor.
- * @param encoding
- * @param nFrequency
- * @param SampleSizeInBits
- * @param nChannels
- * @param FrameSize
- * @param FrameRate
- * @param isBigEndian
- * @param properties
- */
- public VorbisAudioFormat(AudioFormat.Encoding encoding, float nFrequency, int SampleSizeInBits, int nChannels, int FrameSize, float FrameRate, boolean isBigEndian, Map properties)
- {
- super(encoding, nFrequency, SampleSizeInBits, nChannels, FrameSize, FrameRate, isBigEndian, properties);
- }
-
- /**
- * Ogg Vorbis audio format parameters.
- * Some parameters might be unavailable. So availability test is required before reading any parameter.
- *
- * <br>AudioFormat parameters.
- * <ul>
- * <li><b>bitrate</b> [Integer], bitrate in bits per seconds, average bitrate for VBR enabled stream.
- * <li><b>vbr</b> [Boolean], VBR flag.
- * </ul>
- */
- public Map properties()
- {
- return super.properties();
- }
-}
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisEncoding.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisEncoding.java
deleted file mode 100644
index 7800f1556d..0000000000
--- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisEncoding.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * VorbisEncoding.
- *
- * JavaZOOM : vorbisspi@javazoom.net
- * http://www.javazoom.net
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-package javazoom.spi.vorbis.sampled.file;
-
-import javax.sound.sampled.AudioFormat;
-
-/**
- * Encodings used by the VORBIS audio decoder.
- */
-public class VorbisEncoding extends AudioFormat.Encoding
-{
- public static final AudioFormat.Encoding VORBISENC = new VorbisEncoding("VORBISENC");
-
- /**
- * Constructors.
- */
- public VorbisEncoding(String name)
- {
- super(name);
- }
-}
diff --git a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisFileFormatType.java b/songdbj/javazoom/spi/vorbis/sampled/file/VorbisFileFormatType.java
deleted file mode 100644
index f006bbfe1d..0000000000
--- a/songdbj/javazoom/spi/vorbis/sampled/file/VorbisFileFormatType.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * VorbisFileFormatType.
- *
- * JavaZOOM : vorbisspi@javazoom.net
- * http://www.javazoom.net
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-package javazoom.spi.vorbis.sampled.file;
-
-import javax.sound.sampled.AudioFileFormat;
-
-/**
- * FileFormatTypes used by the VORBIS audio decoder.
- */
-public class VorbisFileFormatType extends AudioFileFormat.Type
-{
- public static final AudioFileFormat.Type VORBIS = new VorbisFileFormatType("VORBIS", "ogg");
- public static final AudioFileFormat.Type OGG = new VorbisFileFormatType("OGG", "ogg");
- /**
- * Constructor.
- */
- public VorbisFileFormatType(String name, String extension)
- {
- super(name, extension);
- }
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/FormatDecodeException.java b/songdbj/net/shredzone/ifish/ltr/FormatDecodeException.java
deleted file mode 100644
index 72522eaa4d..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/FormatDecodeException.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-/**
- * This exception signals that the Tag could not be decoded for various
- * reasons.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public class FormatDecodeException extends Exception {
- private static final long serialVersionUID = 3690758397339187507L;
-
- /**
- * Constructor for the FormatDecodeException object
- *
- * @param msg A message
- */
- public FormatDecodeException( String msg ) {
- super( msg );
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/LTR.java b/songdbj/net/shredzone/ifish/ltr/LTR.java
deleted file mode 100644
index 8a38676583..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/LTR.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-
-/**
- * The Base Class for the Lightweight Tag Reader. LTR was made to read
- * the basic tag information of MP3 (IDv1, IDv2), Ogg Vorbis and ASF/WMA
- * files. It is lightweight because it is optimized for speed, and is
- * only able to read the tag information, but unable to edit them.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public abstract class LTR {
- protected RandomAccessFile in; // The file to be checked
-
- /**
- * Create a new LTR object. It is connected to the file to be decoded,
- * by a RandomAccessFile. The cursor position will be changed during
- * recognizing and decoding.
- *
- * @param in RandomAccessFile to be used
- * @throws FormatDecodeException Description of the Exception
- */
- public LTR( RandomAccessFile in )
- throws FormatDecodeException {
- this.in = in;
- try {
- in.seek( 0 ); // To the beginning of file
- } catch( IOException e ) {
- throw new FormatDecodeException( "couldn't seek: " + e.toString() );
- }
- }
-
- /**
- * Create an LTR object for a file. If the file given, was not
- * recognized or did not contain any tags, null will be returned.
- *
- * @param file File to open
- * @return LTR to this file, or null
- * @exception IOException Description of the Exception
- */
- public static LTR create( File file ) {
- RandomAccessFile in = null;
- LTR result = null;
-
- try {
- in = new RandomAccessFile( file, "r" );
-
- try {
- result = new TagOggVorbis( in );
- return result;
- } catch( FormatDecodeException e ) {}
-
- try {
- result = new TagMp3v2( in );
- return result;
- } catch( FormatDecodeException e ) {}
-
- try {
- result = new TagMp3v200( in );
- return result;
- } catch( FormatDecodeException e ) {}
-
- try {
- result = new TagAsf( in, file );
- return result;
- }catch( FormatDecodeException e ) {}
-
- try {
- // Always check ID3v1 *after* ID3v2, because a lot of ID3v2
- // files also contain ID3v1 tags with limited content.
- result = new TagMp3v1( in );
- return result;
- } catch( FormatDecodeException e ) {}
- }catch(IOException e) {
- return null;
- } finally {
- try {
- if( in!=null ) in.close();
- } catch(IOException e) {
- System.out.println("Failed to close file.");
- }
- }
-
- return null;
- }
-
- /**
- * Get the type of this file. This is usually the compression format
- * itself (e.g. "OGG" or "MP3"). If there are different taggings for
- * this format, the used tag format is appended after a slash (e.g.
- * "MP3/id3v2").
- *
- * @return The type
- */
- public abstract String getType();
-
- /**
- * Get the artist.
- *
- * @return The artist (never null)
- */
- public abstract String getArtist();
-
- /**
- * Get the album.
- *
- * @return The album (never null)
- */
- public abstract String getAlbum();
-
- /**
- * Get the title.
- *
- * @return The title (never null)
- */
- public abstract String getTitle();
-
- /**
- * Get the genre.
- *
- * @return The genre (never null)
- */
- public abstract String getGenre();
-
- /**
- * Get the year.
- *
- * @return The year (never null)
- */
- public abstract String getYear();
-
- /**
- * Get the comment.
- *
- * @return The comment (never null)
- */
- public abstract String getComment();
-
- /**
- * Get the track.
- *
- * @return The track (never null)
- */
- public abstract String getTrack();
-
- /**
- * Read a String of a certain length from the file. It will always use
- * "ISO-8859-1" encoding!
- *
- * @param length Maximum number of bytes to read
- * @return String that was read
- * @throws IOException If EOF was already reached
- */
- protected String readStringLen( int length )
- throws IOException {
- return readStringLen( length, "ISO-8859-1" );
- }
-
- /**
- * Read a String of a certain length from the file. The length will
- * not be exceeded. No null termination is required. Anyhow an
- * IOException will be thrown if the EOF was reached before invocation.
- *
- * @param length Maximum number of bytes to read
- * @param charset Charset to be used
- * @return String that was read
- * @throws IOException If EOF was already reached
- */
- protected String readStringLen( int length, String charset )
- throws IOException {
- byte[] buf = new byte[length];
- int readlength = in.read( buf );
- if( readlength < 0 ) {
- throw new IOException( "Unexpected EOF" );
- }
- return new String( buf, 0, readlength, charset );
- }
-
- /**
- * Return a string representation of the LTR content.
- *
- * @return String representation
- */
- public String toString() {
- StringBuffer buff = new StringBuffer();
- buff.append( getType() );
- buff.append( "[ART='" );
- buff.append( getArtist() );
- buff.append( "' ALB='" );
- buff.append( getAlbum() );
- buff.append( "' TIT='" );
- buff.append( getTitle() );
- buff.append( "' TRK='" );
- buff.append( getTrack() );
- buff.append( "' GEN='" );
- buff.append( getGenre() );
- buff.append( "' YR='" );
- buff.append( getYear() );
- buff.append( "' CMT='" );
- buff.append( getComment() );
- buff.append( "']" );
- return buff.toString();
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/LTRmp3.java b/songdbj/net/shredzone/ifish/ltr/LTRmp3.java
deleted file mode 100644
index 1b31c405ba..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/LTRmp3.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-
-/**
- * The Base Class for mp3 decoding of the Lightweight Tag Reader.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public abstract class LTRmp3 extends LTR {
-
- private final static String[] genres = {
- //--- Genres as specified in ID3v1 ---
- "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk",
- "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other",
- "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial",
- "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack",
- "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk",
- "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House",
- "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass",
- "Soul", "Punk", "Space", "Meditative", "Instrumental Pop",
- "Instrumental Rock", "Ethnic", "Gothic", "Darkwave",
- "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream",
- "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40",
- "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret",
- "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi",
- "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical",
- "Rock & Roll", "Hard Rock",
-
- //--- This are WinAmp extensions ---
- "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebop",
- "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock",
- "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock",
- "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech",
- "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass",
- "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba",
- "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle",
- "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall",
- };
-
- protected final String charsetV1 = "ISO-8859-1";
- protected final String charsetV2 = "ISO-8859-1";
-
- /**
- * Constructor for the LTRmp3 object
- *
- * @param in File to be used
- * @throws FormatDecodeException Could not decode file
- */
- public LTRmp3( RandomAccessFile in )
- throws FormatDecodeException {
- super( in );
- }
-
- /**
- * Decode the mp3 numerical Genre code and convert it to a human
- * readable string. The genre is decoded according to the
- * specifications found at <a href="http://www.id3.org">www.id3.org</a>,
- * as well as the WinAmp extensions.
- *
- * @param id Genre ID
- * @return ID String, null if the genre ID was unknown
- */
- protected String decodeGenre( int id ) {
- if( id>=genres.length ) return null;
- return genres[id];
- }
-
- /**
- * Read an ID3v2 integer. This is a 4 byte big endian value, which is
- * always not syncsafe.
- *
- * @return The integer read.
- * @throws IOException If there were not enough bytes in the file.
- */
- protected int readInt()
- throws IOException {
- int val = 0;
- for( int cnt = 4; cnt > 0; cnt-- ) {
- val <<= 8;
- val |= ( in.readByte() & 0xFF );
- }
- return val;
- }
-
- /**
- * Read an ID3v2 syncsafe integer. This is a 4 byte big endian value
- * with the bit 7 of each byte always being 0.
- *
- * @return The syncsafe integer read.
- * @throws IOException If there were not enough bytes in the file.
- */
- protected int readSyncsafeInt()
- throws IOException {
- int val = 0;
- for( int cnt = 4; cnt > 0; cnt-- ) {
- val <<= 7;
- val |= ( readSyncsafe() & 0x7F );
- }
- return val;
- }
-
- /**
- * Read a syncsafe byte. It is made sure that a byte is available in
- * the file, and that bit 7 is 0. An IOException is thrown otherwise.
- *
- * @return The byte read.
- * @throws IOException If premature EOF was reached or byte was not
- * syncsafe.
- */
- protected byte readSyncsafe()
- throws IOException {
- byte read = in.readByte();
- if(( read & 0x80 ) != 0 ) {
- throw new IOException( "not syncsafe" );
- }
- return read;
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/OggFastFileStream.java b/songdbj/net/shredzone/ifish/ltr/OggFastFileStream.java
deleted file mode 100644
index f86699b0f1..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/OggFastFileStream.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-import java.util.*;
-
-import de.jarnbjo.ogg.*;
-
-/**
- * Replacement file reader class. The original J-Ogg FileStream has the
- * major disadvantage that it reads the entire file, even though we just
- * need a few byte from it. This FastFileStream will only read as little
- * information as possible.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public class OggFastFileStream implements PhysicalOggStream {
- private InputStream sourceStream;
- private boolean closed = false;
- private int contentLength = 0;
- private int position = 0;
- private HashMap logicalStreams = new HashMap();
- private OggPage firstPage;
-
- /**
- * Constructor for the OggFastFileStream object
- *
- * @param in RandomAccessFile to be read
- * @throws OggFormatException Bad format
- * @throws IOException IO error
- */
- public OggFastFileStream( RandomAccessFile in )
- throws OggFormatException, IOException {
- this.sourceStream = new RandomAdapterInputStream( in );
- contentLength = (int) in.length();
- firstPage = OggPage.create( sourceStream );
- position += firstPage.getTotalLength();
- LogicalOggStreamImpl los = new LogicalOggStreamImpl( this, firstPage.getStreamSerialNumber() );
- logicalStreams.put( new Integer( firstPage.getStreamSerialNumber() ), los );
- los.checkFormat( firstPage );
- }
-
- /**
- * Get a collection of the logical streams.
- *
- * @return Collection
- */
- public Collection getLogicalStreams() {
- return logicalStreams.values();
- }
-
- /**
- * Checks if the file is open.
- *
- * @return true: open, false: closed
- */
- public boolean isOpen() {
- return !closed;
- }
-
- /**
- * Closes the stream
- *
- * @throws IOException IO error
- */
- public void close()
- throws IOException {
- closed = true;
- sourceStream.close();
- }
-
- /**
- * Get the content length
- *
- * @return The content length
- */
- public int getContentLength() {
- return contentLength;
- }
-
- /**
- * Get the current position
- *
- * @return Position
- */
- public int getPosition() {
- return position;
- }
-
- /**
- * Get an OggPage.
- *
- * @param index Index to be fetched
- * @return The oggPage value
- * @throws IOException IO Error
- */
- public OggPage getOggPage( int index )
- throws IOException {
- if( firstPage != null ) {
- OggPage tmp = firstPage;
- firstPage = null;
- return tmp;
- } else {
- OggPage page = OggPage.create( sourceStream );
- position += page.getTotalLength();
- return page;
- }
- }
-
- /**
- * Move the stream to a certain time position.
- *
- * @param granulePosition The new position
- * @throws IOException
- */
- public void setTime( long granulePosition )
- throws IOException {
- throw new UnsupportedOperationException( "not supported" );
- }
-
- /**
- * Is this FileStream seekable? We pretend we are not, so J-Ogg
- * will not get some stupid thoughts... ;)
- *
- * @return false
- */
- public boolean isSeekable() {
- return false;
- }
-
-/*--------------------------------------------------------------------*/
-
- /**
- * This class repairs a design flaw in JDK1.0. A RandomAccessFile
- * is not derived from InputStream, though it provides the same API.
- * This Adapter gives an InputStream view of a Random Access File.
- * <p>
- * For a detailed method description, see InputStream.
- */
- private static class RandomAdapterInputStream extends InputStream {
- private RandomAccessFile rf;
-
- /**
- * Create a new Adapter.
- *
- * @param rf RandomAccessFile to be used
- */
- public RandomAdapterInputStream( RandomAccessFile rf ) {
- this.rf = rf;
- }
-
- /**
- * Read a byte.
- *
- * @return Read byte or -1.
- */
- public int read() throws IOException {
- return rf.read();
- }
-
- /**
- * Read a byte array.
- *
- * @param b Byte array to be read
- * @return Number of bytes read or -1
- */
- public int read( byte[] b) throws IOException {
- return rf.read(b);
- }
-
- /**
- * Read into a byte array.
- *
- * @param b Byte array to be read
- * @param off Starting offset
- * @param len Length
- * @return Number of bytes read or -1
- */
- public int read( byte[] b, int off, int len) throws IOException {
- return rf.read( b, off, len );
- }
-
- /**
- * Skip a number of bytes in forward direction.
- *
- * @param n Number of bytes to skip
- * @return Number of bytes skipped, or -1
- */
- public long skip( long n ) throws IOException {
- return rf.skipBytes( (int) n );
- }
-
- /**
- * Return the number of available bytes. Here it is the number of
- * bytes remaining until EOF.
- *
- * @return Number of bytes available.
- */
- public int available() throws IOException {
- return (int) (rf.length() - rf.getFilePointer());
- }
-
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/TagAsf.java b/songdbj/net/shredzone/ifish/ltr/TagAsf.java
deleted file mode 100644
index fc68789345..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/TagAsf.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-import java.util.List;
-
-import de.jarnbjo.ogg.*;
-import de.jarnbjo.vorbis.*;
-import entagged.audioformats.AudioFile;
-import entagged.audioformats.Tag;
-import entagged.audioformats.asf.AsfFileReader;
-import entagged.audioformats.exceptions.CannotReadException;
-
-/**
- * Decodes an ASF/WMA stream. It uses parts of the
- * <a href="http://entagged.sf.net/">Entagged</a> software, which is
- * copyrighted by the Entagged Development Team, and published under
- * GPL.
- * <p>
- * <em>NOTE</em> that due to the fact that Entagged is GPL, you <em>MUST</em>
- * remove all entagged sources and this class file if you decide to use
- * the LGPL or MPL part of the iFish licence!
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public class TagAsf extends LTR {
- private final Tag tag;
-
- /**
- * Create a new TagAsf object.
- *
- * @param in File to read
- * @param file Reference to the file itself
- * @throws FormatDecodeException Couldn't decode this file
- */
- public TagAsf( RandomAccessFile in, File file )
- throws FormatDecodeException {
- super( in );
-
- try {
- final AsfFileReader afr = new AsfFileReader();
- final AudioFile af = afr.read( file, in );
- tag = af.getTag();
- }catch( CannotReadException e ) {
- throw new FormatDecodeException( "could not decode file: " + e.toString() );
- }catch( RuntimeException e ) {
- throw new FormatDecodeException( "error decoding file: " + e.toString() );
- }
- }
-
- /**
- * Get the type of this file. This is usually the compression format
- * itself (e.g. "OGG" or "MP3"). If there are different taggings for
- * this format, the used tag format is appended after a slash (e.g.
- * "MP3/id3v2").
- *
- * @return The type
- */
- public String getType() {
- return "ASF";
- }
-
- /**
- * Get the artist.
- *
- * @return The artist (never null)
- */
- public String getArtist() {
- return tag.getFirstArtist().trim();
- }
-
- /**
- * Get the album.
- *
- * @return The album (never null)
- */
- public String getAlbum() {
- return tag.getFirstAlbum().trim();
- }
-
- /**
- * Get the title.
- *
- * @return The title (never null)
- */
- public String getTitle() {
- return tag.getFirstTitle().trim();
- }
-
- /**
- * Get the genre.
- *
- * @return The genre (never null)
- */
- public String getGenre() {
- return tag.getFirstGenre().trim();
- }
-
- /**
- * Get the year.
- *
- * @return The year (never null)
- */
- public String getYear() {
- return tag.getFirstYear().trim();
- }
-
- /**
- * Get the comment.
- *
- * @return The comment (never null)
- */
- public String getComment() {
- return tag.getFirstComment().trim();
- }
-
- /**
- * Get the track.
- *
- * @return The track (never null)
- */
- public String getTrack() {
- return tag.getFirstTrack().trim();
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/TagMp3v1.java b/songdbj/net/shredzone/ifish/ltr/TagMp3v1.java
deleted file mode 100644
index 9d3182260a..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/TagMp3v1.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-
-/**
- * Decodes an MP3 file with ID3v1 tag. The file is compliant to the
- * specifications found at <a href="http://www.id3.org">www.id3.org</a>.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public class TagMp3v1 extends LTRmp3 {
- private String artist = "";
- private String comment = "";
- private String title = "";
- private String album = "";
- private String year = "";
- private String track = "";
- private String genre = "";
-
- /**
- * Create a new TagMp3v1 object.
- *
- * @param in File to be read
- * @throws FormatDecodeException Description of the Exception
- */
- public TagMp3v1( RandomAccessFile in )
- throws FormatDecodeException {
- super( in );
-
- try {
- //--- Decode header ---
- in.seek( in.length() - 128 ); // To the place where the tag lives
- if( !readStringLen( 3 ).equals( "TAG" ) ) {
- throw new FormatDecodeException( "not an id3v1 tag" );
- }
-
- title = readStringLen( 30, charsetV1 ).trim();
- artist = readStringLen( 30, charsetV1 ).trim();
- album = readStringLen( 30, charsetV1 ).trim();
- year = readStringLen( 4, charsetV1 ).trim();
- comment = readStringLen( 28, charsetV1 );
-
- byte[] sto = new byte[2];
- in.readFully( sto );
- if( sto[0] == 0x00 ) {
- // ID3v1.1
- track = ( sto[1]>0 ? String.valueOf(sto[1]) : "" );
- } else {
- // ID3v1.0
- comment += new String( sto, charsetV1 );
- }
- comment = comment.trim();
-
- genre = decodeGenre( in.readUnsignedByte() );
- if( genre==null ) genre="";
-
- } catch( IOException e ) {
- throw new FormatDecodeException( "could not decode file: " + e.toString() );
- }catch( RuntimeException e ) {
- throw new FormatDecodeException( "error decoding file: " + e.toString() );
- }
- }
-
- /**
- * Get the type of this file. This is usually the compression format
- * itself (e.g. "OGG" or "MP3"). If there are different taggings for
- * this format, the used tag format is appended after a slash (e.g.
- * "MP3/id3v2").
- *
- * @return The type
- */
- public String getType() {
- return "MP3/id3v1";
- }
-
- /**
- * Get the artist.
- *
- * @return The artist (never null)
- */
- public String getArtist() {
- return artist;
- }
-
- /**
- * Get the album.
- *
- * @return The album (never null)
- */
- public String getAlbum() {
- return album;
- }
-
- /**
- * Get the title.
- *
- * @return The title (never null)
- */
- public String getTitle() {
- return title;
- }
-
- /**
- * Get the genre.
- *
- * @return The genre (never null)
- */
- public String getGenre() {
- return genre;
- }
-
- /**
- * Get the year.
- *
- * @return The year (never null)
- */
- public String getYear() {
- return year;
- }
-
- /**
- * Get the comment.
- *
- * @return The comment (never null)
- */
- public String getComment() {
- return comment;
- }
-
- /**
- * Get the track.
- *
- * @return The track (never null)
- */
- public String getTrack() {
- return track;
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/TagMp3v2.java b/songdbj/net/shredzone/ifish/ltr/TagMp3v2.java
deleted file mode 100644
index 689dd21618..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/TagMp3v2.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-import java.util.regex.*;
-
-/**
- * Decodes an MP3 file with ID3v2 tag. The file is compliant to the
- * specifications found at <a href="http://www.id3.org">www.id3.org</a>,
- * V2.4.0 and V2.3.0. ID3 V2.2.0 is handled in a separate tag handler.
- * Anyhow it has certain limitations regarding tag frames which could
- * not be used or entirely used to iFish, e.g. multiple genres.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public class TagMp3v2 extends LTRmp3 {
- private int globalSize;
- private Pattern patGenre;
- private boolean v230 = false; // V2.3.0 detected
-
- private String artist = "";
- private String comment = "";
- private String title = "";
- private String album = "";
- private String year = "";
- private String track = "";
- private String genre = "";
-
- /**
- * Create a new TagMp3v2 instance.
- *
- * @param in File to be read
- * @throws FormatDecodeException Couldn't decode this file
- */
- public TagMp3v2( RandomAccessFile in )
- throws FormatDecodeException {
- super( in );
-
- patGenre = Pattern.compile( "\\((\\d{1,3})\\).*" );
-
- try {
- //--- Decode header ---
- if( !readStringLen( 3 ).equals( "ID3" ) ) {
- throw new FormatDecodeException( "not an id3v2 tag" );
- }
-
- byte version = in.readByte();
- byte revision = in.readByte();
-
- if( version==0xFF || revision==0xFF ) {
- throw new FormatDecodeException( "not an id3v2 tag" );
- }
-
- if( version<=0x02 || version>0x04 ) {
- throw new FormatDecodeException( "unable to decode ID3v2."+version+"."+revision );
- }
-
- byte flags = in.readByte();
- v230 = (version==0x03);
- globalSize = readSyncsafeInt() + 10;
-
- //--- Skip extended header ---
- if( ( flags & 0x40 ) != 0 ) {
- int ehsize = readAutoInt();
- if( ehsize < 6 ) {
- throw new FormatDecodeException( "extended header too small" );
- }
- in.skipBytes( ehsize - 4 );
- }
-
- //--- Read all frames ---
- Frame frm;
- while( ( frm = readFrame() ) != null ) {
- String type = frm.getType();
- String[] answer;
-
- if( type.equals( "TOPE" ) || type.equals( "TPE1" ) ) {
-
- answer = frm.getAsStringEnc();
- artist = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "COMM" ) ) {
-
- answer = frm.getAsStringEnc();
- comment = (answer.length>1 ? answer[1].trim() : "");
-
- } else if( type.equals( "TIT2" ) ) {
-
- answer = frm.getAsStringEnc();
- title =(answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TALB" ) ) {
-
- answer = frm.getAsStringEnc();
- album = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TYER" ) ) {
-
- answer = frm.getAsStringEnc();
- year = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TRCK" ) ) {
-
- answer = frm.getAsStringEnc();
- track = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TCON" ) ) {
-
- answer = frm.getAsStringEnc();
- if( answer.length>0 ) {
- genre = answer[0].trim();
- Matcher mat = patGenre.matcher( genre );
- if( mat.matches() ) {
- genre = decodeGenre( Integer.parseInt( mat.group( 1 ) ) );
- if( genre==null ) genre="";
- }
- }
- }
- }
-
- //--- Footer frame? ---
- if( ( flags & 0x10 ) != 0 ) {
- in.skipBytes( 10 ); // Then skip it
- }
- // Position is now the start of the MP3 data
-
- } catch( IOException e ) {
- throw new FormatDecodeException( "could not decode file: " + e.toString() );
- }catch( RuntimeException e ) {
- throw new FormatDecodeException( "error decoding file: " + e.toString() );
- }
- }
-
- /**
- * Get the type of this file. This is usually the compression format
- * itself (e.g. "OGG" or "MP3"). If there are different taggings for
- * this format, the used tag format is appended after a slash (e.g.
- * "MP3/id3v2").
- *
- * @return The type
- */
- public String getType() {
- return ( v230 ? "MP3/id3v2.3.0" : "MP3/id3v2.4.0" );
- }
-
- /**
- * Get the artist.
- *
- * @return The artist (never null)
- */
- public String getArtist() {
- return artist;
- }
-
- /**
- * Get the album.
- *
- * @return The album (never null)
- */
- public String getAlbum() {
- return album;
- }
-
- /**
- * Get the title.
- *
- * @return The title (never null)
- */
- public String getTitle() {
- return title;
- }
-
- /**
- * Get the genre.
- *
- * @return The genre (never null)
- */
- public String getGenre() {
- return genre;
- }
-
- /**
- * Get the year.
- *
- * @return The year (never null)
- */
- public String getYear() {
- return year;
- }
-
- /**
- * Get the comment.
- *
- * @return The comment (never null)
- */
- public String getComment() {
- return comment;
- }
-
- /**
- * Get the track.
- *
- * @return The track (never null)
- */
- public String getTrack() {
- return track;
- }
-
- /**
- * Read an ID3v2 integer. This is a 4 byte big endian value, which is
- * only syncsafe for ID3v2.4 or higher, but not for ID3v2.3.
- *
- * @return The integer read.
- * @throws IOException If there were not enough bytes in the file.
- */
- protected int readAutoInt()
- throws IOException {
- return( v230 ? readInt() : readSyncsafeInt() );
- }
-
- /**
- * Read a tag frame. A Frame object will be returned, or null if no
- * more frames were available.
- *
- * @return The next frame, or null
- * @throws IOException If premature EOF was reached.
- */
- protected Frame readFrame()
- throws IOException {
- if( in.getFilePointer() >= globalSize ) {
- return null;
- }
-
- //--- Get the type ---
- String type = readStringLen( 4 );
- if( type.charAt(0)==0 ) { // Optional padding frame
- in.skipBytes( (int) ( globalSize - in.getFilePointer() ) );// Skip it...
- return null; // Return null
- }
-
- //--- Read the frame ---
- int size = readAutoInt();
- byte flag1 = in.readByte();
- byte flag2 = in.readByte();
-
- //--- Read the content ---
- // Stay within reasonable boundaries. If the data part is bigger than
- // 16K, it's not really useful for us, so we will keep the frame empty.
- byte[] data = null;
- if( size<=16384 ) {
- data = new byte[size];
- int rlen = in.read( data );
- if( rlen != size ) {
- throw new IOException( "unexpected EOF" );
- }
- }else {
- in.skipBytes( size );
- }
-
- //--- Return the frame ---
- return new Frame( type, size, flag1, flag2, data );
- }
-
-/*--------------------------------------------------------------------*/
-
- /**
- * This class contains a ID3v2 frame.
- */
- private static class Frame {
- private final String charset;
- private final String type;
-// private final int size;
-// private final byte flag1;
- private final byte flag2;
- private byte[] data;
- private boolean decoded = false;
-
- /**
- * Constructor for the Frame object
- *
- * @param type Frame type
- * @param size Frame size
- * @param flag1 Flag 1
- * @param flag2 Flag 2
- * @param data Frame content, may be null
- */
- public Frame( String type, int size, byte flag1, byte flag2, byte[] data ) {
- charset = "ISO-8859-1";
- this.type = type;
-// Currently unused...
-// this.size = size;
-// this.flag1 = flag1;
- this.flag2 = flag2;
- this.data = data;
- }
-
- /**
- * Get the type.
- *
- * @return The type of this Frame
- */
- public String getType() {
- return type;
- }
-
- /**
- * Return the Frame content as String. This method is to be used for
- * strings without a leading encoding byte. This machine's default
- * encoding will be used instead.
- *
- * @return Encoded string
- * @throws FormatDecodeException Could not read or decode frame
- */
- public String getAsString()
- throws FormatDecodeException {
- if(data==null) return null;
- decode();
- return new String( data );
- }
-
- /**
- * Return the Frame content as encoded String. The first byte will
- * contain the encoding type, following the string itself. Multiple
- * strings are null-terminated. An array of all strings found, will
- * be returned.
- *
- * @return Array of all strings. Might be an empty array!
- * @throws FormatDecodeException Could not read or decode frame
- */
- public String[] getAsStringEnc()
- throws FormatDecodeException {
- if( data==null ) return new String[0];
- decode();
- if( data.length==0 ) return new String[0];
- int len = data.length - 1;
- String result = "";
- try {
- switch ( data[0] ) {
- case 0x00:
- result = new String( data, 1, len, charset );
- break;
- case 0x01:
- result = new String( data, 1, len, "UTF-16" );
- break;
- case 0x02:
- result = new String( data, 1, len, "UTF-16BE" );
- break;
- case 0x03:
- result = new String( data, 1, len, "UTF-8" );
- break;
- default:
- throw new FormatDecodeException( "unknown encoding of frame " + type );
- }
- }catch( UnsupportedEncodingException e ) {
- throw new FormatDecodeException( "Java misses a basic encoding!?" );
- }
- return result.split( "\0" );
- }
-
- /**
- * Decode a frame, unless already decoded. If the frame was
- * unsynchronized, it will be synchronized here. Compression and
- * encryption is not supported yet. You can invoke this method
- * several times without any effect.
- *
- * @throws FormatDecodeException Description of the Exception
- */
- private void decode()
- throws FormatDecodeException {
- if( decoded ) return;
- decoded = true;
-
- if( ( flag2 & 0x02 ) != 0 ) { // Unsynchronize
- byte decoded[] = new byte[data.length];
- int pos = 0;
- for( int ix = 0; ix < data.length - 1; ix++ ) {
- decoded[pos++] = data[ix];
- if( data[ix] == 0xFF && data[ix + 1] == 0x00 ) {
- ix++;
- }
- }
- data = new byte[pos];
- System.arraycopy( decoded, 0, data, 0, pos );
- }
-
- if( ( flag2 & 0x08 ) != 0 ) { // Compression
- throw new FormatDecodeException( "sorry, compression is not yet supported" );
- }
-
- if( ( flag2 & 0x04 ) != 0 ) { // Encryption
- throw new FormatDecodeException( "sorry, encryption is not yet supported" );
- }
- }
-
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/TagMp3v200.java b/songdbj/net/shredzone/ifish/ltr/TagMp3v200.java
deleted file mode 100644
index 28e623f962..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/TagMp3v200.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-import java.util.regex.*;
-
-/**
- * Decodes an MP3 file with old ID3v2.00 tag. The file is compliant to the
- * specifications found at <a href="http://www.id3.org/id3v2-00.txt">www.id3.org</a>.
- * Only ID3 V2.00 up to v2.2.0 is handled here. Newer versions are separately
- * handled in TagMp3v2.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public class TagMp3v200 extends LTRmp3 {
- private int globalSize;
- private Pattern patGenre;
-
- private String artist = "";
- private String comment = "";
- private String title = "";
- private String album = "";
- private String year = "";
- private String track = "";
- private String genre = "";
-
- /**
- * Create a new TagMp3v200 instance.
- *
- * @param in File to be read
- * @throws FormatDecodeException Couldn't decode this file
- */
- public TagMp3v200( RandomAccessFile in )
- throws FormatDecodeException {
- super( in );
-
- patGenre = Pattern.compile( "\\((\\d{1,3})\\).*" );
-
- try {
- //--- Decode header ---
- if( !readStringLen( 3 ).equals( "ID3" ) ) {
- throw new FormatDecodeException( "not an id3v2 tag" );
- }
-
- byte version = in.readByte();
- byte revision = in.readByte();
-
- if( version!=0x02 || revision==0xFF ) {
- throw new FormatDecodeException( "not an id3v2.2.0 tag" );
- }
-
- byte flags = in.readByte();
- globalSize = readSyncsafeInt() + 10;
-
- //--- Read all frames ---
- Frame frm;
- while( ( frm = readFrame() ) != null ) {
- String type = frm.getType();
- String[] answer;
-
- if( type.equals( "TOA" ) || type.equals( "TP1" ) ) {
-
- answer = frm.getAsStringEnc();
- artist = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "COM" ) ) {
-
- answer = frm.getAsStringEnc();
- comment = (answer.length>1 ? answer[1].trim() : "");
-
- } else if( type.equals( "TT2" ) ) {
-
- answer = frm.getAsStringEnc();
- title =(answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TAL" ) ) {
-
- answer = frm.getAsStringEnc();
- album = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TYE" ) ) {
-
- answer = frm.getAsStringEnc();
- year = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TRK" ) ) {
-
- answer = frm.getAsStringEnc();
- track = (answer.length>0 ? answer[0].trim() : "");
-
- } else if( type.equals( "TCO" ) ) {
-
- answer = frm.getAsStringEnc();
- if( answer.length>0 ) {
- genre = answer[0].trim();
- Matcher mat = patGenre.matcher( genre );
- if( mat.matches() ) {
- genre = decodeGenre( Integer.parseInt( mat.group( 1 ) ) );
- if( genre==null ) genre="";
- }
- }
- }
- }
-
- // Position is now the start of the MP3 data
-
- } catch( IOException e ) {
- throw new FormatDecodeException( "could not decode file: " + e.toString() );
- }catch( RuntimeException e ) {
- throw new FormatDecodeException( "error decoding file: " + e.toString() );
- }
- }
-
- /**
- * Get the type of this file. This is usually the compression format
- * itself (e.g. "OGG" or "MP3"). If there are different taggings for
- * this format, the used tag format is appended after a slash (e.g.
- * "MP3/id3v2").
- *
- * @return The type
- */
- public String getType() {
- return "MP3/id3v2.2.0";
- }
-
- /**
- * Get the artist.
- *
- * @return The artist (never null)
- */
- public String getArtist() {
- return artist;
- }
-
- /**
- * Get the album.
- *
- * @return The album (never null)
- */
- public String getAlbum() {
- return album;
- }
-
- /**
- * Get the title.
- *
- * @return The title (never null)
- */
- public String getTitle() {
- return title;
- }
-
- /**
- * Get the genre.
- *
- * @return The genre (never null)
- */
- public String getGenre() {
- return genre;
- }
-
- /**
- * Get the year.
- *
- * @return The year (never null)
- */
- public String getYear() {
- return year;
- }
-
- /**
- * Get the comment.
- *
- * @return The comment (never null)
- */
- public String getComment() {
- return comment;
- }
-
- /**
- * Get the track.
- *
- * @return The track (never null)
- */
- public String getTrack() {
- return track;
- }
-
- /**
- * Read a tag frame. A Frame object will be returned, or null if no
- * more frames were available.
- *
- * @return The next frame, or null
- * @throws IOException If premature EOF was reached.
- */
- protected Frame readFrame()
- throws IOException {
- if( in.getFilePointer() >= globalSize ) {
- return null;
- }
-
- //--- Get the type ---
- String type = readStringLen( 3 );
- if( type.charAt(0)==0 ) { // Optional padding frame
- in.skipBytes( (int) ( globalSize - in.getFilePointer() ) );// Skip it...
- return null; // Return null
- }
-
- //--- Read the frame ---
- int size = read3Int();
-
- //--- Read the content ---
- // Stay within reasonable boundaries. If the data part is bigger than
- // 16K, it's not really useful for us, so we will keep the frame empty.
- byte[] data = null;
- if( size<=16384 ) {
- data = new byte[size];
- int rlen = in.read( data );
- if( rlen != size ) {
- throw new IOException( "unexpected EOF" );
- }
- }else {
- in.skipBytes( size );
- }
-
- //--- Return the frame ---
- return new Frame( type, size, data );
- }
-
- /**
- * Read an ID3v2 3 byte integer. This is a 3 byte big endian value, which is
- * always not syncsafe.
- *
- * @return The integer read.
- * @throws IOException If there were not enough bytes in the file.
- */
- protected int read3Int()
- throws IOException {
- int val = 0;
- for( int cnt = 3; cnt > 0; cnt-- ) {
- val <<= 8;
- val |= ( in.readByte() & 0xFF );
- }
- return val;
- }
-
-/*--------------------------------------------------------------------*/
-
- /**
- * This class contains a ID3v2.2.0 frame.
- */
- private static class Frame {
- private final String charset;
- private final String type;
-// private final int size;
- private byte[] data;
-
- /**
- * Constructor for the Frame object
- *
- * @param type Frame type
- * @param size Frame size
- * @param data Frame content, may be null
- */
- public Frame( String type, int size, byte[] data ) {
- this.charset = "ISO-8859-1";
- this.type = type;
-// Currently unused...
-// this.size = size;
- this.data = data;
- }
-
- /**
- * Get the type.
- *
- * @return The type of this Frame
- */
- public String getType() {
- return type;
- }
-
- /**
- * Return the Frame content as String. This method is to be used for
- * strings without a leading encoding byte. This machine's default
- * encoding will be used instead.
- *
- * @return Encoded string
- * @throws FormatDecodeException Could not read or decode frame
- */
- public String getAsString()
- throws FormatDecodeException {
- if(data==null) return null;
- return new String( data );
- }
-
- /**
- * Return the Frame content as encoded String. The first byte will
- * contain the encoding type, following the string itself. Multiple
- * strings are null-terminated. An array of all strings found, will
- * be returned.
- *
- * @return Array of all strings. Might be an empty array!
- * @throws FormatDecodeException Could not read or decode frame
- */
- public String[] getAsStringEnc()
- throws FormatDecodeException {
- if(data==null) return new String[0];
- int len = data.length - 1;
- String result = "";
- try {
- switch ( data[0] ) {
- case 0x00:
- result = new String( data, 1, len, charset );
- break;
- case 0x01:
- result = new String( data, 1, len, "UTF-16" );
- break;
- default:
- throw new FormatDecodeException( "unknown encoding of frame " + type );
- }
- }catch( UnsupportedEncodingException e ) {
- throw new FormatDecodeException( "Java misses a basic encoding!?" );
- }
- return result.split( "\0" );
- }
-
- }
-
-}
diff --git a/songdbj/net/shredzone/ifish/ltr/TagOggVorbis.java b/songdbj/net/shredzone/ifish/ltr/TagOggVorbis.java
deleted file mode 100644
index 45b7401437..0000000000
--- a/songdbj/net/shredzone/ifish/ltr/TagOggVorbis.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * iFish -- An iRiver iHP jukebox database creation tool
- *
- * Copyright (c) 2004 Richard "Shred" Körber
- * http://www.shredzone.net/go/ifish
- *
- *-----------------------------------------------------------------------
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is IFISH.
- *
- * The Initial Developer of the Original Code is
- * Richard "Shred" Körber.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-package net.shredzone.ifish.ltr;
-
-import java.io.*;
-import de.jarnbjo.ogg.*;
-import de.jarnbjo.vorbis.*;
-
-/**
- * Decodes an Ogg Vorbis stream. It uses the
- * <a href="http://www.j-ogg.de/">J-Ogg</a> library, which is
- * copyrighted by Tor-Einar Jarnbjo. His licence says that may use and
- * modify it as will (even commercial), as long as a reference to his
- * library is stated in the software.
- * <p>
- * <b>NOTE:</b> Due to a bug, there is a patch required in the J-Ogg
- * library. In class de.jarnbjo.vorbis.CommentHeader, private method
- * <tt>addComment()</tt>, add a line
- * <pre>
- * key = key.toUpperCase();
- * </pre>
- * after the method declaration header.
- *
- * @author Richard Körber &lt;dev@shredzone.de&gt;
- * @version $Id$
- */
-public class TagOggVorbis extends LTR {
- private CommentHeader cmt;
-
- /**
- * Create a new TagOggVorbis object.
- *
- * @param in File to read
- * @throws FormatDecodeException Couldn't decode this file
- */
- public TagOggVorbis( RandomAccessFile in )
- throws FormatDecodeException {
- super( in );
-
- try {
- //--- Check for Ogg Signature ---
- // I expected J-Ogg to do this check, but it has been commented
- // out because very old ogg files do not seem to have this header.
- // We will ignore those files.
- if( !readStringLen(4).equals("OggS") )
- throw new FormatDecodeException( "not an Ogg file" );
- in.seek(0);
-
- //--- Get the Comment Header ---
- OggFastFileStream fs = new OggFastFileStream(in);
- LogicalOggStream los = (LogicalOggStream) fs.getLogicalStreams().iterator().next();
- if( los.getFormat() != LogicalOggStream.FORMAT_VORBIS )
- throw new FormatDecodeException( "not a plain Ogg Vorbis file" );
- VorbisStream vos = new VorbisStream( los );
- cmt = vos.getCommentHeader();
-
- }catch( OggFormatException e ) {
- throw new FormatDecodeException( "not an Ogg file" );
- }catch( VorbisFormatException e ) {
- throw new FormatDecodeException( "not an Ogg Vorbis file" );
- }catch( IOException e ) {
- throw new FormatDecodeException( "could not decode file: " + e.toString() );
- }catch( RuntimeException e ) {
- throw new FormatDecodeException( "error decoding file: " + e.toString() );
- }
- }
-
- /**
- * Get the type of this file. This is usually the compression format
- * itself (e.g. "OGG" or "MP3"). If there are different taggings for
- * this format, the used tag format is appended after a slash (e.g.
- * "MP3/id3v2").
- *
- * @return The type
- */
- public String getType() {
- return "OGG";
- }
-
- /**
- * Get the artist.
- *
- * @return The artist (never null)
- */
- public String getArtist() {
- String val = cmt.getArtist();
- if( val==null ) val="";
- return val.trim();
- }
-
- /**
- * Get the album.
- *
- * @return The album (never null)
- */
- public String getAlbum() {
- String val = cmt.getAlbum();
- if( val==null ) val="";
- return val.trim();
- }
-
- /**
- * Get the title.
- *
- * @return The title (never null)
- */
- public String getTitle() {
- String val = cmt.getTitle();
- if( val==null ) val="";
- return val.trim();
- }
-
- /**
- * Get the genre.
- *
- * @return The genre (never null)
- */
- public String getGenre() {
- String val = cmt.getGenre();
- if( val==null ) val="";
- return val.trim();
- }
-
- /**
- * Get the year.
- *
- * @return The year (never null)
- */
- public String getYear() {
- String val = cmt.getDate();
- if( val==null ) val="";
- return val.trim();
- }
-
- /**
- * Get the comment.
- *
- * @return The comment (never null)
- */
- public String getComment() {
- String val = cmt.getDescription();
- if( val==null ) {
- // *sigh* The Ogg Vorbis documentation does not explicitely
- // state the comment types. So there are some ogg writers
- // around that use COMMENT instead of DESCRIPTION. We will
- // use COMMENT if DESCRIPTION was empty.
- val = cmt.getComment("COMMENT");
- }
- if( val==null )
- val="";
- return val.trim();
- }
-
- /**
- * Get the track.
- *
- * @return The track (never null)
- */
- public String getTrack() {
- String val = cmt.getTrackNumber();
- if( val==null ) val="";
- return val.trim();
- }
-
-}
diff --git a/songdbj/org/tritonus/file/AiffAudioFileReader.java b/songdbj/org/tritonus/file/AiffAudioFileReader.java
deleted file mode 100644
index 139ba05425..0000000000
--- a/songdbj/org/tritonus/file/AiffAudioFileReader.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * AiffAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-import org.tritonus.share.TDebug;
-
-
-/** Class for reading AIFF and AIFF-C files.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class AiffAudioFileReader extends TAudioFileReader
-{
- private static final int READ_LIMIT = 1000;
-
-
-
- public AiffAudioFileReader()
- {
- super(READ_LIMIT);
- }
-
-
-
- private void skipChunk(DataInputStream dataInputStream, int chunkLength, int chunkRead)
- throws IOException {
- chunkLength-=chunkRead;
- if (chunkLength>0) {
- dataInputStream.skip(chunkLength + (chunkLength % 2));
- }
- }
-
- private AudioFormat readCommChunk(DataInputStream dataInputStream, int chunkLength)
- throws IOException, UnsupportedAudioFileException {
-
- int nNumChannels = dataInputStream.readShort();
- if (nNumChannels <= 0) {
- throw new UnsupportedAudioFileException(
- "not an AIFF file: number of channels must be positive");
- }
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("Found "+nNumChannels+" channels.");
- }
- // ignored: frame count
- dataInputStream.readInt();
- int nSampleSize = dataInputStream.readShort();
- float fSampleRate = (float) readIeeeExtended(dataInputStream);
- if (fSampleRate <= 0.0) {
- throw new UnsupportedAudioFileException(
- "not an AIFF file: sample rate must be positive");
- }
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("Found framerate "+fSampleRate);
- }
- AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
- int nRead=18;
- if (chunkLength>nRead) {
- int nEncoding=dataInputStream.readInt();
- nRead+=4;
- if (nEncoding==AiffTool.AIFF_COMM_PCM) {
- // PCM - nothing to do
- }
- else if (nEncoding==AiffTool.AIFF_COMM_ULAW) {
- // ULAW
- encoding=AudioFormat.Encoding.ULAW;
- nSampleSize=8;
- }
- else if (nEncoding==AiffTool.AIFF_COMM_IMA_ADPCM) {
- encoding = new AudioFormat.Encoding("IMA_ADPCM");
- nSampleSize=4;
- }
- else {
- throw new UnsupportedAudioFileException(
- "Encoding 0x"+Integer.toHexString(nEncoding)
- +" of AIFF file not supported");
- }
- }
- /* In case of IMA ADPCM, frame size is 0.5 bytes (since it is
- always mono). A value of 1 as frame size would be wrong.
- Handling of frame size 0 in defined nowhere. So the best
- solution is to set the frame size to unspecified (-1).
- */
- int nFrameSize = (nSampleSize == 4) ?
- AudioSystem.NOT_SPECIFIED :
- calculateFrameSize(nSampleSize, nNumChannels);
- if (TDebug.TraceAudioFileReader) { TDebug.out("calculated frame size: " + nFrameSize); }
- skipChunk(dataInputStream, chunkLength, nRead);
- AudioFormat format = new AudioFormat(encoding,
- fSampleRate,
- nSampleSize,
- nNumChannels,
- nFrameSize,
- fSampleRate,
- true);
- return format;
- }
-
- private void readVerChunk(DataInputStream dataInputStream, int chunkLength)
- throws IOException, UnsupportedAudioFileException {
- if (chunkLength<4) {
- throw new UnsupportedAudioFileException(
- "Corrput AIFF file: FVER chunk too small.");
- }
- int nVer=dataInputStream.readInt();
- if (nVer!=AiffTool.AIFF_FVER_TIME_STAMP) {
- throw new UnsupportedAudioFileException(
- "Unsupported AIFF file: version not known.");
- }
- skipChunk(dataInputStream, chunkLength, 4);
- }
-
-
-
- protected AudioFileFormat getAudioFileFormat(InputStream inputStream, long lFileSizeInBytes)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("AiffAudioFileReader.getAudioFileFormat(InputStream, long): begin"); }
- DataInputStream dataInputStream = new DataInputStream(inputStream);
- int nMagic = dataInputStream.readInt();
- if (nMagic != AiffTool.AIFF_FORM_MAGIC) {
- throw new UnsupportedAudioFileException(
- "not an AIFF file: header magic is not FORM");
- }
- int nTotalLength = dataInputStream.readInt();
- nMagic = dataInputStream.readInt();
- boolean bIsAifc;
- if (nMagic == AiffTool.AIFF_AIFF_MAGIC) {
- bIsAifc = false;
- } else if (nMagic == AiffTool.AIFF_AIFC_MAGIC) {
- bIsAifc = true;
- } else {
- throw new UnsupportedAudioFileException(
- "unsupported IFF file: header magic neither AIFF nor AIFC");
- }
- boolean bFVerFound=!bIsAifc;
- boolean bCommFound=false;
- boolean bSSndFound=false;
- AudioFormat format=null;
- int nDataChunkLength=0;
-
- // walk through the chunks
- // chunks may be in any order. However, in this implementation, SSND must be last
- while (!bFVerFound || !bCommFound || !bSSndFound) {
- nMagic = dataInputStream.readInt();
- int nChunkLength = dataInputStream.readInt();
- switch (nMagic) {
- case AiffTool.AIFF_COMM_MAGIC:
- format=readCommChunk(dataInputStream, nChunkLength);
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("Read COMM chunk with length "+nChunkLength);
- }
- bCommFound=true;
- break;
- case AiffTool.AIFF_FVER_MAGIC:
- if (!bFVerFound) {
- readVerChunk(dataInputStream, nChunkLength);
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("Read FVER chunk with length "+nChunkLength);
- }
- bFVerFound=true;
- } else {
- skipChunk(dataInputStream, nChunkLength, 0);
- }
- break;
- case AiffTool.AIFF_SSND_MAGIC:
- if (!bCommFound || !bFVerFound) {
- throw new UnsupportedAudioFileException(
- "cannot handle AIFF file: SSND not last chunk");
- }
- bSSndFound=true;
- nDataChunkLength=nChunkLength-8;
- // 8 information bytes of no interest
- dataInputStream.skip(8);
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("Found SSND chunk with length "+nChunkLength);
- }
- break;
- default:
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("Skipping unknown chunk: "
- +Integer.toHexString(nMagic));
- }
- skipChunk(dataInputStream, nChunkLength, 0);
- break;
- }
- }
-
- // TODO: length argument has to be in frames
- AudioFileFormat audioFileFormat = new TAudioFileFormat(
- bIsAifc ? AudioFileFormat.Type.AIFC : AudioFileFormat.Type.AIFF,
- format,
- nDataChunkLength / format.getFrameSize(),
- nTotalLength + 8);
- if (TDebug.TraceAudioFileReader) {TDebug.out("AiffAudioFileReader.getAudioFileFormat(InputStream, long): end"); }
- return audioFileFormat;
- }
-}
-
-
-
-/*** AiffAudioFileReader.java ***/
diff --git a/songdbj/org/tritonus/file/AiffAudioFileWriter.java b/songdbj/org/tritonus/file/AiffAudioFileWriter.java
deleted file mode 100644
index cfd6996ae9..0000000000
--- a/songdbj/org/tritonus/file/AiffAudioFileWriter.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * AiffAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.AudioOutputStream;
-import org.tritonus.share.sampled.file.TAudioFileWriter;
-import org.tritonus.share.sampled.file.TDataOutputStream;
-
-
-/**
- * Class for writing AIFF and AIFF-C files.
- *
- * @author Florian Bomers
- */
-
-public class AiffAudioFileWriter extends TAudioFileWriter {
-
- private static final AudioFileFormat.Type[] FILE_TYPES =
- {
- AudioFileFormat.Type.AIFF,
- AudioFileFormat.Type.AIFC
- };
-
- private static final int ALL=AudioSystem.NOT_SPECIFIED;
- private static final AudioFormat.Encoding PCM_SIGNED = AudioFormat.Encoding.PCM_SIGNED;
- private static final AudioFormat.Encoding ULAW = AudioFormat.Encoding.ULAW;
- private static final AudioFormat.Encoding IMA_ADPCM = new AudioFormat.Encoding("IMA_ADPCM");
-
- // IMPORTANT: this array depends on the AudioFormat.match() algorithm which takes
- // AudioSystem.NOT_SPECIFIED into account !
- private static final AudioFormat[] AUDIO_FORMATS =
- {
- new AudioFormat(PCM_SIGNED, ALL, 8, ALL, ALL, ALL, true),
- new AudioFormat(PCM_SIGNED, ALL, 8, ALL, ALL, ALL, false),
- new AudioFormat(ULAW, ALL, 8, ALL, ALL, ALL, false),
- new AudioFormat(ULAW, ALL, 8, ALL, ALL, ALL, true),
- new AudioFormat(PCM_SIGNED, ALL, 16, ALL, ALL, ALL, true),
- new AudioFormat(PCM_SIGNED, ALL, 24, ALL, ALL, ALL, true),
- new AudioFormat(PCM_SIGNED, ALL, 32, ALL, ALL, ALL, true),
- new AudioFormat(IMA_ADPCM, ALL, 4, ALL, ALL, ALL, true),
- new AudioFormat(IMA_ADPCM, ALL, 4, ALL, ALL, ALL, false),
- };
-
- public AiffAudioFileWriter() {
- super(Arrays.asList(FILE_TYPES),
- Arrays.asList(AUDIO_FORMATS));
- }
-
-
- protected boolean isAudioFormatSupportedImpl(AudioFormat format,
- AudioFileFormat.Type fileType) {
- return AiffTool.getFormatCode(format)!=AiffTool.AIFF_COMM_UNSPECIFIED;
- }
-
-
- protected AudioOutputStream getAudioOutputStream(AudioFormat audioFormat,
- long lLengthInBytes,
- AudioFileFormat.Type fileType,
- TDataOutputStream dataOutputStream) throws IOException {
- return new AiffAudioOutputStream(audioFormat, fileType,
- lLengthInBytes,
- dataOutputStream);
- }
-
-}
-
-/*** AiffAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/file/AiffAudioOutputStream.java b/songdbj/org/tritonus/file/AiffAudioOutputStream.java
deleted file mode 100644
index d0006ebfe0..0000000000
--- a/songdbj/org/tritonus/file/AiffAudioOutputStream.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * AiffAudioOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.IOException;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioOutputStream;
-import org.tritonus.share.sampled.file.TDataOutputStream;
-
-
-/**
- * AudioOutputStream for AIFF and AIFF-C files.
- *
- * @author Florian Bomers
- */
-public class AiffAudioOutputStream extends TAudioOutputStream {
-
- // this constant is used for chunk lengths when the length is not known yet
- private static final int LENGTH_NOT_KNOWN=-1;
-
- private AudioFileFormat.Type m_FileType;
-
- public AiffAudioOutputStream(AudioFormat audioFormat,
- AudioFileFormat.Type fileType,
- long lLength,
- TDataOutputStream dataOutputStream) {
- super(audioFormat,
- lLength,
- dataOutputStream,
- lLength == AudioSystem.NOT_SPECIFIED
- && dataOutputStream.supportsSeek());
- // AIFF files cannot exceed 2GB
- if (lLength != AudioSystem.NOT_SPECIFIED && lLength>0x7FFFFFFFl) {
- throw new IllegalArgumentException(
- "AIFF files cannot be larger than 2GB.");
- }
- // IDEA: write AIFF file instead of AIFC when encoding=PCM ?
- m_FileType=fileType;
- if (!audioFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
- && !audioFormat.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED)) {
- // only AIFC files can handle non-pcm data
- m_FileType=AudioFileFormat.Type.AIFC;
- }
- }
-
- protected void writeHeader()
- throws IOException {
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("AiffAudioOutputStream.writeHeader(): called.");
- }
- AudioFormat format = getFormat();
- boolean bIsAifc = m_FileType.equals(AudioFileFormat.Type.AIFC);
- long lLength = getLength();
- TDataOutputStream dos = getDataOutputStream();
- int nCommChunkSize=18;
- int nFormatCode=AiffTool.getFormatCode(format);
- if (bIsAifc) {
- // encoding takes 4 bytes
- // encoding name takes at minimum 2 bytes
- nCommChunkSize+=6;
- }
- int nHeaderSize=4 // magic
- +8+nCommChunkSize // COMM chunk
- +8; // header of SSND chunk
- if (bIsAifc) {
- // add length for FVER chunk
- nHeaderSize+=12;
- }
- // if patching the header, and the length has not been known at first
- // writing of the header, just truncate the size fields, don't throw an exception
- if (lLength != AudioSystem.NOT_SPECIFIED && lLength+nHeaderSize>0x7FFFFFFFl) {
- lLength=0x7FFFFFFFl-nHeaderSize;
- }
- // chunks must be on word-boundaries
- long lSSndChunkSize=(lLength!=AudioSystem.NOT_SPECIFIED)?
- (lLength+(lLength%2)+8):AudioSystem.NOT_SPECIFIED;
-
- // write IFF container chunk
- dos.writeInt(AiffTool.AIFF_FORM_MAGIC);
- dos.writeInt((lLength!=AudioSystem.NOT_SPECIFIED)?
- ((int) (lSSndChunkSize+nHeaderSize)):LENGTH_NOT_KNOWN);
- if (bIsAifc) {
- dos.writeInt(AiffTool.AIFF_AIFC_MAGIC);
- // write FVER chunk
- dos.writeInt(AiffTool.AIFF_FVER_MAGIC);
- dos.writeInt(4);
- dos.writeInt(AiffTool.AIFF_FVER_TIME_STAMP);
- } else {
- dos.writeInt(AiffTool.AIFF_AIFF_MAGIC);
- }
-
- // write COMM chunk
- dos.writeInt(AiffTool.AIFF_COMM_MAGIC);
- dos.writeInt(nCommChunkSize);
- dos.writeShort((short) format.getChannels());
- dos.writeInt((lLength!=AudioSystem.NOT_SPECIFIED)?
- ((int) (lLength / format.getFrameSize())):LENGTH_NOT_KNOWN);
- if (nFormatCode==AiffTool.AIFF_COMM_ULAW) {
- // AIFF ulaw states 16 bits for ulaw data
- dos.writeShort(16);
- } else {
- dos.writeShort((short) format.getSampleSizeInBits());
- }
- writeIeeeExtended(dos, format.getSampleRate());
- if (bIsAifc) {
- dos.writeInt(nFormatCode);
- dos.writeShort(0); // no encoding name
- // TODO: write encoding.toString() ??
- }
-
- // write header of SSND chunk
-
-
-
- dos.writeInt(AiffTool.AIFF_SSND_MAGIC);
- // don't use lSSndChunkSize here !
- dos.writeInt((lLength!=AudioSystem.NOT_SPECIFIED)
- ?((int) (lLength+8)):LENGTH_NOT_KNOWN);
- // 8 information bytes of no interest
- dos.writeInt(0); // offset
- dos.writeInt(0); // blocksize
- }
-
-
-
-
- protected void patchHeader()
- throws IOException {
- TDataOutputStream tdos = getDataOutputStream();
- tdos.seek(0);
- setLengthFromCalculatedLength();
- writeHeader();
- }
-
- public void close() throws IOException {
- long nBytesWritten=getCalculatedLength();
-
- if ((nBytesWritten % 2)==1) {
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("AiffOutputStream.close(): adding padding byte");
- }
- // extra byte for to align on word boundaries
- TDataOutputStream tdos = getDataOutputStream();
- tdos.writeByte(0);
- // DON'T adjust calculated length !
- }
-
-
-
- super.close();
- }
-
- public void writeIeeeExtended(TDataOutputStream dos, float sampleRate) throws IOException {
- // currently, only integer sample rates are written
- // TODO: real conversion
- // I don't know exactly how much I have to shift left the mantisse for normalisation
- // now I do it so that there are any bits set in the first 5 bits
- int nSampleRate=(int) sampleRate;
- short ieeeExponent=0;
- while ((nSampleRate!=0) && (nSampleRate & 0x80000000)==0) {
- ieeeExponent++;
- nSampleRate<<=1;
- }
- dos.writeShort(16414-ieeeExponent); // exponent
- dos.writeInt(nSampleRate); // mantisse high double word
- dos.writeInt(0); // mantisse low double word
- }
-
-
-
-
-}
-
-/*** AiffAudioOutputStream.java ***/
diff --git a/songdbj/org/tritonus/file/AiffTool.java b/songdbj/org/tritonus/file/AiffTool.java
deleted file mode 100644
index 39cdbf0878..0000000000
--- a/songdbj/org/tritonus/file/AiffTool.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * AiffTool.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-
-
-/**
- * Common constants and methods for handling aiff and aiff-c files.
- *
- * @author Florian Bomers
- */
-
-public class AiffTool {
-
- public static final int AIFF_FORM_MAGIC = 0x464F524D;
- public static final int AIFF_AIFF_MAGIC = 0x41494646;
- public static final int AIFF_AIFC_MAGIC = 0x41494643;
- public static final int AIFF_COMM_MAGIC = 0x434F4D4D;
- public static final int AIFF_SSND_MAGIC = 0x53534E44;
- public static final int AIFF_FVER_MAGIC = 0x46564552;
- public static final int AIFF_COMM_UNSPECIFIED = 0x00000000; // "0000"
- public static final int AIFF_COMM_PCM = 0x4E4F4E45; // "NONE"
- public static final int AIFF_COMM_ULAW = 0x756C6177; // "ulaw"
- public static final int AIFF_COMM_IMA_ADPCM = 0x696D6134; // "ima4"
- public static final int AIFF_FVER_TIME_STAMP = 0xA2805140; // May 23, 1990, 2:40pm
-
- public static int getFormatCode(AudioFormat format) {
- AudioFormat.Encoding encoding = format.getEncoding();
- int nSampleSize = format.getSampleSizeInBits();
- boolean bigEndian = format.isBigEndian();
- // $$fb 2000-08-16: check the frame size, too.
- boolean frameSizeOK=format.getFrameSize()==AudioSystem.NOT_SPECIFIED
- || format.getChannels()!=AudioSystem.NOT_SPECIFIED
- || format.getFrameSize()==nSampleSize/8*format.getChannels();
-
- if ((encoding.equals(AudioFormat.Encoding.PCM_SIGNED))
- && ((bigEndian && nSampleSize>=16 && nSampleSize<=32) || (nSampleSize==8))
- && frameSizeOK) {
- return AIFF_COMM_PCM;
- } else if (encoding.equals(AudioFormat.Encoding.ULAW) && nSampleSize == 8 && frameSizeOK) {
- return AIFF_COMM_ULAW;
- } else if (encoding.equals(new AudioFormat.Encoding("IMA_ADPCM")) && nSampleSize == 4) {
- return AIFF_COMM_IMA_ADPCM;
- } else {
- return AIFF_COMM_UNSPECIFIED;
- }
- }
-
-}
-
-/*** AiffTool.java ***/
diff --git a/songdbj/org/tritonus/file/AuAudioFileReader.java b/songdbj/org/tritonus/file/AuAudioFileReader.java
deleted file mode 100644
index b527920118..0000000000
--- a/songdbj/org/tritonus/file/AuAudioFileReader.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * AuAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999,2000,2001 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-import javax.sound.sampled.spi.AudioFileReader;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-
-/** Class for reading Sun/Next AU files.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class AuAudioFileReader extends TAudioFileReader
-{
- private static final int READ_LIMIT = 1000;
-
-
-
- public AuAudioFileReader()
- {
- super(READ_LIMIT);
- }
-
-
-
- private static String readDescription(DataInputStream dis, int len) throws IOException {
- byte c=-1;
- String ret="";
- while (len>0 && (c=dis.readByte())!=0) {
- ret=ret+(char) c;
- len--;
- }
- if (len>1 && c==0) {
- dis.skip(len-1);
- }
- return ret;
- }
-
-
-
- protected AudioFileFormat getAudioFileFormat(InputStream inputStream, long lFileSizeInBytes)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("AuAudioFileReader.getAudioFileFormat(InputStream, long): begin"); }
- DataInputStream dataInputStream = new DataInputStream(inputStream);
- int nMagic = dataInputStream.readInt();
- if (nMagic != AuTool.AU_HEADER_MAGIC) {
- throw new UnsupportedAudioFileException(
- "not an AU file: wrong header magic");
- }
- int nDataOffset = dataInputStream.readInt();
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("AuAudioFileReader.getAudioFileFormat(): data offset: " + nDataOffset);
- }
- if (nDataOffset < AuTool.DATA_OFFSET) {
- throw new UnsupportedAudioFileException(
- "not an AU file: data offset must be 24 or greater");
- }
- int nDataLength = dataInputStream.readInt();
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("AuAudioFileReader.getAudioFileFormat(): data length: " + nDataLength);
- }
- if (nDataLength < 0 && nDataLength!=AuTool.AUDIO_UNKNOWN_SIZE) {
- throw new UnsupportedAudioFileException(
- "not an AU file: data length must be positive, 0 or -1 for unknown");
- }
- AudioFormat.Encoding encoding = null;
- int nSampleSize = 0;
- int nEncoding = dataInputStream.readInt();
- switch (nEncoding) {
- case AuTool.SND_FORMAT_MULAW_8: // 8-bit uLaw G.711
- encoding = AudioFormat.Encoding.ULAW;
- nSampleSize = 8;
- break;
-
- case AuTool.SND_FORMAT_LINEAR_8:
- encoding = AudioFormat.Encoding.PCM_SIGNED;
- nSampleSize = 8;
- break;
-
- case AuTool.SND_FORMAT_LINEAR_16:
- encoding = AudioFormat.Encoding.PCM_SIGNED;
- nSampleSize = 16;
- break;
-
- case AuTool.SND_FORMAT_LINEAR_24:
- encoding = AudioFormat.Encoding.PCM_SIGNED;
- nSampleSize = 24;
- break;
-
- case AuTool.SND_FORMAT_LINEAR_32:
- encoding = AudioFormat.Encoding.PCM_SIGNED;
- nSampleSize = 32;
- break;
-
- case AuTool.SND_FORMAT_ALAW_8: // 8-bit aLaw G.711
- encoding = AudioFormat.Encoding.ALAW;
- nSampleSize = 8;
- break;
- }
- if (nSampleSize == 0) {
- throw new UnsupportedAudioFileException(
- "unsupported AU file: unknown encoding " + nEncoding);
- }
- int nSampleRate = dataInputStream.readInt();
- if (nSampleRate <= 0) {
- throw new UnsupportedAudioFileException(
- "corrupt AU file: sample rate must be positive");
- }
- int nNumChannels = dataInputStream.readInt();
- if (nNumChannels <= 0) {
- throw new UnsupportedAudioFileException(
- "corrupt AU file: number of channels must be positive");
- }
- // skip header information field
- inputStream.skip(nDataOffset - AuTool.DATA_OFFSET);
- // read header info field
- //String desc=readDescription(dataInputStream, nDataOffset - AuTool.DATA_OFFSET);
-
- AudioFormat format = new AudioFormat(encoding,
- (float) nSampleRate,
- nSampleSize,
- nNumChannels,
- calculateFrameSize(nSampleSize, nNumChannels),
- (float) nSampleRate,
- true);
- AudioFileFormat audioFileFormat = new TAudioFileFormat(
- AudioFileFormat.Type.AU,
- format,
- (nDataLength==AuTool.AUDIO_UNKNOWN_SIZE)?
- AudioSystem.NOT_SPECIFIED:(nDataLength / format.getFrameSize()),
- (nDataLength==AuTool.AUDIO_UNKNOWN_SIZE)?
- AudioSystem.NOT_SPECIFIED:(nDataLength + nDataOffset));
- if (TDebug.TraceAudioFileReader) { TDebug.out("AuAudioFileReader.getAudioFileFormat(InputStream, long): begin"); }
- return audioFileFormat;
- }
-}
-
-
-
-/*** AuAudioFileReader.java ***/
-
diff --git a/songdbj/org/tritonus/file/AuAudioFileWriter.java b/songdbj/org/tritonus/file/AuAudioFileWriter.java
deleted file mode 100644
index 5ac80a8c8a..0000000000
--- a/songdbj/org/tritonus/file/AuAudioFileWriter.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * AuAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999,2000,2001 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.AudioOutputStream;
-import org.tritonus.share.sampled.file.TAudioFileWriter;
-import org.tritonus.share.sampled.file.TDataOutputStream;
-
-
-/**
- * AudioFileWriter for Sun/Next AU files.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class AuAudioFileWriter extends TAudioFileWriter {
-
- private static final AudioFileFormat.Type[] FILE_TYPES =
- {
- AudioFileFormat.Type.AU
- };
-
- private static final int ALL=AudioSystem.NOT_SPECIFIED;
-
- // IMPORTANT: this array depends on the AudioFormat.match() algorithm which takes
- // AudioSystem.NOT_SPECIFIED into account !
- private static final AudioFormat[] AUDIO_FORMATS =
- {
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 8, ALL, ALL, ALL, true),
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 8, ALL, ALL, ALL, false),
-
- new AudioFormat(AudioFormat.Encoding.ULAW, ALL, 8, ALL, ALL, ALL, false),
- new AudioFormat(AudioFormat.Encoding.ULAW, ALL, 8, ALL, ALL, ALL, true),
-
- new AudioFormat(AudioFormat.Encoding.ALAW, ALL, 8, ALL, ALL, ALL, false),
- new AudioFormat(AudioFormat.Encoding.ALAW, ALL, 8, ALL, ALL, ALL, true),
-
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 16, ALL, ALL, ALL, true),
-
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 24, ALL, ALL, ALL, true),
-
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 32, ALL, ALL, ALL, true),
- };
-
- public AuAudioFileWriter() {
- super(Arrays.asList(FILE_TYPES),
- Arrays.asList(AUDIO_FORMATS));
- }
-
-
- protected boolean isAudioFormatSupportedImpl(AudioFormat format,
- AudioFileFormat.Type fileType) {
- return AuTool.getFormatCode(format)!=AuTool.SND_FORMAT_UNSPECIFIED;
- }
- protected AudioOutputStream getAudioOutputStream(AudioFormat audioFormat,
- long lLengthInBytes,
- AudioFileFormat.Type fileType,
- TDataOutputStream dataOutputStream) throws IOException {
- return new AuAudioOutputStream(audioFormat,
- lLengthInBytes,
- dataOutputStream);
- }
-
-}
-
-/*** AuAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/file/AuAudioOutputStream.java b/songdbj/org/tritonus/file/AuAudioOutputStream.java
deleted file mode 100644
index 9f33e7a2aa..0000000000
--- a/songdbj/org/tritonus/file/AuAudioOutputStream.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * AuAudioOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000,2001 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.IOException;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioOutputStream;
-import org.tritonus.share.sampled.file.TDataOutputStream;
-
-
-
-/**
- * AudioOutputStream for AU files.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-
-public class AuAudioOutputStream extends TAudioOutputStream {
-
- private static String description="Created by Tritonus";
-
- /**
- * Writes a null-terminated ascii string s to f.
- * The total number of bytes written is aligned on a 2byte boundary.
- * @exception IOException Write error.
- */
- protected static void writeText(TDataOutputStream dos, String s) throws IOException {
- if (s.length()>0) {
- dos.writeBytes(s);
- dos.writeByte(0); // pour terminer le texte
- if ((s.length() % 2)==0) {
- // ajout d'un zero pour faire la longeur pair
- dos.writeByte(0);
- }
- }
- }
-
- /**
- * Returns number of bytes that have to written for string s (with alignment)
- */
- protected static int getTextLength(String s) {
- if (s.length()==0) {
- return 0;
- } else {
- return (s.length()+2) & 0xFFFFFFFE;
- }
- }
-
- public AuAudioOutputStream(AudioFormat audioFormat,
- long lLength,
- TDataOutputStream dataOutputStream) {
- // if length exceeds 2GB, set the length field to NOT_SPECIFIED
- super(audioFormat,
- lLength>0x7FFFFFFFl?AudioSystem.NOT_SPECIFIED:lLength,
- dataOutputStream,
- lLength == AudioSystem.NOT_SPECIFIED && dataOutputStream.supportsSeek());
- }
-
- protected void writeHeader() throws IOException {
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("AuAudioOutputStream.writeHeader(): called.");
- }
- AudioFormat format = getFormat();
- long lLength = getLength();
- TDataOutputStream dos = getDataOutputStream();
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("AuAudioOutputStream.writeHeader(): AudioFormat: " + format);
- TDebug.out("AuAudioOutputStream.writeHeader(): length: " + lLength);
- }
-
- dos.writeInt(AuTool.AU_HEADER_MAGIC);
- dos.writeInt(AuTool.DATA_OFFSET+getTextLength(description));
- dos.writeInt((lLength!=AudioSystem.NOT_SPECIFIED)?((int) lLength):AuTool.AUDIO_UNKNOWN_SIZE);
- dos.writeInt(AuTool.getFormatCode(format));
- dos.writeInt((int) format.getSampleRate());
- dos.writeInt(format.getChannels());
- writeText(dos, description);
- }
-
- protected void patchHeader() throws IOException {
- TDataOutputStream tdos = getDataOutputStream();
- tdos.seek(0);
- setLengthFromCalculatedLength();
- writeHeader();
- }
-}
-
-/*** AuAudioOutputStream.java ***/
diff --git a/songdbj/org/tritonus/file/AuTool.java b/songdbj/org/tritonus/file/AuTool.java
deleted file mode 100644
index bcdc62f86c..0000000000
--- a/songdbj/org/tritonus/file/AuTool.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * AuTool.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000,2001 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-
-
-/** Common constants and methods for handling au files.
- *
- * @author Florian Bomers
- */
-
-public class AuTool {
-
- public static final int AU_HEADER_MAGIC = 0x2e736e64;
- public static final int AUDIO_UNKNOWN_SIZE = -1;
-
- // length of header in bytes
- public static final int DATA_OFFSET = 24;
-
- public static final int SND_FORMAT_UNSPECIFIED = 0;
- public static final int SND_FORMAT_MULAW_8 = 1;
- public static final int SND_FORMAT_LINEAR_8 = 2;
- public static final int SND_FORMAT_LINEAR_16 = 3;
- public static final int SND_FORMAT_LINEAR_24 = 4;
- public static final int SND_FORMAT_LINEAR_32 = 5;
- public static final int SND_FORMAT_FLOAT = 6;
- public static final int SND_FORMAT_DOUBLE = 7;
- public static final int SND_FORMAT_ADPCM_G721 = 23;
- public static final int SND_FORMAT_ADPCM_G722 = 24;
- public static final int SND_FORMAT_ADPCM_G723_3 = 25;
- public static final int SND_FORMAT_ADPCM_G723_5 = 26;
- public static final int SND_FORMAT_ALAW_8 = 27;
-
- public static int getFormatCode(AudioFormat format) {
- AudioFormat.Encoding encoding = format.getEncoding();
- int nSampleSize = format.getSampleSizeInBits();
- // must be big endian for >8 bit formats
- boolean bigEndian = format.isBigEndian();
- // $$fb 2000-08-16: check the frame size, too.
- boolean frameSizeOK=(
- format.getFrameSize()==AudioSystem.NOT_SPECIFIED
- || format.getChannels()!=AudioSystem.NOT_SPECIFIED
- || format.getFrameSize()==nSampleSize/8*format.getChannels());
-
- if (encoding.equals(AudioFormat.Encoding.ULAW) && nSampleSize == 8 && frameSizeOK) {
- return SND_FORMAT_MULAW_8;
- } else if (encoding.equals(AudioFormat.Encoding.PCM_SIGNED) && frameSizeOK) {
- if (nSampleSize == 8) {
- return SND_FORMAT_LINEAR_8;
- } else if (nSampleSize == 16 && bigEndian) {
- return SND_FORMAT_LINEAR_16;
- } else if (nSampleSize == 24 && bigEndian) {
- return SND_FORMAT_LINEAR_24;
- } else if (nSampleSize == 32 && bigEndian) {
- return SND_FORMAT_LINEAR_32;
- }
- } else if (encoding.equals(AudioFormat.Encoding.ALAW) && nSampleSize == 8 && frameSizeOK) {
- return SND_FORMAT_ALAW_8;
- }
- return SND_FORMAT_UNSPECIFIED;
- }
-}
-
-/*** AuTool.java ***/
diff --git a/songdbj/org/tritonus/file/WaveAudioFileReader.java b/songdbj/org/tritonus/file/WaveAudioFileReader.java
deleted file mode 100644
index 62d3f1a9ea..0000000000
--- a/songdbj/org/tritonus/file/WaveAudioFileReader.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * WaveAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999,2000 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.UnsupportedAudioFileException;
-import javax.sound.sampled.spi.AudioFileReader;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-
-/**
- * Class for reading wave files.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-
-public class WaveAudioFileReader extends TAudioFileReader
-{
- private static final int READ_LIMIT = 1000;
-
-
-
- public WaveAudioFileReader()
- {
- super(READ_LIMIT);
- }
-
-
-
- protected void advanceChunk(DataInputStream dis, long prevLength, long prevRead)
- throws IOException {
- if (prevLength>0) {
- dis.skip(((prevLength+1) & 0xFFFFFFFE)-prevRead);
- }
- }
-
-
- protected long findChunk(DataInputStream dis, int key)
- throws UnsupportedAudioFileException, IOException {
- // $$fb 1999-12-18: we should take care that we don't exceed
- // the mark of this stream. When we exceeded the mark and
- // we notice that we don't support this wave file,
- // other potential wave file readers have no chance.
- int thisKey;
- long chunkLength=0;
- do {
- advanceChunk(dis, chunkLength, 0);
- try {
- thisKey = dis.readInt();
- } catch (IOException e)
- {
- if (TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- // $$fb: when we come here, we skipped past the end of the wave file
- // without finding the chunk.
- // IMHO, this is not an IOException, as there are incarnations
- // of WAVE files which store data in different chunks.
- // maybe we can find a nice description of the "required chunk" ?
- throw new UnsupportedAudioFileException(
- "unsupported WAVE file: required chunk not found.");
- }
- chunkLength = readLittleEndianInt(dis) & 0xFFFFFFFF; // unsigned
- }
- while (thisKey != key);
- return chunkLength;
- }
-
- protected AudioFormat readFormatChunk(DataInputStream dis,
- long chunkLength) throws UnsupportedAudioFileException, IOException {
- String debugAdd="";
-
- int read=WaveTool.MIN_FMT_CHUNK_LENGTH;
-
- if (chunkLength<WaveTool.MIN_FMT_CHUNK_LENGTH) {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: format chunk is too small");
- }
-
- short formatCode=readLittleEndianShort(dis);
- short channelCount = readLittleEndianShort(dis);
- if (channelCount <= 0) {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: number of channels must be positive");
- }
-
- int sampleRate = readLittleEndianInt(dis);
- if (sampleRate <= 0) {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: sample rate must be positive");
- }
-
- int avgBytesPerSecond=readLittleEndianInt(dis);
- int blockAlign=readLittleEndianShort(dis);
-
- AudioFormat.Encoding encoding;
- int sampleSizeInBits;
- int frameSize=0;
- float frameRate=(float) sampleRate;
-
- int cbSize = 0;
- switch (formatCode) {
- case WaveTool.WAVE_FORMAT_PCM:
- if (chunkLength<WaveTool.MIN_FMT_CHUNK_LENGTH+2) {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: format chunk is too small");
- }
- sampleSizeInBits = readLittleEndianShort(dis);
- if (sampleSizeInBits <= 0) {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: sample size must be positive");
- }
- encoding = (sampleSizeInBits <= 8) ?
- AudioFormat.Encoding.PCM_UNSIGNED : AudioFormat.Encoding.PCM_SIGNED;
- if (TDebug.TraceAudioFileReader) {
- debugAdd+=", wBitsPerSample="+sampleSizeInBits;
- }
- read+=2;
- break;
- case WaveTool.WAVE_FORMAT_ALAW:
- sampleSizeInBits = 8;
- encoding = AudioFormat.Encoding.ALAW;
- break;
- case WaveTool.WAVE_FORMAT_ULAW:
- sampleSizeInBits = 8;
- encoding = AudioFormat.Encoding.ULAW;
- break;
- case WaveTool.WAVE_FORMAT_GSM610:
- if (chunkLength<WaveTool.MIN_FMT_CHUNK_LENGTH+6) {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: extra GSM bytes are missing");
- }
- sampleSizeInBits = readLittleEndianShort(dis); // sample Size (is 0 for GSM)
- cbSize=readLittleEndianShort(dis);
- if (cbSize < 2) {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: extra GSM bytes are corrupt");
- }
- int decodedSamplesPerBlock=readLittleEndianShort(dis) & 0xFFFF; // unsigned
- if (TDebug.TraceAudioFileReader) {
- debugAdd+=", wBitsPerSample="+sampleSizeInBits
- +", cbSize="+cbSize
- +", wSamplesPerBlock="+decodedSamplesPerBlock;
- }
- sampleSizeInBits = AudioSystem.NOT_SPECIFIED;
- encoding = WaveTool.GSM0610;
- frameSize=blockAlign;
- frameRate=((float) sampleRate)/((float) decodedSamplesPerBlock);
- read+=6;
- break;
-
- case WaveTool.WAVE_FORMAT_IMA_ADPCM:
- if (chunkLength < WaveTool.MIN_FMT_CHUNK_LENGTH + 2)
- {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: extra GSM bytes are missing");
- }
- sampleSizeInBits = readLittleEndianShort(dis);
- cbSize = readLittleEndianShort(dis);
- if (cbSize < 2)
- {
- throw new UnsupportedAudioFileException(
- "corrupt WAVE file: extra IMA ADPCM bytes are corrupt");
- }
- int samplesPerBlock = readLittleEndianShort(dis) & 0xFFFF; // unsigned
- if (TDebug.TraceAudioFileReader) {
- debugAdd+=", wBitsPerSample="+sampleSizeInBits
- +", cbSize="+cbSize
- +", wSamplesPerBlock=" + samplesPerBlock;
- }
- sampleSizeInBits = AudioSystem.NOT_SPECIFIED;
- encoding = WaveTool.GSM0610;
- frameSize = blockAlign;
- frameRate = ((float) sampleRate)/((float) samplesPerBlock);
- read += 6;
- break;
-
- default:
- throw new UnsupportedAudioFileException(
- "unsupported WAVE file: unknown format code "+formatCode);
- }
- // if frameSize isn't set, calculate it (the default)
- if (frameSize==0) {
- frameSize = calculateFrameSize(sampleSizeInBits, channelCount);
- }
-
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("WaveAudioFileReader.readFormatChunk():");
- TDebug.out(" read values: wFormatTag="+formatCode
- +", nChannels="+channelCount
- +", nSamplesPerSec="+sampleRate
- +", nAvgBytesPerSec="+avgBytesPerSecond
- +", nBlockAlign=="+blockAlign
- +debugAdd);
- TDebug.out(" constructed values: "
- +"encoding="+encoding
- +", sampleRate="+((float) sampleRate)
- +", sampleSizeInBits="+sampleSizeInBits
- +", channels="+channelCount
- +", frameSize="+frameSize
- +", frameRate="+frameRate);
- }
-
- // go to next chunk
- advanceChunk(dis, chunkLength, read);
- return new AudioFormat(
- encoding,
- (float) sampleRate,
- sampleSizeInBits,
- channelCount,
- frameSize,
- frameRate,
- false);
- }
-
-
-
- protected AudioFileFormat getAudioFileFormat(InputStream inputStream, long lFileLengthInBytes)
- throws UnsupportedAudioFileException, IOException {
- DataInputStream dataInputStream = new DataInputStream(inputStream);
- int magic = dataInputStream.readInt();
- if (magic != WaveTool.WAVE_RIFF_MAGIC) {
- throw new UnsupportedAudioFileException(
- "not a WAVE file: wrong header magic");
- }
- long totalLength = readLittleEndianInt(dataInputStream) & 0xFFFFFFFF; // unsigned
- magic = dataInputStream.readInt();
- if (magic != WaveTool.WAVE_WAVE_MAGIC) {
- throw new UnsupportedAudioFileException("not a WAVE file: wrong header magic");
- }
- // search for "fmt " chunk
- long chunkLength = findChunk(dataInputStream, WaveTool.WAVE_FMT_MAGIC);
- AudioFormat format = readFormatChunk(dataInputStream, chunkLength);
-
- // search for "data" chunk
- long dataChunkLength = findChunk(dataInputStream, WaveTool.WAVE_DATA_MAGIC);
-
- long frameLength = dataChunkLength / format.getFrameSize();
- if (format.getEncoding().equals(WaveTool.GSM0610)) {
- // TODO: should not be necessary
- frameLength = dataChunkLength;
- }
-
- if (TDebug.TraceAudioFileReader) {
- TDebug.out("WaveAudioFileReader.getAudioFileFormat(): total length: "
- +totalLength+", frame length = "+frameLength);
- }
- return new TAudioFileFormat(AudioFileFormat.Type.WAVE,
- format,
- (int) frameLength,
- (int) (totalLength + WaveTool.CHUNK_HEADER_SIZE));
- }
-}
-
-
-
-/*** WaveAudioFileReader.java ***/
-
diff --git a/songdbj/org/tritonus/file/WaveAudioFileWriter.java b/songdbj/org/tritonus/file/WaveAudioFileWriter.java
deleted file mode 100644
index d501b5b2b1..0000000000
--- a/songdbj/org/tritonus/file/WaveAudioFileWriter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * WaveAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999,2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.AudioOutputStream;
-import org.tritonus.share.sampled.file.TAudioFileWriter;
-import org.tritonus.share.sampled.file.TDataOutputStream;
-
-
-/**
- * Class for writing Microsoft(tm) WAVE files
- *
- * @author Florian Bomers
- */
-public class WaveAudioFileWriter
-extends TAudioFileWriter {
-
- private static final AudioFileFormat.Type[] FILE_TYPES =
- {
- AudioFileFormat.Type.WAVE
- };
-
- private static final int ALL=AudioSystem.NOT_SPECIFIED;
-
- // IMPORTANT: this array depends on the AudioFormat.match() algorithm which takes
- // AudioSystem.NOT_SPECIFIED into account !
- private static final AudioFormat[] AUDIO_FORMATS =
- {
- // Encoding, SampleRate, sampleSizeInBits, channels, frameSize, frameRate, bigEndian
- new AudioFormat(AudioFormat.Encoding.PCM_UNSIGNED, ALL, 8, ALL, ALL, ALL, true),
- new AudioFormat(AudioFormat.Encoding.PCM_UNSIGNED, ALL, 8, ALL, ALL, ALL, false),
- new AudioFormat(AudioFormat.Encoding.ULAW, ALL, 8, ALL, ALL, ALL, false),
- new AudioFormat(AudioFormat.Encoding.ULAW, ALL, 8, ALL, ALL, ALL, true),
- new AudioFormat(AudioFormat.Encoding.ALAW, ALL, 8, ALL, ALL, ALL, false),
- new AudioFormat(AudioFormat.Encoding.ALAW, ALL, 8, ALL, ALL, ALL, true),
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 16, ALL, ALL, ALL, false),
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 24, ALL, ALL, ALL, false),
- new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, ALL, 32, ALL, ALL, ALL, false),
- new AudioFormat(WaveTool.GSM0610, ALL, ALL, ALL, ALL, ALL, false),
- new AudioFormat(WaveTool.GSM0610, ALL, ALL, ALL, ALL, ALL, true),
- };
-
- public WaveAudioFileWriter() {
- super(Arrays.asList(FILE_TYPES),
- Arrays.asList(AUDIO_FORMATS));
- }
-
- // overwritten for quicker and more accurate check
- protected boolean isAudioFormatSupportedImpl(AudioFormat format,
- AudioFileFormat.Type fileType) {
- return WaveTool.getFormatCode(format) != WaveTool.WAVE_FORMAT_UNSPECIFIED;
- }
-
-
- protected AudioOutputStream getAudioOutputStream(AudioFormat audioFormat,
- long lLengthInBytes,
- AudioFileFormat.Type fileType,
- TDataOutputStream dataOutputStream) throws IOException {
- return new WaveAudioOutputStream(audioFormat,
- lLengthInBytes,
- dataOutputStream);
- }
-
-}
-
-/*** WaveAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/file/WaveAudioOutputStream.java b/songdbj/org/tritonus/file/WaveAudioOutputStream.java
deleted file mode 100644
index 9054c3c4e1..0000000000
--- a/songdbj/org/tritonus/file/WaveAudioOutputStream.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * WaveAudioOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import java.io.IOException;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioOutputStream;
-import org.tritonus.share.sampled.file.TDataOutputStream;
-
-
-/**
- * AudioOutputStream for Wave files.
- *
- * @author Florian Bomers
- */
-
-public class WaveAudioOutputStream extends TAudioOutputStream {
-
- // this constant is used for chunk lengths when the length is not known yet
- private static final int LENGTH_NOT_KNOWN=-1;
- private int formatCode;
-
- public WaveAudioOutputStream(AudioFormat audioFormat,
- long lLength,
- TDataOutputStream dataOutputStream) {
- super(audioFormat,
- lLength,
- dataOutputStream,
- lLength == AudioSystem.NOT_SPECIFIED && dataOutputStream.supportsSeek());
- // wave cannot store more than 4GB
- if (lLength != AudioSystem.NOT_SPECIFIED
- && (lLength+WaveTool.DATA_OFFSET)>0xFFFFFFFFl) {
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("WaveAudioOutputStream: Length exceeds 4GB: "
- +lLength+"=0x"+Long.toHexString(lLength)
- +" with header="+(lLength+WaveTool.DATA_OFFSET)
- +"=0x"+Long.toHexString(lLength+WaveTool.DATA_OFFSET));
- }
- throw new IllegalArgumentException("Wave files cannot be larger than 4GB.");
- }
- formatCode = WaveTool.getFormatCode(getFormat());
- if (formatCode == WaveTool.WAVE_FORMAT_UNSPECIFIED) {
- throw new IllegalArgumentException("Unknown encoding/format for this wave file.");
- }
-
- }
-
- protected void writeHeader()
- throws IOException {
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("WaveAudioOutputStream.writeHeader()");
- }
- AudioFormat format = getFormat();
- long lLength = getLength();
- int formatChunkAdd=0;
- if (formatCode==WaveTool.WAVE_FORMAT_GSM610) {
- // space for extra fields
- formatChunkAdd+=2;
- }
- int dataOffset=WaveTool.DATA_OFFSET+formatChunkAdd;
- if (formatCode!=WaveTool.WAVE_FORMAT_PCM) {
- // space for fact chunk
- dataOffset+=4+WaveTool.CHUNK_HEADER_SIZE;
- }
-
- // if patching the header, and the length has not been known at first
- // writing of the header, just truncate the size fields, don't throw an exception
- if (lLength != AudioSystem.NOT_SPECIFIED
- && lLength+dataOffset>0xFFFFFFFFl) {
- lLength=0xFFFFFFFFl-dataOffset;
- }
-
- // chunks must be on word-boundaries
- long lDataChunkSize=lLength+(lLength%2);
- TDataOutputStream dos = getDataOutputStream();
-
- // write RIFF container chunk
- dos.writeInt(WaveTool.WAVE_RIFF_MAGIC);
- dos.writeLittleEndian32((int) ((lDataChunkSize+dataOffset-WaveTool.CHUNK_HEADER_SIZE)
- & 0xFFFFFFFF));
- dos.writeInt(WaveTool.WAVE_WAVE_MAGIC);
-
- // write fmt_ chunk
- int formatChunkSize=WaveTool.FMT_CHUNK_SIZE+formatChunkAdd;
- short sampleSizeInBits=(short) format.getSampleSizeInBits();
- int decodedSamplesPerBlock=1;
-
- if (formatCode==WaveTool.WAVE_FORMAT_GSM610) {
- if (format.getFrameSize()==33) {
- decodedSamplesPerBlock=320;
- } else if (format.getFrameSize()==65) {
- decodedSamplesPerBlock=320;
- } else {
- // how to retrieve this value here ?
- decodedSamplesPerBlock=(int) (format.getFrameSize()*(320.0f/65.0f));
- }
- sampleSizeInBits=0; // MS standard
- }
-
-
- int avgBytesPerSec=((int) format.getSampleRate())/decodedSamplesPerBlock*format.getFrameSize();
- dos.writeInt(WaveTool.WAVE_FMT_MAGIC);
- dos.writeLittleEndian32(formatChunkSize);
- dos.writeLittleEndian16((short) formatCode); // wFormatTag
- dos.writeLittleEndian16((short) format.getChannels()); // nChannels
- dos.writeLittleEndian32((int) format.getSampleRate()); // nSamplesPerSec
- dos.writeLittleEndian32(avgBytesPerSec); // nAvgBytesPerSec
- dos.writeLittleEndian16((short) format.getFrameSize()); // nBlockalign
- dos.writeLittleEndian16(sampleSizeInBits); // wBitsPerSample
- dos.writeLittleEndian16((short) formatChunkAdd); // cbSize
-
- if (formatCode==WaveTool.WAVE_FORMAT_GSM610) {
- dos.writeLittleEndian16((short) decodedSamplesPerBlock); // wSamplesPerBlock
- }
-
- // write fact chunk
-
-
- if (formatCode!=WaveTool.WAVE_FORMAT_PCM) {
- // write "fact" chunk: number of samples
- // todo: add this as an attribute or property
- // in AudioOutputStream or AudioInputStream
- long samples=0;
- if (lLength!=AudioSystem.NOT_SPECIFIED) {
- samples=lLength/format.getFrameSize()*decodedSamplesPerBlock;
- }
- // saturate sample count
- if (samples>0xFFFFFFFFl) {
- samples=(0xFFFFFFFFl/decodedSamplesPerBlock)*decodedSamplesPerBlock;
- }
- dos.writeInt(WaveTool.WAVE_FACT_MAGIC);
- dos.writeLittleEndian32(4);
- dos.writeLittleEndian32((int) (samples & 0xFFFFFFFF));
- }
-
- // write header of data chunk
- dos.writeInt(WaveTool.WAVE_DATA_MAGIC);
- dos.writeLittleEndian32((lLength!=AudioSystem.NOT_SPECIFIED)?((int) lLength):LENGTH_NOT_KNOWN);
- }
-
- protected void patchHeader()
- throws IOException {
- TDataOutputStream tdos = getDataOutputStream();
- tdos.seek(0);
- setLengthFromCalculatedLength();
- writeHeader();
- }
-
- public void close() throws IOException {
- long nBytesWritten=getCalculatedLength();
-
- if ((nBytesWritten % 2)==1) {
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("WaveOutputStream.close(): adding padding byte");
- }
- // extra byte for to align on word boundaries
- TDataOutputStream tdos = getDataOutputStream();
- tdos.writeByte(0);
- // DON'T adjust calculated length !
- }
-
-
- super.close();
- }
-
-}
-
-/*** WaveAudioOutputStream.java ***/
diff --git a/songdbj/org/tritonus/file/WaveTool.java b/songdbj/org/tritonus/file/WaveTool.java
deleted file mode 100644
index 3487557088..0000000000
--- a/songdbj/org/tritonus/file/WaveTool.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * WaveTool.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-
-
-/**
- * Common constants and methods for handling wave files.
- *
- * @author Florian Bomers
- */
-
-public class WaveTool {
-
- public static final int WAVE_RIFF_MAGIC = 0x52494646; // "RIFF"
- public static final int WAVE_WAVE_MAGIC = 0x57415645; // "WAVE"
- public static final int WAVE_FMT_MAGIC = 0x666D7420; // "fmt "
- public static final int WAVE_DATA_MAGIC = 0x64617461; // "DATA"
- public static final int WAVE_FACT_MAGIC = 0x66616374; // "fact"
-
- public static final short WAVE_FORMAT_UNSPECIFIED = 0;
- public static final short WAVE_FORMAT_PCM = 1;
- public static final short WAVE_FORMAT_MS_ADPCM = 2;
- public static final short WAVE_FORMAT_ALAW = 6;
- public static final short WAVE_FORMAT_ULAW = 7;
- public static final short WAVE_FORMAT_IMA_ADPCM = 17; // same as DVI_ADPCM
- public static final short WAVE_FORMAT_G723_ADPCM = 20;
- public static final short WAVE_FORMAT_GSM610 = 49;
- public static final short WAVE_FORMAT_G721_ADPCM = 64;
- public static final short WAVE_FORMAT_MPEG = 80;
-
- public static final int MIN_FMT_CHUNK_LENGTH=14;
- public static final int MIN_DATA_OFFSET=12+8+MIN_FMT_CHUNK_LENGTH+8;
- public static final int MIN_FACT_CHUNK_LENGTH = 4;
-
- // we always write the sample size in bits and the length of extra bytes.
- // There are programs (CoolEdit) that rely on the
- // additional entry for sample size in bits.
- public static final int FMT_CHUNK_SIZE=18;
- public static final int RIFF_CONTAINER_CHUNK_SIZE=12;
- public static final int CHUNK_HEADER_SIZE=8;
- public static final int DATA_OFFSET=RIFF_CONTAINER_CHUNK_SIZE
- +CHUNK_HEADER_SIZE+FMT_CHUNK_SIZE+CHUNK_HEADER_SIZE;
-
- public static AudioFormat.Encoding GSM0610 = new AudioFormat.Encoding("GSM0610");
- public static AudioFormat.Encoding IMA_ADPCM = new AudioFormat.Encoding("IMA_ADPCM");
-
- public static short getFormatCode(AudioFormat format) {
- AudioFormat.Encoding encoding = format.getEncoding();
- int nSampleSize = format.getSampleSizeInBits();
- boolean littleEndian = !format.isBigEndian();
- boolean frameSizeOK=format.getFrameSize()==AudioSystem.NOT_SPECIFIED
- || format.getChannels()!=AudioSystem.NOT_SPECIFIED
- || format.getFrameSize()==nSampleSize/8*format.getChannels();
-
- if (nSampleSize==8 && frameSizeOK
- && (encoding.equals(AudioFormat.Encoding.PCM_SIGNED)
- || encoding.equals(AudioFormat.Encoding.PCM_UNSIGNED))) {
- return WAVE_FORMAT_PCM;
- } else if (nSampleSize>8 && frameSizeOK && littleEndian
- && encoding.equals(AudioFormat.Encoding.PCM_SIGNED)) {
- return WAVE_FORMAT_PCM;
- } else if (encoding.equals(AudioFormat.Encoding.ULAW)
- && (nSampleSize==AudioSystem.NOT_SPECIFIED || nSampleSize == 8)
- && frameSizeOK) {
- return WAVE_FORMAT_ULAW;
- } else if (encoding.equals(AudioFormat.Encoding.ALAW)
- && (nSampleSize==AudioSystem.NOT_SPECIFIED || nSampleSize == 8)
- && frameSizeOK) {
- return WAVE_FORMAT_ALAW;
- } else if (encoding.equals(new AudioFormat.Encoding("IMA_ADPCM"))
- && nSampleSize == 4)
- {
- return WAVE_FORMAT_IMA_ADPCM;
- }
- else if (encoding.equals(GSM0610)) {
- return WAVE_FORMAT_GSM610;
- }
- return WAVE_FORMAT_UNSPECIFIED;
- }
-
-}
-
-/*** WaveTool.java ***/
diff --git a/songdbj/org/tritonus/file/gsm/GSMAudioFileReader.java b/songdbj/org/tritonus/file/gsm/GSMAudioFileReader.java
deleted file mode 100644
index 26859ddf24..0000000000
--- a/songdbj/org/tritonus/file/gsm/GSMAudioFileReader.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * GSMAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- * Copyright (c) 2001 by Florian Bomers <http://www.bomers.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.gsm;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.EOFException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.UnsupportedAudioFileException;
-import javax.sound.sampled.spi.AudioFileReader;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-
-
-/** AudioFileReader class for GSM 06.10 data.
- @author Matthias Pfisterer
- */
-public class GSMAudioFileReader
-extends TAudioFileReader
-{
- private static final int GSM_MAGIC = 0xD0;
- private static final int GSM_MAGIC_MASK = 0xF0;
-
- private static final int MARK_LIMIT = 1;
-
-
-
- public GSMAudioFileReader()
- {
- super(MARK_LIMIT, true);
- }
-
-
-
- protected AudioFileFormat getAudioFileFormat(InputStream inputStream, long lFileSizeInBytes)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("GSMAudioFileReader.getAudioFileFormat(): begin"); }
- int b0 = inputStream.read();
- if (b0 < 0)
- {
- throw new EOFException();
- }
-
- /*
- * Check for magic number.
- */
- if ((b0 & GSM_MAGIC_MASK) != GSM_MAGIC)
- {
- throw new UnsupportedAudioFileException("not a GSM stream: wrong magic number");
- }
-
-
- /*
- If the file size is known, we derive the number of frames
- ('frame size') from it.
- If the values don't fit into integers, we leave them at
- NOT_SPECIFIED. 'Unknown' is considered less incorrect than
- a wrong value.
- */
- // [fb] not specifying it causes Sun's Wave file writer to write rubbish
- int nByteSize = AudioSystem.NOT_SPECIFIED;
- int nFrameSize = AudioSystem.NOT_SPECIFIED;
- Map<String, Object> properties = new HashMap<String, Object>();
- if (lFileSizeInBytes != AudioSystem.NOT_SPECIFIED)
- {
- // the number of GSM frames
- long lFrameSize = lFileSizeInBytes / 33;
- // duration in microseconds
- long lDuration = lFrameSize * 20000;
- properties.put("duration", lDuration);
- if (lFileSizeInBytes <= Integer.MAX_VALUE)
- {
- nByteSize = (int) lFileSizeInBytes;
- nFrameSize = (int) (lFileSizeInBytes / 33);
- }
- }
-
- Map<String, Object> afProperties = new HashMap<String, Object>();
- afProperties.put("bitrate", 13200L);
- AudioFormat format = new AudioFormat(
- new AudioFormat.Encoding("GSM0610"),
- 8000.0F,
- AudioSystem.NOT_SPECIFIED /* ??? [sample size in bits] */,
- 1,
- 33,
- 50.0F,
- true, // this value is chosen arbitrarily
- afProperties);
- AudioFileFormat audioFileFormat =
- new TAudioFileFormat(
- new AudioFileFormat.Type("GSM","gsm"),
- format,
- nFrameSize,
- nByteSize,
- properties);
- if (TDebug.TraceAudioFileReader) { TDebug.out("GSMAudioFileReader.getAudioFileFormat(): end"); }
- return audioFileFormat;
- }
-}
-
-
-
-/*** GSMAudioFileReader.java ***/
-
diff --git a/songdbj/org/tritonus/file/gsm/GSMAudioFileWriter.java b/songdbj/org/tritonus/file/gsm/GSMAudioFileWriter.java
deleted file mode 100644
index eb3d1f3f16..0000000000
--- a/songdbj/org/tritonus/file/gsm/GSMAudioFileWriter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * GSMAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.gsm;
-
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.THeaderlessAudioFileWriter;
-
-
-
-/** Class for writing GSM streams
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class GSMAudioFileWriter
-extends THeaderlessAudioFileWriter
-{
- private static final AudioFileFormat.Type[] FILE_TYPES =
- {
- new AudioFileFormat.Type("GSM", "gsm")
- };
-
- private static final AudioFormat[] AUDIO_FORMATS =
- {
- new AudioFormat(new AudioFormat.Encoding("GSM0610"), 8000.0F, ALL, 1, 33, 50.0F, false),
- new AudioFormat(new AudioFormat.Encoding("GSM0610"), 8000.0F, ALL, 1, 33, 50.0F, true),
- };
-
-
-
- public GSMAudioFileWriter()
- {
- super(Arrays.asList(FILE_TYPES),
- Arrays.asList(AUDIO_FORMATS));
- if (TDebug.TraceAudioFileWriter) { TDebug.out("GSMAudioFileWriter.<init>(): begin"); }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("GSMAudioFileWriter.<init>(): end"); }
- }
-}
-
-
-
-/*** GSMAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/file/gsm/package.html b/songdbj/org/tritonus/file/gsm/package.html
deleted file mode 100644
index 763851dda0..0000000000
--- a/songdbj/org/tritonus/file/gsm/package.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>GSM 06.10 audio file reader and writer.
- The classes provided here .</p>
- </body>
-</html>
diff --git a/songdbj/org/tritonus/file/jorbis/JorbisAudioFileReader.java b/songdbj/org/tritonus/file/jorbis/JorbisAudioFileReader.java
deleted file mode 100644
index 5b33534b21..0000000000
--- a/songdbj/org/tritonus/file/jorbis/JorbisAudioFileReader.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * JorbisAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.jorbis;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-import com.jcraft.jogg.Buffer;
-import com.jcraft.jogg.SyncState;
-import com.jcraft.jogg.StreamState;
-import com.jcraft.jogg.Page;
-import com.jcraft.jogg.Packet;
-
-
-
-/**
- * @author Matthias Pfisterer
- */
-public class JorbisAudioFileReader
-extends TAudioFileReader
-{
- private static final int INITAL_READ_LENGTH = 4096;
- private static final int MARK_LIMIT = INITAL_READ_LENGTH + 1;
-
-
-
- public JorbisAudioFileReader()
- {
- super(MARK_LIMIT, true);
- }
-
-
-
- protected AudioFileFormat getAudioFileFormat(InputStream inputStream, long lFileSizeInBytes)
- throws UnsupportedAudioFileException, IOException
- {
- // sync and verify incoming physical bitstream
- SyncState oggSyncState = new SyncState();
-
- // take physical pages, weld into a logical stream of packets
- StreamState oggStreamState = new StreamState();
-
- // one Ogg bitstream page. Vorbis packets are inside
- Page oggPage = new Page();
-
- // one raw packet of data for decode
- Packet oggPacket = new Packet();
-
- int bytes = 0;
-
- // Decode setup
-
- oggSyncState.init(); // Now we can read pages
-
- // grab some data at the head of the stream. We want the first page
- // (which is guaranteed to be small and only contain the Vorbis
- // stream initial header) We need the first page to get the stream
- // serialno.
-
- // submit a 4k block to libvorbis' Ogg layer
- int index = oggSyncState.buffer(INITAL_READ_LENGTH);
- bytes = inputStream.read(oggSyncState.data, index, INITAL_READ_LENGTH);
- oggSyncState.wrote(bytes);
-
- // Get the first page.
- if (oggSyncState.pageout(oggPage) != 1)
- {
- // have we simply run out of data? If so, we're done.
- if (bytes < 4096)
- {
- // IDEA: throw EOFException?
- throw new UnsupportedAudioFileException("not a Vorbis stream: ended prematurely");
- }
- throw new UnsupportedAudioFileException("not a Vorbis stream: not in Ogg bitstream format");
- }
-
- // Get the serial number and set up the rest of decode.
- // serialno first; use it to set up a logical stream
- oggStreamState.init(oggPage.serialno());
-
- // extract the initial header from the first page and verify that the
- // Ogg bitstream is in fact Vorbis data
-
- // I handle the initial header first instead of just having the code
- // read all three Vorbis headers at once because reading the initial
- // header is an easy way to identify a Vorbis bitstream and it's
- // useful to see that functionality seperated out.
-
- if (oggStreamState.pagein(oggPage) < 0)
- {
- // error; stream version mismatch perhaps
- throw new UnsupportedAudioFileException("not a Vorbis stream: can't read first page of Ogg bitstream data");
- }
-
- if (oggStreamState.packetout(oggPacket) != 1)
- {
- // no page? must not be vorbis
- throw new UnsupportedAudioFileException("not a Vorbis stream: can't read initial header packet");
- }
-
- Buffer oggPacketBuffer = new Buffer();
- oggPacketBuffer.readinit(oggPacket.packet_base, oggPacket.packet, oggPacket.bytes);
-
- int nPacketType = oggPacketBuffer.read(8);
- byte[] buf = new byte[6];
- oggPacketBuffer.read(buf, 6);
- if(buf[0]!='v' || buf[1]!='o' || buf[2]!='r' ||
- buf[3]!='b' || buf[4]!='i' || buf[5]!='s')
- {
- throw new UnsupportedAudioFileException("not a Vorbis stream: not a vorbis header packet");
- }
- if (nPacketType != 1)
- {
- throw new UnsupportedAudioFileException("not a Vorbis stream: first packet is not the identification header");
- }
- if(oggPacket.b_o_s == 0)
- {
- throw new UnsupportedAudioFileException("not a Vorbis stream: initial packet not marked as beginning of stream");
- }
- int nVersion = oggPacketBuffer.read(32);
- if (nVersion != 0)
- {
- throw new UnsupportedAudioFileException("not a Vorbis stream: wrong vorbis version");
- }
- int nChannels = oggPacketBuffer.read(8);
- float fSampleRate = oggPacketBuffer.read(32);
-
- // These are only used for error checking.
- int bitrate_upper = oggPacketBuffer.read(32);
- int bitrate_nominal = oggPacketBuffer.read(32);
- int bitrate_lower = oggPacketBuffer.read(32);
-
- int[] blocksizes = new int[2];
- blocksizes[0] = 1 << oggPacketBuffer.read(4);
- blocksizes[1] = 1 << oggPacketBuffer.read(4);
-
- if (fSampleRate < 1.0F ||
- nChannels < 1 ||
- blocksizes[0] < 8||
- blocksizes[1] < blocksizes[0] ||
- oggPacketBuffer.read(1) != 1)
- {
- throw new UnsupportedAudioFileException("not a Vorbis stream: illegal values in initial header");
- }
-
-
- if (TDebug.TraceAudioFileReader) { TDebug.out("JorbisAudioFileReader.getAudioFileFormat(): channels: " + nChannels); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("JorbisAudioFileReader.getAudioFileFormat(): rate: " + fSampleRate); }
-
- /*
- If the file size is known, we derive the number of frames
- ('frame size') from it.
- If the values don't fit into integers, we leave them at
- NOT_SPECIFIED. 'Unknown' is considered less incorrect than
- a wrong value.
- */
- // [fb] not specifying it causes Sun's Wave file writer to write rubbish
- int nByteSize = AudioSystem.NOT_SPECIFIED;
- if (lFileSizeInBytes != AudioSystem.NOT_SPECIFIED
- && lFileSizeInBytes <= Integer.MAX_VALUE)
- {
- nByteSize = (int) lFileSizeInBytes;
- }
- int nFrameSize = AudioSystem.NOT_SPECIFIED;
- /* Can we calculate a useful size?
- Peeking into ogginfo gives the insight that the only
- way seems to be reading through the file. This is
- something we do not want, at least not by default.
- */
- // nFrameSize = (int) (lFileSizeInBytes / ...;
-
- AudioFormat format = new AudioFormat(
- new AudioFormat.Encoding("VORBIS"),
- fSampleRate,
- AudioSystem.NOT_SPECIFIED,
- nChannels,
- AudioSystem.NOT_SPECIFIED,
- AudioSystem.NOT_SPECIFIED,
- true); // this value is chosen arbitrarily
- if (TDebug.TraceAudioFileReader) { TDebug.out("JorbisAudioFileReader.getAudioFileFormat(): AudioFormat: " + format); }
- AudioFileFormat.Type type = new AudioFileFormat.Type("Ogg","ogg");
- AudioFileFormat audioFileFormat =
- new TAudioFileFormat(
- type,
- format,
- nFrameSize,
- nByteSize);
- if (TDebug.TraceAudioFileReader) { TDebug.out("JorbisAudioFileReader.getAudioFileFormat(): AudioFileFormat: " + audioFileFormat); }
- return audioFileFormat;
- }
-}
-
-
-
-/*** JorbisAudioFileReader.java ***/
-
diff --git a/songdbj/org/tritonus/file/jorbis/package.html b/songdbj/org/tritonus/file/jorbis/package.html
deleted file mode 100644
index e5b5599d8c..0000000000
--- a/songdbj/org/tritonus/file/jorbis/package.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Ogg vorbis audio file reader based on the jorbis library.
- The classes provided here .</p>
- </body>
-</html>
diff --git a/songdbj/org/tritonus/file/mpeg/MpegAudioFileWriter.java b/songdbj/org/tritonus/file/mpeg/MpegAudioFileWriter.java
deleted file mode 100644
index d958fecf0d..0000000000
--- a/songdbj/org/tritonus/file/mpeg/MpegAudioFileWriter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * MpegAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.mpeg;
-
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.THeaderlessAudioFileWriter;
-
-
-
-/** Class for writing mpeg files
- *
- * @author Florian Bomers
- */
-public class MpegAudioFileWriter extends THeaderlessAudioFileWriter {
-
- private static final AudioFileFormat.Type[] FILE_TYPES = {
- //new AudioFileFormat.Type("MPEG", "mpeg"),
- // workaround for the fixed extension problem in AudioFileFormat.Type
- // see org.tritonus.share.sampled.AudioFileTypes.java
- new AudioFileFormat.Type("MP3", "mp3")
- };
-
- public static AudioFormat.Encoding MPEG1L3=new AudioFormat.Encoding("MPEG1L3");
-
- private static final AudioFormat[] AUDIO_FORMATS = {
- new AudioFormat(MPEG1L3, ALL, ALL, 1, ALL, ALL, false),
- new AudioFormat(MPEG1L3, ALL, ALL, 1, ALL, ALL, true),
- new AudioFormat(MPEG1L3, ALL, ALL, 2, ALL, ALL, false),
- new AudioFormat(MPEG1L3, ALL, ALL, 2, ALL, ALL, true),
- };
-
- public MpegAudioFileWriter()
- {
- super(Arrays.asList(FILE_TYPES),
- Arrays.asList(AUDIO_FORMATS));
- if (TDebug.TraceAudioFileWriter) { TDebug.out("MpegAudioFileWriter.<init>(): begin"); }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("MpegAudioFileWriter.<init>(): end"); }
- }
-}
-
-
-/*** MpegAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/file/mpeg/package.html b/songdbj/org/tritonus/file/mpeg/package.html
deleted file mode 100644
index f24ded00ec..0000000000
--- a/songdbj/org/tritonus/file/mpeg/package.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Mp3 audio file reader and writer.
- The classes provided here .</p>
- </body>
-</html>
diff --git a/songdbj/org/tritonus/file/package.html b/songdbj/org/tritonus/file/package.html
deleted file mode 100644
index a3ba1632a8..0000000000
--- a/songdbj/org/tritonus/file/package.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Standard audio file readers and writers (.aiff, .au, .wav).
- The classes provided here .</p>
- </body>
-</html>
diff --git a/songdbj/org/tritonus/file/pvorbis/VorbisAudioFileReader.java b/songdbj/org/tritonus/file/pvorbis/VorbisAudioFileReader.java
deleted file mode 100644
index a882f11c3a..0000000000
--- a/songdbj/org/tritonus/file/pvorbis/VorbisAudioFileReader.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * VorbisAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 - 2004 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.pvorbis;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-import org.tritonus.lowlevel.pogg.Buffer;
-import org.tritonus.lowlevel.pogg.Page;
-import org.tritonus.lowlevel.pogg.Packet;
-import org.tritonus.lowlevel.pogg.SyncState;
-import org.tritonus.lowlevel.pogg.StreamState;
-
-
-
-/**
- * @author Matthias Pfisterer
- */
-public class VorbisAudioFileReader
-extends TAudioFileReader
-{
- private static final int INITAL_READ_LENGTH = 4096;
- private static final int MARK_LIMIT = INITAL_READ_LENGTH + 1;
-
-
-
- public VorbisAudioFileReader()
- {
- super(MARK_LIMIT, true);
- }
-
-
-
- protected AudioFileFormat getAudioFileFormat(InputStream inputStream,
- long lFileSizeInBytes)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out(">VorbisAudioFileReader.getAudioFileFormat(): begin"); }
- SyncState oggSyncState = new SyncState();
- StreamState oggStreamState = new StreamState();
- Page oggPage = new Page();
- Packet oggPacket = new Packet();
-
- int bytes = 0;
-
- // Decode setup
-
- oggSyncState.init(); // Now we can read pages
-
- // grab some data at the head of the stream. We want the first page
- // (which is guaranteed to be small and only contain the Vorbis
- // stream initial header) We need the first page to get the stream
- // serialno.
-
- // submit a 4k block to libvorbis' Ogg layer
- byte[] abBuffer = new byte[INITAL_READ_LENGTH];
- bytes = inputStream.read(abBuffer);
- if (TDebug.TraceAudioFileReader) { TDebug.out("read bytes from input stream: " + bytes); }
- int nResult = oggSyncState.write(abBuffer, bytes);
- if (TDebug.TraceAudioFileReader) { TDebug.out("SyncState.write() returned " + nResult); }
-
- // Get the first page.
- if (oggSyncState.pageOut(oggPage) != 1)
- {
- // have we simply run out of data? If so, we're done.
- if (bytes < INITAL_READ_LENGTH)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("stream ended prematurely"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- // IDEA: throw EOFException?
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: ended prematurely");
- }
- if (TDebug.TraceAudioFileReader) { TDebug.out("not in Ogg bitstream format"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: not in Ogg bitstream format");
- }
-
- // Get the serial number and set up the rest of decode.
- // serialno first; use it to set up a logical stream
- int nSerialNo = oggPage.getSerialNo();
- if (TDebug.TraceAudioFileReader) TDebug.out("serial no.: " + nSerialNo);
- oggStreamState.init(nSerialNo);
-
- // extract the initial header from the first page and verify that the
- // Ogg bitstream is in fact Vorbis data
-
- // I handle the initial header first instead of just having the code
- // read all three Vorbis headers at once because reading the initial
- // header is an easy way to identify a Vorbis bitstream and it's
- // useful to see that functionality seperated out.
-
- if (oggStreamState.pageIn(oggPage) < 0)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("can't read first page of Ogg bitstream data"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- // error; stream version mismatch perhaps
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: can't read first page of Ogg bitstream data");
- }
-
- if (oggStreamState.packetOut(oggPacket) != 1)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("can't read initial header packet"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- // no page? must not be vorbis
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: can't read initial header packet");
- }
-
- byte[] abData = oggPacket.getData();
- if (TDebug.TraceAudioFileReader)
- {
- String strData = "";
- for (int i = 0; i < abData.length; i++)
- {
- strData += " " + abData[i];
- }
- TDebug.out("packet data: " + strData);
- }
-
- int nPacketType = abData[0];
- if (TDebug.TraceAudioFileReader) { TDebug.out("packet type: " + nPacketType); }
- if (nPacketType != 1)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("first packet is not the identification header"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: first packet is not the identification header");
- }
- if(abData[1] != 'v' ||
- abData[2] != 'o' ||
- abData[3] != 'r' ||
- abData[4] != 'b' ||
- abData[5] != 'i' ||
- abData[6] != 's')
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("not a vorbis header packet"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: not a vorbis header packet");
- }
- if (! oggPacket.isBos())
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("initial packet not marked as beginning of stream"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: initial packet not marked as beginning of stream");
- }
- int nVersion = (abData[7] & 0xFF) + 256 * (abData[8] & 0xFF) + 65536 * (abData[9] & 0xFF) + 16777216 * (abData[10] & 0xFF);
- if (TDebug.TraceAudioFileReader) { TDebug.out("version: " + nVersion); }
- if (nVersion != 0)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("wrong vorbis version"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: wrong vorbis version");
- }
- int nChannels = (abData[11] & 0xFF);
- float fSampleRate = (abData[12] & 0xFF) + 256 * (abData[13] & 0xFF) + 65536 * (abData[14] & 0xFF) + 16777216 * (abData[15] & 0xFF);
- if (TDebug.TraceAudioFileReader) { TDebug.out("channels: " + nChannels); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("rate: " + fSampleRate); }
-
- // These are only used for error checking.
- int bitrate_upper = abData[16] + 256 * abData[17] + 65536 * abData[18] + 16777216 * abData[19];
- int bitrate_nominal = abData[20] + 256 * abData[21] + 65536 * abData[22] + 16777216 * abData[23];
- int bitrate_lower = abData[24] + 256 * abData[25] + 65536 * abData[26] + 16777216 * abData[27];
-
- int[] blocksizes = new int[2];
- blocksizes[0] = 1 << (abData[28] & 0xF);
- blocksizes[1] = 1 << ((abData[28] >>> 4) & 0xF);
- if (TDebug.TraceAudioFileReader) { TDebug.out("blocksizes[0]: " + blocksizes[0]); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("blocksizes[1]: " + blocksizes[1]); }
-
- if (fSampleRate < 1.0F ||
- nChannels < 1 ||
- blocksizes[0] < 8||
- blocksizes[1] < blocksizes[0] ||
- (abData[29] & 0x1) != 1)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("illegal values in initial header"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: illegal values in initial header");
- }
-
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
-
- /*
- If the file size is known, we derive the number of frames
- ('frame size') from it.
- If the values don't fit into integers, we leave them at
- NOT_SPECIFIED. 'Unknown' is considered less incorrect than
- a wrong value.
- */
- // [fb] not specifying it causes Sun's Wave file writer to write rubbish
- int nByteSize = AudioSystem.NOT_SPECIFIED;
- if (lFileSizeInBytes != AudioSystem.NOT_SPECIFIED
- && lFileSizeInBytes <= Integer.MAX_VALUE)
- {
- nByteSize = (int) lFileSizeInBytes;
- }
- int nFrameSize = AudioSystem.NOT_SPECIFIED;
- /* Can we calculate a useful size?
- Peeking into ogginfo gives the insight that the only
- way seems to be reading through the file. This is
- something we do not want, at least not by default.
- */
- // nFrameSize = (int) (lFileSizeInBytes / ...;
-
- AudioFormat format = new AudioFormat(
- new AudioFormat.Encoding("VORBIS"),
- fSampleRate,
- AudioSystem.NOT_SPECIFIED,
- nChannels,
- AudioSystem.NOT_SPECIFIED,
- AudioSystem.NOT_SPECIFIED,
- true); // this value is chosen arbitrarily
- if (TDebug.TraceAudioFileReader) { TDebug.out("AudioFormat: " + format); }
- AudioFileFormat.Type type = new AudioFileFormat.Type("Ogg","ogg");
- AudioFileFormat audioFileFormat =
- new TAudioFileFormat(
- type,
- format,
- nFrameSize,
- nByteSize);
- if (TDebug.TraceAudioFileReader) { TDebug.out("AudioFileFormat: " + audioFileFormat); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): end"); }
- return audioFileFormat;
- }
-}
-
-
-
-/*** VorbisAudioFileReader.java ***/
-
diff --git a/songdbj/org/tritonus/file/pvorbis/VorbisAudioFileWriter.java b/songdbj/org/tritonus/file/pvorbis/VorbisAudioFileWriter.java
deleted file mode 100644
index 5fc9c0663d..0000000000
--- a/songdbj/org/tritonus/file/pvorbis/VorbisAudioFileWriter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * VorbisAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 2000 -2004 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.pvorbis;
-
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.THeaderlessAudioFileWriter;
-
-
-
-/** Class for writing Vorbis streams
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class VorbisAudioFileWriter
-extends THeaderlessAudioFileWriter
-{
- private static final AudioFileFormat.Type[] FILE_TYPES =
- {
- new AudioFileFormat.Type("Vorbis", "ogg")
- };
-
- private static final AudioFormat[] AUDIO_FORMATS =
- {
- new AudioFormat(new AudioFormat.Encoding("VORBIS"), ALL, ALL, ALL, ALL, ALL, false),
- new AudioFormat(new AudioFormat.Encoding("VORBIS"), ALL, ALL, ALL, ALL, ALL, true),
- };
-
-
-
- public VorbisAudioFileWriter()
- {
- super(Arrays.asList(FILE_TYPES),
- Arrays.asList(AUDIO_FORMATS));
- if (TDebug.TraceAudioFileWriter) { TDebug.out("VorbisAudioFileWriter.<init>(): begin"); }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("VorbisAudioFileWriter.<init>(): end"); }
- }
-}
-
-
-
-/*** VorbisAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/file/pvorbis/package.html b/songdbj/org/tritonus/file/pvorbis/package.html
deleted file mode 100644
index a5238aaca0..0000000000
--- a/songdbj/org/tritonus/file/pvorbis/package.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Ogg vorbis audio file reader and writer based on the pure java libraries.
- The classes provided here .</p>
-
- @see org.tritonus.lowlevel.ogg
- </body>
-</html>
diff --git a/songdbj/org/tritonus/file/vorbis/VorbisAudioFileReader.java b/songdbj/org/tritonus/file/vorbis/VorbisAudioFileReader.java
deleted file mode 100644
index f8b34d5411..0000000000
--- a/songdbj/org/tritonus/file/vorbis/VorbisAudioFileReader.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * VorbisAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.vorbis;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.TAudioFileFormat;
-import org.tritonus.share.sampled.file.TAudioFileReader;
-
-import org.tritonus.lowlevel.ogg.Buffer;
-import org.tritonus.lowlevel.ogg.Page;
-import org.tritonus.lowlevel.ogg.Packet;
-import org.tritonus.lowlevel.ogg.SyncState;
-import org.tritonus.lowlevel.ogg.StreamState;
-
-
-
-/**
- * @author Matthias Pfisterer
- */
-public class VorbisAudioFileReader
-extends TAudioFileReader
-{
- private static final int INITAL_READ_LENGTH = 4096;
- private static final int MARK_LIMIT = INITAL_READ_LENGTH + 1;
-
-
-
- public VorbisAudioFileReader()
- {
- super(MARK_LIMIT, true);
- }
-
-
-
- protected AudioFileFormat getAudioFileFormat(InputStream inputStream,
- long lFileSizeInBytes)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out(">VorbisAudioFileReader.getAudioFileFormat(): begin"); }
- SyncState oggSyncState = new SyncState();
- StreamState oggStreamState = new StreamState();
- Page oggPage = new Page();
- Packet oggPacket = new Packet();
-
- int bytes = 0;
-
- // Decode setup
-
- oggSyncState.init(); // Now we can read pages
-
- // grab some data at the head of the stream. We want the first page
- // (which is guaranteed to be small and only contain the Vorbis
- // stream initial header) We need the first page to get the stream
- // serialno.
-
- // submit a 4k block to libvorbis' Ogg layer
- byte[] abBuffer = new byte[INITAL_READ_LENGTH];
- bytes = inputStream.read(abBuffer);
- if (TDebug.TraceAudioFileReader) { TDebug.out("read bytes from input stream: " + bytes); }
- int nResult = oggSyncState.write(abBuffer, bytes);
- if (TDebug.TraceAudioFileReader) { TDebug.out("SyncState.write() returned " + nResult); }
-
- // Get the first page.
- if (oggSyncState.pageOut(oggPage) != 1)
- {
- // have we simply run out of data? If so, we're done.
- if (bytes < INITAL_READ_LENGTH)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("stream ended prematurely"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- // IDEA: throw EOFException?
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: ended prematurely");
- }
- if (TDebug.TraceAudioFileReader) { TDebug.out("not in Ogg bitstream format"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: not in Ogg bitstream format");
- }
-
- // Get the serial number and set up the rest of decode.
- // serialno first; use it to set up a logical stream
- int nSerialNo = oggPage.getSerialNo();
- TDebug.out("serial no.: " + nSerialNo);
- oggStreamState.init(nSerialNo);
-
- // extract the initial header from the first page and verify that the
- // Ogg bitstream is in fact Vorbis data
-
- // I handle the initial header first instead of just having the code
- // read all three Vorbis headers at once because reading the initial
- // header is an easy way to identify a Vorbis bitstream and it's
- // useful to see that functionality seperated out.
-
- if (oggStreamState.pageIn(oggPage) < 0)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("can't read first page of Ogg bitstream data"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- // error; stream version mismatch perhaps
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: can't read first page of Ogg bitstream data");
- }
-
- if (oggStreamState.packetOut(oggPacket) != 1)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("can't read initial header packet"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- // no page? must not be vorbis
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: can't read initial header packet");
- }
-
- byte[] abData = oggPacket.getData();
- if (TDebug.TraceAudioFileReader)
- {
- String strData = "";
- for (int i = 0; i < abData.length; i++)
- {
- strData += " " + abData[i];
- }
- TDebug.out("packet data: " + strData);
- }
-
- int nPacketType = abData[0];
- if (TDebug.TraceAudioFileReader) { TDebug.out("packet type: " + nPacketType); }
- if (nPacketType != 1)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("first packet is not the identification header"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: first packet is not the identification header");
- }
- if(abData[1] != 'v' ||
- abData[2] != 'o' ||
- abData[3] != 'r' ||
- abData[4] != 'b' ||
- abData[5] != 'i' ||
- abData[6] != 's')
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("not a vorbis header packet"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: not a vorbis header packet");
- }
- if (! oggPacket.isBos())
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("initial packet not marked as beginning of stream"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: initial packet not marked as beginning of stream");
- }
- int nVersion = (abData[7] & 0xFF) + 256 * (abData[8] & 0xFF) + 65536 * (abData[9] & 0xFF) + 16777216 * (abData[10] & 0xFF);
- if (TDebug.TraceAudioFileReader) { TDebug.out("version: " + nVersion); }
- if (nVersion != 0)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("wrong vorbis version"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: wrong vorbis version");
- }
- int nChannels = (abData[11] & 0xFF);
- float fSampleRate = (abData[12] & 0xFF) + 256 * (abData[13] & 0xFF) + 65536 * (abData[14] & 0xFF) + 16777216 * (abData[15] & 0xFF);
- if (TDebug.TraceAudioFileReader) { TDebug.out("channels: " + nChannels); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("rate: " + fSampleRate); }
-
- // These are only used for error checking.
- int bitrate_upper = abData[16] + 256 * abData[17] + 65536 * abData[18] + 16777216 * abData[19];
- int bitrate_nominal = abData[20] + 256 * abData[21] + 65536 * abData[22] + 16777216 * abData[23];
- int bitrate_lower = abData[24] + 256 * abData[25] + 65536 * abData[26] + 16777216 * abData[27];
-
- int[] blocksizes = new int[2];
- blocksizes[0] = 1 << (abData[28] & 0xF);
- blocksizes[1] = 1 << ((abData[28] >>> 4) & 0xF);
- if (TDebug.TraceAudioFileReader) { TDebug.out("blocksizes[0]: " + blocksizes[0]); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("blocksizes[1]: " + blocksizes[1]); }
-
- if (fSampleRate < 1.0F ||
- nChannels < 1 ||
- blocksizes[0] < 8||
- blocksizes[1] < blocksizes[0] ||
- (abData[29] & 0x1) != 1)
- {
- if (TDebug.TraceAudioFileReader) { TDebug.out("illegal values in initial header"); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): throwing exception"); }
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
- throw new UnsupportedAudioFileException("not a Vorbis stream: illegal values in initial header");
- }
-
- oggSyncState.free();
- oggStreamState.free();
- oggPage.free();
- oggPacket.free();
-
- /*
- If the file size is known, we derive the number of frames
- ('frame size') from it.
- If the values don't fit into integers, we leave them at
- NOT_SPECIFIED. 'Unknown' is considered less incorrect than
- a wrong value.
- */
- // [fb] not specifying it causes Sun's Wave file writer to write rubbish
- int nByteSize = AudioSystem.NOT_SPECIFIED;
- if (lFileSizeInBytes != AudioSystem.NOT_SPECIFIED
- && lFileSizeInBytes <= Integer.MAX_VALUE)
- {
- nByteSize = (int) lFileSizeInBytes;
- }
- int nFrameSize = AudioSystem.NOT_SPECIFIED;
- /* Can we calculate a useful size?
- Peeking into ogginfo gives the insight that the only
- way seems to be reading through the file. This is
- something we do not want, at least not by default.
- */
- // nFrameSize = (int) (lFileSizeInBytes / ...;
-
- AudioFormat format = new AudioFormat(
- new AudioFormat.Encoding("VORBIS"),
- fSampleRate,
- AudioSystem.NOT_SPECIFIED,
- nChannels,
- AudioSystem.NOT_SPECIFIED,
- AudioSystem.NOT_SPECIFIED,
- true); // this value is chosen arbitrarily
- if (TDebug.TraceAudioFileReader) { TDebug.out("AudioFormat: " + format); }
- AudioFileFormat.Type type = new AudioFileFormat.Type("Ogg","ogg");
- AudioFileFormat audioFileFormat =
- new TAudioFileFormat(
- type,
- format,
- nFrameSize,
- nByteSize);
- if (TDebug.TraceAudioFileReader) { TDebug.out("AudioFileFormat: " + audioFileFormat); }
- if (TDebug.TraceAudioFileReader) { TDebug.out("<VorbisAudioFileReader.getAudioFileFormat(): end"); }
- return audioFileFormat;
- }
-}
-
-
-
-/*** VorbisAudioFileReader.java ***/
-
diff --git a/songdbj/org/tritonus/file/vorbis/VorbisAudioFileWriter.java b/songdbj/org/tritonus/file/vorbis/VorbisAudioFileWriter.java
deleted file mode 100644
index ee7e310e48..0000000000
--- a/songdbj/org/tritonus/file/vorbis/VorbisAudioFileWriter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * VorbisAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.sampled.file.vorbis;
-
-import java.util.Arrays;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.file.THeaderlessAudioFileWriter;
-
-
-
-/** Class for writing Vorbis streams
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class VorbisAudioFileWriter
-extends THeaderlessAudioFileWriter
-{
- private static final AudioFileFormat.Type[] FILE_TYPES =
- {
- new AudioFileFormat.Type("Vorbis", "ogg")
- };
-
- private static final AudioFormat[] AUDIO_FORMATS =
- {
- new AudioFormat(new AudioFormat.Encoding("VORBIS"), ALL, ALL, ALL, ALL, ALL, false),
- new AudioFormat(new AudioFormat.Encoding("VORBIS"), ALL, ALL, ALL, ALL, ALL, true),
- };
-
-
-
- public VorbisAudioFileWriter()
- {
- super(Arrays.asList(FILE_TYPES),
- Arrays.asList(AUDIO_FORMATS));
- if (TDebug.TraceAudioFileWriter) { TDebug.out("VorbisAudioFileWriter.<init>(): begin"); }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("VorbisAudioFileWriter.<init>(): end"); }
- }
-}
-
-
-
-/*** VorbisAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/file/vorbis/package.html b/songdbj/org/tritonus/file/vorbis/package.html
deleted file mode 100644
index 5d6c328b7d..0000000000
--- a/songdbj/org/tritonus/file/vorbis/package.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Ogg vorbis audio file reader and writer based on native libraries.
- The classes provided here .</p>
-
- @see org.tritonus.lowlevel.ogg
- </body>
-</html>
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Buffer.java b/songdbj/org/tritonus/lowlevel/ogg/Buffer.java
deleted file mode 100644
index 2903f0e17e..0000000000
--- a/songdbj/org/tritonus/lowlevel/ogg/Buffer.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Buffer.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.ogg;
-
-import org.tritonus.share.TDebug;
-
-
-/** Wrapper for oggpack_buffer.
- */
-public class Buffer
-{
- static
- {
- Ogg.loadNativeLibrary();
- if (TDebug.TraceOggNative)
- {
- setTrace(true);
- }
- }
-
-
- /**
- * Holds the pointer to oggpack_buffer
- * for the native code.
- * This must be long to be 64bit-clean.
- */
- private long m_lNativeHandle;
-
-
-
- public Buffer()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): begin"); }
- int nReturn = malloc();
- if (nReturn < 0)
- {
- throw new RuntimeException("malloc of ogg_page failed");
- }
- if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): end"); }
- }
-
-
-
- public void finalize()
- {
- // TODO: call free()
- // call super.finalize() first or last?
- // and introduce a flag if free() has already been called?
- }
-
-
-
- private native int malloc();
- public native void free();
-
-
- /** Calls oggpack_writeinit().
- */
- public native void writeInit();
-
-
- /** Calls oggpack_writetrunc().
- */
- public native void writeTrunc(int nBits);
-
-
- /** Calls oggpack_writealign().
- */
- public native void writeAlign();
-
-
- /** Calls oggpack_writecopy().
- */
- public native void writeCopy(byte[] abSource, int nBits);
-
-
- /** Calls oggpack_reset().
- */
- public native void reset();
-
-
- /** Calls oggpack_writeclear().
- */
- public native void writeClear();
-
-
- /** Calls oggpack_readinit().
- */
- public native void readInit(byte[] abBuffer, int nBytes);
-
-
- /** Calls oggpack_write().
- */
- public native void write(int nValue, int nBits);
-
-
- /** Calls oggpack_look().
- */
- public native int look(int nBits);
-
-
- /** Calls oggpack_look1().
- */
- public native int look1();
-
-
- /** Calls oggpack_adv().
- */
- public native void adv(int nBits);
-
-
- /** Calls oggpack_adv1().
- */
- public native void adv1();
-
-
- /** Calls oggpack_read().
- */
- public native int read(int nBits);
-
-
- /** Calls oggpack_read1().
- */
- public native int read1();
-
-
- /** Calls oggpack_bytes().
- */
- public native int bytes();
-
-
- /** Calls oggpack_bits().
- */
- public native int bits();
-
-
- /** Calls oggpack_get_buffer().
- */
- public native byte[] getBuffer();
-
-
- private static native void setTrace(boolean bTrace);
-}
-
-
-
-/*** Buffer.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Ogg.java b/songdbj/org/tritonus/lowlevel/ogg/Ogg.java
deleted file mode 100644
index 1ad6bde789..0000000000
--- a/songdbj/org/tritonus/lowlevel/ogg/Ogg.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Ogg.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.ogg;
-
-import org.tritonus.share.TDebug;
-
-
-/** libogg loading.
- */
-public class Ogg
-{
- private static boolean sm_bIsLibraryAvailable = false;
-
-
-
- static
- {
- Ogg.loadNativeLibrary();
- }
-
-
-
- public static void loadNativeLibrary()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibrary(): begin"); }
-
- if (! isLibraryAvailable())
- {
- loadNativeLibraryImpl();
- }
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibrary(): end"); }
- }
-
-
-
- /** Load the native library for ogg vorbis.
-
- This method actually does the loading of the library. Unlike
- {@link loadNativeLibrary() loadNativeLibrary()}, it does not
- check if the library is already loaded.
-
- */
- private static void loadNativeLibraryImpl()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibraryImpl(): loading native library tritonusvorbis"); }
- try
- {
- System.loadLibrary("tritonusvorbis");
- // only reached if no exception occures
- sm_bIsLibraryAvailable = true;
- }
- catch (Error e)
- {
- if (TDebug.TraceOggNative ||
- TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- // throw e;
- }
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibraryImpl(): loaded"); }
- }
-
-
-
- /** Returns whether the libraries are installed correctly.
- */
- public static boolean isLibraryAvailable()
- {
- return sm_bIsLibraryAvailable;
- }
-}
-
-
-
-/*** Ogg.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Packet.java b/songdbj/org/tritonus/lowlevel/ogg/Packet.java
deleted file mode 100644
index a5b3f6e7e2..0000000000
--- a/songdbj/org/tritonus/lowlevel/ogg/Packet.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Packet.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.ogg;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Wrapper for ogg_packet.
- */
-public class Packet
-{
- static
- {
- Ogg.loadNativeLibrary();
- if (TDebug.TraceOggNative)
- {
- setTrace(true);
- }
- }
-
-
- /**
- * Holds the pointer to ogg_packet
- * for the native code.
- * This must be long to be 64bit-clean.
- */
- private long m_lNativeHandle;
-
-
-
- public Packet()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Packet.<init>(): begin"); }
- int nReturn = malloc();
- if (nReturn < 0)
- {
- throw new RuntimeException("malloc of ogg_packet failed");
- }
- if (TDebug.TraceOggNative) { TDebug.out("Packet.<init>(): end"); }
- }
-
-
-
- public void finalize()
- {
- // TODO: call free()
- // call super.finalize() first or last?
- // and introduce a flag if free() has already been called?
- }
-
-
-
- private native int malloc();
- public native void free();
-
-
-
- /** Calls ogg_packet_clear().
- */
- public native void clear();
-
-
-
- /** Accesses packet and bytes.
- */
- public native byte[] getData();
-
-
- /** Accesses b_o_s.
- */
- public native boolean isBos();
-
-
- /** Accesses e_o_s.
- */
- public native boolean isEos();
-
-
- private static native void setTrace(boolean bTrace);
-}
-
-
-
-
-
-/*** Packet.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Page.java b/songdbj/org/tritonus/lowlevel/ogg/Page.java
deleted file mode 100644
index ae30f210d4..0000000000
--- a/songdbj/org/tritonus/lowlevel/ogg/Page.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Page.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.ogg;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Wrapper for ogg_page.
- */
-public class Page
-{
- static
- {
- Ogg.loadNativeLibrary();
- if (TDebug.TraceOggNative)
- {
- setTrace(true);
- }
- }
- /**
- * Holds the pointer to ogg_page
- * for the native code.
- * This must be long to be 64bit-clean.
- */
- private long m_lNativeHandle;
-
-
-
- public Page()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Page.<init>(): begin"); }
- int nReturn = malloc();
- if (nReturn < 0)
- {
- throw new RuntimeException("malloc of ogg_page failed");
- }
- if (TDebug.TraceOggNative) { TDebug.out("Page.<init>(): end"); }
- }
-
-
-
- public void finalize()
- {
- // TODO: call free()
- // call super.finalize() first or last?
- // and introduce a flag if free() has already been called?
- }
-
-
-
- private native int malloc();
- public native void free();
-
-
- /** Calls ogg_page_version().
- */
- public native int getVersion();
-
- /** Calls ogg_page_continued().
- */
- public native boolean isContinued();
-
- /** Calls ogg_page_packets().
- */
- public native int getPackets();
-
- /** Calls ogg_page_bos().
- */
- public native boolean isBos();
-
- /** Calls ogg_page_eos().
- */
- public native boolean isEos();
-
- /** Calls ogg_page_granulepos().
- */
- public native long getGranulePos();
-
- /** Calls ogg_page_serialno().
- */
- public native int getSerialNo();
-
- /** Calls ogg_page_pageno().
- */
- public native int getPageNo();
-
- /** Calls ogg_page_checksum_set().
- */
- public native void setChecksum();
-
-
- public native byte[] getHeader();
-
- public native byte[] getBody();
-
-
- private static native void setTrace(boolean bTrace);
-}
-
-
-
-
-
-/*** Page.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/StreamState.java b/songdbj/org/tritonus/lowlevel/ogg/StreamState.java
deleted file mode 100644
index 34b970c5e2..0000000000
--- a/songdbj/org/tritonus/lowlevel/ogg/StreamState.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * StreamState.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.ogg;
-
-import org.tritonus.share.TDebug;
-
-
-/** Wrapper for ogg_stream_state.
- */
-public class StreamState
-{
- static
- {
- Ogg.loadNativeLibrary();
- if (TDebug.TraceOggNative)
- {
- setTrace(true);
- }
- }
-
-
- /**
- * Holds the pointer to ogg_stream_state
- * for the native code.
- * This must be long to be 64bit-clean.
- */
- private long m_lNativeHandle;
-
-
-
- public StreamState()
- {
- if (TDebug.TraceOggNative) { TDebug.out("StreamState.<init>(): begin"); }
- int nReturn = malloc();
- if (nReturn < 0)
- {
- throw new RuntimeException("malloc of ogg_stream_state failed");
- }
- if (TDebug.TraceOggNative) { TDebug.out("StreamState.<init>(): end"); }
- }
-
-
-
- public void finalize()
- {
- // TODO: call free()
- // call super.finalize() first or last?
- // and introduce a flag if free() has already been called?
- }
-
-
-
- private native int malloc();
- public native void free();
-
-
-
- /** Calls ogg_stream_init().
- */
- public native int init(int nSerialNo);
-
- /** Calls ogg_stream_clear().
- */
- public native int clear();
-
- /** Calls ogg_stream_reset().
- */
- public native int reset();
-
- /** Calls ogg_stream_destroy().
- */
- public native int destroy();
-
- /** Calls ogg_stream_eos().
- */
- public native boolean isEOSReached();
-
-
-
- /** Calls ogg_stream_packetin().
- */
- public native int packetIn(Packet packet);
-
-
- /** Calls ogg_stream_pageout().
- */
- public native int pageOut(Page page);
-
-
- /** Calls ogg_stream_flush().
- */
- public native int flush(Page page);
-
-
- /** Calls ogg_stream_pagein().
- */
- public native int pageIn(Page page);
-
-
- /** Calls ogg_stream_packetout().
- */
- public native int packetOut(Packet packet);
-
-
- /** Calls ogg_stream_packetpeek().
- */
- public native int packetPeek(Packet packet);
-
-
- private static native void setTrace(boolean bTrace);
-}
-
-
-
-
-
-/*** StreamState.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/SyncState.java b/songdbj/org/tritonus/lowlevel/ogg/SyncState.java
deleted file mode 100644
index 3b3b535fbe..0000000000
--- a/songdbj/org/tritonus/lowlevel/ogg/SyncState.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * SyncState.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.ogg;
-
-import org.tritonus.share.TDebug;
-
-
-/** Wrapper for ogg_sync_state.
- */
-public class SyncState
-{
- static
- {
- Ogg.loadNativeLibrary();
- if (TDebug.TraceOggNative)
- {
- setTrace(true);
- }
- }
-
-
- /**
- * Holds the pointer to ogg_sync_state
- * for the native code.
- * This must be long to be 64bit-clean.
- */
- private long m_lNativeHandle;
-
-
-
- public SyncState()
- {
- if (TDebug.TraceOggNative) { TDebug.out("SyncState.<init>(): begin"); }
- int nReturn = malloc();
- if (nReturn < 0)
- {
- throw new RuntimeException("malloc of ogg_sync_state failed");
- }
- if (TDebug.TraceOggNative) { TDebug.out("SyncState.<init>(): end"); }
- }
-
-
-
- public void finalize()
- {
- // TODO: call free()
- // call super.finalize() first or last?
- // and introduce a flag if free() has already been called?
- }
-
-
-
- private native int malloc();
- public native void free();
-
-
-
- /** Calls ogg_sync_init().
- */
- public native void init();
-
-
- /** Calls ogg_sync_clear().
- */
- public native void clear();
-
-
- /** Calls ogg_sync_reset().
- */
- public native void reset();
-
-
- /** Calls ogg_sync_destroy().
- */
- public native void destroy();
-
-
- /** Calls ogg_sync_buffer()
- and ogg_sync_wrote().
- */
- public native int write(byte[] abBuffer, int nBytes);
-
-
- /** Calls ogg_sync_pageseek().
- */
- public native int pageseek(Page page);
-
-
- /** Calls ogg_sync_pageout().
- */
- public native int pageOut(Page page);
-
-
- private static native void setTrace(boolean bTrace);
-}
-
-
-
-
-
-/*** SyncState.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/package.html b/songdbj/org/tritonus/lowlevel/ogg/package.html
deleted file mode 100644
index 4202aaebac..0000000000
--- a/songdbj/org/tritonus/lowlevel/ogg/package.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Access to the native ogg library.
- The classes provided here .</p>
-
- @see org.tritonus.sampled.convert.vorbis
- </body>
-</html>
diff --git a/songdbj/org/tritonus/lowlevel/pogg/Buffer.java b/songdbj/org/tritonus/lowlevel/pogg/Buffer.java
deleted file mode 100644
index 6d94c37740..0000000000
--- a/songdbj/org/tritonus/lowlevel/pogg/Buffer.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Buffer.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2005 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.pogg;
-
-import java.io.UnsupportedEncodingException;
-
-import org.tritonus.share.TDebug;
-
-
-/** Wrapper for oggpack_buffer.
- */
-public class Buffer
-{
- static
- {
- Ogg.loadNativeLibrary();
- if (TDebug.TraceOggNative)
- {
- setTrace(true);
- }
- }
-
-
- /**
- * Holds the pointer to oggpack_buffer
- * for the native code.
- * This must be long to be 64bit-clean.
- */
- private long m_lNativeHandle;
-
-
-
- public Buffer()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): begin"); }
- int nReturn = malloc();
- if (nReturn < 0)
- {
- throw new RuntimeException("malloc of ogg_page failed");
- }
- if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): end"); }
- }
-
-
-
- public void finalize()
- {
- // TODO: call free()
- // call super.finalize() first or last?
- // and introduce a flag if free() has already been called?
- }
-
-
-
- private native int malloc();
- public native void free();
-
-
- /** Calls oggpack_writeinit().
- */
- public native void writeInit();
-
-
- /** Calls oggpack_writetrunc().
- */
- public native void writeTrunc(int nBits);
-
-
- /** Calls oggpack_writealign().
- */
- public native void writeAlign();
-
-
- /** Calls oggpack_writecopy().
- */
- public native void writeCopy(byte[] abSource, int nBits);
-
-
- /** Calls oggpack_reset().
- */
- public native void reset();
-
-
- /** Calls oggpack_writeclear().
- */
- public native void writeClear();
-
-
- /** Calls oggpack_readinit().
- */
- public native void readInit(byte[] abBuffer, int nBytes);
-
-
- /** Calls oggpack_write().
- */
- public native void write(int nValue, int nBits);
-
-
- /** Calls oggpack_look().
- */
- public native int look(int nBits);
-
-
- /** Calls oggpack_look1().
- */
- public native int look1();
-
-
- /** Calls oggpack_adv().
- */
- public native void adv(int nBits);
-
-
- /** Calls oggpack_adv1().
- */
- public native void adv1();
-
-
- /** Calls oggpack_read().
- */
- public native int read(int nBits);
-
-
- /** Calls oggpack_read1().
- */
- public native int read1();
-
-
- /** Calls oggpack_bytes().
- */
- public native int bytes();
-
-
- /** Calls oggpack_bits().
- */
- public native int bits();
-
-
- /** Calls oggpack_get_buffer().
- */
- public native byte[] getBuffer();
-
-
- /** Writes a string as UTF-8.
- Note: no length coding and no end byte are written,
- just the pure string!
- */
- public void write(String str)
- {
- write(str, false);
- }
-
-
- /** Writes a string as UTF-8, including a length coding.
- In front of the string, the length in bytes is written
- as a 32 bit integer. No end byte is written.
- */
- public void writeWithLength(String str)
- {
- write(str, true);
- }
-
-
- /** Writes a string as UTF-8, with or without a length coding.
- If a length coding is requested, the length in (UTF8-)bytes is written
- as a 32 bit integer in front of the string.
- No end byte is written.
- */
- private void write(String str, boolean bWithLength)
- {
- byte[] aBytes = null;
- try
- {
- aBytes = str.getBytes("UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- if (TDebug.TraceAllExceptions) TDebug.out(e);
- }
- if (bWithLength)
- {
- write(aBytes.length, 32);
- }
- for (int i = 0; i < aBytes.length; i++)
- {
- write(aBytes[i], 8);
- }
- }
-
-
- /** Reads a UTF-8 coded string with length coding.
- It is expected that at the current read position,
- there is a 32 bit integer containing the length in (UTF8-)bytes,
- followed by the specified number of bytes in UTF-8 coding.
-
- @return the string read from the buffer or null if an error occurs.
- */
- public String readString()
- {
- int length = read(32);
- if (length < 0)
- {
- return null;
- }
- return readString(length);
- }
-
-
- /** Reads a UTF-8 coded string without length coding.
- It is expected that at the current read position,
- there is string in UTF-8 coding.
-
- @return the string read from the buffer or null if an error occurs.
- */
- public String readString(int nLength)
- {
- byte[] aBytes = new byte[nLength];
- for (int i = 0; i < nLength; i++)
- {
- aBytes[i] = (byte) read(8);
- }
- String s = null;
- try
- {
- s = new String(aBytes, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- if (TDebug.TraceAllExceptions) TDebug.out(e);
- }
- return s;
- }
-
-
- /** Reads a single bit.
- */
- public boolean readFlag()
- {
- return (read(1) != 0);
- }
-
- private static native void setTrace(boolean bTrace);
-
- // for debugging
- public static void outBuffer(byte[] buffer)
- {
- String s = "";
- for (int i = 0; i < buffer.length; i++)
- {
- s += "" + buffer[i] + ", ";
- }
- TDebug.out("buffer: " + s);
- }
-}
-
-
-
-/*** Buffer.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/pogg/Ogg.java b/songdbj/org/tritonus/lowlevel/pogg/Ogg.java
deleted file mode 100644
index 086dd0f001..0000000000
--- a/songdbj/org/tritonus/lowlevel/pogg/Ogg.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Ogg.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.pogg;
-
-import org.tritonus.share.TDebug;
-
-
-/** libogg loading.
- */
-public class Ogg
-{
- private static boolean sm_bIsLibraryAvailable = false;
-
-
-
- static
- {
- Ogg.loadNativeLibrary();
- }
-
-
-
- public static void loadNativeLibrary()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibrary(): begin"); }
-
- if (! isLibraryAvailable())
- {
- loadNativeLibraryImpl();
- }
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibrary(): end"); }
- }
-
-
-
- /** Load the native library for ogg vorbis.
-
- This method actually does the loading of the library. Unlike
- {@link loadNativeLibrary() loadNativeLibrary()}, it does not
- check if the library is already loaded.
-
- */
- private static void loadNativeLibraryImpl()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibraryImpl(): loading native library tritonuspvorbis"); }
- try
- {
- System.loadLibrary("tritonuspvorbis");
- // only reached if no exception occures
- sm_bIsLibraryAvailable = true;
- }
- catch (Error e)
- {
- if (TDebug.TraceOggNative ||
- TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- // throw e;
- }
- if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibraryImpl(): loaded"); }
- }
-
-
-
- /** Returns whether the libraries are installed correctly.
- */
- public static boolean isLibraryAvailable()
- {
- return sm_bIsLibraryAvailable;
- }
-}
-
-
-
-/*** Ogg.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/pogg/Packet.java b/songdbj/org/tritonus/lowlevel/pogg/Packet.java
deleted file mode 100644
index 15c5d9a66e..0000000000
--- a/songdbj/org/tritonus/lowlevel/pogg/Packet.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Packet.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.pogg;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Wrapper for ogg_packet.
- */
-public class Packet
-{
- static
- {
- Ogg.loadNativeLibrary();
- if (TDebug.TraceOggNative)
- {
- setTrace(true);
- }
- }
-
-
- /**
- * Holds the pointer to ogg_packet
- * for the native code.
- * This must be long to be 64bit-clean.
- */
- private long m_lNativeHandle;
-
-
-
- public Packet()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Packet.<init>(): begin"); }
- int nReturn = malloc();
- if (nReturn < 0)
- {
- throw new RuntimeException("malloc of ogg_packet failed");
- }
- if (TDebug.TraceOggNative) { TDebug.out("Packet.<init>(): end"); }
- }
-
-
-
- public void finalize()
- {
- // TODO: call free()
- // call super.finalize() first or last?
- // and introduce a flag if free() has already been called?
- }
-
-
-
- private native int malloc();
- public native void free();
-
-
-
- /** Calls ogg_packet_clear().
- */
- public native void clear();
-
-
-
- /** Accesses packet and bytes.
- */
- public native byte[] getData();
-
-
- /** Accesses b_o_s.
- */
- public native boolean isBos();
-
-
- /** Accesses e_o_s.
- */
- public native boolean isEos();
-
-
- public native long getGranulePos();
-
-
- public native long getPacketNo();
-
-
- /** Sets the data in the packet.
- */
- public native void setData(byte[] abData, int nOffset, int nLength);
-
-
- public native void setFlags(boolean bBos, boolean bEos, long lGranulePos,
- long lPacketNo);
-
- public void setFlags(boolean bBos, boolean bEos, long lGranulePos)
- {
- setFlags(bBos, bEos, lGranulePos, 0);
- }
-
-
- private static native void setTrace(boolean bTrace);
-}
-
-
-
-
-
-/*** Packet.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/pogg/Page.java b/songdbj/org/tritonus/lowlevel/pogg/Page.java
deleted file mode 100644
index 3f89d7166e..0000000000
--- a/songdbj/org/tritonus/lowlevel/pogg/Page.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Page.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.pogg;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Wrapper for ogg_page.
- */
-public class Page
-{
- private static final int[] crc_lookup =
- {
- 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
- 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
- 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
- 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,
- 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,
- 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75,
- 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,
- 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd,
- 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,
- 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,
- 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,
- 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d,
- 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,
- 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95,
- 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,
- 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,
- 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,
- 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072,
- 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,
- 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca,
- 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,
- 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,
- 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,
- 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba,
- 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,
- 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692,
- 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,
- 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,
- 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,
- 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2,
- 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,
- 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a,
- 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,
- 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,
- 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,
- 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53,
- 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,
- 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b,
- 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,
- 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,
- 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,
- 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b,
- 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,
- 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3,
- 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,
- 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,
- 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,
- 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3,
- 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,
- 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c,
- 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,
- 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,
- 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,
- 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec,
- 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,
- 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654,
- 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,
- 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,
- 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,
- 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4,
- 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,
- 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c,
- 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,
- 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4
- };
-
-
- private byte[] m_abHeader;
- private int m_nHeaderLength;
- private byte[] m_abBody;
- private int m_nBodyLength;
-
-
- public Page()
- {
- if (TDebug.TraceOggNative) { TDebug.out("Page.<init>(): begin"); }
- if (TDebug.TraceOggNative) { TDebug.out("Page.<init>(): end"); }
- }
-
-
-
- private native int malloc();
-
- // TODO: remove calls to this method
- public void free()
- {
- }
-
-
- /** Calls ogg_page_version().
- */
- public int getVersion()
- {
- return m_abHeader[4] & 0xFF;
- }
-
-
- /** Calls ogg_page_continued().
- */
- public boolean isContinued()
- {
- return (m_abHeader[5] & 0x01) != 0;
- }
-
-
-
- /** Calls ogg_page_packets().
- */
-/* returns the number of packets that are completed on this page (if
- the leading packet is begun on a previous page, but ends on this
- page, it's counted */
-
-/* NOTE:
-If a page consists of a packet begun on a previous page, and a new
-packet begun (but not completed) on this page, the return will be:
- ogg_page_packets(page) ==1,
- ogg_page_continued(page) !=0
-
-If a page happens to be a single packet that was begun on a
-previous page, and spans to the next page (in the case of a three or
-more page packet), the return will be:
- ogg_page_packets(page) ==0,
- ogg_page_continued(page) !=0
-*/
- public int getPackets()
- {
- int n = m_abHeader[26] & 0xFF;
- int count = 0;
- for (int i = 0; i < n; i++)
- if ((m_abHeader[27 + i] & 0xFF) < 255)
- count++;
- return count;
- }
-
-
-
- /** Calls ogg_page_bos().
- */
- public boolean isBos()
- {
- return (m_abHeader[5] & 0x02) != 0;
- }
-
-
-
- /** Calls ogg_page_eos().
- */
- public boolean isEos()
- {
- return (m_abHeader[5] & 0x04) != 0;
- }
-
-
-
- /** Calls ogg_page_granulepos().
- */
- public long getGranulePos()
- {
- long granulepos = m_abHeader[13]&(0xff);
- granulepos = (granulepos<<8)|(m_abHeader[12] & 0xFF);
- granulepos = (granulepos<<8)|(m_abHeader[11] & 0xFF);
- granulepos = (granulepos<<8)|(m_abHeader[10] & 0xFF);
- granulepos = (granulepos<<8)|(m_abHeader[9] & 0xFF);
- granulepos = (granulepos<<8)|(m_abHeader[8] & 0xFF);
- granulepos = (granulepos<<8)|(m_abHeader[7] & 0xFF);
- granulepos = (granulepos<<8)|(m_abHeader[6] & 0xFF);
- return granulepos;
- }
-
-
-
- /** Calls ogg_page_serialno().
- */
- public int getSerialNo()
- {
- return m_abHeader[14] |
- (m_abHeader[15] << 8) |
- (m_abHeader[16] << 16) |
- (m_abHeader[17] << 24);
- }
-
-
-
- /** Calls ogg_page_pageno().
- */
- public int getPageNo()
- {
- return m_abHeader[18] |
- (m_abHeader[19] << 8) |
- (m_abHeader[20] << 16) |
- (m_abHeader[21] << 24);
- }
-
-
-
- /** Calls ogg_page_checksum_set().
- */
- public void setChecksum()
- {
- int crc_reg = 0;
-
- /* safety; needed for API behavior, but not framing code */
- m_abHeader[22]=0;
- m_abHeader[23]=0;
- m_abHeader[24]=0;
- m_abHeader[25]=0;
-
- for(int i = 0; i < m_nHeaderLength; i++)
- crc_reg = (crc_reg << 8) ^ crc_lookup[((crc_reg >>> 24) & 0xff) ^ (m_abHeader[i] & 0xFF)];
- for(int i = 0; i < m_nBodyLength; i++)
- crc_reg = (crc_reg << 8) ^ crc_lookup[((crc_reg >>> 24) & 0xff) ^ (m_abBody[i] & 0xFF)];
-
- m_abHeader[22] = (byte) (crc_reg & 0xff);
- m_abHeader[23] = (byte) ((crc_reg >> 8) & 0xff);
- m_abHeader[24] = (byte) ((crc_reg >> 16) & 0xff);
- m_abHeader[25] = (byte) ((crc_reg >> 24) & 0xff);
- }
-
-
-
-
- public byte[] getHeader()
- {
- byte[] abHeader = new byte[m_nHeaderLength];
- System.arraycopy(m_abHeader, 0, abHeader, 0, m_nHeaderLength);
- return abHeader;
- }
-
-
-
- public byte[] getBody()
- {
- byte[] abBody = new byte[m_nBodyLength];
- System.arraycopy(m_abBody, 0, abBody, 0, m_nBodyLength);
- return abBody;
- }
-
-
-
- public void setData(byte[] abHeader, int nHeaderOffset,
- int nHeaderLength,
- byte[] abBody, int nBodyOffset,
- int nBodyLength)
- {
- m_abHeader = new byte[nHeaderLength];
- System.arraycopy(abHeader, nHeaderOffset, m_abHeader, 0, nHeaderLength);
- m_nHeaderLength = nHeaderLength;
- m_abBody = new byte[nBodyLength];
- System.arraycopy(abBody, nBodyOffset, m_abBody, 0, nBodyLength);
- m_nBodyLength = nBodyLength;
- }
-}
-
-
-
-
-
-/*** Page.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/pogg/StreamState.java b/songdbj/org/tritonus/lowlevel/pogg/StreamState.java
deleted file mode 100644
index 3fde33de8f..0000000000
--- a/songdbj/org/tritonus/lowlevel/pogg/StreamState.java
+++ /dev/null
@@ -1,703 +0,0 @@
-/*
- * StreamState.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2005 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.pogg;
-
-import org.tritonus.share.TDebug;
-
-
-/** Wrapper for ogg_stream_state.
- */
-public class StreamState
-{
- private static final int INITIAL_BODY_DATA_SIZE = 16 * 1024;
- private static final int INITIAL_LACING_VALUES_SIZE = 1024;
-
- /** The serial number of the stream.
- This is set by init().
- */
- private int m_nSerialNo;
-
- /** Storage for packet bodies.
- */
- private byte[] m_abBodyData;
-
- /** Number of bytes used in te body storage.
- */
- private int m_nBodyFill;
-
- /** Number of bytes aready returned (as pages) from the body storage.
- */
- private int m_nBodyReturned;
-
- /** Lacing values. Bit 0 to 7 contain the lacing value (mask
- 0xFF). Bit 8 is set if the segment belongs to the first
- packet of the stream (mask 0x100). Bit 9 is set ig the
- segment belongs to the last packet of the stream (mask 0x200).
- */
- private int[] m_anLacingValues;
-
- /** Granule values.
- */
- private long[] m_alGranuleValues;
-
- /** Number of elements used in m_anLacingValues and m_alGranuleValues.
- The elements with the index m_nLacingFill is the first free element.
- */
- private int m_nLacingFill;
-
- /** Pointer to the index in m_anLacingValues where the lacing values
- of the last decoded packet start (??)
- */
- private int m_nLacingPacket;
-
- /**
- */
- private int m_nLacingReturned;
-
- private byte[] m_abHeader;
-
- private int m_nHeaderFill;
-
- private boolean m_bBos;
- private boolean m_bEos;
- private int m_nPageNo;
- private long m_lPacketNo;
- private long m_lGranulePos;
-
-
-
- public StreamState()
- {
- if (TDebug.TraceOggNative) { TDebug.out("StreamState.<init>(): begin"); }
- if (TDebug.TraceOggNative) { TDebug.out("StreamState.<init>(): end"); }
- }
-
-
-
- public void free()
- {
- }
-
-
-
- /** Calls ogg_stream_init().
- */
- public int init(int nSerialNo)
- {
- m_nSerialNo = nSerialNo;
- m_abBodyData = new byte[INITIAL_BODY_DATA_SIZE];
- m_nBodyFill = 0;
- m_nBodyReturned = 0;
- m_anLacingValues = new int[INITIAL_LACING_VALUES_SIZE];
- m_alGranuleValues = new long[INITIAL_LACING_VALUES_SIZE];
- m_nLacingFill = 0;
- m_nLacingPacket = 0;
- m_nLacingReturned = 0;
-
- m_abHeader = new byte[282];
- m_nHeaderFill = 0;
-
- m_bBos = false;
- m_bEos = false;
- m_nPageNo = 0;
- m_lPacketNo = 0;
- m_lGranulePos = 0;
-
- // TODO: necessary?
- for (int i = 0; i < m_abBodyData.length; i++)
- m_abBodyData[i] = 0;
- for (int i = 0; i < m_anLacingValues.length; i++)
- m_anLacingValues[i] = 0;
- for (int i = 0; i < m_alGranuleValues.length; i++)
- m_alGranuleValues[i] = 0;
-
- // TODO: remove return value
- return 0;
- }
-
- /** Calls ogg_stream_clear().
- */
- public int clear()
- {
- m_nSerialNo = 0;
- m_abBodyData = null;
- m_nBodyFill = 0;
- m_nBodyReturned = 0;
- m_anLacingValues = null;
- m_alGranuleValues = null;
- m_nLacingFill = 0;
- m_nLacingPacket = 0;
- m_nLacingReturned = 0;
-
- m_abHeader = null;
- m_nHeaderFill = 0;
-
- m_bBos = false;
- m_bEos = false;
- m_nPageNo = 0;
- m_lPacketNo = 0;
- m_lGranulePos = 0;
-
- // TODO: remove return value
- return 0;
- }
-
- /** Calls ogg_stream_reset().
- */
- public int reset()
- {
- m_nBodyFill = 0;
- m_nBodyReturned = 0;
-
- m_nLacingFill = 0;
- m_nLacingPacket = 0;
- m_nLacingReturned = 0;
-
- m_nHeaderFill = 0;
-
- m_bBos = false;
- m_bEos = false;
- m_nPageNo = -1;
- m_lPacketNo = 0;
- m_lGranulePos = 0;
-
- // TODO: remove return value
- return 0;
- }
-
- /** Calls ogg_stream_eos().
- */
- public boolean isEOSReached()
- {
- return m_bEos;
- }
-
- /** Calls ogg_stream_packetin().
- */
- /* submit data to the internal buffer of the framing engine */
- public int packetIn(Packet packet)
- {
- int i;
- byte[] abPacketData = packet.getData();
- int lacing_vals = abPacketData.length / 255 + 1;
-
- if (m_nBodyReturned > 0)
- {
- /* advance packet data according to the body_returned pointer. We
- had to keep it around to return a pointer into the buffer last
- call */
- m_nBodyFill -= m_nBodyReturned;
- if (m_nBodyFill > 0)
- {
- System.arraycopy(m_abBodyData, m_nBodyReturned,
- m_abBodyData, 0, m_nBodyFill);
- }
- m_nBodyReturned = 0;
- }
-
- /* make sure we have the buffer storage */
- assureBodyDataCapacity(abPacketData.length);
- assureLacingValuesCapacity(lacing_vals);
-
- /* Copy in the submitted packet. Yes, the copy is a waste;
- this is the liability of overly clean abstraction for the
- time being. It will actually be fairly easy to eliminate
- the extra copy in the future */
- System.arraycopy(abPacketData, 0, m_abBodyData, m_nBodyFill,
- abPacketData.length);
- m_nBodyFill += abPacketData.length;
-
- /* Store lacing vals for this packet */
- for (i = 0; i < lacing_vals - 1; i++)
- {
- m_anLacingValues[m_nLacingFill + i] = 255;
- m_alGranuleValues[m_nLacingFill + i] = m_lGranulePos;
- }
- m_anLacingValues[m_nLacingFill + i] = abPacketData.length % 255;
- m_alGranuleValues[m_nLacingFill + i] = packet.getGranulePos();
- m_lGranulePos = packet.getGranulePos();
-
- /* flag the first segment as the beginning of the packet */
- m_anLacingValues[m_nLacingFill] |= 0x100;
-
- m_nLacingFill += lacing_vals;
-
- /* for the sake of completeness */
- m_lPacketNo++;
-
- if (packet.isEos())
- m_bEos = true;
- return 0;
- }
-
-
-
- /** Calls ogg_stream_pageout().
- */
-/* This constructs pages from buffered packet segments. The pointers
- returned are to static buffers; do not free. The returned buffers are
- good only until the next call (using the same ogg_stream_state) */
- public int pageOut(Page page)
- {
- if ((m_bEos && m_nLacingFill > 0) || /* 'were done, now flush' */
- m_nBodyFill - m_nBodyReturned > 4096 || /* 'page nominal size' */
- m_nLacingFill >= 255 || /* 'segment table full' */
- (m_nLacingFill > 0 && ! m_bBos)) /* 'initial header page' */
- {
- return flush(page);
- }
- /* not enough data to construct a page and not end of stream */
- return 0;
- }
-
-
-
- /** Calls ogg_stream_flush().
- */
-/* This will flush remaining packets into a page (returning nonzero),
- even if there is not enough data to trigger a flush normally
- (undersized page). If there are no packets or partial packets to
- flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will
- try to flush a normal sized page like ogg_stream_pageout; a call to
- ogg_stream_flush does not guarantee that all packets have flushed.
- Only a return value of 0 from ogg_stream_flush indicates all packet
- data is flushed into pages.
-
- since ogg_stream_flush will flush the last page in a stream even if
- it's undersized, you almost certainly want to use ogg_stream_pageout
- (and *not* ogg_stream_flush) unless you specifically need to flush
- an page regardless of size in the middle of a stream.
-*/
- public int flush(Page page)
- {
- int i;
- int vals = 0;
- int maxvals = Math.min(m_nLacingFill, 255);
- int bytes = 0;
- int acc = 0;
- long granule_pos = m_alGranuleValues[0];
-
- if (maxvals == 0)
- {
- return 0;
- }
-
- /* construct a page */
- /* decide how many segments to include */
-
- /* If this is the initial header case, the first page must
- only include the initial header packet */
- if (! m_bBos)
- { /* 'initial header page' case */
- granule_pos = 0;
- for (vals = 0; vals < maxvals; vals++)
- {
- if ((m_anLacingValues[vals] & 0x0FF) < 255)
- {
- vals++;
- break;
- }
- }
- }
- else
- {
- for (vals = 0; vals < maxvals; vals++)
- {
- if (acc > 4096)
- break;
- acc += (m_anLacingValues[vals] & 0x0FF);
- granule_pos = m_alGranuleValues[vals];
- }
- }
-
- /* construct the header in temp storage */
- m_abHeader[0] = (byte) 'O';
- m_abHeader[1] = (byte) 'g';
- m_abHeader[2] = (byte) 'g';
- m_abHeader[3] = (byte) 'S';
-
- /* stream structure version */
- m_abHeader[4] = 0;
-
- m_abHeader[5] = 0x00;
- /* continued packet flag? */
- if ((m_anLacingValues[0] & 0x100) == 0)
- m_abHeader[5] |= 0x01;
- /* first page flag? */
- if (! m_bBos)
- m_abHeader[5] |= 0x02;
- /* last page flag? */
- if (m_bEos && m_nLacingFill == vals)
- m_abHeader[5] |= 0x04;
- m_bBos = true;
-
- /* 64 bits of PCM position */
- for (i = 6; i < 14; i++)
- {
- m_abHeader[i] = (byte) (granule_pos & 0xFF);
- granule_pos >>>= 8;
- }
-
- /* 32 bits of stream serial number */
- int serialno = m_nSerialNo;
- for (i = 14; i < 18; i++)
- {
- m_abHeader[i] = (byte) (serialno & 0xFF);
- serialno >>>= 8;
- }
-
- /* 32 bits of page counter (we have both counter and page header
- because this val can roll over) */
- if (m_nPageNo == -1)
- {
- m_nPageNo = 0; /* because someone called
- stream_reset; this would be a
- strange thing to do in an
- encode stream, but it has
- plausible uses */
- }
- int pageno = m_nPageNo++;
- for (i = 18; i < 22; i++)
- {
- m_abHeader[i] = (byte) (pageno & 0xFF);
- pageno >>>= 8;
- }
-
- /* zero for computation; filled in later */
- m_abHeader[22] = 0;
- m_abHeader[23] = 0;
- m_abHeader[24] = 0;
- m_abHeader[25] = 0;
-
- /* segment table */
- m_abHeader[26] = (byte) (vals & 0xFF);
- for (i = 0; i < vals; i++)
- {
- m_abHeader[i + 27] = (byte) (m_anLacingValues[i] & 0xFF);
- bytes += (m_anLacingValues[i] & 0xFF);
- }
-
- /* set pointers in the ogg_page struct */
- page.setData(m_abHeader, 0, vals + 27,
- m_abBodyData, m_nBodyReturned, bytes);
- m_nHeaderFill = vals + 27;
-
- /* advance the lacing data and set the body_returned pointer */
-
- m_nLacingFill -= vals;
- System.arraycopy(m_anLacingValues, vals, m_anLacingValues, 0,
- m_nLacingFill);
- System.arraycopy(m_alGranuleValues, vals, m_alGranuleValues, 0,
- m_nLacingFill);
- m_nBodyReturned += bytes;
-
- /* calculate the checksum */
-
- page.setChecksum();
-
- /* done */
- return 1;
- }
-
-
-
- /** add the incoming page to the stream state; we decompose the
- page into packet segments here as well.
-
- @return 0 on success, -1 if the stream serial number stored in
- the page does not match the one stored in the stream state or
- if the protocol version stored in the page is greater than 0.
- */
- public int pageIn(Page page)
- {
- byte[] header = page.getHeader();
- byte[] body = page.getBody();
- int nBodyOffset = 0;
- int bodysize = body.length;
- int segptr = 0;
-
- int version = page.getVersion();
- boolean continued = page.isContinued();
- boolean bos = page.isBos();
- boolean eos = page.isEos();
- long granulepos = page.getGranulePos();
- int serialno = page.getSerialNo();
- int pageno = page.getPageNo();
- int segments = header[26] & 0xFF;
-
- /* clean up 'returned data' */
- int lr = m_nLacingReturned;
- int br = m_nBodyReturned;
-
- /* body data */
- if (br > 0)
- {
- m_nBodyFill -= br;
- if (m_nBodyFill > 0)
- {
- System.arraycopy(m_abBodyData, br, m_abBodyData, 0,
- m_nBodyFill);
- }
- m_nBodyReturned = 0;
- }
-
- if (lr > 0)
- {
- /* segment table */
- if (m_nLacingFill - lr > 0)
- {
- System.arraycopy(m_anLacingValues, lr, m_anLacingValues, 0,
- m_nLacingFill - lr);
- System.arraycopy(m_alGranuleValues, lr, m_alGranuleValues, 0,
- m_nLacingFill - lr);
- }
- m_nLacingFill -= lr;
- m_nLacingPacket -= lr;
- m_nLacingReturned = 0;
- }
-
- /* check the serial number */
- if (serialno != m_nSerialNo)
- return -1;
- if (version > 0)
- return -1;
-
- assureLacingValuesCapacity(segments + 1);
-
- /* are we in sequence? */
- if (pageno != m_nPageNo)
- {
- int i;
-
- /* unroll previous partial packet (if any) */
- for (i = m_nLacingPacket; i < m_nLacingFill; i++)
- m_nBodyFill -= (m_anLacingValues[i] & 0xFF);
- m_nLacingFill = m_nLacingPacket;
-
- /* make a note of dropped data in segment table */
- if (m_nPageNo != -1)
- {
- m_anLacingValues[m_nLacingFill] = 0x400;
- m_nLacingFill++;
- m_nLacingPacket++;
- }
-
- /* are we a 'continued packet' page? If so, we'll need to skip
- some segments */
- if (continued)
- {
- bos = false;
- for (; segptr < segments; segptr++)
- {
- int val = header[27 + segptr] & 0xFF;
- nBodyOffset += val;
- bodysize -= val;
- if (val < 255)
- {
- segptr++;
- break;
- }
- }
- }
- }
-
- if (bodysize > 0)
- {
- assureBodyDataCapacity(bodysize);
- System.arraycopy(body, nBodyOffset, m_abBodyData, m_nBodyFill,
- bodysize);
- m_nBodyFill += bodysize;
- }
-
- int saved = -1;
- while (segptr < segments)
- {
- int val = header[27 + segptr] & 0xFF;
- m_anLacingValues[m_nLacingFill] = val;
- m_alGranuleValues[m_nLacingFill] = -1;
-
- if (bos)
- {
- m_anLacingValues[m_nLacingFill] |= 0x100;
- bos = false;
- }
-
- if (val < 255)
- saved = m_nLacingFill;
-
- m_nLacingFill++;
- segptr++;
-
- if (val < 255)
- m_nLacingPacket = m_nLacingFill;
- }
-
- /* set the granulepos on the last granuleval of the last full packet */
- if (saved != -1)
- {
- m_alGranuleValues[saved] = granulepos;
- }
-
- if (eos)
- {
- m_bEos = true;
- if (m_nLacingFill > 0)
- m_anLacingValues[m_nLacingFill - 1] |= 0x200;
- }
-
- m_nPageNo = pageno + 1;
-
- return 0;
- }
-
-
- /** Calls ogg_stream_packetout().
- */
- public int packetOut(Packet packet)
- {
- return packetOutInternal(packet, true);
- }
-
-
- /** Calls ogg_stream_packetpeek().
- */
- public int packetPeek(Packet packet)
- {
- return packetOutInternal(packet, false);
- }
-
-
- /** Retrieves a packet from the internal storage for emission.
- This method is called by packetOut and packetPeek.
-
- @param packet the Packet object to store the retrieved packet
- data in. May be null if bAdvance is false.
-
- @param bAdvance should the internal pointers to the packet
- data storage be advanced to the next packet after retrieving
- this one? Called with a value of true for ordinary packet out
- and with a value of false for packet peek.
-
- @return
- */
- private int packetOutInternal(Packet packet, boolean bAdvance)
- {
- /* The last part of decode. We have the stream broken into
- packet segments. Now we need to group them into packets
- (or return the out of sync markers) */
-
- int ptr = m_nLacingReturned;
-
- if (m_nLacingPacket <= ptr)
- return 0;
-
- if ((m_anLacingValues[ptr] & 0x400) != 0)
- {
- /* we need to tell the codec there's a gap; it might need
- to handle previous packet dependencies. */
- m_nLacingReturned++;
- m_lPacketNo++;
- return -1;
- }
-
- if (packet == null && ! bAdvance)
- return 1; /* just using peek as an inexpensive way
- to ask if there's a whole packet
- waiting */
-
- /* Gather the whole packet. We'll have no holes or a partial
- * packet */
- int size = m_anLacingValues[ptr] & 0xFF;
- int bytes = size;
- /* last packet of the stream? */
- boolean eos = (m_anLacingValues[ptr] & 0x200) != 0;
- /* first packet of the stream? */
- boolean bos = (m_anLacingValues[ptr] & 0x100) != 0;
-
- while (size == 255)
- {
- int val = m_anLacingValues[++ptr];
- size = val & 0xff;
- if ((val & 0x200) != 0)
- eos = true;
- bytes += size;
- }
-
- if (packet != null)
- {
- packet.setData(m_abBodyData, m_nBodyReturned, bytes);
- packet.setFlags(bos, eos, m_alGranuleValues[ptr], m_lPacketNo);
- }
-
- if (bAdvance)
- {
- m_nBodyReturned += bytes;
- m_nLacingReturned = ptr + 1;
- m_lPacketNo++;
- }
- return 1;
- }
-
-
- private void assureBodyDataCapacity(int needed)
- {
- if (m_abBodyData.length <= m_nBodyFill + needed)
- {
- int nNewSize = m_abBodyData.length + needed + 1024;
- byte[] abNewBodyData = new byte[nNewSize];
- System.arraycopy(m_abBodyData, 0, abNewBodyData, 0,
- m_abBodyData.length);
- m_abBodyData = abNewBodyData;
- }
- }
-
-
-
- private void assureLacingValuesCapacity(int needed)
- {
- if (m_anLacingValues.length <= m_nLacingFill + needed)
- {
- int nNewSize = m_anLacingValues.length + needed + 32;
- int[] anNewLacingValues = new int[nNewSize];
- System.arraycopy(m_anLacingValues, 0, anNewLacingValues, 0,
- m_anLacingValues.length);
- m_anLacingValues = anNewLacingValues;
- long[] alNewGranuleValues = new long[nNewSize];
- System.arraycopy(m_alGranuleValues, 0, alNewGranuleValues, 0,
- m_alGranuleValues.length);
- m_alGranuleValues = alNewGranuleValues;
- }
- }
-}
-
-
-
-
-
-/*** StreamState.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/pogg/SyncState.java b/songdbj/org/tritonus/lowlevel/pogg/SyncState.java
deleted file mode 100644
index 4246808bd3..0000000000
--- a/songdbj/org/tritonus/lowlevel/pogg/SyncState.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * SyncState.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 - 2005 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.lowlevel.pogg;
-
-import org.tritonus.share.TDebug;
-
-
-/** Wrapper for ogg_sync_state.
- */
-public class SyncState
-{
- /** The stream buffer.
- This points to a buffer that holds the incoming data from a stream
- until the data is emitted in form of a page.
- */
- private byte[] m_abData;
-
- /** The number of bytes in the stream buffer that are used. This
- always counts from the beginning of the buffer. So
- m_abData[m_nFill] is the first free byte in the buffer.
- */
- private int m_nFill;
-
- /** Number of bytes that have been used to construct a returned
- page. This is counted from the beginning of the
- buffer. m_abData[m_nReturned] is the first valid byte in the
- buffer.
- */
- private int m_nReturned;
-
- /**
- */
- private boolean m_bUnsynced;
-
- /**
- */
- private int m_nHeaderBytes;
-
- /**
- */
- private int m_nBodyBytes;
-
- /** Page object for re-calculating the checksum.
- */
- private Page m_tmpPage;
-
- /** Storage for the checksum saved from the page.
- */
- private byte[] m_abChecksum;
-
-
- public SyncState()
- {
- if (TDebug.TraceOggNative) { TDebug.out("SyncState.<init>(): begin"); }
- m_tmpPage = new Page();
- m_abChecksum = new byte[4];
- if (TDebug.TraceOggNative) { TDebug.out("SyncState.<init>(): end"); }
- }
-
-
- // TODO: remove calls to this method
- public void free()
- {
- }
-
-
-
- /** Calls ogg_sync_init().
- */
- public void init()
- {
- m_abData = null;
- m_nFill = 0;
- m_nReturned = 0;
- m_bUnsynced = false;
- m_nHeaderBytes = 0;
- m_nBodyBytes = 0;
- }
-
-
- /** Calls ogg_sync_clear().
- */
- public void clear()
- {
- init();
- }
-
-
- /** Calls ogg_sync_reset().
- */
- public void reset()
- {
- m_nFill = 0;
- m_nReturned = 0;
- m_bUnsynced = false;
- m_nHeaderBytes = 0;
- m_nBodyBytes = 0;
- }
-
-
- /** Writes to the stream buffer.
- */
- public int write(byte[] abBuffer, int nBytes)
- {
- /* Clear out space that has been previously returned. */
- if (m_nReturned > 0)
- {
- m_nFill -= m_nReturned;
- if (m_nFill > 0)
- {
- System.arraycopy(m_abData, m_nReturned,
- m_abData, 0,
- m_nFill);
- }
- m_nReturned = 0;
- }
-
- /* Check for enough space in the stream buffer and if it is
- * allocated at all. If there isn't sufficient space, extend
- * the buffer. */
- if (m_abData == null || nBytes > m_abData.length - m_nFill)
- {
- int nNewSize = nBytes + m_nFill + 4096;
- byte[] abOldBuffer = m_abData;
- m_abData = new byte[nNewSize];
- if (abOldBuffer != null)
- {
- System.arraycopy(abOldBuffer, 0, m_abData, 0, m_nFill);
- }
- }
-
- /* Now finally fill with the new data. */
- System.arraycopy(abBuffer, 0, m_abData, m_nFill, nBytes);
- m_nFill += nBytes;
- return 0;
- }
-
-
- /** Synchronizes the stream. This method looks if there is a
- complete, valid page in the stream buffer. If a page is found,
- it is returned in the passed Page object.
-
- @param page The Page to store the result of the page search
- in. The content is only changed if the return value is > 0.
-
- @return if a page has been found at the current location, the
- length of the page in bytes is returned. If not enough data
- for a page is available in the stream buffer, 0 is
- returned. If data in the stream buffer has been skipped
- because there is no page at the current position, the skip
- amount in bytes is returned as a negative number.
- */
- public int pageseek(Page page)
- {
- int nPage = m_nReturned;
- int nBytes = m_nFill - m_nReturned;
-
- if (m_nHeaderBytes == 0)
- {
- if (nBytes < 27)
- {
- /* Not enough data for a header. */
- return 0;
- }
- /* Verify capture pattern. */
- if (m_abData[nPage] != (byte) 'O' ||
- m_abData[nPage + 1] != (byte) 'g' ||
- m_abData[nPage + 2] != (byte) 'g' ||
- m_abData[nPage + 3] != (byte) 'S')
- {
- TDebug.out("wrong capture pattern");
- return syncFailure();
- }
- int nHeaderBytes = (m_abData[nPage + 26] & 0xFF) + 27;
- if (nBytes < nHeaderBytes)
- {
- /* Not enough data for header + segment table. */
- return 0;
- }
- /* Count up body length in the segment table. */
- for (int i = 0; i < (m_abData[nPage + 26] & 0xFF); i++)
- {
- m_nBodyBytes += (m_abData[nPage + 27 + i] & 0xFF);
- }
- m_nHeaderBytes = nHeaderBytes;
- }
-
- if (m_nBodyBytes + m_nHeaderBytes > nBytes)
- {
- /* Not enough data for the whole packet. */
- return 0;
- }
-
- /* Save the original checksum, set it to zero and recalculate it. */
- System.arraycopy(m_abData, nPage + 22, m_abChecksum, 0, 4);
- m_abData[nPage + 22] = 0;
- m_abData[nPage + 23] = 0;
- m_abData[nPage + 24] = 0;
- m_abData[nPage + 25] = 0;
-
- m_tmpPage.setData(m_abData, nPage, m_nHeaderBytes,
- m_abData, nPage + m_nHeaderBytes, m_nBodyBytes);
-// TDebug.out("temporary page:");
-// byte[] abHeader = m_tmpPage.getHeader();
-// TDebug.out("H0:" + m_abData[nPage + 0] + " - " + abHeader[0]);
-// TDebug.out("H1:" + m_abData[nPage + 1] + " - " + abHeader[1]);
-// TDebug.out("H2:" + m_abData[nPage + 2] + " - " + abHeader[2]);
-// TDebug.out("H3:" + m_abData[nPage + 3] + " - " + abHeader[3]);
-// TDebug.out("" + m_abChecksum[0] + " - " + abHeader[22]);
-// TDebug.out("" + m_abChecksum[1] + " - " + abHeader[23]);
-// TDebug.out("" + m_abChecksum[2] + " - " + abHeader[24]);
-// TDebug.out("" + m_abChecksum[3] + " - " + abHeader[25]);
- m_tmpPage.setChecksum();
- byte[] abHeader = m_tmpPage.getHeader();
- //m_tmpPage.free();
- if (abHeader[22] != m_abChecksum[0] ||
- abHeader[23] != m_abChecksum[1] ||
- abHeader[24] != m_abChecksum[2] ||
- abHeader[25] != m_abChecksum[3])
- {
- TDebug.out("wrong checksum");
- TDebug.out("" + m_abChecksum[0] + " - " + abHeader[22]);
- TDebug.out("" + m_abChecksum[1] + " - " + abHeader[23]);
- TDebug.out("" + m_abChecksum[2] + " - " + abHeader[24]);
- TDebug.out("" + m_abChecksum[3] + " - " + abHeader[25]);
- /* Copy back the saved checksum. */
- System.arraycopy(m_abChecksum, 0, m_abData, nPage + 22, 4);
- return syncFailure();
- }
-
- /* Ok, we have a correct page to emit. */
- page.setData(m_abData, nPage, m_nHeaderBytes,
- m_abData, nPage + m_nHeaderBytes, m_nBodyBytes);
- m_bUnsynced = false;
- nBytes = m_nHeaderBytes + m_nBodyBytes;
- m_nReturned += nBytes;
- m_nHeaderBytes = 0;
- m_nBodyBytes = 0;
- return nBytes;
- }
-
-
- /** Auxiliary method for pageseek().
- */
- private int syncFailure()
- {
- int nPage = m_nReturned;
- int nBytes = m_nFill - m_nReturned;
- m_nHeaderBytes = 0;
- m_nBodyBytes = 0;
- int nNext = -1;
- for (int i = 0; i < nBytes - 1; i++)
- {
- if (m_abData[nPage + 1 + i] == (byte) 'O')
- {
- nNext = nPage + 1 + i;
- break;
- }
- }
- if (nNext == -1)
- {
- nNext = m_nFill;
- }
- m_nReturned = nNext;
- return -(nNext - nPage);
- }
-
-
-
-
- /** Returns a page from the stream buffer, if possible. This
- method searches the current data in the stream buffer for the
- beginning of a page. If there is one, it is returned in the
- passed Page object. A synchronization error is signaled by a
- return value of -1. However, only the first synchronization
- error is reported. Consecutive sync errors are suppressed.
-
- @param page The Page to store the result of the page search
- in. The content is only changed if the return value is 1.
-
- @return 1 if a page has been found, 0 if there is not enough
- data, -1 if a synchronization error occured.
- */
- public int pageOut(Page page)
- {
- while (true)
- {
- int nReturn = pageseek(page);
- if (nReturn > 0)
- {
- return 1;
- }
- else if (nReturn == 0)
- {
- return 0;
- }
- else // nReturn < 0
- {
- if (! m_bUnsynced)
- {
- m_bUnsynced = true;
- return -1;
- }
- }
- }
- }
-}
-
-
-
-
-
-/*** SyncState.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/pogg/package.html b/songdbj/org/tritonus/lowlevel/pogg/package.html
deleted file mode 100644
index 57b0e50763..0000000000
--- a/songdbj/org/tritonus/lowlevel/pogg/package.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Alternative pure java implementation of the ogg library.
- The classes provided here .</p>
-
- @see org.tritonus.sampled.convert.pvorbis
- </body>
-</html>
diff --git a/songdbj/org/tritonus/share/ArraySet.java b/songdbj/org/tritonus/share/ArraySet.java
deleted file mode 100644
index 5aa677364f..0000000000
--- a/songdbj/org/tritonus/share/ArraySet.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ArraySet.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 -2004 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-
-
-
-public class ArraySet<E>
-extends ArrayList<E>
-implements Set<E>
-{
- public ArraySet()
- {
- super();
- }
-
-
-
- public ArraySet(Collection<E> c)
- {
- this();
- addAll(c);
- }
-
-
-
- public boolean add(E element)
- {
- if (!contains(element))
- {
- super.add(element);
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
-
- public void add(int index, E element)
- {
- throw new UnsupportedOperationException("ArraySet.add(int index, Object element) unsupported");
- }
-
- public E set(int index, E element)
- {
- throw new UnsupportedOperationException("ArraySet.set(int index, Object element) unsupported");
- }
-
-}
-
-
-
-/*** ArraySet.java ***/
diff --git a/songdbj/org/tritonus/share/GlobalInfo.java b/songdbj/org/tritonus/share/GlobalInfo.java
deleted file mode 100644
index 9a44c9c870..0000000000
--- a/songdbj/org/tritonus/share/GlobalInfo.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * GlobalInfo.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share;
-
-import org.tritonus.share.TDebug;
-
-
-
-public class GlobalInfo
-{
- private static final String VENDOR = "Tritonus is free software. See http://www.tritonus.org/";
- private static final String VERSION = "0.3.1";
-
-
-
- public static String getVendor()
- {
- return VENDOR;
- }
-
-
-
- public static String getVersion()
- {
- return VERSION;
- }
-}
-
-
-
-/*** GlobalInfo.java ***/
-
diff --git a/songdbj/org/tritonus/share/StringHashedSet.java b/songdbj/org/tritonus/share/StringHashedSet.java
deleted file mode 100644
index 8e244665fb..0000000000
--- a/songdbj/org/tritonus/share/StringHashedSet.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * StringHashedSet.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.tritonus.share.ArraySet;
-
-
-/**
- * A set where the elements are uniquely referenced by their
- * string representation as given by the objects toString()
- * method. No 2 objects with the same toString() can
- * be in the set.
- * <p>
- * The <code>contains(Object elem)</code> and <code>get(Object elem)</code>
- * methods can be called with Strings as <code>elem</code> parameter.
- * For <code>get(Object elem)</code>, the object that has been added
- * is returned, and not its String representation.
- * <p>
- * Though it's possible to store
- * Strings as objects in this class, it doesn't make sense
- * as you could use ArraySet for that equally well.
- * <p>
- * You shouldn't use the ArrayList specific functions
- * like those that take index parameters.
- * <p>
- * It is not possible to add <code>null</code> elements.
- */
-
-public class StringHashedSet<E> extends ArraySet<E>
-{
- public StringHashedSet()
- {
- super();
- }
-
- public StringHashedSet(Collection<E> c)
- {
- super(c);
- }
-
- public boolean add(E elem)
- {
- if (elem==null) {
- return false;
- }
- return super.add(elem);
- }
-
- public boolean contains(Object elem)
- {
- if (elem==null) {
- return false;
- }
- String comp=elem.toString();
- Iterator<E> it=iterator();
- while (it.hasNext()) {
- if (comp.equals(it.next().toString())) {
- return true;
- }
- }
- return false;
- }
-
- public E get(E elem) {
- if (elem==null) {
- return null;
- }
- String comp=elem.toString();
- Iterator<E> it=iterator();
- while (it.hasNext()) {
- E thisElem=it.next();
- if (comp.equals(thisElem.toString())) {
- return thisElem;
- }
- }
- return null;
- }
-}
-
-/*** StringHashedSet.java ***/
diff --git a/songdbj/org/tritonus/share/TCircularBuffer.java b/songdbj/org/tritonus/share/TCircularBuffer.java
deleted file mode 100644
index 11ebc0af01..0000000000
--- a/songdbj/org/tritonus/share/TCircularBuffer.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * TCircularBuffer.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share;
-
-import org.tritonus.share.TDebug;
-
-
-
-public class TCircularBuffer
-{
- private boolean m_bBlockingRead;
- private boolean m_bBlockingWrite;
- private byte[] m_abData;
- private int m_nSize;
- private long m_lReadPos;
- private long m_lWritePos;
- private Trigger m_trigger;
- private boolean m_bOpen;
-
-
-
- public TCircularBuffer(int nSize, boolean bBlockingRead, boolean bBlockingWrite, Trigger trigger)
- {
- m_bBlockingRead = bBlockingRead;
- m_bBlockingWrite = bBlockingWrite;
- m_nSize = nSize;
- m_abData = new byte[m_nSize];
- m_lReadPos = 0;
- m_lWritePos = 0;
- m_trigger = trigger;
- m_bOpen = true;
- }
-
-
-
- public void close()
- {
- m_bOpen = false;
- // TODO: call notify() ?
- }
-
-
-
- private boolean isOpen()
- {
- return m_bOpen;
- }
-
-
- public int availableRead()
- {
- return (int) (m_lWritePos - m_lReadPos);
- }
-
-
-
- public int availableWrite()
- {
- return m_nSize - availableRead();
- }
-
-
-
- private int getReadPos()
- {
- return (int) (m_lReadPos % m_nSize);
- }
-
-
-
- private int getWritePos()
- {
- return (int) (m_lWritePos % m_nSize);
- }
-
-
-
- public int read(byte[] abData)
- {
- return read(abData, 0, abData.length);
- }
-
-
-
- public int read(byte[] abData, int nOffset, int nLength)
- {
- if (TDebug.TraceCircularBuffer)
- {
- TDebug.out(">TCircularBuffer.read(): called.");
- dumpInternalState();
- }
- if (! isOpen())
- {
- if (availableRead() > 0)
- {
- nLength = Math.min(nLength, availableRead());
- if (TDebug.TraceCircularBuffer) { TDebug.out("reading rest in closed buffer, length: " + nLength); }
- }
- else
- {
- if (TDebug.TraceCircularBuffer) { TDebug.out("< not open. returning -1."); }
- return -1;
- }
- }
- synchronized (this)
- {
- if (m_trigger != null && availableRead() < nLength)
- {
- if (TDebug.TraceCircularBuffer) { TDebug.out("executing trigger."); }
- m_trigger.execute();
- }
- if (!m_bBlockingRead)
- {
- nLength = Math.min(availableRead(), nLength);
- }
- int nRemainingBytes = nLength;
- while (nRemainingBytes > 0)
- {
- while (availableRead() == 0)
- {
- try
- {
- wait();
- }
- catch (InterruptedException e)
- {
- if (TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- }
- }
- int nAvailable = Math.min(availableRead(), nRemainingBytes);
- while (nAvailable > 0)
- {
- int nToRead = Math.min(nAvailable, m_nSize - getReadPos());
- System.arraycopy(m_abData, getReadPos(), abData, nOffset, nToRead);
- m_lReadPos += nToRead;
- nOffset += nToRead;
- nAvailable -= nToRead;
- nRemainingBytes -= nToRead;
- }
- notifyAll();
- }
- if (TDebug.TraceCircularBuffer)
- {
- TDebug.out("After read:");
- dumpInternalState();
- TDebug.out("< completed. Read " + nLength + " bytes");
- }
- return nLength;
- }
- }
-
-
- public int write(byte[] abData)
- {
- return write(abData, 0, abData.length);
- }
-
-
-
- public int write(byte[] abData, int nOffset, int nLength)
- {
- if (TDebug.TraceCircularBuffer)
- {
- TDebug.out(">TCircularBuffer.write(): called; nLength: " + nLength);
- dumpInternalState();
- }
- synchronized (this)
- {
- if (TDebug.TraceCircularBuffer) { TDebug.out("entered synchronized block."); }
- if (!m_bBlockingWrite)
- {
- nLength = Math.min(availableWrite(), nLength);
- }
- int nRemainingBytes = nLength;
- while (nRemainingBytes > 0)
- {
- while (availableWrite() == 0)
- {
- try
- {
- wait();
- }
- catch (InterruptedException e)
- {
- if (TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- }
- }
- int nAvailable = Math.min(availableWrite(), nRemainingBytes);
- while (nAvailable > 0)
- {
- int nToWrite = Math.min(nAvailable, m_nSize - getWritePos());
- //TDebug.out("src buf size= " + abData.length + ", offset = " + nOffset + ", dst buf size=" + m_abData.length + " write pos=" + getWritePos() + " len=" + nToWrite);
- System.arraycopy(abData, nOffset, m_abData, getWritePos(), nToWrite);
- m_lWritePos += nToWrite;
- nOffset += nToWrite;
- nAvailable -= nToWrite;
- nRemainingBytes -= nToWrite;
- }
- notifyAll();
- }
- if (TDebug.TraceCircularBuffer)
- {
- TDebug.out("After write:");
- dumpInternalState();
- TDebug.out("< completed. Wrote "+nLength+" bytes");
- }
- return nLength;
- }
- }
-
-
-
- private void dumpInternalState()
- {
- TDebug.out("m_lReadPos = " + m_lReadPos + " ^= "+getReadPos());
- TDebug.out("m_lWritePos = " + m_lWritePos + " ^= "+getWritePos());
- TDebug.out("availableRead() = " + availableRead());
- TDebug.out("availableWrite() = " + availableWrite());
- }
-
-
-
- public static interface Trigger
- {
- public void execute();
- }
-
-
-}
-
-
-
-/*** TCircularBuffer.java ***/
-
diff --git a/songdbj/org/tritonus/share/TDebug.java b/songdbj/org/tritonus/share/TDebug.java
deleted file mode 100644
index 5969d91a72..0000000000
--- a/songdbj/org/tritonus/share/TDebug.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * TDebug.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2002 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share;
-
-import java.io.PrintStream;
-import java.util.StringTokenizer;
-import java.security.AccessControlException;
-
-
-
-public class TDebug
-{
- public static boolean SHOW_ACCESS_CONTROL_EXCEPTIONS = false;
- private static final String PROPERTY_PREFIX = "tritonus.";
- // The stream we output to
- public static PrintStream m_printStream = System.out;
-
- private static String indent="";
-
- // meta-general
- public static boolean TraceAllExceptions = getBooleanProperty("TraceAllExceptions");
- public static boolean TraceAllWarnings = getBooleanProperty("TraceAllWarnings");
-
- // general
- public static boolean TraceInit = getBooleanProperty("TraceInit");
- public static boolean TraceCircularBuffer = getBooleanProperty("TraceCircularBuffer");
- public static boolean TraceService = getBooleanProperty("TraceService");
-
- // sampled common implementation
- public static boolean TraceAudioSystem = getBooleanProperty("TraceAudioSystem");
- public static boolean TraceAudioConfig = getBooleanProperty("TraceAudioConfig");
- public static boolean TraceAudioInputStream = getBooleanProperty("TraceAudioInputStream");
- public static boolean TraceMixerProvider = getBooleanProperty("TraceMixerProvider");
- public static boolean TraceControl = getBooleanProperty("TraceControl");
- public static boolean TraceLine = getBooleanProperty("TraceLine");
- public static boolean TraceDataLine = getBooleanProperty("TraceDataLine");
- public static boolean TraceMixer = getBooleanProperty("TraceMixer");
- public static boolean TraceSourceDataLine = getBooleanProperty("TraceSourceDataLine");
- public static boolean TraceTargetDataLine = getBooleanProperty("TraceTargetDataLine");
- public static boolean TraceClip = getBooleanProperty("TraceClip");
- public static boolean TraceAudioFileReader = getBooleanProperty("TraceAudioFileReader");
- public static boolean TraceAudioFileWriter = getBooleanProperty("TraceAudioFileWriter");
- public static boolean TraceAudioConverter = getBooleanProperty("TraceAudioConverter");
- public static boolean TraceAudioOutputStream = getBooleanProperty("TraceAudioOutputStream");
-
- // sampled specific implementation
- public static boolean TraceEsdNative = getBooleanProperty("TraceEsdNative");
- public static boolean TraceEsdStreamNative = getBooleanProperty("TraceEsdStreamNative");
- public static boolean TraceEsdRecordingStreamNative = getBooleanProperty("TraceEsdRecordingStreamNative");
- public static boolean TraceAlsaNative = getBooleanProperty("TraceAlsaNative");
- public static boolean TraceAlsaMixerNative = getBooleanProperty("TraceAlsaMixerNative");
- public static boolean TraceAlsaPcmNative = getBooleanProperty("TraceAlsaPcmNative");
- public static boolean TraceMixingAudioInputStream = getBooleanProperty("TraceMixingAudioInputStream");
- public static boolean TraceOggNative = getBooleanProperty("TraceOggNative");
- public static boolean TraceVorbisNative = getBooleanProperty("TraceVorbisNative");
-
- // midi common implementation
- public static boolean TraceMidiSystem = getBooleanProperty("TraceMidiSystem");
- public static boolean TraceMidiConfig = getBooleanProperty("TraceMidiConfig");
- public static boolean TraceMidiDeviceProvider = getBooleanProperty("TraceMidiDeviceProvider");
- public static boolean TraceSequencer = getBooleanProperty("TraceSequencer");
- public static boolean TraceMidiDevice = getBooleanProperty("TraceMidiDevice");
-
- // midi specific implementation
- public static boolean TraceAlsaSeq = getBooleanProperty("TraceAlsaSeq");
- public static boolean TraceAlsaSeqDetails = getBooleanProperty("TraceAlsaSeqDetails");
- public static boolean TraceAlsaSeqNative = getBooleanProperty("TraceAlsaSeqNative");
- public static boolean TracePortScan = getBooleanProperty("TracePortScan");
- public static boolean TraceAlsaMidiIn = getBooleanProperty("TraceAlsaMidiIn");
- public static boolean TraceAlsaMidiOut = getBooleanProperty("TraceAlsaMidiOut");
- public static boolean TraceAlsaMidiChannel = getBooleanProperty("TraceAlsaMidiChannel");
-
- // misc
- public static boolean TraceAlsaCtlNative = getBooleanProperty("TraceAlsaCtlNative");
- public static boolean TraceCdda = getBooleanProperty("TraceCdda");
- public static boolean TraceCddaNative = getBooleanProperty("TraceCddaNative");
-
-
-
- // make this method configurable to write to file, write to stderr,...
- public static void out(String strMessage)
- {
- if (strMessage.length()>0 && strMessage.charAt(0)=='<') {
- if (indent.length()>2) {
- indent=indent.substring(2);
- } else {
- indent="";
- }
- }
- String newMsg=null;
- if (indent!="" && strMessage.indexOf("\n")>=0) {
- newMsg="";
- StringTokenizer tokenizer=new StringTokenizer(strMessage, "\n");
- while (tokenizer.hasMoreTokens()) {
- newMsg+=indent+tokenizer.nextToken()+"\n";
- }
- } else {
- newMsg=indent+strMessage;
- }
- m_printStream.println(newMsg);
- if (strMessage.length()>0 && strMessage.charAt(0)=='>') {
- indent+=" ";
- }
- }
-
-
-
- public static void out(Throwable throwable)
- {
- throwable.printStackTrace(m_printStream);
- }
-
-
-
- public static void assertion(boolean bAssertion)
- {
- if (!bAssertion)
- {
- throw new AssertException();
- }
- }
-
-
- public static class AssertException
- extends RuntimeException
- {
- public AssertException()
- {
- }
-
-
-
- public AssertException(String sMessage)
- {
- super(sMessage);
- }
- }
-
-
-
- private static boolean getBooleanProperty(String strName)
- {
- String strPropertyName = PROPERTY_PREFIX + strName;
- String strValue = "false";
- try
- {
- strValue = System.getProperty(strPropertyName, "false");
- }
- catch (AccessControlException e)
- {
- if (SHOW_ACCESS_CONTROL_EXCEPTIONS)
- {
- out(e);
- }
- }
- // TDebug.out("property: " + strPropertyName + "=" + strValue);
- boolean bValue = strValue.toLowerCase().equals("true");
- // TDebug.out("bValue: " + bValue);
- return bValue;
- }
-}
-
-
-
-/*** TDebug.java ***/
-
diff --git a/songdbj/org/tritonus/share/TNotifier.java b/songdbj/org/tritonus/share/TNotifier.java
deleted file mode 100644
index 822b30c305..0000000000
--- a/songdbj/org/tritonus/share/TNotifier.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * TNotifier.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share;
-
-import java.util.EventObject;
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
-
-import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineEvent;
-
-
-
-public class TNotifier
-extends Thread
-{
- public static class NotifyEntry
- {
- private EventObject m_event;
- private List<LineListener> m_listeners;
-
-
-
- public NotifyEntry(EventObject event, Collection<LineListener> listeners)
- {
- m_event = event;
- m_listeners = new ArrayList<LineListener>(listeners);
- }
-
-
- public void deliver()
- {
- // TDebug.out("%% TNotifier.NotifyEntry.deliver(): called.");
- Iterator<LineListener> iterator = m_listeners.iterator();
- while (iterator.hasNext())
- {
- LineListener listener = iterator.next();
- listener.update((LineEvent) m_event);
- }
- }
- }
-
-
- public static TNotifier notifier = null;
-
- static
- {
- notifier = new TNotifier();
- notifier.setDaemon(true);
- notifier.start();
- }
-
-
-
- /** The queue of events to deliver.
- * The entries are of class NotifyEntry.
- */
- private List<NotifyEntry> m_entries;
-
-
- public TNotifier()
- {
- super("Tritonus Notifier");
- m_entries = new ArrayList<NotifyEntry>();
- }
-
-
-
- public void addEntry(EventObject event, Collection<LineListener> listeners)
- {
- // TDebug.out("%% TNotifier.addEntry(): called.");
- synchronized (m_entries)
- {
- m_entries.add(new NotifyEntry(event, listeners));
- m_entries.notifyAll();
- }
- // TDebug.out("%% TNotifier.addEntry(): completed.");
- }
-
-
- public void run()
- {
- while (true)
- {
- NotifyEntry entry = null;
- synchronized (m_entries)
- {
- while (m_entries.size() == 0)
- {
- try
- {
- m_entries.wait();
- }
- catch (InterruptedException e)
- {
- if (TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- }
- }
- entry = m_entries.remove(0);
- }
- entry.deliver();
- }
- }
-}
-
-
-/*** TNotifier.java ***/
diff --git a/songdbj/org/tritonus/share/TSettings.java b/songdbj/org/tritonus/share/TSettings.java
deleted file mode 100644
index ae1a315e0e..0000000000
--- a/songdbj/org/tritonus/share/TSettings.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * TSettings.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share;
-
-import java.io.PrintStream;
-import java.util.StringTokenizer;
-import java.security.AccessControlException;
-
-import org.tritonus.share.TDebug;
-
-
-public class TSettings
-{
- public static boolean SHOW_ACCESS_CONTROL_EXCEPTIONS = false;
- private static final String PROPERTY_PREFIX = "tritonus.";
-
-
- public static boolean AlsaUsePlughw = getBooleanProperty("AlsaUsePlughw");
-
-
-
- private static boolean getBooleanProperty(String strName)
- {
- String strPropertyName = PROPERTY_PREFIX + strName;
- String strValue = "false";
- try
- {
- strValue = System.getProperty(strPropertyName, "false");
- }
- catch (AccessControlException e)
- {
- if (SHOW_ACCESS_CONTROL_EXCEPTIONS)
- {
- TDebug.out(e);
- }
- }
- // TDebug.out("property: " + strPropertyName + "=" + strValue);
- boolean bValue = strValue.toLowerCase().equals("true");
- // TDebug.out("bValue: " + bValue);
- return bValue;
- }
-}
-
-
-
-/*** TSettings.java ***/
-
diff --git a/songdbj/org/tritonus/share/package.html b/songdbj/org/tritonus/share/package.html
deleted file mode 100644
index 200904dc60..0000000000
--- a/songdbj/org/tritonus/share/package.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Misc helper classes.
- The classes provided here .</p>
- </body>
-</html>
diff --git a/songdbj/org/tritonus/share/sampled/AudioFileTypes.java b/songdbj/org/tritonus/share/sampled/AudioFileTypes.java
deleted file mode 100644
index 45e4a0ffbc..0000000000
--- a/songdbj/org/tritonus/share/sampled/AudioFileTypes.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * AudioFileTypes.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-
-package org.tritonus.share.sampled;
-
-import javax.sound.sampled.AudioFileFormat;
-import org.tritonus.share.StringHashedSet;
-import org.tritonus.share.TDebug;
-
-/**
- * This class is a proposal for generic handling of audio file format types.
- * The main purpose is to provide a standardized way of
- * implementing audio file format types. Like this, file types
- * are only identified by their String name, and not, as currently,
- * by their object instance.
- * <p>
- * A standard registry of file type names will
- * be maintained by the Tritonus team.
- * <p>
- * In a specification request to JavaSoft, these static methods
- * could be integrated into<code>AudioFileFormat.Type</code>. The static
- * instances of AIFF, AIFC, AU, SND, and WAVE types in class
- * <code>AudioFileFormat.Type</code> should be retrieved
- * using this method, too (internally).<br>
- * At best, the protected constructor of that class
- * should also be replaced to be a private constructor.
- * Like this it will be prevented that developers create
- * instances of Type, which causes problems with the
- * equals method. In fact, the equals method should be redefined anyway
- * so that it compares the names and not the objects.
- * <p>
- * Also, the file name extension should be deprecated and moved
- * to <code>AudioFileFormat</code>. There are some file formats
- * which have varying extensions depending, e.g. on the encoding.
- * An example for this is MPEG: the special encoding Mpeg 1, layer 3
- * has the extension mp3, whereas other Mpeg files use mpeg or mpg.<br>
- * This could be implemented with 2 methods in <code>AudioFileFormat</code>:
- * <ol><li>String[] getFileExtensions(): returns all usable extensions
- * for this file.
- * <li>String getDefaultFileExtension(): returns the preferred extension.
- * </ol>
- *
- * @author Florian Bomers
- */
-public class AudioFileTypes extends AudioFileFormat.Type {
-
- /** contains all known types */
- private static StringHashedSet types = new StringHashedSet();
-
- // initially add the standard types
- static {
- types.add(AudioFileFormat.Type.AIFF);
- types.add(AudioFileFormat.Type.AIFC);
- types.add(AudioFileFormat.Type.AU);
- types.add(AudioFileFormat.Type.SND);
- types.add(AudioFileFormat.Type.WAVE);
- }
-
- AudioFileTypes(String name, String ext) {
- super(name, ext);
- }
-
- /**
- * Use this method to retrieve an instance of
- * <code>AudioFileFormat.Type</code> of the specified
- * name. If no type of this name is in the internally
- * maintained list, <code>null</code> is returned.
- * <p>
- * This method is supposed to be used by user programs.
- * <p>
- * In order to assure a well-filled internal list,
- * call <code>AudioSystem.getAudioFileTypes()</code>
- * at initialization time.
- *
- * @see #getType(String, String)
- */
- public static AudioFileFormat.Type getType(String name) {
- return getType(name, null);
- }
-
- /**
- * Use this method to retrieve an instance of
- * <code>AudioFileFormat.Type</code> of the specified
- * name. If it does not exist in the internal list
- * of types, a new type is created and returned.
- * If it a type of that name already exists (regardless
- * of extension), it is returned. In this case it can
- * not be guaranteed that the extension is the same as
- * passed as parameter.<br>
- * If <code>extension</code> is <code>null</code>,
- * this method returns <code>null</code> if the
- * type of the specified name does not exist in the
- * internal list.
- * <p>
- * This method is supposed to be used by file providers.
- * Every file reader and file writer provider should
- * exclusively use this method for retrieving instances
- * of <code>AudioFileFormat.Type</code>.
- */
- public static AudioFileFormat.Type getType(String name, String extension) {
- AudioFileFormat.Type res=(AudioFileFormat.Type) types.get(name);
- if (res==null) {
- // it is not already in the string set.
- if (extension==null) {
- return null;
- }
- // Create a new type instance.
- res=new AudioFileTypes(name, extension);
- // and save it for the future
- types.add(res);
- }
- return res;
- }
-
- /**
- * Tests for equality of 2 file types. They are equal when their names match.
- * <p>
- * This function should be AudioFileFormat.Type.equals and must
- * be considered as a temporary workaround until it flows into the
- * JavaSound API.
- */
- // IDEA: create a special "NOT_SPECIFIED" file type
- // and a AudioFileFormat.Type.matches method.
- public static boolean equals(AudioFileFormat.Type t1, AudioFileFormat.Type t2) {
- return t2.toString().equals(t1.toString());
- }
-
-}
-
-/*** AudioFileTypes.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/AudioFormatSet.java b/songdbj/org/tritonus/share/sampled/AudioFormatSet.java
deleted file mode 100644
index 8d89541d77..0000000000
--- a/songdbj/org/tritonus/share/sampled/AudioFormatSet.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * AudioFormatSet.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.ArraySet;
-import org.tritonus.share.sampled.AudioFormats;
-
-
-/**
- * A set where the elements are uniquely referenced by
- * AudioFormats.equals rather than their object reference.
- * No 2 equal AudioFormats can exist in the set.
- * <p>
- * This class provide convenience methods like
- * <code>getAudioFormat(AudioFormat)</code> and
- * <code>matches(AudioFormat)</code>.
- * <p>
- * The <code>contains(Object elem)</code> and <code>get(Object elem)</code>
- * fail, if elem is not an instance of AudioFormat.
- * <p>
- * You shouldn't use the ArrayList specific functions
- * like those that take index parameters.
- * <p>
- * It is not possible to add <code>null</code> elements.
- * <p>
- * Currently, the methods equals(.,.) and matches(.,.) of
- * class AudioFormats are used. Let's hope that they will
- * be integrated into AudioFormat.
- */
-
-public class AudioFormatSet extends ArraySet<AudioFormat>
-{
- protected static final AudioFormat[] EMPTY_FORMAT_ARRAY = new AudioFormat[0];
-
- public AudioFormatSet() {
- super();
- }
-
- public AudioFormatSet(Collection<AudioFormat> c) {
- super(c);
- }
-
- public boolean add(AudioFormat elem) {
- if (elem==null || !(elem instanceof AudioFormat)) {
- return false;
- }
- return super.add(elem);
- }
-
- public boolean contains(AudioFormat elem) {
- if (elem==null || !(elem instanceof AudioFormat)) {
- return false;
- }
- AudioFormat comp=(AudioFormat) elem;
- Iterator it=iterator();
- while (it.hasNext()) {
- if (AudioFormats.equals(comp, (AudioFormat) it.next())) {
- return true;
- }
- }
- return false;
- }
-
- public AudioFormat get(AudioFormat elem) {
- if (elem==null || !(elem instanceof AudioFormat)) {
- return null;
- }
- AudioFormat comp=(AudioFormat) elem;
- Iterator it=iterator();
- while (it.hasNext()) {
- AudioFormat thisElem=(AudioFormat) it.next();
- if (AudioFormats.equals(comp, thisElem)) {
- return thisElem;
- }
- }
- return null;
- }
-
- public AudioFormat getAudioFormat(AudioFormat elem) {
- return (AudioFormat) get(elem);
- }
-
- /**
- * Checks whether this Set contains an AudioFormat
- * that matches <code>elem</code>.
- * The first matching format is returned. If no element
- * matches <code>elem</code>, <code>null</code> is returned.
- * <p>
- * @see AudioFormats#matches(AudioFormat, AudioFormat)
- */
- public AudioFormat matches(AudioFormat elem) {
- if (elem==null) {
- return null;
- }
- Iterator it=iterator();
- while (it.hasNext()) {
- AudioFormat thisElem=(AudioFormat) it.next();
- if (AudioFormats.matches(elem, thisElem)) {
- return thisElem;
- }
- }
- return null;
- }
-
-
- // $$mp: TODO: remove; should be obsolete
- public AudioFormat[] toAudioFormatArray() {
- return (AudioFormat[]) toArray(EMPTY_FORMAT_ARRAY);
- }
-
-
- public void add(int index, AudioFormat element) {
- throw new UnsupportedOperationException("unsupported");
- }
-
- public AudioFormat set(int index, AudioFormat element) {
- throw new UnsupportedOperationException("unsupported");
- }
-}
-
-/*** AudioFormatSet.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/AudioFormats.java b/songdbj/org/tritonus/share/sampled/AudioFormats.java
deleted file mode 100644
index 41ac3f37c7..0000000000
--- a/songdbj/org/tritonus/share/sampled/AudioFormats.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * AudioFormats.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999,2000 by Matthias Pfisterer
- * Copyright (c) 1999 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-
-
-
-public class AudioFormats
-{
- private static boolean doMatch(int i1, int i2)
- {
- return i1 == AudioSystem.NOT_SPECIFIED
- || i2 == AudioSystem.NOT_SPECIFIED
- || i1 == i2;
- }
-
-
-
- private static boolean doMatch(float f1, float f2)
- {
- return f1 == AudioSystem.NOT_SPECIFIED
- || f2 == AudioSystem.NOT_SPECIFIED
- || Math.abs(f1 - f2) < 1.0e-9;
- }
-
-
-
- /**
- * Tests whether 2 AudioFormats have matching formats.
- * A field matches when it is AudioSystem.NOT_SPECIFIED in
- * at least one of the formats or the field is the same
- * in both formats.<br>
- * Exceptions:
- * <ul>
- * <li>Encoding must always be equal for a match.
- * <li> For a match, endianness must be equal if SampleSizeInBits is not
- * AudioSystem.NOT_SPECIFIED and greater than 8bit in both formats.<br>
- * In other words: If SampleSizeInBits is AudioSystem.NOT_SPECIFIED
- * in either format or both formats have a SampleSizeInBits<8,
- * endianness does not matter.
- * </ul>
- * This is a proposition to be used as AudioFormat.matches.
- * It can therefore be considered as a temporary workaround.
- */
- // IDEA: create a special "NOT_SPECIFIED" encoding
- // and a AudioFormat.Encoding.matches method.
- public static boolean matches(AudioFormat format1,
- AudioFormat format2)
- {
- //$$fb 19 Dec 99: endian must be checked, too.
- //
- // we do have a problem with redundant elements:
- // e.g.
- // encoding=ALAW || ULAW -> bigEndian and samplesizeinbits don't matter
- // sample size in bits == 8 -> bigEndian doesn't matter
- // sample size in bits > 8 -> PCM is always signed.
- // This is an overall issue in JavaSound, I think.
- // At present, it is not consistently implemented to support these
- // redundancies and implicit definitions
- //
- // As a workaround of this issue I return in the converters
- // all combinations, e.g. for ULAW I return bigEndian and !bigEndian formats.
-/* old version
-*/
- // as proposed by florian
- return format1.getEncoding().equals(format2.getEncoding())
- && (format2.getSampleSizeInBits()<=8
- || format1.getSampleSizeInBits()==AudioSystem.NOT_SPECIFIED
- || format2.getSampleSizeInBits()==AudioSystem.NOT_SPECIFIED
- || format1.isBigEndian()==format2.isBigEndian())
- && doMatch(format1.getChannels(),format2.getChannels())
- && doMatch(format1.getSampleSizeInBits(), format2.getSampleSizeInBits())
- && doMatch(format1.getFrameSize(), format2.getFrameSize())
- && doMatch(format1.getSampleRate(), format2.getSampleRate())
- && doMatch(format1.getFrameRate(),format2.getFrameRate());
- }
-
- /**
- * Tests for exact equality of 2 AudioFormats.
- * This is the behaviour of AudioFormat.matches in JavaSound 1.0.
- * <p>
- * This is a proposition to be used as AudioFormat.equals.
- * It can therefore be considered as a temporary workaround.
- */
- public static boolean equals(AudioFormat format1,
- AudioFormat format2)
- {
- return format1.getEncoding().equals(format2.getEncoding())
- && format1.getChannels() == format2.getChannels()
- && format1.getSampleSizeInBits() == format2.getSampleSizeInBits()
- && format1.getFrameSize() == format2.getFrameSize()
- && (Math.abs(format1.getSampleRate() - format2.getSampleRate()) < 1.0e-9)
- && (Math.abs(format1.getFrameRate() - format2.getFrameRate()) < 1.0e-9);
- }
-
-}
-
-
-
-/*** AudioFormats.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/AudioSystemShadow.java b/songdbj/org/tritonus/share/sampled/AudioSystemShadow.java
deleted file mode 100644
index 70b4e9ebd7..0000000000
--- a/songdbj/org/tritonus/share/sampled/AudioSystemShadow.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * AudioSystemShadow.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999, 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-import java.io.File;
-import java.io.OutputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.sampled.file.AudioOutputStream;
-import org.tritonus.share.sampled.file.TDataOutputStream;
-import org.tritonus.share.sampled.file.TSeekableDataOutputStream;
-import org.tritonus.share.sampled.file.TNonSeekableDataOutputStream;
-import org.tritonus.sampled.file.AiffAudioOutputStream;
-import org.tritonus.sampled.file.AuAudioOutputStream;
-import org.tritonus.sampled.file.WaveAudioOutputStream;
-
-
-
-/** Experminatal area for AudioSystem.
- * This class is used to host features that may become part of the
- * Java Sound API (In which case they will be moved to AudioSystem).
- */
-public class AudioSystemShadow
-{
- public static TDataOutputStream getDataOutputStream(File file)
- throws IOException
- {
- return new TSeekableDataOutputStream(file);
- }
-
-
-
- public static TDataOutputStream getDataOutputStream(OutputStream stream)
- throws IOException
- {
- return new TNonSeekableDataOutputStream(stream);
- }
-
-
-
- // TODO: lLengthInBytes actually should be lLengthInFrames (design problem of A.O.S.)
- public static AudioOutputStream getAudioOutputStream(AudioFileFormat.Type type, AudioFormat audioFormat, long lLengthInBytes, TDataOutputStream dataOutputStream)
- {
- AudioOutputStream audioOutputStream = null;
-
- if (type.equals(AudioFileFormat.Type.AIFF) ||
- type.equals(AudioFileFormat.Type.AIFF))
- {
- audioOutputStream = new AiffAudioOutputStream(audioFormat, type, lLengthInBytes, dataOutputStream);
- }
- else if (type.equals(AudioFileFormat.Type.AU))
- {
- audioOutputStream = new AuAudioOutputStream(audioFormat, lLengthInBytes, dataOutputStream);
- }
- else if (type.equals(AudioFileFormat.Type.WAVE))
- {
- audioOutputStream = new WaveAudioOutputStream(audioFormat, lLengthInBytes, dataOutputStream);
- }
- return audioOutputStream;
- }
-
-
-
- public static AudioOutputStream getAudioOutputStream(AudioFileFormat.Type type, AudioFormat audioFormat, long lLengthInBytes, File file)
- throws IOException
- {
- TDataOutputStream dataOutputStream = getDataOutputStream(file);
- AudioOutputStream audioOutputStream = getAudioOutputStream(type, audioFormat, lLengthInBytes, dataOutputStream);
- return audioOutputStream;
- }
-
-
-
- public static AudioOutputStream getAudioOutputStream(AudioFileFormat.Type type, AudioFormat audioFormat, long lLengthInBytes, OutputStream outputStream)
- throws IOException
- {
- TDataOutputStream dataOutputStream = getDataOutputStream(outputStream);
- AudioOutputStream audioOutputStream = getAudioOutputStream(type, audioFormat, lLengthInBytes, dataOutputStream);
- return audioOutputStream;
- }
-}
-
-
-/*** AudioSystemShadow.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/AudioUtils.java b/songdbj/org/tritonus/share/sampled/AudioUtils.java
deleted file mode 100644
index 21c838b032..0000000000
--- a/songdbj/org/tritonus/share/sampled/AudioUtils.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * AudioUtils.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.spi.AudioFileWriter;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.TConversionTool;
-
-
-
-public class AudioUtils
-{
- public static long getLengthInBytes(AudioInputStream audioInputStream)
- {
- return getLengthInBytes(audioInputStream.getFormat(),
- audioInputStream.getFrameLength());
-/*
- long lLengthInFrames = audioInputStream.getFrameLength();
- int nFrameSize = audioInputStream.getFormat().getFrameSize();
- if (lLengthInFrames >= 0 && nFrameSize >= 1)
- {
- return lLengthInFrames * nFrameSize;
- }
- else
- {
- return AudioSystem.NOT_SPECIFIED;
- }
-*/
- }
-
-
-
- /**
- * if the passed value for lLength is
- * AudioSystem.NOT_SPECIFIED (unknown
- * length), the length in bytes becomes
- * AudioSystem.NOT_SPECIFIED, too.
- */
- public static long getLengthInBytes(AudioFormat audioFormat,
- long lLengthInFrames)
- {
- int nFrameSize = audioFormat.getFrameSize();
- if (lLengthInFrames >= 0 && nFrameSize >= 1)
- {
- return lLengthInFrames * nFrameSize;
- }
- else
- {
- return AudioSystem.NOT_SPECIFIED;
- }
- }
-
-
-
- public static boolean containsFormat(AudioFormat sourceFormat,
- Iterator possibleFormats)
- {
- while (possibleFormats.hasNext())
- {
- AudioFormat format = (AudioFormat) possibleFormats.next();
- if (AudioFormats.matches(format, sourceFormat))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Conversion milliseconds -> bytes
- */
-
- public static long millis2Bytes(long ms, AudioFormat format) {
- return millis2Bytes(ms, format.getFrameRate(), format.getFrameSize());
- }
-
- public static long millis2Bytes(long ms, float frameRate, int frameSize) {
- return (long) (ms*frameRate/1000*frameSize);
- }
-
- /**
- * Conversion milliseconds -> bytes (bytes will be frame-aligned)
- */
- public static long millis2BytesFrameAligned(long ms, AudioFormat format) {
- return millis2BytesFrameAligned(ms, format.getFrameRate(), format.getFrameSize());
- }
-
- public static long millis2BytesFrameAligned(long ms, float frameRate, int frameSize) {
- return ((long) (ms*frameRate/1000))*frameSize;
- }
-
- /**
- * Conversion milliseconds -> frames
- */
- public static long millis2Frames(long ms, AudioFormat format) {
- return millis2Frames(ms, format.getFrameRate());
- }
-
- public static long millis2Frames(long ms, float frameRate) {
- return (long) (ms*frameRate/1000);
- }
-
- /**
- * Conversion bytes -> milliseconds
- */
- public static long bytes2Millis(long bytes, AudioFormat format) {
- return (long) (bytes/format.getFrameRate()*1000/format.getFrameSize());
- }
-
- /**
- * Conversion frames -> milliseconds
- */
- public static long frames2Millis(long frames, AudioFormat format) {
- return (long) (frames/format.getFrameRate()*1000);
- }
-
-
- //$$fb 2000-07-18: added these debugging functions
- public static String NS_or_number(int number) {
- return (number==AudioSystem.NOT_SPECIFIED)?"NOT_SPECIFIED":String.valueOf(number);
- }
- public static String NS_or_number(float number) {
- return (number==AudioSystem.NOT_SPECIFIED)?"NOT_SPECIFIED":String.valueOf(number);
- }
-
- /**
- * For debugging purposes.
- */
- public static String format2ShortStr(AudioFormat format) {
- return format.getEncoding() + "-" +
- NS_or_number(format.getChannels()) + "ch-" +
- NS_or_number(format.getSampleSizeInBits()) + "bit-" +
- NS_or_number(((int)format.getSampleRate())) + "Hz-"+
- (format.isBigEndian() ? "be" : "le");
- }
-
-}
-
-
-
-/*** AudioUtils.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/Encodings.java b/songdbj/org/tritonus/share/sampled/Encodings.java
deleted file mode 100644
index 6b880d24d9..0000000000
--- a/songdbj/org/tritonus/share/sampled/Encodings.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Encodings.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-
-package org.tritonus.share.sampled;
-
-import java.util.Iterator;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import org.tritonus.share.StringHashedSet;
-import org.tritonus.share.TDebug;
-
-/**
- * This class is a proposal for generic handling of encodings.
- * The main purpose is to provide a standardized way of
- * implementing encoding types. Like this, encodings
- * are only identified by their String name, and not, as currently,
- * by their object instance.
- * <p>
- * A registry of standard encoding names will
- * be maintained by the Tritonus team.
- * <p>
- * In a specification request to JavaSoft, the static method
- * <code>getEncoding</code> should be integrated into
- * <code>AudioFormat.Encoding(String name)</code> (possibly
- * renamed to <code>getInstance(String name)</code>.<br>
- * The static instances of ULAW, ALAW PCM_UNSIGNED and PCM_SIGNED
- * encodings in that class should be retrieved using that function,
- * too (internally).<br>
- * At best, the protected constructor of that class
- * should also be replaced to be a private constructor.
- * Like this it will be prevented that developers create their own
- * instances of Encoding, which causes problems with the
- * equals method. In fact, the equals method should be redefined anyway
- * so that it compares the names and not the objects.
- * <p>
- * Also, a specification request should be made to integrate
- * <code>getEncodings()</code> into AudioSystem (this is
- * especially annoying as the relevant methods already exist
- * in the provider interfaces of file readers, file writers and
- * converters).
- *
- * @author Florian Bomers
- */
-public class Encodings extends AudioFormat.Encoding {
-
- /** contains all known encodings */
- private static StringHashedSet encodings = new StringHashedSet();
-
- // initially add the standard encodings
- static {
- encodings.add(AudioFormat.Encoding.PCM_SIGNED);
- encodings.add(AudioFormat.Encoding.PCM_UNSIGNED);
- encodings.add(AudioFormat.Encoding.ULAW);
- encodings.add(AudioFormat.Encoding.ALAW);
- }
-
- Encodings(String name) {
- super(name);
- }
-
- /**
- * Use this method for retrieving an instance of
- * <code>AudioFormat.Encoding</code> of the specified
- * name. A standard registry of encoding names will
- * be maintained by the Tritonus team.
- * <p>
- * Every file reader, file writer, and format converter
- * provider should exclusively use this method for
- * retrieving instances of <code>AudioFormat.Encoding</code>.
- */
- /*
- MP2000/09/11:
- perhaps it is not a good idea to allow user programs the creation of new
- encodings. The problem with it is that a plain typo will produce an encoding
- object that is not supported. Instead, some indication of an error should be
- signaled to the user program. And, there should be a second interface for
- service providers allowing them to register encodings supported by themselves.
-
- $$fb2000/09/26:
- The problem is what you see as second issue: it can never be assured
- that this class knows all available encodings. So at the moment, there
- is no choice than to allow users to create any Encoding they wish.
- The encodings database will simplify things.
- A problem with an interface to retrieve supported encodings (or API
- function in spi.FormatConversionProvider) is that this requires
- loading of all providers very early. Hmmm, maybe this is necessary in any
- case when the user issues something like AudioSystem.isConversionSupported.
- */
- public static AudioFormat.Encoding getEncoding(String name) {
- AudioFormat.Encoding res=(AudioFormat.Encoding) encodings.get(name);
- if (res==null) {
- // it is not already in the string set. Create a new encoding instance.
- res=new Encodings(name);
- // and save it for the future
- encodings.add(res);
- }
- return res;
- }
-
- /**
- * Tests for equality of 2 encodings. They are equal when their strings match.
- * <p>
- * This function should be AudioFormat.Encoding.equals and must
- * be considered as a temporary work around until it flows into the
- * JavaSound API.
- */
- // IDEA: create a special "NOT_SPECIFIED" encoding
- // and a AudioFormat.Encoding.matches method.
- public static boolean equals(AudioFormat.Encoding e1, AudioFormat.Encoding e2) {
- return e2.toString().equals(e1.toString());
- }
-
-
- /**
- * Returns all &quot;supported&quot; encodings.
- * Supported means that it is possible to read or
- * write files with this encoding, or that a converter
- * accepts this encoding as source or target format.
- * <p>
- * Currently, this method returns a best guess and
- * the search algorithm is far from complete: with standard
- * methods of AudioSystem, only the target encodings
- * of the converters can be retrieved - neither
- * the source encodings of converters nor the encodings
- * of file readers and file writers cannot be retrieved.
- */
- public static AudioFormat.Encoding[] getEncodings() {
- StringHashedSet iteratedSources=new StringHashedSet();
- StringHashedSet retrievedTargets=new StringHashedSet();
- Iterator sourceFormats=encodings.iterator();
- while (sourceFormats.hasNext()) {
- AudioFormat.Encoding source=(AudioFormat.Encoding) sourceFormats.next();
- iterateEncodings(source, iteratedSources, retrievedTargets);
- }
- return (AudioFormat.Encoding[]) retrievedTargets.toArray(
- new AudioFormat.Encoding[retrievedTargets.size()]);
- }
-
-
- private static void iterateEncodings(AudioFormat.Encoding source,
- StringHashedSet iteratedSources,
- StringHashedSet retrievedTargets) {
- if (!iteratedSources.contains(source)) {
- iteratedSources.add(source);
- AudioFormat.Encoding[] targets=AudioSystem.getTargetEncodings(source);
- for (int i=0; i<targets.length; i++) {
- AudioFormat.Encoding target=targets[i];
- if (retrievedTargets.add(target.toString())) {
- iterateEncodings(target, iteratedSources,retrievedTargets);
- }
- }
- }
- }
-}
-
-
-
-/*** Encodings.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/FloatSampleBuffer.java b/songdbj/org/tritonus/share/sampled/FloatSampleBuffer.java
deleted file mode 100644
index d1fe534613..0000000000
--- a/songdbj/org/tritonus/share/sampled/FloatSampleBuffer.java
+++ /dev/null
@@ -1,734 +0,0 @@
-/*
- * FloatSampleBuffer.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000,2004 by Florian Bomers <http://www.bomers.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Random;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.spi.AudioFileWriter;
-
-import org.tritonus.share.TDebug;
-
-/**
- * A class for small buffers of samples in linear, 32-bit
- * floating point format.
- * <p>
- * It is supposed to be a replacement of the byte[] stream
- * architecture of JavaSound, especially for chains of
- * AudioInputStreams. Ideally, all involved AudioInputStreams
- * handle reading into a FloatSampleBuffer.
- * <p>
- * Specifications:
- * <ol>
- * <li>Channels are separated, i.e. for stereo there are 2 float arrays
- * with the samples for the left and right channel
- * <li>All data is handled in samples, where one sample means
- * one float value in each channel
- * <li>All samples are normalized to the interval [-1.0...1.0]
- * </ol>
- * <p>
- * When a cascade of AudioInputStreams use FloatSampleBuffer for
- * processing, they may implement the interface FloatSampleInput.
- * This signals that this stream may provide float buffers
- * for reading. The data is <i>not</i> converted back to bytes,
- * but stays in a single buffer that is passed from stream to stream.
- * For that serves the read(FloatSampleBuffer) method, which is
- * then used as replacement for the byte-based read functions of
- * AudioInputStream.<br>
- * However, backwards compatibility must always be retained, so
- * even when an AudioInputStream implements FloatSampleInput,
- * it must work the same way when any of the byte-based read methods
- * is called.<br>
- * As an example, consider the following set-up:<br>
- * <ul>
- * <li>auAIS is an AudioInputStream (AIS) that reads from an AU file
- * in 8bit pcm at 8000Hz. It does not implement FloatSampleInput.
- * <li>pcmAIS1 is an AIS that reads from auAIS and converts the data
- * to PCM 16bit. This stream implements FloatSampleInput, i.e. it
- * can generate float audio data from the ulaw samples.
- * <li>pcmAIS2 reads from pcmAIS1 and adds a reverb.
- * It operates entirely on floating point samples.
- * <li>The method that reads from pcmAIS2 (i.e. AudioSystem.write) does
- * not handle floating point samples.
- * </ul>
- * So, what happens when a block of samples is read from pcmAIS2 ?
- * <ol>
- * <li>the read(byte[]) method of pcmAIS2 is called
- * <li>pcmAIS2 always operates on floating point samples, so
- * it uses an own instance of FloatSampleBuffer and initializes
- * it with the number of samples requested in the read(byte[])
- * method.
- * <li>It queries pcmAIS1 for the FloatSampleInput interface. As it
- * implements it, pcmAIS2 calls the read(FloatSampleBuffer) method
- * of pcmAIS1.
- * <li>pcmAIS1 notes that its underlying stream does not support floats,
- * so it instantiates a byte buffer which can hold the number of
- * samples of the FloatSampleBuffer passed to it. It calls the
- * read(byte[]) method of auAIS.
- * <li>auAIS fills the buffer with the bytes.
- * <li>pcmAIS1 calls the <code>initFromByteArray</code> method of
- * the float buffer to initialize it with the 8 bit data.
- * <li>Then pcmAIS1 processes the data: as the float buffer is
- * normalized, it does nothing with the buffer - and returns
- * control to pcmAIS2. The SampleSizeInBits field of the
- * AudioFormat of pcmAIS1 defines that it should be 16 bits.
- * <li>pcmAIS2 receives the filled buffer from pcmAIS1 and does
- * its processing on the buffer - it adds the reverb.
- * <li>As pcmAIS2's read(byte[]) method had been called, pcmAIS2
- * calls the <code>convertToByteArray</code> method of
- * the float buffer to fill the byte buffer with the
- * resulting samples.
- * </ol>
- * <p>
- * To summarize, here are some advantages when using a FloatSampleBuffer
- * for streaming:
- * <ul>
- * <li>no conversions from/to bytes need to be done during processing
- * <li>the sample size in bits is irrelevant - normalized range
- * <li>higher quality for processing
- * <li>separated channels (easy process/remove/add channels)
- * <li>potentially less copying of audio data, as processing
- * the float samples is generally done in-place. The same
- * instance of a FloatSampleBuffer may be used from the original data source
- * to the final data sink.
- * </ul>
- * <p>
- * Simple benchmarks showed that the processing requirements
- * for the conversion to and from float is about the same as
- * when converting it to shorts or ints without dithering,
- * and significantly higher with dithering. An own implementation
- * of a random number generator may improve this.
- * <p>
- * &quot;Lazy&quot; deletion of samples and channels:<br>
- * <ul>
- * <li>When the sample count is reduced, the arrays are not resized, but
- * only the member variable <code>sampleCount</code> is reduced. A subsequent
- * increase of the sample count (which will occur frequently), will check
- * that and eventually reuse the existing array.
- * <li>When a channel is deleted, it is not removed from memory but only
- * hidden. Subsequent insertions of a channel will check whether a hidden channel
- * can be reused.
- * </ul>
- * The lazy mechanism can save many array instantiation (and copy-) operations
- * for the sake of performance. All relevant methods exist in a second
- * version which allows explicitely to disable lazy deletion.
- * <p>
- * Use the <code>reset</code> functions to clear the memory and remove
- * hidden samples and channels.
- * <p>
- * Note that the lazy mechanism implies that the arrays returned
- * from <code>getChannel(int)</code> may have a greater size
- * than getSampleCount(). Consequently, be sure to never rely on the
- * length field of the sample arrays.
- * <p>
- * As an example, consider a chain of converters that all act
- * on the same instance of FloatSampleBuffer. Some converters
- * may decrease the sample count (e.g. sample rate converter) and
- * delete channels (e.g. PCM2PCM converter). So, processing of one
- * block will decrease both. For the next block, all starts
- * from the beginning. With the lazy mechanism, all float arrays
- * are only created once for processing all blocks.<br>
- * Having lazy disabled would require for each chunk that is processed
- * <ol>
- * <li>new instantiation of all channel arrays
- * at the converter chain beginning as they have been
- * either deleted or decreased in size during processing of the
- * previous chunk, and
- * <li>re-instantiation of all channel arrays for
- * the reduction of the sample count.
- * </ol>
- * <p>
- * Dithering:<br>
- * By default, this class uses dithering for reduction
- * of sample width (e.g. original data was 16bit, target
- * data is 8bit). As dithering may be needed in other cases
- * (especially when the float samples are processed using DSP
- * algorithms), or it is preferred to switch it off,
- * dithering can be explicitely switched on or off with
- * the method setDitherMode(int).<br>
- * For a discussion about dithering, see
- * <a href="http://www.iqsoft.com/IQSMagazine/BobsSoapbox/Dithering.htm">
- * here</a> and
- * <a href="http://www.iqsoft.com/IQSMagazine/BobsSoapbox/Dithering2.htm">
- * here</a>.
- *
- * @author Florian Bomers
- */
-
-public class FloatSampleBuffer {
-
- /** Whether the functions without lazy parameter are lazy or not. */
- private static final boolean LAZY_DEFAULT=true;
-
- private ArrayList<float[]> channels = new ArrayList<float[]>(); // contains for each channel a float array
- private int sampleCount=0;
- private int channelCount=0;
- private float sampleRate=0;
- private int originalFormatType=0;
-
- /** Constant for setDitherMode: dithering will be enabled if sample size is decreased */
- public static final int DITHER_MODE_AUTOMATIC=0;
- /** Constant for setDitherMode: dithering will be done */
- public static final int DITHER_MODE_ON=1;
- /** Constant for setDitherMode: dithering will not be done */
- public static final int DITHER_MODE_OFF=2;
-
- private float ditherBits = FloatSampleTools.DEFAULT_DITHER_BITS;
-
- // e.g. the sample rate converter may want to force dithering
- private int ditherMode = DITHER_MODE_AUTOMATIC;
-
- //////////////////////////////// initialization /////////////////////////////////
-
- /**
- * Create an instance with initially no channels.
- */
- public FloatSampleBuffer() {
- this(0,0,1);
- }
-
- /**
- * Create an empty FloatSampleBuffer with the specified number of channels,
- * samples, and the specified sample rate.
- */
- public FloatSampleBuffer(int channelCount, int sampleCount, float sampleRate) {
- init(channelCount, sampleCount, sampleRate, LAZY_DEFAULT);
- }
-
- /**
- * Creates a new instance of FloatSampleBuffer and initializes
- * it with audio data given in the interleaved byte array <code>buffer</code>.
- */
- public FloatSampleBuffer(byte[] buffer, int offset, int byteCount,
- AudioFormat format) {
- this(format.getChannels(),
- byteCount/(format.getSampleSizeInBits()/8*format.getChannels()),
- format.getSampleRate());
- initFromByteArray(buffer, offset, byteCount, format);
- }
-
- protected void init(int channelCount, int sampleCount, float sampleRate) {
- init(channelCount, sampleCount, sampleRate, LAZY_DEFAULT);
- }
-
- protected void init(int channelCount, int sampleCount, float sampleRate, boolean lazy) {
- if (channelCount<0 || sampleCount<0) {
- throw new IllegalArgumentException(
- "invalid parameters in initialization of FloatSampleBuffer.");
- }
- setSampleRate(sampleRate);
- if (getSampleCount()!=sampleCount || getChannelCount()!=channelCount) {
- createChannels(channelCount, sampleCount, lazy);
- }
- }
-
- private void createChannels(int channelCount, int sampleCount, boolean lazy) {
- this.sampleCount=sampleCount;
- // lazy delete of all channels. Intentionally lazy !
- this.channelCount=0;
- for (int ch=0; ch<channelCount; ch++) {
- insertChannel(ch, false, lazy);
- }
- if (!lazy) {
- // remove hidden channels
- while (channels.size()>channelCount) {
- channels.remove(channels.size()-1);
- }
- }
- }
-
-
- /**
- * Resets this buffer with the audio data specified
- * in the arguments. This FloatSampleBuffer's sample count
- * will be set to <code>byteCount / format.getFrameSize()</code>.
- * If LAZY_DEFAULT is true, it will use lazy deletion.
- *
- * @throws IllegalArgumentException
- */
- public void initFromByteArray(byte[] buffer, int offset, int byteCount,
- AudioFormat format) {
- initFromByteArray(buffer, offset, byteCount, format, LAZY_DEFAULT);
- }
-
-
- /**
- * Resets this buffer with the audio data specified
- * in the arguments. This FloatSampleBuffer's sample count
- * will be set to <code>byteCount / format.getFrameSize()</code>.
- *
- * @param lazy if true, then existing channels will be tried to be re-used
- * to minimize garbage collection.
- * @throws IllegalArgumentException
- */
- public void initFromByteArray(byte[] buffer, int offset, int byteCount,
- AudioFormat format, boolean lazy) {
- if (offset+byteCount>buffer.length) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer.initFromByteArray: buffer too small.");
- }
-
- int thisSampleCount = byteCount/format.getFrameSize();
- init(format.getChannels(), thisSampleCount, format.getSampleRate(), lazy);
-
- // save format for automatic dithering mode
- originalFormatType = FloatSampleTools.getFormatType(format);
-
- FloatSampleTools.byte2float(buffer, offset,
- channels, 0, sampleCount, format);
- }
-
- /**
- * Resets this sample buffer with the data in <code>source</code>.
- */
- public void initFromFloatSampleBuffer(FloatSampleBuffer source) {
- init(source.getChannelCount(), source.getSampleCount(), source.getSampleRate());
- for (int ch=0; ch<getChannelCount(); ch++) {
- System.arraycopy(source.getChannel(ch), 0, getChannel(ch), 0, sampleCount);
- }
- }
-
- /**
- * Deletes all channels, frees memory...
- * This also removes hidden channels by lazy remove.
- */
- public void reset() {
- init(0,0,1, false);
- }
-
- /**
- * Destroys any existing data and creates new channels.
- * It also destroys lazy removed channels and samples.
- */
- public void reset(int channels, int sampleCount, float sampleRate) {
- init(channels, sampleCount, sampleRate, false);
- }
-
- //////////////////////////////// conversion back to bytes /////////////////////////////////
-
- /**
- * @return the required size of the buffer
- * for calling convertToByteArray(..) is called
- */
- public int getByteArrayBufferSize(AudioFormat format) {
- // make sure this format is supported
- FloatSampleTools.getFormatType(format);
- return format.getFrameSize() * getSampleCount();
- }
-
- /**
- * Writes this sample buffer's audio data to <code>buffer</code>
- * as an interleaved byte array.
- * <code>buffer</code> must be large enough to hold all data.
- *
- * @throws IllegalArgumentException when buffer is too small or <code>format</code> doesn't match
- * @return number of bytes written to <code>buffer</code>
- */
- public int convertToByteArray(byte[] buffer, int offset, AudioFormat format) {
- int byteCount = getByteArrayBufferSize(format);
- if (offset + byteCount > buffer.length) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer.convertToByteArray: buffer too small.");
- }
- if (format.getSampleRate()!=getSampleRate()) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer.convertToByteArray: different samplerates.");
- }
- if (format.getChannels()!=getChannelCount()) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer.convertToByteArray: different channel count.");
- }
- FloatSampleTools.float2byte(channels, 0, buffer, offset, getSampleCount(),
- format, getConvertDitherBits(FloatSampleTools.getFormatType(format)));
-
- return byteCount;
- }
-
-
- /**
- * Creates a new byte[] buffer, fills it with the audio data, and returns it.
- * @throws IllegalArgumentException when sample rate or channels do not match
- * @see #convertToByteArray(byte[], int, AudioFormat)
- */
- public byte[] convertToByteArray(AudioFormat format) {
- // throws exception when sampleRate doesn't match
- // creates a new byte[] buffer and returns it
- byte[] res = new byte[getByteArrayBufferSize(format)];
- convertToByteArray(res, 0, format);
- return res;
- }
-
- //////////////////////////////// actions /////////////////////////////////
-
- /**
- * Resizes this buffer.
- * <p>If <code>keepOldSamples</code> is true, as much as possible samples are
- * retained. If the buffer is enlarged, silence is added at the end.
- * If <code>keepOldSamples</code> is false, existing samples are discarded
- * and the buffer contains random samples.
- */
- public void changeSampleCount(int newSampleCount, boolean keepOldSamples) {
- int oldSampleCount=getSampleCount();
- if (oldSampleCount==newSampleCount) {
- return;
- }
- Object[] oldChannels=null;
- if (keepOldSamples) {
- oldChannels=getAllChannels();
- }
- init(getChannelCount(), newSampleCount, getSampleRate());
- if (keepOldSamples) {
- // copy old channels and eventually silence out new samples
- int copyCount=newSampleCount<oldSampleCount?
- newSampleCount:oldSampleCount;
- for (int ch=0; ch<getChannelCount(); ch++) {
- float[] oldSamples=(float[]) oldChannels[ch];
- float[] newSamples=(float[]) getChannel(ch);
- if (oldSamples!=newSamples) {
- // if this sample array was not object of lazy delete
- System.arraycopy(oldSamples, 0, newSamples, 0, copyCount);
- }
- if (oldSampleCount<newSampleCount) {
- // silence out new samples
- for (int i=oldSampleCount; i<newSampleCount; i++) {
- newSamples[i]=0.0f;
- }
- }
- }
- }
- }
-
- public void makeSilence() {
- // silence all channels
- if (getChannelCount()>0) {
- makeSilence(0);
- for (int ch=1; ch<getChannelCount(); ch++) {
- copyChannel(0, ch);
- }
- }
- }
-
- public void makeSilence(int channel) {
- float[] samples=getChannel(channel);
- for (int i=0; i<getSampleCount(); i++) {
- samples[i]=0.0f;
- }
- }
-
- public void addChannel(boolean silent) {
- // creates new, silent channel
- insertChannel(getChannelCount(), silent);
- }
-
- /**
- * Insert a (silent) channel at position <code>index</code>.
- * If LAZY_DEFAULT is true, this is done lazily.
- */
- public void insertChannel(int index, boolean silent) {
- insertChannel(index, silent, LAZY_DEFAULT);
- }
-
- /**
- * Inserts a channel at position <code>index</code>.
- * <p>If <code>silent</code> is true, the new channel will be silent.
- * Otherwise it will contain random data.
- * <p>If <code>lazy</code> is true, hidden channels which have at least getSampleCount()
- * elements will be examined for reusage as inserted channel.<br>
- * If <code>lazy</code> is false, still hidden channels are reused,
- * but it is assured that the inserted channel has exactly getSampleCount() elements,
- * thus not wasting memory.
- */
- public void insertChannel(int index, boolean silent, boolean lazy) {
- int physSize=channels.size();
- int virtSize=getChannelCount();
- float[] newChannel=null;
- if (physSize>virtSize) {
- // there are hidden channels. Try to use one.
- for (int ch=virtSize; ch<physSize; ch++) {
- float[] thisChannel=(float[]) channels.get(ch);
- if ((lazy && thisChannel.length>=getSampleCount())
- || (!lazy && thisChannel.length==getSampleCount())) {
- // we found a matching channel. Use it !
- newChannel=thisChannel;
- channels.remove(ch);
- break;
- }
- }
- }
- if (newChannel==null) {
- newChannel=new float[getSampleCount()];
- }
- channels.add(index, newChannel);
- this.channelCount++;
- if (silent) {
- makeSilence(index);
- }
- }
-
- /** performs a lazy remove of the channel */
- public void removeChannel(int channel) {
- removeChannel(channel, LAZY_DEFAULT);
- }
-
-
- /**
- * Removes a channel.
- * If lazy is true, the channel is not physically removed, but only hidden.
- * These hidden channels are reused by subsequent calls to addChannel
- * or insertChannel.
- */
- public void removeChannel(int channel, boolean lazy) {
- if (!lazy) {
- channels.remove(channel);
- } else if (channel<getChannelCount()-1) {
- // if not already, move this channel at the end
- channels.add(channels.remove(channel));
- }
- channelCount--;
- }
-
- /**
- * both source and target channel have to exist. targetChannel
- * will be overwritten
- */
- public void copyChannel(int sourceChannel, int targetChannel) {
- float[] source=getChannel(sourceChannel);
- float[] target=getChannel(targetChannel);
- System.arraycopy(source, 0, target, 0, getSampleCount());
- }
-
- /**
- * Copies data inside all channel. When the 2 regions
- * overlap, the behavior is not specified.
- */
- public void copy(int sourceIndex, int destIndex, int length) {
- for (int i=0; i<getChannelCount(); i++) {
- copy(i, sourceIndex, destIndex, length);
- }
- }
-
- /**
- * Copies data inside a channel. When the 2 regions
- * overlap, the behavior is not specified.
- */
- public void copy(int channel, int sourceIndex, int destIndex, int length) {
- float[] data=getChannel(channel);
- int bufferCount=getSampleCount();
- if (sourceIndex+length>bufferCount || destIndex+length>bufferCount
- || sourceIndex<0 || destIndex<0 || length<0) {
- throw new IndexOutOfBoundsException("parameters exceed buffer size");
- }
- System.arraycopy(data, sourceIndex, data, destIndex, length);
- }
-
- /**
- * Mix up of 1 channel to n channels.<br>
- * It copies the first channel to all newly created channels.
- * @param targetChannelCount the number of channels that this sample buffer
- * will have after expanding. NOT the number of
- * channels to add !
- * @exception IllegalArgumentException if this buffer does not have one
- * channel before calling this method.
- */
- public void expandChannel(int targetChannelCount) {
- // even more sanity...
- if (getChannelCount()!=1) {
- throw new IllegalArgumentException(
- "FloatSampleBuffer: can only expand channels for mono signals.");
- }
- for (int ch=1; ch<targetChannelCount; ch++) {
- addChannel(false);
- copyChannel(0, ch);
- }
- }
-
- /**
- * Mix down of n channels to one channel.<br>
- * It uses a simple mixdown: all other channels are added to first channel.<br>
- * The volume is NOT lowered !
- * Be aware, this might cause clipping when converting back
- * to integer samples.
- */
- public void mixDownChannels() {
- float[] firstChannel=getChannel(0);
- int sampleCount=getSampleCount();
- int channelCount=getChannelCount();
- for (int ch=channelCount-1; ch>0; ch--) {
- float[] thisChannel=getChannel(ch);
- for (int i=0; i<sampleCount; i++) {
- firstChannel[i]+=thisChannel[i];
- }
- removeChannel(ch);
- }
- }
-
- /**
- * Initializes audio data from the provided byte array.
- * The float samples are written at <code>destOffset</code>.
- * This FloatSampleBuffer must be big enough to accomodate the samples.
- * <p>
- * <code>srcBuffer</code> is read from index <code>srcOffset</code>
- * to <code>(srcOffset + (lengthInSamples * format.getFrameSize()))</code.
- *
- * @param input the input buffer in interleaved audio data
- * @param inByteOffset the offset in <code>input</code>
- * @param format input buffer's audio format
- * @param floatOffset the offset where to write the float samples
- * @param frameCount number of samples to write to this sample buffer
- */
- public void setSamplesFromBytes(byte[] input, int inByteOffset, AudioFormat format,
- int floatOffset, int frameCount) {
- if (floatOffset < 0 || frameCount < 0 || inByteOffset < 0) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer.setSamplesFromBytes: negative inByteOffset, floatOffset, or frameCount");
- }
- if (inByteOffset + (frameCount * format.getFrameSize()) > input.length) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer.setSamplesFromBytes: input buffer too small.");
- }
- if (floatOffset + frameCount > getSampleCount()) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer.setSamplesFromBytes: frameCount too large");
- }
-
- FloatSampleTools.byte2float(input, inByteOffset, channels, floatOffset, frameCount, format);
- }
-
- //////////////////////////////// properties /////////////////////////////////
-
- public int getChannelCount() {
- return channelCount;
- }
-
- public int getSampleCount() {
- return sampleCount;
- }
-
- public float getSampleRate() {
- return sampleRate;
- }
-
- /**
- * Sets the sample rate of this buffer.
- * NOTE: no conversion is done. The samples are only re-interpreted.
- */
- public void setSampleRate(float sampleRate) {
- if (sampleRate<=0) {
- throw new IllegalArgumentException
- ("Invalid samplerate for FloatSampleBuffer.");
- }
- this.sampleRate=sampleRate;
- }
-
- /**
- * NOTE: the returned array may be larger than sampleCount. So in any case,
- * sampleCount is to be respected.
- */
- public float[] getChannel(int channel) {
- if (channel<0 || channel>=getChannelCount()) {
- throw new IllegalArgumentException(
- "FloatSampleBuffer: invalid channel number.");
- }
- return (float[]) channels.get(channel);
- }
-
- public Object[] getAllChannels() {
- Object[] res=new Object[getChannelCount()];
- for (int ch=0; ch<getChannelCount(); ch++) {
- res[ch]=getChannel(ch);
- }
- return res;
- }
-
- /**
- * Set the number of bits for dithering.
- * Typically, a value between 0.2 and 0.9 gives best results.
- * <p>Note: this value is only used, when dithering is actually performed.
- */
- public void setDitherBits(float ditherBits) {
- if (ditherBits<=0) {
- throw new IllegalArgumentException("DitherBits must be greater than 0");
- }
- this.ditherBits=ditherBits;
- }
-
- public float getDitherBits() {
- return ditherBits;
- }
-
- /**
- * Sets the mode for dithering.
- * This can be one of:
- * <ul><li>DITHER_MODE_AUTOMATIC: it is decided automatically,
- * whether dithering is necessary - in general when sample size is
- * decreased.
- * <li>DITHER_MODE_ON: dithering will be forced
- * <li>DITHER_MODE_OFF: dithering will not be done.
- * </ul>
- */
- public void setDitherMode(int mode) {
- if (mode!=DITHER_MODE_AUTOMATIC
- && mode!=DITHER_MODE_ON
- && mode!=DITHER_MODE_OFF) {
- throw new IllegalArgumentException("Illegal DitherMode");
- }
- this.ditherMode=mode;
- }
-
- public int getDitherMode() {
- return ditherMode;
- }
-
-
- /**
- * @return the ditherBits parameter for the float2byte functions
- */
- protected float getConvertDitherBits(int newFormatType) {
- // let's see whether dithering is necessary
- boolean doDither = false;
- switch (ditherMode) {
- case DITHER_MODE_AUTOMATIC:
- doDither=(originalFormatType & FloatSampleTools.F_SAMPLE_WIDTH_MASK)>
- (newFormatType & FloatSampleTools.F_SAMPLE_WIDTH_MASK);
- break;
- case DITHER_MODE_ON:
- doDither=true;
- break;
- case DITHER_MODE_OFF:
- doDither=false;
- break;
- }
- return doDither?ditherBits:0.0f;
- }
-}
diff --git a/songdbj/org/tritonus/share/sampled/FloatSampleTools.java b/songdbj/org/tritonus/share/sampled/FloatSampleTools.java
deleted file mode 100644
index 76913ba39e..0000000000
--- a/songdbj/org/tritonus/share/sampled/FloatSampleTools.java
+++ /dev/null
@@ -1,696 +0,0 @@
-/*
- * FloatSampleTools.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000,2004 by Florian Bomers <http://www.bomers.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-import java.util.*;
-import javax.sound.sampled.*;
-import org.tritonus.share.TDebug;
-
-/**
- * Utility functions for handling data in normalized float arrays.
- * Each sample is linear in the range of [-1.0f, +1.0f].
- * <p>
- * Currently, the following bit sizes are supported:
- * <ul>
- * <li>8-bit
- * <li>16-bit
- * <li>packed 24-bit (stored in 3 bytes)
- * <li>32-bit
- * </ul>
- * 8-bit data can be unsigned or signed. All other data is only
- * supported in signed encoding.
- *
- * @see FloatSampleBuffer
- * @author Florian Bomers
- */
-
-public class FloatSampleTools {
-
- /** default number of bits to be dithered: 0.7f */
- public static final float DEFAULT_DITHER_BITS = 0.7f;
-
- private static Random random = null;
-
- // sample width (must be in order !)
- static final int F_8=1;
- static final int F_16=2;
- static final int F_24=3;
- static final int F_32=4;
- static final int F_SAMPLE_WIDTH_MASK=F_8 | F_16 | F_24 | F_32;
-
- // format bit-flags
- static final int F_SIGNED=8;
- static final int F_BIGENDIAN=16;
-
- // supported formats
- static final int CT_8S=F_8 | F_SIGNED;
- static final int CT_8U=F_8;
- static final int CT_16SB=F_16 | F_SIGNED | F_BIGENDIAN;
- static final int CT_16SL=F_16 | F_SIGNED;
- static final int CT_24SB=F_24 | F_SIGNED | F_BIGENDIAN;
- static final int CT_24SL=F_24 | F_SIGNED;
- static final int CT_32SB=F_32 | F_SIGNED | F_BIGENDIAN;
- static final int CT_32SL=F_32 | F_SIGNED;
-
- // ////////////////////////////// initialization /////////////////////////////// //
-
- /** prevent instanciation */
- private FloatSampleTools() {
- }
-
-
- // /////////////////// FORMAT / FORMAT TYPE /////////////////////////////////// //
-
- /**
- * only allow "packed" samples -- currently no support for 18, 20, 24_32 bits.
- * @throws IllegalArgumentException
- */
- static void checkSupportedSampleSize(int ssib, int channels, int frameSize) {
- if ((ssib*channels) != frameSize * 8) {
- throw new IllegalArgumentException("unsupported sample size: "+ssib
- +" stored in "+(frameSize/channels)+" bytes.");
- }
- }
-
-
- /**
- * Get the formatType code from the given format.
- * @throws IllegalArgumentException
- */
- static int getFormatType(AudioFormat format) {
- boolean signed = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
- if (!signed &&
- !format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED)) {
- throw new IllegalArgumentException
- ("unsupported encoding: only PCM encoding supported.");
- }
- if (!signed && format.getSampleSizeInBits() != 8) {
- throw new IllegalArgumentException
- ("unsupported encoding: only 8-bit can be unsigned");
- }
- checkSupportedSampleSize(format.getSampleSizeInBits(),
- format.getChannels(),
- format.getFrameSize());
-
- int formatType = getFormatType(format.getSampleSizeInBits(),
- signed, format.isBigEndian());
- return formatType;
- }
-
- /**
- * @throws IllegalArgumentException
- */
- static int getFormatType(int ssib, boolean signed, boolean bigEndian) {
- int bytesPerSample=ssib/8;
- int res=0;
- if (ssib==8) {
- res=F_8;
- } else if (ssib==16) {
- res=F_16;
- } else if (ssib==24) {
- res=F_24;
- } else if (ssib==32) {
- res=F_32;
- }
- if (res==0) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer: unsupported sample size of "
- +ssib+" bits per sample.");
- }
- if (!signed && bytesPerSample>1) {
- throw new IllegalArgumentException
- ("FloatSampleBuffer: unsigned samples larger than "
- +"8 bit are not supported");
- }
- if (signed) {
- res|=F_SIGNED;
- }
- if (bigEndian && (ssib!=8)) {
- res|=F_BIGENDIAN;
- }
- return res;
- }
-
- static int getSampleSize(int formatType) {
- switch (formatType & F_SAMPLE_WIDTH_MASK) {
- case F_8: return 1;
- case F_16: return 2;
- case F_24: return 3;
- case F_32: return 4;
- }
- return 0;
- }
-
- /**
- * Return a string representation of this format
- */
- static String formatType2Str(int formatType) {
- String res=""+formatType+": ";
- switch (formatType & F_SAMPLE_WIDTH_MASK) {
- case F_8:
- res+="8bit";
- break;
- case F_16:
- res+="16bit";
- break;
- case F_24:
- res+="24bit";
- break;
- case F_32:
- res+="32bit";
- break;
- }
- res+=((formatType & F_SIGNED)==F_SIGNED)?" signed":" unsigned";
- if ((formatType & F_SAMPLE_WIDTH_MASK)!=F_8) {
- res+=((formatType & F_BIGENDIAN)==F_BIGENDIAN)?
- " big endian":" little endian";
- }
- return res;
- }
-
-
- // /////////////////// BYTE 2 FLOAT /////////////////////////////////// //
-
- private static final float twoPower7=128.0f;
- private static final float twoPower15=32768.0f;
- private static final float twoPower23=8388608.0f;
- private static final float twoPower31=2147483648.0f;
-
- private static final float invTwoPower7=1/twoPower7;
- private static final float invTwoPower15=1/twoPower15;
- private static final float invTwoPower23=1/twoPower23;
- private static final float invTwoPower31=1/twoPower31;
-
-
- /**
- * Conversion function to convert an interleaved byte array to
- * a List of interleaved float arrays. The float arrays will contain normalized
- * samples in the range [-1.0f, +1.0f]. The input array
- * provides bytes in the format specified in <code>format</code>.
- * <p>
- * Only PCM formats are accepted. The method will convert all
- * byte values from
- * <code>input[inByteOffset]</code> to
- * <code>input[inByteOffset + (frameCount * format.getFrameSize()) - 1]</code>
- * to floats from
- * <code>output(n)[outOffset]</code> to
- * <code>output(n)[outOffset + frameCount - 1]</code>
- *
- * @param input the audio data in an byte array
- * @param inByteOffset index in input where to start the conversion
- * @param output list of float[] arrays which receive the converted audio data.
- * if the list does not contain enough elements, or individual float arrays
- * are not large enough, they are created.
- * @param outOffset the start offset in <code>output</code>
- * @param frameCount number of frames to be converted
- * @param format the input format. Only packed PCM is allowed
- * @throws IllegalArgumentException if one of the parameters is out of bounds
- *
- * @see #byte2floatInterleaved(byte[],int,float[],int,int,AudioFormat)
- */
- public static void byte2float(byte[] input, int inByteOffset,
- List<float[]> output, int outOffset, int frameCount,
- //List output, int outOffset, int frameCount,
- AudioFormat format) {
- for (int channel = 0; channel < format.getChannels(); channel++) {
- float[] data;
- if (output.size() < channel) {
- data = new float[frameCount + outOffset];
- output.add(data);
- } else {
- data = output.get(channel);
- if (data.length < frameCount + outOffset) {
- data = new float[frameCount + outOffset];
- output.set(channel, data);
- }
- }
-
- byte2floatGeneric(input, inByteOffset, format.getFrameSize(),
- data, outOffset,
- frameCount, format);
- inByteOffset += format.getFrameSize() / format.getChannels();
- }
- }
-
-
- /**
- * Conversion function to convert an interleaved byte array to
- * an interleaved float array. The float array will contain normalized
- * samples in the range [-1.0f, +1.0f]. The input array
- * provides bytes in the format specified in <code>format</code>.
- * <p>
- * Only PCM formats are accepted. The method will convert all
- * byte values from
- * <code>input[inByteOffset]</code> to
- * <code>input[inByteOffset + (frameCount * format.getFrameSize()) - 1]</code>
- * to floats from
- * <code>output[outOffset]</code> to
- * <code>output[outOffset + (frameCount * format.getChannels()) - 1]</code>
- *
- * @param input the audio data in an byte array
- * @param inByteOffset index in input where to start the conversion
- * @param output the float array that receives the converted audio data
- * @param outOffset the start offset in <code>output</code>
- * @param frameCount number of frames to be converted
- * @param format the input format. Only packed PCM is allowed
- * @throws IllegalArgumentException if one of the parameters is out of bounds
- *
- * @see #byte2float(byte[],int,List,int,int,AudioFormat)
- */
- public static void byte2floatInterleaved(byte[] input, int inByteOffset,
- float[] output, int outOffset, int frameCount,
- AudioFormat format) {
-
- byte2floatGeneric(input, inByteOffset, format.getFrameSize() / format.getChannels(),
- output, outOffset, frameCount * format.getChannels(),
- format);
- }
-
-
-
- /**
- * Generic conversion function to convert a byte array to
- * a float array.
- * <p>
- * Only PCM formats are accepted. The method will convert all
- * bytes from
- * <code>input[inByteOffset]</code> to
- * <code>input[inByteOffset + (sampleCount * (inByteStep - 1)]</code>
- * to samples from
- * <code>output[outOffset]</code> to
- * <code>output[outOffset+sampleCount-1]</code>.
- * <p>
- * The <code>format</code>'s channel count is ignored.
- * <p>
- * For mono data, set <code>inByteOffset</code> to <code>format.getFrameSize()</code>.<br>
- * For converting interleaved input data, multiply <code>sampleCount</code>
- * by the number of channels and set inByteStep to
- * <code>format.getFrameSize() / format.getChannels()</code>.
- *
- * @param sampleCount number of samples to be written to output
- * @param inByteStep how many bytes advance for each output sample in <code>output</code>.
- * @throws IllegalArgumentException if one of the parameters is out of bounds
- *
- * @see #byte2floatInterleaved(byte[],int,float[],int,int,AudioFormat)
- * @see #byte2float(byte[],int,List,int,int,AudioFormat)
- */
- static void byte2floatGeneric(byte[] input, int inByteOffset, int inByteStep,
- float[] output, int outOffset, int sampleCount,
- AudioFormat format) {
- int formatType = getFormatType(format);
-
- byte2floatGeneric(input, inByteOffset, inByteStep,
- output, outOffset, sampleCount,
- formatType);
- }
-
-
- /**
- * Central conversion function from
- * a byte array to a normalized float array. In order to accomodate
- * interleaved and non-interleaved
- * samples, this method takes inByteStep as parameter which
- * can be used to flexibly convert the data.
- * <p>
- * E.g.:<br>
- * mono->mono: inByteStep=format.getFrameSize()<br>
- * interleaved_stereo->interleaved_stereo: inByteStep=format.getFrameSize()/2,
- * sampleCount*2<br>
- * stereo->2 mono arrays:<br>
- * ---inByteOffset=0, outOffset=0, inByteStep=format.getFrameSize()<br>
- * ---inByteOffset=format.getFrameSize()/2, outOffset=1, inByteStep=format.getFrameSize()<br>
- */
- static void byte2floatGeneric(byte[] input, int inByteOffset, int inByteStep,
- float[] output, int outOffset, int sampleCount,
- int formatType) {
- //if (TDebug.TraceAudioConverter) {
- // TDebug.out("FloatSampleTools.byte2floatGeneric, formatType="
- // +formatType2Str(formatType));
- //}
- int endCount = outOffset + sampleCount;
- int inIndex = inByteOffset;
- for (int outIndex = outOffset; outIndex < endCount; outIndex++, inIndex+=inByteStep) {
- // do conversion
- switch (formatType) {
- case CT_8S:
- output[outIndex]=
- ((float) input[inIndex])*invTwoPower7;
- break;
- case CT_8U:
- output[outIndex]=
- ((float) ((input[inIndex] & 0xFF)-128))*invTwoPower7;
- break;
- case CT_16SB:
- output[outIndex]=
- ((float) ((input[inIndex]<<8)
- | (input[inIndex+1] & 0xFF)))*invTwoPower15;
- break;
- case CT_16SL:
- output[outIndex]=
- ((float) ((input[inIndex+1]<<8)
- | (input[inIndex] & 0xFF)))*invTwoPower15;
- break;
- case CT_24SB:
- output[outIndex]=
- ((float) ((input[inIndex]<<16)
- | ((input[inIndex+1] & 0xFF)<<8)
- | (input[inIndex+2] & 0xFF)))*invTwoPower23;
- break;
- case CT_24SL:
- output[outIndex]=
- ((float) ((input[inIndex+2]<<16)
- | ((input[inIndex+1] & 0xFF)<<8)
- | (input[inIndex] & 0xFF)))*invTwoPower23;
- break;
- case CT_32SB:
- output[outIndex]=
- ((float) ((input[inIndex]<<24)
- | ((input[inIndex+1] & 0xFF)<<16)
- | ((input[inIndex+2] & 0xFF)<<8)
- | (input[inIndex+3] & 0xFF)))*invTwoPower31;
- break;
- case CT_32SL:
- output[outIndex]=
- ((float) ((input[inIndex+3]<<24)
- | ((input[inIndex+2] & 0xFF)<<16)
- | ((input[inIndex+1] & 0xFF)<<8)
- | (input[inIndex] & 0xFF)))*invTwoPower31;
- break;
- default:
- throw new IllegalArgumentException
- ("unsupported format="+formatType2Str(formatType));
- }
- }
- }
-
- // /////////////////// FLOAT 2 BYTE /////////////////////////////////// //
-
- private static byte quantize8(float sample, float ditherBits) {
- if (ditherBits!=0) {
- sample+=random.nextFloat()*ditherBits;
- }
- if (sample>=127.0f) {
- return (byte) 127;
- } else if (sample<=-128.0f) {
- return (byte) -128;
- } else {
- return (byte) (sample<0?(sample-0.5f):(sample+0.5f));
- }
- }
-
- private static int quantize16(float sample, float ditherBits) {
- if (ditherBits!=0) {
- sample+=random.nextFloat()*ditherBits;
- }
- if (sample>=32767.0f) {
- return 32767;
- } else if (sample<=-32768.0f) {
- return -32768;
- } else {
- return (int) (sample<0?(sample-0.5f):(sample+0.5f));
- }
- }
-
- private static int quantize24(float sample, float ditherBits) {
- if (ditherBits!=0) {
- sample+=random.nextFloat()*ditherBits;
- }
- if (sample>=8388607.0f) {
- return 8388607;
- } else if (sample<=-8388608.0f) {
- return -8388608;
- } else {
- return (int) (sample<0?(sample-0.5f):(sample+0.5f));
- }
- }
-
- private static int quantize32(float sample, float ditherBits) {
- if (ditherBits!=0) {
- sample+=random.nextFloat()*ditherBits;
- }
- if (sample>=2147483647.0f) {
- return 2147483647;
- } else if (sample<=-2147483648.0f) {
- return -2147483648;
- } else {
- return (int) (sample<0?(sample-0.5f):(sample+0.5f));
- }
- }
-
-
- /**
- * Conversion function to convert a non-interleaved float audio data to
- * an interleaved byte array. The float arrays contains normalized
- * samples in the range [-1.0f, +1.0f]. The output array
- * will receive bytes in the format specified in <code>format</code>.
- * Exactly <code>format.getChannels()</code> channels are converted
- * regardless of the number of elements in <code>input</code>. If <code>input</code>
- * does not provide enough channels, an </code>IllegalArgumentException<code> is thrown.
- * <p>
- * Only PCM formats are accepted. The method will convert all
- * samples from <code>input(n)[inOffset]</code> to
- * <code>input(n)[inOffset + frameCount - 1]</code>
- * to byte values from <code>output[outByteOffset]</code> to
- * <code>output[outByteOffset + (frameCount * format.getFrameSize()) - 1]</code>
- * <p>
- * Dithering should be used when the output resolution is significantly
- * lower than the original resolution. This includes if the original
- * data was 16-bit and it is now converted to 8-bit, or if the
- * data was generated in the float domain. No dithering need to be used
- * if the original sample data was in e.g. 8-bit and the resulting output
- * data has a higher resolution. If dithering is used, a sensitive value
- * is DEFAULT_DITHER_BITS.
- *
- * @param input a List of float arrays with the input audio data
- * @param inOffset index in the input arrays where to start the conversion
- * @param output the byte array that receives the converted audio data
- * @param outByteOffset the start offset in <code>output</code>
- * @param frameCount number of frames to be converted.
- * @param format the output format. Only packed PCM is allowed
- * @param ditherBits if 0, do not dither. Otherwise the number of bits to be dithered
- * @throws IllegalArgumentException if one of the parameters is out of bounds
- *
- * @see #DEFAULT_DITHER_BITS
- * @see #float2byteInterleaved(float[],int,byte[],int,int,AudioFormat,float)
- */
- //public static void float2byte(List<float[]> input, int inOffset,
- public static void float2byte(List input, int inOffset,
- byte[] output, int outByteOffset,
- int frameCount,
- AudioFormat format, float ditherBits) {
- for (int channel = 0; channel < format.getChannels(); channel++) {
- float[] data = (float[]) input.get(channel);
- float2byteGeneric(data, inOffset,
- output, outByteOffset, format.getFrameSize(),
- frameCount, format, ditherBits);
- outByteOffset += format.getFrameSize() / format.getChannels();
- }
- }
-
- /**
- * Conversion function to convert an interleaved float array to
- * an interleaved byte array. The float array contains normalized
- * samples in the range [-1.0f, +1.0f]. The output array
- * will receive bytes in the format specified in <code>format</code>.
- * <p>
- * Only PCM formats are accepted. The method will convert all
- * samples from <code>input[inOffset]</code> to
- * <code>input[inOffset + (frameCount * format.getChannels()) - 1]</code>
- * to byte values from <code>output[outByteOffset]</code> to
- * <code>output[outByteOffset + (frameCount * format.getFrameSize()) - 1]</code>
- * <p>
- * Dithering should be used when the output resolution is significantly
- * lower than the original resolution. This includes if the original
- * data was 16-bit and it is now converted to 8-bit, or if the
- * data was generated in the float domain. No dithering need to be used
- * if the original sample data was in e.g. 8-bit and the resulting output
- * data has a higher resolution. If dithering is used, a sensitive value
- * is DEFAULT_DITHER_BITS.
- *
- * @param input the audio data in normalized samples
- * @param inOffset index in input where to start the conversion
- * @param output the byte array that receives the converted audio data
- * @param outByteOffset the start offset in <code>output</code>
- * @param frameCount number of frames to be converted.
- * @param format the output format. Only packed PCM is allowed
- * @param ditherBits if 0, do not dither. Otherwise the number of bits to be dithered
- * @throws IllegalArgumentException if one of the parameters is out of bounds
- *
- * @see #DEFAULT_DITHER_BITS
- * @see #float2byte(List,int,byte[],int,int,AudioFormat,float)
- */
- public static void float2byteInterleaved(float[] input, int inOffset,
- byte[] output, int outByteOffset,
- int frameCount,
- AudioFormat format, float ditherBits) {
- float2byteGeneric(input, inOffset,
- output, outByteOffset, format.getFrameSize() / format.getChannels(),
- frameCount * format.getChannels(),
- format, ditherBits);
- }
-
-
-
- /**
- * Generic conversion function to convert a float array to
- * a byte array.
- * <p>
- * Only PCM formats are accepted. The method will convert all
- * samples from <code>input[inOffset]</code> to
- * <code>input[inOffset+sampleCount-1]</code>
- * to byte values from <code>output[outByteOffset]</code> to
- * <code>output[outByteOffset + (sampleCount * (outByteStep - 1)]</code>.
- * <p>
- * The <code>format</code>'s channel count is ignored.
- * <p>
- * For mono data, set <code>outByteOffset</code> to <code>format.getFrameSize()</code>.<br>
- * For converting interleaved input data, multiply <code>sampleCount</code>
- * by the number of channels and set outByteStep to
- * <code>format.getFrameSize() / format.getChannels()</code>.
- *
- * @param sampleCount number of samples in input to be converted.
- * @param outByteStep how many bytes advance for each input sample in <code>input</code>.
- * @throws IllegalArgumentException if one of the parameters is out of bounds
- *
- * @see #float2byteInterleaved(float[],int,byte[],int,int,AudioFormat,float)
- * @see #float2byte(List,int,byte[],int,int,AudioFormat,float)
- */
- static void float2byteGeneric(float[] input, int inOffset,
- byte[] output, int outByteOffset, int outByteStep,
- int sampleCount,
- AudioFormat format, float ditherBits) {
- int formatType = getFormatType(format);
-
- float2byteGeneric(input, inOffset,
- output, outByteOffset, outByteStep,
- sampleCount,
- formatType, ditherBits);
- }
-
-
- /**
- * Central conversion function from normalized float array to
- * a byte array. In order to accomodate interleaved and non-interleaved
- * samples, this method takes outByteStep as parameter which
- * can be used to flexibly convert the data.
- * <p>
- * E.g.:<br>
- * mono->mono: outByteStep=format.getFrameSize()<br>
- * interleaved stereo->interleaved stereo: outByteStep=format.getFrameSize()/2, sampleCount*2<br>
- * 2 mono arrays->stereo:<br>
- * ---inOffset=0, outByteOffset=0, outByteStep=format.getFrameSize()<br>
- * ---inOffset=1, outByteOffset=format.getFrameSize()/2, outByteStep=format.getFrameSize()<br>
- */
- static void float2byteGeneric(float[] input, int inOffset,
- byte[] output, int outByteOffset, int outByteStep,
- int sampleCount, int formatType, float ditherBits) {
- //if (TDebug.TraceAudioConverter) {
- // TDebug.out("FloatSampleBuffer.float2byteGeneric, formatType="
- // +"formatType2Str(formatType));
- //}
-
- if (inOffset < 0
- || inOffset + sampleCount > input.length
- || sampleCount < 0) {
- throw new IllegalArgumentException("invalid input index: "
- +"input.length="+input.length
- +" inOffset="+inOffset
- +" sampleCount="+sampleCount);
- }
- if (outByteOffset < 0
- || outByteOffset + (sampleCount * outByteStep) > output.length
- || outByteStep < getSampleSize(formatType)) {
- throw new IllegalArgumentException("invalid output index: "
- +"output.length="+output.length
- +" outByteOffset="+outByteOffset
- +" sampleCount="+sampleCount
- +" format="+formatType2Str(formatType));
- }
-
- if (ditherBits!=0.0f && random==null) {
- // create the random number generator for dithering
- random=new Random();
- }
- int endSample = inOffset + sampleCount;
- int iSample;
- int outIndex = outByteOffset;
- for (int inIndex = inOffset;
- inIndex < endSample;
- inIndex++, outIndex+=outByteStep) {
- // do conversion
- switch (formatType) {
- case CT_8S:
- output[outIndex]=quantize8(input[inIndex]*twoPower7, ditherBits);
- break;
- case CT_8U:
- output[outIndex]=(byte) (quantize8((input[inIndex]*twoPower7), ditherBits)+128);
- break;
- case CT_16SB:
- iSample=quantize16(input[inIndex]*twoPower15, ditherBits);
- output[outIndex]=(byte) (iSample >> 8);
- output[outIndex+1]=(byte) (iSample & 0xFF);
- break;
- case CT_16SL:
- iSample=quantize16(input[inIndex]*twoPower15, ditherBits);
- output[outIndex+1]=(byte) (iSample >> 8);
- output[outIndex]=(byte) (iSample & 0xFF);
- break;
- case CT_24SB:
- iSample=quantize24(input[inIndex]*twoPower23, ditherBits);
- output[outIndex]=(byte) (iSample >> 16);
- output[outIndex+1]=(byte) ((iSample >>> 8) & 0xFF);
- output[outIndex+2]=(byte) (iSample & 0xFF);
- break;
- case CT_24SL:
- iSample=quantize24(input[inIndex]*twoPower23, ditherBits);
- output[outIndex+2]=(byte) (iSample >> 16);
- output[outIndex+1]=(byte) ((iSample >>> 8) & 0xFF);
- output[outIndex]=(byte) (iSample & 0xFF);
- break;
- case CT_32SB:
- iSample=quantize32(input[inIndex]*twoPower31, ditherBits);
- output[outIndex]=(byte) (iSample >> 24);
- output[outIndex+1]=(byte) ((iSample >>> 16) & 0xFF);
- output[outIndex+2]=(byte) ((iSample >>> 8) & 0xFF);
- output[outIndex+3]=(byte) (iSample & 0xFF);
- break;
- case CT_32SL:
- iSample=quantize32(input[inIndex]*twoPower31, ditherBits);
- output[outIndex+3]=(byte) (iSample >> 24);
- output[outIndex+2]=(byte) ((iSample >>> 16) & 0xFF);
- output[outIndex+1]=(byte) ((iSample >>> 8) & 0xFF);
- output[outIndex]=(byte) (iSample & 0xFF);
- break;
- default:
- throw new IllegalArgumentException
- ("unsupported format="+formatType2Str(formatType));
- }
- }
- }
-}
diff --git a/songdbj/org/tritonus/share/sampled/TAudioFormat.java b/songdbj/org/tritonus/share/sampled/TAudioFormat.java
deleted file mode 100644
index 7911d5e005..0000000000
--- a/songdbj/org/tritonus/share/sampled/TAudioFormat.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * TAudioFormat.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2003 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-
-
-
-public class TAudioFormat
-extends AudioFormat
-{
- private Map<String, Object> m_properties;
- private Map<String, Object> m_unmodifiableProperties;
-
-
- public TAudioFormat(AudioFormat.Encoding encoding,
- float sampleRate,
- int sampleSizeInBits,
- int channels,
- int frameSize,
- float frameRate,
- boolean bigEndian,
- Map<String, Object> properties)
- {
- super(encoding,
- sampleRate,
- sampleSizeInBits,
- channels,
- frameSize,
- frameRate,
- bigEndian);
- initMaps(properties);
- }
-
-
- public TAudioFormat(float sampleRate,
- int sampleSizeInBits,
- int channels,
- boolean signed,
- boolean bigEndian,
- Map<String, Object> properties)
- {
- super(sampleRate,
- sampleSizeInBits,
- channels,
- signed,
- bigEndian);
- initMaps(properties);
- }
-
-
-
- private void initMaps(Map<String, Object> properties)
- {
- /* Here, we make a shallow copy of the map. It's unclear if this
- is sufficient (or if a deep copy should be made).
- */
- m_properties = new HashMap<String, Object>();
- m_properties.putAll(properties);
- m_unmodifiableProperties = Collections.unmodifiableMap(m_properties);
- }
-
-
-
- public Map<String, Object> properties()
- {
- return m_unmodifiableProperties;
- }
-
-
-
- protected void setProperty(String key, Object value)
- {
- m_properties.put(key, value);
- }
-}
-
-
-
-/*** TAudioFormat.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/TConversionTool.java b/songdbj/org/tritonus/share/sampled/TConversionTool.java
deleted file mode 100644
index 18673edf31..0000000000
--- a/songdbj/org/tritonus/share/sampled/TConversionTool.java
+++ /dev/null
@@ -1,1224 +0,0 @@
-/*
- * TConversionTool.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999,2000 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-
-/**
- * Useful methods for converting audio data.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-
-/*
-For convenience, a list of available methods is maintained here.
-Some hints:
-- buffers: always byte arrays
-- offsets: always in bytes
-- sampleCount: number of SAMPLES to read/write, as opposed to FRAMES or BYTES!
-- when in buffer and out buffer are given, the data is copied,
- otherwise it is replaced in the same buffer (buffer size is not checked!)
-- a number (except "2") gives the number of bits in which format
- the samples have to be.
-- >8 bits per sample is always treated signed.
-- all functions are tried to be optimized - hints welcome !
-
-
-** "high level" methods **
-changeOrderOrSign(buffer, nOffset, nByteLength, nBytesPerSample)
-changeOrderOrSign(inBuffer, nInOffset, outBuffer, nOutOffset, nByteLength, nBytesPerSample)
-
-
-** PCM byte order and sign conversion **
-void convertSign8(buffer, byteOffset, sampleCount)
-void swapOrder16(buffer, byteOffset, sampleCount)
-void swapOrder24(buffer, byteOffset, sampleCount)
-void swapOrder32(buffer, byteOffset, sampleCount)
-void convertSign8(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount)
-void swapOrder16(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount)
-void swapOrder24(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount)
-void swapOrder32(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount)
-
-
-** conversion functions for byte arrays **
-** these are for reference to see how to implement these conversions **
-short bytesToShort16(highByte, lowByte)
-short bytesToShort16(buffer, byteOffset, bigEndian)
-short bytesToInt16(highByte, lowByte)
-short bytesToInt16(buffer, byteOffset, bigEndian)
-short bytesToInt24(buffer, byteOffset, bigEndian)
-short bytesToInt32(buffer, byteOffset, bigEndian)
-void shortToBytes16(sample, buffer, byteOffset, bigEndian)
-void intToBytes24(sample, buffer, byteOffset, bigEndian)
-void intToBytes32(sample, buffer, byteOffset, bigEndian)
-
-
-** ULAW <-> PCM **
-byte linear2ulaw(int sample)
-short ulaw2linear(int ulawbyte)
-void pcm162ulaw(buffer, byteOffset, sampleCount, bigEndian)
-void pcm162ulaw(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, bigEndian)
-void pcm82ulaw(buffer, byteOffset, sampleCount, signed)
-void pcm82ulaw(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, signed)
-void ulaw2pcm16(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, bigEndian)
-void ulaw2pcm8(buffer, byteOffset, sampleCount, signed)
-void ulaw2pcm8(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, signed)
-
-
-** ALAW <-> PCM **
-byte linear2alaw(short pcm_val)
-short alaw2linear(byte ulawbyte)
-void pcm162alaw(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, bigEndian)
-void pcm162alaw(buffer, byteOffset, sampleCount, bigEndian)
-void pcm82alaw(buffer, byteOffset, sampleCount, signed)
-void pcm82alaw(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, signed)
-void alaw2pcm16(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, bigEndian)
-void alaw2pcm8(buffer, byteOffset, sampleCount, signed)
-void alaw2pcm8(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount, signed)
-
-
-** ULAW <-> ALAW **
-byte ulaw2alaw(byte sample)
-void ulaw2alaw(buffer, byteOffset, sampleCount)
-void ulaw2alaw(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount)
-byte alaw2ulaw(byte sample)
-void alaw2ulaw(buffer, byteOffset, sampleCount)
-void alaw2ulaw(inBuffer, inByteOffset, outBuffer, outByteOffset, sampleCount)
-
-*/
-
-public class TConversionTool {
-
- ///////////////// sign/byte-order conversion ///////////////////////////////////
-
- public static void convertSign8(byte[] buffer, int byteOffset, int sampleCount) {
- sampleCount+=byteOffset;
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]+=128;
- }
- }
-
- public static void swapOrder16(byte[] buffer, int byteOffset, int sampleCount) {
- int byteMax=sampleCount*2+byteOffset-1;
- int i=byteOffset;
- while (i<byteMax) {
- byte h=buffer[i];
- buffer[i]=buffer[++i];
- buffer[i++]=h;
- }
- }
-
- public static void swapOrder24(byte[] buffer, int byteOffset, int sampleCount) {
- int byteMax=sampleCount*3+byteOffset-2;
- int i=byteOffset;
- while (i<byteMax) {
- byte h=buffer[i];
- buffer[i]=buffer[++i+1];
- buffer[++i]=h;
- i++;
- }
- }
-
- public static void swapOrder32(byte[] buffer, int byteOffset, int sampleCount) {
- int byteMax=sampleCount*4+byteOffset-3;
- int i=byteOffset;
- while (i<byteMax) {
- byte h=buffer[i];
- buffer[i]=buffer[i+3];
- buffer[i+3]=h;
- i++;
- h=buffer[i];
- buffer[i]=buffer[++i];
- buffer[i++]=h;
- i++;
- }
- }
-
- public static void convertSign8(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount) {
- while (sampleCount>0) {
- outBuffer[outByteOffset++]=(byte)(inBuffer[inByteOffset++]+128);
- sampleCount--;
- }
- }
-
- public static void swapOrder16(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount) {
- while (sampleCount>0) {
- outBuffer[outByteOffset++]=inBuffer[inByteOffset+1];
- outBuffer[outByteOffset++]=inBuffer[inByteOffset++];
- inByteOffset++;
- sampleCount--;
- }
- }
-
- public static void swapOrder24(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount) {
- while (sampleCount>0) {
- outBuffer[outByteOffset++]=inBuffer[inByteOffset+2];
- outByteOffset++;
- outBuffer[outByteOffset++]=inBuffer[inByteOffset++];
- inByteOffset++;
- inByteOffset++;
- sampleCount--;
- }
- }
-
- public static void swapOrder32(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount) {
- while (sampleCount>0) {
- outBuffer[outByteOffset++]=inBuffer[inByteOffset+3];
- outBuffer[outByteOffset++]=inBuffer[inByteOffset+2];
- outBuffer[outByteOffset++]=inBuffer[inByteOffset+1];
- outBuffer[outByteOffset++]=inBuffer[inByteOffset++];
- inByteOffset++;
- inByteOffset++;
- inByteOffset++;
- sampleCount--;
- }
- }
-
-
- ///////////////// conversion functions for byte arrays ////////////////////////////
-
-
- /**
- * Converts 2 bytes to a signed sample of type <code>short</code>.
- * <p> This is a reference function.
- */
- public static short bytesToShort16(byte highByte, byte lowByte) {
- return (short) ((highByte<<8) | (lowByte & 0xFF));
- }
-
- /**
- * Converts 2 successive bytes starting at <code>byteOffset</code> in
- * <code>buffer</code> to a signed sample of type <code>short</code>.
- * <p>
- * For little endian, buffer[byteOffset] is interpreted as low byte,
- * whereas it is interpreted as high byte in big endian.
- * <p> This is a reference function.
- */
- public static short bytesToShort16(byte[] buffer, int byteOffset, boolean bigEndian) {
- return bigEndian?
- ((short) ((buffer[byteOffset]<<8) | (buffer[byteOffset+1] & 0xFF))):
- ((short) ((buffer[byteOffset+1]<<8) | (buffer[byteOffset] & 0xFF)));
- }
-
- /**
- * Converts 2 bytes to a signed integer sample with 16bit range.
- * <p> This is a reference function.
- */
- public static int bytesToInt16(byte highByte, byte lowByte) {
- return (highByte<<8) | (lowByte & 0xFF);
- }
-
- /**
- * Converts 2 successive bytes starting at <code>byteOffset</code> in
- * <code>buffer</code> to a signed integer sample with 16bit range.
- * <p>
- * For little endian, buffer[byteOffset] is interpreted as low byte,
- * whereas it is interpreted as high byte in big endian.
- * <p> This is a reference function.
- */
- public static int bytesToInt16(byte[] buffer, int byteOffset, boolean bigEndian) {
- return bigEndian?
- ((buffer[byteOffset]<<8) | (buffer[byteOffset+1] & 0xFF)):
- ((buffer[byteOffset+1]<<8) | (buffer[byteOffset] & 0xFF));
- }
-
- /**
- * Converts 3 successive bytes starting at <code>byteOffset</code> in
- * <code>buffer</code> to a signed integer sample with 24bit range.
- * <p>
- * For little endian, buffer[byteOffset] is interpreted as lowest byte,
- * whereas it is interpreted as highest byte in big endian.
- * <p> This is a reference function.
- */
- public static int bytesToInt24(byte[] buffer, int byteOffset, boolean bigEndian) {
- return bigEndian?
- ((buffer[byteOffset]<<16) // let Java handle sign-bit
- | ((buffer[byteOffset+1] & 0xFF)<<8) // inhibit sign-bit handling
- | (buffer[byteOffset+2] & 0xFF)):
- ((buffer[byteOffset+2]<<16) // let Java handle sign-bit
- | ((buffer[byteOffset+1] & 0xFF)<<8) // inhibit sign-bit handling
- | (buffer[byteOffset] & 0xFF));
- }
-
- /**
- * Converts a 4 successive bytes starting at <code>byteOffset</code> in
- * <code>buffer</code> to a signed 32bit integer sample.
- * <p>
- * For little endian, buffer[byteOffset] is interpreted as lowest byte,
- * whereas it is interpreted as highest byte in big endian.
- * <p> This is a reference function.
- */
- public static int bytesToInt32(byte[] buffer, int byteOffset, boolean bigEndian) {
- return bigEndian?
- ((buffer[byteOffset]<<24) // let Java handle sign-bit
- | ((buffer[byteOffset+1] & 0xFF)<<16) // inhibit sign-bit handling
- | ((buffer[byteOffset+2] & 0xFF)<<8) // inhibit sign-bit handling
- | (buffer[byteOffset+3] & 0xFF)):
- ((buffer[byteOffset+3]<<24) // let Java handle sign-bit
- | ((buffer[byteOffset+2] & 0xFF)<<16) // inhibit sign-bit handling
- | ((buffer[byteOffset+1] & 0xFF)<<8) // inhibit sign-bit handling
- | (buffer[byteOffset] & 0xFF));
- }
-
-
- /**
- * Converts a sample of type <code>short</code> to 2 bytes in an array.
- * <code>sample</code> is interpreted as signed (as Java does).
- * <p>
- * For little endian, buffer[byteOffset] is filled with low byte of sample,
- * and buffer[byteOffset+1] is filled with high byte of sample.
- * <p> For big endian, this is reversed.
- * <p> This is a reference function.
- */
- public static void shortToBytes16(short sample, byte[] buffer, int byteOffset, boolean bigEndian) {
- intToBytes16(sample, buffer, byteOffset, bigEndian);
- }
-
- /**
- * Converts a 16 bit sample of type <code>int</code> to 2 bytes in an array.
- * <code>sample</code> is interpreted as signed (as Java does).
- * <p>
- * For little endian, buffer[byteOffset] is filled with low byte of sample,
- * and buffer[byteOffset+1] is filled with high byte of sample + sign bit.
- * <p> For big endian, this is reversed.
- * <p> Before calling this function, it should be assured that <code>sample</code>
- * is in the 16bit range - it will not be clipped.
- * <p> This is a reference function.
- */
- public static void intToBytes16(int sample, byte[] buffer, int byteOffset, boolean bigEndian) {
- if (bigEndian) {
- buffer[byteOffset++]=(byte) (sample >> 8);
- buffer[byteOffset]=(byte) (sample & 0xFF);
- } else {
- buffer[byteOffset++]=(byte) (sample & 0xFF);
- buffer[byteOffset]=(byte) (sample >> 8);
- }
- }
-
- /**
- * Converts a 24 bit sample of type <code>int</code> to 3 bytes in an array.
- * <code>sample</code> is interpreted as signed (as Java does).
- * <p>
- * For little endian, buffer[byteOffset] is filled with low byte of sample,
- * and buffer[byteOffset+2] is filled with the high byte of sample + sign bit.
- * <p> For big endian, this is reversed.
- * <p> Before calling this function, it should be assured that <code>sample</code>
- * is in the 24bit range - it will not be clipped.
- * <p> This is a reference function.
- */
- public static void intToBytes24(int sample, byte[] buffer, int byteOffset, boolean bigEndian) {
- if (bigEndian) {
- buffer[byteOffset++]=(byte) (sample >> 16);
- buffer[byteOffset++]=(byte) ((sample >>> 8) & 0xFF);
- buffer[byteOffset]=(byte) (sample & 0xFF);
- } else {
- buffer[byteOffset++]=(byte) (sample & 0xFF);
- buffer[byteOffset++]=(byte) ((sample >>> 8) & 0xFF);
- buffer[byteOffset]=(byte) (sample >> 16);
- }
- }
-
-
- /**
- * Converts a 32 bit sample of type <code>int</code> to 4 bytes in an array.
- * <code>sample</code> is interpreted as signed (as Java does).
- * <p>
- * For little endian, buffer[byteOffset] is filled with lowest byte of sample,
- * and buffer[byteOffset+3] is filled with the high byte of sample + sign bit.
- * <p> For big endian, this is reversed.
- * <p> This is a reference function.
- */
- public static void intToBytes32(int sample, byte[] buffer, int byteOffset, boolean bigEndian) {
- if (bigEndian) {
- buffer[byteOffset++]=(byte) (sample >> 24);
- buffer[byteOffset++]=(byte) ((sample >>> 16) & 0xFF);
- buffer[byteOffset++]=(byte) ((sample >>> 8) & 0xFF);
- buffer[byteOffset]=(byte) (sample & 0xFF);
- } else {
- buffer[byteOffset++]=(byte) (sample & 0xFF);
- buffer[byteOffset++]=(byte) ((sample >>> 8) & 0xFF);
- buffer[byteOffset++]=(byte) ((sample >>> 16) & 0xFF);
- buffer[byteOffset]=(byte) (sample >> 24);
- }
- }
-
-
- /////////////////////// ULAW ///////////////////////////////////////////
-
- private static final boolean ZEROTRAP=true;
- private static final short BIAS=0x84;
- private static final int CLIP=32635;
- private static final int exp_lut1[] ={
- 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
- 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
- };
-
-
- /**
- * Converts a linear signed 16bit sample to a uLaw byte.
- * Ported to Java by fb.
- * <BR>Originally by:<BR>
- * Craig Reese: IDA/Supercomputing Research Center <BR>
- * Joe Campbell: Department of Defense <BR>
- * 29 September 1989 <BR>
- */
- public static byte linear2ulaw(int sample) {
- int sign, exponent, mantissa, ulawbyte;
-
- if (sample>32767) sample=32767;
- else if (sample<-32768) sample=-32768;
- /* Get the sample into sign-magnitude. */
- sign = (sample >> 8) & 0x80; /* set aside the sign */
- if (sign != 0) sample = -sample; /* get magnitude */
- if (sample > CLIP) sample = CLIP; /* clip the magnitude */
-
- /* Convert from 16 bit linear to ulaw. */
- sample = sample + BIAS;
- exponent = exp_lut1[(sample >> 7) & 0xFF];
- mantissa = (sample >> (exponent + 3)) & 0x0F;
- ulawbyte = ~(sign | (exponent << 4) | mantissa);
- if (ZEROTRAP)
- if (ulawbyte == 0) ulawbyte = 0x02; /* optional CCITT trap */
- return((byte) ulawbyte);
- }
-
- /* u-law to linear conversion table */
- private static short[] u2l = {
- -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
- -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764,
- -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,
- -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316,
- -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140,
- -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092,
- -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004,
- -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980,
- -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436,
- -1372, -1308, -1244, -1180, -1116, -1052, -988, -924,
- -876, -844, -812, -780, -748, -716, -684, -652,
- -620, -588, -556, -524, -492, -460, -428, -396,
- -372, -356, -340, -324, -308, -292, -276, -260,
- -244, -228, -212, -196, -180, -164, -148, -132,
- -120, -112, -104, -96, -88, -80, -72, -64,
- -56, -48, -40, -32, -24, -16, -8, 0,
- 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956,
- 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764,
- 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412,
- 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316,
- 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140,
- 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092,
- 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004,
- 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980,
- 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436,
- 1372, 1308, 1244, 1180, 1116, 1052, 988, 924,
- 876, 844, 812, 780, 748, 716, 684, 652,
- 620, 588, 556, 524, 492, 460, 428, 396,
- 372, 356, 340, 324, 308, 292, 276, 260,
- 244, 228, 212, 196, 180, 164, 148, 132,
- 120, 112, 104, 96, 88, 80, 72, 64,
- 56, 48, 40, 32, 24, 16, 8, 0
- };
- public static short ulaw2linear(byte ulawbyte) {
- return u2l[ulawbyte & 0xFF];
- }
-
-
-
- /**
- * Converts a buffer of signed 16bit big endian samples to uLaw.
- * The uLaw bytes overwrite the original 16 bit values.
- * The first byte-offset of the uLaw bytes is byteOffset.
- * It will be written sampleCount/2 bytes.
- */
- public static void pcm162ulaw(byte[] buffer, int byteOffset, int sampleCount, boolean bigEndian) {
- int shortIndex=byteOffset;
- int ulawIndex=shortIndex;
- if (bigEndian) {
- while (sampleCount>0) {
- buffer[ulawIndex++]=linear2ulaw
- (bytesToInt16(buffer[shortIndex], buffer[shortIndex+1]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- buffer[ulawIndex++]=linear2ulaw
- (bytesToInt16(buffer[shortIndex+1], buffer[shortIndex]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- }
- }
-
- /**
- * Fills outBuffer with ulaw samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount*2 bytes read from inBuffer;
- * There will be sampleCount <B>bytes</B> written to outBuffer.
- */
- public static void pcm162ulaw(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset,
- int sampleCount, boolean bigEndian) {
- int shortIndex=inByteOffset;
- int ulawIndex=outByteOffset;
- if (bigEndian) {
- while (sampleCount>0) {
- outBuffer[ulawIndex++]=linear2ulaw
- (bytesToInt16(inBuffer[shortIndex], inBuffer[shortIndex+1]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- outBuffer[ulawIndex++]=linear2ulaw
- (bytesToInt16(inBuffer[shortIndex+1], inBuffer[shortIndex]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- }
- }
-
- // TODO: either direct 8bit pcm to ulaw, or better conversion from 8bit to 16bit
- /**
- * Converts a buffer of 8bit samples to uLaw.
- * The uLaw bytes overwrite the original 8 bit values.
- * The first byte-offset of the uLaw bytes is byteOffset.
- * It will be written sampleCount bytes.
- */
- public static void pcm82ulaw(byte[] buffer, int byteOffset, int sampleCount, boolean signed) {
- sampleCount+=byteOffset;
- if (signed) {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=linear2ulaw(buffer[i] << 8);
- }
- } else {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=linear2ulaw(((byte) (buffer[i]+128)) << 8);
- }
- }
- }
-
- /**
- * Fills outBuffer with ulaw samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount <B>bytes</B> written to outBuffer.
- */
- public static void pcm82ulaw(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount, boolean signed) {
- int ulawIndex=outByteOffset;
- int pcmIndex=inByteOffset;
- if (signed) {
- while (sampleCount>0) {
- outBuffer[ulawIndex++]=linear2ulaw(inBuffer[pcmIndex++] << 8);
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- outBuffer[ulawIndex++]=linear2ulaw(((byte) (inBuffer[pcmIndex++]+128)) << 8);
- sampleCount--;
- }
- }
- }
-
- /**
- * Fills outBuffer with pcm signed 16 bit samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount bytes read from inBuffer;
- * There will be sampleCount*2 bytes written to outBuffer.
- */
- public static void ulaw2pcm16(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset,
- int sampleCount, boolean bigEndian) {
- int shortIndex=outByteOffset;
- int ulawIndex=inByteOffset;
- while (sampleCount>0) {
- intToBytes16
- (u2l[inBuffer[ulawIndex++] & 0xFF], outBuffer, shortIndex++, bigEndian);
- shortIndex++;
- sampleCount--;
- }
- }
-
-
- // TODO: either direct 8bit pcm to ulaw, or better conversion from 8bit to 16bit
- /**
- * Inplace-conversion of a ulaw buffer to 8bit samples.
- * The 8bit bytes overwrite the original ulaw values.
- * The first byte-offset of the uLaw bytes is byteOffset.
- * It will be written sampleCount bytes.
- */
- public static void ulaw2pcm8(byte[] buffer, int byteOffset, int sampleCount, boolean signed) {
- sampleCount+=byteOffset;
- if (signed) {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=(byte) ((u2l[buffer[i] & 0xFF] >> 8) & 0xFF);
- }
- } else {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=(byte) ((u2l[buffer[i] & 0xFF]>>8)+128);
- }
- }
- }
-
- /**
- * Fills outBuffer with ulaw samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount <B>bytes</B> written to outBuffer.
- */
- public static void ulaw2pcm8(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount, boolean signed) {
- int ulawIndex=inByteOffset;
- int pcmIndex=outByteOffset;
- if (signed) {
- while (sampleCount>0) {
- outBuffer[pcmIndex++]=
- (byte) ((u2l[inBuffer[ulawIndex++] & 0xFF] >> 8) & 0xFF);
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- outBuffer[pcmIndex++]=
- (byte) ((u2l[inBuffer[ulawIndex++] & 0xFF]>>8)+128);
- sampleCount--;
- }
- }
- }
-
-
- //////////////////// ALAW ////////////////////////////
-
-
- /*
- * This source code is a product of Sun Microsystems, Inc. and is provided
- * for unrestricted use. Users may copy or modify this source code without
- * charge.
- *
- * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
- *
- * linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
- *
- * Linear Input Code Compressed Code
- * ------------------------ ---------------
- * 0000000wxyza 000wxyz
- * 0000001wxyza 001wxyz
- * 000001wxyzab 010wxyz
- * 00001wxyzabc 011wxyz
- * 0001wxyzabcd 100wxyz
- * 001wxyzabcde 101wxyz
- * 01wxyzabcdef 110wxyz
- * 1wxyzabcdefg 111wxyz
- *
- * For further information see John C. Bellamy's Digital Telephony, 1982,
- * John Wiley & Sons, pps 98-111 and 472-476.
- */
- private static final byte QUANT_MASK = 0xf; /* Quantization field mask. */
- private static final byte SEG_SHIFT = 4; /* Left shift for segment number. */
- private static final short[] seg_end = {
- 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF
- };
-
- public static byte linear2alaw(short pcm_val) /* 2's complement (16-bit range) */
- {
- byte mask;
- byte seg=8;
- byte aval;
-
- if (pcm_val >= 0) {
- mask = (byte) 0xD5; /* sign (7th) bit = 1 */
- } else {
- mask = 0x55; /* sign bit = 0 */
- pcm_val = (short) (-pcm_val - 8);
- }
-
- /* Convert the scaled magnitude to segment number. */
- for (int i = 0; i < 8; i++) {
- if (pcm_val <= seg_end[i]) {
- seg=(byte) i;
- break;
- }
- }
-
- /* Combine the sign, segment, and quantization bits. */
- if (seg >= 8) /* out of range, return maximum value. */
- return (byte) ((0x7F ^ mask) & 0xFF);
- else {
- aval = (byte) (seg << SEG_SHIFT);
- if (seg < 2)
- aval |= (pcm_val >> 4) & QUANT_MASK;
- else
- aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
- return (byte) ((aval ^ mask) & 0xFF);
- }
- }
-
- private static short[] a2l = {
- -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
- -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
- -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
- -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
- -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944,
- -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136,
- -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472,
- -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568,
- -344, -328, -376, -360, -280, -264, -312, -296,
- -472, -456, -504, -488, -408, -392, -440, -424,
- -88, -72, -120, -104, -24, -8, -56, -40,
- -216, -200, -248, -232, -152, -136, -184, -168,
- -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
- -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
- -688, -656, -752, -720, -560, -528, -624, -592,
- -944, -912, -1008, -976, -816, -784, -880, -848,
- 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
- 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
- 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
- 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
- 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
- 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
- 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
- 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
- 344, 328, 376, 360, 280, 264, 312, 296,
- 472, 456, 504, 488, 408, 392, 440, 424,
- 88, 72, 120, 104, 24, 8, 56, 40,
- 216, 200, 248, 232, 152, 136, 184, 168,
- 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
- 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
- 688, 656, 752, 720, 560, 528, 624, 592,
- 944, 912, 1008, 976, 816, 784, 880, 848
- };
-
- public static short alaw2linear(byte ulawbyte) {
- return a2l[ulawbyte & 0xFF];
- }
-
- /**
- * Converts a buffer of signed 16bit big endian samples to uLaw.
- * The uLaw bytes overwrite the original 16 bit values.
- * The first byte-offset of the uLaw bytes is byteOffset.
- * It will be written sampleCount/2 bytes.
- */
- public static void pcm162alaw(byte[] buffer, int byteOffset, int sampleCount, boolean bigEndian) {
- int shortIndex=byteOffset;
- int alawIndex=shortIndex;
- if (bigEndian) {
- while (sampleCount>0) {
- buffer[alawIndex++]=
- linear2alaw(bytesToShort16
- (buffer[shortIndex], buffer[shortIndex+1]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- buffer[alawIndex++]=
- linear2alaw(bytesToShort16
- (buffer[shortIndex+1], buffer[shortIndex]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- }
- }
-
- /**
- * Fills outBuffer with alaw samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount*2 bytes read from inBuffer;
- * There will be sampleCount <B>bytes</B> written to outBuffer.
- */
- public static void pcm162alaw(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount, boolean bigEndian) {
- int shortIndex=inByteOffset;
- int alawIndex=outByteOffset;
- if (bigEndian) {
- while (sampleCount>0) {
- outBuffer[alawIndex++]=linear2alaw
- (bytesToShort16(inBuffer[shortIndex], inBuffer[shortIndex+1]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- outBuffer[alawIndex++]=linear2alaw
- (bytesToShort16(inBuffer[shortIndex+1], inBuffer[shortIndex]));
- shortIndex++;
- shortIndex++;
- sampleCount--;
- }
- }
- }
-
- /**
- * Converts a buffer of 8bit samples to alaw.
- * The alaw bytes overwrite the original 8 bit values.
- * The first byte-offset of the aLaw bytes is byteOffset.
- * It will be written sampleCount bytes.
- */
- public static void pcm82alaw(byte[] buffer, int byteOffset, int sampleCount, boolean signed) {
- sampleCount+=byteOffset;
- if (signed) {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=linear2alaw((short) (buffer[i] << 8));
- }
- } else {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=linear2alaw((short) (((byte) (buffer[i]+128)) << 8));
- }
- }
- }
-
- /**
- * Fills outBuffer with alaw samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount <B>bytes</B> written to outBuffer.
- */
- public static void pcm82alaw(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount, boolean signed) {
- int alawIndex=outByteOffset;
- int pcmIndex=inByteOffset;
- if (signed) {
- while (sampleCount>0) {
- outBuffer[alawIndex++]=
- linear2alaw((short) (inBuffer[pcmIndex++] << 8));
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- outBuffer[alawIndex++]=
- linear2alaw((short) (((byte) (inBuffer[pcmIndex++]+128)) << 8));
- sampleCount--;
- }
- }
- }
-
-
-
- /**
- * Converts an alaw buffer to 8bit pcm samples
- * The 8bit bytes overwrite the original alaw values.
- * The first byte-offset of the aLaw bytes is byteOffset.
- * It will be written sampleCount bytes.
- */
- public static void alaw2pcm8(byte[] buffer, int byteOffset, int sampleCount, boolean signed) {
- sampleCount+=byteOffset;
- if (signed) {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=(byte) ((a2l[buffer[i] & 0xFF] >> 8) & 0xFF);
- }
- } else {
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=(byte) ((a2l[buffer[i] & 0xFF]>>8)+128);
- }
- }
- }
-
- /**
- * Fills outBuffer with alaw samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount <B>bytes</B> written to outBuffer.
- */
- public static void alaw2pcm8(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount, boolean signed) {
- int alawIndex=inByteOffset;
- int pcmIndex=outByteOffset;
- if (signed) {
- while (sampleCount>0) {
- outBuffer[pcmIndex++]=
- (byte) ((a2l[inBuffer[alawIndex++] & 0xFF] >> 8) & 0xFF);
- sampleCount--;
- }
- } else {
- while (sampleCount>0) {
- outBuffer[pcmIndex++]=
- (byte) ((a2l[inBuffer[alawIndex++] & 0xFF]>>8)+128);
- sampleCount--;
- }
- }
- }
-
- /**
- * Fills outBuffer with pcm signed 16 bit samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount bytes read from inBuffer;
- * There will be sampleCount*2 bytes written to outBuffer.
- */
- public static void alaw2pcm16(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset,
- int sampleCount, boolean bigEndian) {
- int shortIndex=outByteOffset;
- int alawIndex=inByteOffset;
- while (sampleCount>0) {
- intToBytes16
- (a2l[inBuffer[alawIndex++] & 0xFF], outBuffer, shortIndex++, bigEndian);
- shortIndex++;
- sampleCount--;
- }
- }
-
- //////////////////////// cross conversion alaw <-> ulaw ////////////////////////////////////////
-
- private static byte[] u2a = {
- -86, -85, -88, -87, -82, -81, -84, -83, -94, -93, -96, -95, -90, -89, -92, -91,
- -70, -69, -72, -71, -66, -65, -68, -67, -78, -77, -80, -79, -74, -73, -76, -75,
- -118, -117, -120, -119, -114, -113, -116, -115, -126, -125, -128, -127, -122, -121, -124, -123,
- -101, -104, -103, -98, -97, -100, -99, -110, -109, -112, -111, -106, -105, -108, -107, -22,
- -24, -23, -18, -17, -20, -19, -30, -29, -32, -31, -26, -25, -28, -27, -6, -8,
- -2, -1, -4, -3, -14, -13, -16, -15, -10, -9, -12, -11, -53, -55, -49, -51,
- -62, -61, -64, -63, -58, -57, -60, -59, -38, -37, -40, -39, -34, -33, -36, -35,
- -46, -46, -45, -45, -48, -48, -47, -47, -42, -42, -41, -41, -44, -44, -43, -43,
- 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37,
- 58, 59, 56, 57, 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53,
- 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5,
- 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, 106,
- 104, 105, 110, 111, 108, 109, 98, 99, 96, 97, 102, 103, 100, 101, 122, 120,
- 126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117, 75, 73, 79, 77,
- 66, 67, 64, 65, 70, 71, 68, 69, 90, 91, 88, 89, 94, 95, 92, 93,
- 82, 82, 83, 83, 80, 80, 81, 81, 86, 86, 87, 87, 84, 84, 85, 85,
- };
-
- public static byte ulaw2alaw(byte sample) {
- return u2a[sample & 0xFF];
- }
-
- /**
- * Converts a buffer of uLaw samples to aLaw.
- */
- public static void ulaw2alaw(byte[] buffer, int byteOffset, int sampleCount) {
- sampleCount+=byteOffset;
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=u2a[buffer[i] & 0xFF];
- }
- }
-
- /**
- * Fills outBuffer with alaw samples.
- */
- public static void ulaw2alaw(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount) {
- int ulawIndex=outByteOffset;
- int alawIndex=inByteOffset;
- while (sampleCount>0) {
- outBuffer[alawIndex++]=u2a[inBuffer[ulawIndex++] & 0xFF];
- sampleCount--;
- }
- }
-
- private static byte[] a2u = {
- -86, -85, -88, -87, -82, -81, -84, -83, -94, -93, -96, -95, -90, -89, -92, -91,
- -71, -70, -73, -72, -67, -66, -69, -68, -79, -78, -80, -80, -75, -74, -77, -76,
- -118, -117, -120, -119, -114, -113, -116, -115, -126, -125, -128, -127, -122, -121, -124, -123,
- -102, -101, -104, -103, -98, -97, -100, -99, -110, -109, -112, -111, -106, -105, -108, -107,
- -30, -29, -32, -31, -26, -25, -28, -27, -35, -35, -36, -36, -33, -33, -34, -34,
- -12, -10, -16, -14, -4, -2, -8, -6, -22, -21, -24, -23, -18, -17, -20, -19,
- -56, -55, -58, -57, -52, -51, -54, -53, -64, -63, -65, -65, -60, -59, -62, -61,
- -42, -41, -44, -43, -38, -37, -40, -39, -49, -49, -50, -50, -46, -45, -48, -47,
- 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37,
- 57, 58, 55, 56, 61, 62, 59, 60, 49, 50, 48, 48, 53, 54, 51, 52,
- 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5,
- 26, 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21,
- 98, 99, 96, 97, 102, 103, 100, 101, 93, 93, 92, 92, 95, 95, 94, 94,
- 116, 118, 112, 114, 124, 126, 120, 122, 106, 107, 104, 105, 110, 111, 108, 109,
- 72, 73, 70, 71, 76, 77, 74, 75, 64, 65, 63, 63, 68, 69, 66, 67,
- 86, 87, 84, 85, 90, 91, 88, 89, 79, 79, 78, 78, 82, 83, 80, 81,
- };
-
- public static byte alaw2ulaw(byte sample) {
- return a2u[sample & 0xFF];
- }
-
- /**
- * Converts a buffer of aLaw samples to uLaw.
- * The uLaw bytes overwrite the original aLaw values.
- * The first byte-offset of the uLaw bytes is byteOffset.
- * It will be written sampleCount bytes.
- */
- public static void alaw2ulaw(byte[] buffer, int byteOffset, int sampleCount) {
- sampleCount+=byteOffset;
- for (int i=byteOffset; i<sampleCount; i++) {
- buffer[i]=a2u[buffer[i] & 0xFF];
- }
- }
-
- /**
- * Fills outBuffer with ulaw samples.
- * reading starts from inBuffer[inByteOffset].
- * writing starts at outBuffer[outByteOffset].
- * There will be sampleCount <B>bytes</B> written to outBuffer.
- */
- public static void alaw2ulaw(byte[] inBuffer, int inByteOffset,
- byte[] outBuffer, int outByteOffset, int sampleCount) {
- int ulawIndex=outByteOffset;
- int alawIndex=inByteOffset;
- while (sampleCount>0) {
- outBuffer[ulawIndex++]=a2u[inBuffer[alawIndex++] & 0xFF];
- sampleCount--;
- }
- }
-
-
- //////////////////////// high level methods /////////////////////////////////////////////////
-
- /*
- * !! Here, unlike other functions in this class, the length is
- * in bytes rather than samples !!
- */
- public static void changeOrderOrSign(byte[] buffer, int nOffset,
- int nByteLength, int nBytesPerSample) {
- switch (nBytesPerSample) {
- case 1:
- convertSign8(buffer, nOffset, nByteLength);
- break;
-
- case 2:
- swapOrder16(buffer, nOffset, nByteLength / 2);
- break;
-
- case 3:
- swapOrder24(buffer, nOffset, nByteLength / 3);
- break;
-
- case 4:
- swapOrder32(buffer, nOffset, nByteLength / 4);
- break;
- }
- }
-
-
-
- /*
- * !! Here, unlike other functions in this class, the length is
- * in bytes rather than samples !!
- */
- public static void changeOrderOrSign(
- byte[] inBuffer, int nInOffset,
- byte[] outBuffer, int nOutOffset,
- int nByteLength, int nBytesPerSample) {
- switch (nBytesPerSample) {
- case 1:
- convertSign8(
- inBuffer, nInOffset,
- outBuffer, nOutOffset,
- nByteLength);
- break;
-
- case 2:
- swapOrder16(
- inBuffer, nInOffset,
- outBuffer, nOutOffset,
- nByteLength / 2);
- break;
-
- case 3:
- swapOrder24(
- inBuffer, nInOffset,
- outBuffer, nOutOffset,
- nByteLength / 3);
- break;
-
- case 4:
- swapOrder32(
- inBuffer, nInOffset,
- outBuffer, nOutOffset,
- nByteLength / 4);
- break;
- }
- }
-
-
- ///////////////// Annexe: how the arrays were created. //////////////////////////////////
-
- /*
- * Converts a uLaw byte to a linear signed 16bit sample.
- * Ported to Java by fb.
- * <BR>Originally by:<BR>
- *
- * Craig Reese: IDA/Supercomputing Research Center <BR>
- * 29 September 1989 <BR>
- *
- * References: <BR>
- * <OL>
- * <LI>CCITT Recommendation G.711 (very difficult to follow)</LI>
- * <LI>MIL-STD-188-113,"Interoperability and Performance Standards
- * for Analog-to_Digital Conversion Techniques,"
- * 17 February 1987</LI>
- * </OL>
- */
- /*
- private static final int exp_lut2[] = {
- 0,132,396,924,1980,4092,8316,16764
-};
-
- public static short _ulaw2linear(int ulawbyte) {
- int sign, exponent, mantissa, sample;
-
- ulawbyte = ~ulawbyte;
- sign = (ulawbyte & 0x80);
- exponent = (ulawbyte >> 4) & 0x07;
- mantissa = ulawbyte & 0x0F;
- sample = exp_lut2[exponent] + (mantissa << (exponent + 3));
- if (sign != 0) sample = -sample;
- return((short) sample);
-}*/
-
-
- /* u- to A-law conversions: copied from CCITT G.711 specifications */
- /*
- private static byte[] _u2a = {
- 1, 1, 2, 2, 3, 3, 4, 4,
- 5, 5, 6, 6, 7, 7, 8, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 27, 29, 31, 33, 34, 35, 36,
- 37, 38, 39, 40, 41, 42, 43, 44,
- 46, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62,
- 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79,
- 81, 82, 83, 84, 85, 86, 87, 88,
- 89, 90, 91, 92, 93, 94, 95, 96,
- 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 107, 108, 109, 110, 111, 112,
- 113, 114, 115, 116, 117, 118, 119, 120,
- 121, 122, 123, 124, 125, 126, 127, (byte) 128};
- */
-
- /* u-law to A-law conversion */
- /*
- * This source code is a product of Sun Microsystems, Inc. and is provided
- * for unrestricted use. Users may copy or modify this source code without
- * charge.
- */
- /*
- public static byte _ulaw2alaw(byte sample) {
- sample &= 0xff;
- return (byte) (((sample & 0x80)!=0) ? (0xD5 ^ (_u2a[(0x7F ^ sample) & 0x7F] - 1)) :
- (0x55 ^ (_u2a[(0x7F ^ sample) & 0x7F] - 1)));
-}*/
-
- /* A- to u-law conversions */
- /*
- private static byte[] _a2u = {
- 1, 3, 5, 7, 9, 11, 13, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 32, 33, 33, 34, 34, 35, 35,
- 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 48, 49, 49,
- 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 64,
- 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 79,
- 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103,
- 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127};
- */
-
- /*
- * This source code is a product of Sun Microsystems, Inc. and is provided
- * for unrestricted use. Users may copy or modify this source code without
- * charge.
- */
- /*
- public static byte _alaw2ulaw(byte sample) {
- sample &= 0xff;
- return (byte) (((sample & 0x80)!=0) ? (0xFF ^ _a2u[(sample ^ 0xD5) & 0x7F]) :
- (0x7F ^ _a2u[(sample ^ 0x55) & 0x7F]));
-}
-
- public static void print_a2u() {
- System.out.println("\tprivate static byte[] a2u = {");
- for (int i=-128; i<128; i++) {
- if (((i+128) % 16)==0) {
- System.out.print("\t\t");
- }
- byte b=(byte) i;
- System.out.print(_alaw2ulaw(b)+", ");
- if (((i+128) % 16)==15) {
- System.out.println("");
- }
-}
- System.out.println("\t};");
-}
-
- public static void print_u2a() {
- System.out.println("\tprivate static byte[] u2a = {");
- for (int i=-128; i<128; i++) {
- if (((i+128) % 16)==0) {
- System.out.print("\t\t");
- }
- byte b=(byte) i;
- System.out.print(_ulaw2alaw(b)+", ");
- if (((i+128) % 16)==15) {
- System.out.println("");
- }
-}
- System.out.println("\t};");
-}
- */
-
-}
-
-
-/*** TConversionTool.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/TVolumeUtils.java b/songdbj/org/tritonus/share/sampled/TVolumeUtils.java
deleted file mode 100644
index 0eaf1388da..0000000000
--- a/songdbj/org/tritonus/share/sampled/TVolumeUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * TVolumeUtils.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled;
-
-
-
-public class TVolumeUtils
-{
- private static final double FACTOR1 = 20.0 / Math.log(10.0);
- private static final double FACTOR2 = 1 / 20.0;
-
-
-
- public static double lin2log(double dLinear)
- {
- return FACTOR1 * Math.log(dLinear);
- }
-
-
-
- public static double log2lin(double dLogarithmic)
- {
- return Math.pow(10.0, dLogarithmic * FACTOR2);
- }
-}
-
-
-
-/*** TVolumeUtils.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/TAsynchronousFilteredAudioInputStream.java b/songdbj/org/tritonus/share/sampled/convert/TAsynchronousFilteredAudioInputStream.java
deleted file mode 100644
index 83349439eb..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/TAsynchronousFilteredAudioInputStream.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * TAsynchronousFilteredAudioInputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999, 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.convert;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.TCircularBuffer;
-
-
-
-/** Base class for asynchronus converters.
- This class serves as base class for
- converters that do not have a fixed
- ratio between the size of a block of input
- data and the size of a block of output data.
- These types of converters therefore need an
- internal buffer, which is realized in this
- class.
-
- @author Matthias Pfisterer
-*/
-public abstract class TAsynchronousFilteredAudioInputStream
-extends TAudioInputStream
-implements TCircularBuffer.Trigger
-{
- private static final int DEFAULT_BUFFER_SIZE = 327670;
- private static final int DEFAULT_MIN_AVAILABLE = 4096;
- private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
-
-
- private TCircularBuffer m_circularBuffer;
- private int m_nMinAvailable;
- private byte[] m_abSingleByte;
-
-
-
- /** Constructor.
- This constructor uses the default buffer size and the default
- min available amount.
-
- @param lLength length of this stream in frames. May be
- AudioSystem.NOT_SPECIFIED.
- */
- public TAsynchronousFilteredAudioInputStream(AudioFormat outputFormat, long lLength)
- {
- this(outputFormat, lLength,
- DEFAULT_BUFFER_SIZE,
- DEFAULT_MIN_AVAILABLE);
- }
-
-
-
- /** Constructor.
- With this constructor, the buffer size and the minimum
- available amount can be specified as parameters.
-
- @param lLength length of this stream in frames. May be
- AudioSystem.NOT_SPECIFIED.
-
- @param nBufferSize size of the circular buffer in bytes.
- */
- public TAsynchronousFilteredAudioInputStream(
- AudioFormat outputFormat, long lLength,
- int nBufferSize,
- int nMinAvailable)
- {
- /* The usage of a ByteArrayInputStream is a hack.
- * (the infamous "JavaOne hack", because I did it on June
- * 6th 2000 in San Francisco, only hours before a
- * JavaOne session where I wanted to show mp3 playback
- * with Java Sound.) It is necessary because in the FCS
- * version of the Sun jdk1.3, the constructor of
- * AudioInputStream throws an exception if its first
- * argument is null. So we have to pass a dummy non-null
- * value.
- */
- super(new ByteArrayInputStream(EMPTY_BYTE_ARRAY),
- outputFormat,
- lLength);
- if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.<init>(): begin"); }
- m_circularBuffer = new TCircularBuffer(
- nBufferSize,
- false, // blocking read
- true, // blocking write
- this); // trigger
- m_nMinAvailable = nMinAvailable;
- if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.<init>(): end"); }
- }
-
-
- /** Returns the circular buffer.
- */
- protected TCircularBuffer getCircularBuffer()
- {
- return m_circularBuffer;
- }
-
-
-
- /** Check if writing more data to the circular buffer is recommanded.
- This checks the available write space in the circular buffer
- against the minimum available property. If the available write
- space is greater than th minimum available property, more
- writing is encouraged, so this method returns true.
- Note that this is only a hint to subclasses. However,
- it is an important hint.
-
- @return true if more writing to the circular buffer is
- recommanden. Otherwise, false is returned.
- */
- protected boolean writeMore()
- {
- return getCircularBuffer().availableWrite() > m_nMinAvailable;
- }
-
-
-
- public int read()
- throws IOException
- {
- // if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.read(): begin"); }
- int nByte = -1;
- if (m_abSingleByte == null)
- {
- m_abSingleByte = new byte[1];
- }
- int nReturn = read(m_abSingleByte);
- if (nReturn == -1)
- {
- nByte = -1;
- }
- else
- {
- //$$fb 2001-04-14 nobody really knows that...
- nByte = m_abSingleByte[0] & 0xFF;
- }
- // if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.read(): end"); }
- return nByte;
- }
-
-
-
- public int read(byte[] abData)
- throws IOException
- {
- if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.read(byte[]): begin"); }
- int nRead = read(abData, 0, abData.length);
- if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.read(byte[]): end"); }
- return nRead;
- }
-
-
-
- public int read(byte[] abData, int nOffset, int nLength)
- throws IOException
- {
- if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.read(byte[], int, int): begin"); }
- //$$fb 2001-04-22: this returns at maximum circular buffer
- // length. This is not very efficient...
- //$$fb 2001-04-25: we should check that we do not exceed getFrameLength() !
- int nRead = m_circularBuffer.read(abData, nOffset, nLength);
- if (TDebug.TraceAudioConverter) { TDebug.out("TAsynchronousFilteredAudioInputStream.read(byte[], int, int): end"); }
- return nRead;
- }
-
-
-
- public long skip(long lSkip)
- throws IOException
- {
- // TODO: this is quite inefficient
- for (long lSkipped = 0; lSkipped < lSkip; lSkipped++)
- {
- int nReturn = read();
- if (nReturn == -1)
- {
- return lSkipped;
- }
- }
- return lSkip;
- }
-
-
-
- public int available()
- throws IOException
- {
- return m_circularBuffer.availableRead();
- }
-
-
-
- public void close()
- throws IOException
- {
- m_circularBuffer.close();
- }
-
-
-
- public boolean markSupported()
- {
- return false;
- }
-
-
-
- public void mark(int nReadLimit)
- {
- }
-
-
-
- public void reset()
- throws IOException
- {
- throw new IOException("mark not supported");
- }
-}
-
-
-
-/*** TAsynchronousFilteredAudioInputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java b/songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java
deleted file mode 100644
index d84530e115..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/TAudioInputStream.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * TAudioInputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2003 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.convert;
-
-import java.io.InputStream;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-
-
-/** AudioInputStream base class. This class implements "dynamic"
- properties. "Dynamic" properties are properties that may change
- during the life time of the objects. This is typically used to
- pass information like the current frame number, volume of subbands
- and similar values. "Dynamic" properties are different from
- properties in AudioFormat and AudioFileFormat, which are
- considered "static", as they aren't allowed to change after
- creating of the object, thereby maintaining the immutable
- character of these classes.
-*/
-
-public class TAudioInputStream
-extends AudioInputStream
-{
- private Map<String, Object> m_properties;
- private Map<String, Object> m_unmodifiableProperties;
-
-
- /** Constructor without properties.
- Creates an empty properties map.
- */
- public TAudioInputStream(InputStream inputStream,
- AudioFormat audioFormat,
- long lLengthInFrames)
- {
- super(inputStream, audioFormat, lLengthInFrames);
- initMaps(new HashMap<String, Object>());
- }
-
-
- /** Constructor with properties.
- The passed properties map is not copied. This allows subclasses
- to change values in the map after creation, and the changes are
- reflected in the map the application program can obtain.
- */
- public TAudioInputStream(InputStream inputStream,
- AudioFormat audioFormat,
- long lLengthInFrames,
- Map<String, Object> properties)
- {
- super(inputStream, audioFormat, lLengthInFrames);
- initMaps(properties);
- }
-
-
- private void initMaps(Map<String, Object> properties)
- {
- /* Here, we make a shallow copy of the map. It's unclear if this
- is sufficient (of if a deep copy should be made).
- */
- m_properties = properties;
- m_unmodifiableProperties = Collections.unmodifiableMap(m_properties);
- }
-
-
- /** Obtain a Map containing the properties. This method returns a
- Map that cannot be modified by the application program, but
- reflects changes to the map made by the implementation.
-
- @return a map containing the properties.
- */
- public Map<String, Object> properties()
- {
- return m_unmodifiableProperties;
- }
-
-
- /** Set a property. Unlike in AudioFormat and AudioFileFormat,
- this method may be used anywhere by subclasses - it is not
- restricted to be used in the constructor.
- */
- protected void setProperty(String key, Object value)
- {
- m_properties.put(key, value);
- }
-}
-
-
-
-/*** TAudioInputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/TEncodingFormatConversionProvider.java b/songdbj/org/tritonus/share/sampled/convert/TEncodingFormatConversionProvider.java
deleted file mode 100644
index 6b83403c43..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/TEncodingFormatConversionProvider.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * TEncodingFormatConversionProvider.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.convert;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.ArraySet;
-
-
-// this class depends on handling of AudioSystem.NOT_SPECIFIED in AudioFormat.matches()
-
-/**
- * This is a base class for FormatConversionProviders that only
- * change the encoding, i.e. they never
- * <ul>
- * <li> change the sample size in bits without changing the encoding
- * <li> change the sample rate
- * <li> change the number of channels
- * </ul>
- * <p>It is assumed that each source format can be encoded to all
- * target formats.
- * <p>In the sourceFormats and targetFormats collections that are passed to
- * the constructor of this class, fields may be set to AudioSystem.NOT_SPECIFIED.
- * This means that it handles all values of that field, but cannot change it.
- * <p>This class prevents that a conversion is done (e.g. for sample rates),
- * because the overriding class specified AudioSystem.NOT_SPECIFIED as sample rate,
- * meaning it handles all sample rates.
- * <p>Overriding classes must implement at least
- * <code>AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)</code>
- * and provide a constructor that calls the protected constructor of this class.
- *
- * @author Florian Bomers
- */
-public abstract class TEncodingFormatConversionProvider
-extends TSimpleFormatConversionProvider
-{
- protected TEncodingFormatConversionProvider(
- Collection<AudioFormat> sourceFormats,
- Collection<AudioFormat> targetFormats)
- {
- super(sourceFormats, targetFormats);
- }
-
-
-
- /**
- * This implementation assumes that the converter can convert
- * from each of its source formats to each of its target
- * formats. If this is not the case, the converter has to
- * override this method.
- * <p>When conversion is supported, for every target encoding,
- * the fields sample size in bits, channels and sample rate are checked:
- * <ul>
- * <li>When a field in both the source and target format is AudioSystem.NOT_SPECIFIED,
- * one instance of that targetFormat is returned with this field set to AudioSystem.NOT_SPECIFIED.
- * <li>When a field in sourceFormat is set and it is AudioSystem.NOT_SPECIFIED in the target format,
- * the value of the field of source format is set in the returned format.
- * <li>The same applies for the other way round.
- * </ul>
- * For this, <code>replaceNotSpecified(sourceFormat, targetFormat)</code> in the base
- * class TSimpleFormatConversionProvider is used - and accordingly, the frameSize
- * is recalculated with <code>getFrameSize(...)</code> if a field with AudioSystem.NOT_SPECIFIED
- * is replaced. Inheriting classes may wish to override this method if the
- * default mode of calculating the frame size is not appropriate.
- */
- public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) {
- if (TDebug.TraceAudioConverter) {
- TDebug.out(">TEncodingFormatConversionProvider.getTargetFormats(AudioFormat.Encoding, AudioFormat):");
- TDebug.out("checking if conversion possible");
- TDebug.out("from: " + sourceFormat);
- TDebug.out("to: " + targetEncoding);
- }
- if (isConversionSupported(targetEncoding, sourceFormat)) {
- // TODO: check that no duplicates may occur...
- ArraySet<AudioFormat> result=new ArraySet<AudioFormat>();
- Iterator<AudioFormat> iterator = getCollectionTargetFormats().iterator();
- while (iterator.hasNext()) {
- AudioFormat targetFormat = iterator.next();
- targetFormat=replaceNotSpecified(sourceFormat, targetFormat);
- result.add(targetFormat);
- }
- if (TDebug.TraceAudioConverter) {
- TDebug.out("< returning "+result.size()+" elements.");
- }
- return result.toArray(EMPTY_FORMAT_ARRAY);
- } else {
- if (TDebug.TraceAudioConverter) {
- TDebug.out("< returning empty array.");
- }
- return EMPTY_FORMAT_ARRAY;
- }
- }
-
-}
-
-/*** TEncodingFormatConversionProvider.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/TFormatConversionProvider.java b/songdbj/org/tritonus/share/sampled/convert/TFormatConversionProvider.java
deleted file mode 100644
index eaec65bb06..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/TFormatConversionProvider.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * TFormatConversionProvider.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999, 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.convert;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.spi.FormatConversionProvider;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.AudioFormats;
-
-
-
-/** Base class for all conversion providers of Tritonus.
- *
- * @author Matthias Pfisterer
- */
-public abstract class TFormatConversionProvider
-extends FormatConversionProvider
-{
- protected static final AudioFormat.Encoding[] EMPTY_ENCODING_ARRAY = new AudioFormat.Encoding[0];
- protected static final AudioFormat[] EMPTY_FORMAT_ARRAY = new AudioFormat[0];
-
-
-
- // $$fb2000-10-04: use AudioSystem.NOT_SPECIFIED for all fields.
- public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream audioInputStream)
- {
- AudioFormat sourceFormat = audioInputStream.getFormat();
- AudioFormat targetFormat = new AudioFormat(
- targetEncoding,
- AudioSystem.NOT_SPECIFIED, // sample rate
- AudioSystem.NOT_SPECIFIED, // sample size in bits
- AudioSystem.NOT_SPECIFIED, // channels
- AudioSystem.NOT_SPECIFIED, // frame size
- AudioSystem.NOT_SPECIFIED, // frame rate
- sourceFormat.isBigEndian()); // big endian
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out("TFormatConversionProvider.getAudioInputStream(AudioFormat.Encoding, AudioInputStream):");
- TDebug.out("trying to convert to " + targetFormat);
- }
- return getAudioInputStream(targetFormat, audioInputStream);
- }
-
-
-
- /**
- * WARNING: this method uses <code>getTargetFormats(AudioFormat.Encoding, AudioFormat)</code>
- * which may create infinite loops if the latter is overwritten.
- * <p>
- * This method is overwritten here to make use of org.tritonus.share.sampled.AudioFormats.matches
- * and is considered temporary until AudioFormat.matches is corrected in the JavaSound API.
- */
- /* $$mp: if we decide to use getMatchingFormat(), this method should be
- implemented by simply calling getMatchingFormat() and comparing the
- result against null.
- */
- public boolean isConversionSupported(
- AudioFormat targetFormat,
- AudioFormat sourceFormat)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(">TFormatConversionProvider.isConversionSupported(AudioFormat, AudioFormat):");
- TDebug.out("class: "+getClass().getName());
- TDebug.out("checking if conversion possible");
- TDebug.out("from: " + sourceFormat);
- TDebug.out("to: " + targetFormat);
- }
- AudioFormat[] aTargetFormats = getTargetFormats(targetFormat.getEncoding(), sourceFormat);
- for (int i = 0; i < aTargetFormats.length; i++)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out("checking against possible target format: " + aTargetFormats[i]);
- }
- if (aTargetFormats[i] != null
- && AudioFormats.matches(aTargetFormats[i], targetFormat))
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out("<result=true");
- }
- return true;
- }
- }
- if (TDebug.TraceAudioConverter) {
- TDebug.out("<result=false");
- }
- return false;
- }
-
-
- /**
- * WARNING: this method uses <code>getTargetFormats(AudioFormat.Encoding, AudioFormat)</code>
- * which may create infinite loops if the latter is overwritten.
- * <p>
- * This method is overwritten here to make use of org.tritonus.share.sampled.AudioFormats.matches
- * and is considered temporary until AudioFormat.matches is corrected in the JavaSound API.
- */
- public AudioFormat getMatchingFormat(
- AudioFormat targetFormat,
- AudioFormat sourceFormat)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out(">TFormatConversionProvider.isConversionSupported(AudioFormat, AudioFormat):");
- TDebug.out("class: "+getClass().getName());
- TDebug.out("checking if conversion possible");
- TDebug.out("from: " + sourceFormat);
- TDebug.out("to: " + targetFormat);
- }
- AudioFormat[] aTargetFormats = getTargetFormats(targetFormat.getEncoding(), sourceFormat);
- for (int i = 0; i < aTargetFormats.length; i++)
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out("checking against possible target format: " + aTargetFormats[i]);
- }
- if (aTargetFormats[i] != null
- && AudioFormats.matches(aTargetFormats[i], targetFormat))
- {
- if (TDebug.TraceAudioConverter)
- {
- TDebug.out("<result=true");
- }
- return aTargetFormats[i];
- }
- }
- if (TDebug.TraceAudioConverter) {
- TDebug.out("<result=false");
- }
- return null;
- }
-
-}
-
-
-
-/*** TFormatConversionProvider.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/TMatrixFormatConversionProvider.java b/songdbj/org/tritonus/share/sampled/convert/TMatrixFormatConversionProvider.java
deleted file mode 100644
index 05dca90309..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/TMatrixFormatConversionProvider.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * TMatrixFormatConversionProvider.java
- */
-
-/*
- * Copyright (c) 1999, 2000 by Matthias Pfisterer <Matthias.Pfisterer@gmx.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-
-package org.tritonus.share.sampled.convert;
-
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.spi.FormatConversionProvider;
-
-import org.tritonus.share.sampled.AudioFormats;
-import org.tritonus.share.ArraySet;
-
-/**
- * Base class for arbitrary formatConversionProviders.
- *
- * @author Matthias Pfisterer
- */
-
-
-public abstract class TMatrixFormatConversionProvider
- extends TSimpleFormatConversionProvider
-{
- /*
- * keys: source AudioFormat
- * values: collection of possible target encodings
- *
- * Note that accessing values with get() is not appropriate,
- * since the equals() method in AudioFormat is not overloaded.
- * The hashtable is just used as a convenient storage
- * organization.
- */
- private Map m_targetEncodingsFromSourceFormat;
-
-
- /*
- * keys: source AudioFormat
- * values: a Map that contains a mapping from target encodings
- * (keys) to a collection of target formats (values).
- *
- * Note that accessing values with get() is not appropriate,
- * since the equals() method in AudioFormat is not overloaded.
- * The hashtable is just used as a convenient storage
- * organization.
- */
- private Map m_targetFormatsFromSourceFormat;
-
-
-
- protected TMatrixFormatConversionProvider(
- List sourceFormats,
- List targetFormats,
- boolean[][] abConversionPossible)
- {
- super(sourceFormats,
- targetFormats);
- m_targetEncodingsFromSourceFormat = new HashMap();
- m_targetFormatsFromSourceFormat = new HashMap();
-
- for (int nSourceFormat = 0;
- nSourceFormat < sourceFormats.size();
- nSourceFormat++)
- {
- AudioFormat sourceFormat = (AudioFormat) sourceFormats.get(nSourceFormat);
- List supportedTargetEncodings = new ArraySet();
- m_targetEncodingsFromSourceFormat.put(sourceFormat, supportedTargetEncodings);
- Map targetFormatsFromTargetEncodings = new HashMap();
- m_targetFormatsFromSourceFormat.put(sourceFormat, targetFormatsFromTargetEncodings);
- for (int nTargetFormat = 0;
- nTargetFormat < targetFormats.size();
- nTargetFormat++)
- {
- AudioFormat targetFormat = (AudioFormat) targetFormats.get(nTargetFormat);
- if (abConversionPossible[nSourceFormat][nTargetFormat])
- {
- AudioFormat.Encoding targetEncoding = targetFormat.getEncoding();
- supportedTargetEncodings.add(targetEncoding);
- Collection supportedTargetFormats = (Collection) targetFormatsFromTargetEncodings.get(targetEncoding);
- if (supportedTargetFormats == null)
- {
- supportedTargetFormats = new ArraySet();
- targetFormatsFromTargetEncodings.put(targetEncoding, supportedTargetFormats);
- }
- supportedTargetFormats.add(targetFormat);
- }
- }
- }
- }
-
-
-
- public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat)
- {
- Iterator iterator = m_targetEncodingsFromSourceFormat.entrySet().iterator();
- while (iterator.hasNext())
- {
- Map.Entry entry = (Map.Entry) iterator.next();
- AudioFormat format = (AudioFormat) entry.getKey();
- if (AudioFormats.matches(format, sourceFormat))
- {
- Collection targetEncodings = (Collection) entry.getValue();
- return (AudioFormat.Encoding[]) targetEncodings.toArray(EMPTY_ENCODING_ARRAY);
- }
-
- }
- return EMPTY_ENCODING_ARRAY;
- }
-
-
-
- // TODO: this should work on the array returned by getTargetEncodings(AudioFormat)
-/*
- public boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)
- {
- return isAllowedSourceFormat(sourceFormat) &&
- isTargetEncodingSupported(targetEncoding);
- }
-*/
-
-
-
- public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)
- {
- Iterator iterator = m_targetFormatsFromSourceFormat.entrySet().iterator();
- while (iterator.hasNext())
- {
- Map.Entry entry = (Map.Entry) iterator.next();
- AudioFormat format = (AudioFormat) entry.getKey();
- if (AudioFormats.matches(format, sourceFormat))
- {
- Map targetEncodings = (Map) entry.getValue();
- Collection targetFormats = (Collection) targetEncodings.get(targetEncoding);
- if (targetFormats != null)
- {
- return (AudioFormat[]) targetFormats.toArray(EMPTY_FORMAT_ARRAY);
- }
- else
- {
- return EMPTY_FORMAT_ARRAY;
- }
- }
-
- }
- return EMPTY_FORMAT_ARRAY;
- }
-
-
-}
-
-
-
-/*** TMatrixFormatConversionProvider.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/TSimpleFormatConversionProvider.java b/songdbj/org/tritonus/share/sampled/convert/TSimpleFormatConversionProvider.java
deleted file mode 100644
index 71b055ff79..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/TSimpleFormatConversionProvider.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * TSimpleFormatConversionProvider.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.convert;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.sampled.AudioFormats;
-import org.tritonus.share.ArraySet;
-import org.tritonus.share.TDebug;
-
-
-/**
- * This is a base class for FormatConversionProviders that can convert
- * from each source encoding/format to each target encoding/format.
- * If this is not the case, use TEncodingFormatConversionProvider.
- *
- * <p>Overriding classes must
- * provide a constructor that calls the protected constructor of this class and override
- * <code>AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)</code>.
- * The latter method should be able to handle the case that all fields are NOT_SPECIFIED
- * and provide appropriate default values.
- *
- * @author Matthias Pfisterer
- */
-
-// todo:
-// - declare a constant ALL_BUT_SAME_VALUE (==-2) or so that can be used in format lists
-// - consistent implementation of replacing NOT_SPECIFIED when not given in conversion
-
-public abstract class TSimpleFormatConversionProvider
-extends TFormatConversionProvider
-{
- private Collection<AudioFormat.Encoding> m_sourceEncodings;
- private Collection<AudioFormat.Encoding> m_targetEncodings;
- private Collection<AudioFormat> m_sourceFormats;
- private Collection<AudioFormat> m_targetFormats;
-
-
-
- protected TSimpleFormatConversionProvider(
- Collection<AudioFormat> sourceFormats,
- Collection<AudioFormat> targetFormats)
- {
- m_sourceEncodings = new ArraySet<AudioFormat.Encoding>();
- m_targetEncodings = new ArraySet<AudioFormat.Encoding>();
- m_sourceFormats = sourceFormats;
- m_targetFormats = targetFormats;
- collectEncodings(m_sourceFormats, m_sourceEncodings);
- collectEncodings(m_targetFormats, m_targetEncodings);
- }
-
-
-
- /** Disables this FormatConversionProvider.
- This may be useful when e.g. native libraries are not present.
- TODO: enable method, better implementation
- */
- protected void disable()
- {
- if (TDebug.TraceAudioConverter) { TDebug.out("TSimpleFormatConversionProvider.disable(): disabling " + getClass().getName()); }
- m_sourceEncodings = new ArraySet<AudioFormat.Encoding>();
- m_targetEncodings = new ArraySet<AudioFormat.Encoding>();
- m_sourceFormats = new ArraySet<AudioFormat>();
- m_targetFormats = new ArraySet<AudioFormat>();
- }
-
-
-
- private static void collectEncodings(Collection<AudioFormat> formats,
- Collection<AudioFormat.Encoding> encodings)
- {
- Iterator<AudioFormat> iterator = formats.iterator();
- while (iterator.hasNext())
- {
- AudioFormat format = iterator.next();
- encodings.add(format.getEncoding());
- }
- }
-
-
-
- public AudioFormat.Encoding[] getSourceEncodings()
- {
- return m_sourceEncodings.toArray(EMPTY_ENCODING_ARRAY);
- }
-
-
-
- public AudioFormat.Encoding[] getTargetEncodings()
- {
- return m_targetEncodings.toArray(EMPTY_ENCODING_ARRAY);
- }
-
-
-
- // overwritten of FormatConversionProvider
- public boolean isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding)
- {
- return m_sourceEncodings.contains(sourceEncoding);
- }
-
-
-
- // overwritten of FormatConversionProvider
- public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding)
- {
- return m_targetEncodings.contains(targetEncoding);
- }
-
-
-
- /**
- * This implementation assumes that the converter can convert
- * from each of its source encodings to each of its target
- * encodings. If this is not the case, the converter has to
- * override this method.
- */
- public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat)
- {
- if (isAllowedSourceFormat(sourceFormat))
- {
- return getTargetEncodings();
- }
- else
- {
- return EMPTY_ENCODING_ARRAY;
- }
- }
-
-
-
- /**
- * This implementation assumes that the converter can convert
- * from each of its source formats to each of its target
- * formats. If this is not the case, the converter has to
- * override this method.
- */
- public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)
- {
- if (isConversionSupported(targetEncoding, sourceFormat))
- {
- return m_targetFormats.toArray(EMPTY_FORMAT_ARRAY);
- }
- else
- {
- return EMPTY_FORMAT_ARRAY;
- }
- }
-
-
- // TODO: check if necessary
- protected boolean isAllowedSourceEncoding(AudioFormat.Encoding sourceEncoding)
- {
- return m_sourceEncodings.contains(sourceEncoding);
- }
-
-
-
- protected boolean isAllowedTargetEncoding(AudioFormat.Encoding targetEncoding)
- {
- return m_targetEncodings.contains(targetEncoding);
- }
-
-
-
- protected boolean isAllowedSourceFormat(AudioFormat sourceFormat)
- {
- Iterator<AudioFormat> iterator = m_sourceFormats.iterator();
- while (iterator.hasNext())
- {
- AudioFormat format = iterator.next();
- if (AudioFormats.matches(format, sourceFormat))
- {
- return true;
- }
- }
- return false;
- }
-
-
-
- protected boolean isAllowedTargetFormat(AudioFormat targetFormat)
- {
- Iterator<AudioFormat> iterator = m_targetFormats.iterator();
- while (iterator.hasNext())
- {
- AudioFormat format = iterator.next();
- if (AudioFormats.matches(format, targetFormat))
- {
- return true;
- }
- }
- return false;
- }
-
- // $$fb 2000-04-02 added some convenience methods for overriding classes
- protected Collection<AudioFormat.Encoding> getCollectionSourceEncodings()
- {
- return m_sourceEncodings;
- }
-
- protected Collection<AudioFormat.Encoding> getCollectionTargetEncodings()
- {
- return m_targetEncodings;
- }
-
- protected Collection<AudioFormat> getCollectionSourceFormats() {
- return m_sourceFormats;
- }
-
- protected Collection<AudioFormat> getCollectionTargetFormats() {
- return m_targetFormats;
- }
-
- /**
- * Utility method to check whether these values match,
- * taking into account AudioSystem.NOT_SPECIFIED.
- * @return true if any of the values is AudioSystem.NOT_SPECIFIED
- * or both values have the same value.
- */
- //$$fb 2000-08-16: moved from TEncodingFormatConversionProvider
- protected static boolean doMatch(int i1, int i2) {
- return i1==AudioSystem.NOT_SPECIFIED
- || i2==AudioSystem.NOT_SPECIFIED
- || i1==i2;
- }
-
- /**
- * @see #doMatch(int,int)
- */
- //$$fb 2000-08-16: moved from TEncodingFormatConversionProvider
- protected static boolean doMatch(float f1, float f2) {
- return f1==AudioSystem.NOT_SPECIFIED
- || f2==AudioSystem.NOT_SPECIFIED
- || Math.abs(f1 - f2) < 1.0e-9;
- }
-
- /**
- * Utility method, replaces all occurences of AudioSystem.NOT_SPECIFIED
- * in <code>targetFormat</code> with the corresponding value in <code>sourceFormat</code>.
- * If <code>targetFormat</code> does not contain any fields with AudioSystem.NOT_SPECIFIED,
- * it is returned unmodified. The endian-ness and encoding remain the same in all cases.
- * <p>
- * If any of the fields is AudioSystem.NOT_SPECIFIED in both <code>sourceFormat</code> and
- * <code>targetFormat</code>, it will remain not specified.
- * <p>
- * This method uses <code>getFrameSize(...)</code> (see below) to set the new frameSize,
- * if a new AudioFormat instance is created.
- * <p>
- * This method isn't used in TSimpleFormatConversionProvider - it is solely there
- * for inheriting classes.
- */
- //$$fb 2000-08-16: moved from TEncodingFormatConversionProvider
- protected AudioFormat replaceNotSpecified(AudioFormat sourceFormat, AudioFormat targetFormat) {
- boolean bSetSampleSize=false;
- boolean bSetChannels=false;
- boolean bSetSampleRate=false;
- boolean bSetFrameRate=false;
- if (targetFormat.getSampleSizeInBits()==AudioSystem.NOT_SPECIFIED
- && sourceFormat.getSampleSizeInBits()!=AudioSystem.NOT_SPECIFIED) {
- bSetSampleSize=true;
- }
- if (targetFormat.getChannels()==AudioSystem.NOT_SPECIFIED
- && sourceFormat.getChannels()!=AudioSystem.NOT_SPECIFIED) {
- bSetChannels=true;
- }
- if (targetFormat.getSampleRate()==AudioSystem.NOT_SPECIFIED
- && sourceFormat.getSampleRate()!=AudioSystem.NOT_SPECIFIED) {
- bSetSampleRate=true;
- }
- if (targetFormat.getFrameRate()==AudioSystem.NOT_SPECIFIED
- && sourceFormat.getFrameRate()!=AudioSystem.NOT_SPECIFIED) {
- bSetFrameRate=true;
- }
- if (bSetSampleSize || bSetChannels || bSetSampleRate || bSetFrameRate
- || (targetFormat.getFrameSize()==AudioSystem.NOT_SPECIFIED
- && sourceFormat.getFrameSize()!=AudioSystem.NOT_SPECIFIED)) {
- // create new format in place of the original target format
- float sampleRate=bSetSampleRate?
- sourceFormat.getSampleRate():targetFormat.getSampleRate();
- float frameRate=bSetFrameRate?
- sourceFormat.getFrameRate():targetFormat.getFrameRate();
- int sampleSize=bSetSampleSize?
- sourceFormat.getSampleSizeInBits():targetFormat.getSampleSizeInBits();
- int channels=bSetChannels?
- sourceFormat.getChannels():targetFormat.getChannels();
- int frameSize=getFrameSize(
- targetFormat.getEncoding(),
- sampleRate,
- sampleSize,
- channels,
- frameRate,
- targetFormat.isBigEndian(),
- targetFormat.getFrameSize());
- targetFormat= new AudioFormat(
- targetFormat.getEncoding(),
- sampleRate,
- sampleSize,
- channels,
- frameSize,
- frameRate,
- targetFormat.isBigEndian());
- }
- return targetFormat;
- }
-
- /**
- * Calculates the frame size for the given format description.
- * The default implementation returns AudioSystem.NOT_SPECIFIED
- * if either <code>sampleSize</code> or <code>channels</code> is AudioSystem.NOT_SPECIFIED,
- * otherwise <code>sampleSize*channels/8</code> is returned.
- * <p>
- * If this does not reflect the way to calculate the right frame size,
- * inheriting classes should overwrite this method if they use
- * replaceNotSpecified(...). It is not used elsewhere in this class.
- */
- //$$fb 2000-08-16: added
- protected int getFrameSize(
- AudioFormat.Encoding encoding,
- float sampleRate,
- int sampleSize,
- int channels,
- float frameRate,
- boolean bigEndian,
- int oldFrameSize) {
- if (sampleSize==AudioSystem.NOT_SPECIFIED || channels==AudioSystem.NOT_SPECIFIED) {
- return AudioSystem.NOT_SPECIFIED;
- }
- return sampleSize*channels/8;
- }
-
-
-
-}
-
-/*** TSimpleFormatConversionProvider.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/TSynchronousFilteredAudioInputStream.java b/songdbj/org/tritonus/share/sampled/convert/TSynchronousFilteredAudioInputStream.java
deleted file mode 100644
index 8a588e5c3e..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/TSynchronousFilteredAudioInputStream.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * TSynchronousFilteredAudioInputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999,2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.convert;
-
-import java.io.IOException;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.spi.FormatConversionProvider;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.AudioUtils;
-
-
-
-/**
- * Base class for types of audio filter/converter that translate one frame to another frame.<br>
- * It provides all the transformation of frame sizes.<br>
- * It does NOT handle different sample rates of original stream and this stream !
- *
- * @author Florian Bomers
- */
-public abstract class TSynchronousFilteredAudioInputStream
-extends TAudioInputStream {
-
- private AudioInputStream originalStream;
- private AudioFormat originalFormat;
- /** 1 if original format's frame size is NOT_SPECIFIED */
- private int originalFrameSize;
- /** 1 if original format's frame size is NOT_SPECIFIED */
- private int newFrameSize;
-
- /**
- * The intermediate buffer used during convert actions
- * (if not convertInPlace is used).
- * It remains until this audioStream is closed or destroyed
- * and grows with the time - it always has the size of the
- * largest intermediate buffer ever needed.
- */
- protected byte[] buffer=null;
-
- /**
- * For use of the more efficient method convertInPlace.
- * it will be set to true when (frameSizeFactor==1)
- */
- private boolean m_bConvertInPlace = false;
-
- public TSynchronousFilteredAudioInputStream(AudioInputStream audioInputStream, AudioFormat newFormat) {
- // the super class will do nothing... we override everything
- super(audioInputStream, newFormat, audioInputStream.getFrameLength());
- originalStream=audioInputStream;
- originalFormat=audioInputStream.getFormat();
- originalFrameSize=(originalFormat.getFrameSize()<=0) ?
- 1 : originalFormat.getFrameSize();
- newFrameSize=(getFormat().getFrameSize()<=0) ?
- 1 : getFormat().getFrameSize();
- if (TDebug.TraceAudioConverter) {
- TDebug.out("TSynchronousFilteredAudioInputStream: original format ="
- +AudioUtils.format2ShortStr(originalFormat));
- TDebug.out("TSynchronousFilteredAudioInputStream: converted format="
- +AudioUtils.format2ShortStr(getFormat()));
- }
- //$$fb 2000-07-17: convert in place has to be enabled explicitly with "enableConvertInPlace"
- //if (getFormat().getFrameSize() == originalFormat.getFrameSize()) {
- // m_bConvertInPlace = true;
- //}
- m_bConvertInPlace = false;
- }
-
- protected boolean enableConvertInPlace() {
- if (newFrameSize >= originalFrameSize) {
- m_bConvertInPlace = true;
- }
- return m_bConvertInPlace;
- }
-
-
- /**
- * Override this method to do the actual conversion.
- * inBuffer starts always at index 0 (it is an internal buffer)
- * You should always override this.
- * inFrameCount is the number of frames in inBuffer. These
- * frames are of the format originalFormat.
- * @return the resulting number of <B>frames</B> converted and put into
- * outBuffer. The return value is in the format of this stream.
- */
- protected abstract int convert(byte[] inBuffer, byte[] outBuffer, int outByteOffset, int inFrameCount);
-
-
-
- /**
- * Override this method to provide in-place conversion of samples.
- * To use it, call "enableConvertInPlace()". It will only be used when
- * input bytes per frame >= output bytes per frame.
- * This method must always convert frameCount frames, so no return value is necessary.
- */
- protected void convertInPlace(byte[] buffer, int byteOffset, int frameCount) {
- throw new RuntimeException("Illegal call to convertInPlace");
- }
-
- public int read()
- throws IOException {
- if (newFrameSize != 1) {
- throw new IOException("frame size must be 1 to read a single byte");
- }
- // very ugly, but efficient. Who uses this method anyway ?
- // TODO: use an instance variable
- byte[] temp = new byte[1];
- int result = read(temp);
- if (result == -1) {
- return -1;
- }
- if (result == 0) {
- // what in this case ??? Let's hope it never occurs.
- return -1;
- }
- return temp[0] & 0xFF;
- }
-
-
-
- private void clearBuffer() {
- buffer = null;
- }
-
- public AudioInputStream getOriginalStream() {
- return originalStream;
- }
-
- public AudioFormat getOriginalFormat() {
- return originalFormat;
- }
-
- /**
- * Read nLength bytes that will be the converted samples
- * of the original InputStream.
- * When nLength is not an integral number of frames,
- * this method may read less than nLength bytes.
- */
- public int read(byte[] abData, int nOffset, int nLength)
- throws IOException {
- // number of frames that we have to read from the underlying stream.
- int nFrameLength = nLength/newFrameSize;
-
- // number of bytes that we need to read from underlying stream.
- int originalBytes = nFrameLength * originalFrameSize;
-
- if (TDebug.TraceAudioConverter) {
- TDebug.out("> TSynchronousFilteredAIS.read(buffer["+abData.length+"], "
- +nOffset+" ,"+nLength+" bytes ^="+nFrameLength+" frames)");
- }
- int nFramesConverted = 0;
-
- // set up buffer to read
- byte readBuffer[];
- int readOffset;
- if (m_bConvertInPlace) {
- readBuffer=abData;
- readOffset=nOffset;
- } else {
- // assert that the buffer fits
- if (buffer == null || buffer.length < originalBytes) {
- buffer = new byte[originalBytes];
- }
- readBuffer=buffer;
- readOffset=0;
- }
- int nBytesRead = originalStream.read(readBuffer, readOffset, originalBytes);
- if (nBytesRead == -1) {
- // end of stream
- clearBuffer();
- return -1;
- }
- int nFramesRead = nBytesRead / originalFrameSize;
- if (TDebug.TraceAudioConverter) {
- TDebug.out("original.read returned "
- +nBytesRead+" bytes ^="+nFramesRead+" frames");
- }
- if (m_bConvertInPlace) {
- convertInPlace(abData, nOffset, nFramesRead);
- nFramesConverted=nFramesRead;
- } else {
- nFramesConverted = convert(buffer, abData, nOffset, nFramesRead);
- }
- if (TDebug.TraceAudioConverter) {
- TDebug.out("< converted "+nFramesConverted+" frames");
- }
- return nFramesConverted*newFrameSize;
- }
-
-
- public long skip(long nSkip)
- throws IOException {
- // only returns integral frames
- long skipFrames = nSkip / newFrameSize;
- long originalSkippedBytes = originalStream.skip(skipFrames*originalFrameSize);
- long skippedFrames = originalSkippedBytes/originalFrameSize;
- return skippedFrames * newFrameSize;
- }
-
-
- public int available()
- throws IOException {
- int origAvailFrames = originalStream.available()/originalFrameSize;
- return origAvailFrames*newFrameSize;
- }
-
-
- public void close()
- throws IOException {
- originalStream.close();
- clearBuffer();
- }
-
-
-
- public void mark(int readlimit) {
- int readLimitFrames=readlimit/newFrameSize;
- originalStream.mark(readLimitFrames*originalFrameSize);
- }
-
-
-
- public void reset()
- throws IOException {
- originalStream.reset();
- }
-
-
- public boolean markSupported() {
- return originalStream.markSupported();
- }
-
-
- private int getFrameSize() {
- return getFormat().getFrameSize();
- }
-
-}
-
-
-/*** TSynchronousFilteredAudioInputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/convert/package.html b/songdbj/org/tritonus/share/sampled/convert/package.html
deleted file mode 100644
index d0cc35c408..0000000000
--- a/songdbj/org/tritonus/share/sampled/convert/package.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Base classes for the implementation of FormatConversionProviders.
- The classes provided here .</p>
-
- @see javax.sound.sampled.spi.FormatConversionProvider
- @see org.tritonus.sampled.convert
- @see org.tritonus.sampled.convert.gsm
- @see org.tritonus.sampled.convert.jorbis
- @see org.tritonus.sampled.convert.lame
- @see org.tritonus.sampled.convert.vorbis
- </body>
-</html>
diff --git a/songdbj/org/tritonus/share/sampled/file/AudioOutputStream.java b/songdbj/org/tritonus/share/sampled/file/AudioOutputStream.java
deleted file mode 100644
index d76296cd2d..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/AudioOutputStream.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * AudioOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.IOException;
-
-import javax.sound.sampled.AudioFormat;
-
-
-
-/** Represents a one-time writing of audio data to a destination (file or output stream).
- *
- * This interface is the lowest abstraction level of writing audio data.
- * Implementations of this interface should, when write() is called, never
- * do buffering and they should never do format conversions. However,
- * this interface is intended to abstract the file format (how the
- * headers and data chunks look like) and the way of writing to the
- * destination object. (implementation note [non-normative]: the last
- * should be done by using TDataOutputStream implementing classes).
- *
- * One reasoning behind this interface was to allow direct, unbuffered
- * writing of recorded data.
- * In JS API 0.90, there was no obvious way for this.
- * Data have had to be recorded to a buffer, then written to a file
- * from that buffer.
- * This gave problems with long recordings, where the main
- * memory of the machine is not big enough to hold all data. There are
- * two ways so solve this:
- *
- * a) Having a special AudioInputStream that fetches its data from a
- * TargetDataLine. This way, the loop inside the AudioFileWriters reads
- * directely from the recording line via the special AudioInputStream.
- * This is the solution Sun adopted for JS 1.0.
- *
- * b) The other way is to expose a direct interface to the writing of the
- * audio file with no loop inside it. This is to enable the application
- * programmer to write the main loop itself, possibly doing some
- * additional processing inside it. This is the more flexible way.
- * The drawback is that it requires a new architecture for writing files.
- *
- * This interface is the central part of a proposal for the second
- * solution.
- * The idea is now to use the new structure inside the old one to gain
- * experience with it before proposing to make it a public interface
- * (public in the sense that it is part of the javax.sound.sampled
- * package).
- *
- * @author Matthias Pfisterer
- */
-public interface AudioOutputStream
-{
- /**
- * Retrieves the AufioFormat of this AudioOutputStream.
- */
- public AudioFormat getFormat();
-
-
- /** Gives length of the stream.
- * This value is in bytes. It may be AudioSystem.NOT_SPECIFIED
- * to express that the length is unknown.
- */
- public long getLength();
-
-
-
- /**
- * Writes a chunk of audio data to the destination (file or output stream).
- */
- // IDEA: use long?
- public int write(byte[] abData, int nOffset, int nLength)
- throws IOException;
-
-
-
- /** Closes the stream.
- * This does write remaining buffered data to the destination,
- * backpatch the header, if necessary, and closes the destination.
- */
- public void close()
- throws IOException;
-}
-
-
-
-/*** AudioOutputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/HeaderlessAudioOutputStream.java b/songdbj/org/tritonus/share/sampled/file/HeaderlessAudioOutputStream.java
deleted file mode 100644
index 3083fd5b8f..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/HeaderlessAudioOutputStream.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * HeaderlessAudioOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.IOException;
-import javax.sound.sampled.AudioFormat;
-
-
-/**
- * AudioOutputStream for files without a header; the input is written as it is.
- *
- * @author Florian Bomers
- */
-
-// todo: implement directly AudioOutputStream without using TAudioOutputStream
-
-public class HeaderlessAudioOutputStream extends TAudioOutputStream {
-
- public HeaderlessAudioOutputStream(AudioFormat audioFormat,
- long lLength,
- TDataOutputStream dataOutputStream) {
- super(audioFormat, lLength, dataOutputStream, false);
- }
-
- protected void writeHeader() throws IOException
- {
- }
-}
-
-/*** HeaderlessAudioOutputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/TAudioFileFormat.java b/songdbj/org/tritonus/share/sampled/file/TAudioFileFormat.java
deleted file mode 100644
index fd9831e291..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/TAudioFileFormat.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * TAudioFileFormat.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-
-
-
-/**
- * This class is just to have a public constructor taking the
- * number of bytes of the whole file. The public constructor of
- * AudioFileFormat doesn't take this parameter, the one who takes
- * it is protected.
- *
- * @author Matthias Pfisterer
- */
-public class TAudioFileFormat
-extends AudioFileFormat
-{
- private Map<String, Object> m_properties;
- private Map<String, Object> m_unmodifiableProperties;
-
-
- /*
- * Note that the order of the arguments is different from
- * the one in AudioFileFormat.
- */
- public TAudioFileFormat(Type type,
- AudioFormat audioFormat,
- int nLengthInFrames,
- int nLengthInBytes)
- {
- super(type,
- nLengthInBytes,
- audioFormat,
- nLengthInFrames);
- }
-
-
- public TAudioFileFormat(Type type,
- AudioFormat audioFormat,
- int nLengthInFrames,
- int nLengthInBytes,
- Map<String, Object> properties)
- {
- super(type,
- nLengthInBytes,
- audioFormat,
- nLengthInFrames);
- initMaps(properties);
- }
-
-
- private void initMaps(Map<String, Object> properties)
- {
- /* Here, we make a shallow copy of the map. It's unclear if this
- is sufficient (of if a deep copy should be made).
- */
- m_properties = new HashMap<String, Object>();
- m_properties.putAll(properties);
- m_unmodifiableProperties = Collections.unmodifiableMap(m_properties);
- }
-
-
- public Map<String, Object> properties()
- {
- return m_unmodifiableProperties;
- }
-
-
-
- protected void setProperty(String key, Object value)
- {
- m_properties.put(key, value);
- }
-}
-
-
-
-/*** TAudioFileFormat.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/TAudioFileReader.java b/songdbj/org/tritonus/share/sampled/file/TAudioFileReader.java
deleted file mode 100644
index ee79becf20..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/TAudioFileReader.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * TAudioFileReader.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Matthias Pfisterer
- * Copyright (c) 2001 by Florian Bomers <http://www.bomers.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.DataInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.EOFException;
-
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
-import javax.sound.sampled.spi.AudioFileReader;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Base class for audio file readers.
- This is Tritonus' base class for classes that provide the facility
- of detecting an audio file type and reading its header.
- Classes should be derived from this class or one of its subclasses
- rather than from javax.sound.sampled.spi.AudioFileReader.
-
- @author Matthias Pfisterer
- @author Florian Bomers
-*/
-public abstract class TAudioFileReader
-extends AudioFileReader
-{
- private int m_nMarkLimit = -1;
- private boolean m_bRereading;
-
-
- protected TAudioFileReader(int nMarkLimit)
- {
- this(nMarkLimit, false);
- }
-
-
-
- protected TAudioFileReader(int nMarkLimit, boolean bRereading)
- {
- m_nMarkLimit = nMarkLimit;
- m_bRereading = bRereading;
- }
-
-
-
- private int getMarkLimit()
- {
- return m_nMarkLimit;
- }
-
-
-
- private boolean isRereading()
- {
- return m_bRereading;
- }
-
-
-
- /** Get an AudioFileFormat object for a File.
- This method calls getAudioFileFormat(InputStream, long).
- Subclasses should not override this method unless there are
- really severe reasons. Normally, it is sufficient to
- implement getAudioFileFormat(InputStream, long).
-
- @param file the file to read from.
- @return an AudioFileFormat instance containing
- information from the header of the file passed in.
- */
- public AudioFileFormat getAudioFileFormat(File file)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioFileFormat(File): begin"); }
- long lFileLengthInBytes = file.length();
- InputStream inputStream = new FileInputStream(file);
- AudioFileFormat audioFileFormat = null;
- try
- {
- audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
- }
- finally
- {
- inputStream.close();
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioFileFormat(File): end"); }
- return audioFileFormat;
- }
-
-
-
- /** Get an AudioFileFormat object for a URL.
- This method calls getAudioFileFormat(InputStream, long).
- Subclasses should not override this method unless there are
- really severe reasons. Normally, it is sufficient to
- implement getAudioFileFormat(InputStream, long).
-
- @param url the URL to read from.
- @return an AudioFileFormat instance containing
- information from the header of the URL passed in.
- */
- public AudioFileFormat getAudioFileFormat(URL url)
- throws UnsupportedAudioFileException, IOException
-
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioFileFormat(URL): begin"); }
- long lFileLengthInBytes = getDataLength(url);
- InputStream inputStream = url.openStream();
- AudioFileFormat audioFileFormat = null;
- try
- {
- audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
- }
- finally
- {
- inputStream.close();
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioFileFormat(URL): end"); }
- return audioFileFormat;
- }
-
-
-
- /** Get an AudioFileFormat object for an InputStream.
- This method calls getAudioFileFormat(InputStream, long).
- Subclasses should not override this method unless there are
- really severe reasons. Normally, it is sufficient to
- implement getAudioFileFormat(InputStream, long).
-
- @param inputStream the stream to read from.
- @return an AudioFileFormat instance containing
- information from the header of the stream passed in.
- */
- public AudioFileFormat getAudioFileFormat(InputStream inputStream)
- throws UnsupportedAudioFileException, IOException
-
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioFileFormat(InputStream): begin"); }
- long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
- inputStream.mark(getMarkLimit());
- AudioFileFormat audioFileFormat = null;
- try
- {
- audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
- }
- finally
- {
- /* TODO: required semantics is unclear: should reset()
- be executed only when there is an exception or
- should it be done always?
- */
- inputStream.reset();
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioFileFormat(InputStream): end"); }
- return audioFileFormat;
- }
-
-
-
- /** Get an AudioFileFormat (internal implementation).
- Subclasses must implement this method in a way specific
- to the file format they handle.
-
- Note that depending on the implementation of this method,
- you should or should not override
- getAudioInputStream(InputStream, long), too (see comment
- there).
-
- @param inputStream The InputStream to read from.
- @param lFileLengthInBytes The size of the originating
- file, if known. If it isn't known, AudioSystem.NOT_SPECIFIED
- should be passed. This value may be used for byteLength in
- AudioFileFormat, if this value can't be derived from the
- informmation in the file header.
-
- @return an AudioFileFormat instance containing
- information from the header of the stream passed in as
- inputStream.
- */
- protected abstract AudioFileFormat getAudioFileFormat(
- InputStream inputStream,
- long lFileLengthInBytes)
- throws UnsupportedAudioFileException, IOException;
-
-
-
- /** Get an AudioInputStream object for a file.
- This method calls getAudioInputStream(InputStream, long).
- Subclasses should not override this method unless there are
- really severe reasons. Normally, it is sufficient to
- implement getAudioFileFormat(InputStream, long) and perhaps
- override getAudioInputStream(InputStream, long).
-
- @param file the File object to read from.
- @return an AudioInputStream instance containing
- the audio data from this file.
- */
- public AudioInputStream getAudioInputStream(File file)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(File): begin"); }
- long lFileLengthInBytes = file.length();
- InputStream inputStream = new FileInputStream(file);
- AudioInputStream audioInputStream = null;
- try
- {
- audioInputStream = getAudioInputStream(inputStream, lFileLengthInBytes);
- }
- catch (UnsupportedAudioFileException e)
- {
- inputStream.close();
- throw e;
- }
- catch (IOException e)
- {
- inputStream.close();
- throw e;
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(File): end"); }
- return audioInputStream;
- }
-
-
-
- /** Get an AudioInputStream object for a URL.
- This method calls getAudioInputStream(InputStream, long).
- Subclasses should not override this method unless there are
- really severe reasons. Normally, it is sufficient to
- implement getAudioFileFormat(InputStream, long) and perhaps
- override getAudioInputStream(InputStream, long).
-
- @param url the URL to read from.
- @return an AudioInputStream instance containing
- the audio data from this URL.
- */
- public AudioInputStream getAudioInputStream(URL url)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(URL): begin"); }
- long lFileLengthInBytes = getDataLength(url);
- InputStream inputStream = url.openStream();
- AudioInputStream audioInputStream = null;
- try
- {
- audioInputStream = getAudioInputStream(inputStream, lFileLengthInBytes);
- }
- catch (UnsupportedAudioFileException e)
- {
- inputStream.close();
- throw e;
- }
- catch (IOException e)
- {
- inputStream.close();
- throw e;
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(URL): end"); }
- return audioInputStream;
- }
-
-
-
- /** Get an AudioInputStream object for an InputStream.
- This method calls getAudioInputStream(InputStream, long).
- Subclasses should not override this method unless there are
- really severe reasons. Normally, it is sufficient to
- implement getAudioFileFormat(InputStream, long) and perhaps
- override getAudioInputStream(InputStream, long).
-
- @param inputStream the stream to read from.
- @return an AudioInputStream instance containing
- the audio data from this stream.
- */
- public AudioInputStream getAudioInputStream(InputStream inputStream)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(InputStream): begin"); }
- long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
- AudioInputStream audioInputStream = null;
- inputStream.mark(getMarkLimit());
- try
- {
- audioInputStream = getAudioInputStream(inputStream, lFileLengthInBytes);
- }
- catch (UnsupportedAudioFileException e)
- {
- inputStream.reset();
- throw e;
- }
- catch (IOException e)
- {
- inputStream.reset();
- throw e;
- }
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(InputStream): end"); }
- return audioInputStream;
- }
-
-
-
- /** Get an AudioInputStream (internal implementation).
- This implementation calls getAudioFileFormat() with the
- same arguments as passed in here. Then, it constructs
- an AudioInputStream instance. This instance takes the passed
- inputStream in the state it is left after getAudioFileFormat()
- did its work. In other words, the implementation here
- assumes that getAudioFileFormat() reads the entire header
- up to a position exactely where the audio data starts.
- If this can't be realized for a certain format, this method
- should be overridden.
-
- @param inputStream The InputStream to read from.
- @param lFileLengthInBytes The size of the originating
- file, if known. If it isn't known, AudioSystem.NOT_SPECIFIED
- should be passed. This value may be used for byteLength in
- AudioFileFormat, if this value can't be derived from the
- informmation in the file header.
- */
- protected AudioInputStream getAudioInputStream(InputStream inputStream, long lFileLengthInBytes)
- throws UnsupportedAudioFileException, IOException
- {
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(InputStream, long): begin"); }
- if (isRereading())
- {
- inputStream = new BufferedInputStream(inputStream, getMarkLimit());
- inputStream.mark(getMarkLimit());
- }
- AudioFileFormat audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
- if (isRereading())
- {
- inputStream.reset();
- }
- AudioInputStream audioInputStream =
- new AudioInputStream(inputStream,
- audioFileFormat.getFormat(),
- audioFileFormat.getFrameLength());
- if (TDebug.TraceAudioFileReader) {TDebug.out("TAudioFileReader.getAudioInputStream(InputStream, long): end"); }
- return audioInputStream;
- }
-
-
-
- protected static int calculateFrameSize(int nSampleSize, int nNumChannels)
- {
- return ((nSampleSize + 7) / 8) * nNumChannels;
- }
-
-
-
- private static long getDataLength(URL url)
- throws IOException
- {
- long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
- URLConnection connection = url.openConnection();
- connection.connect();
- int nLength = connection.getContentLength();
- if (nLength > 0)
- {
- lFileLengthInBytes = nLength;
- }
- return lFileLengthInBytes;
- }
-
-
-
- public static int readLittleEndianInt(InputStream is)
- throws IOException
- {
- int b0 = is.read();
- int b1 = is.read();
- int b2 = is.read();
- int b3 = is.read();
- if ((b0 | b1 | b2 | b3) < 0)
- {
- throw new EOFException();
- }
- return (b3 << 24) + (b2 << 16) + (b1 << 8) + (b0 << 0);
- }
-
-
-
- public static short readLittleEndianShort(InputStream is)
- throws IOException
- {
- int b0 = is.read();
- int b1 = is.read();
- if ((b0 | b1) < 0)
- {
- throw new EOFException();
- }
- return (short) ((b1 << 8) + (b0 << 0));
- }
-
-
-/*
- * C O N V E R T F R O M I E E E E X T E N D E D
- */
-
-/*
- * Copyright (C) 1988-1991 Apple Computer, Inc.
- * All rights reserved.
- *
- * Machine-independent I/O routines for IEEE floating-point numbers.
- *
- * NaN's and infinities are converted to HUGE_VAL or HUGE, which
- * happens to be infinity on IEEE machines. Unfortunately, it is
- * impossible to preserve NaN's in a machine-independent way.
- * Infinities are, however, preserved on IEEE machines.
- *
- * These routines have been tested on the following machines:
- * Apple Macintosh, MPW 3.1 C compiler
- * Apple Macintosh, THINK C compiler
- * Silicon Graphics IRIS, MIPS compiler
- * Cray X/MP and Y/MP
- * Digital Equipment VAX
- *
- *
- * Implemented by Malcolm Slaney and Ken Turkowski.
- *
- * Malcolm Slaney contributions during 1988-1990 include big- and little-
- * endian file I/O, conversion to and from Motorola's extended 80-bit
- * floating-point format, and conversions to and from IEEE single-
- * precision floating-point format.
- *
- * In 1991, Ken Turkowski implemented the conversions to and from
- * IEEE double-precision format, added more precision to the extended
- * conversions, and accommodated conversions involving +/- infinity,
- * NaN's, and denormalized numbers.
- */
-
- public static double readIeeeExtended(DataInputStream dis)
- throws IOException
- {
- double f = 0.0D;
- int expon = 0;
- long hiMant = 0L;
- long loMant = 0L;
- double HUGE = 3.4028234663852886E+038D;
- expon = dis.readUnsignedShort();
- long t1 = dis.readUnsignedShort();
- long t2 = dis.readUnsignedShort();
- hiMant = t1 << 16 | t2;
- t1 = dis.readUnsignedShort();
- t2 = dis.readUnsignedShort();
- loMant = t1 << 16 | t2;
- if(expon == 0 && hiMant == 0L && loMant == 0L)
- {
- f = 0.0D;
- }
- else
- {
- if(expon == 32767)
- {
- f = HUGE;
- }
- else
- {
- expon -= 16383;
- expon -= 31;
- f = hiMant * Math.pow(2D, expon);
- expon -= 32;
- f += loMant * Math.pow(2D, expon);
- }
- }
- return f;
- }
-}
-
-
-
-/*** TAudioFileReader.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/file/TAudioFileWriter.java b/songdbj/org/tritonus/share/sampled/file/TAudioFileWriter.java
deleted file mode 100644
index d9d6ee86ec..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/TAudioFileWriter.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * TAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999, 2000 by Matthias Pfisterer
- * Copyright (c) 1999, 2000 by Florian Bomers <http://www.bomers.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.spi.AudioFileWriter;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.AudioFormats;
-import org.tritonus.share.sampled.AudioUtils;
-import org.tritonus.share.sampled.TConversionTool;
-import org.tritonus.share.ArraySet;
-
-/**
- * Common base class for implementing classes of AudioFileWriter.
- * <p>It provides often-used functionality and the new architecture using
- * an AudioOutputStream.
- * <p>There should be only one set of audio formats supported by any given
- * class of TAudioFileWriter. This class assumes implicitely that all
- * supported file types have a common set of audio formats they can handle.
- *
- * @author Matthias Pfisterer
- * @author Florian Bomers
- */
-
-public abstract class TAudioFileWriter
-extends AudioFileWriter
-{
- protected static final int ALL = AudioSystem.NOT_SPECIFIED;
-
- public static AudioFormat.Encoding PCM_SIGNED=new AudioFormat.Encoding("PCM_SIGNED");
- public static AudioFormat.Encoding PCM_UNSIGNED=new AudioFormat.Encoding("PCM_UNSIGNED");
-
- /** Buffer length for the loop in the write() method.
- * This is in bytes. Perhaps it should be in frames to give an
- * equal amount of latency.
- */
- private static final int BUFFER_LENGTH = 16384;
-
- // only needed for Collection.toArray()
- protected static final AudioFileFormat.Type[] NULL_TYPE_ARRAY = new AudioFileFormat.Type[0];
-
-
- /** The audio file types (AudioFileFormat.Type) that can be
- * handled by the AudioFileWriter.
- */
- private Collection<AudioFileFormat.Type> m_audioFileTypes;
-
-
-
- /** The AudioFormats that can be handled by the
- * AudioFileWriter.
- */
- // IDEA: implement a special collection that uses matches() to test whether an element is already in
- private Collection<AudioFormat> m_audioFormats;
-
-
- /**
- * Inheriting classes should call this constructor
- * in order to make use of the functionality of TAudioFileWriter.
- */
- protected TAudioFileWriter(Collection<AudioFileFormat.Type> fileTypes,
- Collection<AudioFormat> audioFormats)
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("TAudioFileWriter.<init>(): begin"); }
- m_audioFileTypes = fileTypes;
- m_audioFormats = audioFormats;
- if (TDebug.TraceAudioFileWriter) { TDebug.out("TAudioFileWriter.<init>(): end"); }
- }
-
- // implementing the interface
- public AudioFileFormat.Type[] getAudioFileTypes()
- {
- return m_audioFileTypes.toArray(NULL_TYPE_ARRAY);
- }
-
-
- // implementing the interface
- public boolean isFileTypeSupported(AudioFileFormat.Type fileType)
- {
- return m_audioFileTypes.contains(fileType);
- }
-
-
-
- // implementing the interface
- public AudioFileFormat.Type[] getAudioFileTypes(
- AudioInputStream audioInputStream)
- {
- //$$fb 2000-08-16: rewrote this method. We need to check for *each*
- // file type, whether the format is supported !
- AudioFormat format = audioInputStream.getFormat();
- ArraySet<AudioFileFormat.Type> res=new ArraySet<AudioFileFormat.Type>();
- Iterator<AudioFileFormat.Type> it=m_audioFileTypes.iterator();
- while (it.hasNext()) {
- AudioFileFormat.Type thisType = it.next();
- if (isAudioFormatSupportedImpl(format, thisType)) {
- res.add(thisType);
- }
- }
- return res.toArray(NULL_TYPE_ARRAY);
- }
-
-
-
- // implementing the interface
- public boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream audioInputStream)
- {
- // $$fb 2000-08-16: finally this method works reliably !
- return isFileTypeSupported(fileType)
- && (isAudioFormatSupportedImpl(audioInputStream.getFormat(), fileType)
- || findConvertableFormat(audioInputStream.getFormat(), fileType)!=null);
- // we may soft it up by including the possibility of endian/sign
- // changing for PCM formats.
- // I prefer to return false if the format is not exactly supported
- // but still exectute the write, if only sign/endian changing is necessary.
- }
-
-
-
- // implementing the interface
- public int write(AudioInputStream audioInputStream,
- AudioFileFormat.Type fileType,
- File file)
- throws IOException
- {
- if (TDebug.TraceAudioFileWriter)
- {
- TDebug.out(">TAudioFileWriter.write(.., File): called");
- TDebug.out("class: "+getClass().getName());
- }
- //$$fb added this check
- if (!isFileTypeSupported(fileType)) {
- if (TDebug.TraceAudioFileWriter)
- {
- TDebug.out("< file type is not supported");
- }
- throw new IllegalArgumentException("file type is not supported.");
- }
-
- AudioFormat inputFormat = audioInputStream.getFormat();
- if (TDebug.TraceAudioFileWriter) { TDebug.out("input format: " + inputFormat); }
- AudioFormat outputFormat = null;
- boolean bNeedsConversion = false;
- if (isAudioFormatSupportedImpl(inputFormat, fileType))
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("input format is supported directely"); }
- outputFormat = inputFormat;
- bNeedsConversion = false;
- }
- else
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("input format is not supported directely; trying to find a convertable format"); }
- outputFormat = findConvertableFormat(inputFormat, fileType);
- if (outputFormat != null)
- {
- bNeedsConversion = true;
- // $$fb 2000-08-16 made consistent with new conversion trials
- // if 8 bit and only endianness changed, don't convert !
- if (outputFormat.getSampleSizeInBits()==8
- && outputFormat.getEncoding().equals(inputFormat.getEncoding())) {
- bNeedsConversion = false;
- }
- }
- else
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< input format is not supported and not convertable."); }
- throw new IllegalArgumentException("format not supported and not convertable");
- }
- }
- long lLengthInBytes = AudioUtils.getLengthInBytes(audioInputStream);
- TDataOutputStream dataOutputStream = new TSeekableDataOutputStream(file);
- AudioOutputStream audioOutputStream =
- getAudioOutputStream(
- outputFormat,
- lLengthInBytes,
- fileType,
- dataOutputStream);
- int written=writeImpl(audioInputStream,
- audioOutputStream,
- bNeedsConversion);
- if (TDebug.TraceAudioFileWriter)
- {
- TDebug.out("< wrote "+written+" bytes.");
- }
- return written;
- }
-
-
-
- // implementing the interface
- public int write(AudioInputStream audioInputStream,
- AudioFileFormat.Type fileType,
- OutputStream outputStream)
- throws IOException
- {
- //$$fb added this check
- if (!isFileTypeSupported(fileType)) {
- throw new IllegalArgumentException("file type is not supported.");
- }
- if (TDebug.TraceAudioFileWriter)
- {
- TDebug.out(">TAudioFileWriter.write(.., OutputStream): called");
- TDebug.out("class: "+getClass().getName());
- }
- AudioFormat inputFormat = audioInputStream.getFormat();
- if (TDebug.TraceAudioFileWriter) { TDebug.out("input format: " + inputFormat); }
- AudioFormat outputFormat = null;
- boolean bNeedsConversion = false;
- if (isAudioFormatSupportedImpl(inputFormat, fileType))
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("input format is supported directely"); }
- outputFormat = inputFormat;
- bNeedsConversion = false;
- }
- else
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("input format is not supported directely; trying to find a convertable format"); }
- outputFormat = findConvertableFormat(inputFormat, fileType);
- if (outputFormat != null)
- {
- bNeedsConversion = true;
- // $$fb 2000-08-16 made consistent with new conversion trials
- // if 8 bit and only endianness changed, don't convert !
- if (outputFormat.getSampleSizeInBits()==8
- && outputFormat.getEncoding().equals(inputFormat.getEncoding())) {
- bNeedsConversion = false;
- }
- }
- else
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< format is not supported"); }
- throw new IllegalArgumentException("format not supported and not convertable");
- }
- }
- long lLengthInBytes = AudioUtils.getLengthInBytes(audioInputStream);
- TDataOutputStream dataOutputStream = new TNonSeekableDataOutputStream(outputStream);
- AudioOutputStream audioOutputStream =
- getAudioOutputStream(
- outputFormat,
- lLengthInBytes,
- fileType,
- dataOutputStream);
- int written=writeImpl(audioInputStream,
- audioOutputStream,
- bNeedsConversion);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< wrote "+written+" bytes."); }
- return written;
- }
-
-
-
- protected int writeImpl(
- AudioInputStream audioInputStream,
- AudioOutputStream audioOutputStream,
- boolean bNeedsConversion)
- throws IOException
- {
- if (TDebug.TraceAudioFileWriter)
- {
- TDebug.out(">TAudioFileWriter.writeImpl(): called");
- TDebug.out("class: "+getClass().getName());
- }
- int nTotalWritten = 0;
- AudioFormat inputFormat = audioInputStream.getFormat();
- AudioFormat outputFormat = audioOutputStream.getFormat();
-
- // TODO: handle case when frame size is unknown ?
- int nBytesPerSample = outputFormat.getFrameSize() / outputFormat.getChannels();
-
- //$$fb 2000-07-18: BUFFER_LENGTH must be a multiple of frame size...
- int nBufferSize=((int)BUFFER_LENGTH/outputFormat.getFrameSize())*outputFormat.getFrameSize();
- byte[] abBuffer = new byte[nBufferSize];
- while (true)
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("trying to read (bytes): " + abBuffer.length); }
- int nBytesRead = audioInputStream.read(abBuffer);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("read (bytes): " + nBytesRead); }
- if (nBytesRead == -1)
- {
- break;
- }
- if (bNeedsConversion)
- {
- TConversionTool.changeOrderOrSign(abBuffer, 0,
- nBytesRead, nBytesPerSample);
- }
- int nWritten = audioOutputStream.write(abBuffer, 0, nBytesRead);
- nTotalWritten += nWritten;
- }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("<TAudioFileWriter.writeImpl(): after main loop. Wrote "+nTotalWritten+" bytes"); }
- audioOutputStream.close();
- // TODO: get bytes written for header etc. from AudioOutputStrem and add to nTotalWrittenBytes
- return nTotalWritten;
- }
-
-
- /** Returns the AudioFormat that can be handled for the given file type.
- * In this simple implementation, all handled AudioFormats are
- * returned (i.e. the fileType argument is ignored). If the
- * handled AudioFormats depend on the file type, this method
- * has to be overwritten by subclasses.
- */
- protected Iterator<AudioFormat> getSupportedAudioFormats(AudioFileFormat.Type fileType)
- {
- return m_audioFormats.iterator();
- }
-
-
- /** Checks whether the passed <b>AudioFormat</b> can be handled.
- * In this simple implementation, it is only checked if the
- * passed AudioFormat matches one of the generally handled
- * formats (i.e. the fileType argument is ignored). If the
- * handled AudioFormats depend on the file type, this method
- * or getSupportedAudioFormats() (on which this method relies)
- * has to be overwritten by subclasses.
- * <p>
- * This is the central method for checking if a FORMAT is supported.
- * Inheriting classes can overwrite this for performance
- * or to exclude/include special type/format combinations.
- * <p>
- * This method is only called when the <code>fileType</code>
- * is in the list of supported file types ! Overriding
- * classes <b>need not</b> check this.
- */
- //$$fb 2000-08-16 changed name, changed documentation. Semantics !
- protected boolean isAudioFormatSupportedImpl(
- AudioFormat audioFormat,
- AudioFileFormat.Type fileType)
- {
- if (TDebug.TraceAudioFileWriter)
- {
- TDebug.out("> TAudioFileWriter.isAudioFormatSupportedImpl(): format to test: " + audioFormat);
- TDebug.out("class: "+getClass().getName());
- }
- Iterator audioFormats = getSupportedAudioFormats(fileType);
- while (audioFormats.hasNext())
- {
- AudioFormat handledFormat = (AudioFormat) audioFormats.next();
- if (TDebug.TraceAudioFileWriter) { TDebug.out("matching against format : " + handledFormat); }
- if (AudioFormats.matches(handledFormat, audioFormat))
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("<...succeeded."); }
- return true;
- }
- }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... failed"); }
- return false;
- }
-
-
-
- protected abstract AudioOutputStream getAudioOutputStream(
- AudioFormat audioFormat,
- long lLengthInBytes,
- AudioFileFormat.Type fileType,
- TDataOutputStream dataOutputStream)
- throws IOException;
-
- private AudioFormat findConvertableFormat(
- AudioFormat inputFormat,
- AudioFileFormat.Type fileType)
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("TAudioFileWriter.findConvertableFormat(): input format: " + inputFormat); }
- if (!isFileTypeSupported(fileType)) {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< input file type is not supported."); }
- return null;
- }
- AudioFormat.Encoding inputEncoding = inputFormat.getEncoding();
- if ((inputEncoding.equals(PCM_SIGNED) || inputEncoding.equals(PCM_UNSIGNED))
- && inputFormat.getSampleSizeInBits() == 8)
- {
- AudioFormat outputFormat = convertFormat(inputFormat, true, false);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("trying output format: " + outputFormat); }
- if (isAudioFormatSupportedImpl(outputFormat, fileType))
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... succeeded"); }
- return outputFormat;
- }
- //$$fb 2000-08-16: added trial of other endianness for 8bit. We try harder !
- outputFormat = convertFormat(inputFormat, false, true);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("trying output format: " + outputFormat); }
- if (isAudioFormatSupportedImpl(outputFormat, fileType))
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... succeeded"); }
- return outputFormat;
- }
- outputFormat = convertFormat(inputFormat, true, true);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("trying output format: " + outputFormat); }
- if (isAudioFormatSupportedImpl(outputFormat, fileType))
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... succeeded"); }
- return outputFormat;
- }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... failed"); }
- return null;
- }
- else if (inputEncoding.equals(PCM_SIGNED) &&
- (inputFormat.getSampleSizeInBits() == 16 ||
- inputFormat.getSampleSizeInBits() == 24 ||
- inputFormat.getSampleSizeInBits() == 32) )
- {
- // TODO: possible to allow all sample sized > 8 bit?
- // $$ fb: don't think that this is necessary. Well, let's talk about that in 5 years :)
- AudioFormat outputFormat = convertFormat(inputFormat, false, true);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("trying output format: " + outputFormat); }
- if (isAudioFormatSupportedImpl(outputFormat, fileType))
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... succeeded"); }
- return outputFormat;
- }
- else
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... failed"); }
- return null;
- }
- }
- else
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("< ... failed"); }
- return null;
- }
- }
-
- // $$fb 2000-08-16: added convenience method
- private AudioFormat convertFormat(AudioFormat format, boolean changeSign, boolean changeEndian) {
- AudioFormat.Encoding enc=PCM_SIGNED;
- if (format.getEncoding().equals(PCM_UNSIGNED)!=changeSign) {
- enc=PCM_UNSIGNED;
- }
- return new AudioFormat(
- enc,
- format.getSampleRate(),
- format.getSampleSizeInBits(),
- format.getChannels(),
- format.getFrameSize(),
- format.getFrameRate(),
- format.isBigEndian() ^ changeEndian);
- }
-
-}
-
-
-
-/*** TAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/TAudioOutputStream.java b/songdbj/org/tritonus/share/sampled/file/TAudioOutputStream.java
deleted file mode 100644
index e54316c0a6..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/TAudioOutputStream.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * TAudioOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.IOException;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-
-import org.tritonus.share.TDebug;
-
-
-/**
- * Base class for classes implementing AudioOutputStream.
- *
- * @author Matthias Pfisterer
- */
-
-public abstract class TAudioOutputStream
-implements AudioOutputStream
-{
- private AudioFormat m_audioFormat;
- private long m_lLength; // in bytes
- private long m_lCalculatedLength;
- private TDataOutputStream m_dataOutputStream;
- private boolean m_bDoBackPatching;
- private boolean m_bHeaderWritten;
-
-
-
- protected TAudioOutputStream(AudioFormat audioFormat,
- long lLength,
- TDataOutputStream dataOutputStream,
- boolean bDoBackPatching)
- {
- m_audioFormat = audioFormat;
- m_lLength = lLength;
- m_lCalculatedLength = 0;
- m_dataOutputStream = dataOutputStream;
- m_bDoBackPatching = bDoBackPatching;
- m_bHeaderWritten = false;
- }
-
-
-
- public AudioFormat getFormat()
- {
- return m_audioFormat;
- }
-
-
-
- /** Gives length of the stream.
- * This value is in bytes. It may be AudioSystem.NOT_SPECIFIED
- * to express that the length is unknown.
- */
- public long getLength()
- {
- return m_lLength;
- }
-
-
-
- /** Gives number of bytes already written.
- */
- // IDEA: rename this to BytesWritten or something like that ?
- public long getCalculatedLength()
- {
- return m_lCalculatedLength;
- }
-
- protected TDataOutputStream getDataOutputStream()
- {
- return m_dataOutputStream;
- }
-
-
- /** Writes audio data to the destination (file or output stream).
- */
- // IDEA: use long?
- public int write(byte[] abData, int nOffset, int nLength)
- throws IOException
- {
- if (TDebug.TraceAudioOutputStream)
- {
- TDebug.out("TAudioOutputStream.write(): wanted length: " + nLength);
- }
- if (! m_bHeaderWritten)
- {
- writeHeader();
- m_bHeaderWritten = true;
- }
- // $$fb added
- // check that total writes do not exceed specified length
- long lTotalLength=getLength();
- if (lTotalLength!=AudioSystem.NOT_SPECIFIED && (m_lCalculatedLength+nLength)>lTotalLength) {
- if (TDebug.TraceAudioOutputStream) {
- TDebug.out("TAudioOutputStream.write(): requested more bytes to write than possible.");
- }
- nLength=(int) (lTotalLength-m_lCalculatedLength);
- // sanity
- if (nLength<0) {
- nLength=0;
- }
- }
- // TODO: throw an exception if nLength==0 ? (to indicate end of file ?)
- if (nLength>0) {
- m_dataOutputStream.write(abData, nOffset, nLength);
- m_lCalculatedLength += nLength;
- }
- if (TDebug.TraceAudioOutputStream)
- {
- TDebug.out("TAudioOutputStream.write(): calculated (total) length: " + m_lCalculatedLength+" bytes = "+(m_lCalculatedLength/getFormat().getFrameSize())+" frames");
- }
- return nLength;
- }
-
-
-
- /** Writes the header of the audio file.
- */
- protected abstract void writeHeader()
- throws IOException;
-
-
-
- /** Closes the stream.
- * This does write remaining buffered data to the destination,
- * backpatch the header, if necessary, and closes the destination.
- */
- public void close()
- throws IOException
- {
- if (TDebug.TraceAudioOutputStream)
- {
- TDebug.out("TAudioOutputStream.close(): called");
- }
- // flush?
- if (m_bDoBackPatching)
- {
- if (TDebug.TraceAudioOutputStream)
- {
- TDebug.out("TAudioOutputStream.close(): patching header");
- }
- patchHeader();
- }
- m_dataOutputStream.close();
- }
-
-
-
- protected void patchHeader()
- throws IOException
- {
- TDebug.out("TAudioOutputStream.patchHeader(): called");
- // DO NOTHING
- }
-
-
-
- protected void setLengthFromCalculatedLength()
- {
- m_lLength = m_lCalculatedLength;
- }
-}
-
-
-
-/*** TAudioOutputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/TDataOutputStream.java b/songdbj/org/tritonus/share/sampled/file/TDataOutputStream.java
deleted file mode 100644
index eacc00a2e2..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/TDataOutputStream.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * TDataOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Florian Bomers <http://www.bomers.de>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.InputStream;
-
-
-/**
- * Interface for the file writing classes.
- * <p>Like that it is possible to write to a file without knowing
- * the length before.
- *
- * @author Florian Bomers
- */
-public interface TDataOutputStream
-extends DataOutput
-{
- public boolean supportsSeek();
-
-
-
- public void seek(long position)
- throws IOException;
-
-
-
- public long getFilePointer()
- throws IOException;
-
-
-
- public long length()
- throws IOException;
-
-
- public void writeLittleEndian32(int value)
- throws IOException;
-
-
- public void writeLittleEndian16(short value)
- throws IOException;
-
- public void close()
- throws IOException;
-}
-
-
-
-/*** TDataOutputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/THeaderlessAudioFileWriter.java b/songdbj/org/tritonus/share/sampled/file/THeaderlessAudioFileWriter.java
deleted file mode 100644
index a9d76de505..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/THeaderlessAudioFileWriter.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * THeaderlessAudioFileWriter.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 2000 - 2002 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioFormat;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Base class for formats without extra header.
- This AudioFileWriter is typically used for compressed formats
- where the encoder puts a header into the encoded stream. In this
- case, the AudioFileWriter needs not to add a header. This is why
- THeaderlessAudioOutputStream is used here.
-
- @author Florian Bomers
- @author Matthias Pfisterer
-*/
-public class THeaderlessAudioFileWriter
-extends TAudioFileWriter
-{
- protected THeaderlessAudioFileWriter(Collection<AudioFileFormat.Type> fileTypes,
- Collection<AudioFormat> audioFormats)
- {
- super(fileTypes, audioFormats);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("THeaderlessAudioFileWriter.<init>(): begin"); }
- if (TDebug.TraceAudioFileWriter) { TDebug.out("THeaderlessAudioFileWriter.<init>(): end"); }
- }
-
-
-
- protected AudioOutputStream getAudioOutputStream(
- AudioFormat audioFormat,
- long lLengthInBytes,
- AudioFileFormat.Type fileType,
- TDataOutputStream dataOutputStream)
- throws IOException
- {
- if (TDebug.TraceAudioFileWriter) { TDebug.out("THeaderlessAudioFileWriter.getAudioOutputStream(): begin"); }
- AudioOutputStream aos = new HeaderlessAudioOutputStream(
- audioFormat,
- lLengthInBytes,
- dataOutputStream);
- if (TDebug.TraceAudioFileWriter) { TDebug.out("THeaderlessAudioFileWriter.getAudioOutputStream(): end"); }
- return aos;
- }
-
-}
-
-
-
-/*** THeaderlessAudioFileWriter.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/TNonSeekableDataOutputStream.java b/songdbj/org/tritonus/share/sampled/file/TNonSeekableDataOutputStream.java
deleted file mode 100644
index 2e9704ed10..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/TNonSeekableDataOutputStream.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * TNonSeekableDataOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.DataOutputStream;
-
-
-
-/**
- * A TDataOutputStream that does not allow seeking.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class TNonSeekableDataOutputStream
-extends DataOutputStream
-implements TDataOutputStream
-{
- public TNonSeekableDataOutputStream(OutputStream outputStream)
- {
- super(outputStream);
- }
-
-
-
- public boolean supportsSeek()
- {
- return false;
- }
-
-
-
- public void seek(long position)
- throws IOException
- {
- throw new IllegalArgumentException("TNonSeekableDataOutputStream: Call to seek not allowed.");
- }
-
-
-
- public long getFilePointer()
- throws IOException
- {
- throw new IllegalArgumentException("TNonSeekableDataOutputStream: Call to getFilePointer not allowed.");
- }
-
-
-
- public long length()
- throws IOException
- {
- throw new IllegalArgumentException("TNonSeekableDataOutputStream: Call to length not allowed.");
- }
-
-
-
- public void writeLittleEndian32(int value)
- throws IOException
- {
- writeByte(value & 0xFF);
- writeByte((value >> 8) & 0xFF);
- writeByte((value >> 16) & 0xFF);
- writeByte((value >> 24) & 0xFF);
- }
-
-
-
- public void writeLittleEndian16(short value)
- throws IOException
- {
- writeByte(value & 0xFF);
- writeByte((value >> 8) & 0xFF);
- }
-}
-
-
-
-/*** TNonSeekableDataOutputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/TSeekableDataOutputStream.java b/songdbj/org/tritonus/share/sampled/file/TSeekableDataOutputStream.java
deleted file mode 100644
index 6f688c5b2e..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/TSeekableDataOutputStream.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * TSeekableDataOutputStream.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Florian Bomers <http://www.bomers.de>
- * Copyright (c) 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.file;
-
-import java.io.File;
-import java.io.RandomAccessFile;
-import java.io.IOException;
-
-
-
-/**
- * A TDataOutputStream that allows seeking.
- *
- * @author Florian Bomers
- * @author Matthias Pfisterer
- */
-public class TSeekableDataOutputStream
-extends RandomAccessFile
-implements TDataOutputStream
-{
- public TSeekableDataOutputStream(File file)
- throws IOException
- {
- super(file, "rw");
- }
-
-
-
- public boolean supportsSeek()
- {
- return true;
- }
-
-
-
- public void writeLittleEndian32(int value)
- throws IOException
- {
- writeByte(value & 0xFF);
- writeByte((value >> 8) & 0xFF);
- writeByte((value >> 16) & 0xFF);
- writeByte((value >> 24) & 0xFF);
- }
-
-
-
- public void writeLittleEndian16(short value)
- throws IOException
- {
- writeByte(value & 0xFF);
- writeByte((value >> 8) & 0xFF);
- }
-}
-
-
-
-/*** TSeekableDataOutputStream.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/file/package.html b/songdbj/org/tritonus/share/sampled/file/package.html
deleted file mode 100644
index a79274048c..0000000000
--- a/songdbj/org/tritonus/share/sampled/file/package.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Base classes for the implementation of AudioFileReaders and AudioFileWriters.
- The classes provided here .</p>
-
- @see javax.sound.sampled.spi.AudioFileReader
- @see javax.sound.sampled.spi.AudioFileWriter
- @see org.tritonus.sampled.file
- @see org.tritonus.sampled.file.gsm
- @see org.tritonus.sampled.file.jorbis
- @see org.tritonus.sampled.file.mpeg
- @see org.tritonus.sampled.file.vorbis
- </body>
-</html>
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TBaseDataLine.java b/songdbj/org/tritonus/share/sampled/mixer/TBaseDataLine.java
deleted file mode 100644
index e589439838..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TBaseDataLine.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * TBaseDataLine.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.Collection;
-import java.util.EventListener;
-import java.util.EventObject;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.DataLine;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.Line;
-import javax.sound.sampled.LineUnavailableException;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Base class for implementing SourceDataLine or TargetDataLine.
- */
-public abstract class TBaseDataLine
-extends TDataLine
-{
- public TBaseDataLine(TMixer mixer,
- DataLine.Info info)
- {
- super(mixer,
- info);
- }
-
-
-
- public TBaseDataLine(TMixer mixer,
- DataLine.Info info,
- Collection<Control> controls)
- {
- super(mixer,
- info,
- controls);
- }
-
-
-
- public void open(AudioFormat format, int nBufferSize)
- throws LineUnavailableException
- {
- if (TDebug.TraceDataLine) { TDebug.out("TBaseDataLine.open(AudioFormat, int): called with buffer size: " + nBufferSize); }
- setBufferSize(nBufferSize);
- open(format);
- }
-
-
-
- public void open(AudioFormat format)
- throws LineUnavailableException
- {
- if (TDebug.TraceDataLine) { TDebug.out("TBaseDataLine.open(AudioFormat): called"); }
- setFormat(format);
- open();
- }
-
-
- // IDEA: move to TDataLine or TLine?
- // necessary and wise at all?
- protected void finalize()
- {
- if (isOpen())
- {
- close();
- }
- }
-}
-
-
-
-/*** TBaseDataLine.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TBooleanControl.java b/songdbj/org/tritonus/share/sampled/mixer/TBooleanControl.java
deleted file mode 100644
index a722edbf31..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TBooleanControl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * TBooleanControl.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import javax.sound.sampled.BooleanControl;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-/** Base class for classes implementing BooleanControl.
- */
-public class TBooleanControl
-extends BooleanControl
-implements TControllable
-{
- private TControlController m_controller;
-
-
-
- public TBooleanControl(BooleanControl.Type type,
- boolean bInitialValue)
- {
- this(type, bInitialValue, null);
- }
-
-
-
- public TBooleanControl(BooleanControl.Type type,
- boolean bInitialValue,
- TCompoundControl parentControl)
- {
- super(type, bInitialValue);
- if (TDebug.TraceControl)
- {
- TDebug.out("TBooleanControl.<init>: begin");
- }
- m_controller = new TControlController();
- if (TDebug.TraceControl)
- {
- TDebug.out("TBooleanControl.<init>: end");
- }
- }
-
-
-
- public TBooleanControl(BooleanControl.Type type,
- boolean bInitialValue,
- String strTrueStateLabel,
- String strFalseStateLabel)
- {
- this(type, bInitialValue, strTrueStateLabel, strFalseStateLabel, null);
- }
-
-
-
- public TBooleanControl(BooleanControl.Type type,
- boolean bInitialValue,
- String strTrueStateLabel,
- String strFalseStateLabel,
- TCompoundControl parentControl)
- {
- super(type, bInitialValue, strTrueStateLabel, strFalseStateLabel);
- if (TDebug.TraceControl)
- {
- TDebug.out("TBooleanControl.<init>: begin");
- }
- m_controller = new TControlController();
- if (TDebug.TraceControl)
- {
- TDebug.out("TBooleanControl.<init>: end");
- }
- }
-
-
-
- public void setParentControl(TCompoundControl compoundControl)
- {
- m_controller.setParentControl(compoundControl);
- }
-
-
-
- public TCompoundControl getParentControl()
- {
- return m_controller.getParentControl();
- }
-
-
-
- public void commit()
- {
- m_controller.commit();
- }
-}
-
-
-
-/*** TBooleanControl.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TClip.java b/songdbj/org/tritonus/share/sampled/mixer/TClip.java
deleted file mode 100644
index e0a8140c37..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TClip.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * TClip.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.util.Collection;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Clip;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.DataLine;
-import javax.sound.sampled.SourceDataLine;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Mixer;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.mixer.TDataLine;
-
-
-
-public class TClip
-extends TDataLine
-implements Clip
-{
- private static final Class[] CONTROL_CLASSES = {/*GainControl.class*/};
- private static final int BUFFER_FRAMES = 16384;
-
-
- public TClip(DataLine.Info info)
- {
- super(null, // TMixer
- info);
- }
-
-
-
- public TClip(DataLine.Info info,
- Collection<Control> controls)
- {
- super(null, // TMixer
- info,
- controls);
- }
-
-
-
- public void open(AudioFormat audioFormat,
- byte[] abData,
- int nOffset,
- int nLength)
- throws LineUnavailableException
- {
- // int nBufferLength = nNumFrames * audioFormat.getFrameSize();
- // TODO: check if nOffset + nBufferLength <= abData.length
- // perhaps truncate automatically
- ByteArrayInputStream bais = new ByteArrayInputStream(abData, nOffset, nLength);
- AudioInputStream audioInputStream = new AudioInputStream(bais, audioFormat, AudioSystem.NOT_SPECIFIED);
- try
- {
- open(audioInputStream);
- }
- catch (IOException e)
- {
- if (TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- throw new LineUnavailableException("IOException occured");
- }
- }
-
-
-
- public void open(AudioInputStream audioInputStream)
- throws LineUnavailableException, IOException
- {
- AudioFormat audioFormat = audioInputStream.getFormat();
- // TOOD:
- DataLine.Info info = new DataLine.Info(Clip.class,
- audioFormat, -1/*nBufferSize*/);
-/*
- setLineInfo(info);
- int nFrameSize = audioFormat.getFrameSize();
- long lTotalLength = audioInputStream.getFrameLength() * nFrameSize;
- int nFormat = Esd.ESD_STREAM | Esd.ESD_PLAY | EsdUtils.getEsdFormat(audioFormat);
- if (TDebug.TraceClip)
- {
- TDebug.out("format: " + nFormat);
- TDebug.out("sample rate: " + audioFormat.getSampleRate());
- }
- // m_esdSample.open(nFormat, (int) audioFormat.getSampleRate(), (int) lTotalLength);
- if (TDebug.TraceClip)
- {
- TDebug.out("size in esd: " + audioInputStream.getFrameLength() * nFrameSize);
- }
- int nBufferLength = BUFFER_FRAMES * nFrameSize;
- byte[] abData = new byte[nBufferLength];
- int nBytesRead = 0;
- int nTotalBytes = 0;
- while (nBytesRead != -1)
- {
- try
- {
- nBytesRead = audioInputStream.read(abData, 0, abData.length);
- }
- catch (IOException e)
- {
- if (TDebug.TraceClip || TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- }
- if (nBytesRead >= 0)
- {
- nTotalBytes += nBytesRead;
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.open(): total bytes: " + nTotalBytes);
- TDebug.out("TClip.open(): Trying to write: " + nBytesRead);
- }
- int nBytesWritten = 0; //m_esdSample.write(abData, 0, nBytesRead);
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.open(): Written: " + nBytesWritten);
- }
- }
- }
- // to trigger the events
- // open();
- */
- }
-
-
-
- public int getFrameLength()
- {
- // TODO:
- return -1;
- }
-
-
-
- public long getMicrosecondLength()
- {
- // TODO:
- return -1;
- }
-
-
-
- public void setFramePosition(int nPosition)
- {
- // TOOD:
- }
-
-
-
- public void setMicrosecondPosition(long lPosition)
- {
- // TOOD:
- }
-
-
-
- public int getFramePosition()
- {
- // TOOD:
- return -1;
- }
-
-
-
- public long getMicrosecondPosition()
- {
- // TOOD:
- return -1;
- }
-
-
-
- public void setLoopPoints(int nStart, int nEnd)
- {
- // TOOD:
- }
-
-
-
- public void loop(int nCount)
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.loop(int): called; count = " + nCount);
- }
- if (false/*isStarted()*/)
- {
- /*
- * only allow zero count to stop the looping
- * at the end of an iteration.
- */
- if (nCount == 0)
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.loop(int): stopping sample");
- }
- // m_esdSample.stop();
- }
- }
- else
- {
- if (nCount == 0)
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.loop(int): starting sample (once)");
- }
- // m_esdSample.play();
- }
- else
- {
- /*
- * we're ignoring the count, because esd
- * cannot loop for a fixed number of
- * times.
- */
- // TDebug.out("hallo");
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.loop(int): starting sample (forever)");
- }
- // m_esdSample.loop();
- }
- }
- // TOOD:
- }
-
-
-
- public void flush()
- {
- // TOOD:
- }
-
-
-
- public void drain()
- {
- // TOOD:
- }
-
-
-
- public void close()
- {
- // m_esdSample.free();
- // m_esdSample.close();
- // TOOD:
- }
-
-
-
-
- public void open()
- {
- // TODO:
- }
-
-
-
- public void start()
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.start(): called");
- }
- /*
- * This is a hack. What start() really should do is
- * start playing at the position playback was stopped.
- */
- if (TDebug.TraceClip)
- {
- TDebug.out("TClip.start(): calling 'loop(0)' [hack]");
- }
- loop(0);
- }
-
-
-
- public void stop()
- {
- // TODO:
- // m_esdSample.kill();
- }
-
-
-
- /*
- * This method is enforced by DataLine, but doesn't make any
- * sense for Clips.
- */
- public int available()
- {
- return -1;
- }
-}
-
-
-
-/*** TClip.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TCompoundControl.java b/songdbj/org/tritonus/share/sampled/mixer/TCompoundControl.java
deleted file mode 100644
index 4a370eb86c..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TCompoundControl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * TCompoundControl.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import javax.sound.sampled.CompoundControl;
-import javax.sound.sampled.Control;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-/** Base class for classes implementing Line.
- */
-public class TCompoundControl
-extends CompoundControl
-implements TControllable
-{
- private TControlController m_controller;
-
-
-
- public TCompoundControl(CompoundControl.Type type,
- Control[] aMemberControls)
- {
- super(type, aMemberControls);
- if (TDebug.TraceControl)
- {
- TDebug.out("TCompoundControl.<init>: begin");
- }
- m_controller = new TControlController();
- if (TDebug.TraceControl)
- {
- TDebug.out("TCompoundControl.<init>: end");
- }
- }
-
-
-
- public void setParentControl(TCompoundControl compoundControl)
- {
- m_controller.setParentControl(compoundControl);
- }
-
-
-
- public TCompoundControl getParentControl()
- {
- return m_controller.getParentControl();
- }
-
-
-
- public void commit()
- {
- m_controller.commit();
- }
-}
-
-
-
-/*** TCompoundControl.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TCompoundControlType.java b/songdbj/org/tritonus/share/sampled/mixer/TCompoundControlType.java
deleted file mode 100644
index 1b90b1a673..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TCompoundControlType.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * TCompoundControlType.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import javax.sound.sampled.CompoundControl;
-
-
-
-/** CompoundControl.Type class.
- This class is only needed to provide a public constructor.
- */
-public class TCompoundControlType
-extends CompoundControl.Type
-{
- /** Constructor.
- Constructs a CompoundControl.Type with the
- name given.
-
- @param strName The name of the control.
- */
- public TCompoundControlType(String strName)
- {
- super(strName);
- }
-}
-
-
-
-/*** TCompoundControlType.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TControlController.java b/songdbj/org/tritonus/share/sampled/mixer/TControlController.java
deleted file mode 100644
index ec17c45b59..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TControlController.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * TControlController.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.Line;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Port;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-/** Base class for classes implementing Line.
- */
-public class TControlController
-implements TControllable
-{
- /** The parent (compound) control.
- In case this control is part of a compound control, the parentControl
- property is set to a value other than null.
- */
- private TCompoundControl m_parentControl;
-
-
- public TControlController()
- {
- }
-
-
-
- public void setParentControl(TCompoundControl compoundControl)
- {
- m_parentControl = compoundControl;
- }
-
-
- public TCompoundControl getParentControl()
- {
- return m_parentControl;
- }
-
-
- public void commit()
- {
- if (TDebug.TraceControl)
- {
- TDebug.out("TControlController.commit(): called [" + this.getClass().getName() + "]");
- }
- if (getParentControl() != null)
- {
- getParentControl().commit();
- }
- }
-}
-
-
-
-/*** TControlController.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TControllable.java b/songdbj/org/tritonus/share/sampled/mixer/TControllable.java
deleted file mode 100644
index b89d34a2b3..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TControllable.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * TControllable.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.Line;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Port;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-public interface TControllable
-{
- public void setParentControl(TCompoundControl compoundControl);
- public TCompoundControl getParentControl();
- public void commit();
-}
-
-
-
-/*** TControllable.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TDataLine.java b/songdbj/org/tritonus/share/sampled/mixer/TDataLine.java
deleted file mode 100644
index a493bac6c5..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TDataLine.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * TDataLine.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.Collection;
-import java.util.EventListener;
-import java.util.EventObject;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.DataLine;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.Line;
-
-import org.tritonus.share.TDebug;
-
-
-
-/** Base class for classes implementing DataLine.
- */
-public abstract class TDataLine
-extends TLine
-implements DataLine
-{
- private static final int DEFAULT_BUFFER_SIZE = 128000;
-
- private AudioFormat m_format;
- private int m_nBufferSize;
- private boolean m_bRunning;
- // private boolean m_bActive;
-
-
-
-
- public TDataLine(TMixer mixer,
- DataLine.Info info)
- {
- super(mixer,
- info);
- init(info);
- }
-
-
-
- public TDataLine(TMixer mixer,
- DataLine.Info info,
- Collection<Control> controls)
- {
- super(mixer,
- info,
- controls);
- init(info);
- }
-
-
-
- // IDEA: extract format and bufsize from info?
- private void init(DataLine.Info info)
- {
- m_format = null;
- m_nBufferSize = AudioSystem.NOT_SPECIFIED;
- setRunning(false);
- // setActive(false);
- }
-
-
-
- // not defined here:
- // public void drain()
- // public void flush()
-
-
-
- public void start()
- {
- if (TDebug.TraceSourceDataLine)
- {
- TDebug.out("TDataLine.start(): called");
- }
- setRunning(true);
- }
-
-
-
- public void stop()
- {
- if (TDebug.TraceSourceDataLine)
- {
- TDebug.out("TDataLine.stop(): called");
- }
- setRunning(false);
- }
-
-
-
- public boolean isRunning()
- {
- return m_bRunning;
- }
-
-
-
- // TODO: recheck
- protected void setRunning(boolean bRunning)
- {
- boolean bOldValue = isRunning();
- m_bRunning = bRunning;
- if (bOldValue != isRunning())
- {
- if (isRunning())
- {
- startImpl();
- notifyLineEvent(LineEvent.Type.START);
- }
- else
- {
- stopImpl();
- notifyLineEvent(LineEvent.Type.STOP);
- }
- }
- }
-
-
-
- protected void startImpl()
- {
- }
-
-
-
- protected void stopImpl()
- {
- }
-
-
-
- /**
- * This implementation returns the status of isRunning().
- * Subclasses should overwrite this method if there is more
- * precise information about the status of the line available.
- */
- public boolean isActive()
- {
- return isRunning();
- }
-
-
-/*
- public boolean isStarted()
- {
- return m_bStarted;
- }
-*/
-
- // TODO: should only ALLOW engaging in data I/O.
- // actual START event should only be sent when line really becomes active
-/*
- protected void setStarted(boolean bStarted)
- {
- m_bStarted = bStarted;
- if (!isRunning())
- {
- setActive(false);
- }
- }
-*/
-
-
- public AudioFormat getFormat()
- {
- return m_format;
- }
-
-
-
- protected void setFormat(AudioFormat format)
- {
- if (TDebug.TraceDataLine)
- {
- TDebug.out("TDataLine.setFormat(): setting: " + format);
- }
- m_format = format;
- }
-
-
-
- public int getBufferSize()
- {
- return m_nBufferSize;
- }
-
-
-
- protected void setBufferSize(int nBufferSize)
- {
- if (TDebug.TraceDataLine)
- {
- TDebug.out("TDataLine.setBufferSize(): setting: " + nBufferSize);
- }
- m_nBufferSize = nBufferSize;
- }
-
-
-
- // not defined here:
- // public int available()
-
-
-
- public int getFramePosition()
- {
- // TODO:
- return -1;
- }
-
-
-
- public long getLongFramePosition()
- {
- // TODO:
- return -1;
- }
-
-
-
- public long getMicrosecondPosition()
- {
- return (long) (getFramePosition() * getFormat().getFrameRate() * 1000000);
- }
-
-
-
- /*
- * Has to be overridden to be useful.
- */
- public float getLevel()
- {
- return AudioSystem.NOT_SPECIFIED;
- }
-
-
-
- protected void checkOpen()
- {
- if (getFormat() == null)
- {
- throw new IllegalStateException("format must be specified");
- }
- if (getBufferSize() == AudioSystem.NOT_SPECIFIED)
- {
- setBufferSize(getDefaultBufferSize());
- }
- }
-
-
-
- protected int getDefaultBufferSize()
- {
- return DEFAULT_BUFFER_SIZE;
- }
-
-
-
- protected void notifyLineEvent(LineEvent.Type type)
- {
- notifyLineEvent(new LineEvent(this, type, getFramePosition()));
- }
-}
-
-
-
-/*** TDataLine.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TEnumControl.java b/songdbj/org/tritonus/share/sampled/mixer/TEnumControl.java
deleted file mode 100644
index 2c9132401f..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TEnumControl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * TEnumControl.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import javax.sound.sampled.EnumControl;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-/** Base class for classes implementing Line.
- */
-public class TEnumControl
-extends EnumControl
-implements TControllable
-{
- private TControlController m_controller;
-
-
-
- public TEnumControl(EnumControl.Type type,
- Object[] aValues,
- Object value)
- {
- super(type,
- aValues,
- value);
- if (TDebug.TraceControl)
- {
- TDebug.out("TEnumControl.<init>: begin");
- }
- m_controller = new TControlController();
- if (TDebug.TraceControl)
- {
- TDebug.out("TEnumControl.<init>: end");
- }
- }
-
-
-
- public void setParentControl(TCompoundControl compoundControl)
- {
- m_controller.setParentControl(compoundControl);
- }
-
-
-
- public TCompoundControl getParentControl()
- {
- return m_controller.getParentControl();
- }
-
-
-
- public void commit()
- {
- m_controller.commit();
- }
-}
-
-
-
-/*** TEnumControl.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TFloatControl.java b/songdbj/org/tritonus/share/sampled/mixer/TFloatControl.java
deleted file mode 100644
index 8a80016865..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TFloatControl.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * TFloatControl.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 2001 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import javax.sound.sampled.FloatControl;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-/** Base class for classes implementing Line.
- */
-public class TFloatControl
-extends FloatControl
-implements TControllable
-{
- private TControlController m_controller;
-
-
-
- public TFloatControl(FloatControl.Type type,
- float fMinimum,
- float fMaximum,
- float fPrecision,
- int nUpdatePeriod,
- float fInitialValue,
- String strUnits)
- {
- super(type,
- fMinimum,
- fMaximum,
- fPrecision,
- nUpdatePeriod,
- fInitialValue,
- strUnits);
- if (TDebug.TraceControl)
- {
- TDebug.out("TFloatControl.<init>: begin");
- }
- m_controller = new TControlController();
- if (TDebug.TraceControl)
- {
- TDebug.out("TFloatControl.<init>: end");
- }
- }
-
-
-
- public TFloatControl(FloatControl.Type type,
- float fMinimum,
- float fMaximum,
- float fPrecision,
- int nUpdatePeriod,
- float fInitialValue,
- String strUnits,
- String strMinLabel,
- String strMidLabel,
- String strMaxLabel)
- {
- super(type,
- fMinimum,
- fMaximum,
- fPrecision,
- nUpdatePeriod,
- fInitialValue,
- strUnits,
- strMinLabel,
- strMidLabel,
- strMaxLabel);
- if (TDebug.TraceControl)
- {
- TDebug.out("TFloatControl.<init>: begin");
- }
- m_controller = new TControlController();
- if (TDebug.TraceControl)
- {
- TDebug.out("TFloatControl.<init>: end");
- }
- }
-
-
-
- public void setParentControl(TCompoundControl compoundControl)
- {
- m_controller.setParentControl(compoundControl);
- }
-
-
-
- public TCompoundControl getParentControl()
- {
- return m_controller.getParentControl();
- }
-
-
-
- public void commit()
- {
- m_controller.commit();
- }
-}
-
-
-
-/*** TFloatControl.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TLine.java b/songdbj/org/tritonus/share/sampled/mixer/TLine.java
deleted file mode 100644
index 89b38099ed..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TLine.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * TLine.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.Line;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineUnavailableException;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.TNotifier;
-
-
-
-
-/** Base class for classes implementing Line.
- */
-public abstract class TLine
-implements Line
-{
- private static final Control[] EMPTY_CONTROL_ARRAY = new Control[0];
-
- private Line.Info m_info;
- private boolean m_bOpen;
- private List<Control> m_controls;
- private Set<LineListener> m_lineListeners;
- private TMixer m_mixer;
-
-
-
- protected TLine(TMixer mixer,
- Line.Info info)
- {
- setLineInfo(info);
- setOpen(false);
- m_controls = new ArrayList<Control>();
- m_lineListeners = new HashSet<LineListener>();
- m_mixer = mixer;
- }
-
-
-
- protected TLine(TMixer mixer,
- Line.Info info,
- Collection<Control> controls)
- {
- this (mixer, info);
- m_controls.addAll(controls);
- }
-
-
- protected TMixer getMixer()
- {
- return m_mixer;
- }
-
-
- public Line.Info getLineInfo()
- {
- return m_info;
- }
-
-
-
- protected void setLineInfo(Line.Info info)
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.setLineInfo(): setting: " + info);
- }
- synchronized (this)
- {
- m_info = info;
- }
- }
-
-
-
- public void open()
- throws LineUnavailableException
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.open(): called");
- }
- if (! isOpen())
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.open(): opening");
- }
- openImpl();
- if (getMixer() != null)
- {
- getMixer().registerOpenLine(this);
- }
- setOpen(true);
- }
- else
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.open(): already open");
- }
- }
- }
-
-
-
- /**
- * Subclasses should override this method.
- */
- protected void openImpl()
- throws LineUnavailableException
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.openImpl(): called");
- }
- }
-
-
-
- public void close()
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.close(): called");
- }
- if (isOpen())
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.close(): closing");
- }
- if (getMixer() != null)
- {
- getMixer().unregisterOpenLine(this);
- }
- closeImpl();
- setOpen(false);
- }
- else
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.close(): not open");
- }
- }
- }
-
-
-
- /**
- * Subclasses should override this method.
- */
- protected void closeImpl()
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.closeImpl(): called");
- }
- }
-
-
-
-
-
- public boolean isOpen()
- {
- return m_bOpen;
- }
-
-
-
-
- protected void setOpen(boolean bOpen)
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.setOpen(): called, value: " + bOpen);
- }
- boolean bOldValue = isOpen();
- m_bOpen = bOpen;
- if (bOldValue != isOpen())
- {
- if (isOpen())
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.setOpen(): opened");
- }
- notifyLineEvent(LineEvent.Type.OPEN);
- }
- else
- {
- if (TDebug.TraceLine)
- {
- TDebug.out("TLine.setOpen(): closed");
- }
- notifyLineEvent(LineEvent.Type.CLOSE);
- }
- }
- }
-
-
-
- protected void addControl(Control control)
- {
- synchronized (m_controls)
- {
- m_controls.add(control);
- }
- }
-
-
-
- protected void removeControl(Control control)
- {
- synchronized (m_controls)
- {
- m_controls.remove(control);
- }
- }
-
-
-
- public Control[] getControls()
- {
- synchronized (m_controls)
- {
- return m_controls.toArray(EMPTY_CONTROL_ARRAY);
- }
- }
-
-
-
- public Control getControl(Control.Type controlType)
- {
- synchronized (m_controls)
- {
- Iterator<Control> it = m_controls.iterator();
- while (it.hasNext())
- {
- Control control = it.next();
- if (control.getType().equals(controlType))
- {
- return control;
- }
- }
- throw new IllegalArgumentException("no control of type " + controlType);
- }
- }
-
-
-
- public boolean isControlSupported(Control.Type controlType)
- {
- // TDebug.out("TLine.isSupportedControl(): called");
- try
- {
- return getControl(controlType) != null;
- }
- catch (IllegalArgumentException e)
- {
- if (TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- // TDebug.out("TLine.isSupportedControl(): returning false");
- return false;
- }
- }
-
-
-
- public void addLineListener(LineListener listener)
- {
- // TDebug.out("%% TChannel.addListener(): called");
- synchronized (m_lineListeners)
- {
- m_lineListeners.add(listener);
- }
- }
-
-
-
- public void removeLineListener(LineListener listener)
- {
- synchronized (m_lineListeners)
- {
- m_lineListeners.remove(listener);
- }
- }
-
-
-
- private Set<LineListener> getLineListeners()
- {
- synchronized (m_lineListeners)
- {
- return new HashSet<LineListener>(m_lineListeners);
- }
- }
-
-
- // is overridden in TDataLine to provide a position
- protected void notifyLineEvent(LineEvent.Type type)
- {
- notifyLineEvent(new LineEvent(this, type, AudioSystem.NOT_SPECIFIED));
- }
-
-
-
- protected void notifyLineEvent(LineEvent event)
- {
- // TDebug.out("%% TChannel.notifyChannelEvent(): called");
- // Channel.Event event = new Channel.Event(this, type, getPosition());
- TNotifier.notifier.addEntry(event, getLineListeners());
- }
-}
-
-
-
-/*** TLine.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TMixer.java b/songdbj/org/tritonus/share/sampled/mixer/TMixer.java
deleted file mode 100644
index 6a5dc4db72..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TMixer.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * TMixer.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.Clip;
-import javax.sound.sampled.DataLine;
-import javax.sound.sampled.Line;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Mixer;
-import javax.sound.sampled.Port;
-import javax.sound.sampled.SourceDataLine;
-import javax.sound.sampled.TargetDataLine;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.AudioFormats;
-import org.tritonus.share.ArraySet;
-
-
-
-// TODO: global controls (that use the system mixer)
-public abstract class TMixer
-extends TLine
-implements Mixer
-{
- private static Line.Info[] EMPTY_LINE_INFO_ARRAY = new Line.Info[0];
- private static Line[] EMPTY_LINE_ARRAY = new Line[0];
-
- private Mixer.Info m_mixerInfo;
- private Collection<AudioFormat> m_supportedSourceFormats;
- private Collection<AudioFormat> m_supportedTargetFormats;
- private Collection<Line.Info> m_supportedSourceLineInfos;
- private Collection<Line.Info> m_supportedTargetLineInfos;
- private Set<SourceDataLine> m_openSourceDataLines;
- private Set<TargetDataLine> m_openTargetDataLines;
-
-
- /** Constructor for mixers that use setSupportInformation().
- */
- protected TMixer(Mixer.Info mixerInfo,
- Line.Info lineInfo)
- {
- this(mixerInfo,
- lineInfo,
- new ArrayList<AudioFormat>(),
- new ArrayList<AudioFormat>(),
- new ArrayList<Line.Info>(),
- new ArrayList<Line.Info>());
- }
-
-
-
- /** Constructor for mixers.
- */
- protected TMixer(Mixer.Info mixerInfo,
- Line.Info lineInfo,
- Collection<AudioFormat> supportedSourceFormats,
- Collection<AudioFormat> supportedTargetFormats,
- Collection<Line.Info> supportedSourceLineInfos,
- Collection<Line.Info> supportedTargetLineInfos)
- {
- super(null, // TMixer
- lineInfo);
- if (TDebug.TraceMixer) { TDebug.out("TMixer.<init>(): begin"); }
- m_mixerInfo = mixerInfo;
- setSupportInformation(
- supportedSourceFormats,
- supportedTargetFormats,
- supportedSourceLineInfos,
- supportedTargetLineInfos);
- m_openSourceDataLines = new ArraySet<SourceDataLine>();
- m_openTargetDataLines = new ArraySet<TargetDataLine>();
- if (TDebug.TraceMixer) { TDebug.out("TMixer.<init>(): end"); }
- }
-
-
-
- protected void setSupportInformation(
- Collection<AudioFormat> supportedSourceFormats,
- Collection<AudioFormat> supportedTargetFormats,
- Collection<Line.Info> supportedSourceLineInfos,
- Collection<Line.Info> supportedTargetLineInfos)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.setSupportInformation(): begin"); }
- m_supportedSourceFormats = supportedSourceFormats;
- m_supportedTargetFormats = supportedTargetFormats;
- m_supportedSourceLineInfos = supportedSourceLineInfos;
- m_supportedTargetLineInfos = supportedTargetLineInfos;
- if (TDebug.TraceMixer) { TDebug.out("TMixer.setSupportInformation(): end"); }
- }
-
-
-
- public Mixer.Info getMixerInfo()
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getMixerInfo(): begin"); }
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getMixerInfo(): end"); }
- return m_mixerInfo;
- }
-
-
-
- public Line.Info[] getSourceLineInfo()
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSourceLineInfo(): begin"); }
- Line.Info[] infos = (Line.Info[]) m_supportedSourceLineInfos.toArray(EMPTY_LINE_INFO_ARRAY);
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSourceLineInfo(): end"); }
- return infos;
- }
-
-
-
- public Line.Info[] getTargetLineInfo()
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getTargetLineInfo(): begin"); }
- Line.Info[] infos = (Line.Info[]) m_supportedTargetLineInfos.toArray(EMPTY_LINE_INFO_ARRAY);
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getTargetLineInfo(): end"); }
- return infos;
- }
-
-
-
- public Line.Info[] getSourceLineInfo(Line.Info info)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSourceLineInfo(Line.Info): info to test: " + info); }
- // TODO:
- return EMPTY_LINE_INFO_ARRAY;
- }
-
-
-
- public Line.Info[] getTargetLineInfo(Line.Info info)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getTargetLineInfo(Line.Info): info to test: " + info); }
- // TODO:
- return EMPTY_LINE_INFO_ARRAY;
- }
-
-
-
- public boolean isLineSupported(Line.Info info)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.isLineSupported(): info to test: " + info); }
- Class lineClass = info.getLineClass();
- if (lineClass.equals(SourceDataLine.class))
- {
- return isLineSupportedImpl(info, m_supportedSourceLineInfos);
- }
- else if (lineClass.equals(TargetDataLine.class))
- {
- return isLineSupportedImpl(info, m_supportedTargetLineInfos);
- }
- else if (lineClass.equals(Port.class))
- {
- return isLineSupportedImpl(info, m_supportedSourceLineInfos) || isLineSupportedImpl(info, m_supportedTargetLineInfos);
- }
- else
- {
- return false;
- }
- }
-
-
-
- private static boolean isLineSupportedImpl(Line.Info info, Collection supportedLineInfos)
- {
- Iterator iterator = supportedLineInfos.iterator();
- while (iterator.hasNext())
- {
- Line.Info info2 = (Line.Info) iterator.next();
- if (info2.matches(info))
- {
- return true;
- }
- }
- return false;
- }
-
-
-
- public Line getLine(Line.Info info)
- throws LineUnavailableException
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getLine(): begin"); }
- Class lineClass = info.getLineClass();
- DataLine.Info dataLineInfo = null;
- Port.Info portInfo = null;
- AudioFormat[] aFormats = null;
- if (info instanceof DataLine.Info)
- {
- dataLineInfo = (DataLine.Info) info;
- aFormats = dataLineInfo.getFormats();
- }
- else if (info instanceof Port.Info)
- {
- portInfo = (Port.Info) info;
- }
- AudioFormat format = null;
- Line line = null;
- if (lineClass == SourceDataLine.class)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getLine(): type: SourceDataLine"); }
- if (dataLineInfo == null)
- {
- throw new IllegalArgumentException("need DataLine.Info for SourceDataLine");
- }
- format = getSupportedSourceFormat(aFormats);
- line = getSourceDataLine(format, dataLineInfo.getMaxBufferSize());
- }
- else if (lineClass == Clip.class)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getLine(): type: Clip"); }
- if (dataLineInfo == null)
- {
- throw new IllegalArgumentException("need DataLine.Info for Clip");
- }
- format = getSupportedSourceFormat(aFormats);
- line = getClip(format);
- }
- else if (lineClass == TargetDataLine.class)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getLine(): type: TargetDataLine"); }
- if (dataLineInfo == null)
- {
- throw new IllegalArgumentException("need DataLine.Info for TargetDataLine");
- }
- format = getSupportedTargetFormat(aFormats);
- line = getTargetDataLine(format, dataLineInfo.getMaxBufferSize());
- }
- else if (lineClass == Port.class)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getLine(): type: TargetDataLine"); }
- if (portInfo == null)
- {
- throw new IllegalArgumentException("need Port.Info for Port");
- }
- line = getPort(portInfo);
- }
- else
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getLine(): unknown line type, will throw exception"); }
- throw new LineUnavailableException("unknown line class: " + lineClass);
- }
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getLine(): end"); }
- return line;
- }
-
-
-
- protected SourceDataLine getSourceDataLine(AudioFormat format, int nBufferSize)
- throws LineUnavailableException
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSourceDataLine(): begin"); }
- throw new IllegalArgumentException("this mixer does not support SourceDataLines");
- }
-
-
-
- protected Clip getClip(AudioFormat format)
- throws LineUnavailableException
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getClip(): begin"); }
- throw new IllegalArgumentException("this mixer does not support Clips");
- }
-
-
-
- protected TargetDataLine getTargetDataLine(AudioFormat format, int nBufferSize)
- throws LineUnavailableException
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getTargetDataLine(): begin"); }
- throw new IllegalArgumentException("this mixer does not support TargetDataLines");
- }
-
-
-
- protected Port getPort(Port.Info info)
- throws LineUnavailableException
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getTargetDataLine(): begin"); }
- throw new IllegalArgumentException("this mixer does not support Ports");
- }
-
-
-
- private AudioFormat getSupportedSourceFormat(AudioFormat[] aFormats)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedSourceFormat(): begin"); }
- AudioFormat format = null;
- for (int i = 0; i < aFormats.length; i++)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedSourceFormat(): checking " + aFormats[i] + "..."); }
- if (isSourceFormatSupported(aFormats[i]))
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedSourceFormat(): ...supported"); }
- format = aFormats[i];
- break;
- }
- else
- {
- if (TDebug.TraceMixer)
- {
- TDebug.out("TMixer.getSupportedSourceFormat(): ...no luck");
- }
- }
- }
- if (format == null)
- {
- throw new IllegalArgumentException("no line matchine one of the passed formats");
- }
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedSourceFormat(): end"); }
- return format;
- }
-
-
-
- private AudioFormat getSupportedTargetFormat(AudioFormat[] aFormats)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedTargetFormat(): begin"); }
- AudioFormat format = null;
- for (int i = 0; i < aFormats.length; i++)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedTargetFormat(): checking " + aFormats[i] + " ..."); }
- if (isTargetFormatSupported(aFormats[i]))
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedTargetFormat(): ...supported"); }
- format = aFormats[i];
- break;
- }
- else
- {
- if (TDebug.TraceMixer)
- {
- TDebug.out("TMixer.getSupportedTargetFormat(): ...no luck");
- }
- }
- }
- if (format == null)
- {
- throw new IllegalArgumentException("no line matchine one of the passed formats");
- }
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSupportedTargetFormat(): end"); }
- return format;
- }
-
-
-
-/*
- not implemented here:
- getMaxLines(Line.Info)
-*/
-
-
-
- public Line[] getSourceLines()
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getSourceLines(): called"); }
- return (Line[]) m_openSourceDataLines.toArray(EMPTY_LINE_ARRAY);
- }
-
-
-
- public Line[] getTargetLines()
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.getTargetLines(): called"); }
- return (Line[]) m_openTargetDataLines.toArray(EMPTY_LINE_ARRAY);
- }
-
-
-
- public void synchronize(Line[] aLines,
- boolean bMaintainSync)
- {
- throw new IllegalArgumentException("synchronization not supported");
- }
-
-
-
- public void unsynchronize(Line[] aLines)
- {
- throw new IllegalArgumentException("synchronization not supported");
- }
-
-
-
- public boolean isSynchronizationSupported(Line[] aLines,
- boolean bMaintainSync)
- {
- return false;
- }
-
-
-
- protected boolean isSourceFormatSupported(AudioFormat format)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.isSourceFormatSupported(): format to test: " + format); }
- Iterator<AudioFormat> iterator = m_supportedSourceFormats.iterator();
- while (iterator.hasNext())
- {
- AudioFormat supportedFormat = iterator.next();
- if (AudioFormats.matches(supportedFormat, format))
- {
- return true;
- }
- }
- return false;
- }
-
-
-
- protected boolean isTargetFormatSupported(AudioFormat format)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.isTargetFormatSupported(): format to test: " + format); }
- Iterator<AudioFormat> iterator = m_supportedTargetFormats.iterator();
- while (iterator.hasNext())
- {
- AudioFormat supportedFormat = iterator.next();
- if (AudioFormats.matches(supportedFormat, format))
- {
- return true;
- }
- }
- return false;
- }
-
-
-
- /*package*/ void registerOpenLine(Line line)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.registerOpenLine(): line to register: " + line);
- }
- if (line instanceof SourceDataLine)
- {
- synchronized (m_openSourceDataLines)
- {
- m_openSourceDataLines.add((SourceDataLine) line);
- }
- }
- else if (line instanceof TargetDataLine)
- {
- synchronized (m_openSourceDataLines)
- {
- m_openTargetDataLines.add((TargetDataLine) line);
- }
- }
- }
-
-
-
- /*package*/ void unregisterOpenLine(Line line)
- {
- if (TDebug.TraceMixer) { TDebug.out("TMixer.unregisterOpenLine(): line to unregister: " + line); }
- if (line instanceof SourceDataLine)
- {
- synchronized (m_openSourceDataLines)
- {
- m_openSourceDataLines.remove((SourceDataLine) line);
- }
- }
- else if (line instanceof TargetDataLine)
- {
- synchronized (m_openTargetDataLines)
- {
- m_openTargetDataLines.remove((TargetDataLine) line);
- }
- }
- }
-}
-
-
-
-/*** TMixer.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TMixerInfo.java b/songdbj/org/tritonus/share/sampled/mixer/TMixerInfo.java
deleted file mode 100644
index cb4b7cc860..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TMixerInfo.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * TMixerInfo.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999, 2000 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import javax.sound.sampled.Mixer;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-/*
- * This is needed only because Mixer.Info's constructor
- * is protected (in the Sun jdk1.3).
- */
-public class TMixerInfo
-extends Mixer.Info
-{
- public TMixerInfo(String a, String b, String c, String d)
- {
- super(a, b, c, d);
- }
-}
-
-
-
-/*** TMixerInfo.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TMixerProvider.java b/songdbj/org/tritonus/share/sampled/mixer/TMixerProvider.java
deleted file mode 100644
index 3116d74dc3..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TMixerProvider.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * TMixerProvider.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.sound.sampled.Mixer;
-import javax.sound.sampled.spi.MixerProvider;
-
-import org.tritonus.share.TDebug;
-
-
-
-public abstract class TMixerProvider
-extends MixerProvider
-{
- private static final Mixer.Info[] EMPTY_MIXER_INFO_ARRAY = new Mixer.Info[0];
-
- private static Map<Class, MixerProviderStruct> sm_mixerProviderStructs = new HashMap<Class, MixerProviderStruct>();
-
- private boolean m_bDisabled = false;
-
-
-
-
- public TMixerProvider()
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.<init>(): begin"); }
- // currently does nothing
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.<init>(): end"); }
- }
-
-
-
- /*
- Override this method if you want a thread-safe static initializaiton.
- */
- protected void staticInit()
- {
- }
-
-
-
- private MixerProviderStruct getMixerProviderStruct()
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixerProviderStruct(): begin"); }
- Class cls = this.getClass();
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixerProviderStruct(): called from " + cls); }
- // Thread.dumpStack();
- synchronized (TMixerProvider.class)
- {
- MixerProviderStruct struct = sm_mixerProviderStructs.get(cls);
- if (struct == null)
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixerProviderStruct(): creating new MixerProviderStruct for " + cls); }
- struct = new MixerProviderStruct();
- sm_mixerProviderStructs.put(cls, struct);
- }
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixerProviderStruct(): end"); }
- return struct;
- }
- }
-
-
-
- protected void disable()
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("disabling " + getClass().getName()); }
- m_bDisabled = true;
- }
-
-
- protected boolean isDisabled()
- {
- return m_bDisabled;
- }
-
-
-
- protected void addMixer(Mixer mixer)
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.addMixer(): begin"); }
- MixerProviderStruct struct = getMixerProviderStruct();
- synchronized (struct)
- {
- struct.m_mixers.add(mixer);
- if (struct.m_defaultMixer == null)
- {
- struct.m_defaultMixer = mixer;
- }
- }
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.addMixer(): end"); }
- }
-
-
-
- protected void removeMixer(Mixer mixer)
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.removeMixer(): begin"); }
- MixerProviderStruct struct = getMixerProviderStruct();
- synchronized (struct)
- {
- struct.m_mixers.remove(mixer);
- // TODO: should search for another mixer
- if (struct.m_defaultMixer == mixer)
- {
- struct.m_defaultMixer = null;
- }
- }
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.removeMixer(): end"); }
- }
-
-
- // $$mp 2003/01/11: TODO: this implementation may become obsolete once the overridden method in spi.MixerProvider is implemented in a way documented officially.
- public boolean isMixerSupported(Mixer.Info info)
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.isMixerSupported(): begin"); }
- boolean bIsSupported = false;
- Mixer.Info[] infos = getMixerInfo();
- for (int i = 0; i < infos.length; i++)
- {
- if (infos[i].equals(info))
- {
- bIsSupported = true;
- break;
- }
- }
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.isMixerSupported(): end"); }
- return bIsSupported;
- }
-
-
-
- /**
- */
- public Mixer getMixer(Mixer.Info info)
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixer(): begin"); }
- MixerProviderStruct struct = getMixerProviderStruct();
- Mixer mixerResult = null;
- synchronized (struct)
- {
- if (info == null)
- {
- mixerResult = struct.m_defaultMixer;
- }
- else
- {
- Iterator mixers = struct.m_mixers.iterator();
- while (mixers.hasNext())
- {
- Mixer mixer = (Mixer) mixers.next();
- if (mixer.getMixerInfo().equals(info))
- {
- mixerResult = mixer;
- break;
- }
- }
- }
- }
- if (mixerResult == null)
- {
- throw new IllegalArgumentException("no mixer available for " + info);
- }
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixer(): end"); }
- return mixerResult;
- }
-
-
-
- public Mixer.Info[] getMixerInfo()
- {
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixerInfo(): begin"); }
- Set<Mixer.Info> mixerInfos = new HashSet<Mixer.Info>();
- MixerProviderStruct struct = getMixerProviderStruct();
- synchronized (struct)
- {
- Iterator<Mixer> mixers = struct.m_mixers.iterator();
- while (mixers.hasNext())
- {
- Mixer mixer = mixers.next();
- mixerInfos.add(mixer.getMixerInfo());
- }
- }
- if (TDebug.TraceMixerProvider) { TDebug.out("TMixerProvider.getMixerInfo(): end"); }
- return mixerInfos.toArray(EMPTY_MIXER_INFO_ARRAY);
- }
-
-
-
- private class MixerProviderStruct
- {
- public List<Mixer> m_mixers;
- public Mixer m_defaultMixer;
-
-
-
- public MixerProviderStruct()
- {
- m_mixers = new ArrayList<Mixer>();
- m_defaultMixer = null;
- }
- }
-}
-
-
-
-/*** TMixerProvider.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TPort.java b/songdbj/org/tritonus/share/sampled/mixer/TPort.java
deleted file mode 100644
index 18d5abae00..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TPort.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * TPort.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 - 2004 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.Line;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Port;
-
-import org.tritonus.share.TDebug;
-
-
-
-
-/** Base class for Ports.
- */
-public class TPort
-extends TLine
-implements Port
-{
- public TPort(TMixer mixer,
- Line.Info info)
- {
- super(mixer, info);
- }
-
-
-
- public TPort(TMixer mixer,
- Line.Info info,
- Collection<Control> controls)
- {
- super(mixer, info, controls);
- }
-}
-
-
-
-/*** TPort.java ***/
diff --git a/songdbj/org/tritonus/share/sampled/mixer/TSoftClip.java b/songdbj/org/tritonus/share/sampled/mixer/TSoftClip.java
deleted file mode 100644
index b5a8aea2c1..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/TSoftClip.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * TSoftClip.java
- *
- * This file is part of Tritonus: http://www.tritonus.org/
- */
-
-/*
- * Copyright (c) 1999 by Matthias Pfisterer
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
-|<--- this code is formatted to fit into 80 columns --->|
-*/
-
-package org.tritonus.share.sampled.mixer;
-
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Clip;
-import javax.sound.sampled.DataLine;
-import javax.sound.sampled.SourceDataLine;
-import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Mixer;
-
-import org.tritonus.share.TDebug;
-import org.tritonus.share.sampled.mixer.TDataLine;
-
-
-
-public class TSoftClip
-extends TClip
-implements Runnable
-{
- private static final Class[] CONTROL_CLASSES = {/*GainControl.class*/};
- private static final int BUFFER_SIZE = 16384;
-
-
- private Mixer m_mixer;
- private SourceDataLine m_line;
- private byte[] m_abClip;
- private int m_nRepeatCount;
- private Thread m_thread;
-
- public TSoftClip(Mixer mixer, AudioFormat format)
- throws LineUnavailableException
- {
- // TODO: info object
-/*
- DataLine.Info info = new DataLine.Info(Clip.class,
- audioFormat, -1);
-*/
- super(null);
- m_mixer = mixer;
- DataLine.Info info = new DataLine.Info(
- SourceDataLine.class,
- // TODO: should pass a real AudioFormat object that isn't too restrictive
- format);
- m_line = (SourceDataLine) AudioSystem.getLine(info);
- }
-
-
-
- public void open(AudioInputStream audioInputStream)
- throws LineUnavailableException, IOException
- {
- AudioFormat audioFormat = audioInputStream.getFormat();
- setFormat(audioFormat);
- int nFrameSize = audioFormat.getFrameSize();
- if (nFrameSize < 1)
- {
- throw new IllegalArgumentException("frame size must be positive");
- }
- if (TDebug.TraceClip)
- {
- TDebug.out("TSoftClip.open(): format: " + audioFormat);
- // TDebug.out("sample rate: " + audioFormat.getSampleRate());
- }
- byte[] abData = new byte[BUFFER_SIZE];
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- int nBytesRead = 0;
- while (nBytesRead != -1)
- {
- try
- {
- nBytesRead = audioInputStream.read(abData, 0, abData.length);
- }
- catch (IOException e)
- {
- if (TDebug.TraceClip || TDebug.TraceAllExceptions)
- {
- TDebug.out(e);
- }
- }
- if (nBytesRead >= 0)
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TSoftClip.open(): Trying to write: " + nBytesRead);
- }
- baos.write(abData, 0, nBytesRead);
- if (TDebug.TraceClip)
- {
- TDebug.out("TSoftClip.open(): Written: " + nBytesRead);
- }
- }
- }
- m_abClip = baos.toByteArray();
- setBufferSize(m_abClip.length);
- // open the line
- m_line.open(getFormat());
- // to trigger the events
- // open();
- }
-
-
-
- public int getFrameLength()
- {
- if (isOpen())
- {
- return getBufferSize() / getFormat().getFrameSize();
- }
- else
- {
- return AudioSystem.NOT_SPECIFIED;
- }
- }
-
-
-
- public long getMicrosecondLength()
- {
- if (isOpen())
- {
- return (long) (getFrameLength() * getFormat().getFrameRate() * 1000000);
- }
- else
- {
- return AudioSystem.NOT_SPECIFIED;
- }
- }
-
-
-
- public void setFramePosition(int nPosition)
- {
- // TOOD:
- }
-
-
-
- public void setMicrosecondPosition(long lPosition)
- {
- // TOOD:
- }
-
-
-
- public int getFramePosition()
- {
- // TOOD:
- return -1;
- }
-
-
-
- public long getMicrosecondPosition()
- {
- // TOOD:
- return -1;
- }
-
-
-
- public void setLoopPoints(int nStart, int nEnd)
- {
- // TOOD:
- }
-
-
-
- public void loop(int nCount)
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TSoftClip.loop(int): called; count = " + nCount);
- }
- if (false/*isStarted()*/)
- {
- /*
- * only allow zero count to stop the looping
- * at the end of an iteration.
- */
- if (nCount == 0)
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TSoftClip.loop(int): stopping sample");
- }
- // m_esdSample.stop();
- }
- }
- else
- {
- m_nRepeatCount = nCount;
- m_thread = new Thread(this);
- m_thread.start();
- }
- // TOOD:
- }
-
-
-
- public void flush()
- {
- // TOOD:
- }
-
-
-
- public void drain()
- {
- // TOOD:
- }
-
-
-
- public void close()
- {
- // m_esdSample.free();
- // m_esdSample.close();
- // TOOD:
- }
-
-
-
-
- public void open()
- {
- // TODO:
- }
-
-
-
- public void start()
- {
- if (TDebug.TraceClip)
- {
- TDebug.out("TSoftClip.start(): called");
- }
- /*
- * This is a hack. What start() really should do is
- * start playing at the position playback was stopped.
- */
- if (TDebug.TraceClip)
- {
- TDebug.out("TSoftClip.start(): calling 'loop(0)' [hack]");
- }
- loop(0);
- }
-
-
-
- public void stop()
- {
- // TODO:
- // m_esdSample.kill();
- }
-
-
-
- /*
- * This method is enforced by DataLine, but doesn't make any
- * sense for Clips.
- */
- public int available()
- {
- return -1;
- }
-
-
-
- public void run()
- {
- while (m_nRepeatCount >= 0)
- {
- m_line.write(m_abClip, 0, m_abClip.length);
- m_nRepeatCount--;
- }
- }
-
-}
-
-
-
-/*** TSoftClip.java ***/
-
diff --git a/songdbj/org/tritonus/share/sampled/mixer/package.html b/songdbj/org/tritonus/share/sampled/mixer/package.html
deleted file mode 100644
index 681024bc9d..0000000000
--- a/songdbj/org/tritonus/share/sampled/mixer/package.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Base classes for the implementation of MixerProviders.
- The classes provided here .</p>
-
- @see javax.sound.sampled.spi.MixerProvider
- @see org.tritonus.sampled.mixer.alsa
- @see org.tritonus.sampled.mixer.esd
- </body>
-</html>
diff --git a/songdbj/org/tritonus/share/sampled/package.html b/songdbj/org/tritonus/share/sampled/package.html
deleted file mode 100644
index f7a6b56099..0000000000
--- a/songdbj/org/tritonus/share/sampled/package.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- </head>
-
- <body>
- <p>Helper classes for the implementation of sampled audio stuff.
- The classes provided here .</p>
- </body>
-</html>