seal 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/LICENSE +13 -0
- data/README.md +265 -0
- data/ext/seal/extconf.rb +45 -0
- data/include/al/al.h +724 -0
- data/include/al/alc.h +277 -0
- data/include/al/efx-presets.h +402 -0
- data/include/al/efx.h +758 -0
- data/include/mpg123/mpg123.h +1034 -0
- data/include/ogg/config_types.h +25 -0
- data/include/ogg/ogg.h +210 -0
- data/include/ogg/os_types.h +147 -0
- data/include/seal.h +23 -0
- data/include/seal/buf.h +143 -0
- data/include/seal/core.h +95 -0
- data/include/seal/efs.h +112 -0
- data/include/seal/err.h +93 -0
- data/include/seal/fmt.h +58 -0
- data/include/seal/listener.h +103 -0
- data/include/seal/raw.h +86 -0
- data/include/seal/rvb.h +520 -0
- data/include/seal/src.h +413 -0
- data/include/seal/stream.h +81 -0
- data/include/vorbis/codec.h +243 -0
- data/include/vorbis/vorbisfile.h +206 -0
- data/mpg123/AUTHORS +150 -0
- data/mpg123/COPYING +773 -0
- data/mpg123/ChangeLog +3 -0
- data/mpg123/INSTALL +111 -0
- data/mpg123/Makefile.am +99 -0
- data/mpg123/Makefile.in +1043 -0
- data/mpg123/NEWS +1200 -0
- data/mpg123/NEWS.libmpg123 +133 -0
- data/mpg123/README +203 -0
- data/mpg123/TODO +38 -0
- data/mpg123/aclocal.m4 +1168 -0
- data/mpg123/build/config.guess +1530 -0
- data/mpg123/build/config.sub +1782 -0
- data/mpg123/build/depcomp +707 -0
- data/mpg123/build/install-sh +527 -0
- data/mpg123/build/ltmain.sh +9655 -0
- data/mpg123/build/missing +330 -0
- data/mpg123/configure +20267 -0
- data/mpg123/configure.ac +2178 -0
- data/mpg123/doc/ACCURACY +2 -0
- data/mpg123/doc/BENCHMARKING +110 -0
- data/mpg123/doc/BUGS +3 -0
- data/mpg123/doc/CONTACT +17 -0
- data/mpg123/doc/LICENSE +22 -0
- data/mpg123/doc/Makefile.am +32 -0
- data/mpg123/doc/Makefile.in +490 -0
- data/mpg123/doc/PATENTS +39 -0
- data/mpg123/doc/README.3DNOW +56 -0
- data/mpg123/doc/README.gain +171 -0
- data/mpg123/doc/README.remote +218 -0
- data/mpg123/doc/ROAD_TO_LGPL +270 -0
- data/mpg123/doc/THANKS +13 -0
- data/mpg123/doc/TODO +63 -0
- data/mpg123/doc/doxy_examples.c +21 -0
- data/mpg123/doc/doxygen.conf +41 -0
- data/mpg123/doc/doxyhead.xhtml +12 -0
- data/mpg123/doc/examples/dump_seekindex.c +41 -0
- data/mpg123/doc/examples/extract_frames.c +92 -0
- data/mpg123/doc/examples/feedseek.c +238 -0
- data/mpg123/doc/examples/id3dump.c +178 -0
- data/mpg123/doc/examples/mpg123_to_wav.c +118 -0
- data/mpg123/doc/examples/mpglib.c +92 -0
- data/mpg123/doc/examples/scan.c +47 -0
- data/mpg123/doc/libmpg123_speed.txt +84 -0
- data/mpg123/equalize.dat +37 -0
- data/mpg123/libmpg123.pc.in +11 -0
- data/mpg123/m4/addrconfig.m4 +34 -0
- data/mpg123/m4/libtool.m4 +7982 -0
- data/mpg123/m4/ltoptions.m4 +384 -0
- data/mpg123/m4/ltsugar.m4 +123 -0
- data/mpg123/m4/ltversion.m4 +23 -0
- data/mpg123/m4/lt~obsolete.m4 +98 -0
- data/mpg123/makedll.sh +19 -0
- data/mpg123/man1/mpg123.1 +512 -0
- data/mpg123/mpg123.spec +68 -0
- data/mpg123/mpg123.spec.in +68 -0
- data/mpg123/ports/MSVC++/2005/libmpg123/libmpg123.vcproj +741 -0
- data/mpg123/ports/MSVC++/2008/dump_seekindex/dump_seekindex.vcproj +194 -0
- data/mpg123/ports/MSVC++/2008/feedseek/feedseek.vcproj +195 -0
- data/mpg123/ports/MSVC++/2008/libmpg123/libmpg123.vcproj +1357 -0
- data/mpg123/ports/MSVC++/2008/mpg123.sln +44 -0
- data/mpg123/ports/MSVC++/2008/mpglib/mpglib.vcproj +191 -0
- data/mpg123/ports/MSVC++/2008/scan/scan.vcproj +195 -0
- data/mpg123/ports/MSVC++/2008clr/2008clr.sln +81 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Program.cs +435 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/ReplaceReaderclr.csproj +72 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Program.cs +331 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/feedseekclr.csproj +71 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Program.cs +79 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/scanclr.csproj +70 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/AssemblyInfo.cpp +76 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/ReadMe.txt +165 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.cpp +91 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.h +130 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/dllmain.cpp +19 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/enum.h +218 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.cpp +48 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.h +134 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.cpp +92 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.h +132 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.cpp +138 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.h +152 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.cpp +896 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.h +953 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.rc +102 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.vcproj +328 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/resource.h +14 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.cpp +8 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.h +38 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.cpp +166 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.h +265 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/targetver.h +24 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.cpp +67 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.h +111 -0
- data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj +90 -0
- data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj +95 -0
- data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj +960 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj.user +3 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/yasm.exe +0 -0
- data/mpg123/ports/MSVC++/2010/mpg123.sln +38 -0
- data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj +93 -0
- data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/CORE_FileIn.H +15 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/SourceFilter_MP3.H +139 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_Def.H +206 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_FileIn.H +167 -0
- data/mpg123/ports/MSVC++/CMP3Stream/README +4 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_FileIn.CPP +462 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Log.CPP +122 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Mutex.CPP +35 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/SourceFilter_MP3Stream.CPP +586 -0
- data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/PLACE_LIBMPG123_SOURCES_HERE +0 -0
- data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/libMPG123.vcproj +245 -0
- data/mpg123/ports/MSVC++/config.h +35 -0
- data/mpg123/ports/MSVC++/examples/feedseek.c +240 -0
- data/mpg123/ports/MSVC++/examples/scan.c +47 -0
- data/mpg123/ports/MSVC++/mpg123.h +46 -0
- data/mpg123/ports/MSVC++/msvc.c +59 -0
- data/mpg123/ports/README +26 -0
- data/mpg123/ports/Sony_PSP/Makefile.psp +38 -0
- data/mpg123/ports/Sony_PSP/README +11 -0
- data/mpg123/ports/Sony_PSP/config.h +368 -0
- data/mpg123/ports/Sony_PSP/readers.c.patch +2 -0
- data/mpg123/ports/Xcode/config.h +197 -0
- data/mpg123/ports/Xcode/mpg123.h +17 -0
- data/mpg123/ports/Xcode/mpg123.xcodeproj/project.pbxproj +670 -0
- data/mpg123/ports/mpg123_.pas +478 -0
- data/mpg123/scripts/benchmark-cpu.pl +56 -0
- data/mpg123/scripts/tag_lyrics.py +76 -0
- data/mpg123/src/Makefile.am +186 -0
- data/mpg123/src/Makefile.in +1097 -0
- data/mpg123/src/audio.c +725 -0
- data/mpg123/src/audio.h +106 -0
- data/mpg123/src/buffer.c +312 -0
- data/mpg123/src/buffer.h +45 -0
- data/mpg123/src/common.c +240 -0
- data/mpg123/src/common.h +29 -0
- data/mpg123/src/config.h.in +436 -0
- data/mpg123/src/control_generic.c +809 -0
- data/mpg123/src/equalizer.c +48 -0
- data/mpg123/src/genre.c +271 -0
- data/mpg123/src/genre.h +15 -0
- data/mpg123/src/getlopt.c +148 -0
- data/mpg123/src/getlopt.h +77 -0
- data/mpg123/src/httpget.c +700 -0
- data/mpg123/src/httpget.h +66 -0
- data/mpg123/src/legacy_module.c +74 -0
- data/mpg123/src/libmpg123/Makefile.am +141 -0
- data/mpg123/src/libmpg123/Makefile.in +919 -0
- data/mpg123/src/libmpg123/compat.c +138 -0
- data/mpg123/src/libmpg123/compat.h +178 -0
- data/mpg123/src/libmpg123/dct36_3dnow.S +505 -0
- data/mpg123/src/libmpg123/dct36_3dnowext.S +512 -0
- data/mpg123/src/libmpg123/dct64.c +174 -0
- data/mpg123/src/libmpg123/dct64_3dnow.S +712 -0
- data/mpg123/src/libmpg123/dct64_3dnowext.S +714 -0
- data/mpg123/src/libmpg123/dct64_altivec.c +315 -0
- data/mpg123/src/libmpg123/dct64_i386.c +336 -0
- data/mpg123/src/libmpg123/dct64_i486.c +342 -0
- data/mpg123/src/libmpg123/dct64_mmx.S +811 -0
- data/mpg123/src/libmpg123/dct64_neon.S +297 -0
- data/mpg123/src/libmpg123/dct64_neon_float.S +270 -0
- data/mpg123/src/libmpg123/dct64_sse.S +454 -0
- data/mpg123/src/libmpg123/dct64_sse_float.S +401 -0
- data/mpg123/src/libmpg123/dct64_x86_64.S +464 -0
- data/mpg123/src/libmpg123/dct64_x86_64_float.S +426 -0
- data/mpg123/src/libmpg123/debug.h +171 -0
- data/mpg123/src/libmpg123/decode.h +268 -0
- data/mpg123/src/libmpg123/dither.c +119 -0
- data/mpg123/src/libmpg123/dither.h +23 -0
- data/mpg123/src/libmpg123/equalizer.c +17 -0
- data/mpg123/src/libmpg123/equalizer_3dnow.S +70 -0
- data/mpg123/src/libmpg123/feature.c +106 -0
- data/mpg123/src/libmpg123/format.c +521 -0
- data/mpg123/src/libmpg123/frame.c +1046 -0
- data/mpg123/src/libmpg123/frame.h +410 -0
- data/mpg123/src/libmpg123/gapless.h +119 -0
- data/mpg123/src/libmpg123/getbits.h +100 -0
- data/mpg123/src/libmpg123/getcpuflags.S +91 -0
- data/mpg123/src/libmpg123/getcpuflags.h +47 -0
- data/mpg123/src/libmpg123/huffman.h +340 -0
- data/mpg123/src/libmpg123/icy.c +32 -0
- data/mpg123/src/libmpg123/icy.h +38 -0
- data/mpg123/src/libmpg123/icy2utf8.c +438 -0
- data/mpg123/src/libmpg123/icy2utf8.h +10 -0
- data/mpg123/src/libmpg123/id3.c +999 -0
- data/mpg123/src/libmpg123/id3.h +43 -0
- data/mpg123/src/libmpg123/index.c +134 -0
- data/mpg123/src/libmpg123/index.h +59 -0
- data/mpg123/src/libmpg123/intsym.h +256 -0
- data/mpg123/src/libmpg123/l12_integer_tables.h +278 -0
- data/mpg123/src/libmpg123/l2tables.h +164 -0
- data/mpg123/src/libmpg123/l3_integer_tables.h +1002 -0
- data/mpg123/src/libmpg123/layer1.c +155 -0
- data/mpg123/src/libmpg123/layer2.c +371 -0
- data/mpg123/src/libmpg123/layer3.c +2053 -0
- data/mpg123/src/libmpg123/lfs_alias.c +252 -0
- data/mpg123/src/libmpg123/lfs_wrap.c +751 -0
- data/mpg123/src/libmpg123/libmpg123.c +1607 -0
- data/mpg123/src/libmpg123/mangle.h +74 -0
- data/mpg123/src/libmpg123/mpeghead.h +87 -0
- data/mpg123/src/libmpg123/mpg123.h.in +1075 -0
- data/mpg123/src/libmpg123/mpg123lib_intern.h +338 -0
- data/mpg123/src/libmpg123/ntom.c +148 -0
- data/mpg123/src/libmpg123/optimize.c +964 -0
- data/mpg123/src/libmpg123/optimize.h +219 -0
- data/mpg123/src/libmpg123/parse.c +1179 -0
- data/mpg123/src/libmpg123/parse.h +25 -0
- data/mpg123/src/libmpg123/reader.h +137 -0
- data/mpg123/src/libmpg123/readers.c +1235 -0
- data/mpg123/src/libmpg123/sample.h +152 -0
- data/mpg123/src/libmpg123/stringbuf.c +163 -0
- data/mpg123/src/libmpg123/synth.c +816 -0
- data/mpg123/src/libmpg123/synth.h +196 -0
- data/mpg123/src/libmpg123/synth_3dnow.S +318 -0
- data/mpg123/src/libmpg123/synth_3dnowext.S +6 -0
- data/mpg123/src/libmpg123/synth_8bit.c +142 -0
- data/mpg123/src/libmpg123/synth_8bit.h +86 -0
- data/mpg123/src/libmpg123/synth_altivec.c +1057 -0
- data/mpg123/src/libmpg123/synth_arm.S +271 -0
- data/mpg123/src/libmpg123/synth_arm_accurate.S +287 -0
- data/mpg123/src/libmpg123/synth_i486.c +252 -0
- data/mpg123/src/libmpg123/synth_i586.S +336 -0
- data/mpg123/src/libmpg123/synth_i586_dither.S +375 -0
- data/mpg123/src/libmpg123/synth_mmx.S +125 -0
- data/mpg123/src/libmpg123/synth_mono.h +64 -0
- data/mpg123/src/libmpg123/synth_neon.S +123 -0
- data/mpg123/src/libmpg123/synth_neon_accurate.S +173 -0
- data/mpg123/src/libmpg123/synth_neon_float.S +149 -0
- data/mpg123/src/libmpg123/synth_neon_s32.S +168 -0
- data/mpg123/src/libmpg123/synth_ntom.h +213 -0
- data/mpg123/src/libmpg123/synth_real.c +404 -0
- data/mpg123/src/libmpg123/synth_s32.c +411 -0
- data/mpg123/src/libmpg123/synth_sse.S +6 -0
- data/mpg123/src/libmpg123/synth_sse3d.h +246 -0
- data/mpg123/src/libmpg123/synth_sse_accurate.S +294 -0
- data/mpg123/src/libmpg123/synth_sse_float.S +241 -0
- data/mpg123/src/libmpg123/synth_sse_s32.S +306 -0
- data/mpg123/src/libmpg123/synth_stereo_neon.S +175 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_accurate.S +262 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_float.S +220 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_s32.S +247 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_accurate.S +508 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_float.S +416 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_s32.S +540 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64.S +335 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_accurate.S +454 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_float.S +396 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_s32.S +473 -0
- data/mpg123/src/libmpg123/synth_x86_64.S +244 -0
- data/mpg123/src/libmpg123/synth_x86_64_accurate.S +301 -0
- data/mpg123/src/libmpg123/synth_x86_64_float.S +259 -0
- data/mpg123/src/libmpg123/synth_x86_64_s32.S +312 -0
- data/mpg123/src/libmpg123/synths.h +52 -0
- data/mpg123/src/libmpg123/tabinit.c +294 -0
- data/mpg123/src/libmpg123/tabinit_mmx.S +210 -0
- data/mpg123/src/libmpg123/testcpu.c +35 -0
- data/mpg123/src/libmpg123/true.h +14 -0
- data/mpg123/src/local.c +63 -0
- data/mpg123/src/local.h +21 -0
- data/mpg123/src/metaprint.c +373 -0
- data/mpg123/src/metaprint.h +17 -0
- data/mpg123/src/module.c +306 -0
- data/mpg123/src/module.h +48 -0
- data/mpg123/src/mpg123.c +1405 -0
- data/mpg123/src/mpg123app.h +171 -0
- data/mpg123/src/output/Makefile.am +213 -0
- data/mpg123/src/output/Makefile.in +1238 -0
- data/mpg123/src/output/aix.c +300 -0
- data/mpg123/src/output/alib.c +209 -0
- data/mpg123/src/output/alsa.c +297 -0
- data/mpg123/src/output/arts.c +117 -0
- data/mpg123/src/output/coreaudio.c +370 -0
- data/mpg123/src/output/dummy.c +78 -0
- data/mpg123/src/output/esd.c +167 -0
- data/mpg123/src/output/hp.c +184 -0
- data/mpg123/src/output/jack.c +450 -0
- data/mpg123/src/output/mint.c +197 -0
- data/mpg123/src/output/nas.c +335 -0
- data/mpg123/src/output/openal.c +197 -0
- data/mpg123/src/output/os2.c +665 -0
- data/mpg123/src/output/oss.c +319 -0
- data/mpg123/src/output/portaudio.c +255 -0
- data/mpg123/src/output/pulse.c +164 -0
- data/mpg123/src/output/sdl.c +206 -0
- data/mpg123/src/output/sgi.c +213 -0
- data/mpg123/src/output/sndio.c +161 -0
- data/mpg123/src/output/sun.c +281 -0
- data/mpg123/src/output/win32.c +229 -0
- data/mpg123/src/playlist.c +596 -0
- data/mpg123/src/playlist.h +52 -0
- data/mpg123/src/resolver.c +319 -0
- data/mpg123/src/resolver.h +25 -0
- data/mpg123/src/sfifo.c +146 -0
- data/mpg123/src/sfifo.h +95 -0
- data/mpg123/src/streamdump.c +74 -0
- data/mpg123/src/streamdump.h +20 -0
- data/mpg123/src/term.c +479 -0
- data/mpg123/src/term.h +81 -0
- data/mpg123/src/tests/noise.c +52 -0
- data/mpg123/src/tests/plain_id3.c +109 -0
- data/mpg123/src/tests/seek_accuracy.c +261 -0
- data/mpg123/src/tests/seek_whence.c +56 -0
- data/mpg123/src/tests/testtext.h +34 -0
- data/mpg123/src/tests/text.c +80 -0
- data/mpg123/src/wav.c +464 -0
- data/mpg123/src/wavhead.h +68 -0
- data/mpg123/src/win32_net.c +599 -0
- data/mpg123/src/win32_support.c +191 -0
- data/mpg123/src/win32_support.h +152 -0
- data/mpg123/src/xfermem.c +321 -0
- data/mpg123/src/xfermem.h +74 -0
- data/mpg123/windows-builds.sh +137 -0
- data/msvc/lib/OpenAL32.lib +0 -0
- data/spec/fixtures/heal.ogg +0 -0
- data/spec/fixtures/tone_up.wav +0 -0
- data/spec/seal/buffer_spec.rb +37 -0
- data/spec/seal/core_spec.rb +29 -0
- data/spec/seal/effect_slot_spec.rb +38 -0
- data/spec/seal/listener_spec.rb +33 -0
- data/spec/seal/reverb_spec.rb +51 -0
- data/spec/seal/source_spec.rb +370 -0
- data/spec/seal/stream_spec.rb +38 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/attribute_examples.rb +75 -0
- data/spec/support/audio_object_with_format.rb +27 -0
- data/spec/support/movable_object.rb +22 -0
- data/src/libogg/bitwise.c +857 -0
- data/src/libogg/framing.c +2093 -0
- data/src/libvorbis/backends.h +144 -0
- data/src/libvorbis/bitrate.c +253 -0
- data/src/libvorbis/bitrate.h +59 -0
- data/src/libvorbis/block.c +1046 -0
- data/src/libvorbis/codebook.c +484 -0
- data/src/libvorbis/codebook.h +119 -0
- data/src/libvorbis/codec_internal.h +167 -0
- data/src/libvorbis/envelope.c +375 -0
- data/src/libvorbis/envelope.h +80 -0
- data/src/libvorbis/floor0.c +221 -0
- data/src/libvorbis/floor1.c +1100 -0
- data/src/libvorbis/highlevel.h +58 -0
- data/src/libvorbis/info.c +668 -0
- data/src/libvorbis/lookup.c +94 -0
- data/src/libvorbis/lookup.h +32 -0
- data/src/libvorbis/lookup_data.h +192 -0
- data/src/libvorbis/lpc.c +160 -0
- data/src/libvorbis/lpc.h +29 -0
- data/src/libvorbis/lsp.c +456 -0
- data/src/libvorbis/lsp.h +28 -0
- data/src/libvorbis/mapping0.c +816 -0
- data/src/libvorbis/masking.h +785 -0
- data/src/libvorbis/mdct.c +563 -0
- data/src/libvorbis/mdct.h +71 -0
- data/src/libvorbis/misc.h +57 -0
- data/src/libvorbis/os.h +186 -0
- data/src/libvorbis/psy.c +1206 -0
- data/src/libvorbis/psy.h +154 -0
- data/src/libvorbis/registry.c +45 -0
- data/src/libvorbis/registry.h +32 -0
- data/src/libvorbis/res0.c +889 -0
- data/src/libvorbis/scales.h +90 -0
- data/src/libvorbis/sharedbook.c +579 -0
- data/src/libvorbis/smallft.c +1255 -0
- data/src/libvorbis/smallft.h +34 -0
- data/src/libvorbis/synthesis.c +184 -0
- data/src/libvorbis/vorbisfile.c +2337 -0
- data/src/libvorbis/window.c +2135 -0
- data/src/libvorbis/window.h +26 -0
- data/src/rubyext.c +2329 -0
- data/src/seal/buf.c +124 -0
- data/src/seal/core.c +283 -0
- data/src/seal/efs.c +74 -0
- data/src/seal/err.c +118 -0
- data/src/seal/fmt.c +86 -0
- data/src/seal/listener.c +111 -0
- data/src/seal/mpg.c +174 -0
- data/src/seal/mpg.h +24 -0
- data/src/seal/ov.c +180 -0
- data/src/seal/ov.h +22 -0
- data/src/seal/raw.c +59 -0
- data/src/seal/reader.c +102 -0
- data/src/seal/reader.h +59 -0
- data/src/seal/rvb.c +368 -0
- data/src/seal/src.c +654 -0
- data/src/seal/stream.c +109 -0
- data/src/seal/threading.c +66 -0
- data/src/seal/threading.h +20 -0
- data/src/seal/wav.c +297 -0
- data/src/seal/wav.h +23 -0
- data/src/win32api.rb +29 -0
- metadata +563 -0
data/src/libvorbis/psy.h
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
/********************************************************************
|
2
|
+
* *
|
3
|
+
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
4
|
+
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
5
|
+
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
6
|
+
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
7
|
+
* *
|
8
|
+
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
|
9
|
+
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
10
|
+
* *
|
11
|
+
********************************************************************
|
12
|
+
|
13
|
+
function: random psychoacoustics (not including preecho)
|
14
|
+
last mod: $Id: psy.h 16946 2010-03-03 16:12:40Z xiphmont $
|
15
|
+
|
16
|
+
********************************************************************/
|
17
|
+
|
18
|
+
#ifndef _V_PSY_H_
|
19
|
+
#define _V_PSY_H_
|
20
|
+
#include "smallft.h"
|
21
|
+
|
22
|
+
#include "backends.h"
|
23
|
+
#include "envelope.h"
|
24
|
+
|
25
|
+
#ifndef EHMER_MAX
|
26
|
+
#define EHMER_MAX 56
|
27
|
+
#endif
|
28
|
+
|
29
|
+
/* psychoacoustic setup ********************************************/
|
30
|
+
#define P_BANDS 17 /* 62Hz to 16kHz */
|
31
|
+
#define P_LEVELS 8 /* 30dB to 100dB */
|
32
|
+
#define P_LEVEL_0 30. /* 30 dB */
|
33
|
+
#define P_NOISECURVES 3
|
34
|
+
|
35
|
+
#define NOISE_COMPAND_LEVELS 40
|
36
|
+
typedef struct vorbis_info_psy{
|
37
|
+
int blockflag;
|
38
|
+
|
39
|
+
float ath_adjatt;
|
40
|
+
float ath_maxatt;
|
41
|
+
|
42
|
+
float tone_masteratt[P_NOISECURVES];
|
43
|
+
float tone_centerboost;
|
44
|
+
float tone_decay;
|
45
|
+
float tone_abs_limit;
|
46
|
+
float toneatt[P_BANDS];
|
47
|
+
|
48
|
+
int noisemaskp;
|
49
|
+
float noisemaxsupp;
|
50
|
+
float noisewindowlo;
|
51
|
+
float noisewindowhi;
|
52
|
+
int noisewindowlomin;
|
53
|
+
int noisewindowhimin;
|
54
|
+
int noisewindowfixed;
|
55
|
+
float noiseoff[P_NOISECURVES][P_BANDS];
|
56
|
+
float noisecompand[NOISE_COMPAND_LEVELS];
|
57
|
+
|
58
|
+
float max_curve_dB;
|
59
|
+
|
60
|
+
int normal_p;
|
61
|
+
int normal_start;
|
62
|
+
int normal_partition;
|
63
|
+
double normal_thresh;
|
64
|
+
} vorbis_info_psy;
|
65
|
+
|
66
|
+
typedef struct{
|
67
|
+
int eighth_octave_lines;
|
68
|
+
|
69
|
+
/* for block long/short tuning; encode only */
|
70
|
+
float preecho_thresh[VE_BANDS];
|
71
|
+
float postecho_thresh[VE_BANDS];
|
72
|
+
float stretch_penalty;
|
73
|
+
float preecho_minenergy;
|
74
|
+
|
75
|
+
float ampmax_att_per_sec;
|
76
|
+
|
77
|
+
/* channel coupling config */
|
78
|
+
int coupling_pkHz[PACKETBLOBS];
|
79
|
+
int coupling_pointlimit[2][PACKETBLOBS];
|
80
|
+
int coupling_prepointamp[PACKETBLOBS];
|
81
|
+
int coupling_postpointamp[PACKETBLOBS];
|
82
|
+
int sliding_lowpass[2][PACKETBLOBS];
|
83
|
+
|
84
|
+
} vorbis_info_psy_global;
|
85
|
+
|
86
|
+
typedef struct {
|
87
|
+
float ampmax;
|
88
|
+
int channels;
|
89
|
+
|
90
|
+
vorbis_info_psy_global *gi;
|
91
|
+
int coupling_pointlimit[2][P_NOISECURVES];
|
92
|
+
} vorbis_look_psy_global;
|
93
|
+
|
94
|
+
|
95
|
+
typedef struct {
|
96
|
+
int n;
|
97
|
+
struct vorbis_info_psy *vi;
|
98
|
+
|
99
|
+
float ***tonecurves;
|
100
|
+
float **noiseoffset;
|
101
|
+
|
102
|
+
float *ath;
|
103
|
+
long *octave; /* in n.ocshift format */
|
104
|
+
long *bark;
|
105
|
+
|
106
|
+
long firstoc;
|
107
|
+
long shiftoc;
|
108
|
+
int eighth_octave_lines; /* power of two, please */
|
109
|
+
int total_octave_lines;
|
110
|
+
long rate; /* cache it */
|
111
|
+
|
112
|
+
float m_val; /* Masking compensation value */
|
113
|
+
|
114
|
+
} vorbis_look_psy;
|
115
|
+
|
116
|
+
extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
|
117
|
+
vorbis_info_psy_global *gi,int n,long rate);
|
118
|
+
extern void _vp_psy_clear(vorbis_look_psy *p);
|
119
|
+
extern void *_vi_psy_dup(void *source);
|
120
|
+
|
121
|
+
extern void _vi_psy_free(vorbis_info_psy *i);
|
122
|
+
extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
|
123
|
+
|
124
|
+
extern void _vp_noisemask(vorbis_look_psy *p,
|
125
|
+
float *logmdct,
|
126
|
+
float *logmask);
|
127
|
+
|
128
|
+
extern void _vp_tonemask(vorbis_look_psy *p,
|
129
|
+
float *logfft,
|
130
|
+
float *logmask,
|
131
|
+
float global_specmax,
|
132
|
+
float local_specmax);
|
133
|
+
|
134
|
+
extern void _vp_offset_and_mix(vorbis_look_psy *p,
|
135
|
+
float *noise,
|
136
|
+
float *tone,
|
137
|
+
int offset_select,
|
138
|
+
float *logmask,
|
139
|
+
float *mdct,
|
140
|
+
float *logmdct);
|
141
|
+
|
142
|
+
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
|
143
|
+
|
144
|
+
extern void _vp_couple_quantize_normalize(int blobno,
|
145
|
+
vorbis_info_psy_global *g,
|
146
|
+
vorbis_look_psy *p,
|
147
|
+
vorbis_info_mapping0 *vi,
|
148
|
+
float **mdct,
|
149
|
+
int **iwork,
|
150
|
+
int *nonzero,
|
151
|
+
int sliding_lowpass,
|
152
|
+
int ch);
|
153
|
+
|
154
|
+
#endif
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/********************************************************************
|
2
|
+
* *
|
3
|
+
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
4
|
+
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
5
|
+
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
6
|
+
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
7
|
+
* *
|
8
|
+
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
|
9
|
+
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
10
|
+
* *
|
11
|
+
********************************************************************
|
12
|
+
|
13
|
+
function: registry for time, floor, res backends and channel mappings
|
14
|
+
last mod: $Id: registry.c 16227 2009-07-08 06:58:46Z xiphmont $
|
15
|
+
|
16
|
+
********************************************************************/
|
17
|
+
|
18
|
+
#include "vorbis/codec.h"
|
19
|
+
#include "codec_internal.h"
|
20
|
+
#include "registry.h"
|
21
|
+
#include "misc.h"
|
22
|
+
/* seems like major overkill now; the backend numbers will grow into
|
23
|
+
the infrastructure soon enough */
|
24
|
+
|
25
|
+
extern const vorbis_func_floor floor0_exportbundle;
|
26
|
+
extern const vorbis_func_floor floor1_exportbundle;
|
27
|
+
extern const vorbis_func_residue residue0_exportbundle;
|
28
|
+
extern const vorbis_func_residue residue1_exportbundle;
|
29
|
+
extern const vorbis_func_residue residue2_exportbundle;
|
30
|
+
extern const vorbis_func_mapping mapping0_exportbundle;
|
31
|
+
|
32
|
+
const vorbis_func_floor *const _floor_P[]={
|
33
|
+
&floor0_exportbundle,
|
34
|
+
&floor1_exportbundle,
|
35
|
+
};
|
36
|
+
|
37
|
+
const vorbis_func_residue *const _residue_P[]={
|
38
|
+
&residue0_exportbundle,
|
39
|
+
&residue1_exportbundle,
|
40
|
+
&residue2_exportbundle,
|
41
|
+
};
|
42
|
+
|
43
|
+
const vorbis_func_mapping *const _mapping_P[]={
|
44
|
+
&mapping0_exportbundle,
|
45
|
+
};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/********************************************************************
|
2
|
+
* *
|
3
|
+
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
4
|
+
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
5
|
+
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
6
|
+
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
7
|
+
* *
|
8
|
+
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
9
|
+
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
10
|
+
* *
|
11
|
+
********************************************************************
|
12
|
+
|
13
|
+
function: registry for time, floor, res backends and channel mappings
|
14
|
+
last mod: $Id: registry.h 15531 2008-11-24 23:50:06Z xiphmont $
|
15
|
+
|
16
|
+
********************************************************************/
|
17
|
+
|
18
|
+
#ifndef _V_REG_H_
|
19
|
+
#define _V_REG_H_
|
20
|
+
|
21
|
+
#define VI_TRANSFORMB 1
|
22
|
+
#define VI_WINDOWB 1
|
23
|
+
#define VI_TIMEB 1
|
24
|
+
#define VI_FLOORB 2
|
25
|
+
#define VI_RESB 3
|
26
|
+
#define VI_MAPB 1
|
27
|
+
|
28
|
+
extern const vorbis_func_floor *const _floor_P[];
|
29
|
+
extern const vorbis_func_residue *const _residue_P[];
|
30
|
+
extern const vorbis_func_mapping *const _mapping_P[];
|
31
|
+
|
32
|
+
#endif
|
@@ -0,0 +1,889 @@
|
|
1
|
+
/********************************************************************
|
2
|
+
* *
|
3
|
+
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
4
|
+
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
5
|
+
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
6
|
+
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
7
|
+
* *
|
8
|
+
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
|
9
|
+
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
10
|
+
* *
|
11
|
+
********************************************************************
|
12
|
+
|
13
|
+
function: residue backend 0, 1 and 2 implementation
|
14
|
+
last mod: $Id: res0.c 17556 2010-10-21 18:25:19Z tterribe $
|
15
|
+
|
16
|
+
********************************************************************/
|
17
|
+
|
18
|
+
/* Slow, slow, slow, simpleminded and did I mention it was slow? The
|
19
|
+
encode/decode loops are coded for clarity and performance is not
|
20
|
+
yet even a nagging little idea lurking in the shadows. Oh and BTW,
|
21
|
+
it's slow. */
|
22
|
+
|
23
|
+
#include <stdlib.h>
|
24
|
+
#include <string.h>
|
25
|
+
#include <math.h>
|
26
|
+
#include <ogg/ogg.h>
|
27
|
+
#include "vorbis/codec.h"
|
28
|
+
#include "codec_internal.h"
|
29
|
+
#include "registry.h"
|
30
|
+
#include "codebook.h"
|
31
|
+
#include "misc.h"
|
32
|
+
#include "os.h"
|
33
|
+
|
34
|
+
//#define TRAIN_RES 1
|
35
|
+
//#define TRAIN_RESAUX 1
|
36
|
+
|
37
|
+
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
|
38
|
+
#include <stdio.h>
|
39
|
+
#endif
|
40
|
+
|
41
|
+
typedef struct {
|
42
|
+
vorbis_info_residue0 *info;
|
43
|
+
|
44
|
+
int parts;
|
45
|
+
int stages;
|
46
|
+
codebook *fullbooks;
|
47
|
+
codebook *phrasebook;
|
48
|
+
codebook ***partbooks;
|
49
|
+
|
50
|
+
int partvals;
|
51
|
+
int **decodemap;
|
52
|
+
|
53
|
+
long postbits;
|
54
|
+
long phrasebits;
|
55
|
+
long frames;
|
56
|
+
|
57
|
+
#if defined(TRAIN_RES) || defined(TRAIN_RESAUX)
|
58
|
+
int train_seq;
|
59
|
+
long *training_data[8][64];
|
60
|
+
float training_max[8][64];
|
61
|
+
float training_min[8][64];
|
62
|
+
float tmin;
|
63
|
+
float tmax;
|
64
|
+
int submap;
|
65
|
+
#endif
|
66
|
+
|
67
|
+
} vorbis_look_residue0;
|
68
|
+
|
69
|
+
void res0_free_info(vorbis_info_residue *i){
|
70
|
+
vorbis_info_residue0 *info=(vorbis_info_residue0 *)i;
|
71
|
+
if(info){
|
72
|
+
memset(info,0,sizeof(*info));
|
73
|
+
_ogg_free(info);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
void res0_free_look(vorbis_look_residue *i){
|
78
|
+
int j;
|
79
|
+
if(i){
|
80
|
+
|
81
|
+
vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
|
82
|
+
|
83
|
+
#ifdef TRAIN_RES
|
84
|
+
{
|
85
|
+
int j,k,l;
|
86
|
+
for(j=0;j<look->parts;j++){
|
87
|
+
/*fprintf(stderr,"partition %d: ",j);*/
|
88
|
+
for(k=0;k<8;k++)
|
89
|
+
if(look->training_data[k][j]){
|
90
|
+
char buffer[80];
|
91
|
+
FILE *of;
|
92
|
+
codebook *statebook=look->partbooks[j][k];
|
93
|
+
|
94
|
+
/* long and short into the same bucket by current convention */
|
95
|
+
sprintf(buffer,"res_sub%d_part%d_pass%d.vqd",look->submap,j,k);
|
96
|
+
of=fopen(buffer,"a");
|
97
|
+
|
98
|
+
for(l=0;l<statebook->entries;l++)
|
99
|
+
fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]);
|
100
|
+
|
101
|
+
fclose(of);
|
102
|
+
|
103
|
+
/*fprintf(stderr,"%d(%.2f|%.2f) ",k,
|
104
|
+
look->training_min[k][j],look->training_max[k][j]);*/
|
105
|
+
|
106
|
+
_ogg_free(look->training_data[k][j]);
|
107
|
+
look->training_data[k][j]=NULL;
|
108
|
+
}
|
109
|
+
/*fprintf(stderr,"\n");*/
|
110
|
+
}
|
111
|
+
}
|
112
|
+
fprintf(stderr,"min/max residue: %g::%g\n",look->tmin,look->tmax);
|
113
|
+
|
114
|
+
/*fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
|
115
|
+
(float)look->phrasebits/look->frames,
|
116
|
+
(float)look->postbits/look->frames,
|
117
|
+
(float)(look->postbits+look->phrasebits)/look->frames);*/
|
118
|
+
#endif
|
119
|
+
|
120
|
+
|
121
|
+
/*vorbis_info_residue0 *info=look->info;
|
122
|
+
|
123
|
+
fprintf(stderr,
|
124
|
+
"%ld frames encoded in %ld phrasebits and %ld residue bits "
|
125
|
+
"(%g/frame) \n",look->frames,look->phrasebits,
|
126
|
+
look->resbitsflat,
|
127
|
+
(look->phrasebits+look->resbitsflat)/(float)look->frames);
|
128
|
+
|
129
|
+
for(j=0;j<look->parts;j++){
|
130
|
+
long acc=0;
|
131
|
+
fprintf(stderr,"\t[%d] == ",j);
|
132
|
+
for(k=0;k<look->stages;k++)
|
133
|
+
if((info->secondstages[j]>>k)&1){
|
134
|
+
fprintf(stderr,"%ld,",look->resbits[j][k]);
|
135
|
+
acc+=look->resbits[j][k];
|
136
|
+
}
|
137
|
+
|
138
|
+
fprintf(stderr,":: (%ld vals) %1.2fbits/sample\n",look->resvals[j],
|
139
|
+
acc?(float)acc/(look->resvals[j]*info->grouping):0);
|
140
|
+
}
|
141
|
+
fprintf(stderr,"\n");*/
|
142
|
+
|
143
|
+
for(j=0;j<look->parts;j++)
|
144
|
+
if(look->partbooks[j])_ogg_free(look->partbooks[j]);
|
145
|
+
_ogg_free(look->partbooks);
|
146
|
+
for(j=0;j<look->partvals;j++)
|
147
|
+
_ogg_free(look->decodemap[j]);
|
148
|
+
_ogg_free(look->decodemap);
|
149
|
+
|
150
|
+
memset(look,0,sizeof(*look));
|
151
|
+
_ogg_free(look);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
static int ilog(unsigned int v){
|
156
|
+
int ret=0;
|
157
|
+
while(v){
|
158
|
+
ret++;
|
159
|
+
v>>=1;
|
160
|
+
}
|
161
|
+
return(ret);
|
162
|
+
}
|
163
|
+
|
164
|
+
static int icount(unsigned int v){
|
165
|
+
int ret=0;
|
166
|
+
while(v){
|
167
|
+
ret+=v&1;
|
168
|
+
v>>=1;
|
169
|
+
}
|
170
|
+
return(ret);
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){
|
175
|
+
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
|
176
|
+
int j,acc=0;
|
177
|
+
oggpack_write(opb,info->begin,24);
|
178
|
+
oggpack_write(opb,info->end,24);
|
179
|
+
|
180
|
+
oggpack_write(opb,info->grouping-1,24); /* residue vectors to group and
|
181
|
+
code with a partitioned book */
|
182
|
+
oggpack_write(opb,info->partitions-1,6); /* possible partition choices */
|
183
|
+
oggpack_write(opb,info->groupbook,8); /* group huffman book */
|
184
|
+
|
185
|
+
/* secondstages is a bitmask; as encoding progresses pass by pass, a
|
186
|
+
bitmask of one indicates this partition class has bits to write
|
187
|
+
this pass */
|
188
|
+
for(j=0;j<info->partitions;j++){
|
189
|
+
if(ilog(info->secondstages[j])>3){
|
190
|
+
/* yes, this is a minor hack due to not thinking ahead */
|
191
|
+
oggpack_write(opb,info->secondstages[j],3);
|
192
|
+
oggpack_write(opb,1,1);
|
193
|
+
oggpack_write(opb,info->secondstages[j]>>3,5);
|
194
|
+
}else
|
195
|
+
oggpack_write(opb,info->secondstages[j],4); /* trailing zero */
|
196
|
+
acc+=icount(info->secondstages[j]);
|
197
|
+
}
|
198
|
+
for(j=0;j<acc;j++)
|
199
|
+
oggpack_write(opb,info->booklist[j],8);
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
/* vorbis_info is for range checking */
|
204
|
+
vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
|
205
|
+
int j,acc=0;
|
206
|
+
vorbis_info_residue0 *info=_ogg_calloc(1,sizeof(*info));
|
207
|
+
codec_setup_info *ci=vi->codec_setup;
|
208
|
+
|
209
|
+
info->begin=oggpack_read(opb,24);
|
210
|
+
info->end=oggpack_read(opb,24);
|
211
|
+
info->grouping=oggpack_read(opb,24)+1;
|
212
|
+
info->partitions=oggpack_read(opb,6)+1;
|
213
|
+
info->groupbook=oggpack_read(opb,8);
|
214
|
+
|
215
|
+
/* check for premature EOP */
|
216
|
+
if(info->groupbook<0)goto errout;
|
217
|
+
|
218
|
+
for(j=0;j<info->partitions;j++){
|
219
|
+
int cascade=oggpack_read(opb,3);
|
220
|
+
int cflag=oggpack_read(opb,1);
|
221
|
+
if(cflag<0) goto errout;
|
222
|
+
if(cflag){
|
223
|
+
int c=oggpack_read(opb,5);
|
224
|
+
if(c<0) goto errout;
|
225
|
+
cascade|=(c<<3);
|
226
|
+
}
|
227
|
+
info->secondstages[j]=cascade;
|
228
|
+
|
229
|
+
acc+=icount(cascade);
|
230
|
+
}
|
231
|
+
for(j=0;j<acc;j++){
|
232
|
+
int book=oggpack_read(opb,8);
|
233
|
+
if(book<0) goto errout;
|
234
|
+
info->booklist[j]=book;
|
235
|
+
}
|
236
|
+
|
237
|
+
if(info->groupbook>=ci->books)goto errout;
|
238
|
+
for(j=0;j<acc;j++){
|
239
|
+
if(info->booklist[j]>=ci->books)goto errout;
|
240
|
+
if(ci->book_param[info->booklist[j]]->maptype==0)goto errout;
|
241
|
+
}
|
242
|
+
|
243
|
+
/* verify the phrasebook is not specifying an impossible or
|
244
|
+
inconsistent partitioning scheme. */
|
245
|
+
/* modify the phrasebook ranging check from r16327; an early beta
|
246
|
+
encoder had a bug where it used an oversized phrasebook by
|
247
|
+
accident. These files should continue to be playable, but don't
|
248
|
+
allow an exploit */
|
249
|
+
{
|
250
|
+
int entries = ci->book_param[info->groupbook]->entries;
|
251
|
+
int dim = ci->book_param[info->groupbook]->dim;
|
252
|
+
int partvals = 1;
|
253
|
+
if (dim<1) goto errout;
|
254
|
+
while(dim>0){
|
255
|
+
partvals *= info->partitions;
|
256
|
+
if(partvals > entries) goto errout;
|
257
|
+
dim--;
|
258
|
+
}
|
259
|
+
info->partvals = partvals;
|
260
|
+
}
|
261
|
+
|
262
|
+
return(info);
|
263
|
+
errout:
|
264
|
+
res0_free_info(info);
|
265
|
+
return(NULL);
|
266
|
+
}
|
267
|
+
|
268
|
+
vorbis_look_residue *res0_look(vorbis_dsp_state *vd,
|
269
|
+
vorbis_info_residue *vr){
|
270
|
+
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
|
271
|
+
vorbis_look_residue0 *look=_ogg_calloc(1,sizeof(*look));
|
272
|
+
codec_setup_info *ci=vd->vi->codec_setup;
|
273
|
+
|
274
|
+
int j,k,acc=0;
|
275
|
+
int dim;
|
276
|
+
int maxstage=0;
|
277
|
+
look->info=info;
|
278
|
+
|
279
|
+
look->parts=info->partitions;
|
280
|
+
look->fullbooks=ci->fullbooks;
|
281
|
+
look->phrasebook=ci->fullbooks+info->groupbook;
|
282
|
+
dim=look->phrasebook->dim;
|
283
|
+
|
284
|
+
look->partbooks=_ogg_calloc(look->parts,sizeof(*look->partbooks));
|
285
|
+
|
286
|
+
for(j=0;j<look->parts;j++){
|
287
|
+
int stages=ilog(info->secondstages[j]);
|
288
|
+
if(stages){
|
289
|
+
if(stages>maxstage)maxstage=stages;
|
290
|
+
look->partbooks[j]=_ogg_calloc(stages,sizeof(*look->partbooks[j]));
|
291
|
+
for(k=0;k<stages;k++)
|
292
|
+
if(info->secondstages[j]&(1<<k)){
|
293
|
+
look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
|
294
|
+
#ifdef TRAIN_RES
|
295
|
+
look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries,
|
296
|
+
sizeof(***look->training_data));
|
297
|
+
#endif
|
298
|
+
}
|
299
|
+
}
|
300
|
+
}
|
301
|
+
|
302
|
+
look->partvals=1;
|
303
|
+
for(j=0;j<dim;j++)
|
304
|
+
look->partvals*=look->parts;
|
305
|
+
|
306
|
+
look->stages=maxstage;
|
307
|
+
look->decodemap=_ogg_malloc(look->partvals*sizeof(*look->decodemap));
|
308
|
+
for(j=0;j<look->partvals;j++){
|
309
|
+
long val=j;
|
310
|
+
long mult=look->partvals/look->parts;
|
311
|
+
look->decodemap[j]=_ogg_malloc(dim*sizeof(*look->decodemap[j]));
|
312
|
+
for(k=0;k<dim;k++){
|
313
|
+
long deco=val/mult;
|
314
|
+
val-=deco*mult;
|
315
|
+
mult/=look->parts;
|
316
|
+
look->decodemap[j][k]=deco;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
|
320
|
+
{
|
321
|
+
static int train_seq=0;
|
322
|
+
look->train_seq=train_seq++;
|
323
|
+
}
|
324
|
+
#endif
|
325
|
+
return(look);
|
326
|
+
}
|
327
|
+
|
328
|
+
/* break an abstraction and copy some code for performance purposes */
|
329
|
+
static int local_book_besterror(codebook *book,int *a){
|
330
|
+
int dim=book->dim;
|
331
|
+
int i,j,o;
|
332
|
+
int minval=book->minval;
|
333
|
+
int del=book->delta;
|
334
|
+
int qv=book->quantvals;
|
335
|
+
int ze=(qv>>1);
|
336
|
+
int index=0;
|
337
|
+
/* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */
|
338
|
+
int p[8]={0,0,0,0,0,0,0,0};
|
339
|
+
|
340
|
+
if(del!=1){
|
341
|
+
for(i=0,o=dim;i<dim;i++){
|
342
|
+
int v = (a[--o]-minval+(del>>1))/del;
|
343
|
+
int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1));
|
344
|
+
index = index*qv+ (m<0?0:(m>=qv?qv-1:m));
|
345
|
+
p[o]=v*del+minval;
|
346
|
+
}
|
347
|
+
}else{
|
348
|
+
for(i=0,o=dim;i<dim;i++){
|
349
|
+
int v = a[--o]-minval;
|
350
|
+
int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1));
|
351
|
+
index = index*qv+ (m<0?0:(m>=qv?qv-1:m));
|
352
|
+
p[o]=v*del+minval;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
|
356
|
+
if(book->c->lengthlist[index]<=0){
|
357
|
+
const static_codebook *c=book->c;
|
358
|
+
int best=-1;
|
359
|
+
/* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */
|
360
|
+
int e[8]={0,0,0,0,0,0,0,0};
|
361
|
+
int maxval = book->minval + book->delta*(book->quantvals-1);
|
362
|
+
for(i=0;i<book->entries;i++){
|
363
|
+
if(c->lengthlist[i]>0){
|
364
|
+
int this=0;
|
365
|
+
for(j=0;j<dim;j++){
|
366
|
+
int val=(e[j]-a[j]);
|
367
|
+
this+=val*val;
|
368
|
+
}
|
369
|
+
if(best==-1 || this<best){
|
370
|
+
memcpy(p,e,sizeof(p));
|
371
|
+
best=this;
|
372
|
+
index=i;
|
373
|
+
}
|
374
|
+
}
|
375
|
+
/* assumes the value patterning created by the tools in vq/ */
|
376
|
+
j=0;
|
377
|
+
while(e[j]>=maxval)
|
378
|
+
e[j++]=0;
|
379
|
+
if(e[j]>=0)
|
380
|
+
e[j]+=book->delta;
|
381
|
+
e[j]= -e[j];
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
if(index>-1){
|
386
|
+
for(i=0;i<dim;i++)
|
387
|
+
*a++ -= p[i];
|
388
|
+
}
|
389
|
+
|
390
|
+
return(index);
|
391
|
+
}
|
392
|
+
|
393
|
+
static int _encodepart(oggpack_buffer *opb,int *vec, int n,
|
394
|
+
codebook *book,long *acc){
|
395
|
+
int i,bits=0;
|
396
|
+
int dim=book->dim;
|
397
|
+
int step=n/dim;
|
398
|
+
|
399
|
+
for(i=0;i<step;i++){
|
400
|
+
int entry=local_book_besterror(book,vec+i*dim);
|
401
|
+
|
402
|
+
#ifdef TRAIN_RES
|
403
|
+
if(entry>=0)
|
404
|
+
acc[entry]++;
|
405
|
+
#endif
|
406
|
+
|
407
|
+
bits+=vorbis_book_encode(book,entry,opb);
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
return(bits);
|
412
|
+
}
|
413
|
+
|
414
|
+
static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
|
415
|
+
int **in,int ch){
|
416
|
+
long i,j,k;
|
417
|
+
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
|
418
|
+
vorbis_info_residue0 *info=look->info;
|
419
|
+
|
420
|
+
/* move all this setup out later */
|
421
|
+
int samples_per_partition=info->grouping;
|
422
|
+
int possible_partitions=info->partitions;
|
423
|
+
int n=info->end-info->begin;
|
424
|
+
|
425
|
+
int partvals=n/samples_per_partition;
|
426
|
+
long **partword=_vorbis_block_alloc(vb,ch*sizeof(*partword));
|
427
|
+
float scale=100./samples_per_partition;
|
428
|
+
|
429
|
+
/* we find the partition type for each partition of each
|
430
|
+
channel. We'll go back and do the interleaved encoding in a
|
431
|
+
bit. For now, clarity */
|
432
|
+
|
433
|
+
for(i=0;i<ch;i++){
|
434
|
+
partword[i]=_vorbis_block_alloc(vb,n/samples_per_partition*sizeof(*partword[i]));
|
435
|
+
memset(partword[i],0,n/samples_per_partition*sizeof(*partword[i]));
|
436
|
+
}
|
437
|
+
|
438
|
+
for(i=0;i<partvals;i++){
|
439
|
+
int offset=i*samples_per_partition+info->begin;
|
440
|
+
for(j=0;j<ch;j++){
|
441
|
+
int max=0;
|
442
|
+
int ent=0;
|
443
|
+
for(k=0;k<samples_per_partition;k++){
|
444
|
+
if(abs(in[j][offset+k])>max)max=abs(in[j][offset+k]);
|
445
|
+
ent+=abs(in[j][offset+k]);
|
446
|
+
}
|
447
|
+
ent*=scale;
|
448
|
+
|
449
|
+
for(k=0;k<possible_partitions-1;k++)
|
450
|
+
if(max<=info->classmetric1[k] &&
|
451
|
+
(info->classmetric2[k]<0 || ent<info->classmetric2[k]))
|
452
|
+
break;
|
453
|
+
|
454
|
+
partword[j][i]=k;
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
#ifdef TRAIN_RESAUX
|
459
|
+
{
|
460
|
+
FILE *of;
|
461
|
+
char buffer[80];
|
462
|
+
|
463
|
+
for(i=0;i<ch;i++){
|
464
|
+
sprintf(buffer,"resaux_%d.vqd",look->train_seq);
|
465
|
+
of=fopen(buffer,"a");
|
466
|
+
for(j=0;j<partvals;j++)
|
467
|
+
fprintf(of,"%ld, ",partword[i][j]);
|
468
|
+
fprintf(of,"\n");
|
469
|
+
fclose(of);
|
470
|
+
}
|
471
|
+
}
|
472
|
+
#endif
|
473
|
+
look->frames++;
|
474
|
+
|
475
|
+
return(partword);
|
476
|
+
}
|
477
|
+
|
478
|
+
/* designed for stereo or other modes where the partition size is an
|
479
|
+
integer multiple of the number of channels encoded in the current
|
480
|
+
submap */
|
481
|
+
static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,int **in,
|
482
|
+
int ch){
|
483
|
+
long i,j,k,l;
|
484
|
+
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
|
485
|
+
vorbis_info_residue0 *info=look->info;
|
486
|
+
|
487
|
+
/* move all this setup out later */
|
488
|
+
int samples_per_partition=info->grouping;
|
489
|
+
int possible_partitions=info->partitions;
|
490
|
+
int n=info->end-info->begin;
|
491
|
+
|
492
|
+
int partvals=n/samples_per_partition;
|
493
|
+
long **partword=_vorbis_block_alloc(vb,sizeof(*partword));
|
494
|
+
|
495
|
+
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
|
496
|
+
FILE *of;
|
497
|
+
char buffer[80];
|
498
|
+
#endif
|
499
|
+
|
500
|
+
partword[0]=_vorbis_block_alloc(vb,partvals*sizeof(*partword[0]));
|
501
|
+
memset(partword[0],0,partvals*sizeof(*partword[0]));
|
502
|
+
|
503
|
+
for(i=0,l=info->begin/ch;i<partvals;i++){
|
504
|
+
int magmax=0;
|
505
|
+
int angmax=0;
|
506
|
+
for(j=0;j<samples_per_partition;j+=ch){
|
507
|
+
if(abs(in[0][l])>magmax)magmax=abs(in[0][l]);
|
508
|
+
for(k=1;k<ch;k++)
|
509
|
+
if(abs(in[k][l])>angmax)angmax=abs(in[k][l]);
|
510
|
+
l++;
|
511
|
+
}
|
512
|
+
|
513
|
+
for(j=0;j<possible_partitions-1;j++)
|
514
|
+
if(magmax<=info->classmetric1[j] &&
|
515
|
+
angmax<=info->classmetric2[j])
|
516
|
+
break;
|
517
|
+
|
518
|
+
partword[0][i]=j;
|
519
|
+
|
520
|
+
}
|
521
|
+
|
522
|
+
#ifdef TRAIN_RESAUX
|
523
|
+
sprintf(buffer,"resaux_%d.vqd",look->train_seq);
|
524
|
+
of=fopen(buffer,"a");
|
525
|
+
for(i=0;i<partvals;i++)
|
526
|
+
fprintf(of,"%ld, ",partword[0][i]);
|
527
|
+
fprintf(of,"\n");
|
528
|
+
fclose(of);
|
529
|
+
#endif
|
530
|
+
|
531
|
+
look->frames++;
|
532
|
+
|
533
|
+
return(partword);
|
534
|
+
}
|
535
|
+
|
536
|
+
static int _01forward(oggpack_buffer *opb,
|
537
|
+
vorbis_block *vb,vorbis_look_residue *vl,
|
538
|
+
int **in,int ch,
|
539
|
+
long **partword,
|
540
|
+
int (*encode)(oggpack_buffer *,int *,int,
|
541
|
+
codebook *,long *),
|
542
|
+
int submap){
|
543
|
+
long i,j,k,s;
|
544
|
+
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
|
545
|
+
vorbis_info_residue0 *info=look->info;
|
546
|
+
|
547
|
+
#ifdef TRAIN_RES
|
548
|
+
look->submap=submap;
|
549
|
+
#endif
|
550
|
+
|
551
|
+
/* move all this setup out later */
|
552
|
+
int samples_per_partition=info->grouping;
|
553
|
+
int possible_partitions=info->partitions;
|
554
|
+
int partitions_per_word=look->phrasebook->dim;
|
555
|
+
int n=info->end-info->begin;
|
556
|
+
|
557
|
+
int partvals=n/samples_per_partition;
|
558
|
+
long resbits[128];
|
559
|
+
long resvals[128];
|
560
|
+
|
561
|
+
#ifdef TRAIN_RES
|
562
|
+
for(i=0;i<ch;i++)
|
563
|
+
for(j=info->begin;j<info->end;j++){
|
564
|
+
if(in[i][j]>look->tmax)look->tmax=in[i][j];
|
565
|
+
if(in[i][j]<look->tmin)look->tmin=in[i][j];
|
566
|
+
}
|
567
|
+
#endif
|
568
|
+
|
569
|
+
memset(resbits,0,sizeof(resbits));
|
570
|
+
memset(resvals,0,sizeof(resvals));
|
571
|
+
|
572
|
+
/* we code the partition words for each channel, then the residual
|
573
|
+
words for a partition per channel until we've written all the
|
574
|
+
residual words for that partition word. Then write the next
|
575
|
+
partition channel words... */
|
576
|
+
|
577
|
+
for(s=0;s<look->stages;s++){
|
578
|
+
|
579
|
+
for(i=0;i<partvals;){
|
580
|
+
|
581
|
+
/* first we encode a partition codeword for each channel */
|
582
|
+
if(s==0){
|
583
|
+
for(j=0;j<ch;j++){
|
584
|
+
long val=partword[j][i];
|
585
|
+
for(k=1;k<partitions_per_word;k++){
|
586
|
+
val*=possible_partitions;
|
587
|
+
if(i+k<partvals)
|
588
|
+
val+=partword[j][i+k];
|
589
|
+
}
|
590
|
+
|
591
|
+
/* training hack */
|
592
|
+
if(val<look->phrasebook->entries)
|
593
|
+
look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb);
|
594
|
+
#if 0 /*def TRAIN_RES*/
|
595
|
+
else
|
596
|
+
fprintf(stderr,"!");
|
597
|
+
#endif
|
598
|
+
|
599
|
+
}
|
600
|
+
}
|
601
|
+
|
602
|
+
/* now we encode interleaved residual values for the partitions */
|
603
|
+
for(k=0;k<partitions_per_word && i<partvals;k++,i++){
|
604
|
+
long offset=i*samples_per_partition+info->begin;
|
605
|
+
|
606
|
+
for(j=0;j<ch;j++){
|
607
|
+
if(s==0)resvals[partword[j][i]]+=samples_per_partition;
|
608
|
+
if(info->secondstages[partword[j][i]]&(1<<s)){
|
609
|
+
codebook *statebook=look->partbooks[partword[j][i]][s];
|
610
|
+
if(statebook){
|
611
|
+
int ret;
|
612
|
+
long *accumulator=NULL;
|
613
|
+
|
614
|
+
#ifdef TRAIN_RES
|
615
|
+
accumulator=look->training_data[s][partword[j][i]];
|
616
|
+
{
|
617
|
+
int l;
|
618
|
+
int *samples=in[j]+offset;
|
619
|
+
for(l=0;l<samples_per_partition;l++){
|
620
|
+
if(samples[l]<look->training_min[s][partword[j][i]])
|
621
|
+
look->training_min[s][partword[j][i]]=samples[l];
|
622
|
+
if(samples[l]>look->training_max[s][partword[j][i]])
|
623
|
+
look->training_max[s][partword[j][i]]=samples[l];
|
624
|
+
}
|
625
|
+
}
|
626
|
+
#endif
|
627
|
+
|
628
|
+
ret=encode(opb,in[j]+offset,samples_per_partition,
|
629
|
+
statebook,accumulator);
|
630
|
+
|
631
|
+
look->postbits+=ret;
|
632
|
+
resbits[partword[j][i]]+=ret;
|
633
|
+
}
|
634
|
+
}
|
635
|
+
}
|
636
|
+
}
|
637
|
+
}
|
638
|
+
}
|
639
|
+
|
640
|
+
/*{
|
641
|
+
long total=0;
|
642
|
+
long totalbits=0;
|
643
|
+
fprintf(stderr,"%d :: ",vb->mode);
|
644
|
+
for(k=0;k<possible_partitions;k++){
|
645
|
+
fprintf(stderr,"%ld/%1.2g, ",resvals[k],(float)resbits[k]/resvals[k]);
|
646
|
+
total+=resvals[k];
|
647
|
+
totalbits+=resbits[k];
|
648
|
+
}
|
649
|
+
|
650
|
+
fprintf(stderr,":: %ld:%1.2g\n",total,(double)totalbits/total);
|
651
|
+
}*/
|
652
|
+
|
653
|
+
return(0);
|
654
|
+
}
|
655
|
+
|
656
|
+
/* a truncated packet here just means 'stop working'; it's not an error */
|
657
|
+
static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
658
|
+
float **in,int ch,
|
659
|
+
long (*decodepart)(codebook *, float *,
|
660
|
+
oggpack_buffer *,int)){
|
661
|
+
|
662
|
+
long i,j,k,l,s;
|
663
|
+
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
|
664
|
+
vorbis_info_residue0 *info=look->info;
|
665
|
+
|
666
|
+
/* move all this setup out later */
|
667
|
+
int samples_per_partition=info->grouping;
|
668
|
+
int partitions_per_word=look->phrasebook->dim;
|
669
|
+
int max=vb->pcmend>>1;
|
670
|
+
int end=(info->end<max?info->end:max);
|
671
|
+
int n=end-info->begin;
|
672
|
+
|
673
|
+
if(n>0){
|
674
|
+
int partvals=n/samples_per_partition;
|
675
|
+
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
|
676
|
+
int ***partword=alloca(ch*sizeof(*partword));
|
677
|
+
|
678
|
+
for(j=0;j<ch;j++)
|
679
|
+
partword[j]=_vorbis_block_alloc(vb,partwords*sizeof(*partword[j]));
|
680
|
+
|
681
|
+
for(s=0;s<look->stages;s++){
|
682
|
+
|
683
|
+
/* each loop decodes on partition codeword containing
|
684
|
+
partitions_per_word partitions */
|
685
|
+
for(i=0,l=0;i<partvals;l++){
|
686
|
+
if(s==0){
|
687
|
+
/* fetch the partition word for each channel */
|
688
|
+
for(j=0;j<ch;j++){
|
689
|
+
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
|
690
|
+
|
691
|
+
if(temp==-1 || temp>=info->partvals)goto eopbreak;
|
692
|
+
partword[j][l]=look->decodemap[temp];
|
693
|
+
if(partword[j][l]==NULL)goto errout;
|
694
|
+
}
|
695
|
+
}
|
696
|
+
|
697
|
+
/* now we decode residual values for the partitions */
|
698
|
+
for(k=0;k<partitions_per_word && i<partvals;k++,i++)
|
699
|
+
for(j=0;j<ch;j++){
|
700
|
+
long offset=info->begin+i*samples_per_partition;
|
701
|
+
if(info->secondstages[partword[j][l][k]]&(1<<s)){
|
702
|
+
codebook *stagebook=look->partbooks[partword[j][l][k]][s];
|
703
|
+
if(stagebook){
|
704
|
+
if(decodepart(stagebook,in[j]+offset,&vb->opb,
|
705
|
+
samples_per_partition)==-1)goto eopbreak;
|
706
|
+
}
|
707
|
+
}
|
708
|
+
}
|
709
|
+
}
|
710
|
+
}
|
711
|
+
}
|
712
|
+
errout:
|
713
|
+
eopbreak:
|
714
|
+
return(0);
|
715
|
+
}
|
716
|
+
|
717
|
+
int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
718
|
+
float **in,int *nonzero,int ch){
|
719
|
+
int i,used=0;
|
720
|
+
for(i=0;i<ch;i++)
|
721
|
+
if(nonzero[i])
|
722
|
+
in[used++]=in[i];
|
723
|
+
if(used)
|
724
|
+
return(_01inverse(vb,vl,in,used,vorbis_book_decodevs_add));
|
725
|
+
else
|
726
|
+
return(0);
|
727
|
+
}
|
728
|
+
|
729
|
+
int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl,
|
730
|
+
int **in,int *nonzero,int ch, long **partword, int submap){
|
731
|
+
int i,used=0;
|
732
|
+
for(i=0;i<ch;i++)
|
733
|
+
if(nonzero[i])
|
734
|
+
in[used++]=in[i];
|
735
|
+
|
736
|
+
if(used){
|
737
|
+
return _01forward(opb,vb,vl,in,used,partword,_encodepart,submap);
|
738
|
+
}else{
|
739
|
+
return(0);
|
740
|
+
}
|
741
|
+
}
|
742
|
+
|
743
|
+
long **res1_class(vorbis_block *vb,vorbis_look_residue *vl,
|
744
|
+
int **in,int *nonzero,int ch){
|
745
|
+
int i,used=0;
|
746
|
+
for(i=0;i<ch;i++)
|
747
|
+
if(nonzero[i])
|
748
|
+
in[used++]=in[i];
|
749
|
+
if(used)
|
750
|
+
return(_01class(vb,vl,in,used));
|
751
|
+
else
|
752
|
+
return(0);
|
753
|
+
}
|
754
|
+
|
755
|
+
int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
756
|
+
float **in,int *nonzero,int ch){
|
757
|
+
int i,used=0;
|
758
|
+
for(i=0;i<ch;i++)
|
759
|
+
if(nonzero[i])
|
760
|
+
in[used++]=in[i];
|
761
|
+
if(used)
|
762
|
+
return(_01inverse(vb,vl,in,used,vorbis_book_decodev_add));
|
763
|
+
else
|
764
|
+
return(0);
|
765
|
+
}
|
766
|
+
|
767
|
+
long **res2_class(vorbis_block *vb,vorbis_look_residue *vl,
|
768
|
+
int **in,int *nonzero,int ch){
|
769
|
+
int i,used=0;
|
770
|
+
for(i=0;i<ch;i++)
|
771
|
+
if(nonzero[i])used++;
|
772
|
+
if(used)
|
773
|
+
return(_2class(vb,vl,in,ch));
|
774
|
+
else
|
775
|
+
return(0);
|
776
|
+
}
|
777
|
+
|
778
|
+
/* res2 is slightly more different; all the channels are interleaved
|
779
|
+
into a single vector and encoded. */
|
780
|
+
|
781
|
+
int res2_forward(oggpack_buffer *opb,
|
782
|
+
vorbis_block *vb,vorbis_look_residue *vl,
|
783
|
+
int **in,int *nonzero,int ch, long **partword,int submap){
|
784
|
+
long i,j,k,n=vb->pcmend/2,used=0;
|
785
|
+
|
786
|
+
/* don't duplicate the code; use a working vector hack for now and
|
787
|
+
reshape ourselves into a single channel res1 */
|
788
|
+
/* ugly; reallocs for each coupling pass :-( */
|
789
|
+
int *work=_vorbis_block_alloc(vb,ch*n*sizeof(*work));
|
790
|
+
for(i=0;i<ch;i++){
|
791
|
+
int *pcm=in[i];
|
792
|
+
if(nonzero[i])used++;
|
793
|
+
for(j=0,k=i;j<n;j++,k+=ch)
|
794
|
+
work[k]=pcm[j];
|
795
|
+
}
|
796
|
+
|
797
|
+
if(used){
|
798
|
+
return _01forward(opb,vb,vl,&work,1,partword,_encodepart,submap);
|
799
|
+
}else{
|
800
|
+
return(0);
|
801
|
+
}
|
802
|
+
}
|
803
|
+
|
804
|
+
/* duplicate code here as speed is somewhat more important */
|
805
|
+
int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
806
|
+
float **in,int *nonzero,int ch){
|
807
|
+
long i,k,l,s;
|
808
|
+
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
|
809
|
+
vorbis_info_residue0 *info=look->info;
|
810
|
+
|
811
|
+
/* move all this setup out later */
|
812
|
+
int samples_per_partition=info->grouping;
|
813
|
+
int partitions_per_word=look->phrasebook->dim;
|
814
|
+
int max=(vb->pcmend*ch)>>1;
|
815
|
+
int end=(info->end<max?info->end:max);
|
816
|
+
int n=end-info->begin;
|
817
|
+
|
818
|
+
if(n>0){
|
819
|
+
int partvals=n/samples_per_partition;
|
820
|
+
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
|
821
|
+
int **partword=_vorbis_block_alloc(vb,partwords*sizeof(*partword));
|
822
|
+
|
823
|
+
for(i=0;i<ch;i++)if(nonzero[i])break;
|
824
|
+
if(i==ch)return(0); /* no nonzero vectors */
|
825
|
+
|
826
|
+
for(s=0;s<look->stages;s++){
|
827
|
+
for(i=0,l=0;i<partvals;l++){
|
828
|
+
|
829
|
+
if(s==0){
|
830
|
+
/* fetch the partition word */
|
831
|
+
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
|
832
|
+
if(temp==-1 || temp>=info->partvals)goto eopbreak;
|
833
|
+
partword[l]=look->decodemap[temp];
|
834
|
+
if(partword[l]==NULL)goto errout;
|
835
|
+
}
|
836
|
+
|
837
|
+
/* now we decode residual values for the partitions */
|
838
|
+
for(k=0;k<partitions_per_word && i<partvals;k++,i++)
|
839
|
+
if(info->secondstages[partword[l][k]]&(1<<s)){
|
840
|
+
codebook *stagebook=look->partbooks[partword[l][k]][s];
|
841
|
+
|
842
|
+
if(stagebook){
|
843
|
+
if(vorbis_book_decodevv_add(stagebook,in,
|
844
|
+
i*samples_per_partition+info->begin,ch,
|
845
|
+
&vb->opb,samples_per_partition)==-1)
|
846
|
+
goto eopbreak;
|
847
|
+
}
|
848
|
+
}
|
849
|
+
}
|
850
|
+
}
|
851
|
+
}
|
852
|
+
errout:
|
853
|
+
eopbreak:
|
854
|
+
return(0);
|
855
|
+
}
|
856
|
+
|
857
|
+
|
858
|
+
const vorbis_func_residue residue0_exportbundle={
|
859
|
+
NULL,
|
860
|
+
&res0_unpack,
|
861
|
+
&res0_look,
|
862
|
+
&res0_free_info,
|
863
|
+
&res0_free_look,
|
864
|
+
NULL,
|
865
|
+
NULL,
|
866
|
+
&res0_inverse
|
867
|
+
};
|
868
|
+
|
869
|
+
const vorbis_func_residue residue1_exportbundle={
|
870
|
+
&res0_pack,
|
871
|
+
&res0_unpack,
|
872
|
+
&res0_look,
|
873
|
+
&res0_free_info,
|
874
|
+
&res0_free_look,
|
875
|
+
&res1_class,
|
876
|
+
&res1_forward,
|
877
|
+
&res1_inverse
|
878
|
+
};
|
879
|
+
|
880
|
+
const vorbis_func_residue residue2_exportbundle={
|
881
|
+
&res0_pack,
|
882
|
+
&res0_unpack,
|
883
|
+
&res0_look,
|
884
|
+
&res0_free_info,
|
885
|
+
&res0_free_look,
|
886
|
+
&res2_class,
|
887
|
+
&res2_forward,
|
888
|
+
&res2_inverse
|
889
|
+
};
|