补充某些必要的文件

This commit is contained in:
SmallMain
2022-06-25 11:52:00 +08:00
parent 4ecc470f86
commit 03533b046c
2869 changed files with 1345388 additions and 2 deletions

View File

@@ -0,0 +1,47 @@
Tremolo changelog:
*** 20100110: 0.8 ***
First "post Google" version. Shift fixes in mdctARM.s and
mdctLARM.s. Many thanks to Gloria Wang for finding the example
file that showed this up. Thanks to everyone else at Google for
making the BSD rerelease possible!
Also, some (mainly error handling) fixes in codebook.c imported
from the trunk version of Tremor.
*** 20071129: 0.7 ***
Bugs in mdct.c, mdctARM.s, mdctLARM.s that caused 'chirping'
and 'popping' fixed. Many thanks to Dan Silsby for spotting
the problem, narrowing it down to the code concerned and
testing potential fixes.
*** 20070807: 0.6 ***
Initial optimisation port from low memory branch of Tremor,
v1.0.2
--------------------------------------------------------------------
Original Tremor changelog follows:
*** 20020517: 1.0.2 ***
Playback bugfix to floor1; mode mistakenly used for sizing instead
of blockflag
*** 20020515: 1.0.1 ***
Added complete API documentation to source tarball. No code
changes.
*** 20020412: 1.0.1 ***
Fixed a clipping bug that affected ARM processors; negative
overflows were being properly clipped, but then clobbered to
positive by the positive overflow chec (asm_arm.h:CLIP_TO_15)
*** 20020403: 1.0.0 ***
Initial version

View File

@@ -0,0 +1,35 @@
Previous versions of this software have been released under the
terms of the GNU GPL. Thanks to a grant from Google, this version
is released is under the same BSD style license as the original
Theora software was.
Copyright (C) 2002-2009 Xiph.org Foundation
Changes Copyright (C) 2009-2010 Robin Watts for Pinknoise Productions Ltd
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,105 @@
# Tremolo Makefile for Windows CE port
# Uses the VLC toolchain
# $URL$
# $Id$
wince_gcc_root = /usr/local/wince/cross-tools
srcdir = .
VPATH = $(srcdir)
CC = arm-wince-pe-gcc
CXX = arm-wince-pe-g++
LD = arm-wince-pe-g++
AR = arm-wince-pe-ar cru
RANLIB = arm-wince-pe-ranlib
STRIP = arm-wince-pe-strip
WINDRES= arm-wince-pe-windres
MKDIR = mkdir -p
RM = rm -f
RM_REC = rm -rf
ECHO = echo -n
CAT = cat
AS = arm-wince-pe-as
DEFINES :=
CFLAGS := -O2 -march=armv4 -mtune=xscale -I$(srcdir) -I$(wince_gcc_root)/include -D__cdecl= -D_WIN32_WCE=300 -D_ARM_ASSEM_ -static
CXXFLAGS := $(CFLAGS)
LDFLAGS := -Llibs/lib -L$(wince_gcc_root)/lib
LIBS := --entry WinMainCRTStartup
OBJS :=
MODULE_DIRS += .
LIBOBJS := bitwise.o bitwiseARM.o codebook.o dpen.o dsp.o floor0.o \
floor1.o floor1ARM.o floor_lookup.o framing.o info.o mapping0.o \
mdct.o mdctARM.o misc.o res012.o vorbisfile.o speed.o
EXEOBJS := testtremor.o
LIBOBJS_C := bitwise.oc codebook.oc dsp.oc floor0.oc floor1.oc \
floor_lookup.oc framing.oc info.oc mapping0.oc mdct.oc misc.oc \
res012.oc vorbisfile.oc speed.o
EXEOBJS_C := testtremor.oc
LIBOBJS_L := bitwise.ol bitwiseARM.o codebook.ol dpen.o dsp.ol floor0.ol \
floor1.ol floor1LARM.o floor_lookup.ol framing.ol info.ol mapping0.ol \
mdct.ol mdctLARM.o misc.ol res012.ol vorbisfile.ol speed.o
EXEOBJS_L := testtremor.ol
LIBOBJS_LC := bitwise.olc codebook.olc dsp.olc floor0.olc floor1.olc \
floor_lookup.olc framing.olc info.olc mapping0.olc mdct.olc misc.olc \
res012.olc vorbisfile.olc speed.o
EXEOBJS_LC := testtremor.olc
# Rules
.SUFFIXES: .oc .ol .olc
.c.oc:
$(CC) $(CFLAGS) -c $(<) -o $*.oc -DONLY_C
.c.ol:
$(CC) $(CFLAGS) -c $(<) -o $*.ol -D_LOW_ACCURACY_
.c.olc:
$(CC) $(CFLAGS) -c $(<) -o $*.olc -D_LOW_ACCURACY_ -DONLY_C
all: libTremolo006.lib bittest.exe testtremor.exe testtremorC.exe testtremorL.exe testtremorLC.exe annotate.exe
cp libTremolo006.lib /cygdrive/c/cvs/scummvm/trunk/backends/platform/wince/libs/lib/
cp ivorbisfile.h /cygdrive/c/cvs/scummvm/trunk/backends/platform/wince/libs/include/tremolo006/tremor/
cp config_types.h /cygdrive/c/cvs/scummvm/trunk/backends/platform/wince/libs/include/tremolo006/
cp ivorbiscodec.h /cygdrive/c/cvs/scummvm/trunk/backends/platform/wince/libs/include/tremolo006/
cp ogg.h /cygdrive/c/cvs/scummvm/trunk/backends/platform/wince/libs/include/tremolo006/
cp os_types.h /cygdrive/c/cvs/scummvm/trunk/backends/platform/wince/libs/include/tremolo006/
libTremolo006.lib: $(LIBOBJS)
arm-wince-pe-ar cru $@ $^
arm-wince-pe-ranlib $@
bitwiseTEST.o: bitwise.c
$(CC) $(CFLAGS) -c -o bitwiseTEST.o bitwise.c -D_V_BIT_TEST
bittest.exe: bitwiseTEST.o bitwiseARM.o dpen.o
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@ -Wl,-Map,bittest.exe.map -Wl,--stack,65536
testtremor.exe: testtremor.o profile.o $(LIBOBJS)
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@ -Wl,-Map,testtremor.exe.map -Wl,--stack,65536 -debug
testtremorC.exe: testtremor.oc profile.o $(LIBOBJS_C)
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@ -Wl,-Map,testtremorC.exe.map -Wl,--stack,65536
testtremorL.exe: testtremor.ol profile.o $(LIBOBJS_L)
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@ -Wl,-Map,testtremorL.exe.map -Wl,--stack,65536
testtremorLC.exe: testtremor.olc profile.o $(LIBOBJS_LC)
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@ -Wl,-Map,testtremorLC.exe.map -Wl,--stack,65536
annotate.exe: annotate.c
gcc $^ -o $@
clean:
rm `find . -name \*.o`
rm `find . -name \*.ol`
rm `find . -name \*.oc`
rm `find . -name \*.olc`

View File

@@ -0,0 +1,496 @@
Profile by Address
00000000 ( 42.09%: 2139) Address 0
00011008 ( 0.00%: 0) WinMainCRTStartup
00011078 ( 0.00%: 0) _cinit
000110d8 ( 0.00%: 0) exit
000111b8 ( 0.00%: 0) _exit
000111c4 ( 0.00%: 0) _cexit
000111d4 ( 0.00%: 0) _c_exit
000111e4 ( 0.00%: 0) Output
000112b0 ( 0.00%: 0) main2
000115d4 ( 0.00%: 0) WinMain
00011610 ( 0.00%: 0) speedtest
000117d4 ( 0.00%: 0) Profile_dump
00011984 ( 0.65%: 33) Profile_init
00011a60 ( 0.00%: 0) oggpack_eop
00011a74 ( 0.00%: 0) oggpack_bytes
00011aa4 ( 1.10%: 56) oggpack_bits
00011ae0 ( 2.48%: 126) oggpack_look
00011c04 ( 0.02%: 1) oggpack_adv
00011c8c ( 0.00%: 0) oggpack_readinit
00011cc4 ( 0.04%: 2) oggpack_read
00011e58 ( 0.00%: 0) _ilog
00012728 ( 0.02%: 1) _book_maptype1_quantvals
000127a8 ( 0.00%: 0) vorbis_book_clear
000127e8 ( 0.33%: 17) vorbis_book_unpack
00013008 ( 0.00%: 0) vorbis_book_decode
00013020 ( 0.00%: 0) vorbis_book_decodevs_add
000130c8 ( 0.00%: 0) vorbis_book_decodev_add
00013160 ( 0.00%: 0) vorbis_book_decodev_set
00013238 ( 2.77%: 141) decode_packed_entry_number_REALSTART
00013264 ( 9.41%: 478) decode_packed_entry_number
0001341c ( 5.51%: 280) decode_map
000135bc ( 5.31%: 270) vorbis_book_decodevv_add
0001364c ( 3.31%: 168) _checksum
000136ac ( 0.00%: 0) vorbis_dsp_restart
00013714 ( 0.00%: 0) vorbis_dsp_create
000137c8 ( 0.02%: 1) vorbis_dsp_destroy
00013918 ( 0.06%: 3) vorbis_dsp_pcmout
00013a44 ( 0.00%: 0) vorbis_dsp_read
00013a84 ( 0.00%: 0) vorbis_packet_blocksize
00013b04 ( 0.04%: 2) vorbis_dsp_synthesis
00013f04 ( 0.00%: 0) floor0_free_info
00013f10 ( 0.00%: 0) floor0_info_unpack
00014020 ( 0.00%: 0) floor0_memosize
0001402c ( 0.00%: 0) floor0_inverse1
00014188 ( 0.00%: 0) vorbis_lsp_to_curve
000147ec ( 0.00%: 0) floor0_inverse2
00014880 ( 0.00%: 0) floor1_free_info
00014938 ( 0.12%: 6) floor1_info_unpack
00014fc8 ( 0.12%: 6) render_point
00015014 ( 0.00%: 0) floor1_memosize
0001501c ( 0.85%: 43) floor1_inverse1
00015308 ( 1.20%: 61) floor1_inverse2
000154c4 ( 0.91%: 46) render_lineARM
00015698 ( 1.40%: 71) ogg_buffer_dup
00015b70 ( 0.04%: 2) ogg_page_version
00015bb0 ( 0.00%: 0) ogg_page_continued
00015bf0 ( 0.00%: 0) ogg_page_bos
00015c30 ( 0.04%: 2) ogg_page_eos
00015c70 ( 0.08%: 4) ogg_page_granulepos
00015d38 ( 0.06%: 3) ogg_page_serialno
00015d78 ( 0.00%: 0) ogg_page_pageno
00015db8 ( 0.00%: 0) ogg_page_packets
00015e1c ( 0.00%: 0) ogg_sync_create
00015e70 ( 0.00%: 0) ogg_sync_reset
00015ea0 ( 0.02%: 1) ogg_sync_destroy
00015ef8 ( 0.22%: 11) ogg_sync_bufferin
00015fb4 ( 0.16%: 8) ogg_sync_wrote
00016010 ( 0.02%: 1) ogg_page_release
00016050 ( 0.33%: 17) ogg_sync_pageseek
00016304 ( 0.00%: 0) ogg_sync_pageout
0001634c ( 0.00%: 0) ogg_stream_create
00016370 ( 0.04%: 2) ogg_stream_destroy
00016410 ( 0.08%: 4) ogg_stream_pagein
000164f8 ( 0.00%: 0) ogg_stream_reset
0001656c ( 0.00%: 0) ogg_stream_reset_serialno
00016588 ( 0.12%: 6) ogg_packet_release
00016a8c ( 0.00%: 0) ogg_stream_packetout
00016a94 ( 0.00%: 0) ogg_stream_packetpeek
00016a9c ( 0.00%: 0) ogg_page_dup
00016b0c ( 0.00%: 0) vorbis_comment_init
00016b80 ( 0.00%: 0) vorbis_comment_query
00016c54 ( 0.00%: 0) vorbis_comment_query_count
00016d04 ( 0.00%: 0) vorbis_comment_clear
00016d90 ( 0.00%: 0) vorbis_info_blocksize
00016da4 ( 0.00%: 0) vorbis_info_init
00016dec ( 0.00%: 0) vorbis_info_clear
00016f9c ( 0.00%: 0) vorbis_dsp_headerin
000175b8 ( 0.00%: 0) mapping_clear_info
00017634 ( 0.00%: 0) mapping_info_unpack
00017888 ( 0.77%: 39) mapping_inverse
00017d28 ( 0.00%: 0) mdct_unroll_lap
00017fa4 ( 0.00%: 0) mdct_backward
00018200 ( 0.10%: 5) mdct_unroll_prelap
000182a0 ( 0.08%: 4) mdct_unroll_postlap
00018364 ( 2.74%: 139) mdct_unroll_part2
000183bc ( 1.79%: 91) mdct_unroll_part3
00018414 ( 0.67%: 34) mdct_shift_right
00018470 ( 12.20%: 620) mdct_backwardARM
00018dc0 ( 0.00%: 0) _VDBG_dump
00018e24 ( 0.00%: 0) _VDBG_malloc
00018f70 ( 0.00%: 0) _VDBG_free
00018f98 ( 0.00%: 0) res_clear_info
00018fe8 ( 0.00%: 0) res_unpack
000191fc ( 1.77%: 90) res_inverse
0001a6f8 ( 0.00%: 0) ov_clear
0001a89c ( 0.00%: 0) ov_test_callbacks
0001a8dc ( 0.00%: 0) ov_test
0001a928 ( 0.00%: 0) ov_streams
0001a930 ( 0.00%: 0) ov_seekable
0001a938 ( 0.00%: 0) ov_time_total
0001a9fc ( 0.00%: 0) ov_bitrate
0001ab84 ( 0.00%: 0) ov_bitrate_instant
0001ac00 ( 0.00%: 0) ov_serialnumber
0001ac78 ( 0.00%: 0) ov_raw_total
0001ad28 ( 0.00%: 0) ov_pcm_total
0001adcc ( 0.00%: 0) ov_raw_seek
0001b6bc ( 0.00%: 0) ov_test_open
0001b6d4 ( 0.00%: 0) ov_open_callbacks
0001b72c ( 0.00%: 0) ov_open
0001b778 ( 0.00%: 0) ov_pcm_seek_page
0001c020 ( 0.00%: 0) ov_pcm_seek
0001c444 ( 0.00%: 0) ov_time_seek
0001c5c4 ( 0.00%: 0) ov_time_seek_page
0001c744 ( 0.00%: 0) ov_raw_tell
0001c768 ( 0.00%: 0) ov_pcm_tell
0001c78c ( 0.00%: 0) ov_time_tell
0001c8a8 ( 0.00%: 0) ov_info
0001c8ec ( 0.02%: 1) ov_comment
0001c930 ( 0.02%: 1) ov_read
0001ca10 ( 0.00%: 0) stmiaTest
0001ca74 ( 0.00%: 0) strTest
0001caf4 ( 0.00%: 0) smullTest
0001cb38 ( 0.00%: 0) __udivdi3
0001d0a8 ( 0.00%: 0) __aeabi_drsub
0001d0b0 ( 0.00%: 0) __aeabi_dsub
0001d0b0 ( 0.00%: 0) __subdf3
0001d0b4 ( 0.00%: 0) __adddf3
0001d0b4 ( 0.00%: 0) __aeabi_dadd
0001d394 ( 0.00%: 0) __aeabi_ui2d
0001d394 ( 0.00%: 0) __floatunsidf
0001d3b8 ( 0.00%: 0) __floatsidf
0001d3b8 ( 0.00%: 0) __aeabi_i2d
0001d3e0 ( 0.00%: 0) __extendsfdf2
0001d3e0 ( 0.00%: 0) __aeabi_f2d
0001d420 ( 0.00%: 0) __aeabi_ul2d
0001d420 ( 0.00%: 0) __floatundidf
0001d434 ( 0.00%: 0) __floatdidf
0001d434 ( 0.00%: 0) __aeabi_l2d
0001d494 ( 0.00%: 0) __aeabi_dmul
0001d494 ( 0.00%: 0) __muldf3
0001d7bc ( 0.00%: 0) __aeabi_ddiv
0001d7bc ( 0.00%: 0) __divdf3
0001d9c0 ( 0.06%: 3) __modsi3
0001daa4 ( 0.28%: 14) __divsi3
0001dbcc ( 0.00%: 0) __aeabi_idivmod
0001dbe4 ( 0.14%: 7) __udivsi3
0001dcdc ( 0.00%: 0) __aeabi_uidivmod
0001dcf4 ( 0.00%: 0) __divdi3
0001e2b0 ( 0.00%: 0) __umodsi3
0001e37c ( 0.00%: 0) __aeabi_ldiv0
0001e37c ( 0.00%: 0) __div0
0001e37c ( 0.00%: 0) __aeabi_idiv0
0001e380 ( 0.00%: 0) _XcptFilter
0001e38c ( 0.00%: 0) __C_specific_handler
0001e398 ( 0.00%: 0) LocalFree
0001e3a4 ( 0.00%: 0) vsprintf
0001e3b0 ( 0.00%: 0) OutputDebugStringW
0001e3bc ( 0.39%: 20) fopen
0001e3c8 ( 0.00%: 0) fwrite
0001e3d4 ( 0.00%: 0) fread
0001e3e0 ( 0.00%: 0) GetThreadTimes
0001e3ec ( 0.00%: 0) Sleep
0001e3f8 ( 0.04%: 2) fputc
0001e404 ( 0.00%: 0) fclose
0001e410 ( 0.00%: 0) memset
0001e41c ( 0.00%: 0) GetThreadContext
0001e428 ( 0.00%: 0) malloc
0001e434 ( 0.00%: 0) CreateThread
0001e440 ( 0.00%: 0) SetThreadPriority
0001e44c ( 0.00%: 0) free
0001e458 ( 0.00%: 0) calloc
0001e464 ( 0.00%: 0) realloc
0001e470 ( 0.00%: 0) memchr
0001e47c ( 0.00%: 0) toupper
0001e488 ( 0.00%: 0) strlen
0001e494 ( 0.00%: 0) strcpy
0001e4a0 ( 0.00%: 0) memcmp
0001e4ac ( 0.00%: 0) _getstdfilex
0001e4b8 ( 0.00%: 0) fprintf
0001e4c4 ( 0.00%: 0) fseek
0001e4d0 ( 0.00%: 0) memcpy
0001e4dc ( 0.00%: 0) ftell
0001f018 ( 0.00%: 0) crc_lookup
0001f418 ( 0.00%: 0) start_time
00028764 ( 0.00%: 0) FLOOR_fromdB_LOOKUP
00028b88 ( 0.00%: 0) sincos_lookup0
00029b90 ( 0.00%: 0) sincos_lookup1
0002ada4 ( 0.00%: 0) __clz_tab
0002d014 ( 0.00%: 0) global_bytes
0002d030 ( 0.00%: 0) __onexitbegin
0002d034 ( 0.00%: 0) __onexitend
0002d038 ( 0.00%: 0) _exitflag
0002d03c ( 0.00%: 0) pcmout
0002e03c ( 0.00%: 0) ref
0002f03c ( 0.00%: 0) text
0003003c ( 0.00%: 0) speedblock
00039000 ( 0.00%: 0) __IMPORT_DESCRIPTOR_COREDLL
00039014 ( 0.00%: 0) __NULL_IMPORT_DESCRIPTOR
000390b8 ( 0.00%: 0) __imp__XcptFilter
000390bc ( 0.00%: 0) __imp___C_specific_handler
000390c0 ( 0.00%: 0) __imp_LocalFree
000390c4 ( 0.00%: 0) __imp_vsprintf
000390c8 ( 0.00%: 0) __imp_OutputDebugStringW
000390cc ( 0.00%: 0) __imp_fopen
000390d0 ( 0.00%: 0) __imp_fwrite
000390d4 ( 0.00%: 0) __imp_fread
000390d8 ( 0.00%: 0) __imp_GetThreadTimes
000390dc ( 0.00%: 0) __imp_Sleep
000390e0 ( 0.00%: 0) __imp_fputc
000390e4 ( 0.00%: 0) __imp_fclose
000390e8 ( 0.00%: 0) __imp_memset
000390ec ( 0.00%: 0) __imp_GetThreadContext
000390f0 ( 0.00%: 0) __imp_malloc
000390f4 ( 0.00%: 0) __imp_CreateThread
000390f8 ( 0.00%: 0) __imp_SetThreadPriority
000390fc ( 0.00%: 0) __imp_free
00039100 ( 0.00%: 0) __imp_calloc
00039104 ( 0.00%: 0) __imp_realloc
00039108 ( 0.00%: 0) __imp_memchr
0003910c ( 0.00%: 0) __imp_toupper
00039110 ( 0.00%: 0) __imp_strlen
00039114 ( 0.00%: 0) __imp_strcpy
00039118 ( 0.00%: 0) __imp_memcmp
0003911c ( 0.00%: 0) __imp__getstdfilex
00039120 ( 0.00%: 0) __imp_fprintf
00039124 ( 0.00%: 0) __imp_fseek
00039128 ( 0.00%: 0) __imp_memcpy
0003912c ( 0.00%: 0) __imp_ftell
0003a000 ( 0.00%: 0) __xc_a
0003a004 ( 0.00%: 0) __xc_z
0003a008 ( 0.00%: 0) __xi_a
0003a00c ( 0.00%: 0) __xi_z
0003a010 ( 0.00%: 0) __xp_a
0003a014 ( 0.00%: 0) __xp_z
0003a018 ( 0.00%: 0) __xt_a
0003a01c ( 0.00%: 0) __xt_z
Profile by Time
00000000 ( 42.09%: 2139) Address 0
00018470 ( 12.20%: 620) mdct_backwardARM
00013264 ( 9.41%: 478) decode_packed_entry_number
0001341c ( 5.51%: 280) decode_map
000135bc ( 5.31%: 270) vorbis_book_decodevv_add
0001364c ( 3.31%: 168) _checksum
00013238 ( 2.77%: 141) decode_packed_entry_number_REALSTART
00018364 ( 2.74%: 139) mdct_unroll_part2
00011ae0 ( 2.48%: 126) oggpack_look
000183bc ( 1.79%: 91) mdct_unroll_part3
000191fc ( 1.77%: 90) res_inverse
00015698 ( 1.40%: 71) ogg_buffer_dup
00015308 ( 1.20%: 61) floor1_inverse2
00011aa4 ( 1.10%: 56) oggpack_bits
000154c4 ( 0.91%: 46) render_lineARM
0001501c ( 0.85%: 43) floor1_inverse1
00017888 ( 0.77%: 39) mapping_inverse
00018414 ( 0.67%: 34) mdct_shift_right
00011984 ( 0.65%: 33) Profile_init
0001e3bc ( 0.39%: 20) fopen
000127e8 ( 0.33%: 17) vorbis_book_unpack
00016050 ( 0.33%: 17) ogg_sync_pageseek
0001daa4 ( 0.28%: 14) __divsi3
00015ef8 ( 0.22%: 11) ogg_sync_bufferin
00015fb4 ( 0.16%: 8) ogg_sync_wrote
0001dbe4 ( 0.14%: 7) __udivsi3
00014fc8 ( 0.12%: 6) render_point
00014938 ( 0.12%: 6) floor1_info_unpack
00016588 ( 0.12%: 6) ogg_packet_release
00018200 ( 0.10%: 5) mdct_unroll_prelap
000182a0 ( 0.08%: 4) mdct_unroll_postlap
00015c70 ( 0.08%: 4) ogg_page_granulepos
00016410 ( 0.08%: 4) ogg_stream_pagein
00015d38 ( 0.06%: 3) ogg_page_serialno
0001d9c0 ( 0.06%: 3) __modsi3
00013918 ( 0.06%: 3) vorbis_dsp_pcmout
00015c30 ( 0.04%: 2) ogg_page_eos
00011cc4 ( 0.04%: 2) oggpack_read
00015b70 ( 0.04%: 2) ogg_page_version
00013b04 ( 0.04%: 2) vorbis_dsp_synthesis
0001e3f8 ( 0.04%: 2) fputc
00016370 ( 0.04%: 2) ogg_stream_destroy
00016010 ( 0.02%: 1) ogg_page_release
00015ea0 ( 0.02%: 1) ogg_sync_destroy
00011c04 ( 0.02%: 1) oggpack_adv
0001c8ec ( 0.02%: 1) ov_comment
0001c930 ( 0.02%: 1) ov_read
000137c8 ( 0.02%: 1) vorbis_dsp_destroy
00012728 ( 0.02%: 1) _book_maptype1_quantvals
00015bb0 ( 0.00%: 0) ogg_page_continued
00015bf0 ( 0.00%: 0) ogg_page_bos
0003a018 ( 0.00%: 0) __xt_a
00015d78 ( 0.00%: 0) ogg_page_pageno
00015db8 ( 0.00%: 0) ogg_page_packets
00015e1c ( 0.00%: 0) ogg_sync_create
00015e70 ( 0.00%: 0) ogg_sync_reset
00011c8c ( 0.00%: 0) oggpack_readinit
00011a74 ( 0.00%: 0) oggpack_bytes
00016304 ( 0.00%: 0) ogg_sync_pageout
0001634c ( 0.00%: 0) ogg_stream_create
0003a01c ( 0.00%: 0) __xt_z
000164f8 ( 0.00%: 0) ogg_stream_reset
0001656c ( 0.00%: 0) ogg_stream_reset_serialno
00011a60 ( 0.00%: 0) oggpack_eop
00016a8c ( 0.00%: 0) ogg_stream_packetout
00016a94 ( 0.00%: 0) ogg_stream_packetpeek
00016a9c ( 0.00%: 0) ogg_page_dup
00016b0c ( 0.00%: 0) vorbis_comment_init
00016b80 ( 0.00%: 0) vorbis_comment_query
00016c54 ( 0.00%: 0) vorbis_comment_query_count
00016d04 ( 0.00%: 0) vorbis_comment_clear
00016d90 ( 0.00%: 0) vorbis_info_blocksize
00016da4 ( 0.00%: 0) vorbis_info_init
00016dec ( 0.00%: 0) vorbis_info_clear
00016f9c ( 0.00%: 0) vorbis_dsp_headerin
000175b8 ( 0.00%: 0) mapping_clear_info
00017634 ( 0.00%: 0) mapping_info_unpack
000117d4 ( 0.00%: 0) Profile_dump
00017d28 ( 0.00%: 0) mdct_unroll_lap
00017fa4 ( 0.00%: 0) mdct_backward
00011610 ( 0.00%: 0) speedtest
000115d4 ( 0.00%: 0) WinMain
000112b0 ( 0.00%: 0) main2
000111e4 ( 0.00%: 0) Output
000111d4 ( 0.00%: 0) _c_exit
000111c4 ( 0.00%: 0) _cexit
00018dc0 ( 0.00%: 0) _VDBG_dump
00018e24 ( 0.00%: 0) _VDBG_malloc
00018f70 ( 0.00%: 0) _VDBG_free
00018f98 ( 0.00%: 0) res_clear_info
00018fe8 ( 0.00%: 0) res_unpack
000111b8 ( 0.00%: 0) _exit
0001a6f8 ( 0.00%: 0) ov_clear
0001a89c ( 0.00%: 0) ov_test_callbacks
0001a8dc ( 0.00%: 0) ov_test
0001a928 ( 0.00%: 0) ov_streams
0001a930 ( 0.00%: 0) ov_seekable
0001a938 ( 0.00%: 0) ov_time_total
0001a9fc ( 0.00%: 0) ov_bitrate
0001ab84 ( 0.00%: 0) ov_bitrate_instant
0001ac00 ( 0.00%: 0) ov_serialnumber
0001ac78 ( 0.00%: 0) ov_raw_total
0001ad28 ( 0.00%: 0) ov_pcm_total
0001adcc ( 0.00%: 0) ov_raw_seek
0001b6bc ( 0.00%: 0) ov_test_open
0001b6d4 ( 0.00%: 0) ov_open_callbacks
0001b72c ( 0.00%: 0) ov_open
0001b778 ( 0.00%: 0) ov_pcm_seek_page
0001c020 ( 0.00%: 0) ov_pcm_seek
0001c444 ( 0.00%: 0) ov_time_seek
0001c5c4 ( 0.00%: 0) ov_time_seek_page
0001c744 ( 0.00%: 0) ov_raw_tell
0001c768 ( 0.00%: 0) ov_pcm_tell
0001c78c ( 0.00%: 0) ov_time_tell
0001c8a8 ( 0.00%: 0) ov_info
0001ca10 ( 0.00%: 0) stmiaTest
0001ca74 ( 0.00%: 0) strTest
0001caf4 ( 0.00%: 0) smullTest
0001cb38 ( 0.00%: 0) __udivdi3
0001d0a8 ( 0.00%: 0) __aeabi_drsub
0001d0b0 ( 0.00%: 0) __aeabi_dsub
0001d0b0 ( 0.00%: 0) __subdf3
0001d0b4 ( 0.00%: 0) __adddf3
0001d0b4 ( 0.00%: 0) __aeabi_dadd
0001d394 ( 0.00%: 0) __aeabi_ui2d
0001d394 ( 0.00%: 0) __floatunsidf
0001d3b8 ( 0.00%: 0) __floatsidf
0001d3b8 ( 0.00%: 0) __aeabi_i2d
0001d3e0 ( 0.00%: 0) __extendsfdf2
0001d3e0 ( 0.00%: 0) __aeabi_f2d
0001d420 ( 0.00%: 0) __aeabi_ul2d
0001d420 ( 0.00%: 0) __floatundidf
0001d434 ( 0.00%: 0) __floatdidf
0001d434 ( 0.00%: 0) __aeabi_l2d
0001d494 ( 0.00%: 0) __aeabi_dmul
0001d494 ( 0.00%: 0) __muldf3
0001d7bc ( 0.00%: 0) __aeabi_ddiv
0001d7bc ( 0.00%: 0) __divdf3
000110d8 ( 0.00%: 0) exit
0001dbcc ( 0.00%: 0) __aeabi_idivmod
00011078 ( 0.00%: 0) _cinit
0001dcdc ( 0.00%: 0) __aeabi_uidivmod
0001dcf4 ( 0.00%: 0) __divdi3
0001e2b0 ( 0.00%: 0) __umodsi3
0001e37c ( 0.00%: 0) __aeabi_ldiv0
0001e37c ( 0.00%: 0) __div0
0001e37c ( 0.00%: 0) __aeabi_idiv0
0001e380 ( 0.00%: 0) _XcptFilter
0001e38c ( 0.00%: 0) __C_specific_handler
0001e398 ( 0.00%: 0) LocalFree
0001e3a4 ( 0.00%: 0) vsprintf
0001e3b0 ( 0.00%: 0) OutputDebugStringW
00011008 ( 0.00%: 0) WinMainCRTStartup
0001e3c8 ( 0.00%: 0) fwrite
0001e3d4 ( 0.00%: 0) fread
0001e3e0 ( 0.00%: 0) GetThreadTimes
0001e3ec ( 0.00%: 0) Sleep
0001e404 ( 0.00%: 0) fclose
0001e410 ( 0.00%: 0) memset
0001e41c ( 0.00%: 0) GetThreadContext
0001e428 ( 0.00%: 0) malloc
0001e434 ( 0.00%: 0) CreateThread
0001e440 ( 0.00%: 0) SetThreadPriority
0001e44c ( 0.00%: 0) free
0001e458 ( 0.00%: 0) calloc
0001e464 ( 0.00%: 0) realloc
0001e470 ( 0.00%: 0) memchr
0001e47c ( 0.00%: 0) toupper
0001e488 ( 0.00%: 0) strlen
0001e494 ( 0.00%: 0) strcpy
0001e4a0 ( 0.00%: 0) memcmp
0001e4ac ( 0.00%: 0) _getstdfilex
0001e4b8 ( 0.00%: 0) fprintf
0001e4c4 ( 0.00%: 0) fseek
0001e4d0 ( 0.00%: 0) memcpy
0001e4dc ( 0.00%: 0) ftell
0001f018 ( 0.00%: 0) crc_lookup
0001f418 ( 0.00%: 0) start_time
00028764 ( 0.00%: 0) FLOOR_fromdB_LOOKUP
00028b88 ( 0.00%: 0) sincos_lookup0
00029b90 ( 0.00%: 0) sincos_lookup1
0002ada4 ( 0.00%: 0) __clz_tab
0002d014 ( 0.00%: 0) global_bytes
0002d030 ( 0.00%: 0) __onexitbegin
0002d034 ( 0.00%: 0) __onexitend
0002d038 ( 0.00%: 0) _exitflag
0002d03c ( 0.00%: 0) pcmout
0002e03c ( 0.00%: 0) ref
0002f03c ( 0.00%: 0) text
0003003c ( 0.00%: 0) speedblock
00039000 ( 0.00%: 0) __IMPORT_DESCRIPTOR_COREDLL
00039014 ( 0.00%: 0) __NULL_IMPORT_DESCRIPTOR
000390b8 ( 0.00%: 0) __imp__XcptFilter
000390bc ( 0.00%: 0) __imp___C_specific_handler
000390c0 ( 0.00%: 0) __imp_LocalFree
000390c4 ( 0.00%: 0) __imp_vsprintf
000390c8 ( 0.00%: 0) __imp_OutputDebugStringW
000390cc ( 0.00%: 0) __imp_fopen
000390d0 ( 0.00%: 0) __imp_fwrite
000390d4 ( 0.00%: 0) __imp_fread
000390d8 ( 0.00%: 0) __imp_GetThreadTimes
000390dc ( 0.00%: 0) __imp_Sleep
000390e0 ( 0.00%: 0) __imp_fputc
000390e4 ( 0.00%: 0) __imp_fclose
000390e8 ( 0.00%: 0) __imp_memset
000390ec ( 0.00%: 0) __imp_GetThreadContext
000390f0 ( 0.00%: 0) __imp_malloc
000390f4 ( 0.00%: 0) __imp_CreateThread
000390f8 ( 0.00%: 0) __imp_SetThreadPriority
000390fc ( 0.00%: 0) __imp_free
00039100 ( 0.00%: 0) __imp_calloc
00039104 ( 0.00%: 0) __imp_realloc
00039108 ( 0.00%: 0) __imp_memchr
0003910c ( 0.00%: 0) __imp_toupper
00039110 ( 0.00%: 0) __imp_strlen
00039114 ( 0.00%: 0) __imp_strcpy
00039118 ( 0.00%: 0) __imp_memcmp
0003911c ( 0.00%: 0) __imp__getstdfilex
00039120 ( 0.00%: 0) __imp_fprintf
00039124 ( 0.00%: 0) __imp_fseek
00039128 ( 0.00%: 0) __imp_memcpy
0003912c ( 0.00%: 0) __imp_ftell
0003a000 ( 0.00%: 0) __xc_a
0003a004 ( 0.00%: 0) __xc_z
0003a008 ( 0.00%: 0) __xi_a
0003a00c ( 0.00%: 0) __xi_z
0003a010 ( 0.00%: 0) __xp_a
0003a014 ( 0.00%: 0) __xp_z
00013160 ( 0.00%: 0) vorbis_book_decodev_set
000136ac ( 0.00%: 0) vorbis_dsp_restart
000130c8 ( 0.00%: 0) vorbis_book_decodev_add
00013714 ( 0.00%: 0) vorbis_dsp_create
00013a44 ( 0.00%: 0) vorbis_dsp_read
00013a84 ( 0.00%: 0) vorbis_packet_blocksize
00013f04 ( 0.00%: 0) floor0_free_info
00013f10 ( 0.00%: 0) floor0_info_unpack
00014020 ( 0.00%: 0) floor0_memosize
0001402c ( 0.00%: 0) floor0_inverse1
00014188 ( 0.00%: 0) vorbis_lsp_to_curve
000147ec ( 0.00%: 0) floor0_inverse2
00014880 ( 0.00%: 0) floor1_free_info
00013020 ( 0.00%: 0) vorbis_book_decodevs_add
00013008 ( 0.00%: 0) vorbis_book_decode
00015014 ( 0.00%: 0) floor1_memosize
000127a8 ( 0.00%: 0) vorbis_book_clear
00011e58 ( 0.00%: 0) _ilog

View File

@@ -0,0 +1,64 @@
This README covers the Tremolo library, version 0.08.
Tremolo is a modified version of the Ogg Vorbis 'Tremor' integer
playback codec, branching from 1.0.2 of the low memory branch of
that source from svn.
Previous versions of Tremolo have been released under the GNU GPL
but thanks to a grant from Google, this version is back to being
released under the same license as vanilla Tremor.
Robin Watts
tremolo@wss.co.uk
----------------------------------------------------------------------
This README covers the Ogg Vorbis 'Tremor' integer playback codec
source as of date 2002 09 02, version 1.0.0.
******
The C source in this package will build on any ANSI C compiler and
function completely and properly on any platform. The included build
system assumes GNU build system and make tools (m4, automake,
autoconf, libtool and gmake). GCC is not required, although GCC is
the most tested compiler. To build using GNU tools, type in the
source directory:
./autogen.sh
make
Currently, the source implements playback in pure C on all platforms
except ARM, where a [currently] small amount of assembly (see
asm_arm.h) is used to implement 64 bit math operations and fast LSP
computation. If building on ARM without the benefit of GNU build
system tools, be sure that '_ARM_ASSEM_' is #defined by the build
system if this assembly is desired, else the resulting library will
use whatever 64 bit math builtins the compiler implements.
No math library is required by this source. No floating point
operations are used at any point in either setup or decode. This
decoder library will properly decode any past, current or future
Vorbis I file or stream.
********
The build system produces a static and [when supported by the OS]
dynamic library named 'libvorbisidec'. This library exposes an API
nearly identical to the BSD reference library's 'libvorbisfile',
including all the features familiar to users of vorbisfile. This API
is similar enough that the proper header file to include is named
'ivorbisfile.h' [included in the source build directory]. Lower level
libvorbis-style headers and structures are in 'ivorbiscodec.h'
[included in the source build directory]. A simple example program,
ivorbisfile_example.c, can be built with 'make example'.
********
Detailed Tremor API Documentation begins at doc/index.html
Monty
xiph.org

View File

@@ -0,0 +1,2 @@
Add explicit 64 bit integer support rather than relying on compiler
Roll in optional use of bounded heap memory manager

View File

@@ -0,0 +1,300 @@
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char *name;
int offset;
int count;
float percent;
}
Profile_Entry;
static const char *profile_filename;
static const char *map_filename;
static int granularity;
static int *profile;
static int profile_len;
static Profile_Entry *functionTable;
static int numFunctions;
static int maxFunctions;
static void read_args(int argc, const char *argv[])
{
if (argc < 3)
{
fprintf(stderr, "annotate <profile file> <map file>\n");
fclose(stderr);
exit(EXIT_FAILURE);
}
profile_filename = argv[1];
map_filename = argv[2];
}
static void read_profile()
{
FILE *in = fopen(profile_filename, "rb");
if (in == NULL)
{
fprintf(stderr, "Failed to open profile file '%s'\n",
profile_filename);
fclose(stderr);
exit(EXIT_FAILURE);
}
fseek(in, 0, SEEK_END);
profile_len = (int)ftell(in)-8;
fseek(in, 0, SEEK_SET);
if ((fgetc(in) != 'P') ||
(fgetc(in) != 'R') ||
(fgetc(in) != '0') ||
(fgetc(in) != 'F'))
{
fclose(in);
fprintf(stderr, "'%s' is not a profile file\n",
profile_filename);
fclose(stderr);
exit(EXIT_FAILURE);
}
fread(&granularity, 4, 1, in);
profile = malloc(profile_len);
if (profile == NULL)
{
fclose(in);
fprintf(stderr, "Out of memory reading profile\n");
fclose(stderr);
exit(EXIT_FAILURE);
}
fread(profile, 4, profile_len>>2, in);
fclose(in);
}
static void addFn(const char *text, int offset)
{
if (numFunctions == maxFunctions)
{
int newSize = maxFunctions*2;
if (newSize == 0)
newSize = 128;
functionTable = realloc(functionTable,
newSize*sizeof(Profile_Entry));
if (functionTable == NULL)
{
fprintf(stderr, "Out of memory reading mapfile\n");
fflush(stderr);
exit(EXIT_FAILURE);
}
maxFunctions = newSize;
}
functionTable[numFunctions].name = malloc(strlen(text)+1);
strcpy(functionTable[numFunctions].name, text);
functionTable[numFunctions].offset = offset;
functionTable[numFunctions].count = 0;
functionTable[numFunctions].percent = 0.0;
//fprintf(stdout, "%s %x\n", functionTable[numFunctions].name,
// functionTable[numFunctions].offset);
numFunctions++;
}
static void read_map()
{
FILE *in = fopen(map_filename, "rb");
char text[2048];
if (in == NULL)
{
fprintf(stderr, "Failed to open map file '%s'\n",
map_filename);
fclose(stderr);
exit(EXIT_FAILURE);
}
functionTable = NULL;
numFunctions = 0;
maxFunctions = 0;
addFn("Address 0", 0);
while (!feof(in))
{
int offset;
char c;
char *t;
/* Skip over any whitespace */
do
{
c = fgetc(in);
}
while (((c == 32) || (c == 9)) && (!feof(in)));
ungetc(c, in);
/* Try to read an offset */
if (fscanf(in, "0x%x", &offset) != 1)
{
goto over;
}
/* Skip over any whitespace */
do
{
c = fgetc(in);
}
while ((c == 32) && (!feof(in)));
ungetc(c, in);
/* Names never start with . or (*/
if ((c != '_') &&
((c < 'a') || (c > 'z')) &&
((c < 'A') || (c > 'Z')))
goto over;
/* Read the name */
t = text;
do
{
c = fgetc(in);
*t++ = c;
}
while (c > 32);
t[-1] = 0;
/* Now there should be nothing left on this line */
if ((c != 10) && (c != 13))
goto over;
/* And put the return back */
ungetc(c, in);
if (t != text)
{
addFn(text, offset);
}
over:
/* Skip to the end of the line */
do
{
c = fgetc(in);
}
while ((c >= 32) && (!feof(in)));
/* Skip over any newlines */
while (((c == 10) || (c == 13)) && (!feof(in)))
{
c = fgetc(in);
}
/* And put the first non whitespace/non return char back */
ungetc(c, in);
}
fclose(in);
}
static void show_profile()
{
int i;
for (i=0; i < numFunctions; i++)
{
fprintf(stdout, "%08x (%6.2f%%: %6d) %s\n",
functionTable[i].offset,
functionTable[i].percent,
functionTable[i].count,
functionTable[i].name);
}
}
int byAddress(const void *_e1, const void *_e2)
{
const Profile_Entry *e1 = (const Profile_Entry *)_e1;
const Profile_Entry *e2 = (const Profile_Entry *)_e2;
return e1->offset - e2->offset;
}
int byTime(const void *_e1, const void *_e2)
{
const Profile_Entry *e1 = (const Profile_Entry *)_e1;
const Profile_Entry *e2 = (const Profile_Entry *)_e2;
return e2->count - e1->count;
}
static void process_profile()
{
int next;
int fn;
int idx;
int max;
int total;
/* Sort into address order */
qsort(functionTable,
numFunctions,
sizeof(Profile_Entry),
byAddress);
/* Run through the profile adding it to the appropriate function */
fn = -1; /* Which function are we looking at */
next = -1; /* At what address should we move to the next function */
idx = 0; /* Where are we in the profile */
max = profile_len>>2;
total = 0;
for (idx = 0; idx < max; idx++)
{
while ((idx<<(granularity+2)) >= next)
{
/* Move to the next function */
fn++;
//fprintf(stdout, "Will be on fn %s until we pass %x\n",
// functionTable[fn].name, functionTable[fn+1].offset);
next = 0x7FFFFFFF;
if (fn+1 < numFunctions)
{
next = functionTable[fn+1].offset;
}
}
//fprintf(stdout, "fn=%d count=%d idx=%d next=%x\n",
// fn, functionTable[fn].count, idx, next);
functionTable[fn].count += profile[idx];
total += profile[idx];
}
for (fn = 0; fn < numFunctions; fn++)
{
functionTable[fn].percent = 100.0*functionTable[fn].count/total;
}
fprintf(stdout, "Profile by Address\n");
show_profile();
/* Sort into time order */
qsort(functionTable,
numFunctions,
sizeof(Profile_Entry),
byTime);
fprintf(stdout, "\n\n");
fprintf(stdout, "Profile by Time\n");
show_profile();
}
int main(int argc, const char *argv[])
{
read_args(argc, argv);
read_profile();
read_map();
process_profile();
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,245 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: arm7 and later wide math functions
********************************************************************/
#ifdef _ARM_ASSEM_
#if !defined(_V_WIDE_MATH) && !defined(_LOW_ACCURACY_)
#define _V_WIDE_MATH
static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
int lo,hi;
asm volatile("smull\t%0, %1, %2, %3"
: "=&r"(lo),"=&r"(hi)
: "%r"(x),"r"(y)
: "cc");
return(hi);
}
static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return MULT32(x,y)<<1;
}
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
int lo,hi;
asm volatile("smull %0, %1, %2, %3\n\t"
"movs %0, %0, lsr #15\n\t"
"adc %1, %0, %1, lsl #17\n\t"
: "=&r"(lo),"=&r"(hi)
: "%r"(x),"r"(y)
: "cc");
return(hi);
}
#define MB() asm volatile ("" : : : "memory")
static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
int x1, y1, l;
asm( "smull %0, %1, %4, %6\n\t"
"smlal %0, %1, %5, %7\n\t"
"rsb %3, %4, #0\n\t"
"smull %0, %2, %5, %6\n\t"
"smlal %0, %2, %3, %7"
: "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a)
: "3" (a), "r" (b), "r" (t), "r" (v)
: "cc" );
*x = x1;
MB();
*y = y1;
}
/* x = (a*t + b*v)>>31, y = (b*t - a*v)>>31 */
static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
int x1, y1, l;
asm( "smull %0, %1, %4, %6\n\t"
"smlal %0, %1, %5, %7\n\t"
"rsb %3, %4, #0\n\t"
"smull %0, %2, %5, %6\n\t"
"smlal %0, %2, %3, %7"
: "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a)
: "3" (a), "r" (b), "r" (t), "r" (v)
: "cc" );
*x = x1 << 1;
MB();
*y = y1 << 1;
}
/* x = (a*t - b*v)>>31, y = (b*t + a*v)>>31 */
static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
int x1, y1, l;
asm( "rsb %2, %4, #0\n\t"
"smull %0, %1, %3, %5\n\t"
"smlal %0, %1, %2, %6\n\t"
"smull %0, %2, %4, %5\n\t"
"smlal %0, %2, %3, %6"
: "=&r" (l), "=&r" (x1), "=&r" (y1)
: "r" (a), "r" (b), "r" (t), "r" (v)
: "cc" );
*x = x1 << 1;
MB();
*y = y1 << 1;
}
#endif
#ifndef _V_CLIP_MATH
#define _V_CLIP_MATH
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int tmp;
asm volatile("subs %1, %0, #32768\n\t"
"movpl %0, #0x7f00\n\t"
"orrpl %0, %0, #0xff\n"
"adds %1, %0, #32768\n\t"
"movmi %0, #0x8000"
: "+r"(x),"=r"(tmp)
:
: "cc");
return(x);
}
#endif
#ifndef _V_LSP_MATH_ASM
#define _V_LSP_MATH_ASM
static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
ogg_int32_t *qexpp,
ogg_int32_t *ilsp,ogg_int32_t wi,
ogg_int32_t m){
ogg_uint32_t qi=*qip,pi=*pip;
ogg_int32_t qexp=*qexpp;
asm("mov r0,%3;"
"mov r1,%5,asr#1;"
"add r0,r0,r1,lsl#3;"
"1:"
"ldmdb r0!,{r1,r3};"
"subs r1,r1,%4;" //ilsp[j]-wi
"rsbmi r1,r1,#0;" //labs(ilsp[j]-wi)
"umull %0,r2,r1,%0;" //qi*=labs(ilsp[j]-wi)
"subs r1,r3,%4;" //ilsp[j+1]-wi
"rsbmi r1,r1,#0;" //labs(ilsp[j+1]-wi)
"umull %1,r3,r1,%1;" //pi*=labs(ilsp[j+1]-wi)
"cmn r2,r3;" // shift down 16?
"beq 0f;"
"add %2,%2,#16;"
"mov %0,%0,lsr #16;"
"orr %0,%0,r2,lsl #16;"
"mov %1,%1,lsr #16;"
"orr %1,%1,r3,lsl #16;"
"0:"
"cmp r0,%3;\n"
"bhi 1b;\n"
// odd filter assymetry
"ands r0,%5,#1;\n"
"beq 2f;\n"
"add r0,%3,%5,lsl#2;\n"
"ldr r1,[r0,#-4];\n"
"mov r0,#0x4000;\n"
"subs r1,r1,%4;\n" //ilsp[j]-wi
"rsbmi r1,r1,#0;\n" //labs(ilsp[j]-wi)
"umull %0,r2,r1,%0;\n" //qi*=labs(ilsp[j]-wi)
"umull %1,r3,r0,%1;\n" //pi*=labs(ilsp[j+1]-wi)
"cmn r2,r3;\n" // shift down 16?
"beq 2f;\n"
"add %2,%2,#16;\n"
"mov %0,%0,lsr #16;\n"
"orr %0,%0,r2,lsl #16;\n"
"mov %1,%1,lsr #16;\n"
"orr %1,%1,r3,lsl #16;\n"
//qi=(pi>>shift)*labs(ilsp[j]-wi);
//pi=(qi>>shift)*labs(ilsp[j+1]-wi);
//qexp+=shift;
//}
/* normalize to max 16 sig figs */
"2:"
"mov r2,#0;"
"orr r1,%0,%1;"
"tst r1,#0xff000000;"
"addne r2,r2,#8;"
"movne r1,r1,lsr #8;"
"tst r1,#0x00f00000;"
"addne r2,r2,#4;"
"movne r1,r1,lsr #4;"
"tst r1,#0x000c0000;"
"addne r2,r2,#2;"
"movne r1,r1,lsr #2;"
"tst r1,#0x00020000;"
"addne r2,r2,#1;"
"movne r1,r1,lsr #1;"
"tst r1,#0x00010000;"
"addne r2,r2,#1;"
"mov %0,%0,lsr r2;"
"mov %1,%1,lsr r2;"
"add %2,%2,r2;"
: "+r"(qi),"+r"(pi),"+r"(qexp)
: "r"(ilsp),"r"(wi),"r"(m)
: "r0","r1","r2","r3","cc");
*qip=qi;
*pip=pi;
*qexpp=qexp;
}
static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){
ogg_uint32_t qi=*qip;
ogg_int32_t qexp=*qexpp;
asm("tst %0,#0x0000ff00;"
"moveq %0,%0,lsl #8;"
"subeq %1,%1,#8;"
"tst %0,#0x0000f000;"
"moveq %0,%0,lsl #4;"
"subeq %1,%1,#4;"
"tst %0,#0x0000c000;"
"moveq %0,%0,lsl #2;"
"subeq %1,%1,#2;"
"tst %0,#0x00008000;"
"moveq %0,%0,lsl #1;"
"subeq %1,%1,#1;"
: "+r"(qi),"+r"(qexp)
:
: "cc");
*qip=qi;
*qexpp=qexp;
}
#endif
#endif

View File

@@ -0,0 +1,486 @@
Profile by Address
00000000 ( 40.06%: 2115) Address 0
00011008 ( 0.00%: 0) WinMainCRTStartup
00011078 ( 0.00%: 0) _cinit
000110d8 ( 0.00%: 0) exit
000111b8 ( 0.00%: 0) _exit
000111c4 ( 0.00%: 0) _cexit
000111d4 ( 0.00%: 0) _c_exit
000111e4 ( 0.00%: 0) Output
000112b0 ( 0.00%: 0) main2
000115c8 ( 0.00%: 0) WinMain
00011604 ( 0.00%: 0) speedtest
000117c8 ( 0.00%: 0) Profile_dump
00011978 ( 0.42%: 22) Profile_init
00011a54 ( 0.00%: 0) oggpack_eop
00011a68 ( 0.00%: 0) oggpack_bytes
00011a98 ( 1.84%: 97) oggpack_bits
00011ad4 ( 1.55%: 82) oggpack_look
00011bf8 ( 0.97%: 51) oggpack_adv
00011c80 ( 0.00%: 0) oggpack_readinit
00011cb8 ( 0.02%: 1) oggpack_read
00011e4c ( 0.02%: 1) _ilog
0001271c ( 0.02%: 1) _book_maptype1_quantvals
0001279c ( 0.00%: 0) vorbis_book_clear
000127d0 ( 1.08%: 57) vorbis_book_unpack
00012fd8 ( 0.00%: 0) vorbis_book_decode
00012ff0 ( 7.61%: 402) decode_map
00013230 ( 0.00%: 0) vorbis_book_decodevs_add
000132f8 ( 0.00%: 0) vorbis_book_decodev_add
000133b0 ( 0.32%: 17) vorbis_book_decodev_set
000134a4 ( 4.30%: 227) vorbis_book_decodevv_add
00013578 ( 0.00%: 0) vorbis_dsp_restart
000135e0 ( 0.00%: 0) vorbis_dsp_create
00013694 ( 0.04%: 2) vorbis_dsp_destroy
000137e4 ( 0.04%: 2) vorbis_dsp_pcmout
00013910 ( 0.00%: 0) vorbis_dsp_read
00013950 ( 0.00%: 0) vorbis_packet_blocksize
000139d0 ( 0.02%: 1) vorbis_dsp_synthesis
00013dd0 ( 0.00%: 0) floor0_free_info
00013ddc ( 0.00%: 0) floor0_info_unpack
00013eec ( 0.00%: 0) floor0_memosize
00013ef8 ( 0.00%: 0) floor0_inverse1
00014054 ( 0.00%: 0) vorbis_lsp_to_curve
000146b8 ( 0.00%: 0) floor0_inverse2
0001474c ( 0.04%: 2) floor1_free_info
00014804 ( 0.04%: 2) floor1_info_unpack
00014e94 ( 0.00%: 0) floor1_memosize
00014e9c ( 0.49%: 26) floor1_inverse1
000151b8 ( 4.89%: 258) floor1_inverse2
00015588 ( 1.19%: 63) ogg_buffer_dup
00015a60 ( 0.08%: 4) ogg_page_version
00015aa0 ( 0.02%: 1) ogg_page_continued
00015ae0 ( 0.02%: 1) ogg_page_bos
00015b20 ( 0.00%: 0) ogg_page_eos
00015b60 ( 0.11%: 6) ogg_page_granulepos
00015c28 ( 0.15%: 8) ogg_page_serialno
00015c68 ( 0.00%: 0) ogg_page_pageno
00015ca8 ( 0.00%: 0) ogg_page_packets
00015d0c ( 0.00%: 0) ogg_sync_create
00015d60 ( 0.00%: 0) ogg_sync_reset
00015d90 ( 0.11%: 6) ogg_sync_destroy
00015de8 ( 0.13%: 7) ogg_sync_bufferin
00015ea4 ( 0.08%: 4) ogg_sync_wrote
00015f00 ( 0.11%: 6) ogg_page_release
00015f40 ( 2.90%: 153) ogg_sync_pageseek
00016260 ( 0.00%: 0) ogg_sync_pageout
000162a8 ( 0.00%: 0) ogg_stream_create
000162cc ( 0.08%: 4) ogg_stream_destroy
0001636c ( 0.21%: 11) ogg_stream_pagein
00016454 ( 0.06%: 3) ogg_stream_reset
000164c8 ( 0.00%: 0) ogg_stream_reset_serialno
000164e4 ( 0.40%: 21) ogg_packet_release
000169e8 ( 0.00%: 0) ogg_stream_packetout
000169f0 ( 0.00%: 0) ogg_stream_packetpeek
000169f8 ( 0.00%: 0) ogg_page_dup
00016a68 ( 0.00%: 0) vorbis_comment_init
00016adc ( 0.00%: 0) vorbis_comment_query
00016bb0 ( 0.00%: 0) vorbis_comment_query_count
00016c60 ( 0.00%: 0) vorbis_comment_clear
00016cec ( 0.00%: 0) vorbis_info_blocksize
00016d00 ( 0.00%: 0) vorbis_info_init
00016d48 ( 0.00%: 0) vorbis_info_clear
00016ef8 ( 0.00%: 0) vorbis_dsp_headerin
00017514 ( 0.00%: 0) mapping_clear_info
00017590 ( 0.02%: 1) mapping_info_unpack
000177e4 ( 1.59%: 84) mapping_inverse
00017c84 ( 0.04%: 2) mdct_unroll_lap
00017f00 ( 0.02%: 1) mdct_backward
00018244 ( 0.00%: 0) _VDBG_dump
000182a8 ( 0.00%: 0) _VDBG_malloc
000183f4 ( 0.00%: 0) _VDBG_free
0001841c ( 0.00%: 0) res_clear_info
0001846c ( 0.00%: 0) res_unpack
00018680 ( 1.86%: 98) res_inverse
00019b7c ( 0.00%: 0) ov_clear
00019d20 ( 0.00%: 0) ov_test_callbacks
00019d60 ( 0.00%: 0) ov_test
00019dac ( 0.00%: 0) ov_streams
00019db4 ( 0.00%: 0) ov_seekable
00019dbc ( 0.00%: 0) ov_time_total
00019e80 ( 0.00%: 0) ov_bitrate
0001a008 ( 0.00%: 0) ov_bitrate_instant
0001a084 ( 0.00%: 0) ov_serialnumber
0001a0fc ( 0.00%: 0) ov_raw_total
0001a1ac ( 0.00%: 0) ov_pcm_total
0001a250 ( 0.00%: 0) ov_raw_seek
0001ab40 ( 0.00%: 0) ov_test_open
0001ab58 ( 0.00%: 0) ov_open_callbacks
0001abb0 ( 0.00%: 0) ov_open
0001abfc ( 0.00%: 0) ov_pcm_seek_page
0001b4a4 ( 0.00%: 0) ov_pcm_seek
0001b8c8 ( 0.00%: 0) ov_time_seek
0001ba48 ( 0.00%: 0) ov_time_seek_page
0001bbc8 ( 0.00%: 0) ov_raw_tell
0001bbec ( 0.00%: 0) ov_pcm_tell
0001bc10 ( 0.00%: 0) ov_time_tell
0001bd2c ( 0.00%: 0) ov_info
0001bd70 ( 0.00%: 0) ov_comment
0001bdb4 ( 0.09%: 5) ov_read
0001be94 ( 0.00%: 0) mdct_unroll_prelap
0001bf34 ( 0.06%: 3) mdct_unroll_postlap
0001bff8 ( 3.43%: 181) mdct_unroll_part2
0001c050 ( 1.21%: 64) mdct_unroll_part3
0001c0a8 ( 0.85%: 45) mdct_shift_right
0001c104 ( 14.45%: 763) mdct_backwardARM
0001c998 ( 6.04%: 319) decode_packed_entry_number
0001cb58 ( 0.00%: 0) stmiaTest
0001cbbc ( 0.00%: 0) strTest
0001cc3c ( 0.00%: 0) smullTest
0001cc80 ( 0.00%: 0) __udivdi3
0001d1f0 ( 0.00%: 0) __aeabi_drsub
0001d1f8 ( 0.00%: 0) __aeabi_dsub
0001d1f8 ( 0.00%: 0) __subdf3
0001d1fc ( 0.00%: 0) __adddf3
0001d1fc ( 0.00%: 0) __aeabi_dadd
0001d4dc ( 0.00%: 0) __aeabi_ui2d
0001d4dc ( 0.00%: 0) __floatunsidf
0001d500 ( 0.00%: 0) __floatsidf
0001d500 ( 0.00%: 0) __aeabi_i2d
0001d528 ( 0.00%: 0) __extendsfdf2
0001d528 ( 0.00%: 0) __aeabi_f2d
0001d568 ( 0.00%: 0) __aeabi_ul2d
0001d568 ( 0.00%: 0) __floatundidf
0001d57c ( 0.00%: 0) __floatdidf
0001d57c ( 0.00%: 0) __aeabi_l2d
0001d5dc ( 0.00%: 0) __aeabi_dmul
0001d5dc ( 0.00%: 0) __muldf3
0001d904 ( 0.00%: 0) __aeabi_ddiv
0001d904 ( 0.00%: 0) __divdf3
0001db08 ( 0.00%: 0) __modsi3
0001dbec ( 0.30%: 16) __divsi3
0001dd14 ( 0.00%: 0) __aeabi_idivmod
0001dd2c ( 0.04%: 2) __udivsi3
0001de24 ( 0.00%: 0) __aeabi_uidivmod
0001de3c ( 0.00%: 0) __divdi3
0001e3f8 ( 0.00%: 0) __umodsi3
0001e4c4 ( 0.00%: 0) __aeabi_ldiv0
0001e4c4 ( 0.00%: 0) __div0
0001e4c4 ( 0.00%: 0) __aeabi_idiv0
0001e4c8 ( 0.00%: 0) _XcptFilter
0001e4d4 ( 0.00%: 0) __C_specific_handler
0001e4e0 ( 0.00%: 0) LocalFree
0001e4ec ( 0.00%: 0) vsprintf
0001e4f8 ( 0.57%: 30) OutputDebugStringW
0001e504 ( 0.00%: 0) fopen
0001e510 ( 0.00%: 0) fwrite
0001e51c ( 0.00%: 0) fread
0001e528 ( 0.00%: 0) GetThreadTimes
0001e534 ( 0.00%: 0) Sleep
0001e540 ( 0.04%: 2) fputc
0001e54c ( 0.00%: 0) fclose
0001e558 ( 0.00%: 0) memset
0001e564 ( 0.00%: 0) GetThreadContext
0001e570 ( 0.00%: 0) malloc
0001e57c ( 0.00%: 0) CreateThread
0001e588 ( 0.00%: 0) SetThreadPriority
0001e594 ( 0.00%: 0) free
0001e5a0 ( 0.00%: 0) calloc
0001e5ac ( 0.00%: 0) realloc
0001e5b8 ( 0.00%: 0) memchr
0001e5c4 ( 0.00%: 0) toupper
0001e5d0 ( 0.00%: 0) strlen
0001e5dc ( 0.00%: 0) strcpy
0001e5e8 ( 0.00%: 0) memcmp
0001e5f4 ( 0.00%: 0) _getstdfilex
0001e600 ( 0.00%: 0) fprintf
0001e60c ( 0.00%: 0) fseek
0001e618 ( 0.00%: 0) memcpy
0001e624 ( 0.00%: 0) ftell
0001f418 ( 0.00%: 0) start_time
00028764 ( 0.00%: 0) FLOOR_fromdB_LOOKUP
00028b88 ( 0.00%: 0) sincos_lookup0
00029b90 ( 0.00%: 0) sincos_lookup1
0002ada4 ( 0.00%: 0) __clz_tab
0002d014 ( 0.00%: 0) global_bytes
0002d030 ( 0.00%: 0) __onexitbegin
0002d034 ( 0.00%: 0) __onexitend
0002d038 ( 0.00%: 0) _exitflag
0002d03c ( 0.00%: 0) pcmout
0002e03c ( 0.00%: 0) ref
0002f03c ( 0.00%: 0) text
0003003c ( 0.00%: 0) speedblock
00039000 ( 0.00%: 0) __IMPORT_DESCRIPTOR_COREDLL
00039014 ( 0.00%: 0) __NULL_IMPORT_DESCRIPTOR
000390b8 ( 0.00%: 0) __imp__XcptFilter
000390bc ( 0.00%: 0) __imp___C_specific_handler
000390c0 ( 0.00%: 0) __imp_LocalFree
000390c4 ( 0.00%: 0) __imp_vsprintf
000390c8 ( 0.00%: 0) __imp_OutputDebugStringW
000390cc ( 0.00%: 0) __imp_fopen
000390d0 ( 0.00%: 0) __imp_fwrite
000390d4 ( 0.00%: 0) __imp_fread
000390d8 ( 0.00%: 0) __imp_GetThreadTimes
000390dc ( 0.00%: 0) __imp_Sleep
000390e0 ( 0.00%: 0) __imp_fputc
000390e4 ( 0.00%: 0) __imp_fclose
000390e8 ( 0.00%: 0) __imp_memset
000390ec ( 0.00%: 0) __imp_GetThreadContext
000390f0 ( 0.00%: 0) __imp_malloc
000390f4 ( 0.00%: 0) __imp_CreateThread
000390f8 ( 0.00%: 0) __imp_SetThreadPriority
000390fc ( 0.00%: 0) __imp_free
00039100 ( 0.00%: 0) __imp_calloc
00039104 ( 0.00%: 0) __imp_realloc
00039108 ( 0.00%: 0) __imp_memchr
0003910c ( 0.00%: 0) __imp_toupper
00039110 ( 0.00%: 0) __imp_strlen
00039114 ( 0.00%: 0) __imp_strcpy
00039118 ( 0.00%: 0) __imp_memcmp
0003911c ( 0.00%: 0) __imp__getstdfilex
00039120 ( 0.00%: 0) __imp_fprintf
00039124 ( 0.00%: 0) __imp_fseek
00039128 ( 0.00%: 0) __imp_memcpy
0003912c ( 0.00%: 0) __imp_ftell
0003a000 ( 0.00%: 0) __xc_a
0003a004 ( 0.00%: 0) __xc_z
0003a008 ( 0.00%: 0) __xi_a
0003a00c ( 0.00%: 0) __xi_z
0003a010 ( 0.00%: 0) __xp_a
0003a014 ( 0.00%: 0) __xp_z
0003a018 ( 0.00%: 0) __xt_a
0003a01c ( 0.00%: 0) __xt_z
Profile by Time
00000000 ( 40.06%: 2115) Address 0
0001c104 ( 14.45%: 763) mdct_backwardARM
00012ff0 ( 7.61%: 402) decode_map
0001c998 ( 6.04%: 319) decode_packed_entry_number
000151b8 ( 4.89%: 258) floor1_inverse2
000134a4 ( 4.30%: 227) vorbis_book_decodevv_add
0001bff8 ( 3.43%: 181) mdct_unroll_part2
00015f40 ( 2.90%: 153) ogg_sync_pageseek
00018680 ( 1.86%: 98) res_inverse
00011a98 ( 1.84%: 97) oggpack_bits
000177e4 ( 1.59%: 84) mapping_inverse
00011ad4 ( 1.55%: 82) oggpack_look
0001c050 ( 1.21%: 64) mdct_unroll_part3
00015588 ( 1.19%: 63) ogg_buffer_dup
000127d0 ( 1.08%: 57) vorbis_book_unpack
00011bf8 ( 0.97%: 51) oggpack_adv
0001c0a8 ( 0.85%: 45) mdct_shift_right
0001e4f8 ( 0.57%: 30) OutputDebugStringW
00014e9c ( 0.49%: 26) floor1_inverse1
00011978 ( 0.42%: 22) Profile_init
000164e4 ( 0.40%: 21) ogg_packet_release
000133b0 ( 0.32%: 17) vorbis_book_decodev_set
0001dbec ( 0.30%: 16) __divsi3
0001636c ( 0.21%: 11) ogg_stream_pagein
00015c28 ( 0.15%: 8) ogg_page_serialno
00015de8 ( 0.13%: 7) ogg_sync_bufferin
00015d90 ( 0.11%: 6) ogg_sync_destroy
00015f00 ( 0.11%: 6) ogg_page_release
00015b60 ( 0.11%: 6) ogg_page_granulepos
0001bdb4 ( 0.09%: 5) ov_read
000162cc ( 0.08%: 4) ogg_stream_destroy
00015ea4 ( 0.08%: 4) ogg_sync_wrote
00015a60 ( 0.08%: 4) ogg_page_version
0001bf34 ( 0.06%: 3) mdct_unroll_postlap
00016454 ( 0.06%: 3) ogg_stream_reset
0001e540 ( 0.04%: 2) fputc
00014804 ( 0.04%: 2) floor1_info_unpack
0001474c ( 0.04%: 2) floor1_free_info
0001dd2c ( 0.04%: 2) __udivsi3
00017c84 ( 0.04%: 2) mdct_unroll_lap
00013694 ( 0.04%: 2) vorbis_dsp_destroy
000137e4 ( 0.04%: 2) vorbis_dsp_pcmout
00011cb8 ( 0.02%: 1) oggpack_read
00017f00 ( 0.02%: 1) mdct_backward
000139d0 ( 0.02%: 1) vorbis_dsp_synthesis
00011e4c ( 0.02%: 1) _ilog
0001271c ( 0.02%: 1) _book_maptype1_quantvals
00017590 ( 0.02%: 1) mapping_info_unpack
00015ae0 ( 0.02%: 1) ogg_page_bos
00015aa0 ( 0.02%: 1) ogg_page_continued
00018244 ( 0.00%: 0) _VDBG_dump
000182a8 ( 0.00%: 0) _VDBG_malloc
000183f4 ( 0.00%: 0) _VDBG_free
0001841c ( 0.00%: 0) res_clear_info
0001846c ( 0.00%: 0) res_unpack
00019b7c ( 0.00%: 0) ov_clear
00019d20 ( 0.00%: 0) ov_test_callbacks
00019d60 ( 0.00%: 0) ov_test
00019dac ( 0.00%: 0) ov_streams
00019db4 ( 0.00%: 0) ov_seekable
00019dbc ( 0.00%: 0) ov_time_total
00019e80 ( 0.00%: 0) ov_bitrate
0001a008 ( 0.00%: 0) ov_bitrate_instant
0001a084 ( 0.00%: 0) ov_serialnumber
0001a0fc ( 0.00%: 0) ov_raw_total
0001a1ac ( 0.00%: 0) ov_pcm_total
0001a250 ( 0.00%: 0) ov_raw_seek
0001ab40 ( 0.00%: 0) ov_test_open
0001ab58 ( 0.00%: 0) ov_open_callbacks
0001abb0 ( 0.00%: 0) ov_open
0001abfc ( 0.00%: 0) ov_pcm_seek_page
0001b4a4 ( 0.00%: 0) ov_pcm_seek
0001b8c8 ( 0.00%: 0) ov_time_seek
0001ba48 ( 0.00%: 0) ov_time_seek_page
0001bbc8 ( 0.00%: 0) ov_raw_tell
0001bbec ( 0.00%: 0) ov_pcm_tell
0001bc10 ( 0.00%: 0) ov_time_tell
0001bd2c ( 0.00%: 0) ov_info
0001bd70 ( 0.00%: 0) ov_comment
0001be94 ( 0.00%: 0) mdct_unroll_prelap
0001cb58 ( 0.00%: 0) stmiaTest
0001cbbc ( 0.00%: 0) strTest
0001cc3c ( 0.00%: 0) smullTest
0001cc80 ( 0.00%: 0) __udivdi3
0001d1f0 ( 0.00%: 0) __aeabi_drsub
0001d1f8 ( 0.00%: 0) __aeabi_dsub
0001d1f8 ( 0.00%: 0) __subdf3
0001d1fc ( 0.00%: 0) __adddf3
0001d1fc ( 0.00%: 0) __aeabi_dadd
0001d4dc ( 0.00%: 0) __aeabi_ui2d
0001d4dc ( 0.00%: 0) __floatunsidf
0001d500 ( 0.00%: 0) __floatsidf
0001d500 ( 0.00%: 0) __aeabi_i2d
0001d528 ( 0.00%: 0) __extendsfdf2
0001d528 ( 0.00%: 0) __aeabi_f2d
0001d568 ( 0.00%: 0) __aeabi_ul2d
0001d568 ( 0.00%: 0) __floatundidf
0001d57c ( 0.00%: 0) __floatdidf
0001d57c ( 0.00%: 0) __aeabi_l2d
0001d5dc ( 0.00%: 0) __aeabi_dmul
0001d5dc ( 0.00%: 0) __muldf3
0001d904 ( 0.00%: 0) __aeabi_ddiv
0001d904 ( 0.00%: 0) __divdf3
0001db08 ( 0.00%: 0) __modsi3
0001dd14 ( 0.00%: 0) __aeabi_idivmod
0001de24 ( 0.00%: 0) __aeabi_uidivmod
0001de3c ( 0.00%: 0) __divdi3
0001e3f8 ( 0.00%: 0) __umodsi3
0001e4c4 ( 0.00%: 0) __aeabi_ldiv0
0001e4c4 ( 0.00%: 0) __div0
0001e4c4 ( 0.00%: 0) __aeabi_idiv0
0001e4c8 ( 0.00%: 0) _XcptFilter
0001e4d4 ( 0.00%: 0) __C_specific_handler
0001e4e0 ( 0.00%: 0) LocalFree
0001e4ec ( 0.00%: 0) vsprintf
0001e504 ( 0.00%: 0) fopen
0001e510 ( 0.00%: 0) fwrite
0001e51c ( 0.00%: 0) fread
0001e528 ( 0.00%: 0) GetThreadTimes
0001e534 ( 0.00%: 0) Sleep
0001e54c ( 0.00%: 0) fclose
0001e558 ( 0.00%: 0) memset
0001e564 ( 0.00%: 0) GetThreadContext
0001e570 ( 0.00%: 0) malloc
0001e57c ( 0.00%: 0) CreateThread
0001e588 ( 0.00%: 0) SetThreadPriority
0001e594 ( 0.00%: 0) free
0001e5a0 ( 0.00%: 0) calloc
0001e5ac ( 0.00%: 0) realloc
0001e5b8 ( 0.00%: 0) memchr
0001e5c4 ( 0.00%: 0) toupper
0001e5d0 ( 0.00%: 0) strlen
0001e5dc ( 0.00%: 0) strcpy
0001e5e8 ( 0.00%: 0) memcmp
0001e5f4 ( 0.00%: 0) _getstdfilex
0001e600 ( 0.00%: 0) fprintf
0001e60c ( 0.00%: 0) fseek
0001e618 ( 0.00%: 0) memcpy
0001e624 ( 0.00%: 0) ftell
0001f418 ( 0.00%: 0) start_time
00028764 ( 0.00%: 0) FLOOR_fromdB_LOOKUP
00028b88 ( 0.00%: 0) sincos_lookup0
00029b90 ( 0.00%: 0) sincos_lookup1
0002ada4 ( 0.00%: 0) __clz_tab
0002d014 ( 0.00%: 0) global_bytes
0002d030 ( 0.00%: 0) __onexitbegin
0002d034 ( 0.00%: 0) __onexitend
0002d038 ( 0.00%: 0) _exitflag
0002d03c ( 0.00%: 0) pcmout
0002e03c ( 0.00%: 0) ref
0002f03c ( 0.00%: 0) text
0003003c ( 0.00%: 0) speedblock
00039000 ( 0.00%: 0) __IMPORT_DESCRIPTOR_COREDLL
00039014 ( 0.00%: 0) __NULL_IMPORT_DESCRIPTOR
000390b8 ( 0.00%: 0) __imp__XcptFilter
000390bc ( 0.00%: 0) __imp___C_specific_handler
000390c0 ( 0.00%: 0) __imp_LocalFree
000390c4 ( 0.00%: 0) __imp_vsprintf
000390c8 ( 0.00%: 0) __imp_OutputDebugStringW
000390cc ( 0.00%: 0) __imp_fopen
000390d0 ( 0.00%: 0) __imp_fwrite
000390d4 ( 0.00%: 0) __imp_fread
000390d8 ( 0.00%: 0) __imp_GetThreadTimes
000390dc ( 0.00%: 0) __imp_Sleep
000390e0 ( 0.00%: 0) __imp_fputc
000390e4 ( 0.00%: 0) __imp_fclose
000390e8 ( 0.00%: 0) __imp_memset
000390ec ( 0.00%: 0) __imp_GetThreadContext
000390f0 ( 0.00%: 0) __imp_malloc
000390f4 ( 0.00%: 0) __imp_CreateThread
000390f8 ( 0.00%: 0) __imp_SetThreadPriority
000390fc ( 0.00%: 0) __imp_free
00039100 ( 0.00%: 0) __imp_calloc
00039104 ( 0.00%: 0) __imp_realloc
00039108 ( 0.00%: 0) __imp_memchr
0003910c ( 0.00%: 0) __imp_toupper
00039110 ( 0.00%: 0) __imp_strlen
00039114 ( 0.00%: 0) __imp_strcpy
00039118 ( 0.00%: 0) __imp_memcmp
0003911c ( 0.00%: 0) __imp__getstdfilex
00039120 ( 0.00%: 0) __imp_fprintf
00039124 ( 0.00%: 0) __imp_fseek
00039128 ( 0.00%: 0) __imp_memcpy
0003912c ( 0.00%: 0) __imp_ftell
0003a000 ( 0.00%: 0) __xc_a
0003a004 ( 0.00%: 0) __xc_z
0003a008 ( 0.00%: 0) __xi_a
0003a00c ( 0.00%: 0) __xi_z
0003a010 ( 0.00%: 0) __xp_a
0003a014 ( 0.00%: 0) __xp_z
0003a018 ( 0.00%: 0) __xt_a
0003a01c ( 0.00%: 0) __xt_z
00011008 ( 0.00%: 0) WinMainCRTStartup
00011078 ( 0.00%: 0) _cinit
000110d8 ( 0.00%: 0) exit
000111b8 ( 0.00%: 0) _exit
000111c4 ( 0.00%: 0) _cexit
000111d4 ( 0.00%: 0) _c_exit
000111e4 ( 0.00%: 0) Output
000112b0 ( 0.00%: 0) main2
000115c8 ( 0.00%: 0) WinMain
00011604 ( 0.00%: 0) speedtest
000117c8 ( 0.00%: 0) Profile_dump
00011a54 ( 0.00%: 0) oggpack_eop
00011a68 ( 0.00%: 0) oggpack_bytes
00011c80 ( 0.00%: 0) oggpack_readinit
0001279c ( 0.00%: 0) vorbis_book_clear
00012fd8 ( 0.00%: 0) vorbis_book_decode
00013230 ( 0.00%: 0) vorbis_book_decodevs_add
000132f8 ( 0.00%: 0) vorbis_book_decodev_add
00013578 ( 0.00%: 0) vorbis_dsp_restart
000135e0 ( 0.00%: 0) vorbis_dsp_create
00013910 ( 0.00%: 0) vorbis_dsp_read
00013950 ( 0.00%: 0) vorbis_packet_blocksize
00013dd0 ( 0.00%: 0) floor0_free_info
00013ddc ( 0.00%: 0) floor0_info_unpack
00013eec ( 0.00%: 0) floor0_memosize
00013ef8 ( 0.00%: 0) floor0_inverse1
00014054 ( 0.00%: 0) vorbis_lsp_to_curve
000146b8 ( 0.00%: 0) floor0_inverse2
00014e94 ( 0.00%: 0) floor1_memosize
00015b20 ( 0.00%: 0) ogg_page_eos
00015c68 ( 0.00%: 0) ogg_page_pageno
00015ca8 ( 0.00%: 0) ogg_page_packets
00015d0c ( 0.00%: 0) ogg_sync_create
00015d60 ( 0.00%: 0) ogg_sync_reset
00016260 ( 0.00%: 0) ogg_sync_pageout
000162a8 ( 0.00%: 0) ogg_stream_create
000164c8 ( 0.00%: 0) ogg_stream_reset_serialno
000169e8 ( 0.00%: 0) ogg_stream_packetout
000169f0 ( 0.00%: 0) ogg_stream_packetpeek
000169f8 ( 0.00%: 0) ogg_page_dup
00016a68 ( 0.00%: 0) vorbis_comment_init
00016adc ( 0.00%: 0) vorbis_comment_query
00016bb0 ( 0.00%: 0) vorbis_comment_query_count
00016c60 ( 0.00%: 0) vorbis_comment_clear
00016cec ( 0.00%: 0) vorbis_info_blocksize
00016d00 ( 0.00%: 0) vorbis_info_init
00016d48 ( 0.00%: 0) vorbis_info_clear
00016ef8 ( 0.00%: 0) vorbis_dsp_headerin
00017514 ( 0.00%: 0) mapping_clear_info

View File

@@ -0,0 +1,843 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: packing variable sized words into an octet stream
********************************************************************/
/* We're 'LSb' endian; if we write a word but read individual bits,
then we'll read the lsb first */
#include <string.h>
#include <stdlib.h>
#include "misc.h"
#include "ogg.h"
#include <stdio.h>
#if !defined(ARM_LITTLE_ENDIAN) || defined(_V_BIT_TEST)
static unsigned long 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 };
#endif
#ifdef ARM_LITTLE_ENDIAN
#ifdef DEBUGGING_BITWISE
extern void oggpack_readinitARM(oggpack_buffer *b,ogg_reference *r);
void oggpack_readinit(oggpack_buffer *b,ogg_reference *r){
oggpack_readinitARM(b,r);
//fprintf(stderr, "Init: buffer=(%d,%x,%d,%d) %08x%08x\n",
// b->bitsLeftInSegment, b->ptr, b->bitsLeftInWord, b->count,
// b->ptr[1], b->ptr[0]);
//fflush(stderr);
}
extern long oggpack_lookARM(oggpack_buffer *b,int bits);
long oggpack_look(oggpack_buffer *b,int bits){
long l;
//fprintf(stderr, "PreLook: buffer=(%x,%x,%x) %08x%08x (%d bits)\n",
// b->bitsLeftInSegment, b->ptr, b->bitsLeftInWord,
// b->ptr[1], b->ptr[0], bits);
//fflush(stderr);
l = oggpack_lookARM(b,bits);
//fprintf(stderr, "Look: buffer=(%d,%x,%d,%d) %08x%08x (%d bits) (result=%x)\n",
// b->bitsLeftInSegment, b->ptr, b->bitsLeftInWord, b->count,
// b->ptr[1], b->ptr[0], bits, l);
//fflush(stderr);
return l;
}
extern void oggpack_advARM(oggpack_buffer *b,int bits);
void oggpack_adv(oggpack_buffer *b,int bits){
//fprintf(stderr, "Adv before: buffer=(%x,%x,%x) %08x%08x (%d bits)\n",
// b->bitsLeftInSegment, b->ptr, b->bitsLeftInWord,
// b->ptr[1], b->ptr[0],bits);
//fflush(stderr);
oggpack_advARM(b,bits);
//fprintf(stderr, "Adv: buffer=(%d,%x,%d,%d) %08x%08x\n",
// b->bitsLeftInSegment, b->ptr, b->bitsLeftInWord, b->count,
// b->ptr[1], b->ptr[0]);
//fflush(stderr);
}
extern long oggpack_readARM(oggpack_buffer *b,int bits);
/* bits <= 32 */
long oggpack_read(oggpack_buffer *b,int bits){
long l;
//fprintf(stderr, "PreRead: buffer=(%d,%x,%d,%d) %08x%08x (%d bits)\n",
// b->bitsLeftInSegment, b->ptr, b->bitsLeftInWord, b->count,
// b->ptr[1], b->ptr[0], bits);
//fflush(stderr);
l = oggpack_readARM(b,bits);
//fprintf(stderr, "Read: buffer=(%d,%x,%d,%d) %08x%08x (%d bits) (result=%x)\n",
// b->bitsLeftInSegment, b->ptr, b->bitsLeftInWord, b->count,
// b->ptr[1], b->ptr[0], bits, l);
//fflush(stderr);
return l;
}
#endif
int oggpack_eop(oggpack_buffer *b){
int ret;
if(b->bitsLeftInSegment<0)ret= -1;
else ret = 0;
//fprintf(stderr, "EOP %d\n", ret);
//fflush(stderr);
return ret;
}
long oggpack_bytes(oggpack_buffer *b){
long ret;
if(b->bitsLeftInSegment<0) ret = b->count+b->head->length;
else ret = b->count + b->head->length - (b->bitsLeftInSegment)/8;
//fprintf(stderr, "count=%d length=%d bitsLeftInSegment=%d\n",
// b->count, b->head->length, b->bitsLeftInSegment);
//fflush(stderr);
return ret;
}
long oggpack_bits(oggpack_buffer *b){
long ret;
if(b->bitsLeftInSegment<0) ret=(b->count+b->head->length)*8;
else ret = b->count*8 + b->head->length*8 - b->bitsLeftInSegment;
//fprintf(stderr, "count=%d length=%d bitsLeftInSegment=%d\n",
// b->count, b->head->length, b->bitsLeftInSegment);
//fflush(stderr);
return ret;
}
#else
/* spans forward, skipping as many bytes as headend is negative; if
headend is zero, simply finds next byte. If we're up to the end
of the buffer, leaves headend at zero. If we've read past the end,
halt the decode process. */
static void _span(oggpack_buffer *b){
while(b->headend-(b->headbit>>3)<1){
b->headend-=b->headbit>>3;
b->headbit&=0x7;
if(b->head->next){
b->count+=b->head->length;
b->head=b->head->next;
if(b->headend+b->head->length>0)
b->headptr=b->head->buffer->data+b->head->begin-b->headend;
b->headend+=b->head->length;
}else{
/* we've either met the end of decode, or gone past it. halt
only if we're past */
if(b->headend*8<b->headbit)
/* read has fallen off the end */
b->headend=-1;
break;
}
}
}
void oggpack_readinit(oggpack_buffer *b,ogg_reference *r){
memset(b,0,sizeof(*b));
b->tail=b->head=r;
b->count=0;
b->headptr=b->head->buffer->data+b->head->begin;
b->headend=b->head->length;
_span(b);
//fprintf(stderr,
// "Init: buffer=(%d,%x,%d,%d) %02x%02x%02x%02x%02x%02x%02x%02x\n",
// b->headbit, b->headptr, b->headend, b->count,
// b->headptr[7], b->headptr[6], b->headptr[5], b->headptr[4],
// b->headptr[3], b->headptr[2], b->headptr[1], b->headptr[0]);
//fflush(stderr);
}
#define _lookspan() while(!end){\
head=head->next;\
if(!head) return -1;\
ptr=head->buffer->data + head->begin;\
end=head->length;\
}
/* Read in bits without advancing the bitptr; bits <= 32 */
long oggpack_look(oggpack_buffer *b,int bits){
unsigned long m=mask[bits];
unsigned long ret;
int BITS = bits;
bits+=b->headbit;
if(bits >= b->headend<<3){
int end=b->headend;
unsigned char *ptr=b->headptr;
ogg_reference *head=b->head;
if(end<0)return -1;
if(bits){
_lookspan();
ret=*ptr++>>b->headbit;
if(bits>8){
--end;
_lookspan();
ret|=*ptr++<<(8-b->headbit);
if(bits>16){
--end;
_lookspan();
ret|=*ptr++<<(16-b->headbit);
if(bits>24){
--end;
_lookspan();
ret|=*ptr++<<(24-b->headbit);
if(bits>32 && b->headbit){
--end;
_lookspan();
ret|=*ptr<<(32-b->headbit);
}
}
}
}
}
}else{
/* make this a switch jump-table */
ret=b->headptr[0]>>b->headbit;
if(bits>8){
ret|=b->headptr[1]<<(8-b->headbit);
if(bits>16){
ret|=b->headptr[2]<<(16-b->headbit);
if(bits>24){
ret|=b->headptr[3]<<(24-b->headbit);
if(bits>32 && b->headbit)
ret|=b->headptr[4]<<(32-b->headbit);
}
}
}
}
ret&=m;
//fprintf(stderr,
// "Look: buffer=(%d,%x,%d,%d) %02x%02x%02x%02x%02x%02x%02x%02x (%d bits) return=%x\n",
// b->headbit, b->headptr, b->headend, b->count,
// b->headptr[7], b->headptr[6], b->headptr[5], b->headptr[4],
// b->headptr[3], b->headptr[2], b->headptr[1], b->headptr[0],
// BITS, ret);
//fflush(stderr);
return ret;
}
/* limited to 32 at a time */
void oggpack_adv(oggpack_buffer *b,int bits){
int BITS=bits;
bits+=b->headbit;
b->headbit=bits&7;
b->headend-=(bits>>3);
b->headptr+=(bits>>3);
if(b->headend<1)_span(b);
//fprintf(stderr, "Adv: buffer=(%d,%x,%d,%d) %02x%02x%02x%02x%02x%02x%02x%02x (%d bits)\n",
// b->headbit, b->headptr, b->headend,b->count,
// b->headptr[7], b->headptr[6], b->headptr[5], b->headptr[4],
// b->headptr[3], b->headptr[2], b->headptr[1], b->headptr[0],
// BITS);
//fflush(stderr);
}
int oggpack_eop(oggpack_buffer *b){
int ret;
if(b->headend<0)ret= -1;
else ret = 0;
//fprintf(stderr, "EOP %d\n", ret);
//fflush(stderr);
return ret;
}
long oggpack_bytes(oggpack_buffer *b){
long ret;
if(b->headend<0) ret = b->count+b->head->length;
ret = b->count + b->head->length-b->headend + (b->headbit+7)/8;
//fprintf(stderr, "Bytes: buffer=(%d,%x,%d,%d) %02x%02x%02x%02x%02x%02x%02x%02x (%d bytes)\n",
// b->headbit, b->headptr, b->headend, b->count,
// b->headptr[7], b->headptr[6], b->headptr[5], b->headptr[4],
// b->headptr[3], b->headptr[2], b->headptr[1], b->headptr[0],
// ret);
//fflush(stderr);
return ret;
}
long oggpack_bits(oggpack_buffer *b){
long ret;
if(b->headend<0) ret = (b->count+b->head->length)*8;
else ret = (b->count + b->head->length-b->headend)*8 + b->headbit;
//fprintf(stderr, "Bits: buffer=(%x,%x,%x) %02x%02x%02x%02x%02x%02x%02x%02x (%d bits)\n",
// b->headbit, b->headptr, b->headend,
// b->headptr[7], b->headptr[6], b->headptr[5], b->headptr[4],
// b->headptr[3], b->headptr[2], b->headptr[1], b->headptr[0],
// ret);
//fflush(stderr);
return ret;
}
/* bits <= 32 */
long oggpack_read(oggpack_buffer *b,int bits){
long ret=oggpack_look(b,bits);
oggpack_adv(b,bits);
return(ret);
}
#endif
/* Self test of the bitwise routines; everything else is based on
them, so they damned well better be solid. */
#ifdef _V_BIT_TEST
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "framing.c"
static int ilog(unsigned long v){
int ret=0;
while(v){
ret++;
v>>=1;
}
return(ret);
}
oggpack_buffer r;
oggpack_buffer o;
ogg_buffer_state *bs;
ogg_reference *or;
#define TESTWORDS 256
void report(char *in){
fprintf(stderr,"%s",in);
exit(1);
}
int getbyte(ogg_reference *or,int position){
while(or && position>=or->length){
position-=or->length;
or=or->next;
if(or==NULL){
fprintf(stderr,"\n\tERROR: getbyte ran off end of buffer.\n");
exit(1);
}
}
if((position+or->begin)&1)
return (or->buffer->data[(position+or->begin)>>1])&0xff;
else
return (or->buffer->data[(position+or->begin)>>1]>>8)&0xff;
}
void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){
long i,bitcount=0;
ogg_reference *or=ogg_buffer_alloc(bs,64);
for(i=0;i<compsize;i++)
or->buffer->data[i]= comp[i];
or->length=i;
oggpack_readinit(&r,or);
for(i=0;i<vals;i++){
unsigned long test;
int tbit=bits?bits:ilog(b[i]);
if((test=oggpack_look(&r,tbit))==0xffffffff)
report("out of data!\n");
if(test!=(b[i]&mask[tbit])){
fprintf(stderr,"%ld) %lx %lx\n",i,(b[i]&mask[tbit]),test);
report("looked at incorrect value!\n");
}
if((test=oggpack_read(&r,tbit))==0xffffffff){
report("premature end of data when reading!\n");
}
if(test!=(b[i]&mask[tbit])){
fprintf(stderr,"%ld) %lx %lx\n",i,(b[i]&mask[tbit]),test);
report("read incorrect value!\n");
}
bitcount+=tbit;
if(bitcount!=oggpack_bits(&r))
report("wrong number of bits while reading!\n");
if((bitcount+7)/8!=oggpack_bytes(&r))
report("wrong number of bytes while reading!\n");
}
if(oggpack_bytes(&r)!=(bitcount+7)/8){
fprintf(stderr, "%d vs %d\n", oggpack_bytes(&r), (bitcount+7)/8);
report("leftover bytes after read!\n");
}
ogg_buffer_release(or);
}
void _end_verify(int count){
int i;
/* are the proper number of bits left over? */
int leftover=count*8-oggpack_bits(&o);
if(leftover>7)
report("\nERROR: too many bits reported left over.\n");
/* does reading to exactly byte alignment *not* trip EOF? */
if(oggpack_read(&o,leftover)==-1)
report("\nERROR: read to but not past exact end tripped EOF.\n");
if(oggpack_bits(&o)!=count*8)
report("\nERROR: read to but not past exact end reported bad bitcount.\n");
/* does EOF trip properly after a single additional bit? */
if(oggpack_read(&o,1)!=-1)
report("\nERROR: read past exact end did not trip EOF.\n");
if(oggpack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
/* does EOF stay set over additional bit reads? */
for(i=0;i<=32;i++){
if(oggpack_read(&o,i)!=-1)
report("\nERROR: EOF did not stay set on stream.\n");
if(oggpack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
}
}
void _end_verify2(int count){
int i;
/* are the proper number of bits left over? */
int leftover=count*8-oggpack_bits(&o);
if(leftover>7)
report("\nERROR: too many bits reported left over.\n");
/* does reading to exactly byte alignment *not* trip EOF? */
oggpack_adv(&o,leftover);
#ifdef ARM_LITTLE_ENDIAN
if(o.bitsLeftInSegment!=0)
#else
if(o.headend!=0)
#endif
report("\nERROR: read to but not past exact end tripped EOF.\n");
if(oggpack_bits(&o)!=count*8)
report("\nERROR: read to but not past exact end reported bad bitcount.\n");
/* does EOF trip properly after a single additional bit? */
oggpack_adv(&o,1);
#ifdef ARM_LITTLE_ENDIAN
if(o.bitsLeftInSegment>=0)
#else
if(o.headend>=0)
#endif
report("\nERROR: read past exact end did not trip EOF.\n");
if(oggpack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
/* does EOF stay set over additional bit reads? */
for(i=0;i<=32;i++){
oggpack_adv(&o,i);
#ifdef ARM_LITTLE_ENDIAN
if(o.bitsLeftInSegment>=0)
#else
if(o.headend>=0)
#endif
report("\nERROR: EOF did not stay set on stream.\n");
if(oggpack_bits(&o)!=count*8)
report("\nERROR: read past exact end reported bad bitcount.\n");
}
}
long ogg_buffer_length(ogg_reference *or){
int count=0;
while(or){
count+=or->length;
or=or->next;
}
return count;
}
ogg_reference *ogg_buffer_extend(ogg_reference *or,long bytes){
if(or){
while(or->next){
or=or->next;
}
or->next=ogg_buffer_alloc(or->buffer->ptr.owner,bytes);
return(or->next);
}
return 0;
}
void ogg_buffer_posttruncate(ogg_reference *or,long pos){
/* walk to the point where we want to begin truncate */
while(or && pos>or->length){
pos-=or->length;
or=or->next;
}
if(or){
ogg_buffer_release(or->next);
or->next=0;
or->length=pos;
}
}
int main(void){
long i;
static unsigned long 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};
int test1size=43;
static unsigned long testbuffer2[]=
{216531625L,1237861823,56732452,131,3212421,12325343,34547562,12313212,
1233432,534,5,346435231,14436467,7869299,76326614,167548585,
85525151,0,12321,1,349528352};
int test2size=21;
static unsigned long 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};
int test3size=56;
static unsigned long large[]=
{2136531625L,2137861823,56732452,131,3212421,12325343,34547562,12313212,
1233432,534,5,2146435231,14436467,7869299,76326614,167548585,
85525151,0,12321,1,2146528352};
int onesize=33;
static int one[33]={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};
int twosize=6;
static int two[6]={61,255,255,251,231,29};
int threesize=54;
static int three[54]={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};
int foursize=38;
static int four[38]={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};
int fivesize=45;
static int five[45]={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};
int sixsize=7;
static int six[7]={17,177,170,242,169,19,148};
/* Test read/write together */
/* Later we test against pregenerated bitstreams */
bs=ogg_buffer_create();
fprintf(stderr,"\nSmall preclipped packing (LSb): ");
cliptest(testbuffer1,test1size,0,one,onesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nNull bit call (LSb): ");
cliptest(testbuffer3,test3size,0,two,twosize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nLarge preclipped packing (LSb): ");
cliptest(testbuffer2,test2size,0,three,threesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\n32 bit preclipped packing (LSb): ");
or=ogg_buffer_alloc(bs,128);
for(i=0;i<test2size;i++){
or->buffer->data[i*4] = large[i]&0xff;
or->buffer->data[i*4+1] = (large[i]>>8)&0xff;
or->buffer->data[i*4+2] = (large[i]>>16)&0xff;
or->buffer->data[i*4+3] = (large[i]>>24)&0xff;
}
or->length=test2size*4;
oggpack_readinit(&r,or);
for(i=0;i<test2size;i++){
unsigned long test;
if((test=oggpack_look(&r,32))==0xffffffffUL)report("out of data. failed!");
if(test!=large[i]){
fprintf(stderr,"%ld != %ld (%lx!=%lx):",test,large[i],
test,large[i]);
report("read incorrect value!\n");
}
oggpack_adv(&r,32);
}
ogg_buffer_release(or);
if(oggpack_bytes(&r)!=test2size*4){
fprintf(stderr, "%d vs %d\n", oggpack_bytes(&r), test2size*4);
report("leftover bytes after read!\n");
}
fprintf(stderr,"ok.");
fprintf(stderr,"\nSmall unclipped packing (LSb): ");
cliptest(testbuffer1,test1size,7,four,foursize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nLarge unclipped packing (LSb): ");
cliptest(testbuffer2,test2size,17,five,fivesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nSingle bit unclipped packing (LSb): ");
cliptest(testbuffer3,test3size,1,six,sixsize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nTesting read past end (LSb): ");
{
unsigned char dda[]={0,0,0,0};
ogg_buffer lob={dda,8,0,{0}};
ogg_reference lor={&lob,0,8,0};
oggpack_readinit(&r,&lor);
for(i=0;i<64;i++){
if(oggpack_read(&r,1)<0){
fprintf(stderr,"failed; got -1 prematurely.\n");
exit(1);
}
}
if(oggpack_look(&r,1)!=-1 ||
oggpack_read(&r,1)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
}
{
unsigned char dda[]={0,0,0,0};
ogg_buffer lob={dda,8,0,{0}};
ogg_reference lor={&lob,0,8,0};
unsigned long test;
oggpack_readinit(&r,&lor);
if((test=oggpack_read(&r,30))==0xffffffffUL ||
(test=oggpack_read(&r,16))==0xffffffffUL){
fprintf(stderr,"failed 2; got -1 prematurely.\n");
exit(1);
}
if((test=oggpack_look(&r,18))==0xffffffffUL){
fprintf(stderr,"failed 3; got -1 prematurely.\n");
exit(1);
}
if((test=oggpack_look(&r,19))!=0xffffffffUL){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
if((test=oggpack_look(&r,32))!=0xffffffffUL){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
}
fprintf(stderr,"ok.\n");
/* now the scary shit: randomized testing */
for(i=0;i<10000;i++){
long j,count=0,count2=0,bitcount=0;
unsigned long values[TESTWORDS];
int len[TESTWORDS];
unsigned char flat[4*TESTWORDS]; /* max possible needed size */
memset(flat,0,sizeof(flat));
fprintf(stderr,"\rRandomized testing (LSb)... (%ld) ",10000-i);
/* generate a list of words and lengths */
/* write the required number of bits out to packbuffer */
{
long word=0;
long bit=0;
int k;
for(j=0;j<TESTWORDS;j++){
values[j]=rand();
len[j]=(rand()%33);
for(k=0;k<len[j];k++){
flat[word] |= ((values[j]>>k)&0x1)<<bit;
bit++;
bitcount++;
if(bit>7){
bit=0;
word++;
}
}
}
}
count2=(bitcount+7)>>3;
/* construct random-length buffer chain from flat vector; random
byte starting offset within the length of the vector */
{
ogg_reference *or=NULL,*orl=NULL;
long pos=0;
/* build buffer chain */
while(count2){
int ilen=(rand()%32),k;
int ibegin=(rand()%32);
if(ilen>count2)ilen=count2;
if(or)
orl=ogg_buffer_extend(orl,64);
else
or=orl=ogg_buffer_alloc(bs,64);
orl->length=ilen;
orl->begin=ibegin;
for(k=0;k<ilen;k++)
orl->buffer->data[ibegin++]= flat[pos++];
count2-=ilen;
}
if(ogg_buffer_length(or)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: buffer length incorrect after build.\n");
exit(1);
}
{
int begin=0; //=(rand()%TESTWORDS);
int ilen=(rand()%(TESTWORDS-begin));
int bitoffset,bitcount=0;
unsigned long temp;
for(j=0;j<begin;j++)
bitcount+=len[j];
or=ogg_buffer_pretruncate(or,bitcount/8);
bitoffset=bitcount%=8;
for(;j<begin+ilen;j++)
bitcount+=len[j];
ogg_buffer_posttruncate(or,((bitcount+7)/8));
if((count=ogg_buffer_length(or))!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: buffer length incorrect after truncate.\n");
exit(1);
}
oggpack_readinit(&o,or);
/* verify bit count */
if(oggpack_bits(&o)!=0){
fprintf(stderr,"\nERROR: Read bitcounter not zero!\n");
exit(1);
}
if(oggpack_bytes(&o)!=0){
fprintf(stderr,"\nERROR: Read bytecounter not zero!\n");
exit(1);
}
bitcount=bitoffset;
oggpack_read(&o,bitoffset);
/* read and compare to original list */
for(j=begin;j<begin+ilen;j++){
temp=oggpack_read(&o,len[j]);
if(temp==0xffffffffUL){
fprintf(stderr,"\nERROR: End of stream too soon! word: %ld,%d\n",
j-begin,ilen);
exit(1);
}
if(temp!=(values[j]&mask[len[j]])){
fprintf(stderr,"\nERROR: Incorrect read %lx != %lx, word %ld, len %d\n"
,
values[j]&mask[len[j]],temp,j-begin,len[j]);
exit(1);
}
bitcount+=len[j];
if(oggpack_bits(&o)!=bitcount){
fprintf(stderr,"\nERROR: Read bitcounter %d != %ld!\n",
bitcount,oggpack_bits(&o));
exit(1);
}
if(oggpack_bytes(&o)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: Read bytecounter %d != %ld!\n",
(bitcount+7)/8,oggpack_bytes(&o));
exit(1);
}
}
_end_verify(count);
/* look/adv version */
oggpack_readinit(&o,or);
bitcount=bitoffset;
oggpack_adv(&o,bitoffset);
/* read and compare to original list */
for(j=begin;j<begin+ilen;j++){
temp=oggpack_look(&o,len[j]);
if(temp==0xffffffffUL){
fprintf(stderr,"\nERROR: End of stream too soon! word: %ld\n",
j-begin);
exit(1);
}
if(temp!=(values[j]&mask[len[j]])){
fprintf(stderr,"\nERROR: Incorrect look %lx != %lx, word %ld, len %d\n"
,
values[j]&mask[len[j]],temp,j-begin,len[j]);
exit(1);
}
oggpack_adv(&o,len[j]);
bitcount+=len[j];
if(oggpack_bits(&o)!=bitcount){
fprintf(stderr,"\nERROR: Look/Adv bitcounter %d != %ld!\n",
bitcount,oggpack_bits(&o));
exit(1);
}
if(oggpack_bytes(&o)!=(bitcount+7)/8){
fprintf(stderr,"\nERROR: Look/Adv bytecounter %d != %ld!\n",
(bitcount+7)/8,oggpack_bytes(&o));
exit(1);
}
}
_end_verify2(count);
}
ogg_buffer_release(or);
}
}
fprintf(stderr,"\rRandomized testing (LSb)... ok. \n");
return(0);
}
#ifdef _WIN32_WCE
int WinMain(void){
return main();
}
#endif
#endif

View File

@@ -0,0 +1,359 @@
.text
.global oggpack_look
.global oggpack_adv
.global oggpack_readinit
.global oggpack_read
oggpack_look:
@ r0 = oggpack_buffer *b
@ r1 = int bits
STMFD r13!,{r10,r11,r14}
LDMIA r0,{r2,r3,r12}
@ r2 = bitsLeftInSegment
@ r3 = ptr
@ r12= bitsLeftInWord
SUBS r2,r2,r1 @ bitsLeftinSegment -= bits
BLT look_slow @ Not enough bits in this segment for
@ this request. Do it slowly.
LDR r10,[r3] @ r10= ptr[0]
RSB r14,r12,#32 @ r14= 32-bitsLeftInWord
SUBS r12,r12,r1 @ r12= bitsLeftInWord -= bits
LDRLT r11,[r3,#4]! @ r11= ptr[1]
MOV r10,r10,LSR r14 @ r10= ptr[0]>>(32-bitsLeftInWord)
ADDLE r12,r12,#32 @ r12= bitsLeftInWord += 32
RSB r14,r14,#32 @ r14= 32-bitsLeftInWord
ORRLT r10,r10,r11,LSL r14 @ r10= Next 32 bits.
MOV r14,#1
RSB r14,r14,r14,LSL r1
AND r0,r10,r14
LDMFD r13!,{r10,r11,PC}
look_slow:
STMFD r13!,{r5,r6}
ADDS r10,r2,r1 @ r10= bitsLeftInSegment + bits (i.e.
@ the initial value of bitsLeftInSeg)
@ r10 = bitsLeftInSegment (initial)
@ r12 = bitsLeftInWord
RSB r14,r12,#32 @ r14= 32-bitsLeftInWord
MOV r5,r10 @ r5 = bitsLeftInSegment (initial)
BLT look_overrun
BEQ look_next_segment @ r10= r12 = 0, if we branch
CMP r12,r10 @ If bitsLeftInWord < bitsLeftInSeg
@ there must be more in the next word
LDR r10,[r3],#4 @ r10= ptr[0]
LDRLT r6,[r3] @ r6 = ptr[1]
MOV r11,#1
MOV r10,r10,LSR r14 @ r10= first bitsLeftInWord bits
ORRLT r10,r10,r6,LSL r12 @ r10= first bitsLeftInSeg bits+crap
RSB r11,r11,r11,LSL r5 @ r11= mask
AND r10,r10,r11 @ r10= first r5 bits
@ Load the next segments data
look_next_segment:
@ At this point, r10 contains the first r5 bits of the result
LDR r11,[r0,#12] @ r11= head = b->head
@ Stall
@ Stall
look_next_segment_2:
LDR r11,[r11,#12] @ r11= head = head->next
@ Stall
@ Stall
CMP r11,#0
BEQ look_out_of_data
LDMIA r11,{r6,r12,r14} @ r6 = buffer
@ r12= begin
@ r14= length
LDR r6,[r6] @ r6 = buffer->data
CMP r14,#0
BEQ look_next_segment_2
ADD r6,r6,r12 @ r6 = buffer->data+begin
look_slow_loop:
LDRB r12,[r6],#1 @ r12= *buffer
SUBS r14,r14,#1 @ r14= length
@ Stall
ORR r10,r10,r12,LSL r5 @ r10= first r5+8 bits
ADD r5,r5,#8
BLE look_really_slow
CMP r5,r1
BLT look_slow_loop
MOV r14,#1
RSB r14,r14,r14,LSL r1
AND r0,r10,r14
LDMFD r13!,{r5,r6,r10,r11,PC}
look_really_slow:
CMP r5,r1
BLT look_next_segment_2
MOV r14,#1
RSB r14,r14,r14,LSL r1
AND r0,r10,r14
LDMFD r13!,{r5,r6,r10,r11,PC}
look_out_of_data:
MVN r0,#0 @ return -1
LDMFD r13!,{r5,r6,r10,r11,PC}
look_overrun:
@ We had overrun when we started, so we need to skip -r10 bits.
LDR r11,[r0,#12] @ r11 = head = b->head
@ stall
@ stall
look_overrun_next_segment:
LDR r11,[r11,#12] @ r11 = head->next
@ stall
@ stall
CMP r11,#0
BEQ look_out_of_data
LDMIA r11,{r6,r7,r14} @ r6 = buffer
@ r7 = begin
@ r14= length
LDR r6,[r6] @ r6 = buffer->data
@ stall
@ stall
ADD r6,r6,r7 @ r6 = buffer->data+begin
MOV r14,r14,LSL #3 @ r14= length in bits
ADDS r14,r14,r10 @ r14= length in bits-bits to skip
MOVLE r10,r14
BLE look_overrun_next_segment
RSB r10,r10,#0 @ r10= bits to skip
ADD r6,r10,r10,LSR #3 @ r6 = pointer to data
MOV r10,#0
B look_slow_loop
oggpack_adv:
@ r0 = oggpack_buffer *b
@ r1 = bits
LDMIA r0,{r2,r3,r12}
@ r2 = bitsLeftInSegment
@ r3 = ptr
@ r12= bitsLeftInWord
SUBS r2,r2,r1 @ Does this run us out of bits in the
BLE adv_slow @ segment? If so, do it slowly
SUBS r12,r12,r1
ADDLE r12,r12,#32
ADDLE r3,r3,#4
STMIA r0,{r2,r3,r12}
MOV PC,R14
adv_slow:
STMFD r13!,{r10,r14}
LDR r14,[r0,#12] @ r14= head
@ stall
adv_slow_loop:
LDR r1,[r0,#20] @ r1 = count
LDR r10,[r14,#8] @ r10= head->length
LDR r14,[r14,#12] @ r14= head->next
@ stall
ADD r1,r1,r10 @ r1 = count += head->length
CMP r14,#0
BEQ adv_end
STR r1,[r0,#20] @ b->count = count
STR r14,[r0,#12] @ b->head = head
LDMIA r14,{r3,r10,r12} @ r3 = buffer
@ r10= begin
@ r12= length
LDR r3,[r3] @ r3 = buffer->data
ADD r3,r3,r10 @ r3 = Pointer to start (byte)
AND r10,r3,#3 @ r10= bytes to backtrk to word align
MOV r10,r10,LSL #3 @ r10= bits to backtrk to word align
RSB r10,r10,#32 @ r10= bits left in word
ADDS r10,r10,r2 @ r10= bits left in word after skip
ADDLE r10,r10,#32
ADDLE r3,r3,#4
BIC r3,r3,#3 @ r3 = Pointer to start (word)
ADDS r2,r2,r12,LSL #3 @ r2 = length in bits after advance
BLE adv_slow_loop
STMIA r0,{r2,r3,r10}
LDMFD r13!,{r10,PC}
adv_end:
STMIA r0,{r2,r3,r12}
LDMFD r13!,{r10,PC}
oggpack_readinit:
@ r0 = oggpack_buffer *b
@ r1 = oggreference *r
STR r1,[r0,#12] @ b->head = r1
STR r1,[r0,#16] @ b->tail = r1
LDMIA r1,{r2,r3,r12} @ r2 = b->head->buffer
@ r3 = b->head->begin
@ r12= b->head->length
LDR r2,[r2] @ r2 = b->head->buffer->data
MOV r1,r12,LSL #3 @ r1 = BitsInSegment
MOV r12,#0
ADD r3,r2,r3 @ r3 = r2+b->head->begin
BIC r2,r3,#3 @ r2 = b->headptr (word)
AND r3,r3,#3
MOV r3,r3,LSL #3
RSB r3,r3,#32 @ r3 = BitsInWord
STMIA r0,{r1,r2,r3}
STR r12,[r0,#20]
MOV PC,R14
oggpack_read:
@ r0 = oggpack_buffer *b
@ r1 = int bits
STMFD r13!,{r10,r11,r14}
LDMIA r0,{r2,r3,r12}
@ r2 = bitsLeftInSegment
@ r3 = ptr
@ r12= bitsLeftInWord
SUBS r2,r2,r1 @ bitsLeftinSegment -= bits
BLT read_slow @ Not enough bits in this segment for
@ this request. Do it slowly.
LDR r10,[r3] @ r10= ptr[0]
RSB r14,r12,#32 @ r14= 32-bitsLeftInWord
SUBS r12,r12,r1 @ r12= bitsLeftInWord -= bits
ADDLE r3,r3,#4
LDRLT r11,[r3] @ r11= ptr[1]
MOV r10,r10,LSR r14 @ r10= ptr[0]>>(32-bitsLeftInWord)
ADDLE r12,r12,#32 @ r12= bitsLeftInWord += 32
RSB r14,r14,#32 @ r14= 32-bitsLeftInWord
ORRLT r10,r10,r11,LSL r14 @ r10= Next 32 bits.
STMIA r0,{r2,r3,r12}
MOV r14,#1
RSB r14,r14,r14,LSL r1
AND r0,r10,r14
LDMFD r13!,{r10,r11,PC}
read_slow:
STMFD r13!,{r5,r6}
ADDS r10,r2,r1 @ r10= bitsLeftInSegment + bits (i.e.
@ the initial value of bitsLeftInSeg)
@ r10 = bitsLeftInSegment (initial)
@ r12 = bitsLeftInWord
RSB r14,r12,#32 @ r14= 32-bitsLeftInWord
MOV r5,r10 @ r5 = bitsLeftInSegment (initial)
BLT read_overrun
BEQ read_next_segment @ r10= r12 = 0, if we branch
CMP r12,r10 @ If bitsLeftInWord < bitsLeftInSeg
@ there must be more in the next word
LDR r10,[r3],#4 @ r10= ptr[0]
LDRLT r6,[r3] @ r6 = ptr[1]
MOV r11,#1
MOV r10,r10,LSR r14 @ r10= first bitsLeftInWord bits
ORRLT r10,r10,r6,LSL r12 @ r10= first bitsLeftInSeg bits+crap
RSB r11,r11,r11,LSL r5 @ r11= mask
AND r10,r10,r11 @ r10= first r5 bits
@ Load the next segments data
read_next_segment:
@ At this point, r10 contains the first r5 bits of the result
LDR r11,[r0,#12] @ r11= head = b->head
@ Stall
read_next_segment_2:
@ r11 = head
LDR r6,[r0,#20] @ r6 = count
LDR r12,[r11,#8] @ r12= length
LDR r11,[r11,#12] @ r11= head = head->next
@ Stall
ADD r6,r6,r12 @ count += length
CMP r11,#0
BEQ read_out_of_data
STR r11,[r0,#12]
STR r6,[r0,#20] @ b->count = count
LDMIA r11,{r6,r12,r14} @ r6 = buffer
@ r12= begin
@ r14= length
LDR r6,[r6] @ r6 = buffer->data
CMP r14,#0
BEQ read_next_segment_2
ADD r6,r6,r12 @ r6 = buffer->data+begin
read_slow_loop:
LDRB r12,[r6],#1 @ r12= *buffer
SUBS r14,r14,#1 @ r14= length
@ Stall
ORR r10,r10,r12,LSL r5 @ r10= first r5+8 bits
ADD r5,r5,#8
BLE read_really_slow
CMP r5,r1
BLT read_slow_loop
read_end:
MOV r12,#1
RSB r12,r12,r12,LSL r1
@ Store back the new position
@ r2 = -number of bits to go from this segment
@ r6 = ptr
@ r14= bytesLeftInSegment
@ r11= New head value
LDMIA r11,{r3,r6,r14} @ r3 = buffer
@ r6 = begin
@ r14= length
LDR r3,[r3] @ r3 = buffer->data
ADD r1,r2,r14,LSL #3 @ r1 = bitsLeftInSegment
@ stall
ADD r6,r3,r6 @ r6 = pointer
AND r3,r6,#3 @ r3 = bytes used in first word
RSB r3,r2,r3,LSL #3 @ r3 = bits used in first word
BIC r2,r6,#3 @ r2 = word ptr
RSBS r3,r3,#32 @ r3 = bitsLeftInWord
ADDLE r3,r3,#32
ADDLE r2,r2,#4
STMIA r0,{r1,r2,r3}
AND r0,r10,r12
LDMFD r13!,{r5,r6,r10,r11,PC}
read_really_slow:
CMP r5,r1
BGE read_end
LDR r14,[r11,#8] @ r14= length of segment just done
@ stall
@ stall
ADD r2,r2,r14,LSL #3 @ r2 = -bits to use from next seg
B read_next_segment_2
read_out_of_data:
@ Store back the new position
@ r2 = -number of bits to go from this segment
@ r6 = ptr
@ r14= bytesLeftInSegment
@ RJW: This may be overkill - we leave the buffer empty, with -1
@ bits left in it. We might get away with just storing the
@ bitsLeftInSegment as -1.
LDR r11,[r0,#12] @ r11=head
LDMIA r11,{r3,r6,r14} @ r3 = buffer
@ r6 = begin
@ r14= length
LDR r3,[r3] @ r3 = buffer->data
ADD r6,r3,r6 @ r6 = pointer
ADD r6,r6,r14
AND r3,r6,#3 @ r3 = bytes used in first word
MOV r3,r3,LSL #3 @ r3 = bits used in first word
BIC r2,r6,#3 @ r2 = word ptr
RSBS r3,r3,#32 @ r3 = bitsLeftInWord
MVN r1,#0 @ r1 = -1 = bitsLeftInSegment
STMIA r0,{r1,r2,r3}
MVN r0,#0 @ return -1
LDMFD r13!,{r5,r6,r10,r11,PC}
read_overrun:
@ We had overrun when we started, so we need to skip -r10 bits.
LDR r11,[r0,#12] @ r11 = head = b->head
@ stall
@ stall
read_overrun_next_segment:
LDR r11,[r11,#12] @ r11 = head->next
@ stall
@ stall
CMP r11,#0
BEQ read_out_of_data
LDMIA r11,{r6,r7,r14} @ r6 = buffer
@ r7 = begin
@ r14= length
LDR r6,[r6] @ r6 = buffer->data
@ stall
@ stall
ADD r6,r6,r7 @ r6 = buffer->data+begin
MOV r14,r14,LSL #3 @ r14= length in bits
ADDS r14,r14,r10 @ r14= length in bits-bits to skip
MOVLE r10,r14
BLE read_overrun_next_segment
RSB r10,r10,#0 @ r10= bits to skip
ADD r6,r10,r10,LSR #3 @ r6 = pointer to data
MOV r10,#0
B read_slow_loop

View File

@@ -0,0 +1,874 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: basic codebook pack/unpack/code/decode operations
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codebook.h"
#include "misc.h"
#include "os.h"
/**** pack/unpack helpers ******************************************/
int _ilog(unsigned int v){
int ret=0;
while(v){
ret++;
v>>=1;
}
return(ret);
}
static ogg_uint32_t decpack(long entry,long used_entry,long quantvals,
codebook *b,oggpack_buffer *opb,int maptype){
ogg_uint32_t ret=0;
int j;
switch(b->dec_type){
case 0:
return (ogg_uint32_t)entry;
case 1:
if(maptype==1){
/* vals are already read into temporary column vector here */
for(j=0;j<b->dim;j++){
ogg_uint32_t off=entry%quantvals;
entry/=quantvals;
ret|=((ogg_uint16_t *)(b->q_val))[off]<<(b->q_bits*j);
}
}else{
for(j=0;j<b->dim;j++)
ret|=oggpack_read(opb,b->q_bits)<<(b->q_bits*j);
}
return ret;
case 2:
for(j=0;j<b->dim;j++){
ogg_uint32_t off=entry%quantvals;
entry/=quantvals;
ret|=off<<(b->q_pack*j);
}
return ret;
case 3:
return (ogg_uint32_t)used_entry;
}
return 0; /* silence compiler */
}
/* 32 bit float (not IEEE; nonnormalized mantissa +
biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
Why not IEEE? It's just not that important here. */
static ogg_int32_t _float32_unpack(long val,int *point){
long mant=val&0x1fffff;
int sign=val&0x80000000;
*point=((val&0x7fe00000L)>>21)-788;
if(mant){
while(!(mant&0x40000000)){
mant<<=1;
*point-=1;
}
if(sign)mant= -mant;
}else{
*point=-9999;
}
return mant;
}
/* choose the smallest supported node size that fits our decode table.
Legal bytewidths are 1/1 1/2 2/2 2/4 4/4 */
static int _determine_node_bytes(long used, int leafwidth){
/* special case small books to size 4 to avoid multiple special
cases in repack */
if(used<2)
return 4;
if(leafwidth==3)leafwidth=4;
if(_ilog(3*used-6)+1 <= leafwidth*4)
return leafwidth/2?leafwidth/2:1;
return leafwidth;
}
/* convenience/clarity; leaves are specified as multiple of node word
size (1 or 2) */
static int _determine_leaf_words(int nodeb, int leafwidth){
if(leafwidth>nodeb)return 2;
return 1;
}
/* given a list of word lengths, number of used entries, and byte
width of a leaf, generate the decode table */
static int _make_words(char *l,long n,ogg_uint32_t *r,long quantvals,
codebook *b, oggpack_buffer *opb,int maptype){
long i,j,count=0;
long top=0;
ogg_uint32_t marker[33];
if (n<1)
return 1;
if(n<2){
r[0]=0x80000000;
}else{
memset(marker,0,sizeof(marker));
for(i=0;i<n;i++){
long length=l[i];
if(length){
ogg_uint32_t entry=marker[length];
long chase=0;
if(count && !entry)return -1; /* overpopulated tree! */
/* chase the tree as far as it's already populated, fill in past */
for(j=0;j<length-1;j++){
int bit=(entry>>(length-j-1))&1;
if(chase>=top){
if (chase < 0 || chase >= n) return 1;
top++;
r[chase*2]=top;
r[chase*2+1]=0;
}else
if (chase < 0 || chase >= n || chase*2+bit > n*2+1) return 1;
if(!r[chase*2+bit])
r[chase*2+bit]=top;
chase=r[chase*2+bit];
if (chase < 0 || chase >= n) return 1;
}
{
int bit=(entry>>(length-j-1))&1;
if(chase>=top){
top++;
r[chase*2+1]=0;
}
r[chase*2+bit]= decpack(i,count++,quantvals,b,opb,maptype) |
0x80000000;
}
/* Look to see if the next shorter marker points to the node
above. if so, update it and repeat. */
for(j=length;j>0;j--){
if(marker[j]&1){
marker[j]=marker[j-1]<<1;
break;
}
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(j=length+1;j<33;j++)
if((marker[j]>>1) == entry){
entry=marker[j];
marker[j]=marker[j-1]<<1;
}else
break;
}
}
}
return 0;
}
static int _make_decode_table(codebook *s,char *lengthlist,long quantvals,
oggpack_buffer *opb,int maptype){
int i;
ogg_uint32_t *work;
if (!lengthlist) return 1;
if(s->dec_nodeb==4){
/* Over-allocate by using s->entries instead of used_entries.
* This means that we can use s->entries to enforce size in
* _make_words without messing up length list looping.
* This probably wastes a bit of space, but it shouldn't
* impact behavior or size too much.
*/
s->dec_table=_ogg_malloc((s->entries*2+1)*sizeof(*work));
if (!s->dec_table) return 1;
/* +1 (rather than -2) is to accommodate 0 and 1 sized books,
which are specialcased to nodeb==4 */
if(_make_words(lengthlist,s->entries,
s->dec_table,quantvals,s,opb,maptype))return 1;
return 0;
}
if (s->used_entries > INT_MAX/2 ||
s->used_entries*2 > INT_MAX/((long) sizeof(*work)) - 1) return 1;
/* Overallocate as above */
work=alloca((s->entries*2+1)*sizeof(*work));
if(_make_words(lengthlist,s->entries,work,quantvals,s,opb,maptype))return 1;
if (s->used_entries > INT_MAX/(s->dec_leafw+1)) return 1;
if (s->dec_nodeb && s->used_entries * (s->dec_leafw+1) > INT_MAX/s->dec_nodeb) return 1;
s->dec_table=_ogg_malloc((s->used_entries*(s->dec_leafw+1)-2)*
s->dec_nodeb);
if (!s->dec_table) return 1;
if(s->dec_leafw==1){
switch(s->dec_nodeb){
case 1:
for(i=0;i<s->used_entries*2-2;i++)
((unsigned char *)s->dec_table)[i]=(unsigned char)
(((work[i] & 0x80000000UL) >> 24) | work[i]);
break;
case 2:
for(i=0;i<s->used_entries*2-2;i++)
((ogg_uint16_t *)s->dec_table)[i]=(ogg_uint16_t)
(((work[i] & 0x80000000UL) >> 16) | work[i]);
break;
}
}else{
/* more complex; we have to do a two-pass repack that updates the
node indexing. */
long top=s->used_entries*3-2;
if(s->dec_nodeb==1){
unsigned char *out=(unsigned char *)s->dec_table;
for(i=s->used_entries*2-4;i>=0;i-=2){
if(work[i]&0x80000000UL){
if(work[i+1]&0x80000000UL){
top-=4;
out[top]=(work[i]>>8 & 0x7f)|0x80;
out[top+1]=(work[i+1]>>8 & 0x7f)|0x80;
out[top+2]=work[i] & 0xff;
out[top+3]=work[i+1] & 0xff;
}else{
top-=3;
out[top]=(work[i]>>8 & 0x7f)|0x80;
out[top+1]=work[work[i+1]*2];
out[top+2]=work[i] & 0xff;
}
}else{
if(work[i+1]&0x80000000UL){
top-=3;
out[top]=work[work[i]*2];
out[top+1]=(work[i+1]>>8 & 0x7f)|0x80;
out[top+2]=work[i+1] & 0xff;
}else{
top-=2;
out[top]=work[work[i]*2];
out[top+1]=work[work[i+1]*2];
}
}
work[i]=top;
}
}else{
ogg_uint16_t *out=(ogg_uint16_t *)s->dec_table;
for(i=s->used_entries*2-4;i>=0;i-=2){
if(work[i]&0x80000000UL){
if(work[i+1]&0x80000000UL){
top-=4;
out[top]=(work[i]>>16 & 0x7fff)|0x8000;
out[top+1]=(work[i+1]>>16 & 0x7fff)|0x8000;
out[top+2]=work[i] & 0xffff;
out[top+3]=work[i+1] & 0xffff;
}else{
top-=3;
out[top]=(work[i]>>16 & 0x7fff)|0x8000;
out[top+1]=work[work[i+1]*2];
out[top+2]=work[i] & 0xffff;
}
}else{
if(work[i+1]&0x80000000UL){
top-=3;
out[top]=work[work[i]*2];
out[top+1]=(work[i+1]>>16 & 0x7fff)|0x8000;
out[top+2]=work[i+1] & 0xffff;
}else{
top-=2;
out[top]=work[work[i]*2];
out[top+1]=work[work[i+1]*2];
}
}
work[i]=top;
}
}
}
return 0;
}
/* 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 */
/* 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 */
long _book_maptype1_quantvals(codebook *b){
/* get us a starting hint, we'll polish it below */
int bits=_ilog(b->entries);
int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim);
while(1){
long acc=1;
long acc1=1;
int i;
for(i=0;i<b->dim;i++){
acc*=vals;
acc1*=vals+1;
}
if(acc<=b->entries && acc1>b->entries){
return(vals);
}else{
if(acc>b->entries){
vals--;
}else{
vals++;
}
}
}
}
void vorbis_book_clear(codebook *b){
/* static book is not cleared; we're likely called on the lookup and
the static codebook belongs to the info struct */
if(b->q_val)_ogg_free(b->q_val);
if(b->dec_table)_ogg_free(b->dec_table);
if(b->dec_buf)_ogg_free(b->dec_buf);
memset(b,0,sizeof(*b));
}
int vorbis_book_unpack(oggpack_buffer *opb,codebook *s){
char *lengthlist=NULL;
int quantvals=0;
long i,j;
int maptype;
memset(s,0,sizeof(*s));
/* make sure alignment is correct */
if(oggpack_read(opb,24)!=0x564342)goto _eofout;
/* first the basic parameters */
s->dim=oggpack_read(opb,16);
s->dec_buf=_ogg_malloc(sizeof(ogg_int32_t)*s->dim);
if (s->dec_buf == NULL)
goto _errout;
s->entries=oggpack_read(opb,24);
if(s->entries<=0)goto _eofout;
if(s->dim<=0)goto _eofout;
if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout;
if (s->dim > INT_MAX/s->entries) goto _eofout;
/* codeword ordering.... length ordered or unordered? */
switch((int)oggpack_read(opb,1)){
case 0:
/* unordered */
lengthlist=(char *)alloca(sizeof(*lengthlist)*s->entries);
if(!lengthlist) goto _eofout;
/* allocated but unused entries? */
if(oggpack_read(opb,1)){
/* yes, unused entries */
for(i=0;i<s->entries;i++){
if(oggpack_read(opb,1)){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
lengthlist[i]=(char)(num+1);
s->used_entries++;
if(num+1>s->dec_maxlength)s->dec_maxlength=num+1;
}else
lengthlist[i]=0;
}
}else{
/* all entries used; no tagging */
s->used_entries=s->entries;
for(i=0;i<s->entries;i++){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
lengthlist[i]=(char)(num+1);
if(num+1>s->dec_maxlength)s->dec_maxlength=num+1;
}
}
break;
case 1:
/* ordered */
{
long length=oggpack_read(opb,5)+1;
s->used_entries=s->entries;
lengthlist=(char *)alloca(sizeof(*lengthlist)*s->entries);
if (!lengthlist) goto _eofout;
for(i=0;i<s->entries;){
long num=oggpack_read(opb,_ilog(s->entries-i));
if(num<0)goto _eofout;
for(j=0;j<num && i<s->entries;j++,i++)
lengthlist[i]=(char)length;
s->dec_maxlength=length;
length++;
}
}
break;
default:
/* EOF */
goto _eofout;
}
/* Do we have a mapping to unpack? */
if((maptype=oggpack_read(opb,4))>0){
s->q_min=_float32_unpack(oggpack_read(opb,32),&s->q_minp);
s->q_del=_float32_unpack(oggpack_read(opb,32),&s->q_delp);
s->q_bits=oggpack_read(opb,4)+1;
s->q_seq=oggpack_read(opb,1);
s->q_del>>=s->q_bits;
s->q_delp+=s->q_bits;
}
switch(maptype){
case 0:
/* no mapping; decode type 0 */
/* how many bytes for the indexing? */
/* this is the correct boundary here; we lose one bit to
node/leaf mark */
s->dec_nodeb=_determine_node_bytes(s->used_entries,_ilog(s->entries)/8+1);
s->dec_leafw=_determine_leaf_words(s->dec_nodeb,_ilog(s->entries)/8+1);
s->dec_type=0;
if(_make_decode_table(s,lengthlist,quantvals,opb,maptype)) goto _errout;
break;
case 1:
/* mapping type 1; implicit values by lattice position */
quantvals=_book_maptype1_quantvals(s);
/* dec_type choices here are 1,2; 3 doesn't make sense */
{
/* packed values */
long total1=(s->q_bits*s->dim+8)/8; /* remember flag bit */
if (s->dim > (INT_MAX-8)/s->q_bits) goto _eofout;
/* vector of column offsets; remember flag bit */
long total2=(_ilog(quantvals-1)*s->dim+8)/8+(s->q_bits+7)/8;
if(total1<=4 && total1<=total2){
/* use dec_type 1: vector of packed values */
/* need quantized values before */
s->q_val=alloca(sizeof(ogg_uint16_t)*quantvals);
if (!s->q_val) goto _eofout;
for(i=0;i<quantvals;i++)
((ogg_uint16_t *)s->q_val)[i]=(ogg_uint16_t)oggpack_read(opb,s->q_bits);
if(oggpack_eop(opb)){
s->q_val=0; /* cleanup must not free alloca memory */
goto _eofout;
}
s->dec_type=1;
s->dec_nodeb=_determine_node_bytes(s->used_entries,
(s->q_bits*s->dim+8)/8);
s->dec_leafw=_determine_leaf_words(s->dec_nodeb,
(s->q_bits*s->dim+8)/8);
if(_make_decode_table(s,lengthlist,quantvals,opb,maptype)){
s->q_val=0; /* cleanup must not free alloca memory */
goto _errout;
}
s->q_val=0; /* about to go out of scope; _make_decode_table
was using it */
}else{
/* use dec_type 2: packed vector of column offsets */
/* need quantized values before */
if(s->q_bits<=8){
s->q_val=_ogg_malloc(quantvals);
if (!s->q_val) goto _eofout;
for(i=0;i<quantvals;i++)
((unsigned char *)s->q_val)[i]=(unsigned char)oggpack_read(opb,s->q_bits);
}else{
s->q_val=_ogg_malloc(quantvals*2);
if (!s->q_val) goto _eofout;
for(i=0;i<quantvals;i++)
((ogg_uint16_t *)s->q_val)[i]=(ogg_uint16_t)oggpack_read(opb,s->q_bits);
}
if(oggpack_eop(opb))goto _eofout;
s->q_pack=_ilog(quantvals-1);
s->dec_type=2;
s->dec_nodeb=_determine_node_bytes(s->used_entries,
(_ilog(quantvals-1)*s->dim+8)/8);
s->dec_leafw=_determine_leaf_words(s->dec_nodeb,
(_ilog(quantvals-1)*s->dim+8)/8);
if(_make_decode_table(s,lengthlist,quantvals,opb,maptype))goto _errout;
}
}
break;
case 2:
/* mapping type 2; explicit array of values */
quantvals=s->entries*s->dim;
/* dec_type choices here are 1,3; 2 is not possible */
if( (s->q_bits*s->dim+8)/8 <=4){ /* remember flag bit */
/* use dec_type 1: vector of packed values */
s->dec_type=1;
s->dec_nodeb=_determine_node_bytes(s->used_entries,(s->q_bits*s->dim+8)/8);
s->dec_leafw=_determine_leaf_words(s->dec_nodeb,(s->q_bits*s->dim+8)/8);
if(_make_decode_table(s,lengthlist,quantvals,opb,maptype))goto _errout;
}else{
/* use dec_type 3: scalar offset into packed value array */
s->dec_type=3;
s->dec_nodeb=_determine_node_bytes(s->used_entries,_ilog(s->used_entries-1)/8+1);
s->dec_leafw=_determine_leaf_words(s->dec_nodeb,_ilog(s->used_entries-1)/8+1);
if(_make_decode_table(s,lengthlist,quantvals,opb,maptype))goto _errout;
/* get the vals & pack them */
s->q_pack=(s->q_bits+7)/8*s->dim;
s->q_val=_ogg_malloc(s->q_pack*s->used_entries);
if(s->q_bits<=8){
for(i=0;i<s->used_entries*s->dim;i++)
((unsigned char *)(s->q_val))[i]=(unsigned char)oggpack_read(opb,s->q_bits);
}else{
for(i=0;i<s->used_entries*s->dim;i++)
((ogg_uint16_t *)(s->q_val))[i]=(ogg_uint16_t)oggpack_read(opb,s->q_bits);
}
}
break;
default:
goto _errout;
}
if (s->dec_nodeb==1)
if (s->dec_leafw == 1)
s->dec_method = 0;
else
s->dec_method = 1;
else if (s->dec_nodeb==2)
if (s->dec_leafw == 1)
s->dec_method = 2;
else
s->dec_method = 3;
else
s->dec_method = 4;
if(oggpack_eop(opb))goto _eofout;
return 0;
_errout:
_eofout:
vorbis_book_clear(s);
return -1;
}
#ifndef ONLY_C
ogg_uint32_t decode_packed_entry_number(codebook *book,
oggpack_buffer *b);
#else
static inline ogg_uint32_t decode_packed_entry_number(codebook *book,
oggpack_buffer *b){
ogg_uint32_t chase=0;
int read=book->dec_maxlength;
long lok = oggpack_look(b,read),i;
while(lok<0 && read>1)
lok = oggpack_look(b, --read);
if(lok<0){
oggpack_adv(b,1); /* force eop */
return -1;
}
/* chase the tree with the bits we got */
switch (book->dec_method)
{
case 0:
{
/* book->dec_nodeb==1, book->dec_leafw==1 */
/* 8/8 - Used */
unsigned char *t=(unsigned char *)book->dec_table;
for(i=0;i<read;i++){
chase=t[chase*2+((lok>>i)&1)];
if(chase&0x80UL)break;
}
chase&=0x7fUL;
break;
}
case 1:
{
/* book->dec_nodeb==1, book->dec_leafw!=1 */
/* 8/16 - Used by infile2 */
unsigned char *t=(unsigned char *)book->dec_table;
for(i=0;i<read;i++){
int bit=(lok>>i)&1;
int next=t[chase+bit];
if(next&0x80){
chase= (next<<8) | t[chase+bit+1+(!bit || t[chase]&0x80)];
break;
}
chase=next;
}
//chase&=0x7fffUL;
chase&=~0x8000UL;
break;
}
case 2:
{
/* book->dec_nodeb==2, book->dec_leafw==1 */
/* 16/16 - Used */
for(i=0;i<read;i++){
chase=((ogg_uint16_t *)(book->dec_table))[chase*2+((lok>>i)&1)];
if(chase&0x8000UL)break;
}
//chase&=0x7fffUL;
chase&=~0x8000UL;
break;
}
case 3:
{
/* book->dec_nodeb==2, book->dec_leafw!=1 */
/* 16/32 - Used by infile2 */
ogg_uint16_t *t=(ogg_uint16_t *)book->dec_table;
for(i=0;i<read;i++){
int bit=(lok>>i)&1;
int next=t[chase+bit];
if(next&0x8000){
chase= (next<<16) | t[chase+bit+1+(!bit || t[chase]&0x8000)];
break;
}
chase=next;
}
//chase&=0x7fffffffUL;
chase&=~0x80000000UL;
break;
}
case 4:
{
//Output("32/32");
for(i=0;i<read;i++){
chase=((ogg_uint32_t *)(book->dec_table))[chase*2+((lok>>i)&1)];
if(chase&0x80000000UL)break;
}
//chase&=0x7fffffffUL;
chase&=~0x80000000UL;
break;
}
}
if(i<read){
oggpack_adv(b,i+1);
return chase;
}
oggpack_adv(b,read+1);
return(-1);
}
#endif
/* returns the [original, not compacted] entry number or -1 on eof *********/
long vorbis_book_decode(codebook *book, oggpack_buffer *b){
if(book->dec_type)return -1;
return decode_packed_entry_number(book,b);
}
#ifndef ONLY_C
int decode_map(codebook *s, oggpack_buffer *b, ogg_int32_t *v, int point);
#else
static int decode_map(codebook *s, oggpack_buffer *b, ogg_int32_t *v, int point){
ogg_uint32_t entry = decode_packed_entry_number(s,b);
int i;
if(oggpack_eop(b))return(-1);
/* 1 used by test file 0 */
/* according to decode type */
switch(s->dec_type){
case 1:{
/* packed vector of values */
int mask=(1<<s->q_bits)-1;
for(i=0;i<s->dim;i++){
v[i]=entry&mask;
entry>>=s->q_bits;
}
break;
}
case 2:{
/* packed vector of column offsets */
int mask=(1<<s->q_pack)-1;
for(i=0;i<s->dim;i++){
if(s->q_bits<=8)
v[i]=((unsigned char *)(s->q_val))[entry&mask];
else
v[i]=((ogg_uint16_t *)(s->q_val))[entry&mask];
entry>>=s->q_pack;
}
break;
}
case 3:{
/* offset into array */
void *ptr=s->q_val+entry*s->q_pack;
if(s->q_bits<=8){
for(i=0;i<s->dim;i++)
v[i]=((unsigned char *)ptr)[i];
}else{
for(i=0;i<s->dim;i++)
v[i]=((ogg_uint16_t *)ptr)[i];
}
break;
}
default:
return -1;
}
/* we have the unpacked multiplicands; compute final vals */
{
int shiftM = point-s->q_delp;
ogg_int32_t add = point-s->q_minp;
int mul = s->q_del;
if(add>0)
add= s->q_min >> add;
else
add= s->q_min << -add;
if (shiftM<0)
{
mul <<= -shiftM;
shiftM = 0;
}
add <<= shiftM;
for(i=0;i<s->dim;i++)
v[i]= ((add + v[i] * mul) >> shiftM);
if(s->q_seq)
for(i=1;i<s->dim;i++)
v[i]+=v[i-1];
}
return 0;
}
#endif
/* returns 0 on OK or -1 on eof *************************************/
long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
int step=n/book->dim;
ogg_int32_t *v = book->dec_buf;//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);
int i,j,o;
if (!v) return -1;
for (j=0;j<step;j++){
if(decode_map(book,b,v,point))return -1;
for(i=0,o=j;i<book->dim;i++,o+=step)
a[o]+=v[i];
}
}
return 0;
}
long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
ogg_int32_t *v = book->dec_buf;//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);
int i,j;
if (!v) return -1;
for(i=0;i<n;){
if(decode_map(book,b,v,point))return -1;
for (j=0;j<book->dim;j++)
a[i++]+=v[j];
}
}
return 0;
}
long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
ogg_int32_t *v = book->dec_buf;//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);
int i,j;
if (!v) return -1;
for(i=0;i<n;){
if(decode_map(book,b,v,point))return -1;
for (j=0;j<book->dim;j++)
a[i++]=v[j];
}
}else{
int i,j;
for(i=0;i<n;){
for (j=0;j<book->dim;j++)
a[i++]=0;
}
}
return 0;
}
#ifndef ONLY_C
long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
long offset,int ch,
oggpack_buffer *b,int n,int point);
#else
long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
long offset,int ch,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
ogg_int32_t *v = book->dec_buf;//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);
long i,j;
int chptr=0;
if (!v) return -1;
for(i=offset;i<offset+n;){
if(decode_map(book,b,v,point))return -1;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=v[j];
if(chptr==ch){
chptr=0;
i++;
}
}
}
}
return 0;
}
#endif

View File

@@ -0,0 +1,69 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: basic shared codebook operations
********************************************************************/
#ifndef _V_CODEBOOK_H_
#define _V_CODEBOOK_H_
#include "ogg.h"
typedef struct codebook{
/* Top 15 used in ARM code */
int dec_maxlength;
void *dec_table;
int dec_method;
int dec_type; /* 0 = entry number
1 = packed vector of values
2 = packed vector of column offsets, maptype 1
3 = scalar offset into value array, maptype 2 */
int q_bits;
long dim; /* codebook dimensions (elements per vector) */
int q_delp;
int q_minp;
ogg_int32_t q_del;
ogg_int32_t q_min;
int q_seq;
int q_pack;
void *q_val;
long used_entries; /* populated codebook entries */
ogg_int32_t *dec_buf;
/* C only */
int dec_nodeb;
int dec_leafw;
long entries; /* codebook entries */
} codebook;
extern void vorbis_book_clear(codebook *b);
extern int vorbis_book_unpack(oggpack_buffer *b,codebook *c);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
long off,int ch,
oggpack_buffer *b,int n,int point);
extern int _ilog(unsigned int v);
#endif

View File

@@ -0,0 +1,213 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: libvorbis codec headers
********************************************************************/
#ifndef _V_CODECI_H_
#define _V_CODECI_H_
#define CHUNKSIZE 1024
#include "codebook.h"
#include "ivorbiscodec.h"
#define VI_TRANSFORMB 1
#define VI_WINDOWB 1
#define VI_TIMEB 1
#define VI_FLOORB 2
#define VI_RESB 3
#define VI_MAPB 1
typedef void vorbis_info_floor;
/* vorbis_dsp_state buffers the current vorbis audio
analysis/synthesis state. The DSP state belongs to a specific
logical bitstream ****************************************************/
struct vorbis_dsp_state{
vorbis_info *vi;
oggpack_buffer opb;
ogg_int32_t **work;
ogg_int32_t **mdctright;
int out_begin;
int out_end;
long lW;
long W;
ogg_int64_t granulepos;
ogg_int64_t sequence;
ogg_int64_t sample_count;
};
/* Floor backend generic *****************************************/
extern vorbis_info_floor *floor0_info_unpack(vorbis_info *,oggpack_buffer *);
extern void floor0_free_info(vorbis_info_floor *);
extern int floor0_memosize(vorbis_info_floor *);
extern ogg_int32_t *floor0_inverse1(struct vorbis_dsp_state *,
vorbis_info_floor *,ogg_int32_t *);
extern int floor0_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
ogg_int32_t *buffer,ogg_int32_t *);
extern vorbis_info_floor *floor1_info_unpack(vorbis_info *,oggpack_buffer *);
extern void floor1_free_info(vorbis_info_floor *);
extern int floor1_memosize(vorbis_info_floor *);
extern ogg_int32_t *floor1_inverse1(struct vorbis_dsp_state *,
vorbis_info_floor *,ogg_int32_t *);
extern int floor1_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
ogg_int32_t *buffer,ogg_int32_t *);
typedef struct{
int order;
long rate;
long barkmap;
int ampbits;
int ampdB;
int numbooks; /* <= 16 */
char books[16];
} vorbis_info_floor0;
typedef struct{
char class_dim; /* 1 to 8 */
char class_subs; /* 0,1,2,3 (bits: 1<<n poss) */
unsigned char class_book; /* subs ^ dim entries */
unsigned char class_subbook[8]; /* [VIF_CLASS][subs] */
} floor1class;
typedef struct{
floor1class *class; /* [VIF_CLASS] */
char *partitionclass; /* [VIF_PARTS]; 0 to 15 */
ogg_uint16_t *postlist; /* [VIF_POSIT+2]; first two implicit */
char *forward_index; /* [VIF_POSIT+2]; */
char *hineighbor; /* [VIF_POSIT]; */
char *loneighbor; /* [VIF_POSIT]; */
int partitions; /* 0 to 31 */
int posts;
int mult; /* 1 2 3 or 4 */
} vorbis_info_floor1;
/* Residue backend generic *****************************************/
typedef struct vorbis_info_residue{
int type;
unsigned char *stagemasks;
unsigned char *stagebooks;
/* block-partitioned VQ coded straight residue */
long begin;
long end;
/* first stage (lossless partitioning) */
int grouping; /* group n vectors per partition */
char partitions; /* possible codebooks for a partition */
unsigned char groupbook; /* huffbook for partitioning */
char stages;
} vorbis_info_residue;
extern void res_clear_info(vorbis_info_residue *info);
extern int res_unpack(vorbis_info_residue *info,
vorbis_info *vi,oggpack_buffer *opb);
extern int res_inverse(vorbis_dsp_state *,vorbis_info_residue *info,
ogg_int32_t **in,int *nonzero,int ch);
/* mode ************************************************************/
typedef struct {
unsigned char blockflag;
unsigned char mapping;
} vorbis_info_mode;
/* Mapping backend generic *****************************************/
typedef struct coupling_step{
unsigned char mag;
unsigned char ang;
} coupling_step;
typedef struct submap{
char floor;
char residue;
} submap;
typedef struct vorbis_info_mapping{
int submaps;
unsigned char *chmuxlist;
submap *submaplist;
int coupling_steps;
coupling_step *coupling;
} vorbis_info_mapping;
extern int mapping_info_unpack(vorbis_info_mapping *,vorbis_info *,
oggpack_buffer *);
extern void mapping_clear_info(vorbis_info_mapping *);
extern int mapping_inverse(struct vorbis_dsp_state *,vorbis_info_mapping *);
/* codec_setup_info contains all the setup information specific to the
specific compression/decompression mode in progress (eg,
psychoacoustic settings, channel setup, options, codebook
etc).
*********************************************************************/
typedef struct codec_setup_info {
/* Vorbis supports only short and long blocks, but allows the
encoder to choose the sizes */
long blocksizes[2];
/* modes are the primary means of supporting on-the-fly different
blocksizes, different channel mappings (LR or M/A),
different residue backends, etc. Each mode consists of a
blocksize flag and a mapping (along with the mapping setup */
int modes;
int maps;
int floors;
int residues;
int books;
vorbis_info_mode *mode_param;
vorbis_info_mapping *map_param;
char *floor_type;
vorbis_info_floor **floor_param;
vorbis_info_residue *residue_param;
codebook *book_param;
} codec_setup_info;
extern vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi);
extern void vorbis_dsp_destroy(vorbis_dsp_state *v);
extern int vorbis_dsp_headerin(vorbis_info *vi,vorbis_comment *vc,
ogg_packet *op);
extern int vorbis_dsp_restart(vorbis_dsp_state *v);
extern int vorbis_dsp_synthesis(vorbis_dsp_state *vd,
ogg_packet *op,int decodep);
extern int vorbis_dsp_pcmout(vorbis_dsp_state *v,
ogg_int16_t *pcm,int samples);
extern int vorbis_dsp_read(vorbis_dsp_state *v,int samples);
extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
#endif

View File

@@ -0,0 +1,26 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal.
********************************************************************/
#ifndef _OS_CVTYPES_H
#define _OS_CVTYPES_H
typedef long long ogg_int64_t;
typedef int ogg_int32_t;
typedef unsigned int ogg_uint32_t;
typedef short ogg_int16_t;
typedef unsigned short ogg_uint16_t;
#endif

View File

@@ -0,0 +1,449 @@
.text
.global decode_packed_entry_number
.global decode_packed_entry_number_REALSTART
.global decode_map
.global vorbis_book_decodevv_add
.global _checksum
decode_packed_entry_number_REALSTART:
dpen_nobits:
MOV r0,r5 @ r0 = b
MOV r1,#1 @ r1 = 1
BL oggpack_adv @ oggpack_adv(b,1) /* Force eop */
duff:
MVN r0,#0 @ return -1
LDMFD r13!,{r4-r8,r10,PC}
dpen_readfailed:
SUBS r4,r4,#1 @ r4 = --read
BEQ dpen_nobits
MOV r0,r5 @ r0 = b
MOV r1,r4 @ r1 = read
ADR r14,dpen_read_return
B oggpack_look
decode_packed_entry_number:
@ r0 = codebook *book
@ r1 = oggpack_buffer *b
STMFD r13!,{r4-r8,r10,r14}
LDMIA r0,{r4,r6,r7} @ r4 = read = book->max_length
@ r6 = book->dec_table
@ r7 = book->dec_method
MOV r5,r1 @ r5 = b
MOV r0,r5 @ r0 = b
MOV r1,r4 @ r1 = read
BL oggpack_look
dpen_read_return:
CMP r0,#0
BLT dpen_readfailed
@ r0 = lok
@ r4 = read
@ r5 = b
@ r6 = dec_table
@ r7 = dec_method
CMP r7, #3
BGT meth4
BEQ meth3
CMP r7, #1
BGT meth2
BEQ meth1
meth0:
RSB r1, r4, #0 @ r1 = i-read = 0-read
MOV r7, #0 @ r7 = chase
m0_loop:
MOVS r0, r0, LSR #1 @ r0 = lok>>1 C = bottom bit
ADC r2, r6, r7, LSL #1 @ r8 = &t[chase*2+C]
LDRB r7, [r2]
ADDS r1, r1, #1 @ r1 = i-read++ (i-read<0 => i<read)
@ stall Xscale
CMPLT r7, #0x80
BLT m0_loop
AND r7, r7, #0x7F @ r7 = chase
CMP r1, #0 @ if (i-read >= 0) === (i >= read)
MVNGT r7, #0 @ if (i >= read) value to return = -1
ADD r1, r1, r4 @ r1 = i-read+read+1 = i +1
MOV r0, r5 @ r0 = b
BL oggpack_adv @ oggpack_adv(b, i+1);
MOV r0, r7 @ return chase
LDMFD r13!,{r4-r8,r10,PC}
meth1:
@ r0 = lok
@ r4 = read
@ r5 = b
@ r6 = dec_table
RSB r1, r4, #0 @ r1 = i = -read
MOV r10,#0 @ r10= next = 0
m1_loop:
MOV r7, r10 @ r7 = chase=next
MOVS r0, r0, LSR #1 @ r0 = lok>>1 C = bottom bit
ADC r8, r6, r7 @ r8 = t+chase+bit
LDRB r10,[r8], -r6 @ r10= next=t[chase+bit] r8=chase+bit
ADDS r1, r1, #1 @ r1 = i++
@ stall Xscale
CMPLT r10,#0x80 @ if (next & 0x80) == 0
BLT m1_loop
ADD r1, r1, r4 @ r1 = i+read
MOV r0, r5 @ r0 = b
BL oggpack_adv @ oggpack_adv(b, i)
CMP r10,#0x80
BLT duff
CMP r8, r7 @ if bit==0 (chase+bit==chase) (sets C)
LDRNEB r14,[r6, r7] @ r14= t[chase]
MOVEQ r14,#128
ADC r12,r8, r6 @ r12= chase+bit+1+t
LDRB r14,[r12,r14,LSR #7] @ r14= t[chase+bit+1+(!bit || t[chase]&0x80)]
BIC r10,r10,#0x80 @ r3 = next &= ~0x80
@ stall Xscale
ORR r0, r14,r10,LSL #8 @ r7 = chase = (next<<8) | r14
LDMFD r13!,{r4-r8,r10,PC}
meth2:
RSB r1, r4, #0 @ r1 = i-read = 0-read
MOV r7, #0 @ r7 = chase
MOV r6, r6, LSR #1
m2_loop:
MOVS r0, r0, LSR #1 @ r0 = lok>>1 C = bottom bit
ADC r2, r6, r7, LSL #1 @ r8 = &t[chase*2+C]
LDRH r7, [r2, r2]
ADDS r1, r1, #1 @ r1 = i-read++ (i-read<0 => i<read)
@ stall Xscale
CMPLT r7, #0x8000
BLT m2_loop
BIC r7, r7, #0x8000 @ r7 = chase
CMP r1, #0 @ if (i-read >= 0) === (i >= read)
MVNGT r7, #0 @ if (i >= read) value to return = -1
ADD r1, r1, r4 @ r1 = i-read+read+1 = i +1
MOV r0, r5 @ r0 = b
BL oggpack_adv @ oggpack_adv(b, i+1);
MOV r0, r7 @ return chase
LDMFD r13!,{r4-r8,r10,PC}
meth3:
@ r0 = lok
@ r4 = read
@ r5 = b
@ r6 = dec_table
RSB r1, r4, #0 @ r1 = i = -read
MOV r10,#0 @ r10= next = 0
m3_loop:
MOV r7, r10 @ r7 = chase=next
MOVS r0, r0, LSR #1 @ r0 = lok>>1 C = bottom bit
ADC r8, r7, #0 @ r8 = chase+bit
MOV r8, r8, LSL #1 @ r8 = (chase+bit)<<1
LDRH r10,[r6, r8] @ r10= next=t[chase+bit]
ADDS r1, r1, #1 @ r1 = i++
@ stall Xscale
CMPLT r10,#0x8000 @ if (next & 0x8000) == 0
BLT m3_loop
ADD r1, r1, r4 @ r1 = i+read
MOV r0, r5 @ r0 = b
BL oggpack_adv @ oggpack_adv(b, i)
CMP r10,#0x8000
BLT duff
MOV r7, r7, LSL #1
CMP r8, r7 @ if bit==0 (chase+bit==chase) sets C
LDRNEH r14,[r6, r7] @ r14= t[chase]
MOVEQ r14,#0x8000
ADC r12,r8, r14,LSR #15 @ r12= 1+((chase+bit)<<1)+(!bit || t[chase]&0x8000)
ADC r12,r12,r14,LSR #15 @ r12= t + (1+chase+bit+(!bit || t[chase]&0x8000))<<1
LDRH r14,[r6, r12] @ r14= t[chase+bit+1
BIC r10,r10,#0x8000 @ r3 = next &= ~0x8000
@ stall Xscale
ORR r0, r14,r10,LSL #16 @ r7 = chase = (next<<16) | r14
LDMFD r13!,{r4-r8,r10,PC}
meth4:
RSB r1, r4, #0 @ r1 = i-read = 0-read
MOV r7, #0 @ r7 = chase
m4_loop:
MOVS r0, r0, LSR #1 @ r0 = lok>>1 C = bottom bit
ADC r2, r7, r7 @ r8 = chase*2+C
LDR r7, [r6, r2, LSL#2]
ADDS r1, r1, #1 @ r1 = i-read++ (i-read<0 => i<read)
@ stall Xscale
CMPLT r7, #0x80000000
BLT m4_loop
BIC r7, r7, #0x80000000 @ r7 = chase
CMP r1, #0 @ if (i-read >= 0) === (i >= read)
MVNGT r7, #0 @ if (i >= read) value to return = -1
ADD r1, r1, r4 @ r1 = i-read+read+1 = i +1
MOV r0, r5 @ r0 = b
BL oggpack_adv @ oggpack_adv(b, i+1);
MOV r0, r7 @ return chase
LDMFD r13!,{r4-r8,r10,PC}
decode_map:
@ r0 = codebook *s
@ r1 = oggpack_buffer *b
@ r2 = int v
@ r3 = int point
STMFD r13!,{r4-r11,r14}
MOV r4, r0 @ r4 = s
MOV r5, r1 @ r5 = b
MOV r6, r2 @ r6 = v
MOV r7, r3 @ r7 = point
BL decode_packed_entry_number
MOV r8, r0
MOV r0, r5
BL oggpack_eop
CMP r0, #0
BNE dm_duff
@ r4 = s
@ r5 = b
@ r6 = v
@ r7 = point
@ r8 = entry
LDR r1, [r4,#12] @ r1 = s->dec_type
LDR r2, [r4,#16] @ r2 = s->q_bits
LDR r3, [r4,#20] @ r3 = s->dim
LDR r5, [r4,#24] @ r5 = s->q_delp
LDR r11,[r4,#28] @ r11= s->q_minp
LDR r12,[r4,#32] @ r12= s->q_del = mul
LDR r14,[r4,#36] @ r14= s->q_min
SUBS r11,r7, r11 @ r11= add = point - s->q_minp
MOVGT r14,r14,ASR r11 @ r14= add = s->q_min >> add (if add >0)
RSBLT r11,r11,#0
MOVLT r14,r14,LSL r11 @ r14= add = s->q_min << -add (if add < 0)
SUBS r5, r7, r5 @ r5 = shiftM = point - s->q_delp
LDR r7, [r4,#40] @ r7 = s->q_seq
RSBLT r5, r5, #0 @ if (shiftM<0) r5 =-shiftM
MOVLT r12,r12,LSL r5 @ r12=mul<<-shiftM
MOVLT r5, #0 @ r5 =shiftM = 0
MOVGT r14,r14,LSL r5 @ add <<= shiftM
CMP r7,#0 @ seqMask = (s->q_seq?-1:0)
MVNNE r7,#0
CMP r1, #2
BEQ dm2
BGT dm3
CMP r1,#0 @ probably never happens
BLE dm_duff
dm1:
@ r1 = s->dec_type
@ r2 = s->q_bits
@ r3 = s->dim
@ r5 = shiftM
@ r6 = v
@ r7 = seqMask
@ r8 = entry
@ r12= mul
@ r14= add
MOV r0, #1
RSB r0, r0, r0, LSL r2 @ r0 = mask = (1<<s->q_bits)-1
MOV r11,#0 @ r11= prev = 0
dm1_loop:
AND r1, r8, r0 @ r1 = v = entry & mask
MLA r1, r12, r1, r14 @ r1 = (add + mul*v)
MOV r8, r8, LSR r2 @ r8 = entry>>s->q_bits
SUBS r3, r3, #1
ADD r1, r11,r1, ASR r5 @ r1 = v = prev+((add+mul*v)>>shiftM)
AND r11,r1, r7 @ r11= prev = seqMask & v
STR r1, [r6], #4 @ *v++ = v
BGT dm1_loop
MOV r0, #0
LDMFD r13!,{r4-r11,PC}
dm2:
@ r1 = s->dec_type
@ r2 = s->q_bits
@ r3 = s->dim
@ r4 = s
@ r5 = shiftM
@ r6 = v
@ r7 = seqMask
@ r8 = entry
@ r12= mul
@ r14= add
LDR r1, [r4,#44] @ r1 = s->q_pack
LDR r4, [r4,#48] @ r4 = s->q_val
MOV r11,#0 @ r11= prev
MOV r0, #1
RSB r0, r0, r0, LSL r1 @ r8 = mask = (1<<s->q_pack)-1
CMP r2,#8
BGT dm2_hword
dm2_loop:
AND r2, r8, r0 @ r2 = entry & mask
LDRB r2, [r4, r2] @ r2 = v = q->val[entry & mask]
MOV r8, r8, LSR r1 @ r8 = entry>>q_pack
MLA r2, r12,r2, r14 @ r2 = (add+mul*v)
SUBS r3, r3, #1
ADD r2, r11,r2, ASR r5 @ r2 = v = prev+(add+mul*v)>>shiftM
AND r11,r2, r7 @ r11= prev = seqMask & v
STR r2, [r6], #4 @ *v++ = v
BGT dm2_loop
MOV r0, #0
LDMFD r13!,{r4-r11,PC}
dm2_hword:
AND r2, r8, r0 @ r2 = entry & mask
MOV r2, r2, LSL #1 @ r2 = 2*r2
LDRH r2, [r4, r2] @ r2 = v = q->val[entry & mask]
MOV r8, r8, LSR r1 @ r8 = entry>>q_pack
MLA r2, r12,r2, r14 @ r2 = (add+mul*v)
SUBS r3, r3, #1
ADD r2, r11,r2, ASR r5 @ r2 = v = prev+(add+mul*v)>>shiftM
AND r11,r2, r7 @ r11= prev = seqMask & v
STR r2, [r6], #4 @ *v++ = v
BGT dm2_hword
MOV r0, #0
LDMFD r13!,{r4-r11,PC}
dm3:
@ r1 = s->dec_type
@ r2 = s->q_bits
@ r3 = s->dim
@ r4 = s
@ r5 = shiftM
@ r6 = v
@ r7 = seqMask
@ r8 = entry
@ r12= mul
@ r14= add
LDR r1, [r4,#44] @ r1 = s->q_pack
LDR r4, [r4,#52] @ r4 = s->q_val
CMP r2,#8
MOV r11,#0 @ r11= prev
MLA r4,r1,r8,r4 @ r4 = ptr = s->q_val+entry*s->q_pack
BGT dm3_hword
dm3_loop:
LDRB r2, [r4], #1 @ r2 = v = *ptr++
SUBS r3, r3, #1
MLA r2, r12,r2, r14 @ r2 = (add+mul*v)
ADD r2, r11,r2, ASR r5 @ r2 = v = prev+(add+mul*v)>>shiftM
AND r11,r2, r7 @ r11= prev = seqMask & v
STR r2, [r6], #4 @ *v++ = v
BGT dm3_loop
MOV r0, #0
LDMFD r13!,{r4-r11,PC}
dm3_hword:
LDRH r2, [r4], #2 @ r2 = *ptr++
SUBS r3, r3, #1
MLA r2, r12,r2, r14 @ r2 = (add+mul*v)
ADD r2, r11,r2, ASR r5 @ r2 = v = prev+(add+mul*v)>>shiftM
AND r11,r2, r7 @ r11= prev = seqMask & v
STR r2, [r6], #4 @ *v++ = v
BGT dm3_hword
MOV r0, #0
LDMFD r13!,{r4-r11,PC}
dm_duff:
MVN r0,#0
LDMFD r13!,{r4-r11,PC}
vorbis_book_decodevv_add:
@ r0 = codebook *book
@ r1 = ogg_int32_t **a
@ r2 = long offset
@ r3 = int ch
@ <> = b
@ <> = n
@ <> = point
STMFD r13!,{r4-r11,R14}
LDR r7, [r0, #13*4] @ r7 = used_entries
MOV r9, r0 @ r9 = book
MOV r10,r1 @ r10= &a[chptr] chptr=0
MOV r6, r3 @ r6 = ch
ADD r8, r10,r3, LSL #2 @ r8 = &a[ch]
MOV r11,r2 @ r11= offset
CMP r7, #0 @ if (used_entries <= 0)
BLE vbdvva_exit @ exit
LDR r5, [r13,#10*4] @ r5 = n
vbdvva_loop1:
@ r5 = n
@ r6 = ch
@ r8 = &a[ch]
@ r9 = book
@ r10= &a[chptr]
@ r11= offset
MOV r0, r9 @ r0 = book
LDR r1, [r13,# 9*4] @ r1 = b
LDR r2, [r9, #14*4] @ r2 = v = dec_buf
LDR r3, [r13,#11*4] @ r3 = point
BL decode_map
CMP r0, #0
BNE vbdvva_fail
LDR r0, [r9, # 5*4] @ r0 = book->dim
LDR r1, [r9, #14*4] @ r1 = v = dec_buf
vbdvva_loop2:
LDR r2, [r10],#4 @ r2 = a[chptr++]
LDR r12,[r1], #4 @ r1 = v[j++]
CMP r10,r8 @ if (chptr == ch)
SUBEQ r10,r10,r6, LSL #2 @ chptr = 0
LDR r14,[r2, r11,LSL #2]! @ r2 = &a[chptr++][i] r14=[r12]
ADDEQ r11,r11,#1 @ i++
SUBEQ r5, r5, #1 @ n--
SUBS r0, r0, #1 @ r0--
ADD r12,r12,r14 @ r12= a[chptr++][i]+ v[j]
STR r12,[r2] @ r12= a[chptr++][i]+=v[j]
BGT vbdvva_loop2
CMP r5,#0
BGT vbdvva_loop1
vbdvva_exit:
MOV r0, #0 @ return 0
LDMFD r13!,{r4-r11,PC}
vbdvva_fail:
MVN r0, #0 @ return -1
LDMFD r13!,{r4-r11,PC}
_checksum:
@ r0 = ogg_reference *or
@ r1 = bytes
STMFD r13!,{r5-r6,r14}
LDR r5,=crc_lookup
MOV r14,#0 @ r14= crc_reg = 0
MOVS r12,r0
BEQ _cs_end
_cs_loop1:
LDMIA r12,{r0,r2,r3,r12} @ r0 = or->buffer
@ r2 = or->begin
@ r3 = or->length
@ r12= or->next
LDR r0,[r0] @ r0 = or->buffer->data
CMP r1,r3 @ r3 = post = (bytes < or->length ?
MOVLT r3,r1 @ bytes : or->length)
MOVS r6,r3 @ r6 = j = post
BEQ _cs_no_bytes
ADD r0,r0,r2 @ r0 = or->buffer->data + or->begin
_cs_loop2:
LDRB r2, [r0],#1 @ r2 = data[j]
@ stall
@ stall Xscale
EOR r2, r2, r14,LSR #24 @ r2 = (crc_reg>>24)^data[j]
LDR r2, [r5, r2, LSL #2] @ r2 = crc_lkp[(crc_reg>>24)^data[j]]
SUBS r6, r6, #1 @ j--
@ stall Xscale
EOR r14,r2, r14,LSL #8 @ r14= crc_reg = (crc_reg<<8)^r2
BGT _cs_loop2
_cs_no_bytes:
SUBS r1, r1, r3
CMPNE r12,#0
BNE _cs_loop1
_cs_end:
MOV r0,r14
LDMFD r13!,{r5-r6,PC}

View File

@@ -0,0 +1,298 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
********************************************************************/
#include <stdlib.h>
#include "ogg.h"
#include "mdct.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
#include "misc.h"
#include "window_lookup.h"
int vorbis_dsp_restart(vorbis_dsp_state *v){
if(!v)return -1;
{
vorbis_info *vi=v->vi;
codec_setup_info *ci;
if(!vi)return -1;
ci=vi->codec_setup;
if(!ci)return -1;
v->out_end=-1;
v->out_begin=-1;
v->granulepos=-1;
v->sequence=-1;
v->sample_count=-1;
}
return 0;
}
vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi){
int i;
vorbis_dsp_state *v=_ogg_calloc(1,sizeof(*v));
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
v->vi=vi;
v->work=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->work));
v->mdctright=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->mdctright));
for(i=0;i<vi->channels;i++){
v->work[i]=(ogg_int32_t *)_ogg_calloc(1,(ci->blocksizes[1]>>1)*
sizeof(*v->work[i]));
v->mdctright[i]=(ogg_int32_t *)_ogg_calloc(1,(ci->blocksizes[1]>>2)*
sizeof(*v->mdctright[i]));
}
v->lW=0; /* previous window size */
v->W=0; /* current window size */
vorbis_dsp_restart(v);
return v;
}
void vorbis_dsp_destroy(vorbis_dsp_state *v){
int i;
if(v){
vorbis_info *vi=v->vi;
if(v->work){
for(i=0;i<vi->channels;i++)
if(v->work[i])_ogg_free(v->work[i]);
_ogg_free(v->work);
}
if(v->mdctright){
for(i=0;i<vi->channels;i++)
if(v->mdctright[i])_ogg_free(v->mdctright[i]);
_ogg_free(v->mdctright);
}
_ogg_free(v);
}
}
static LOOKUP_T *_vorbis_window(int left){
switch(left){
case 32:
return vwin64;
case 64:
return vwin128;
case 128:
return vwin256;
case 256:
return vwin512;
case 512:
return vwin1024;
case 1024:
return vwin2048;
case 2048:
return vwin4096;
#ifndef LIMIT_TO_64kHz
case 4096:
return vwin8192;
#endif
default:
return(0);
}
}
/* pcm==0 indicates we just want the pending samples, no more */
int vorbis_dsp_pcmout(vorbis_dsp_state *v,ogg_int16_t *pcm,int samples){
vorbis_info *vi=v->vi;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
if(v->out_begin>-1 && v->out_begin<v->out_end){
int n=v->out_end-v->out_begin;
if(pcm){
int i;
if(n>samples)n=samples;
for(i=0;i<vi->channels;i++)
mdct_unroll_lap(ci->blocksizes[0],ci->blocksizes[1],
v->lW,v->W,v->work[i],v->mdctright[i],
_vorbis_window(ci->blocksizes[0]>>1),
_vorbis_window(ci->blocksizes[1]>>1),
pcm+i,vi->channels,
v->out_begin,v->out_begin+n);
}
return(n);
}
return(0);
}
int vorbis_dsp_read(vorbis_dsp_state *v,int s){
if(s && v->out_begin+s>v->out_end)return(OV_EINVAL);
v->out_begin+=s;
return(0);
}
long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
oggpack_buffer opb;
int mode;
int modebits=0;
int v=ci->modes;
oggpack_readinit(&opb,op->packet);
/* Check the packet type */
if(oggpack_read(&opb,1)!=0){
/* Oops. This is not an audio data packet */
return(OV_ENOTAUDIO);
}
while(v>1){
modebits++;
v>>=1;
}
/* read our mode and pre/post windowsize */
mode=oggpack_read(&opb,modebits);
if(mode==-1)return(OV_EBADPACKET);
return(ci->blocksizes[ci->mode_param[mode].blockflag]);
}
static int ilog(ogg_uint32_t v){
int ret=0;
if(v)--v;
while(v){
ret++;
v>>=1;
}
return(ret);
}
int vorbis_dsp_synthesis(vorbis_dsp_state *vd,ogg_packet *op,int decodep){
vorbis_info *vi=vd->vi;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int mode,i;
oggpack_readinit(&vd->opb,op->packet);
/* Check the packet type */
if(oggpack_read(&vd->opb,1)!=0){
/* Oops. This is not an audio data packet */
return OV_ENOTAUDIO ;
}
/* read our mode and pre/post windowsize */
mode=oggpack_read(&vd->opb,ilog(ci->modes));
if(mode==-1 || mode>=ci->modes) return OV_EBADPACKET;
/* shift information we still need from last window */
vd->lW=vd->W;
vd->W=ci->mode_param[mode].blockflag;
for(i=0;i<vi->channels;i++)
mdct_shift_right(ci->blocksizes[vd->lW],vd->work[i],vd->mdctright[i]);
if(vd->W){
int temp;
oggpack_read(&vd->opb,1);
temp=oggpack_read(&vd->opb,1);
if(temp==-1) return OV_EBADPACKET;
}
/* packet decode and portions of synthesis that rely on only this block */
if(decodep){
mapping_inverse(vd,ci->map_param+ci->mode_param[mode].mapping);
if(vd->out_begin==-1){
vd->out_begin=0;
vd->out_end=0;
}else{
vd->out_begin=0;
vd->out_end=ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
}
}
/* track the frame number... This is for convenience, but also
making sure our last packet doesn't end with added padding.
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 we're out of sequence, dump granpos tracking until we sync back up */
if(vd->sequence==-1 || vd->sequence+1 != op->packetno-3){
/* out of sequence; lose count */
vd->granulepos=-1;
vd->sample_count=-1;
}
vd->sequence=op->packetno;
vd->sequence=vd->sequence-3;
if(vd->sample_count==-1){
vd->sample_count=0;
}else{
vd->sample_count+=
ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
}
if(vd->granulepos==-1){
if(op->granulepos!=-1){ /* only set if we have a
position to set to */
vd->granulepos=op->granulepos;
/* is this a short page? */
if(vd->sample_count>vd->granulepos){
/* corner case; if this is both the first and last audio page,
then spec says the end is cut, not beginning */
if(op->e_o_s){
/* trim the end */
/* no preceeding granulepos; assume we started at zero (we'd
have to in a short single-page stream) */
/* granulepos could be -1 due to a seek, but that would result
in a long coun t, not short count */
vd->out_end-=vd->sample_count-vd->granulepos;
}else{
/* trim the beginning */
vd->out_begin+=vd->sample_count-vd->granulepos;
if(vd->out_begin>vd->out_end)
vd->out_begin=vd->out_end;
}
}
}
}else{
vd->granulepos+=
ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
if(op->granulepos!=-1 && vd->granulepos!=op->granulepos){
if(vd->granulepos>op->granulepos){
long extra=vd->granulepos-op->granulepos;
if(extra)
if(op->e_o_s){
/* partial last frame. Strip the extra samples off */
vd->out_end-=extra;
} /* else {Shouldn't happen *unless* the bitstream is out of
spec. Either way, believe the bitstream } */
} /* else {Shouldn't happen *unless* the bitstream is out of
spec. Either way, believe the bitstream } */
vd->granulepos=op->granulepos;
}
}
return(0);
}

View File

@@ -0,0 +1,428 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: floor backend 0 implementation
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
#include "codebook.h"
#include "misc.h"
#include "os.h"
#define LSP_FRACBITS 14
extern const ogg_int32_t FLOOR_fromdB_LOOKUP[];
/*************** LSP decode ********************/
#include "lsp_lookup.h"
/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in
16.16 format
returns in m.8 format */
static long ADJUST_SQRT2[2]={8192,5792};
static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1);
long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */
long val=INVSQ_LOOKUP_I[i]- /* 1.16 */
((INVSQ_LOOKUP_IDel[i]*d)>>INVSQ_LOOKUP_I_SHIFT); /* result 1.16 */
val*=ADJUST_SQRT2[e&1];
e=(e>>1)+21;
return(val>>e);
}
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */
/* a is in n.12 format */
#ifdef _LOW_ACCURACY_
static inline ogg_int32_t vorbis_fromdBlook_i(long a){
if(a>0) return 0x7fffffff;
if(a<(-140<<12)) return 0;
return FLOOR_fromdB_LOOKUP[((a+140)*467)>>20]<<9;
}
#else
static inline ogg_int32_t vorbis_fromdBlook_i(long a){
if(a>0) return 0x7fffffff;
if(a<(-140<<12)) return 0;
return FLOOR_fromdB_LOOKUP[((a+(140<<12))*467)>>20];
}
#endif
/* interpolated lookup based cos function, domain 0 to PI only */
/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */
static inline ogg_int32_t vorbis_coslook_i(long a){
int i=a>>COS_LOOKUP_I_SHIFT;
int d=a&COS_LOOKUP_I_MASK;
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
COS_LOOKUP_I_SHIFT);
}
/* interpolated half-wave lookup based cos function */
/* a is in 0.16 format, where 0==0, 2^^16==PI, return .LSP_FRACBITS */
static inline ogg_int32_t vorbis_coslook2_i(long a){
int i=a>>COS_LOOKUP_I_SHIFT;
int d=a&COS_LOOKUP_I_MASK;
return ((COS_LOOKUP_I[i]<<COS_LOOKUP_I_SHIFT)-
d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
(COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14);
}
static const ogg_uint16_t barklook[54]={
0,51,102,154, 206,258,311,365,
420,477,535,594, 656,719,785,854,
926,1002,1082,1166, 1256,1352,1454,1564,
1683,1812,1953,2107, 2276,2463,2670,2900,
3155,3440,3756,4106, 4493,4919,5387,5901,
6466,7094,7798,8599, 9528,10623,11935,13524,
15453,17775,20517,23667, 27183,31004
};
/* used in init only; interpolate the long way */
static inline ogg_int32_t toBARK(int n){
int i;
for(i=0;i<54;i++)
if(n>=barklook[i] && n<barklook[i+1])break;
if(i==54){
return 54<<14;
}else{
return (i<<14)+(((n-barklook[i])*
((1UL<<31)/(barklook[i+1]-barklook[i])))>>17);
}
}
static const unsigned char MLOOP_1[64]={
0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
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,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
};
static const unsigned char MLOOP_2[64]={
0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
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,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
};
static const unsigned char MLOOP_3[8]={0,1,2,2,3,3,3,3};
void vorbis_lsp_to_curve(ogg_int32_t *curve,int n,int ln,
ogg_int32_t *lsp,int m,
ogg_int32_t amp,
ogg_int32_t ampoffset,
ogg_int32_t nyq){
/* 0 <= m < 256 */
/* set up for using all int later */
int i;
int ampoffseti=ampoffset*4096;
int ampi=amp;
ogg_int32_t *ilsp=(ogg_int32_t *)alloca(m*sizeof(*ilsp));
ogg_uint32_t inyq= (1UL<<31) / toBARK(nyq);
ogg_uint32_t imap= (1UL<<31) / ln;
ogg_uint32_t tBnyq1 = toBARK(nyq)<<1;
/* Besenham for frequency scale to avoid a division */
int f=0;
int fdx=n;
int fbase=nyq/fdx;
int ferr=0;
int fdy=nyq-fbase*fdx;
int map=0;
#ifdef _LOW_ACCURACY_
ogg_uint32_t nextbark=((tBnyq1<<11)/ln)>>12;
#else
ogg_uint32_t nextbark=MULT31(imap>>1,tBnyq1);
#endif
int nextf=barklook[nextbark>>14]+(((nextbark&0x3fff)*
(barklook[(nextbark>>14)+1]-barklook[nextbark>>14]))>>14);
/* lsp is in 8.24, range 0 to PI; coslook wants it in .16 0 to 1*/
for(i=0;i<m;i++){
#ifndef _LOW_ACCURACY_
ogg_int32_t val=MULT32(lsp[i],0x517cc2);
#else
ogg_int32_t val=((lsp[i]>>10)*0x517d)>>14;
#endif
/* safeguard against a malicious stream */
if(val<0 || (val>>COS_LOOKUP_I_SHIFT)>=COS_LOOKUP_I_SZ){
memset(curve,0,sizeof(*curve)*n);
return;
}
ilsp[i]=vorbis_coslook_i(val);
}
i=0;
while(i<n){
int j;
ogg_uint32_t pi=46341; /* 2**-.5 in 0.16 */
ogg_uint32_t qi=46341;
ogg_int32_t qexp=0,shift;
ogg_int32_t wi;
wi=vorbis_coslook2_i((map*imap)>>15);
#ifdef _V_LSP_MATH_ASM
lsp_loop_asm(&qi,&pi,&qexp,ilsp,wi,m);
pi=((pi*pi)>>16);
qi=((qi*qi)>>16);
if(m&1){
qexp= qexp*2-28*((m+1)>>1)+m;
pi*=(1<<14)-((wi*wi)>>14);
qi+=pi>>14;
}else{
qexp= qexp*2-13*m;
pi*=(1<<14)-wi;
qi*=(1<<14)+wi;
qi=(qi+pi)>>14;
}
if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */
qi>>=1; qexp++;
}else
lsp_norm_asm(&qi,&qexp);
#else
qi*=labs(ilsp[0]-wi);
pi*=labs(ilsp[1]-wi);
for(j=3;j<m;j+=2){
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
qi=(qi>>shift)*labs(ilsp[j-1]-wi);
pi=(pi>>shift)*labs(ilsp[j]-wi);
qexp+=shift;
}
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
/* pi,qi normalized collectively, both tracked using qexp */
if(m&1){
/* odd order filter; slightly assymetric */
/* the last coefficient */
qi=(qi>>shift)*labs(ilsp[j-1]-wi);
pi=(pi>>shift)<<14;
qexp+=shift;
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
pi>>=shift;
qi>>=shift;
qexp+=shift-14*((m+1)>>1);
pi=((pi*pi)>>16);
qi=((qi*qi)>>16);
qexp=qexp*2+m;
pi*=(1<<14)-((wi*wi)>>14);
qi+=pi>>14;
}else{
/* even order filter; still symmetric */
/* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
worth tracking step by step */
pi>>=shift;
qi>>=shift;
qexp+=shift-7*m;
pi=((pi*pi)>>16);
qi=((qi*qi)>>16);
qexp=qexp*2+m;
pi*=(1<<14)-wi;
qi*=(1<<14)+wi;
qi=(qi+pi)>>14;
}
/* we've let the normalization drift because it wasn't important;
however, for the lookup, things must be normalized again. We
need at most one right shift or a number of left shifts */
if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */
qi>>=1; qexp++;
}else
while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
qi<<=1; qexp--;
}
#endif
amp=vorbis_fromdBlook_i(ampi* /* n.4 */
vorbis_invsqlook_i(qi,qexp)-
/* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */
#ifdef _LOW_ACCURACY_
amp>>=9;
#endif
curve[i]= MULT31_SHIFT15(curve[i],amp);
while(++i<n){
/* line plot to get new f */
ferr+=fdy;
if(ferr>=fdx){
ferr-=fdx;
f++;
}
f+=fbase;
if(f>=nextf)break;
curve[i]= MULT31_SHIFT15(curve[i],amp);
}
while(1){
map++;
if(map+1<ln){
#ifdef _LOW_ACCURACY_
nextbark=((tBnyq1<<11)/ln*(map+1))>>12;
#else
nextbark=MULT31((map+1)*(imap>>1),tBnyq1);
#endif
nextf=barklook[nextbark>>14]+
(((nextbark&0x3fff)*
(barklook[(nextbark>>14)+1]-barklook[nextbark>>14]))>>14);
if(f<=nextf)break;
}else{
nextf=9999999;
break;
}
}
if(map>=ln){
map=ln-1; /* guard against the approximation */
nextf=9999999;
}
}
}
/*************** vorbis decode glue ************/
void floor0_free_info(vorbis_info_floor *i){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
if(info)_ogg_free(info);
}
vorbis_info_floor *floor0_info_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int j;
vorbis_info_floor0 *info=(vorbis_info_floor0 *)_ogg_malloc(sizeof(*info));
info->order=oggpack_read(opb,8);
info->rate=oggpack_read(opb,16);
info->barkmap=oggpack_read(opb,16);
info->ampbits=oggpack_read(opb,6);
info->ampdB=oggpack_read(opb,8);
info->numbooks=oggpack_read(opb,4)+1;
if(info->order<1)goto err_out;
if(info->rate<1)goto err_out;
if(info->barkmap<1)goto err_out;
for(j=0;j<info->numbooks;j++){
info->books[j]=oggpack_read(opb,8);
if(info->books[j]>=ci->books)goto err_out;
}
if(oggpack_eop(opb))goto err_out;
return(info);
err_out:
floor0_free_info(info);
return(NULL);
}
int floor0_memosize(vorbis_info_floor *i){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
return info->order+1;
}
ogg_int32_t *floor0_inverse1(vorbis_dsp_state *vd,vorbis_info_floor *i,
ogg_int32_t *lsp){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
int j,k;
int ampraw=oggpack_read(&vd->opb,info->ampbits);
if(ampraw>0){ /* also handles the -1 out of data case */
long maxval=(1<<info->ampbits)-1;
int amp=((ampraw*info->ampdB)<<4)/maxval;
int booknum=oggpack_read(&vd->opb,_ilog(info->numbooks));
if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */
codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
codebook *b=ci->book_param+info->books[booknum];
ogg_int32_t last=0;
for(j=0;j<info->order;j+=b->dim)
if(vorbis_book_decodev_set(b,lsp+j,&vd->opb,b->dim,-24)==-1)goto eop;
for(j=0;j<info->order;){
for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1];
}
lsp[info->order]=amp;
return(lsp);
}
}
eop:
return(NULL);
}
int floor0_inverse2(vorbis_dsp_state *vd,vorbis_info_floor *i,
ogg_int32_t *lsp,ogg_int32_t *out){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
if(lsp){
ogg_int32_t amp=lsp[info->order];
/* take the coefficients back to a spectral envelope curve */
vorbis_lsp_to_curve(out,ci->blocksizes[vd->W]/2,info->barkmap,
lsp,info->order,amp,info->ampdB,
info->rate>>1);
return(1);
}
memset(out,0,sizeof(*out)*ci->blocksizes[vd->W]/2);
return(0);
}

View File

@@ -0,0 +1,382 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: floor backend 1 implementation
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
#include "codebook.h"
#include "misc.h"
extern const ogg_int32_t FLOOR_fromdB_LOOKUP[];
#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
#define VIF_POSIT 63
/***********************************************/
void floor1_free_info(vorbis_info_floor *i){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
if(info){
if(info->class)_ogg_free(info->class);
if(info->partitionclass)_ogg_free(info->partitionclass);
if(info->postlist)_ogg_free(info->postlist);
if(info->forward_index)_ogg_free(info->forward_index);
if(info->hineighbor)_ogg_free(info->hineighbor);
if(info->loneighbor)_ogg_free(info->loneighbor);
memset(info,0,sizeof(*info));
_ogg_free(info);
}
}
static int ilog(unsigned int v){
int ret=0;
while(v){
ret++;
v>>=1;
}
return(ret);
}
static void mergesort(char *index,ogg_uint16_t *vals,ogg_uint16_t n){
ogg_uint16_t i,j;
char *temp,*A=index,*B=_ogg_malloc(n*sizeof(*B));
for(i=1;i<n;i<<=1){
for(j=0;j+i<n;){
int k1=j;
int mid=j+i;
int k2=mid;
int end=(j+i*2<n?j+i*2:n);
while(k1<mid && k2<end){
if(vals[A[k1]]<vals[A[k2]])
B[j++]=A[k1++];
else
B[j++]=A[k2++];
}
while(k1<mid) B[j++]=A[k1++];
while(k2<end) B[j++]=A[k2++];
}
for(;j<n;j++)B[j]=A[j];
temp=A;A=B;B=temp;
}
if(B==index){
for(j=0;j<n;j++)B[j]=A[j];
_ogg_free(A);
}else
_ogg_free(B);
}
vorbis_info_floor *floor1_info_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int j,k,count=0,maxclass=-1,rangebits;
vorbis_info_floor1 *info=(vorbis_info_floor1 *)_ogg_calloc(1,sizeof(*info));
/* read partitions */
info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
info->partitionclass=
(char *)_ogg_malloc(info->partitions*sizeof(*info->partitionclass));
for(j=0;j<info->partitions;j++){
info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */
if(maxclass<info->partitionclass[j])maxclass=info->partitionclass[j];
}
/* read partition classes */
info->class=
(floor1class *)_ogg_malloc((maxclass+1)*sizeof(*info->class));
for(j=0;j<maxclass+1;j++){
info->class[j].class_dim=oggpack_read(opb,3)+1; /* 1 to 8 */
info->class[j].class_subs=oggpack_read(opb,2); /* 0,1,2,3 bits */
if(oggpack_eop(opb)<0) goto err_out;
if(info->class[j].class_subs)
info->class[j].class_book=oggpack_read(opb,8);
else
info->class[j].class_book=0;
if(info->class[j].class_book>=ci->books)goto err_out;
for(k=0;k<(1<<info->class[j].class_subs);k++){
info->class[j].class_subbook[k]=oggpack_read(opb,8)-1;
if(info->class[j].class_subbook[k]>=ci->books &&
info->class[j].class_subbook[k]!=0xff)goto err_out;
}
}
/* read the post list */
info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */
rangebits=oggpack_read(opb,4);
for(j=0,k=0;j<info->partitions;j++)
count+=info->class[info->partitionclass[j]].class_dim;
info->postlist=
(ogg_uint16_t *)_ogg_malloc((count+2)*sizeof(*info->postlist));
info->forward_index=
(char *)_ogg_malloc((count+2)*sizeof(*info->forward_index));
info->loneighbor=
(char *)_ogg_malloc(count*sizeof(*info->loneighbor));
info->hineighbor=
(char *)_ogg_malloc(count*sizeof(*info->hineighbor));
count=0;
for(j=0,k=0;j<info->partitions;j++){
count+=info->class[info->partitionclass[j]].class_dim;
for(;k<count;k++){
int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
if(t>=(1<<rangebits))goto err_out;
}
}
if(oggpack_eop(opb))goto err_out;
info->postlist[0]=0;
info->postlist[1]=1<<rangebits;
info->posts=count+2;
/* also store a sorted position index */
for(j=0;j<info->posts;j++)info->forward_index[j]=j;
mergesort(info->forward_index,info->postlist,info->posts);
/* discover our neighbors for decode where we don't use fit flags
(that would push the neighbors outward) */
for(j=0;j<info->posts-2;j++){
int lo=0;
int hi=1;
int lx=0;
int hx=info->postlist[1];
int currentx=info->postlist[j+2];
for(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;
}
}
info->loneighbor[j]=lo;
info->hineighbor[j]=hi;
}
return(info);
err_out:
floor1_free_info(info);
return(NULL);
}
#ifdef ONLY_C
static
#endif
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=abs(dy);
int err=ady*(x-x0);
int off=err/adx;
if(dy<0)return(y0-off);
return(y0+off);
}
}
static void render_line(int n,int x0,int x1,int y0,int y1,ogg_int32_t *d){
int dy;
int adx;
int ady;
int base;
int err;
const ogg_int32_t *floor;
if(n>x1)n=x1;
n -= x0;
if (n <= 0)
return;
dy=y1-y0;
adx=x1-x0;
ady=abs(dy);
base=dy/adx;
err=adx-1;
floor=&FLOOR_fromdB_LOOKUP[y0];
d += x0;
ady-=abs(base*adx);
/* We should add base each time, and then:
* if dy >=0 we occasionally add 1
* else occasionally subtract 1.
* As an optimisation we say that if dy <0 we make base 1 smaller.
* Then we need to add 1 occassionally, rather than subtract 1 - but we
* need to add 1 in all the cases when we wouldn't have done so before.
* Previously we'd have added 1 (100*ady/adx)% of the time. Now we want
* to do so (100*(adx-ady)/adx)% of the time.
*/
if (dy < 0){
base--;
ady = adx-ady;
err = 0;
}
//if(x<n)
// d[x]= MULT31_SHIFT15(d[x],FLOOR_fromdB_LOOKUP[y]);
#if defined(ONLY_C)
do{
*d = MULT31_SHIFT15(*d,*floor);
d++;
floor+=base;
err-=ady;
if(err<0){
err+=adx;
floor+=1;
}
n--;
} while(n>0);
#else
render_lineARM(n,d,floor,base,err,adx,ady);
#endif
}
int floor1_memosize(vorbis_info_floor *i){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
return info->posts;
}
static int quant_look[4]={256,128,86,64};
ogg_int32_t *floor1_inverse1(vorbis_dsp_state *vd,vorbis_info_floor *in,
ogg_int32_t *fit_value){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
int i,j,k;
codebook *books=ci->book_param;
int quant_q=quant_look[info->mult-1];
/* unpack wrapped/predicted values from stream */
if(oggpack_read(&vd->opb,1)==1){
fit_value[0]=oggpack_read(&vd->opb,ilog(quant_q-1));
fit_value[1]=oggpack_read(&vd->opb,ilog(quant_q-1));
/* partition by partition */
/* partition by partition */
for(i=0,j=2;i<info->partitions;i++){
int classv=info->partitionclass[i];
int cdim=info->class[classv].class_dim;
int csubbits=info->class[classv].class_subs;
int csub=1<<csubbits;
int cval=0;
/* decode the partition's first stage cascade value */
if(csubbits){
cval=vorbis_book_decode(books+info->class[classv].class_book,&vd->opb);
if(cval==-1)goto eop;
}
for(k=0;k<cdim;k++){
int book=info->class[classv].class_subbook[cval&(csub-1)];
cval>>=csubbits;
if(book!=0xff){
if((fit_value[j+k]=vorbis_book_decode(books+book,&vd->opb))==-1)
goto eop;
}else{
fit_value[j+k]=0;
}
}
j+=cdim;
}
/* unwrap positive values and reconsitute via linear interpolation */
for(i=2;i<info->posts;i++){
int predicted=render_point(info->postlist[info->loneighbor[i-2]],
info->postlist[info->hineighbor[i-2]],
fit_value[info->loneighbor[i-2]],
fit_value[info->hineighbor[i-2]],
info->postlist[i]);
int hiroom=quant_q-predicted;
int loroom=predicted;
int room=(hiroom<loroom?hiroom:loroom)<<1;
int val=fit_value[i];
if(val){
if(val>=room){
if(hiroom>loroom){
val = val-loroom;
}else{
val = -1-(val-hiroom);
}
}else{
if(val&1){
val= -((val+1)>>1);
}else{
val>>=1;
}
}
fit_value[i]=val+predicted;
fit_value[info->loneighbor[i-2]]&=0x7fff;
fit_value[info->hineighbor[i-2]]&=0x7fff;
}else{
fit_value[i]=predicted|0x8000;
}
}
return(fit_value);
}
eop:
return(NULL);
}
int floor1_inverse2(vorbis_dsp_state *vd,vorbis_info_floor *in,
ogg_int32_t *fit_value,ogg_int32_t *out){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
int n=ci->blocksizes[vd->W]/2;
int j;
if(fit_value){
/* render the lines */
int hx=0;
int lx=0;
int ly=fit_value[0]*info->mult;
for(j=1;j<info->posts;j++){
int current=info->forward_index[j];
int hy=fit_value[current]&0x7fff;
if(hy==fit_value[current]){
hy*=info->mult;
hx=info->postlist[current];
render_line(n,lx,hx,ly,hy,out);
lx=hx;
ly=hy;
}
}
for(j=hx;j<n;j++)out[j]*=ly; /* be certain */
return(1);
}
memset(out,0,sizeof(*out)*n);
return(0);
}

View File

@@ -0,0 +1,31 @@
.text
.global render_lineARM
render_lineARM:
@ r0 = n
@ r1 = d
@ r2 = floor
@ r3 = base
@ <> = err
@ <> = adx
@ <> = ady
MOV r12,r13
STMFD r13!,{r4-r6,r11,r14}
LDMFD r12,{r11,r12,r14} @ r11 = err
@ r12 = adx
@ r14 = ady
rl_loop:
LDR r4,[r1] @ r4 = *d
LDR r5,[r2],r3,LSL #2 @ r5 = *floor r2 = floor+base
SUBS r11,r11,r14 @ err -= ady
ADDLT r11,r11,r12 @ if (err < 0) err+=adx
SMULL r6, r5, r4, r5 @ (r6,r5) = *d * *floor
ADDLT r2, r2, #4 @ floor+=1
MOVS r6, r6, LSR #15
ADC r5, r6, r5, LSL #17 @ r5 = MULT31_SHIFT15
STR r5,[r1],#4
SUBS r0, r0, #1
BGT rl_loop
LDMFD r13!,{r4-r6,r11,PC}

View File

@@ -0,0 +1,30 @@
.text
.global render_lineARM
render_lineARM:
@ r0 = n
@ r1 = d
@ r2 = floor
@ r3 = base
@ <> = err
@ <> = adx
@ <> = ady
MOV r12,r13
STMFD r13!,{r4-r6,r11,r14}
LDMFD r12,{r11,r12,r14} @ r11 = err
@ r12 = adx
@ r14 = ady
rl_loop:
LDR r4, [r1] @ r4 = *d
LDR r5, [r2], r3,LSL #2 @ r5 = *floor r2 = floor+base
SUBS r11,r11,r14 @ err -= ady
MOV r4, r4, ASR #6
MUL r5, r4, r5 @ r5 = MULT31_SHIFT15
ADDLT r11,r11,r12 @ if (err < 0) err+=adx
ADDLT r2, r2, #4 @ floor+=1
SUBS r0, r0, #1
STR r5, [r1], #4
BGT rl_loop
LDMFD r13!,{r4-r6,r11,PC}

View File

@@ -0,0 +1,92 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: floor dB lookup
********************************************************************/
#include "os.h"
#ifdef _LOW_ACCURACY_
# define XdB(n) ((((n)>>8)+1)>>1)
#else
# define XdB(n) (n)
#endif
const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114),
XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163),
XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9),
XdB(0x000001e7), XdB(0x00000206), XdB(0x00000228), XdB(0x0000024c),
XdB(0x00000272), XdB(0x0000029b), XdB(0x000002c6), XdB(0x000002f4),
XdB(0x00000326), XdB(0x0000035a), XdB(0x00000392), XdB(0x000003cd),
XdB(0x0000040c), XdB(0x00000450), XdB(0x00000497), XdB(0x000004e4),
XdB(0x00000535), XdB(0x0000058c), XdB(0x000005e8), XdB(0x0000064a),
XdB(0x000006b3), XdB(0x00000722), XdB(0x00000799), XdB(0x00000818),
XdB(0x0000089e), XdB(0x0000092e), XdB(0x000009c6), XdB(0x00000a69),
XdB(0x00000b16), XdB(0x00000bcf), XdB(0x00000c93), XdB(0x00000d64),
XdB(0x00000e43), XdB(0x00000f30), XdB(0x0000102d), XdB(0x0000113a),
XdB(0x00001258), XdB(0x0000138a), XdB(0x000014cf), XdB(0x00001629),
XdB(0x0000179a), XdB(0x00001922), XdB(0x00001ac4), XdB(0x00001c82),
XdB(0x00001e5c), XdB(0x00002055), XdB(0x0000226f), XdB(0x000024ac),
XdB(0x0000270e), XdB(0x00002997), XdB(0x00002c4b), XdB(0x00002f2c),
XdB(0x0000323d), XdB(0x00003581), XdB(0x000038fb), XdB(0x00003caf),
XdB(0x000040a0), XdB(0x000044d3), XdB(0x0000494c), XdB(0x00004e10),
XdB(0x00005323), XdB(0x0000588a), XdB(0x00005e4b), XdB(0x0000646b),
XdB(0x00006af2), XdB(0x000071e5), XdB(0x0000794c), XdB(0x0000812e),
XdB(0x00008993), XdB(0x00009283), XdB(0x00009c09), XdB(0x0000a62d),
XdB(0x0000b0f9), XdB(0x0000bc79), XdB(0x0000c8b9), XdB(0x0000d5c4),
XdB(0x0000e3a9), XdB(0x0000f274), XdB(0x00010235), XdB(0x000112fd),
XdB(0x000124dc), XdB(0x000137e4), XdB(0x00014c29), XdB(0x000161bf),
XdB(0x000178bc), XdB(0x00019137), XdB(0x0001ab4a), XdB(0x0001c70e),
XdB(0x0001e4a1), XdB(0x0002041f), XdB(0x000225aa), XdB(0x00024962),
XdB(0x00026f6d), XdB(0x000297f0), XdB(0x0002c316), XdB(0x0002f109),
XdB(0x000321f9), XdB(0x00035616), XdB(0x00038d97), XdB(0x0003c8b4),
XdB(0x000407a7), XdB(0x00044ab2), XdB(0x00049218), XdB(0x0004de23),
XdB(0x00052f1e), XdB(0x0005855c), XdB(0x0005e135), XdB(0x00064306),
XdB(0x0006ab33), XdB(0x00071a24), XdB(0x0007904b), XdB(0x00080e20),
XdB(0x00089422), XdB(0x000922da), XdB(0x0009bad8), XdB(0x000a5cb6),
XdB(0x000b091a), XdB(0x000bc0b1), XdB(0x000c8436), XdB(0x000d5471),
XdB(0x000e3233), XdB(0x000f1e5f), XdB(0x001019e4), XdB(0x001125c1),
XdB(0x00124306), XdB(0x001372d5), XdB(0x0014b663), XdB(0x00160ef7),
XdB(0x00177df0), XdB(0x001904c1), XdB(0x001aa4f9), XdB(0x001c603d),
XdB(0x001e384f), XdB(0x00202f0f), XdB(0x0022467a), XdB(0x002480b1),
XdB(0x0026dff7), XdB(0x002966b3), XdB(0x002c1776), XdB(0x002ef4fc),
XdB(0x0032022d), XdB(0x00354222), XdB(0x0038b828), XdB(0x003c67c2),
XdB(0x004054ae), XdB(0x004482e8), XdB(0x0048f6af), XdB(0x004db488),
XdB(0x0052c142), XdB(0x005821ff), XdB(0x005ddc33), XdB(0x0063f5b0),
XdB(0x006a74a7), XdB(0x00715faf), XdB(0x0078bdce), XdB(0x0080967f),
XdB(0x0088f1ba), XdB(0x0091d7f9), XdB(0x009b5247), XdB(0x00a56a41),
XdB(0x00b02a27), XdB(0x00bb9ce2), XdB(0x00c7ce12), XdB(0x00d4ca17),
XdB(0x00e29e20), XdB(0x00f15835), XdB(0x0101074b), XdB(0x0111bb4e),
XdB(0x01238531), XdB(0x01367704), XdB(0x014aa402), XdB(0x016020a7),
XdB(0x017702c3), XdB(0x018f6190), XdB(0x01a955cb), XdB(0x01c4f9cf),
XdB(0x01e269a8), XdB(0x0201c33b), XdB(0x0223265a), XdB(0x0246b4ea),
XdB(0x026c9302), XdB(0x0294e716), XdB(0x02bfda13), XdB(0x02ed9793),
XdB(0x031e4e09), XdB(0x03522ee4), XdB(0x03896ed0), XdB(0x03c445e2),
XdB(0x0402efd6), XdB(0x0445ac4b), XdB(0x048cbefc), XdB(0x04d87013),
XdB(0x05290c67), XdB(0x057ee5ca), XdB(0x05da5364), XdB(0x063bb204),
XdB(0x06a36485), XdB(0x0711d42b), XdB(0x0787710e), XdB(0x0804b299),
XdB(0x088a17ef), XdB(0x0918287e), XdB(0x09af747c), XdB(0x0a50957e),
XdB(0x0afc2f19), XdB(0x0bb2ef7f), XdB(0x0c759034), XdB(0x0d44d6ca),
XdB(0x0e2195bc), XdB(0x0f0cad0d), XdB(0x10070b62), XdB(0x1111aeea),
XdB(0x122da66c), XdB(0x135c120f), XdB(0x149e24d9), XdB(0x15f525b1),
XdB(0x176270e3), XdB(0x18e7794b), XdB(0x1a85c9ae), XdB(0x1c3f06d1),
XdB(0x1e14f07d), XdB(0x200963d7), XdB(0x221e5ccd), XdB(0x2455f870),
XdB(0x26b2770b), XdB(0x29363e2b), XdB(0x2be3db5c), XdB(0x2ebe06b6),
XdB(0x31c7a55b), XdB(0x3503ccd4), XdB(0x3875c5aa), XdB(0x3c210f44),
XdB(0x4009632b), XdB(0x4432b8cf), XdB(0x48a149bc), XdB(0x4d59959e),
XdB(0x52606733), XdB(0x57bad899), XdB(0x5d6e593a), XdB(0x6380b298),
XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,348 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: maintain the info structure, info <-> header packets
********************************************************************/
/* general handling of the header and the vorbis_info structure (and
substructures) */
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
#include "codebook.h"
#include "misc.h"
#include "os.h"
/* helpers */
static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
while(bytes--){
*buf++=oggpack_read(o,8);
}
}
void vorbis_comment_init(vorbis_comment *vc){
memset(vc,0,sizeof(*vc));
}
/* 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 int tagcompare(const char *s1, const char *s2, int n){
int c=0;
while(c < n){
if(toupper(s1[c]) != toupper(s2[c]))
return !0;
c++;
}
return 0;
}
char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
long i;
int found = 0;
int taglen = strlen(tag)+1; /* +1 for the = we append */
char *fulltag = (char *)alloca(taglen+ 1);
strcpy(fulltag, tag);
strcat(fulltag, "=");
for(i=0;i<vc->comments;i++){
if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
if(count == found)
/* We return a pointer to the data, not a copy */
return vc->user_comments[i] + taglen;
else
found++;
}
}
return NULL; /* didn't find anything */
}
int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
int i,count=0;
int taglen = strlen(tag)+1; /* +1 for the = we append */
char *fulltag = (char *)alloca(taglen+1);
strcpy(fulltag,tag);
strcat(fulltag, "=");
for(i=0;i<vc->comments;i++){
if(!tagcompare(vc->user_comments[i], fulltag, taglen))
count++;
}
return count;
}
void vorbis_comment_clear(vorbis_comment *vc){
if(vc){
long i;
for(i=0;i<vc->comments;i++)
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
if(vc->user_comments)_ogg_free(vc->user_comments);
if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->vendor)_ogg_free(vc->vendor);
}
memset(vc,0,sizeof(*vc));
}
/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long.
They may be equal, but short will never ge greater than long */
int vorbis_info_blocksize(vorbis_info *vi,int zo){
codec_setup_info *ci = (codec_setup_info *)vi->codec_setup;
return ci ? ci->blocksizes[zo] : -1;
}
/* used by synthesis, which has a full, alloced vi */
void vorbis_info_init(vorbis_info *vi){
memset(vi,0,sizeof(*vi));
vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info));
}
void vorbis_info_clear(vorbis_info *vi){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int i;
if(ci){
if(ci->mode_param)_ogg_free(ci->mode_param);
if(ci->map_param){
for(i=0;i<ci->maps;i++) /* unpack does the range checking */
mapping_clear_info(ci->map_param+i);
_ogg_free(ci->map_param);
}
if(ci->floor_param){
for(i=0;i<ci->floors;i++) /* unpack does the range checking */
if(ci->floor_type[i])
floor1_free_info(ci->floor_param[i]);
else
floor0_free_info(ci->floor_param[i]);
_ogg_free(ci->floor_param);
_ogg_free(ci->floor_type);
}
if(ci->residue_param){
for(i=0;i<ci->residues;i++) /* unpack does the range checking */
res_clear_info(ci->residue_param+i);
_ogg_free(ci->residue_param);
}
if(ci->book_param){
for(i=0;i<ci->books;i++)
vorbis_book_clear(ci->book_param+i);
_ogg_free(ci->book_param);
}
_ogg_free(ci);
}
memset(vi,0,sizeof(*vi));
}
/* Header packing/unpacking ********************************************/
static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
if(!ci)return(OV_EFAULT);
vi->version=oggpack_read(opb,32);
if(vi->version!=0)return(OV_EVERSION);
vi->channels=oggpack_read(opb,8);
vi->rate=oggpack_read(opb,32);
vi->bitrate_upper=oggpack_read(opb,32);
vi->bitrate_nominal=oggpack_read(opb,32);
vi->bitrate_lower=oggpack_read(opb,32);
ci->blocksizes[0]=1<<oggpack_read(opb,4);
ci->blocksizes[1]=1<<oggpack_read(opb,4);
#ifdef LIMIT_TO_64kHz
if(vi->rate>=64000 || ci->blocksizes[1]>4096)goto err_out;
#else
if(vi->rate<64000 && ci->blocksizes[1]>4096)goto err_out;
#endif
if(vi->rate<1)goto err_out;
if(vi->channels<1)goto err_out;
if(ci->blocksizes[0]<64)goto err_out;
if(ci->blocksizes[1]<ci->blocksizes[0])goto err_out;
if(ci->blocksizes[1]>8192)goto err_out;
if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
return(0);
err_out:
vorbis_info_clear(vi);
return(OV_EBADHEADER);
}
static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
int i;
int vendorlen=oggpack_read(opb,32);
if(vendorlen<0)goto err_out;
vc->vendor=(char *)_ogg_calloc(vendorlen+1,1);
_v_readstring(opb,vc->vendor,vendorlen);
vc->comments=oggpack_read(opb,32);
if(vc->comments<0)goto err_out;
vc->user_comments=(char **)_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
vc->comment_lengths=(int *)_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths));
for(i=0;i<vc->comments;i++){
int len=oggpack_read(opb,32);
if(len<0)goto err_out;
vc->comment_lengths[i]=len;
vc->user_comments[i]=(char *)_ogg_calloc(len+1,1);
_v_readstring(opb,vc->user_comments[i],len);
}
if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
return(0);
err_out:
vorbis_comment_clear(vc);
return(OV_EBADHEADER);
}
/* all of the real encoding details are here. The modes, books,
everything */
static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int i;
if(!ci)return(OV_EFAULT);
/* codebooks */
ci->books=oggpack_read(opb,8)+1;
ci->book_param=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->book_param));
for(i=0;i<ci->books;i++)
if(vorbis_book_unpack(opb,ci->book_param+i))goto err_out;
/* time backend settings, not actually used */
i=oggpack_read(opb,6);
for(;i>=0;i--)
if(oggpack_read(opb,16)!=0)goto err_out;
/* floor backend settings */
ci->floors=oggpack_read(opb,6)+1;
ci->floor_param=_ogg_malloc(sizeof(*ci->floor_param)*ci->floors);
ci->floor_type=_ogg_malloc(sizeof(*ci->floor_type)*ci->floors);
for(i=0;i<ci->floors;i++){
ci->floor_type[i]=oggpack_read(opb,16);
if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
if(ci->floor_type[i])
ci->floor_param[i]=floor1_info_unpack(vi,opb);
else
ci->floor_param[i]=floor0_info_unpack(vi,opb);
if(!ci->floor_param[i])goto err_out;
}
/* residue backend settings */
ci->residues=oggpack_read(opb,6)+1;
ci->residue_param=_ogg_malloc(sizeof(*ci->residue_param)*ci->residues);
for(i=0;i<ci->residues;i++)
if(res_unpack(ci->residue_param+i,vi,opb))goto err_out;
/* map backend settings */
ci->maps=oggpack_read(opb,6)+1;
ci->map_param=_ogg_malloc(sizeof(*ci->map_param)*ci->maps);
for(i=0;i<ci->maps;i++){
if(oggpack_read(opb,16)!=0)goto err_out;
if(mapping_info_unpack(ci->map_param+i,vi,opb))goto err_out;
}
/* mode settings */
ci->modes=oggpack_read(opb,6)+1;
ci->mode_param=
(vorbis_info_mode *)_ogg_malloc(ci->modes*sizeof(*ci->mode_param));
for(i=0;i<ci->modes;i++){
ci->mode_param[i].blockflag=oggpack_read(opb,1);
if(oggpack_read(opb,16))goto err_out;
if(oggpack_read(opb,16))goto err_out;
ci->mode_param[i].mapping=oggpack_read(opb,8);
if(ci->mode_param[i].mapping>=ci->maps)goto err_out;
}
if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
return(0);
err_out:
vorbis_info_clear(vi);
return(OV_EBADHEADER);
}
/* 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. */
int vorbis_dsp_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){
oggpack_buffer opb;
if(op){
oggpack_readinit(&opb,op->packet);
/* Which of the three types of header is this? */
/* Also verify header-ness, vorbis */
{
char buffer[6];
int packtype=oggpack_read(&opb,8);
memset(buffer,0,6);
_v_readstring(&opb,buffer,6);
if(memcmp(buffer,"vorbis",6)){
/* not a vorbis header */
return(OV_ENOTVORBIS);
}
switch(packtype){
case 0x01: /* least significant *bit* is read first */
if(!op->b_o_s){
/* Not the initial packet */
return(OV_EBADHEADER);
}
if(vi->rate!=0){
/* previously initialized info header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_info(vi,&opb));
case 0x03: /* least significant *bit* is read first */
if(vi->rate==0){
/* um... we didn't get the initial header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_comment(vc,&opb));
case 0x05: /* least significant *bit* is read first */
if(vi->rate==0 || vc->vendor==NULL){
/* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_books(vi,&opb));
default:
/* Not a valid vorbis header type */
return(OV_EBADHEADER);
break;
}
}
}
return(OV_EBADHEADER);
}

View File

@@ -0,0 +1,104 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: libvorbis codec headers
********************************************************************/
#ifndef _vorbis_codec_h_
#define _vorbis_codec_h_
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include "ogg.h"
struct vorbis_dsp_state;
typedef struct vorbis_dsp_state vorbis_dsp_state;
typedef struct vorbis_info{
int version;
int channels;
long 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.
*/
long bitrate_upper;
long bitrate_nominal;
long bitrate_lower;
long bitrate_window;
void *codec_setup;
} vorbis_info;
typedef struct vorbis_comment{
char **user_comments;
int *comment_lengths;
int comments;
char *vendor;
} vorbis_comment;
/* Vorbis PRIMITIVES: general ***************************************/
extern void vorbis_info_init(vorbis_info *vi);
extern void vorbis_info_clear(vorbis_info *vi);
extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
extern void vorbis_comment_init(vorbis_comment *vc);
extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
extern void vorbis_comment_add_tag(vorbis_comment *vc,
char *tag, char *contents);
extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag);
extern void vorbis_comment_clear(vorbis_comment *vc);
/* Vorbis ERRORS and return codes ***********************************/
#define OV_FALSE -1
#define OV_EOF -2
#define OV_HOLE -3
#define OV_EREAD -128
#define OV_EFAULT -129
#define OV_EIMPL -130
#define OV_EINVAL -131
#define OV_ENOTVORBIS -132
#define OV_EBADHEADER -133
#define OV_EVERSION -134
#define OV_ENOTAUDIO -135
#define OV_EBADPACKET -136
#define OV_EBADLINK -137
#define OV_ENOSEEK -138
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,122 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: stdio-based convenience library for opening/seeking/decoding
********************************************************************/
#ifndef _OV_FILE_H_
#define _OV_FILE_H_
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <stdio.h>
#include "ivorbiscodec.h"
/* The function prototypes for the callbacks are basically the same as for
* the stdio functions fread, fseek, fclose, ftell.
* The one difference is that the FILE * arguments have been replaced with
* a void * - this is to be used as a pointer to whatever internal data these
* functions might need. In the stdio case, it's just a FILE * cast to a void *
*
* If you use other functions, check the docs for these functions and return
* the right values. For seek_func(), you *MUST* return -1 if the stream is
* unseekable
*/
typedef struct {
size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
int (*close_func) (void *datasource);
long (*tell_func) (void *datasource);
} ov_callbacks;
typedef struct OggVorbis_File {
void *datasource; /* Pointer to a FILE *, etc. */
int seekable;
ogg_int64_t offset;
ogg_int64_t end;
ogg_sync_state *oy;
/* If the FILE handle isn't seekable (eg, a pipe), only the current
stream appears */
int links;
ogg_int64_t *offsets;
ogg_int64_t *dataoffsets;
ogg_uint32_t *serialnos;
ogg_int64_t *pcmlengths;
vorbis_info vi;
vorbis_comment vc;
/* Decoding working state local storage */
ogg_int64_t pcm_offset;
int ready_state;
ogg_uint32_t current_serialno;
int current_link;
ogg_int64_t bittrack;
ogg_int64_t samptrack;
ogg_stream_state *os; /* take physical pages, weld into a logical
stream of packets */
vorbis_dsp_state *vd; /* central working state for the packet->PCM decoder */
ov_callbacks callbacks;
} OggVorbis_File;
extern int ov_clear(OggVorbis_File *vf);
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test_open(OggVorbis_File *vf);
extern long ov_bitrate(OggVorbis_File *vf,int i);
extern long ov_bitrate_instant(OggVorbis_File *vf);
extern long ov_streams(OggVorbis_File *vf);
extern long ov_seekable(OggVorbis_File *vf);
extern long ov_serialnumber(OggVorbis_File *vf,int i);
extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i);
extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
extern long ov_read(OggVorbis_File *vf,void *buffer,int length,
int *bitstream);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,86 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: simple example decoder using vorbisidec
********************************************************************/
/* Takes a vorbis bitstream from stdin and writes raw stereo PCM to
stdout using vorbisfile. Using vorbisfile is much simpler than
dealing with libvorbis. */
#include <stdio.h>
#include <stdlib.h>
#include "ivorbiscodec.h"
#include "ivorbisfile.h"
#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
#include <io.h>
#include <fcntl.h>
#endif
char pcmout[4096]; /* take 4k out of the data segment, not the stack */
int main(){
OggVorbis_File vf;
int eof=0;
int current_section;
#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
/* Beware the evil ifdef. We avoid these where we can, but this one we
cannot. Don't add any more, you'll probably go to hell if you do. */
_setmode( _fileno( stdin ), _O_BINARY );
_setmode( _fileno( stdout ), _O_BINARY );
#endif
if(ov_open(stdin, &vf, NULL, 0) < 0) {
fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
exit(1);
}
/* Throw the comments plus a few lines about the bitstream we're
decoding */
{
char **ptr=ov_comment(&vf,-1)->user_comments;
vorbis_info *vi=ov_info(&vf,-1);
while(*ptr){
fprintf(stderr,"%s\n",*ptr);
++ptr;
}
fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
fprintf(stderr,"\nDecoded length: %ld samples\n",
(long)ov_pcm_total(&vf,-1));
fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
}
while(!eof){
long ret=ov_read(&vf,pcmout,sizeof(pcmout),&current_section);
if (ret == 0) {
/* EOF */
eof=1;
} else if (ret < 0) {
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
} else {
/* we don't bother dealing with sample rate changes, etc, but
you'll have to*/
fwrite(pcmout,1,ret,stdout);
}
}
/* cleanup */
ov_clear(&vf);
fprintf(stderr,"Done.\n");
return(0);
}

View File

@@ -0,0 +1,108 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: lookup data
********************************************************************/
#ifndef _V_LOOKUP_DATA_H_
#define _V_LOOKUP_DATA_H_
#include "os_types.h"
#define INVSQ_LOOKUP_I_SHIFT 10
#define INVSQ_LOOKUP_I_MASK 1023
static const long INVSQ_LOOKUP_I[64+1]={
92682, 91966, 91267, 90583,
89915, 89261, 88621, 87995,
87381, 86781, 86192, 85616,
85051, 84497, 83953, 83420,
82897, 82384, 81880, 81385,
80899, 80422, 79953, 79492,
79039, 78594, 78156, 77726,
77302, 76885, 76475, 76072,
75674, 75283, 74898, 74519,
74146, 73778, 73415, 73058,
72706, 72359, 72016, 71679,
71347, 71019, 70695, 70376,
70061, 69750, 69444, 69141,
68842, 68548, 68256, 67969,
67685, 67405, 67128, 66855,
66585, 66318, 66054, 65794,
65536,
};
static const long INVSQ_LOOKUP_IDel[64]={
716, 699, 684, 668,
654, 640, 626, 614,
600, 589, 576, 565,
554, 544, 533, 523,
513, 504, 495, 486,
477, 469, 461, 453,
445, 438, 430, 424,
417, 410, 403, 398,
391, 385, 379, 373,
368, 363, 357, 352,
347, 343, 337, 332,
328, 324, 319, 315,
311, 306, 303, 299,
294, 292, 287, 284,
280, 277, 273, 270,
267, 264, 260, 258,
};
#define COS_LOOKUP_I_SHIFT 9
#define COS_LOOKUP_I_MASK 511
#define COS_LOOKUP_I_SZ 128
static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
16384, 16379, 16364, 16340,
16305, 16261, 16207, 16143,
16069, 15986, 15893, 15791,
15679, 15557, 15426, 15286,
15137, 14978, 14811, 14635,
14449, 14256, 14053, 13842,
13623, 13395, 13160, 12916,
12665, 12406, 12140, 11866,
11585, 11297, 11003, 10702,
10394, 10080, 9760, 9434,
9102, 8765, 8423, 8076,
7723, 7366, 7005, 6639,
6270, 5897, 5520, 5139,
4756, 4370, 3981, 3590,
3196, 2801, 2404, 2006,
1606, 1205, 804, 402,
0, -401, -803, -1204,
-1605, -2005, -2403, -2800,
-3195, -3589, -3980, -4369,
-4755, -5138, -5519, -5896,
-6269, -6638, -7004, -7365,
-7722, -8075, -8422, -8764,
-9101, -9433, -9759, -10079,
-10393, -10701, -11002, -11296,
-11584, -11865, -12139, -12405,
-12664, -12915, -13159, -13394,
-13622, -13841, -14052, -14255,
-14448, -14634, -14810, -14977,
-15136, -15285, -15425, -15556,
-15678, -15790, -15892, -15985,
-16068, -16142, -16206, -16260,
-16304, -16339, -16363, -16378,
-16383,
};
#endif

View File

@@ -0,0 +1,241 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: channel mapping 0 implementation
********************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "ogg.h"
#include "os.h"
#include "ivorbiscodec.h"
#include "mdct.h"
#include "codec_internal.h"
#include "codebook.h"
#include "misc.h"
void mapping_clear_info(vorbis_info_mapping *info){
if(info){
if(info->chmuxlist)_ogg_free(info->chmuxlist);
if(info->submaplist)_ogg_free(info->submaplist);
if(info->coupling)_ogg_free(info->coupling);
memset(info,0,sizeof(*info));
}
}
static int ilog(unsigned int v){
int ret=0;
if(v)--v;
while(v){
ret++;
v>>=1;
}
return(ret);
}
/* also responsible for range checking */
int mapping_info_unpack(vorbis_info_mapping *info,vorbis_info *vi,
oggpack_buffer *opb){
int i;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
memset(info,0,sizeof(*info));
if(oggpack_read(opb,1))
info->submaps=oggpack_read(opb,4)+1;
else
info->submaps=1;
if(oggpack_read(opb,1)){
info->coupling_steps=oggpack_read(opb,8)+1;
info->coupling=
_ogg_malloc(info->coupling_steps*sizeof(*info->coupling));
for(i=0;i<info->coupling_steps;i++){
int testM=info->coupling[i].mag=oggpack_read(opb,ilog(vi->channels));
int testA=info->coupling[i].ang=oggpack_read(opb,ilog(vi->channels));
if(testM<0 ||
testA<0 ||
testM==testA ||
testM>=vi->channels ||
testA>=vi->channels) goto err_out;
}
}
if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
if(info->submaps>1){
info->chmuxlist=_ogg_malloc(sizeof(*info->chmuxlist)*vi->channels);
for(i=0;i<vi->channels;i++){
info->chmuxlist[i]=oggpack_read(opb,4);
if(info->chmuxlist[i]>=info->submaps)goto err_out;
}
}
info->submaplist=_ogg_malloc(sizeof(*info->submaplist)*info->submaps);
for(i=0;i<info->submaps;i++){
int temp=oggpack_read(opb,8);
info->submaplist[i].floor=oggpack_read(opb,8);
if(info->submaplist[i].floor>=ci->floors)goto err_out;
info->submaplist[i].residue=oggpack_read(opb,8);
if(info->submaplist[i].residue>=ci->residues)goto err_out;
}
return 0;
err_out:
mapping_clear_info(info);
return -1;
}
int mapping_inverse(vorbis_dsp_state *vd,vorbis_info_mapping *info){
vorbis_info *vi=vd->vi;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int i,j;
long n=ci->blocksizes[vd->W];
ogg_int32_t **pcmbundle=
alloca(sizeof(*pcmbundle)*vi->channels);
int *zerobundle=
alloca(sizeof(*zerobundle)*vi->channels);
int *nonzero=
alloca(sizeof(*nonzero)*vi->channels);
ogg_int32_t **floormemo=
alloca(sizeof(*floormemo)*vi->channels);
/* recover the spectral envelope; store it in the PCM vector for now */
for(i=0;i<vi->channels;i++){
int submap=0;
int floorno;
if(info->submaps>1)
submap=info->chmuxlist[i];
floorno=info->submaplist[submap].floor;
if(ci->floor_type[floorno]){
/* floor 1 */
floormemo[i]=alloca(sizeof(*floormemo[i])*
floor1_memosize(ci->floor_param[floorno]));
floormemo[i]=floor1_inverse1(vd,ci->floor_param[floorno],floormemo[i]);
}else{
/* floor 0 */
floormemo[i]=alloca(sizeof(*floormemo[i])*
floor0_memosize(ci->floor_param[floorno]));
floormemo[i]=floor0_inverse1(vd,ci->floor_param[floorno],floormemo[i]);
}
if(floormemo[i])
nonzero[i]=1;
else
nonzero[i]=0;
memset(vd->work[i],0,sizeof(*vd->work[i])*n/2);
}
/* channel coupling can 'dirty' the nonzero listing */
for(i=0;i<info->coupling_steps;i++){
if(nonzero[info->coupling[i].mag] ||
nonzero[info->coupling[i].ang]){
nonzero[info->coupling[i].mag]=1;
nonzero[info->coupling[i].ang]=1;
}
}
/* recover the residue into our working vectors */
for(i=0;i<info->submaps;i++){
int ch_in_bundle=0;
for(j=0;j<vi->channels;j++){
if(!info->chmuxlist || info->chmuxlist[j]==i){
if(nonzero[j])
zerobundle[ch_in_bundle]=1;
else
zerobundle[ch_in_bundle]=0;
pcmbundle[ch_in_bundle++]=vd->work[j];
}
}
res_inverse(vd,ci->residue_param+info->submaplist[i].residue,
pcmbundle,zerobundle,ch_in_bundle);
}
//for(j=0;j<vi->channels;j++)
//_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0);
/* channel coupling */
for(i=info->coupling_steps-1;i>=0;i--){
ogg_int32_t *pcmM=vd->work[info->coupling[i].mag];
ogg_int32_t *pcmA=vd->work[info->coupling[i].ang];
for(j=0;j<n/2;j++){
ogg_int32_t mag=pcmM[j];
ogg_int32_t 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;
}
}
}
//for(j=0;j<vi->channels;j++)
//_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0);
/* compute and apply spectral envelope */
for(i=0;i<vi->channels;i++){
ogg_int32_t *pcm=vd->work[i];
int submap=0;
int floorno;
if(info->submaps>1)
submap=info->chmuxlist[i];
floorno=info->submaplist[submap].floor;
if(ci->floor_type[floorno]){
/* floor 1 */
floor1_inverse2(vd,ci->floor_param[floorno],floormemo[i],pcm);
}else{
/* floor 0 */
floor0_inverse2(vd,ci->floor_param[floorno],floormemo[i],pcm);
}
}
//for(j=0;j<vi->channels;j++)
//_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1);
/* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
/* only MDCT right now.... */
for(i=0;i<vi->channels;i++)
mdct_backward(n,vd->work[i]);
//for(j=0;j<vi->channels;j++)
//_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0);
/* all done! */
return(0);
}

View File

@@ -0,0 +1,562 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ]
last mod: $Id: mdct.c,v 1.9.6.5 2003/04/29 04:03:27 xiphmont Exp $
Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer,
K. Brandenburg and B. Edler, collection of the European Signal
Processing Conference (EUSIPCO), Amsterdam, June 1992, Vol.1, pp
211-214
The below code implements an algorithm that no longer looks much like
that presented in the paper, but the basic structure remains if you
dig deep enough to see it.
This module DOES NOT INCLUDE code to generate/apply the window
function. Everybody has their own weird favorite including me... I
happen to like the properties of y=sin(.5PI*sin^2(x)), but others may
vehemently disagree.
********************************************************************/
#include "ivorbiscodec.h"
#include "os.h"
#include "misc.h"
#include "mdct.h"
#include "mdct_lookup.h"
#include <stdio.h>
#if defined(ONLY_C)
STIN void presymmetry(DATA_TYPE *in,int n2,int step){
DATA_TYPE *aX;
DATA_TYPE *bX;
LOOKUP_T *T;
int n4=n2>>1;
aX = in+n2-3;
T = sincos_lookup0;
do{
REG_TYPE s0= aX[0];
REG_TYPE s2= aX[2];
XPROD31( s0, s2, T[0], T[1], &aX[0], &aX[2] ); T+=step;
aX-=4;
}while(aX>=in+n4);
do{
REG_TYPE s0= aX[0];
REG_TYPE s2= aX[2];
XPROD31( s0, s2, T[1], T[0], &aX[0], &aX[2] ); T-=step;
aX-=4;
}while(aX>=in);
aX = in+n2-4;
bX = in;
T = sincos_lookup0;
do{
REG_TYPE ri0= aX[0];
REG_TYPE ri2= aX[2];
REG_TYPE ro0= bX[0];
REG_TYPE ro2= bX[2];
XNPROD31( ro2, ro0, T[1], T[0], &aX[0], &aX[2] ); T+=step;
XNPROD31( ri2, ri0, T[0], T[1], &bX[0], &bX[2] );
aX-=4;
bX+=4;
}while(aX>=bX);
}
/* 8 point butterfly (in place) */
STIN void mdct_butterfly_8(DATA_TYPE *x){
REG_TYPE s0 = x[0] + x[1];
REG_TYPE s1 = x[0] - x[1];
REG_TYPE s2 = x[2] + x[3];
REG_TYPE s3 = x[2] - x[3];
REG_TYPE s4 = x[4] + x[5];
REG_TYPE s5 = x[4] - x[5];
REG_TYPE s6 = x[6] + x[7];
REG_TYPE s7 = x[6] - x[7];
x[0] = s5 + s3;
x[1] = s7 - s1;
x[2] = s5 - s3;
x[3] = s7 + s1;
x[4] = s4 - s0;
x[5] = s6 - s2;
x[6] = s4 + s0;
x[7] = s6 + s2;
MB();
}
/* 16 point butterfly (in place, 4 register) */
STIN void mdct_butterfly_16(DATA_TYPE *x){
REG_TYPE s0, s1, s2, s3;
s0 = x[ 8] - x[ 9]; x[ 8] += x[ 9];
s1 = x[10] - x[11]; x[10] += x[11];
s2 = x[ 1] - x[ 0]; x[ 9] = x[ 1] + x[0];
s3 = x[ 3] - x[ 2]; x[11] = x[ 3] + x[2];
x[ 0] = MULT31((s0 - s1) , cPI2_8);
x[ 1] = MULT31((s2 + s3) , cPI2_8);
x[ 2] = MULT31((s0 + s1) , cPI2_8);
x[ 3] = MULT31((s3 - s2) , cPI2_8);
MB();
s2 = x[12] - x[13]; x[12] += x[13];
s3 = x[14] - x[15]; x[14] += x[15];
s0 = x[ 4] - x[ 5]; x[13] = x[ 5] + x[ 4];
s1 = x[ 7] - x[ 6]; x[15] = x[ 7] + x[ 6];
x[ 4] = s2; x[ 5] = s1;
x[ 6] = s3; x[ 7] = s0;
MB();
mdct_butterfly_8(x);
mdct_butterfly_8(x+8);
}
/* 32 point butterfly (in place, 4 register) */
STIN void mdct_butterfly_32(DATA_TYPE *x){
REG_TYPE s0, s1, s2, s3;
s0 = x[16] - x[17]; x[16] += x[17];
s1 = x[18] - x[19]; x[18] += x[19];
s2 = x[ 1] - x[ 0]; x[17] = x[ 1] + x[ 0];
s3 = x[ 3] - x[ 2]; x[19] = x[ 3] + x[ 2];
XNPROD31( s0, s1, cPI3_8, cPI1_8, &x[ 0], &x[ 2] );
XPROD31 ( s2, s3, cPI1_8, cPI3_8, &x[ 1], &x[ 3] );
MB();
s0 = x[20] - x[21]; x[20] += x[21];
s1 = x[22] - x[23]; x[22] += x[23];
s2 = x[ 5] - x[ 4]; x[21] = x[ 5] + x[ 4];
s3 = x[ 7] - x[ 6]; x[23] = x[ 7] + x[ 6];
x[ 4] = MULT31((s0 - s1) , cPI2_8);
x[ 5] = MULT31((s3 + s2) , cPI2_8);
x[ 6] = MULT31((s0 + s1) , cPI2_8);
x[ 7] = MULT31((s3 - s2) , cPI2_8);
MB();
s0 = x[24] - x[25]; x[24] += x[25];
s1 = x[26] - x[27]; x[26] += x[27];
s2 = x[ 9] - x[ 8]; x[25] = x[ 9] + x[ 8];
s3 = x[11] - x[10]; x[27] = x[11] + x[10];
XNPROD31( s0, s1, cPI1_8, cPI3_8, &x[ 8], &x[10] );
XPROD31 ( s2, s3, cPI3_8, cPI1_8, &x[ 9], &x[11] );
MB();
s0 = x[28] - x[29]; x[28] += x[29];
s1 = x[30] - x[31]; x[30] += x[31];
s2 = x[12] - x[13]; x[29] = x[13] + x[12];
s3 = x[15] - x[14]; x[31] = x[15] + x[14];
x[12] = s0; x[13] = s3;
x[14] = s1; x[15] = s2;
MB();
mdct_butterfly_16(x);
mdct_butterfly_16(x+16);
}
/* N/stage point generic N stage butterfly (in place, 2 register) */
STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
LOOKUP_T *T = sincos_lookup0;
DATA_TYPE *x1 = x + points - 4;
DATA_TYPE *x2 = x + (points>>1) - 4;
REG_TYPE s0, s1, s2, s3;
do{
s0 = x1[0] - x1[1]; x1[0] += x1[1];
s1 = x1[3] - x1[2]; x1[2] += x1[3];
s2 = x2[1] - x2[0]; x1[1] = x2[1] + x2[0];
s3 = x2[3] - x2[2]; x1[3] = x2[3] + x2[2];
XPROD31( s1, s0, T[0], T[1], &x2[0], &x2[2] );
XPROD31( s2, s3, T[0], T[1], &x2[1], &x2[3] ); T+=step;
x1-=4;
x2-=4;
}while(T<sincos_lookup0+1024);
x1 = x + (points>>1) + (points>>2) - 4;
x2 = x + (points>>2) - 4;
T = sincos_lookup0+1024;
do{
s0 = x1[0] - x1[1]; x1[0] += x1[1];
s1 = x1[2] - x1[3]; x1[2] += x1[3];
s2 = x2[0] - x2[1]; x1[1] = x2[1] + x2[0];
s3 = x2[3] - x2[2]; x1[3] = x2[3] + x2[2];
XNPROD31( s0, s1, T[0], T[1], &x2[0], &x2[2] );
XNPROD31( s3, s2, T[0], T[1], &x2[1], &x2[3] ); T-=step;
x1-=4;
x2-=4;
}while(T>sincos_lookup0);
}
STIN void mdct_butterflies(DATA_TYPE *x,int points,int shift){
int stages=7-shift;
int i,j;
for(i=0;--stages>=0;i++){
for(j=0;j<(1<<i);j++)
{
mdct_butterfly_generic(x+(points>>i)*j,points>>i,4<<(i+shift));
}
}
for(j=0;j<points;j+=32)
mdct_butterfly_32(x+j);
}
static unsigned char bitrev[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
STIN int bitrev12(int x){
return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
}
STIN void mdct_bitreverse(DATA_TYPE *x,int n,int shift){
int bit = 0;
DATA_TYPE *w = x+(n>>1);
do{
DATA_TYPE b = bitrev12(bit++);
DATA_TYPE *xx = x + (b>>shift);
REG_TYPE r;
w -= 2;
if(w>xx){
r = xx[0];
xx[0] = w[0];
w[0] = r;
r = xx[1];
xx[1] = w[1];
w[1] = r;
}
}while(w>x);
}
STIN void mdct_step7(DATA_TYPE *x,int n,int step){
DATA_TYPE *w0 = x;
DATA_TYPE *w1 = x+(n>>1);
LOOKUP_T *T = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
LOOKUP_T *Ttop = T+1024;
REG_TYPE s0, s1, s2, s3;
do{
w1 -= 2;
s0 = w0[0] + w1[0];
s1 = w1[1] - w0[1];
s2 = MULT32(s0, T[1]) + MULT32(s1, T[0]);
s3 = MULT32(s1, T[1]) - MULT32(s0, T[0]);
T+=step;
s0 = (w0[1] + w1[1])>>1;
s1 = (w0[0] - w1[0])>>1;
w0[0] = s0 + s2;
w0[1] = s1 + s3;
w1[0] = s0 - s2;
w1[1] = s3 - s1;
w0 += 2;
}while(T<Ttop);
do{
w1 -= 2;
s0 = w0[0] + w1[0];
s1 = w1[1] - w0[1];
T-=step;
s2 = MULT32(s0, T[0]) + MULT32(s1, T[1]);
s3 = MULT32(s1, T[0]) - MULT32(s0, T[1]);
s0 = (w0[1] + w1[1])>>1;
s1 = (w0[0] - w1[0])>>1;
w0[0] = s0 + s2;
w0[1] = s1 + s3;
w1[0] = s0 - s2;
w1[1] = s3 - s1;
w0 += 2;
}while(w0<w1);
}
#endif
STIN void mdct_step8(DATA_TYPE *x, int n, int step){
LOOKUP_T *T;
LOOKUP_T *V;
DATA_TYPE *iX =x+(n>>1);
switch(step) {
#if defined(ONLY_C)
default:
T=(step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
do{
REG_TYPE s0 = x[0];
REG_TYPE s1 = -x[1];
XPROD31( s0, s1, T[0], T[1], x, x+1); T+=step;
x +=2;
}while(x<iX);
break;
#endif
case 1:
{
/* linear interpolation between table values: offset=0.5, step=1 */
REG_TYPE t0,t1,v0,v1,s0,s1;
T = sincos_lookup0;
V = sincos_lookup1;
t0 = (*T++)>>1;
t1 = (*T++)>>1;
do{
s0 = x[0];
s1 = -x[1];
t0 += (v0 = (*V++)>>1);
t1 += (v1 = (*V++)>>1);
XPROD31( s0, s1, t0, t1, x, x+1 );
s0 = x[2];
s1 = -x[3];
v0 += (t0 = (*T++)>>1);
v1 += (t1 = (*T++)>>1);
XPROD31( s0, s1, v0, v1, x+2, x+3 );
x += 4;
}while(x<iX);
break;
}
case 0:
{
/* linear interpolation between table values: offset=0.25, step=0.5 */
REG_TYPE t0,t1,v0,v1,q0,q1,s0,s1;
T = sincos_lookup0;
V = sincos_lookup1;
t0 = *T++;
t1 = *T++;
do{
v0 = *V++;
v1 = *V++;
t0 += (q0 = (v0-t0)>>2);
t1 += (q1 = (v1-t1)>>2);
s0 = x[0];
s1 = -x[1];
XPROD31( s0, s1, t0, t1, x, x+1 );
t0 = v0-q0;
t1 = v1-q1;
s0 = x[2];
s1 = -x[3];
XPROD31( s0, s1, t0, t1, x+2, x+3 );
t0 = *T++;
t1 = *T++;
v0 += (q0 = (t0-v0)>>2);
v1 += (q1 = (t1-v1)>>2);
s0 = x[4];
s1 = -x[5];
XPROD31( s0, s1, v0, v1, x+4, x+5 );
v0 = t0-q0;
v1 = t1-q1;
s0 = x[6];
s1 = -x[7];
XPROD31( s0, s1, v0, v1, x+5, x+6 );
x+=8;
}while(x<iX);
break;
}
}
}
extern int mdct_backwardARM(int n, DATA_TYPE *in);
/* partial; doesn't perform last-step deinterleave/unrolling. That
can be done more efficiently during pcm output */
void mdct_backward(int n, DATA_TYPE *in){
int step;
#if defined(ONLY_C)
int shift;
for (shift=4;!(n&(1<<shift));shift++);
shift=13-shift;
step=2<<shift;
presymmetry(in,n>>1,step);
mdct_butterflies(in,n>>1,shift);
mdct_bitreverse(in,n,shift);
mdct_step7(in,n,step);
mdct_step8(in,n,step>>2);
#else
step = mdct_backwardARM(n, in);
if (step < 1)
mdct_step8(in,n,step);
#endif
}
#if defined(ONLY_C)
void mdct_shift_right(int n, DATA_TYPE *in, DATA_TYPE *right){
int i;
n>>=2;
in+=1;
for(i=0;i<n;i++)
right[i]=in[i<<1];
}
#endif
extern ogg_int16_t *mdct_unroll_prelap(ogg_int16_t *out,
DATA_TYPE *post,
DATA_TYPE *l,
int step);
extern ogg_int16_t *mdct_unroll_part2(ogg_int16_t *out,
DATA_TYPE *post,
DATA_TYPE *l,
DATA_TYPE *r,
int step,
LOOKUP_T *wL,
LOOKUP_T *wR);
extern ogg_int16_t *mdct_unroll_part3(ogg_int16_t *out,
DATA_TYPE *post,
DATA_TYPE *l,
DATA_TYPE *r,
int step,
LOOKUP_T *wL,
LOOKUP_T *wR);
extern ogg_int16_t *mdct_unroll_postlap(ogg_int16_t *out,
DATA_TYPE *post,
DATA_TYPE *l,
int step);
void mdct_unroll_lap(int n0,int n1,
int lW,int W,
DATA_TYPE *in,
DATA_TYPE *right,
LOOKUP_T *w0,
LOOKUP_T *w1,
ogg_int16_t *out,
int step,
int start, /* samples, this frame */
int end /* samples, this frame */){
DATA_TYPE *l=in+(W&&lW ? n1>>1 : n0>>1);
DATA_TYPE *r=right+(lW ? n1>>2 : n0>>2);
DATA_TYPE *post;
LOOKUP_T *wR=(W && lW ? w1+(n1>>1) : w0+(n0>>1));
LOOKUP_T *wL=(W && lW ? w1 : w0 );
int preLap=(lW && !W ? (n1>>2)-(n0>>2) : 0 );
int halfLap=(lW && W ? (n1>>2) : (n0>>2) );
int postLap=(!lW && W ? (n1>>2)-(n0>>2) : 0 );
int n,off;
/* preceeding direct-copy lapping from previous frame, if any */
if(preLap){
n = (end<preLap?end:preLap);
off = (start<preLap?start:preLap);
post = r-n;
r -= off;
start -= off;
end -= n;
#if defined(ONLY_C)
while(r>post){
*out = CLIP_TO_15((*--r)>>9);
out+=step;
}
#else
out = mdct_unroll_prelap(out,post,r,step);
n -= off;
if (n < 0)
n = 0;
r -= n;
#endif
}
/* cross-lap; two halves due to wrap-around */
n = (end<halfLap?end:halfLap);
off = (start<halfLap?start:halfLap);
post = r-n;
r -= off;
l -= off*2;
start -= off;
wR -= off;
wL += off;
end -= n;
#if defined(ONLY_C)
while(r>post){
l-=2;
*out = CLIP_TO_15((MULT31(*--r,*--wR) + MULT31(*l,*wL++))>>9);
out+=step;
}
#else
out = mdct_unroll_part2(out, post, l, r, step, wL, wR);
n -= off;
if (n < 0)
n = 0;
l -= 2*n;
r -= n;
wR -= n;
wL += n;
#endif
n = (end<halfLap?end:halfLap);
off = (start<halfLap?start:halfLap);
post = r+n;
r += off;
l += off*2;
start -= off;
end -= n;
wR -= off;
wL += off;
#if defined(ONLY_C)
while(r<post){
*out = CLIP_TO_15((MULT31(*r++,*--wR) - MULT31(*l,*wL++))>>9);
out+=step;
l+=2;
}
#else
out = mdct_unroll_part3(out, post, l, r, step, wL, wR);
n -= off;
if (n < 0)
n = 0;
l += 2*n;
r += n;
wR -= n;
wL += n;
#endif
/* preceeding direct-copy lapping from previous frame, if any */
if(postLap){
n = (end<postLap?end:postLap);
off = (start<postLap?start:postLap);
post = l+n*2;
l += off*2;
#if defined(ONLY_C)
while(l<post){
*out = CLIP_TO_15((-*l)>>9);
out+=step;
l+=2;
}
#else
out = mdct_unroll_postlap(out,post,l,step);
#endif
}
}

View File

@@ -0,0 +1,59 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: modified discrete cosine transform prototypes
********************************************************************/
#ifndef _OGG_mdct_H_
#define _OGG_mdct_H_
#include "ivorbiscodec.h"
#include "misc.h"
#define DATA_TYPE ogg_int32_t
#define REG_TYPE register ogg_int32_t
#ifdef _LOW_ACCURACY_
#define cPI3_8 (0x0062)
#define cPI2_8 (0x00b5)
#define cPI1_8 (0x00ed)
#else
#define cPI3_8 (0x30fbc54d)
#define cPI2_8 (0x5a82799a)
#define cPI1_8 (0x7641af3d)
#endif
extern void mdct_backward(int n, DATA_TYPE *in);
extern void mdct_shift_right(int n, DATA_TYPE *in, DATA_TYPE *right);
extern void mdct_unroll_lap(int n0,int n1,
int lW,int W,
DATA_TYPE *in,DATA_TYPE *right,
LOOKUP_T *w0,LOOKUP_T *w1,
ogg_int16_t *out,
int step,
int start,int end /* samples, this frame */);
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,539 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: sin,cos lookup tables
********************************************************************/
#include "os_types.h"
/* {sin(2*i*PI/4096), cos(2*i*PI/4096)}, with i = 0 to 512 */
LOOKUP_T sincos_lookup0[1026] = {
X(0x00000000), X(0x7fffffff), X(0x003243f5), X(0x7ffff621),
X(0x006487e3), X(0x7fffd886), X(0x0096cbc1), X(0x7fffa72c),
X(0x00c90f88), X(0x7fff6216), X(0x00fb5330), X(0x7fff0943),
X(0x012d96b1), X(0x7ffe9cb2), X(0x015fda03), X(0x7ffe1c65),
X(0x01921d20), X(0x7ffd885a), X(0x01c45ffe), X(0x7ffce093),
X(0x01f6a297), X(0x7ffc250f), X(0x0228e4e2), X(0x7ffb55ce),
X(0x025b26d7), X(0x7ffa72d1), X(0x028d6870), X(0x7ff97c18),
X(0x02bfa9a4), X(0x7ff871a2), X(0x02f1ea6c), X(0x7ff75370),
X(0x03242abf), X(0x7ff62182), X(0x03566a96), X(0x7ff4dbd9),
X(0x0388a9ea), X(0x7ff38274), X(0x03bae8b2), X(0x7ff21553),
X(0x03ed26e6), X(0x7ff09478), X(0x041f6480), X(0x7feeffe1),
X(0x0451a177), X(0x7fed5791), X(0x0483ddc3), X(0x7feb9b85),
X(0x04b6195d), X(0x7fe9cbc0), X(0x04e8543e), X(0x7fe7e841),
X(0x051a8e5c), X(0x7fe5f108), X(0x054cc7b1), X(0x7fe3e616),
X(0x057f0035), X(0x7fe1c76b), X(0x05b137df), X(0x7fdf9508),
X(0x05e36ea9), X(0x7fdd4eec), X(0x0615a48b), X(0x7fdaf519),
X(0x0647d97c), X(0x7fd8878e), X(0x067a0d76), X(0x7fd6064c),
X(0x06ac406f), X(0x7fd37153), X(0x06de7262), X(0x7fd0c8a3),
X(0x0710a345), X(0x7fce0c3e), X(0x0742d311), X(0x7fcb3c23),
X(0x077501be), X(0x7fc85854), X(0x07a72f45), X(0x7fc560cf),
X(0x07d95b9e), X(0x7fc25596), X(0x080b86c2), X(0x7fbf36aa),
X(0x083db0a7), X(0x7fbc040a), X(0x086fd947), X(0x7fb8bdb8),
X(0x08a2009a), X(0x7fb563b3), X(0x08d42699), X(0x7fb1f5fc),
X(0x09064b3a), X(0x7fae7495), X(0x09386e78), X(0x7faadf7c),
X(0x096a9049), X(0x7fa736b4), X(0x099cb0a7), X(0x7fa37a3c),
X(0x09cecf89), X(0x7f9faa15), X(0x0a00ece8), X(0x7f9bc640),
X(0x0a3308bd), X(0x7f97cebd), X(0x0a6522fe), X(0x7f93c38c),
X(0x0a973ba5), X(0x7f8fa4b0), X(0x0ac952aa), X(0x7f8b7227),
X(0x0afb6805), X(0x7f872bf3), X(0x0b2d7baf), X(0x7f82d214),
X(0x0b5f8d9f), X(0x7f7e648c), X(0x0b919dcf), X(0x7f79e35a),
X(0x0bc3ac35), X(0x7f754e80), X(0x0bf5b8cb), X(0x7f70a5fe),
X(0x0c27c389), X(0x7f6be9d4), X(0x0c59cc68), X(0x7f671a05),
X(0x0c8bd35e), X(0x7f62368f), X(0x0cbdd865), X(0x7f5d3f75),
X(0x0cefdb76), X(0x7f5834b7), X(0x0d21dc87), X(0x7f531655),
X(0x0d53db92), X(0x7f4de451), X(0x0d85d88f), X(0x7f489eaa),
X(0x0db7d376), X(0x7f434563), X(0x0de9cc40), X(0x7f3dd87c),
X(0x0e1bc2e4), X(0x7f3857f6), X(0x0e4db75b), X(0x7f32c3d1),
X(0x0e7fa99e), X(0x7f2d1c0e), X(0x0eb199a4), X(0x7f2760af),
X(0x0ee38766), X(0x7f2191b4), X(0x0f1572dc), X(0x7f1baf1e),
X(0x0f475bff), X(0x7f15b8ee), X(0x0f7942c7), X(0x7f0faf25),
X(0x0fab272b), X(0x7f0991c4), X(0x0fdd0926), X(0x7f0360cb),
X(0x100ee8ad), X(0x7efd1c3c), X(0x1040c5bb), X(0x7ef6c418),
X(0x1072a048), X(0x7ef05860), X(0x10a4784b), X(0x7ee9d914),
X(0x10d64dbd), X(0x7ee34636), X(0x11082096), X(0x7edc9fc6),
X(0x1139f0cf), X(0x7ed5e5c6), X(0x116bbe60), X(0x7ecf1837),
X(0x119d8941), X(0x7ec8371a), X(0x11cf516a), X(0x7ec14270),
X(0x120116d5), X(0x7eba3a39), X(0x1232d979), X(0x7eb31e78),
X(0x1264994e), X(0x7eabef2c), X(0x1296564d), X(0x7ea4ac58),
X(0x12c8106f), X(0x7e9d55fc), X(0x12f9c7aa), X(0x7e95ec1a),
X(0x132b7bf9), X(0x7e8e6eb2), X(0x135d2d53), X(0x7e86ddc6),
X(0x138edbb1), X(0x7e7f3957), X(0x13c0870a), X(0x7e778166),
X(0x13f22f58), X(0x7e6fb5f4), X(0x1423d492), X(0x7e67d703),
X(0x145576b1), X(0x7e5fe493), X(0x148715ae), X(0x7e57dea7),
X(0x14b8b17f), X(0x7e4fc53e), X(0x14ea4a1f), X(0x7e47985b),
X(0x151bdf86), X(0x7e3f57ff), X(0x154d71aa), X(0x7e37042a),
X(0x157f0086), X(0x7e2e9cdf), X(0x15b08c12), X(0x7e26221f),
X(0x15e21445), X(0x7e1d93ea), X(0x16139918), X(0x7e14f242),
X(0x16451a83), X(0x7e0c3d29), X(0x1676987f), X(0x7e0374a0),
X(0x16a81305), X(0x7dfa98a8), X(0x16d98a0c), X(0x7df1a942),
X(0x170afd8d), X(0x7de8a670), X(0x173c6d80), X(0x7ddf9034),
X(0x176dd9de), X(0x7dd6668f), X(0x179f429f), X(0x7dcd2981),
X(0x17d0a7bc), X(0x7dc3d90d), X(0x1802092c), X(0x7dba7534),
X(0x183366e9), X(0x7db0fdf8), X(0x1864c0ea), X(0x7da77359),
X(0x18961728), X(0x7d9dd55a), X(0x18c7699b), X(0x7d9423fc),
X(0x18f8b83c), X(0x7d8a5f40), X(0x192a0304), X(0x7d808728),
X(0x195b49ea), X(0x7d769bb5), X(0x198c8ce7), X(0x7d6c9ce9),
X(0x19bdcbf3), X(0x7d628ac6), X(0x19ef0707), X(0x7d58654d),
X(0x1a203e1b), X(0x7d4e2c7f), X(0x1a517128), X(0x7d43e05e),
X(0x1a82a026), X(0x7d3980ec), X(0x1ab3cb0d), X(0x7d2f0e2b),
X(0x1ae4f1d6), X(0x7d24881b), X(0x1b161479), X(0x7d19eebf),
X(0x1b4732ef), X(0x7d0f4218), X(0x1b784d30), X(0x7d048228),
X(0x1ba96335), X(0x7cf9aef0), X(0x1bda74f6), X(0x7ceec873),
X(0x1c0b826a), X(0x7ce3ceb2), X(0x1c3c8b8c), X(0x7cd8c1ae),
X(0x1c6d9053), X(0x7ccda169), X(0x1c9e90b8), X(0x7cc26de5),
X(0x1ccf8cb3), X(0x7cb72724), X(0x1d00843d), X(0x7cabcd28),
X(0x1d31774d), X(0x7ca05ff1), X(0x1d6265dd), X(0x7c94df83),
X(0x1d934fe5), X(0x7c894bde), X(0x1dc4355e), X(0x7c7da505),
X(0x1df5163f), X(0x7c71eaf9), X(0x1e25f282), X(0x7c661dbc),
X(0x1e56ca1e), X(0x7c5a3d50), X(0x1e879d0d), X(0x7c4e49b7),
X(0x1eb86b46), X(0x7c4242f2), X(0x1ee934c3), X(0x7c362904),
X(0x1f19f97b), X(0x7c29fbee), X(0x1f4ab968), X(0x7c1dbbb3),
X(0x1f7b7481), X(0x7c116853), X(0x1fac2abf), X(0x7c0501d2),
X(0x1fdcdc1b), X(0x7bf88830), X(0x200d888d), X(0x7bebfb70),
X(0x203e300d), X(0x7bdf5b94), X(0x206ed295), X(0x7bd2a89e),
X(0x209f701c), X(0x7bc5e290), X(0x20d0089c), X(0x7bb9096b),
X(0x21009c0c), X(0x7bac1d31), X(0x21312a65), X(0x7b9f1de6),
X(0x2161b3a0), X(0x7b920b89), X(0x219237b5), X(0x7b84e61f),
X(0x21c2b69c), X(0x7b77ada8), X(0x21f3304f), X(0x7b6a6227),
X(0x2223a4c5), X(0x7b5d039e), X(0x225413f8), X(0x7b4f920e),
X(0x22847de0), X(0x7b420d7a), X(0x22b4e274), X(0x7b3475e5),
X(0x22e541af), X(0x7b26cb4f), X(0x23159b88), X(0x7b190dbc),
X(0x2345eff8), X(0x7b0b3d2c), X(0x23763ef7), X(0x7afd59a4),
X(0x23a6887f), X(0x7aef6323), X(0x23d6cc87), X(0x7ae159ae),
X(0x24070b08), X(0x7ad33d45), X(0x243743fa), X(0x7ac50dec),
X(0x24677758), X(0x7ab6cba4), X(0x2497a517), X(0x7aa8766f),
X(0x24c7cd33), X(0x7a9a0e50), X(0x24f7efa2), X(0x7a8b9348),
X(0x25280c5e), X(0x7a7d055b), X(0x2558235f), X(0x7a6e648a),
X(0x2588349d), X(0x7a5fb0d8), X(0x25b84012), X(0x7a50ea47),
X(0x25e845b6), X(0x7a4210d8), X(0x26184581), X(0x7a332490),
X(0x26483f6c), X(0x7a24256f), X(0x26783370), X(0x7a151378),
X(0x26a82186), X(0x7a05eead), X(0x26d809a5), X(0x79f6b711),
X(0x2707ebc7), X(0x79e76ca7), X(0x2737c7e3), X(0x79d80f6f),
X(0x27679df4), X(0x79c89f6e), X(0x27976df1), X(0x79b91ca4),
X(0x27c737d3), X(0x79a98715), X(0x27f6fb92), X(0x7999dec4),
X(0x2826b928), X(0x798a23b1), X(0x2856708d), X(0x797a55e0),
X(0x288621b9), X(0x796a7554), X(0x28b5cca5), X(0x795a820e),
X(0x28e5714b), X(0x794a7c12), X(0x29150fa1), X(0x793a6361),
X(0x2944a7a2), X(0x792a37fe), X(0x29743946), X(0x7919f9ec),
X(0x29a3c485), X(0x7909a92d), X(0x29d34958), X(0x78f945c3),
X(0x2a02c7b8), X(0x78e8cfb2), X(0x2a323f9e), X(0x78d846fb),
X(0x2a61b101), X(0x78c7aba2), X(0x2a911bdc), X(0x78b6fda8),
X(0x2ac08026), X(0x78a63d11), X(0x2aefddd8), X(0x789569df),
X(0x2b1f34eb), X(0x78848414), X(0x2b4e8558), X(0x78738bb3),
X(0x2b7dcf17), X(0x786280bf), X(0x2bad1221), X(0x7851633b),
X(0x2bdc4e6f), X(0x78403329), X(0x2c0b83fa), X(0x782ef08b),
X(0x2c3ab2b9), X(0x781d9b65), X(0x2c69daa6), X(0x780c33b8),
X(0x2c98fbba), X(0x77fab989), X(0x2cc815ee), X(0x77e92cd9),
X(0x2cf72939), X(0x77d78daa), X(0x2d263596), X(0x77c5dc01),
X(0x2d553afc), X(0x77b417df), X(0x2d843964), X(0x77a24148),
X(0x2db330c7), X(0x7790583e), X(0x2de2211e), X(0x777e5cc3),
X(0x2e110a62), X(0x776c4edb), X(0x2e3fec8b), X(0x775a2e89),
X(0x2e6ec792), X(0x7747fbce), X(0x2e9d9b70), X(0x7735b6af),
X(0x2ecc681e), X(0x77235f2d), X(0x2efb2d95), X(0x7710f54c),
X(0x2f29ebcc), X(0x76fe790e), X(0x2f58a2be), X(0x76ebea77),
X(0x2f875262), X(0x76d94989), X(0x2fb5fab2), X(0x76c69647),
X(0x2fe49ba7), X(0x76b3d0b4), X(0x30133539), X(0x76a0f8d2),
X(0x3041c761), X(0x768e0ea6), X(0x30705217), X(0x767b1231),
X(0x309ed556), X(0x76680376), X(0x30cd5115), X(0x7654e279),
X(0x30fbc54d), X(0x7641af3d), X(0x312a31f8), X(0x762e69c4),
X(0x3158970e), X(0x761b1211), X(0x3186f487), X(0x7607a828),
X(0x31b54a5e), X(0x75f42c0b), X(0x31e39889), X(0x75e09dbd),
X(0x3211df04), X(0x75ccfd42), X(0x32401dc6), X(0x75b94a9c),
X(0x326e54c7), X(0x75a585cf), X(0x329c8402), X(0x7591aedd),
X(0x32caab6f), X(0x757dc5ca), X(0x32f8cb07), X(0x7569ca99),
X(0x3326e2c3), X(0x7555bd4c), X(0x3354f29b), X(0x75419de7),
X(0x3382fa88), X(0x752d6c6c), X(0x33b0fa84), X(0x751928e0),
X(0x33def287), X(0x7504d345), X(0x340ce28b), X(0x74f06b9e),
X(0x343aca87), X(0x74dbf1ef), X(0x3468aa76), X(0x74c7663a),
X(0x34968250), X(0x74b2c884), X(0x34c4520d), X(0x749e18cd),
X(0x34f219a8), X(0x7489571c), X(0x351fd918), X(0x74748371),
X(0x354d9057), X(0x745f9dd1), X(0x357b3f5d), X(0x744aa63f),
X(0x35a8e625), X(0x74359cbd), X(0x35d684a6), X(0x74208150),
X(0x36041ad9), X(0x740b53fb), X(0x3631a8b8), X(0x73f614c0),
X(0x365f2e3b), X(0x73e0c3a3), X(0x368cab5c), X(0x73cb60a8),
X(0x36ba2014), X(0x73b5ebd1), X(0x36e78c5b), X(0x73a06522),
X(0x3714f02a), X(0x738acc9e), X(0x37424b7b), X(0x73752249),
X(0x376f9e46), X(0x735f6626), X(0x379ce885), X(0x73499838),
X(0x37ca2a30), X(0x7333b883), X(0x37f76341), X(0x731dc70a),
X(0x382493b0), X(0x7307c3d0), X(0x3851bb77), X(0x72f1aed9),
X(0x387eda8e), X(0x72db8828), X(0x38abf0ef), X(0x72c54fc1),
X(0x38d8fe93), X(0x72af05a7), X(0x39060373), X(0x7298a9dd),
X(0x3932ff87), X(0x72823c67), X(0x395ff2c9), X(0x726bbd48),
X(0x398cdd32), X(0x72552c85), X(0x39b9bebc), X(0x723e8a20),
X(0x39e6975e), X(0x7227d61c), X(0x3a136712), X(0x7211107e),
X(0x3a402dd2), X(0x71fa3949), X(0x3a6ceb96), X(0x71e35080),
X(0x3a99a057), X(0x71cc5626), X(0x3ac64c0f), X(0x71b54a41),
X(0x3af2eeb7), X(0x719e2cd2), X(0x3b1f8848), X(0x7186fdde),
X(0x3b4c18ba), X(0x716fbd68), X(0x3b78a007), X(0x71586b74),
X(0x3ba51e29), X(0x71410805), X(0x3bd19318), X(0x7129931f),
X(0x3bfdfecd), X(0x71120cc5), X(0x3c2a6142), X(0x70fa74fc),
X(0x3c56ba70), X(0x70e2cbc6), X(0x3c830a50), X(0x70cb1128),
X(0x3caf50da), X(0x70b34525), X(0x3cdb8e09), X(0x709b67c0),
X(0x3d07c1d6), X(0x708378ff), X(0x3d33ec39), X(0x706b78e3),
X(0x3d600d2c), X(0x70536771), X(0x3d8c24a8), X(0x703b44ad),
X(0x3db832a6), X(0x7023109a), X(0x3de4371f), X(0x700acb3c),
X(0x3e10320d), X(0x6ff27497), X(0x3e3c2369), X(0x6fda0cae),
X(0x3e680b2c), X(0x6fc19385), X(0x3e93e950), X(0x6fa90921),
X(0x3ebfbdcd), X(0x6f906d84), X(0x3eeb889c), X(0x6f77c0b3),
X(0x3f1749b8), X(0x6f5f02b2), X(0x3f430119), X(0x6f463383),
X(0x3f6eaeb8), X(0x6f2d532c), X(0x3f9a5290), X(0x6f1461b0),
X(0x3fc5ec98), X(0x6efb5f12), X(0x3ff17cca), X(0x6ee24b57),
X(0x401d0321), X(0x6ec92683), X(0x40487f94), X(0x6eaff099),
X(0x4073f21d), X(0x6e96a99d), X(0x409f5ab6), X(0x6e7d5193),
X(0x40cab958), X(0x6e63e87f), X(0x40f60dfb), X(0x6e4a6e66),
X(0x4121589b), X(0x6e30e34a), X(0x414c992f), X(0x6e174730),
X(0x4177cfb1), X(0x6dfd9a1c), X(0x41a2fc1a), X(0x6de3dc11),
X(0x41ce1e65), X(0x6dca0d14), X(0x41f93689), X(0x6db02d29),
X(0x42244481), X(0x6d963c54), X(0x424f4845), X(0x6d7c3a98),
X(0x427a41d0), X(0x6d6227fa), X(0x42a5311b), X(0x6d48047e),
X(0x42d0161e), X(0x6d2dd027), X(0x42faf0d4), X(0x6d138afb),
X(0x4325c135), X(0x6cf934fc), X(0x4350873c), X(0x6cdece2f),
X(0x437b42e1), X(0x6cc45698), X(0x43a5f41e), X(0x6ca9ce3b),
X(0x43d09aed), X(0x6c8f351c), X(0x43fb3746), X(0x6c748b3f),
X(0x4425c923), X(0x6c59d0a9), X(0x4450507e), X(0x6c3f055d),
X(0x447acd50), X(0x6c242960), X(0x44a53f93), X(0x6c093cb6),
X(0x44cfa740), X(0x6bee3f62), X(0x44fa0450), X(0x6bd3316a),
X(0x452456bd), X(0x6bb812d1), X(0x454e9e80), X(0x6b9ce39b),
X(0x4578db93), X(0x6b81a3cd), X(0x45a30df0), X(0x6b66536b),
X(0x45cd358f), X(0x6b4af279), X(0x45f7526b), X(0x6b2f80fb),
X(0x4621647d), X(0x6b13fef5), X(0x464b6bbe), X(0x6af86c6c),
X(0x46756828), X(0x6adcc964), X(0x469f59b4), X(0x6ac115e2),
X(0x46c9405c), X(0x6aa551e9), X(0x46f31c1a), X(0x6a897d7d),
X(0x471cece7), X(0x6a6d98a4), X(0x4746b2bc), X(0x6a51a361),
X(0x47706d93), X(0x6a359db9), X(0x479a1d67), X(0x6a1987b0),
X(0x47c3c22f), X(0x69fd614a), X(0x47ed5be6), X(0x69e12a8c),
X(0x4816ea86), X(0x69c4e37a), X(0x48406e08), X(0x69a88c19),
X(0x4869e665), X(0x698c246c), X(0x48935397), X(0x696fac78),
X(0x48bcb599), X(0x69532442), X(0x48e60c62), X(0x69368bce),
X(0x490f57ee), X(0x6919e320), X(0x49389836), X(0x68fd2a3d),
X(0x4961cd33), X(0x68e06129), X(0x498af6df), X(0x68c387e9),
X(0x49b41533), X(0x68a69e81), X(0x49dd282a), X(0x6889a4f6),
X(0x4a062fbd), X(0x686c9b4b), X(0x4a2f2be6), X(0x684f8186),
X(0x4a581c9e), X(0x683257ab), X(0x4a8101de), X(0x68151dbe),
X(0x4aa9dba2), X(0x67f7d3c5), X(0x4ad2a9e2), X(0x67da79c3),
X(0x4afb6c98), X(0x67bd0fbd), X(0x4b2423be), X(0x679f95b7),
X(0x4b4ccf4d), X(0x67820bb7), X(0x4b756f40), X(0x676471c0),
X(0x4b9e0390), X(0x6746c7d8), X(0x4bc68c36), X(0x67290e02),
X(0x4bef092d), X(0x670b4444), X(0x4c177a6e), X(0x66ed6aa1),
X(0x4c3fdff4), X(0x66cf8120), X(0x4c6839b7), X(0x66b187c3),
X(0x4c9087b1), X(0x66937e91), X(0x4cb8c9dd), X(0x6675658c),
X(0x4ce10034), X(0x66573cbb), X(0x4d092ab0), X(0x66390422),
X(0x4d31494b), X(0x661abbc5), X(0x4d595bfe), X(0x65fc63a9),
X(0x4d8162c4), X(0x65ddfbd3), X(0x4da95d96), X(0x65bf8447),
X(0x4dd14c6e), X(0x65a0fd0b), X(0x4df92f46), X(0x65826622),
X(0x4e210617), X(0x6563bf92), X(0x4e48d0dd), X(0x6545095f),
X(0x4e708f8f), X(0x6526438f), X(0x4e984229), X(0x65076e25),
X(0x4ebfe8a5), X(0x64e88926), X(0x4ee782fb), X(0x64c99498),
X(0x4f0f1126), X(0x64aa907f), X(0x4f369320), X(0x648b7ce0),
X(0x4f5e08e3), X(0x646c59bf), X(0x4f857269), X(0x644d2722),
X(0x4faccfab), X(0x642de50d), X(0x4fd420a4), X(0x640e9386),
X(0x4ffb654d), X(0x63ef3290), X(0x50229da1), X(0x63cfc231),
X(0x5049c999), X(0x63b0426d), X(0x5070e92f), X(0x6390b34a),
X(0x5097fc5e), X(0x637114cc), X(0x50bf031f), X(0x635166f9),
X(0x50e5fd6d), X(0x6331a9d4), X(0x510ceb40), X(0x6311dd64),
X(0x5133cc94), X(0x62f201ac), X(0x515aa162), X(0x62d216b3),
X(0x518169a5), X(0x62b21c7b), X(0x51a82555), X(0x6292130c),
X(0x51ced46e), X(0x6271fa69), X(0x51f576ea), X(0x6251d298),
X(0x521c0cc2), X(0x62319b9d), X(0x524295f0), X(0x6211557e),
X(0x5269126e), X(0x61f1003f), X(0x528f8238), X(0x61d09be5),
X(0x52b5e546), X(0x61b02876), X(0x52dc3b92), X(0x618fa5f7),
X(0x53028518), X(0x616f146c), X(0x5328c1d0), X(0x614e73da),
X(0x534ef1b5), X(0x612dc447), X(0x537514c2), X(0x610d05b7),
X(0x539b2af0), X(0x60ec3830), X(0x53c13439), X(0x60cb5bb7),
X(0x53e73097), X(0x60aa7050), X(0x540d2005), X(0x60897601),
X(0x5433027d), X(0x60686ccf), X(0x5458d7f9), X(0x604754bf),
X(0x547ea073), X(0x60262dd6), X(0x54a45be6), X(0x6004f819),
X(0x54ca0a4b), X(0x5fe3b38d), X(0x54efab9c), X(0x5fc26038),
X(0x55153fd4), X(0x5fa0fe1f), X(0x553ac6ee), X(0x5f7f8d46),
X(0x556040e2), X(0x5f5e0db3), X(0x5585adad), X(0x5f3c7f6b),
X(0x55ab0d46), X(0x5f1ae274), X(0x55d05faa), X(0x5ef936d1),
X(0x55f5a4d2), X(0x5ed77c8a), X(0x561adcb9), X(0x5eb5b3a2),
X(0x56400758), X(0x5e93dc1f), X(0x566524aa), X(0x5e71f606),
X(0x568a34a9), X(0x5e50015d), X(0x56af3750), X(0x5e2dfe29),
X(0x56d42c99), X(0x5e0bec6e), X(0x56f9147e), X(0x5de9cc33),
X(0x571deefa), X(0x5dc79d7c), X(0x5742bc06), X(0x5da5604f),
X(0x57677b9d), X(0x5d8314b1), X(0x578c2dba), X(0x5d60baa7),
X(0x57b0d256), X(0x5d3e5237), X(0x57d5696d), X(0x5d1bdb65),
X(0x57f9f2f8), X(0x5cf95638), X(0x581e6ef1), X(0x5cd6c2b5),
X(0x5842dd54), X(0x5cb420e0), X(0x58673e1b), X(0x5c9170bf),
X(0x588b9140), X(0x5c6eb258), X(0x58afd6bd), X(0x5c4be5b0),
X(0x58d40e8c), X(0x5c290acc), X(0x58f838a9), X(0x5c0621b2),
X(0x591c550e), X(0x5be32a67), X(0x594063b5), X(0x5bc024f0),
X(0x59646498), X(0x5b9d1154), X(0x598857b2), X(0x5b79ef96),
X(0x59ac3cfd), X(0x5b56bfbd), X(0x59d01475), X(0x5b3381ce),
X(0x59f3de12), X(0x5b1035cf), X(0x5a1799d1), X(0x5aecdbc5),
X(0x5a3b47ab), X(0x5ac973b5), X(0x5a5ee79a), X(0x5aa5fda5),
X(0x5a82799a), X(0x5a82799a)
};
/* {sin((2*i+1)*PI/4096), cos((2*i+1)*PI/4096)}, with i = 0 to 511 */
LOOKUP_T sincos_lookup1[1024] = {
X(0x001921fb), X(0x7ffffd88), X(0x004b65ee), X(0x7fffe9cb),
X(0x007da9d4), X(0x7fffc251), X(0x00afeda8), X(0x7fff8719),
X(0x00e23160), X(0x7fff3824), X(0x011474f6), X(0x7ffed572),
X(0x0146b860), X(0x7ffe5f03), X(0x0178fb99), X(0x7ffdd4d7),
X(0x01ab3e97), X(0x7ffd36ee), X(0x01dd8154), X(0x7ffc8549),
X(0x020fc3c6), X(0x7ffbbfe6), X(0x024205e8), X(0x7ffae6c7),
X(0x027447b0), X(0x7ff9f9ec), X(0x02a68917), X(0x7ff8f954),
X(0x02d8ca16), X(0x7ff7e500), X(0x030b0aa4), X(0x7ff6bcf0),
X(0x033d4abb), X(0x7ff58125), X(0x036f8a51), X(0x7ff4319d),
X(0x03a1c960), X(0x7ff2ce5b), X(0x03d407df), X(0x7ff1575d),
X(0x040645c7), X(0x7fefcca4), X(0x04388310), X(0x7fee2e30),
X(0x046abfb3), X(0x7fec7c02), X(0x049cfba7), X(0x7feab61a),
X(0x04cf36e5), X(0x7fe8dc78), X(0x05017165), X(0x7fe6ef1c),
X(0x0533ab20), X(0x7fe4ee06), X(0x0565e40d), X(0x7fe2d938),
X(0x05981c26), X(0x7fe0b0b1), X(0x05ca5361), X(0x7fde7471),
X(0x05fc89b8), X(0x7fdc247a), X(0x062ebf22), X(0x7fd9c0ca),
X(0x0660f398), X(0x7fd74964), X(0x06932713), X(0x7fd4be46),
X(0x06c5598a), X(0x7fd21f72), X(0x06f78af6), X(0x7fcf6ce8),
X(0x0729bb4e), X(0x7fcca6a7), X(0x075bea8c), X(0x7fc9ccb2),
X(0x078e18a7), X(0x7fc6df08), X(0x07c04598), X(0x7fc3dda9),
X(0x07f27157), X(0x7fc0c896), X(0x08249bdd), X(0x7fbd9fd0),
X(0x0856c520), X(0x7fba6357), X(0x0888ed1b), X(0x7fb7132b),
X(0x08bb13c5), X(0x7fb3af4e), X(0x08ed3916), X(0x7fb037bf),
X(0x091f5d06), X(0x7facac7f), X(0x09517f8f), X(0x7fa90d8e),
X(0x0983a0a7), X(0x7fa55aee), X(0x09b5c048), X(0x7fa1949e),
X(0x09e7de6a), X(0x7f9dbaa0), X(0x0a19fb04), X(0x7f99ccf4),
X(0x0a4c1610), X(0x7f95cb9a), X(0x0a7e2f85), X(0x7f91b694),
X(0x0ab0475c), X(0x7f8d8de1), X(0x0ae25d8d), X(0x7f895182),
X(0x0b147211), X(0x7f850179), X(0x0b4684df), X(0x7f809dc5),
X(0x0b7895f0), X(0x7f7c2668), X(0x0baaa53b), X(0x7f779b62),
X(0x0bdcb2bb), X(0x7f72fcb4), X(0x0c0ebe66), X(0x7f6e4a5e),
X(0x0c40c835), X(0x7f698461), X(0x0c72d020), X(0x7f64aabf),
X(0x0ca4d620), X(0x7f5fbd77), X(0x0cd6da2d), X(0x7f5abc8a),
X(0x0d08dc3f), X(0x7f55a7fa), X(0x0d3adc4e), X(0x7f507fc7),
X(0x0d6cda53), X(0x7f4b43f2), X(0x0d9ed646), X(0x7f45f47b),
X(0x0dd0d01f), X(0x7f409164), X(0x0e02c7d7), X(0x7f3b1aad),
X(0x0e34bd66), X(0x7f359057), X(0x0e66b0c3), X(0x7f2ff263),
X(0x0e98a1e9), X(0x7f2a40d2), X(0x0eca90ce), X(0x7f247ba5),
X(0x0efc7d6b), X(0x7f1ea2dc), X(0x0f2e67b8), X(0x7f18b679),
X(0x0f604faf), X(0x7f12b67c), X(0x0f923546), X(0x7f0ca2e7),
X(0x0fc41876), X(0x7f067bba), X(0x0ff5f938), X(0x7f0040f6),
X(0x1027d784), X(0x7ef9f29d), X(0x1059b352), X(0x7ef390ae),
X(0x108b8c9b), X(0x7eed1b2c), X(0x10bd6356), X(0x7ee69217),
X(0x10ef377d), X(0x7edff570), X(0x11210907), X(0x7ed94538),
X(0x1152d7ed), X(0x7ed28171), X(0x1184a427), X(0x7ecbaa1a),
X(0x11b66dad), X(0x7ec4bf36), X(0x11e83478), X(0x7ebdc0c6),
X(0x1219f880), X(0x7eb6aeca), X(0x124bb9be), X(0x7eaf8943),
X(0x127d7829), X(0x7ea85033), X(0x12af33ba), X(0x7ea1039b),
X(0x12e0ec6a), X(0x7e99a37c), X(0x1312a230), X(0x7e922fd6),
X(0x13445505), X(0x7e8aa8ac), X(0x137604e2), X(0x7e830dff),
X(0x13a7b1bf), X(0x7e7b5fce), X(0x13d95b93), X(0x7e739e1d),
X(0x140b0258), X(0x7e6bc8eb), X(0x143ca605), X(0x7e63e03b),
X(0x146e4694), X(0x7e5be40c), X(0x149fe3fc), X(0x7e53d462),
X(0x14d17e36), X(0x7e4bb13c), X(0x1503153a), X(0x7e437a9c),
X(0x1534a901), X(0x7e3b3083), X(0x15663982), X(0x7e32d2f4),
X(0x1597c6b7), X(0x7e2a61ed), X(0x15c95097), X(0x7e21dd73),
X(0x15fad71b), X(0x7e194584), X(0x162c5a3b), X(0x7e109a24),
X(0x165dd9f0), X(0x7e07db52), X(0x168f5632), X(0x7dff0911),
X(0x16c0cef9), X(0x7df62362), X(0x16f2443e), X(0x7ded2a47),
X(0x1723b5f9), X(0x7de41dc0), X(0x17552422), X(0x7ddafdce),
X(0x17868eb3), X(0x7dd1ca75), X(0x17b7f5a3), X(0x7dc883b4),
X(0x17e958ea), X(0x7dbf298d), X(0x181ab881), X(0x7db5bc02),
X(0x184c1461), X(0x7dac3b15), X(0x187d6c82), X(0x7da2a6c6),
X(0x18aec0db), X(0x7d98ff17), X(0x18e01167), X(0x7d8f4409),
X(0x19115e1c), X(0x7d85759f), X(0x1942a6f3), X(0x7d7b93da),
X(0x1973ebe6), X(0x7d719eba), X(0x19a52ceb), X(0x7d679642),
X(0x19d669fc), X(0x7d5d7a74), X(0x1a07a311), X(0x7d534b50),
X(0x1a38d823), X(0x7d4908d9), X(0x1a6a0929), X(0x7d3eb30f),
X(0x1a9b361d), X(0x7d3449f5), X(0x1acc5ef6), X(0x7d29cd8c),
X(0x1afd83ad), X(0x7d1f3dd6), X(0x1b2ea43a), X(0x7d149ad5),
X(0x1b5fc097), X(0x7d09e489), X(0x1b90d8bb), X(0x7cff1af5),
X(0x1bc1ec9e), X(0x7cf43e1a), X(0x1bf2fc3a), X(0x7ce94dfb),
X(0x1c240786), X(0x7cde4a98), X(0x1c550e7c), X(0x7cd333f3),
X(0x1c861113), X(0x7cc80a0f), X(0x1cb70f43), X(0x7cbcccec),
X(0x1ce80906), X(0x7cb17c8d), X(0x1d18fe54), X(0x7ca618f3),
X(0x1d49ef26), X(0x7c9aa221), X(0x1d7adb73), X(0x7c8f1817),
X(0x1dabc334), X(0x7c837ad8), X(0x1ddca662), X(0x7c77ca65),
X(0x1e0d84f5), X(0x7c6c06c0), X(0x1e3e5ee5), X(0x7c602fec),
X(0x1e6f342c), X(0x7c5445e9), X(0x1ea004c1), X(0x7c4848ba),
X(0x1ed0d09d), X(0x7c3c3860), X(0x1f0197b8), X(0x7c3014de),
X(0x1f325a0b), X(0x7c23de35), X(0x1f63178f), X(0x7c179467),
X(0x1f93d03c), X(0x7c0b3777), X(0x1fc4840a), X(0x7bfec765),
X(0x1ff532f2), X(0x7bf24434), X(0x2025dcec), X(0x7be5ade6),
X(0x205681f1), X(0x7bd9047c), X(0x208721f9), X(0x7bcc47fa),
X(0x20b7bcfe), X(0x7bbf7860), X(0x20e852f6), X(0x7bb295b0),
X(0x2118e3dc), X(0x7ba59fee), X(0x21496fa7), X(0x7b989719),
X(0x2179f64f), X(0x7b8b7b36), X(0x21aa77cf), X(0x7b7e4c45),
X(0x21daf41d), X(0x7b710a49), X(0x220b6b32), X(0x7b63b543),
X(0x223bdd08), X(0x7b564d36), X(0x226c4996), X(0x7b48d225),
X(0x229cb0d5), X(0x7b3b4410), X(0x22cd12bd), X(0x7b2da2fa),
X(0x22fd6f48), X(0x7b1feee5), X(0x232dc66d), X(0x7b1227d3),
X(0x235e1826), X(0x7b044dc7), X(0x238e646a), X(0x7af660c2),
X(0x23beab33), X(0x7ae860c7), X(0x23eeec78), X(0x7ada4dd8),
X(0x241f2833), X(0x7acc27f7), X(0x244f5e5c), X(0x7abdef25),
X(0x247f8eec), X(0x7aafa367), X(0x24afb9da), X(0x7aa144bc),
X(0x24dfdf20), X(0x7a92d329), X(0x250ffeb7), X(0x7a844eae),
X(0x25401896), X(0x7a75b74f), X(0x25702cb7), X(0x7a670d0d),
X(0x25a03b11), X(0x7a584feb), X(0x25d0439f), X(0x7a497feb),
X(0x26004657), X(0x7a3a9d0f), X(0x26304333), X(0x7a2ba75a),
X(0x26603a2c), X(0x7a1c9ece), X(0x26902b39), X(0x7a0d836d),
X(0x26c01655), X(0x79fe5539), X(0x26effb76), X(0x79ef1436),
X(0x271fda96), X(0x79dfc064), X(0x274fb3ae), X(0x79d059c8),
X(0x277f86b5), X(0x79c0e062), X(0x27af53a6), X(0x79b15435),
X(0x27df1a77), X(0x79a1b545), X(0x280edb23), X(0x79920392),
X(0x283e95a1), X(0x79823f20), X(0x286e49ea), X(0x797267f2),
X(0x289df7f8), X(0x79627e08), X(0x28cd9fc1), X(0x79528167),
X(0x28fd4140), X(0x79427210), X(0x292cdc6d), X(0x79325006),
X(0x295c7140), X(0x79221b4b), X(0x298bffb2), X(0x7911d3e2),
X(0x29bb87bc), X(0x790179cd), X(0x29eb0957), X(0x78f10d0f),
X(0x2a1a847b), X(0x78e08dab), X(0x2a49f920), X(0x78cffba3),
X(0x2a796740), X(0x78bf56f9), X(0x2aa8ced3), X(0x78ae9fb0),
X(0x2ad82fd2), X(0x789dd5cb), X(0x2b078a36), X(0x788cf94c),
X(0x2b36ddf7), X(0x787c0a36), X(0x2b662b0e), X(0x786b088c),
X(0x2b957173), X(0x7859f44f), X(0x2bc4b120), X(0x7848cd83),
X(0x2bf3ea0d), X(0x7837942b), X(0x2c231c33), X(0x78264849),
X(0x2c52478a), X(0x7814e9df), X(0x2c816c0c), X(0x780378f1),
X(0x2cb089b1), X(0x77f1f581), X(0x2cdfa071), X(0x77e05f91),
X(0x2d0eb046), X(0x77ceb725), X(0x2d3db928), X(0x77bcfc3f),
X(0x2d6cbb10), X(0x77ab2ee2), X(0x2d9bb5f6), X(0x77994f11),
X(0x2dcaa9d5), X(0x77875cce), X(0x2df996a3), X(0x7775581d),
X(0x2e287c5a), X(0x776340ff), X(0x2e575af3), X(0x77511778),
X(0x2e863267), X(0x773edb8b), X(0x2eb502ae), X(0x772c8d3a),
X(0x2ee3cbc1), X(0x771a2c88), X(0x2f128d99), X(0x7707b979),
X(0x2f41482e), X(0x76f5340e), X(0x2f6ffb7a), X(0x76e29c4b),
X(0x2f9ea775), X(0x76cff232), X(0x2fcd4c19), X(0x76bd35c7),
X(0x2ffbe95d), X(0x76aa670d), X(0x302a7f3a), X(0x76978605),
X(0x30590dab), X(0x768492b4), X(0x308794a6), X(0x76718d1c),
X(0x30b61426), X(0x765e7540), X(0x30e48c22), X(0x764b4b23),
X(0x3112fc95), X(0x76380ec8), X(0x31416576), X(0x7624c031),
X(0x316fc6be), X(0x76115f63), X(0x319e2067), X(0x75fdec60),
X(0x31cc7269), X(0x75ea672a), X(0x31fabcbd), X(0x75d6cfc5),
X(0x3228ff5c), X(0x75c32634), X(0x32573a3f), X(0x75af6a7b),
X(0x32856d5e), X(0x759b9c9b), X(0x32b398b3), X(0x7587bc98),
X(0x32e1bc36), X(0x7573ca75), X(0x330fd7e1), X(0x755fc635),
X(0x333debab), X(0x754bafdc), X(0x336bf78f), X(0x7537876c),
X(0x3399fb85), X(0x75234ce8), X(0x33c7f785), X(0x750f0054),
X(0x33f5eb89), X(0x74faa1b3), X(0x3423d78a), X(0x74e63108),
X(0x3451bb81), X(0x74d1ae55), X(0x347f9766), X(0x74bd199f),
X(0x34ad6b32), X(0x74a872e8), X(0x34db36df), X(0x7493ba34),
X(0x3508fa66), X(0x747eef85), X(0x3536b5be), X(0x746a12df),
X(0x356468e2), X(0x74552446), X(0x359213c9), X(0x744023bc),
X(0x35bfb66e), X(0x742b1144), X(0x35ed50c9), X(0x7415ece2),
X(0x361ae2d3), X(0x7400b69a), X(0x36486c86), X(0x73eb6e6e),
X(0x3675edd9), X(0x73d61461), X(0x36a366c6), X(0x73c0a878),
X(0x36d0d746), X(0x73ab2ab4), X(0x36fe3f52), X(0x73959b1b),
X(0x372b9ee3), X(0x737ff9ae), X(0x3758f5f2), X(0x736a4671),
X(0x37864477), X(0x73548168), X(0x37b38a6d), X(0x733eaa96),
X(0x37e0c7cc), X(0x7328c1ff), X(0x380dfc8d), X(0x7312c7a5),
X(0x383b28a9), X(0x72fcbb8c), X(0x38684c19), X(0x72e69db7),
X(0x389566d6), X(0x72d06e2b), X(0x38c278d9), X(0x72ba2cea),
X(0x38ef821c), X(0x72a3d9f7), X(0x391c8297), X(0x728d7557),
X(0x39497a43), X(0x7276ff0d), X(0x39766919), X(0x7260771b),
X(0x39a34f13), X(0x7249dd86), X(0x39d02c2a), X(0x72333251),
X(0x39fd0056), X(0x721c7580), X(0x3a29cb91), X(0x7205a716),
X(0x3a568dd4), X(0x71eec716), X(0x3a834717), X(0x71d7d585),
X(0x3aaff755), X(0x71c0d265), X(0x3adc9e86), X(0x71a9bdba),
X(0x3b093ca3), X(0x71929789), X(0x3b35d1a5), X(0x717b5fd3),
X(0x3b625d86), X(0x7164169d), X(0x3b8ee03e), X(0x714cbbeb),
X(0x3bbb59c7), X(0x71354fc0), X(0x3be7ca1a), X(0x711dd220),
X(0x3c143130), X(0x7106430e), X(0x3c408f03), X(0x70eea28e),
X(0x3c6ce38a), X(0x70d6f0a4), X(0x3c992ec0), X(0x70bf2d53),
X(0x3cc5709e), X(0x70a7589f), X(0x3cf1a91c), X(0x708f728b),
X(0x3d1dd835), X(0x70777b1c), X(0x3d49fde1), X(0x705f7255),
X(0x3d761a19), X(0x70475839), X(0x3da22cd7), X(0x702f2ccd),
X(0x3dce3614), X(0x7016f014), X(0x3dfa35c8), X(0x6ffea212),
X(0x3e262bee), X(0x6fe642ca), X(0x3e52187f), X(0x6fcdd241),
X(0x3e7dfb73), X(0x6fb5507a), X(0x3ea9d4c3), X(0x6f9cbd79),
X(0x3ed5a46b), X(0x6f841942), X(0x3f016a61), X(0x6f6b63d8),
X(0x3f2d26a0), X(0x6f529d40), X(0x3f58d921), X(0x6f39c57d),
X(0x3f8481dd), X(0x6f20dc92), X(0x3fb020ce), X(0x6f07e285),
X(0x3fdbb5ec), X(0x6eeed758), X(0x40074132), X(0x6ed5bb10),
X(0x4032c297), X(0x6ebc8db0), X(0x405e3a16), X(0x6ea34f3d),
X(0x4089a7a8), X(0x6e89ffb9), X(0x40b50b46), X(0x6e709f2a),
X(0x40e064ea), X(0x6e572d93), X(0x410bb48c), X(0x6e3daaf8),
X(0x4136fa27), X(0x6e24175c), X(0x416235b2), X(0x6e0a72c5),
X(0x418d6729), X(0x6df0bd35), X(0x41b88e84), X(0x6dd6f6b1),
X(0x41e3abbc), X(0x6dbd1f3c), X(0x420ebecb), X(0x6da336dc),
X(0x4239c7aa), X(0x6d893d93), X(0x4264c653), X(0x6d6f3365),
X(0x428fbabe), X(0x6d551858), X(0x42baa4e6), X(0x6d3aec6e),
X(0x42e584c3), X(0x6d20afac), X(0x43105a50), X(0x6d066215),
X(0x433b2585), X(0x6cec03af), X(0x4365e65b), X(0x6cd1947c),
X(0x43909ccd), X(0x6cb71482), X(0x43bb48d4), X(0x6c9c83c3),
X(0x43e5ea68), X(0x6c81e245), X(0x44108184), X(0x6c67300b),
X(0x443b0e21), X(0x6c4c6d1a), X(0x44659039), X(0x6c319975),
X(0x449007c4), X(0x6c16b521), X(0x44ba74bd), X(0x6bfbc021),
X(0x44e4d71c), X(0x6be0ba7b), X(0x450f2edb), X(0x6bc5a431),
X(0x45397bf4), X(0x6baa7d49), X(0x4563be60), X(0x6b8f45c7),
X(0x458df619), X(0x6b73fdae), X(0x45b82318), X(0x6b58a503),
X(0x45e24556), X(0x6b3d3bcb), X(0x460c5cce), X(0x6b21c208),
X(0x46366978), X(0x6b0637c1), X(0x46606b4e), X(0x6aea9cf8),
X(0x468a624a), X(0x6acef1b2), X(0x46b44e65), X(0x6ab335f4),
X(0x46de2f99), X(0x6a9769c1), X(0x470805df), X(0x6a7b8d1e),
X(0x4731d131), X(0x6a5fa010), X(0x475b9188), X(0x6a43a29a),
X(0x478546de), X(0x6a2794c1), X(0x47aef12c), X(0x6a0b7689),
X(0x47d8906d), X(0x69ef47f6), X(0x48022499), X(0x69d3090e),
X(0x482badab), X(0x69b6b9d3), X(0x48552b9b), X(0x699a5a4c),
X(0x487e9e64), X(0x697dea7b), X(0x48a805ff), X(0x69616a65),
X(0x48d16265), X(0x6944da10), X(0x48fab391), X(0x6928397e),
X(0x4923f97b), X(0x690b88b5), X(0x494d341e), X(0x68eec7b9),
X(0x49766373), X(0x68d1f68f), X(0x499f8774), X(0x68b5153a),
X(0x49c8a01b), X(0x689823bf), X(0x49f1ad61), X(0x687b2224),
X(0x4a1aaf3f), X(0x685e106c), X(0x4a43a5b0), X(0x6840ee9b),
X(0x4a6c90ad), X(0x6823bcb7), X(0x4a957030), X(0x68067ac3),
X(0x4abe4433), X(0x67e928c5), X(0x4ae70caf), X(0x67cbc6c0),
X(0x4b0fc99d), X(0x67ae54ba), X(0x4b387af9), X(0x6790d2b6),
X(0x4b6120bb), X(0x677340ba), X(0x4b89badd), X(0x67559eca),
X(0x4bb24958), X(0x6737ecea), X(0x4bdacc28), X(0x671a2b20),
X(0x4c034345), X(0x66fc596f), X(0x4c2baea9), X(0x66de77dc),
X(0x4c540e4e), X(0x66c0866d), X(0x4c7c622d), X(0x66a28524),
X(0x4ca4aa41), X(0x66847408), X(0x4ccce684), X(0x6666531d),
X(0x4cf516ee), X(0x66482267), X(0x4d1d3b7a), X(0x6629e1ec),
X(0x4d455422), X(0x660b91af), X(0x4d6d60df), X(0x65ed31b5),
X(0x4d9561ac), X(0x65cec204), X(0x4dbd5682), X(0x65b0429f),
X(0x4de53f5a), X(0x6591b38c), X(0x4e0d1c30), X(0x657314cf),
X(0x4e34ecfc), X(0x6554666d), X(0x4e5cb1b9), X(0x6535a86b),
X(0x4e846a60), X(0x6516dacd), X(0x4eac16eb), X(0x64f7fd98),
X(0x4ed3b755), X(0x64d910d1), X(0x4efb4b96), X(0x64ba147d),
X(0x4f22d3aa), X(0x649b08a0), X(0x4f4a4f89), X(0x647bed3f),
X(0x4f71bf2e), X(0x645cc260), X(0x4f992293), X(0x643d8806),
X(0x4fc079b1), X(0x641e3e38), X(0x4fe7c483), X(0x63fee4f8),
X(0x500f0302), X(0x63df7c4d), X(0x50363529), X(0x63c0043b),
X(0x505d5af1), X(0x63a07cc7), X(0x50847454), X(0x6380e5f6),
X(0x50ab814d), X(0x63613fcd), X(0x50d281d5), X(0x63418a50),
X(0x50f975e6), X(0x6321c585), X(0x51205d7b), X(0x6301f171),
X(0x5147388c), X(0x62e20e17), X(0x516e0715), X(0x62c21b7e),
X(0x5194c910), X(0x62a219aa), X(0x51bb7e75), X(0x628208a1),
X(0x51e22740), X(0x6261e866), X(0x5208c36a), X(0x6241b8ff),
X(0x522f52ee), X(0x62217a72), X(0x5255d5c5), X(0x62012cc2),
X(0x527c4bea), X(0x61e0cff5), X(0x52a2b556), X(0x61c06410),
X(0x52c91204), X(0x619fe918), X(0x52ef61ee), X(0x617f5f12),
X(0x5315a50e), X(0x615ec603), X(0x533bdb5d), X(0x613e1df0),
X(0x536204d7), X(0x611d66de), X(0x53882175), X(0x60fca0d2),
X(0x53ae3131), X(0x60dbcbd1), X(0x53d43406), X(0x60bae7e1),
X(0x53fa29ed), X(0x6099f505), X(0x542012e1), X(0x6078f344),
X(0x5445eedb), X(0x6057e2a2), X(0x546bbdd7), X(0x6036c325),
X(0x54917fce), X(0x601594d1), X(0x54b734ba), X(0x5ff457ad),
X(0x54dcdc96), X(0x5fd30bbc), X(0x5502775c), X(0x5fb1b104),
X(0x55280505), X(0x5f90478a), X(0x554d858d), X(0x5f6ecf53),
X(0x5572f8ed), X(0x5f4d4865), X(0x55985f20), X(0x5f2bb2c5),
X(0x55bdb81f), X(0x5f0a0e77), X(0x55e303e6), X(0x5ee85b82),
X(0x5608426e), X(0x5ec699e9), X(0x562d73b2), X(0x5ea4c9b3),
X(0x565297ab), X(0x5e82eae5), X(0x5677ae54), X(0x5e60fd84),
X(0x569cb7a8), X(0x5e3f0194), X(0x56c1b3a1), X(0x5e1cf71c),
X(0x56e6a239), X(0x5dfade20), X(0x570b8369), X(0x5dd8b6a7),
X(0x5730572e), X(0x5db680b4), X(0x57551d80), X(0x5d943c4e),
X(0x5779d65b), X(0x5d71e979), X(0x579e81b8), X(0x5d4f883b),
X(0x57c31f92), X(0x5d2d189a), X(0x57e7afe4), X(0x5d0a9a9a),
X(0x580c32a7), X(0x5ce80e41), X(0x5830a7d6), X(0x5cc57394),
X(0x58550f6c), X(0x5ca2ca99), X(0x58796962), X(0x5c801354),
X(0x589db5b3), X(0x5c5d4dcc), X(0x58c1f45b), X(0x5c3a7a05),
X(0x58e62552), X(0x5c179806), X(0x590a4893), X(0x5bf4a7d2),
X(0x592e5e19), X(0x5bd1a971), X(0x595265df), X(0x5bae9ce7),
X(0x59765fde), X(0x5b8b8239), X(0x599a4c12), X(0x5b68596d),
X(0x59be2a74), X(0x5b452288), X(0x59e1faff), X(0x5b21dd90),
X(0x5a05bdae), X(0x5afe8a8b), X(0x5a29727b), X(0x5adb297d),
X(0x5a4d1960), X(0x5ab7ba6c), X(0x5a70b258), X(0x5a943d5e),
};

View File

@@ -0,0 +1,208 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
* *
********************************************************************/
#define HEAD_ALIGN 64
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define MISC_C
#include "misc.h"
#include <sys/time.h>
static void **pointers=NULL;
static long *insertlist=NULL; /* We can't embed this in the pointer list;
a pointer can have any value... */
static char **files=NULL;
static long *file_bytes=NULL;
static int filecount=0;
static int ptop=0;
static int palloced=0;
static int pinsert=0;
typedef struct {
char *file;
long line;
long ptr;
long bytes;
} head;
long global_bytes=0;
long start_time=-1;
static void *_insert(void *ptr,long bytes,char *file,long line){
((head *)ptr)->file=file;
((head *)ptr)->line=line;
((head *)ptr)->ptr=pinsert;
((head *)ptr)->bytes=bytes-HEAD_ALIGN;
if(pinsert>=palloced){
palloced+=64;
if(pointers){
pointers=(void **)realloc(pointers,sizeof(void **)*palloced);
insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced);
}else{
pointers=(void **)malloc(sizeof(void **)*palloced);
insertlist=(long *)malloc(sizeof(long *)*palloced);
}
}
pointers[pinsert]=ptr;
if(pinsert==ptop)
pinsert=++ptop;
else
pinsert=insertlist[pinsert];
#ifdef _VDBG_GRAPHFILE
{
FILE *out;
struct timeval tv;
static struct timezone tz;
int i;
char buffer[80];
gettimeofday(&tv,&tz);
for(i=0;i<filecount;i++)
if(!strcmp(file,files[i]))break;
if(i==filecount){
filecount++;
if(!files){
files=malloc(filecount*sizeof(*files));
file_bytes=malloc(filecount*sizeof(*file_bytes));
}else{
files=realloc(files,filecount*sizeof(*files));
file_bytes=realloc(file_bytes,filecount*sizeof(*file_bytes));
}
files[i]=strdup(file);
file_bytes[i]=0;
}
file_bytes[i]+=bytes-HEAD_ALIGN;
if(start_time==-1)start_time=(tv.tv_sec*1000)+(tv.tv_usec/1000);
snprintf(buffer,80,"%s",file);
if(strchr(buffer,'.'))strchr(buffer,'.')[0]=0;
strcat(buffer,_VDBG_GRAPHFILE);
out=fopen(buffer,"a");
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
file_bytes[i]-(bytes-HEAD_ALIGN));
fprintf(out,"%ld, %ld # FILE %s LINE %ld\n",
-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
file_bytes[i],file,line);
fclose(out);
out=fopen("total"_VDBG_GRAPHFILE,"a");
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
global_bytes);
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
global_bytes+(bytes-HEAD_ALIGN));
fclose(out);
}
#endif
global_bytes+=(bytes-HEAD_ALIGN);
return(ptr+HEAD_ALIGN);
}
static void _ripremove(void *ptr){
int insert;
#ifdef _VDBG_GRAPHFILE
{
FILE *out=fopen("total"_VDBG_GRAPHFILE,"a");
struct timeval tv;
static struct timezone tz;
char buffer[80];
char *file =((head *)ptr)->file;
long bytes =((head *)ptr)->bytes;
int i;
gettimeofday(&tv,&tz);
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
global_bytes);
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
global_bytes-((head *)ptr)->bytes);
fclose(out);
for(i=0;i<filecount;i++)
if(!strcmp(file,files[i]))break;
snprintf(buffer,80,"%s",file);
if(strchr(buffer,'.'))strchr(buffer,'.')[0]=0;
strcat(buffer,_VDBG_GRAPHFILE);
out=fopen(buffer,"a");
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
file_bytes[i]);
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
file_bytes[i]-bytes);
fclose(out);
file_bytes[i]-=bytes;
}
#endif
global_bytes-=((head *)ptr)->bytes;
insert=((head *)ptr)->ptr;
insertlist[insert]=pinsert;
pinsert=insert;
if(pointers[insert]==NULL){
fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing previously freed memory\n");
fprintf(stderr,"\t%s %ld\n",((head *)ptr)->file,((head *)ptr)->line);
}
if(global_bytes<0){
fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing unmalloced memory\n");
}
pointers[insert]=NULL;
}
void _VDBG_dump(void){
int i;
for(i=0;i<ptop;i++){
head *ptr=pointers[i];
if(ptr)
fprintf(stderr,"unfreed bytes from %s:%ld\n",
ptr->file,ptr->line);
}
}
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){
bytes+=HEAD_ALIGN;
if(ptr){
ptr-=HEAD_ALIGN;
_ripremove(ptr);
ptr=realloc(ptr,bytes);
}else{
ptr=malloc(bytes);
memset(ptr,0,bytes);
}
return _insert(ptr,bytes,file,line);
}
extern void _VDBG_free(void *ptr,char *file,long line){
if(ptr){
ptr-=HEAD_ALIGN;
_ripremove(ptr);
free(ptr);
}
}

View File

@@ -0,0 +1,193 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: miscellaneous math and prototypes
********************************************************************/
#ifndef _V_RANDOM_H_
#define _V_RANDOM_H_
#include "ivorbiscodec.h"
#include "os_types.h"
/*#define _VDBG_GRAPHFILE "_0.m"*/
#ifdef _VDBG_GRAPHFILE
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line);
extern void _VDBG_free(void *ptr,char *file,long line);
#undef _ogg_malloc
#undef _ogg_calloc
#undef _ogg_realloc
#undef _ogg_free
#define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__)
#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__)
#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__)
#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__)
#endif
#include "asm_arm.h"
#ifndef _V_WIDE_MATH
#define _V_WIDE_MATH
#ifndef _LOW_ACCURACY_
/* 64 bit multiply */
#include <endian.h>
#include <sys/types.h>
#if BYTE_ORDER==LITTLE_ENDIAN
union magic {
struct {
ogg_int32_t lo;
ogg_int32_t hi;
} halves;
ogg_int64_t whole;
};
#endif
#if BYTE_ORDER==BIG_ENDIAN
union magic {
struct {
ogg_int32_t hi;
ogg_int32_t lo;
} halves;
ogg_int64_t whole;
};
#endif
static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
union magic magic;
magic.whole = (ogg_int64_t)x * y;
return magic.halves.hi;
}
static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return MULT32(x,y)<<1;
}
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
union magic magic;
magic.whole = (ogg_int64_t)x * y;
return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
}
#else
/* 32 bit multiply, more portable but less accurate */
/*
* Note: Precision is biased towards the first argument therefore ordering
* is important. Shift values were chosen for the best sound quality after
* many listening tests.
*/
/*
* For MULT32 and MULT31: The second argument is always a lookup table
* value already preshifted from 31 to 8 bits. We therefore take the
* opportunity to save on text space and use unsigned char for those
* tables in this case.
*/
static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
return (x >> 9) * y; /* y preshifted >>23 */
}
static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return (x >> 8) * y; /* y preshifted >>23 */
}
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
return (x >> 6) * y; /* y preshifted >>9 */
}
#endif
/*
* This should be used as a memory barrier, forcing all cached values in
* registers to wr writen back to memory. Might or might not be beneficial
* depending on the architecture and compiler.
*/
#define MB()
/*
* The XPROD functions are meant to optimize the cross products found all
* over the place in mdct.c by forcing memory operation ordering to avoid
* unnecessary register reloads as soon as memory is being written to.
* However this is only beneficial on CPUs with a sane number of general
* purpose registers which exclude the Intel x86. On Intel, better let the
* compiler actually reload registers directly from original memory by using
* macros.
*/
#ifdef __i386__
#define XPROD32(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT32(_a,_t)+MULT32(_b,_v); \
*(_y)=MULT32(_b,_t)-MULT32(_a,_v); }
#define XPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
#define XNPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
#else
static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
*x = MULT32(a, t) + MULT32(b, v);
*y = MULT32(b, t) - MULT32(a, v);
}
static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
*x = MULT31(a, t) + MULT31(b, v);
*y = MULT31(b, t) - MULT31(a, v);
}
static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
*x = MULT31(a, t) - MULT31(b, v);
*y = MULT31(b, t) + MULT31(a, v);
}
#endif
#endif
#ifndef _V_CLIP_MATH
#define _V_CLIP_MATH
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int ret=x;
ret-= ((x<=32767)-1)&(x-32767);
ret-= ((x>=-32768)-1)&(x+32768);
return(ret);
}
#endif
#endif

View File

@@ -0,0 +1,215 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: subsumed libogg includes
********************************************************************/
#ifndef _OGG_H
#define _OGG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "os_types.h"
#ifndef ONLY_C
#define ARM_LITTLE_ENDIAN
#endif
typedef struct ogg_buffer_state{
struct ogg_buffer *unused_buffers;
struct ogg_reference *unused_references;
int outstanding;
int shutdown;
} ogg_buffer_state;
typedef struct ogg_buffer {
unsigned char *data;
long size;
int refcount;
union {
ogg_buffer_state *owner;
struct ogg_buffer *next;
} ptr;
} ogg_buffer;
typedef struct ogg_reference {
ogg_buffer *buffer;
long begin;
long length;
struct ogg_reference *next;
} ogg_reference;
typedef struct oggpack_buffer {
#ifdef ARM_LITTLE_ENDIAN
int bitsLeftInSegment;
ogg_uint32_t *ptr;
long bitsLeftInWord;
#else
int headbit;
unsigned char *headptr;
long headend;
#endif /* ARM_LITTLE_ENDIAN */
/* memory management */
ogg_reference *head;
ogg_reference *tail;
/* render the byte/bit counter API constant time */
long count; /* doesn't count the tail */
} oggpack_buffer;
typedef struct oggbyte_buffer {
ogg_reference *baseref;
ogg_reference *ref;
unsigned char *ptr;
long pos;
long end;
} oggbyte_buffer;
typedef struct ogg_sync_state {
/* decode memory management pool */
ogg_buffer_state *bufferpool;
/* stream buffers */
ogg_reference *fifo_head;
ogg_reference *fifo_tail;
long fifo_fill;
/* stream sync management */
int unsynced;
int headerbytes;
int bodybytes;
} ogg_sync_state;
typedef struct ogg_stream_state {
ogg_reference *header_head;
ogg_reference *header_tail;
ogg_reference *body_head;
ogg_reference *body_tail;
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 */
long serialno;
long pageno;
ogg_int64_t 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 */
ogg_int64_t granulepos;
int lacing_fill;
ogg_uint32_t body_fill;
/* decode-side state data */
int holeflag;
int spanflag;
int clearflag;
int laceptr;
ogg_uint32_t body_fill_next;
} ogg_stream_state;
typedef struct {
ogg_reference *packet;
long bytes;
long b_o_s;
long e_o_s;
ogg_int64_t granulepos;
ogg_int64_t 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 */
} ogg_packet;
typedef struct {
ogg_reference *header;
int header_len;
ogg_reference *body;
long body_len;
} ogg_page;
/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
extern void oggpack_readinit(oggpack_buffer *b,ogg_reference *r);
extern long oggpack_look(oggpack_buffer *b,int bits);
extern void oggpack_adv(oggpack_buffer *b,int bits);
extern long oggpack_read(oggpack_buffer *b,int bits);
extern long oggpack_bytes(oggpack_buffer *b);
extern long oggpack_bits(oggpack_buffer *b);
extern int oggpack_eop(oggpack_buffer *b);
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
extern ogg_sync_state *ogg_sync_create(void);
extern int ogg_sync_destroy(ogg_sync_state *oy);
extern int ogg_sync_reset(ogg_sync_state *oy);
extern unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long size);
extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
/* Ogg BITSTREAM PRIMITIVES: general ***************************/
extern ogg_stream_state *ogg_stream_create(int serialno);
extern int ogg_stream_destroy(ogg_stream_state *os);
extern int ogg_stream_reset(ogg_stream_state *os);
extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
extern int ogg_stream_eos(ogg_stream_state *os);
extern int ogg_page_checksum_set(ogg_page *og);
extern int ogg_page_version(ogg_page *og);
extern int ogg_page_continued(ogg_page *og);
extern int ogg_page_bos(ogg_page *og);
extern int ogg_page_eos(ogg_page *og);
extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
extern ogg_uint32_t ogg_page_serialno(ogg_page *og);
extern ogg_uint32_t ogg_page_pageno(ogg_page *og);
extern int ogg_page_packets(ogg_page *og);
extern int ogg_page_getbuffer(ogg_page *og, unsigned char **buffer);
extern int ogg_packet_release(ogg_packet *op);
extern int ogg_page_release(ogg_page *og);
extern void ogg_page_dup(ogg_page *d, ogg_page *s);
/* Ogg BITSTREAM PRIMITIVES: return codes ***************************/
#define OGG_SUCCESS 0
#define OGG_HOLE -10
#define OGG_SPAN -11
#define OGG_EVERSION -12
#define OGG_ESERIAL -13
#define OGG_EINVAL -14
#define OGG_EEOS -15
#ifdef __cplusplus
}
#endif
#endif /* _OGG_H */

View File

@@ -0,0 +1,62 @@
#ifndef _OS_H
#define _OS_H
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal.
********************************************************************/
#include <math.h>
#include "os_types.h"
#ifndef _V_IFDEFJAIL_H_
# define _V_IFDEFJAIL_H_
# ifdef __GNUC__
# define STIN static __inline__
# elif _WIN32
# define STIN static __inline
# endif
#else
# define STIN static
#endif
#ifndef M_PI
# define M_PI (3.1415926536f)
#endif
#ifdef _WIN32
# include <malloc.h>
# define rint(x) (floor((x)+0.5f))
# define NO_FLOAT_MATH_LIB
# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef USE_MEMORY_H
# include <memory.h>
#endif
#ifndef min
# define min(x,y) ((x)>(y)?(y):(x))
#endif
#ifndef max
# define max(x,y) ((x)<(y)?(y):(x))
#endif
#endif /* _OS_H */

View File

@@ -0,0 +1,101 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal.
********************************************************************/
#ifndef _OS_TYPES_H
#define _OS_TYPES_H
#ifdef _LOW_ACCURACY_
# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9))
# define LOOKUP_T const unsigned char
#else
# define X(n) (n)
# define LOOKUP_T const ogg_int32_t
#endif
/* make it easy on the folks that want to compile the libs with a
different malloc than stdlib */
#define _ogg_malloc malloc
#define _ogg_calloc calloc
#define _ogg_realloc realloc
#define _ogg_free free
#if defined (_WIN32_WCE)
typedef unsigned short ogg_uint16_t;
typedef short ogg_int16_t;
typedef int ogg_int32_t;
typedef unsigned int ogg_uint32_t;
typedef long long ogg_int64_t;
#elif defined(_WIN32)
# ifndef __GNUC__
/* MSVC/Borland */
typedef __int64 ogg_int64_t;
typedef __int32 ogg_int32_t;
typedef unsigned __int32 ogg_uint32_t;
typedef __int16 ogg_int16_t;
typedef unsigned __int16 ogg_uint16_t;
# else
/* Cygwin */
#include <_G_config.h>
typedef _G_int64_t ogg_int64_t;
typedef _G_int32_t ogg_int32_t;
typedef _G_uint32_t ogg_uint32_t;
typedef _G_int16_t ogg_int16_t;
typedef _G_uint16_t ogg_uint16_t;
# endif
#elif defined(__MACOS__)
# include <sys/types.h>
typedef SInt16 ogg_int16_t;
typedef UInt16 ogg_uint16_t;
typedef SInt32 ogg_int32_t;
typedef UInt32 ogg_uint32_t;
typedef SInt64 ogg_int64_t;
#elif defined(__MACOSX__) /* MacOS X Framework build */
# include <sys/types.h>
typedef int16_t ogg_int16_t;
typedef u_int16_t ogg_uint16_t;
typedef int32_t ogg_int32_t;
typedef u_int32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
#elif defined(__BEOS__)
/* Be */
# include <inttypes.h>
#elif defined (__EMX__)
/* OS/2 GCC */
typedef short ogg_int16_t;
typedef unsigned short ogg_uint16_t;
typedef int ogg_int32_t;
typedef unsigned int ogg_uint32_t;
typedef long long ogg_int64_t;
#else
# include <sys/types.h>
# include "config_types.h"
#endif
#endif /* _OS_TYPES_H */

View File

@@ -0,0 +1,110 @@
/*
* Dead simple processor sampling profiling code.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "windows.h"
static int *Profile_table = NULL;
static int Profile_table_size = 0;
static int Profile_table_granularity = 0;
static DWORD (*ProfileFn)(void *);
static void *ProfileArgs;
static volatile HANDLE threadToProfile = NULL;
static volatile HANDLE thread = NULL;
static volatile int die = 0;
static volatile int taskDone = 0;
void Profile_dump()
{
FILE *file;
die = 1;
while (die)
{
Sleep(1);
}
file = fopen("profile", "wb");
if(file == NULL)
{
Output("Failed to open profile output");
return;
}
Output("Dumping profile...");
fputc('P', file);
fputc('R', file);
fputc('0', file);
fputc('F', file);
fwrite(&Profile_table_granularity, 4, 1, file);
fwrite(Profile_table, 4, Profile_table_size>>2, file);
fclose(file);
}
static DWORD ticker(LPVOID dummy)
{
CONTEXT context;
int offset;
memset(&context, 0, sizeof(CONTEXT));
{
while (!die)
{
Sleep(10);
context.ContextFlags = CONTEXT_FULL;
if (GetThreadContext(thread, &context))
{
offset = context.Pc & ~0xF0000000;
offset >>= Profile_table_granularity+2;
if (offset >= (Profile_table_size>>2))
{
offset = 0;
}
}
else
{
offset = 0;
}
Profile_table[offset]++;
}
}
die = 0;
}
void Profile_init(int size,
int granularity)
{
HANDLE myThread;
Profile_table_granularity = granularity;
Profile_table_size = (size+(1<<granularity)-1)>>granularity;
Profile_table = (int *)malloc(Profile_table_size);
if (Profile_table == NULL)
{
Output("Failed to get memory for Profile table\n");
exit(EXIT_FAILURE);
}
memset(Profile_table, 0, Profile_table_size);
thread = (HANDLE)GetCurrentThreadId();
Output("Commencing profiling");
myThread = CreateThread(NULL, /* Security Attributes */
0,
&ticker,
NULL,
0,
NULL);
if (myThread == NULL)
{
Output("Profiler failed to start");
exit(EXIT_FAILURE);
}
SetThreadPriority(myThread, THREAD_PRIORITY_ABOVE_NORMAL);
}

View File

@@ -0,0 +1,225 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: residue backend 0, 1 and 2 implementation
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
#include "codebook.h"
#include "misc.h"
#include "os.h"
void res_clear_info(vorbis_info_residue *info){
if(info){
if(info->stagemasks)_ogg_free(info->stagemasks);
if(info->stagebooks)_ogg_free(info->stagebooks);
memset(info,0,sizeof(*info));
}
}
/* vorbis_info is for range checking */
int res_unpack(vorbis_info_residue *info,
vorbis_info *vi,oggpack_buffer *opb){
int j,k;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
memset(info,0,sizeof(*info));
info->type=oggpack_read(opb,16);
if(info->type>2 || info->type<0)goto errout;
info->begin=oggpack_read(opb,24);
info->end=oggpack_read(opb,24);
info->grouping=oggpack_read(opb,24)+1;
info->partitions=oggpack_read(opb,6)+1;
info->groupbook=oggpack_read(opb,8);
if(info->groupbook>=ci->books)goto errout;
info->stagemasks=_ogg_malloc(info->partitions*sizeof(*info->stagemasks));
info->stagebooks=_ogg_malloc(info->partitions*8*sizeof(*info->stagebooks));
for(j=0;j<info->partitions;j++){
int cascade=oggpack_read(opb,3);
if(oggpack_read(opb,1))
cascade|=(oggpack_read(opb,5)<<3);
info->stagemasks[j]=cascade;
}
for(j=0;j<info->partitions;j++){
for(k=0;k<8;k++){
if((info->stagemasks[j]>>k)&1){
unsigned char book=oggpack_read(opb,8);
if(book>=ci->books)goto errout;
info->stagebooks[j*8+k]=book;
if(k+1>info->stages)info->stages=k+1;
}else
info->stagebooks[j*8+k]=0xff;
}
}
if(oggpack_eop(opb))goto errout;
return 0;
errout:
res_clear_info(info);
return 1;
}
int res_inverse(vorbis_dsp_state *vd,vorbis_info_residue *info,
ogg_int32_t **in,int *nonzero,int ch){
int i,j,k,s,used=0;
codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
codebook *phrasebook=ci->book_param+info->groupbook;
int samples_per_partition=info->grouping;
int partitions_per_word=phrasebook->dim;
int pcmend=ci->blocksizes[vd->W];
if(info->type<2){
int max=pcmend>>1;
int end=(info->end<max?info->end:max);
int n=end-info->begin;
if(n>0){
int partvals=n/samples_per_partition;
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
for(i=0;i<ch;i++)
if(nonzero[i])
in[used++]=in[i];
ch=used;
if(used){
char **partword=(char **)alloca(ch*sizeof(*partword));
for(j=0;j<ch;j++)
partword[j]=(char *)alloca(partwords*partitions_per_word*
sizeof(*partword[j]));
for(s=0;s<info->stages;s++){
for(i=0;i<partvals;){
if(s==0){
/* fetch the partition word for each channel */
partword[0][i+partitions_per_word-1]=1;
for(k=partitions_per_word-2;k>=0;k--)
partword[0][i+k]=partword[0][i+k+1]*info->partitions;
for(j=1;j<ch;j++)
for(k=partitions_per_word-1;k>=0;k--)
partword[j][i+k]=partword[j-1][i+k];
for(j=0;j<ch;j++){
int temp=vorbis_book_decode(phrasebook,&vd->opb);
if(temp==-1)goto eopbreak;
/* this can be done quickly in assembly due to the quotient
always being at most six bits */
for(k=0;k<partitions_per_word;k++){
ogg_uint32_t div=partword[j][i+k];
partword[j][i+k]=temp/div;
temp-=partword[j][i+k]*div;
}
}
}
/* 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++){
long offset=info->begin+i*samples_per_partition;
if(info->stagemasks[(int)partword[j][i]]&(1<<s)){
codebook *stagebook=ci->book_param+
info->stagebooks[(partword[j][i]<<3)+s];
if(info->type){
if(vorbis_book_decodev_add(stagebook,in[j]+offset,&vd->opb,
samples_per_partition,-8)==-1)
goto eopbreak;
}else{
if(vorbis_book_decodevs_add(stagebook,in[j]+offset,&vd->opb,
samples_per_partition,-8)==-1)
goto eopbreak;
}
}
}
}
}
}
}
}else{
int max=(pcmend*ch)>>1;
int end=(info->end<max?info->end:max);
int n=end-info->begin;
if(n>0){
int partvals=n/samples_per_partition;
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
char *partword=
(char *)alloca(partwords*partitions_per_word*sizeof(*partword));
int beginoff=info->begin/ch;
for(i=0;i<ch;i++)if(nonzero[i])break;
if(i==ch)return(0); /* no nonzero vectors */
samples_per_partition/=ch;
for(s=0;s<info->stages;s++){
for(i=0;i<partvals;){
if(s==0){
int temp;
partword[i+partitions_per_word-1]=1;
for(k=partitions_per_word-2;k>=0;k--)
partword[i+k]=partword[i+k+1]*info->partitions;
/* fetch the partition word */
temp=vorbis_book_decode(phrasebook,&vd->opb);
if(temp==-1)goto eopbreak;
/* this can be done quickly in assembly due to the quotient
always being at most six bits */
for(k=0;k<partitions_per_word;k++){
ogg_uint32_t div=partword[i+k];
partword[i+k]=temp/div;
temp-=partword[i+k]*div;
}
}
/* now we decode residual values for the partitions */
for(k=0;k<partitions_per_word && i<partvals;k++,i++)
if(info->stagemasks[(int)partword[i]]&(1<<s)){
codebook *stagebook=ci->book_param+
info->stagebooks[(partword[i]<<3)+s];
if(vorbis_book_decodevv_add(stagebook,in,
i*samples_per_partition+beginoff,ch,
&vd->opb,
samples_per_partition,-8)==-1)
goto eopbreak;
}
}
}
}
}
errout:
eopbreak:
return 0;
}

View File

@@ -0,0 +1,120 @@
.text
.global stmiaTest
.global strTest
.global smullTest
stmiaTest:
STMFD r13!,{r4-r12,r14}
@ r0 = start
@ r1 = size
@ r2 = loops
stmiaTestLoop2:
MOV r3,r0
MOV r4,r1
stmiaTestLoop:
STMIA r3!,{r6,r7,r8,r9,r10,r11,r12,r14}
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
SUBS r4,r4,#8*4
BGT stmiaTestLoop
SUBS r2,r2,#1
BGT stmiaTestLoop2
LDMFD r13!,{r4-r12,PC}
strTest:
STMFD r13!,{r4-r12,r14}
@ r0 = start
@ r1 = size
@ r2 = loops
strTestLoop2:
MOV r3,r0
MOV r4,r1
strTestLoop:
STR r6,[r3],#4
STR r7,[r3],#4
STR r8,[r3],#4
STR r9,[r3],#4
STR r10,[r3],#4
STR r11,[r3],#4
STR r12,[r3],#4
STR r14,[r3],#4
@STMIA r3!,{r6,r7,r8,r9,r10,r11,r12,r14}
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
MOV r6,#0
SUBS r4,r4,#8*4
BGT strTestLoop
SUBS r2,r2,#1
BGT strTestLoop2
LDMFD r13!,{r4-r12,PC}
smullTest:
STMFD r13!,{r4-r12,r14}
@ r0 = start
@ r1 = size
@ r2 = loops
smullTestLoop2:
MVN r7,#0xAA000000
MVN r8,#0xAA000000
MOV r3,r0
MOV r4,r1
smullTestLoop:
SMULL r14,r12,r7,r8
MOV r6,#0
SMLAL r14,r12,r7,r8
MOV r6,#0
SMULL r14,r11,r7,r8
MOV r6,#0
SMLAL r14,r11,r7,r8
SUBS r4,r4,#8*4
BGT smullTestLoop
SUBS r2,r2,#1
BGT smullTestLoop2
LDMFD r13!,{r4-r12,PC}

View File

@@ -0,0 +1,423 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
* *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: simple example decoder using vorbisidec
********************************************************************/
/* Takes a vorbis bitstream from stdin and writes raw stereo PCM to
stdout using vorbisfile. Using vorbisfile is much simpler than
dealing with libvorbis. */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "ivorbiscodec.h"
#include "ivorbisfile.h"
#include "time.h"
#include "windows.h"
#define PROFILE
#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
#include <io.h>
#include <fcntl.h>
#endif
char pcmout[4096]; /* take 4k out of the data segment, not the stack */
char ref[4096]; /* take 4k out of the data segment, not the stack */
char text[4096];
void Output(const char *fmt, ...)
{
#ifdef _WIN32_WCE
va_list ap;
char *t = text;
WCHAR uni[4096];
WCHAR *u = uni;
va_start(ap,fmt);
vsprintf(text, fmt, ap);
va_end(ap);
while (*t != 0)
{
*u++ = (WCHAR)(*t++);
}
*u++ = 0;
OutputDebugString(uni);
#else
vfprintf(stderr, fmt, ap);
#endif
}
typedef struct
{
FILE *in;
FILE *out;
FILE *refin;
FILE *refout;
int max_samples;
} TestParams;
static DWORD run_test(void *tp)
{
TestParams *params = (TestParams *)tp;
FILE *in = params->in;
FILE *out = params->out;
FILE *refin = params->refin;
FILE *refout = params->refout;
int max_samples = params->max_samples;
OggVorbis_File vf;
int eof=0;
int current_section;
int maxdiff = 0;
int countdiffs = 0;
int samples = 0;
if(ov_open(in, &vf, NULL, 0) < 0) {
Output("Input does not appear to be an Ogg bitstream.\n");
exit(1);
}
/* Throw the comments plus a few lines about the bitstream we're
decoding */
{
char **ptr=ov_comment(&vf,-1)->user_comments;
vorbis_info *vi=ov_info(&vf,-1);
if (out != NULL)
{
while(*ptr){
Output("%s\n",*ptr);
++ptr;
}
Output("\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
Output("\nDecoded length: %ld samples\n",
(long)ov_pcm_total(&vf,-1));
Output("Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
}
}
while((!eof) && (max_samples > 0)){
long ret=ov_read(&vf,pcmout,sizeof(pcmout),&current_section);
if (ret == 0) {
/* EOF */
eof=1;
} else if (ret < 0) {
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
} else {
/* we don't bother dealing with sample rate changes, etc, but
you'll have to*/
if (out != NULL)
{
fwrite(pcmout,1,ret,out);
}
max_samples -= ret>>1;
if (refout != NULL)
{
fwrite(pcmout,1,ret,refout);
samples += ret>>1;
Output("%d", samples);
}
if (refin != NULL)
{
int i, diff;
fread(ref,1,ret,refin);
for (i=0; i<(ret>>1);i++)
{
diff = ((short *)pcmout)[i] - ((short *)ref)[i];
if (diff != 0)
{
if (diff < 0)
diff = -diff;
if (diff > maxdiff)
maxdiff = diff;
countdiffs++;
if (countdiffs < 50)
{
Output("samples differ: %x vs %x\n",
((unsigned short *)pcmout)[i],
((unsigned short *)ref)[i]);
}
else if ((countdiffs % 100) == 0)
{
Output("%d differences, maximum = %d\n",
countdiffs, maxdiff);
}
}
}
}
}
}
/* cleanup */
ov_clear(&vf);
return 0;
}
static int filetimetoms(FILETIME *time)
{
unsigned long long l;
l = ((unsigned long long)time->dwLowDateTime) + (((unsigned long long)time->dwHighDateTime)<<32);
return (int)(l/10000);
}
char speedblock[32768];
void speedtest()
{
int readtime;
FILETIME userStartTime, userStopTime;
FILETIME kernelStartTime, kernelStopTime;
FILETIME exitStartTime, exitStopTime;
FILETIME creationStartTime, creationStopTime;
Output("Speed test: STMIA speed\n");
GetThreadTimes(GetCurrentThread(),
&creationStartTime,
&exitStartTime,
&kernelStartTime,
&userStartTime);
stmiaTest(speedblock, 32768, 65536);
GetThreadTimes(GetCurrentThread(),
&creationStopTime,
&exitStopTime,
&kernelStopTime,
&userStopTime);
readtime = filetimetoms(&userStopTime)-filetimetoms(&userStartTime);
Output("Speed test complete: Timing=%g\n",
((double)readtime)/1000);
Output("Speed test: STR speed\n");
GetThreadTimes(GetCurrentThread(),
&creationStartTime,
&exitStartTime,
&kernelStartTime,
&userStartTime);
strTest(speedblock, 32768, 65536);
GetThreadTimes(GetCurrentThread(),
&creationStopTime,
&exitStopTime,
&kernelStopTime,
&userStopTime);
readtime = filetimetoms(&userStopTime)-filetimetoms(&userStartTime);
Output("Speed test complete: Timing=%g\n",
((double)readtime)/1000);
Output("Speed test: SMULL speed\n");
GetThreadTimes(GetCurrentThread(),
&creationStartTime,
&exitStartTime,
&kernelStartTime,
&userStartTime);
smullTest(speedblock, 32768, 65536);
GetThreadTimes(GetCurrentThread(),
&creationStopTime,
&exitStopTime,
&kernelStopTime,
&userStopTime);
readtime = filetimetoms(&userStopTime)-filetimetoms(&userStartTime);
Output("Speed test complete: Timing=%g\n",
((double)readtime)/1000);
}
int main(int argc, char *argv[]){
FILE *in;
FILE *out = NULL;
FILE *refin = NULL;
FILE *refout = NULL;
int dectime, readtime;
FILETIME userStartTime, userStopTime;
FILETIME kernelStartTime, kernelStopTime;
FILETIME exitStartTime, exitStopTime;
FILETIME creationStartTime, creationStopTime;
TestParams params;
if (argc < 2)
{
Output("Syntax: testtremor <infile> [<outfile>]\n");
exit(EXIT_FAILURE);
}
#ifdef PROFILE
in = fopen(argv[1], "rb");
if (in == NULL)
{
Output("Failed to open '%s' for input\n", argv[1]);
exit(EXIT_FAILURE);
}
params.in = in;
params.out = NULL;
params.refin = NULL;
params.refout = NULL;
params.max_samples = 0x7FFFFFFF;
Profile_init(184000, 4);
run_test(&params);
Profile_dump();
#else
in = fopen(argv[1], "rb");
if (in == NULL)
{
Output("Failed to open '%s' for input\n", argv[1]);
exit(EXIT_FAILURE);
}
if (argc >= 3)
{
out = fopen(argv[2], "wb");
if (out == NULL)
{
Output("Failed to open '%s' for output\n", argv[2]);
exit(EXIT_FAILURE);
}
}
if (argc >= 4)
{
refin = fopen(argv[3], "rb");
if (refin == NULL)
{
Output("Can't find reference file. Creating instead.\n");
refout = fopen(argv[3], "wb");
if (refout == NULL)
{
Output("Failed to open '%s' as output reference file\n", argv[3]);
exit(EXIT_FAILURE);
}
}
}
Output("First test: Decode correctness\n");
params.in = in;
params.out = out;
params.refin = refin;
params.refout = refout;
params.max_samples = 1*1024*1024;
run_test(&params);
Output("First test complete\n");
if (out != NULL)
fclose(out);
if (refin != NULL)
fclose(refin);
if (refout != NULL)
fclose(refout);
Output("Second test: Decode speed\n");
in = fopen(argv[1], "rb");
if (in == NULL)
{
Output("Failed to open '%s' for input\n", argv[1]);
exit(EXIT_FAILURE);
}
GetThreadTimes(GetCurrentThread(),
&creationStartTime,
&exitStartTime,
&kernelStartTime,
&userStartTime);
params.in = in;
params.out = NULL;
params.refin = NULL;
params.refout = NULL;
params.max_samples = 0x7FFFFFFF;
run_test(&params);
GetThreadTimes(GetCurrentThread(),
&creationStopTime,
&exitStopTime,
&kernelStopTime,
&userStopTime);
dectime = filetimetoms(&userStopTime)-filetimetoms(&userStartTime);
Output("Second test complete: Timing=%g\n",
((double)dectime)/1000);
Output("Third test: File read speed\n");
in = fopen(argv[1], "rb");
if (in == NULL)
{
Output("Failed to open '%s' for input\n", argv[1]);
exit(EXIT_FAILURE);
}
GetThreadTimes(GetCurrentThread(),
&creationStartTime,
&exitStartTime,
&kernelStartTime,
&userStartTime);
while (!feof(in))
{
fread(pcmout,1,4096,in);
}
GetThreadTimes(GetCurrentThread(),
&creationStopTime,
&exitStopTime,
&kernelStopTime,
&userStopTime);
readtime = filetimetoms(&userStopTime)-filetimetoms(&userStartTime);
Output("Third test complete: Timing=%g\n",
((double)readtime)/1000);
Output("Adjusted decode time: Timing=%g\n",
((double)(dectime-readtime))/1000);
#endif
Output("Done.\n");
return(0);
}
#ifdef _WIN32_WCE
#define TESTFILE 0
int WinMain(HINSTANCE h,HINSTANCE i,LPWSTR l,int n)
{
#if TESTFILE == 9
char *argv[] = { "testtremor",
"\\Storage Card\\Tremolo\\infile9.ogg",
"\\Storage Card\\Tremolo\\output9.pcm",
#ifdef _LOW_ACCURACY_
"\\Storage Card\\Tremolo\\outputL9.ref",
#else
"\\Storage Card\\Tremolo\\output9.ref",
#endif /* _LOW_ACCURACY_ */
NULL };
#endif
#if TESTFILE == 2
char *argv[] = { "testtremor",
"\\Storage Card\\Tremolo\\infile2.ogg",
"\\Storage Card\\Tremolo\\output2.pcm",
#ifdef _LOW_ACCURACY_
"\\Storage Card\\Tremolo\\outputL2.ref",
#else
"\\Storage Card\\Tremolo\\output2.ref",
#endif /* _LOW_ACCURACY_ */
NULL };
#endif
#if TESTFILE == 0
char *argv[] = { "testtremor",
"\\Storage Card\\Tremolo\\infile.ogg",
"\\Storage Card\\Tremolo\\output.pcm",
#ifdef _LOW_ACCURACY_
"\\Storage Card\\Tremolo\\outputL.ref",
#else
"\\Storage Card\\Tremolo\\output.ref",
#endif /* _LOW_ACCURACY_ */
NULL };
#endif
return main(4, argv);
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff