Commit 7913073d authored by Gloria Wang's avatar Gloria Wang
Browse files

Tremolo (an ARM optimised version of the Tremor library for doing Ogg Vorbis decompression)

parent aedba5ff
ifeq ($(TARGET_ARCH),arm)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES = \
Tremolo/bitwise.c \
Tremolo/codebook.c \
Tremolo/dsp.c \
Tremolo/floor0.c \
Tremolo/floor1.c \
Tremolo/floor_lookup.c \
Tremolo/framing.c \
Tremolo/mapping0.c \
Tremolo/mdct.c \
Tremolo/misc.c \
Tremolo/res012.c \
Tremolo/treminfo.c \
Tremolo/vorbisfile.c \
Tremolo/bitwiseARM.s \
Tremolo/dpen.s \
Tremolo/floor1ARM.s \
Tremolo/mdctARM.s
LOCAL_CFLAGS+= -O2 \
-D_ARM_ASSEM_
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH)/Tremolo
LOCAL_ARM_MODE := arm
LOCAL_MODULE := libvorbisidec
include $(BUILD_SHARED_LIBRARY)
endif
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
---------------------------------------------------------------------
Original COPYING file from Tremor distribution
Copyright (c) 2002, Xiph.org Foundation
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.
This version of Tremolo is derived from Tremolo library version
0.07. It has been patched against publicly known vulnerabilities
with sample files available here:
http://static.dataspill.org/releases/ogg/examples/
When syncing with svn, please ensure that these defects are not
reintroduced.
---------------------------------------------------------------------------
This README covers the Tremolo library, version 0.07.
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.
Tremolo is released under different licenses to Tremor.
Tremor is released under a BSD like license (see the original README
included below, and other documentation for an exact statement of
its licensing terms).
Tremolo is released under twin licenses.
Firstly it is released under the GPL (v2) - this is so that fully
GPLd software such as ScummVM may use it with no problems.
Secondly it is released under a homebrew license of my own. If you
want to use Tremolo in free(*) software, you may do so without
charge. If you want to use Tremolo in non-free(*) software then
you must contact me and come to an agreement first.
* Free software, for the purposes of this definition is defined to
be software that is given away for free to anyone, with no more than
a nominal charge for media permitted.
Software that comes bundled with hardware, or is tied to specific
hardware is NOT free.
Software given away only on magazine discs, or only to subscribers
for another service is NOT free (though software which is given away
to everyone clearly may be included on magazine discs or given to
subscribers).
Shareware is NOT free, but reasonably priced shareware will generally
get permission to use it as it it was free by contacting me first.
If in doubt about whether your software counts as 'free' or not,
contact me. (In fact, contact me if you use the software in anything,
it'd be nice to know!)
I am not looking to make my fortune with this, but if (say) Apple
wanted to put it in the firmware for an iPod, it'd be nice to get
something for my efforts.
I Am Not A Lawyer, so all this is probably horribly unclear. If
anyone wants to hire me a lawyer for the afternoon, we can formalise
it.
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
#!/usr/bin/perl
my $bigend; # little/big endian
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
while ($ARGV[0] =~ /^-/) {
$_ = shift;
last if /^--/;
if (/^-n/) {
$nflag++;
next;
}
die "I don't recognize this switch: $_\\n";
}
$printit++ unless $nflag;
$\ = "\n"; # automatically add newline on print
$n=0;
$thumb = 0; # ARM mode by default, not Thumb.
LINE:
while (<>) {
# For ADRLs we need to add a new line after the substituted one.
$addPadding = 0;
# First, we do not dare to touch *anything* inside double quotes, do we?
# Second, if you want a dollar character in the string,
# insert two of them -- that's how ARM C and assembler treat strings.
s/^([A-Za-z_]\w*)[ \t]+DCB[ \t]*\"/$1: .ascii \"/ && do { s/\$\$/\$/g; next };
s/\bDCB\b[ \t]*\"/.ascii \"/ && do { s/\$\$/\$/g; next };
s/^(\S+)\s+RN\s+(\S+)/$1 .req r$2/ && do { s/\$\$/\$/g; next };
# If substituted -- leave immediately !
s/@/,:/;
s/;/@/;
while ( /@.*'/ ) {
s/(@.*)'/$1/g;
}
s/\{FALSE\}/0/g;
s/\{TRUE\}/1/g;
s/\{(\w\w\w\w+)\}/$1/g;
s/\bINCLUDE[ \t]*([^ \t\n]+)/.include \"$1\"/;
s/\bGET[ \t]*([^ \t\n]+)/.include \"$1\"/;
s/\bIMPORT\b/.extern/;
s/\bEXPORT\b/.global/;
s/^(\s+)\[/$1IF/;
s/^(\s+)\|/$1ELSE/;
s/^(\s+)\]/$1ENDIF/;
s/IF *:DEF:/ .ifdef/;
s/IF *:LNOT: *:DEF:/ .ifndef/;
s/ELSE/ .else/;
s/ENDIF/ .endif/;
if( /\bIF\b/ ) {
s/\bIF\b/ .if/;
s/=/==/;
}
if ( $n == 2) {
s/\$/\\/g;
}
if ($n == 1) {
s/\$//g;
s/label//g;
$n = 2;
}
if ( /MACRO/ ) {
s/MACRO *\n/.macro/;
$n=1;
}
if ( /\bMEND\b/ ) {
s/\bMEND\b/.endm/;
$n=0;
}
# ".rdata" doesn't work in 'as' version 2.13.2, as it is ".rodata" there.
#
if ( /\bAREA\b/ ) {
s/^(.+)CODE(.+)READONLY(.*)/ .text/;
s/^(.+)DATA(.+)READONLY(.*)/ .section .rdata\n .align 2/;
s/^(.+)\|\|\.data\|\|(.+)/ .data\n .align 2/;
s/^(.+)\|\|\.bss\|\|(.+)/ .bss/;
}
s/\|\|\.constdata\$(\d+)\|\|/.L_CONST$1/; # ||.constdata$3||
s/\|\|\.bss\$(\d+)\|\|/.L_BSS$1/; # ||.bss$2||
s/\|\|\.data\$(\d+)\|\|/.L_DATA$1/; # ||.data$2||
s/\|\|([a-zA-Z0-9_]+)\@([a-zA-Z0-9_]+)\|\|/@ $&/;
s/^(\s+)\%(\s)/ .space $1/;
s/\|(.+)\.(\d+)\|/\.$1_$2/; # |L80.123| -> .L80_123
s/\bCODE32\b/.code 32/ && do {$thumb = 0};
s/\bCODE16\b/.code 16/ && do {$thumb = 1};
if (/\bPROC\b/)
{
print " .thumb_func" if ($thumb);
s/\bPROC\b/@ $&/;
}
s/\bENDP\b/@ $&/;
s/\bSUBT\b/@ $&/;
s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25
s/\bKEEP\b/@ $&/;
s/\bEXPORTAS\b/@ $&/;
s/\|\|(.)+\bEQU\b/@ $&/;
s/\|\|([\w\$]+)\|\|/$1/;
s/\bENTRY\b/@ $&/;
s/\bASSERT\b/@ $&/;
s/\bGBLL\b/@ $&/;
s/\bGBLA\b/@ $&/;
s/^\W+OPT\b/@ $&/;
s/:OR:/|/g;
s/:SHL:/<</g;
s/:SHR:/>>/g;
s/:AND:/&/g;
s/:LAND:/&&/g;
s/CPSR/cpsr/;
s/SPSR/spsr/;
s/ALIGN$/.balign 4/;
s/psr_cxsf/psr_all/;
s/LTORG/.ltorg/;
s/^([A-Za-z_]\w*)[ \t]+EQU/ .set $1,/;
s/^([A-Za-z_]\w*)[ \t]+SETL/ .set $1,/;
s/^([A-Za-z_]\w*)[ \t]+SETA/ .set $1,/;
s/^([A-Za-z_]\w*)[ \t]+\*/ .set $1,/;
# {PC} + 0xdeadfeed --> . + 0xdeadfeed
s/\{PC\} \+/ \. +/;
# Single hex constant on the line !
#
# >>> NOTE <<<
# Double-precision floats in gcc are always mixed-endian, which means
# bytes in two words are little-endian, but words are big-endian.
# So, 0x0000deadfeed0000 would be stored as 0x0000dead at low address
# and 0xfeed0000 at high address.
#
s/\bDCFD\b[ \t]+0x([a-fA-F0-9]{8})([a-fA-F0-9]{8})/.long 0x$1, 0x$2/;
# Only decimal constants on the line, no hex !
s/\bDCFD\b[ \t]+([0-9\.\-]+)/.double $1/;
# Single hex constant on the line !
# s/\bDCFS\b[ \t]+0x([a-f0-9]{8})([a-f0-9]{8})/.long 0x$1, 0x$2/;
# Only decimal constants on the line, no hex !
# s/\bDCFS\b[ \t]+([0-9\.\-]+)/.double $1/;
s/\bDCFS[ \t]+0x/.word 0x/;
s/\bDCFS\b/.float/;
s/^([A-Za-z_]\w*)[ \t]+DCD/$1 .word/;
s/\bDCD\b/.word/;
s/^([A-Za-z_]\w*)[ \t]+DCW/$1 .short/;
s/\bDCW\b/.short/;
s/^([A-Za-z_]\w*)[ \t]+DCB/$1 .byte/;
s/\bDCB\b/.byte/;
s/^([A-Za-z_]\w*)[ \t]+\%/.comm $1,/;
s/^[A-Za-z_\.]\w+/$&:/;
s/^(\d+)/$1:/;
s/\%(\d+)/$1b_or_f/;
s/\%[Bb](\d+)/$1b/;
s/\%[Ff](\d+)/$1f/;
s/\%[Ff][Tt](\d+)/$1f/;
s/&([\dA-Fa-f]+)/0x$1/;
if ( /\b2_[01]+\b/ ) {
s/\b2_([01]+)\b/conv$1&&&&/g;
while ( /[01][01][01][01]&&&&/ ) {
s/0000&&&&/&&&&0/g;
s/0001&&&&/&&&&1/g;
s/0010&&&&/&&&&2/g;
s/0011&&&&/&&&&3/g;
s/0100&&&&/&&&&4/g;
s/0101&&&&/&&&&5/g;
s/0110&&&&/&&&&6/g;
s/0111&&&&/&&&&7/g;
s/1000&&&&/&&&&8/g;
s/1001&&&&/&&&&9/g;
s/1010&&&&/&&&&A/g;
s/1011&&&&/&&&&B/g;
s/1100&&&&/&&&&C/g;
s/1101&&&&/&&&&D/g;
s/1110&&&&/&&&&E/g;
s/1111&&&&/&&&&F/g;
}
s/000&&&&/&&&&0/g;
s/001&&&&/&&&&1/g;
s/010&&&&/&&&&2/g;
s/011&&&&/&&&&3/g;
s/100&&&&/&&&&4/g;
s/101&&&&/&&&&5/g;
s/110&&&&/&&&&6/g;
s/111&&&&/&&&&7/g;
s/00&&&&/&&&&0/g;
s/01&&&&/&&&&1/g;
s/10&&&&/&&&&2/g;
s/11&&&&/&&&&3/g;
s/0&&&&/&&&&0/g;
s/1&&&&/&&&&1/g;
s/conv&&&&/0x/g;
}
if ( /commandline/)
{
if( /-bigend/)
{
$bigend=1;
}
}
if ( /\bDCDU\b/ )
{
my $cmd=$_;
my $value;
my $w1;
my $w2;
my $w3;
my $w4;
s/\s+DCDU\b/@ $&/;
$cmd =~ /\bDCDU\b\s+0x(\d+)/;
$value = $1;
$value =~ /(\w\w)(\w\w)(\w\w)(\w\w)/;
$w1 = $1;
$w2 = $2;
$w3 = $3;
$w4 = $4;
if( $bigend ne "")
{
# big endian
print " .byte 0x".$w1;
print " .byte 0x".$w2;
print " .byte 0x".$w3;
print " .byte 0x".$w4;
}
else
{
# little endian
print " .byte 0x".$w4;
print " .byte 0x".$w3;
print " .byte 0x".$w2;
print " .byte 0x".$w1;
}
}
if ( /\badrl\b/i )
{
s/\badrl\s+(\w+)\s*,\s*(\w+)/ldr $1,=$2/i;
$addPadding = 1;
}
s/\bEND\b/@ END/;
} continue {
printf ("%s", $_) if $printit;
if ($addPadding != 0)
{
printf (" mov r0,r0\n");
$addPadding = 0;
}
}
/********************************************************************
* *
* 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
This diff is collapsed.
@ Tremolo library
@ Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
.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
MOV r0,#0
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:
MOV r2, #0
MOV r12,#0
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
MOV r0,#0
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
@ END
This diff is collapsed.
/********************************************************************
* *
* 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
/********************************************************************
* *
* 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 int vorbis_dsp_init(vorbis_dsp_state *v, vorbis_info *vi);
extern void vorbis_dsp_clear(vorbis_dsp_state *v);
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
/********************************************************************
* *
* 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
@ Tremolo library
@ Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
.text
.global decode_packed_entry_number
.global decode_packed_entry_number_REALSTART
.global decode_map
.global vorbis_book_decodevv_add
.global _checksum
.extern oggpack_adv
.extern oggpack_look
.extern oggpack_eop
.extern crc_lookup
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]0x0x80)]
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]0x0x8000)
ADC r12,r12,r14,LSR #15 @ r12= t + (1+chase+bit+(!bit || t[chase]0x0x8000))<<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= 0xa[chptr] chptr=0
MOV r6, r3 @ r6 = ch
ADD r8, r10,r3, LSL #2 @ r8 = 0xa[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 = 0xa[ch]
@ r9 = book
@ r10= 0xa[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 = 0xa[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}
@ END
/********************************************************************
* *
* 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;
}
int vorbis_dsp_init(vorbis_dsp_state *v,vorbis_info *vi){
int i;
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 0;
}
vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi){
vorbis_dsp_state *v=_ogg_calloc(1,sizeof(*v));
vorbis_dsp_init(v,vi);
return v;
}
void vorbis_dsp_clear(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);
}
}
}
void vorbis_dsp_destroy(vorbis_dsp_state *v){
vorbis_dsp_clear(v);
_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-=(int)(vd->sample_count-vd->granulepos);
}else{
/* trim the beginning */
vd->out_begin+=(int)(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=(long)(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);
}
/********************************************************************
* *
* 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]=(char)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);
}
This diff is collapsed.
@ Tremolo library
@ Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
.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}
@ END
@ Tremolo library
@ Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
.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}
@ END
/********************************************************************
* *
* 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),
};
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment