summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--contrib/Makefile.am2
-rw-r--r--contrib/libmad/COPYING340
-rw-r--r--contrib/libmad/D.dat (renamed from src/libmad/D.dat)2
-rw-r--r--contrib/libmad/Makefile.am44
-rw-r--r--[-rwxr-xr-x]contrib/libmad/bit.c (renamed from src/libmad/bit.c)2
-rw-r--r--contrib/libmad/bit.h (renamed from src/libmad/bit.h)2
-rw-r--r--contrib/libmad/decoder.c582
-rw-r--r--contrib/libmad/decoder.h91
-rw-r--r--contrib/libmad/fixed.c (renamed from src/libmad/fixed.c)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/fixed.h (renamed from src/libmad/fixed.h)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/frame.c (renamed from src/libmad/frame.c)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/frame.h (renamed from src/libmad/frame.h)2
-rw-r--r--contrib/libmad/global.h (renamed from src/libmad/global.h)2
-rw-r--r--contrib/libmad/huffman.c (renamed from src/libmad/huffman.c)2
-rw-r--r--contrib/libmad/huffman.h (renamed from src/libmad/huffman.h)2
-rw-r--r--contrib/libmad/imdct_s.dat (renamed from src/libmad/imdct_s.dat)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/layer12.c (renamed from src/libmad/layer12.c)2
-rw-r--r--contrib/libmad/layer12.h (renamed from src/libmad/layer12.h)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/layer3.c (renamed from src/libmad/layer3.c)6
-rw-r--r--contrib/libmad/layer3.h (renamed from src/libmad/layer3.h)2
-rw-r--r--contrib/libmad/qc_table.dat (renamed from src/libmad/qc_table.dat)4
-rw-r--r--contrib/libmad/rq_table.dat (renamed from src/libmad/rq_table.dat)4
-rw-r--r--contrib/libmad/sf_table.dat (renamed from src/libmad/sf_table.dat)12
-rw-r--r--contrib/libmad/stream.c (renamed from src/libmad/stream.c)2
-rw-r--r--contrib/libmad/stream.h (renamed from src/libmad/stream.h)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/synth.c (renamed from src/libmad/synth.c)10
-rw-r--r--contrib/libmad/synth.h (renamed from src/libmad/synth.h)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/timer.c (renamed from src/libmad/timer.c)2
-rw-r--r--[-rwxr-xr-x]contrib/libmad/timer.h (renamed from src/libmad/timer.h)2
-rw-r--r--contrib/libmad/version.c (renamed from src/libmad/version.c)2
-rw-r--r--contrib/libmad/version.h (renamed from src/libmad/version.h)2
-rw-r--r--m4/decoders.m48
-rw-r--r--src/libmad/Makefile.am45
-rw-r--r--src/libmad/imdct_l_arm.S1000
35 files changed, 1114 insertions, 1077 deletions
diff --git a/configure.ac b/configure.ac
index 434049db0..2537ea9ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1116,6 +1116,7 @@ doc/Doxyfile
contrib/Makefile
contrib/gsm610/Makefile
contrib/libdca/Makefile
+contrib/libmad/Makefile
contrib/libmpcdec/Makefile
contrib/libxdg-basedir/Makefile
contrib/nosefart/Makefile
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 76b63d100..6e259a4a3 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = libmpcdec libxdg-basedir libdca nosefart gsm610
+SUBDIRS = libmpcdec libxdg-basedir libdca nosefart gsm610 libmad
srcdir = $(shell cd @srcdir@; pwd)
diff --git a/contrib/libmad/COPYING b/contrib/libmad/COPYING
new file mode 100644
index 000000000..d60c31a97
--- /dev/null
+++ b/contrib/libmad/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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.
diff --git a/src/libmad/D.dat b/contrib/libmad/D.dat
index 31c6cd4fa..4a7fa4fa9 100644
--- a/src/libmad/D.dat
+++ b/contrib/libmad/D.dat
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: D.dat,v 1.3 2004/04/22 00:22:33 miguelfreitas Exp $
+ * $Id: D.dat,v 1.9 2004/01/23 09:41:32 rob Exp $
*/
/*
diff --git a/contrib/libmad/Makefile.am b/contrib/libmad/Makefile.am
new file mode 100644
index 000000000..d3c285b01
--- /dev/null
+++ b/contrib/libmad/Makefile.am
@@ -0,0 +1,44 @@
+AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG)
+AM_CPPFLAGS = -DOPT_SPEED
+
+EXTRA_DIST = COPYING
+
+if ENABLE_MAD
+if !WITH_EXTERNAL_MAD
+noinst_LTLIBRARIES = libmad.la
+endif
+endif
+
+##
+## libmad - MPEG audio decoder library
+## Copyright (C) 2000-2004 Underbit Technologies, Inc.
+##
+## 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## $Id: Makefile.am,v 1.23 2004/02/17 02:02:03 rob Exp $
+##
+
+exported_headers = version.h fixed.h bit.h timer.h stream.h frame.h \
+ synth.h decoder.h
+
+headers = $(exported_headers) \
+ global.h layer12.h layer3.h huffman.h
+
+data_includes = D.dat imdct_s.dat qc_table.dat rq_table.dat \
+ sf_table.dat
+
+libmad_la_SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c \
+ synth.c decoder.c layer12.c layer3.c huffman.c \
+ $(headers) $(data_includes)
diff --git a/src/libmad/bit.c b/contrib/libmad/bit.c
index 8d9571e8f..c2bfb243c 100755..100644
--- a/src/libmad/bit.c
+++ b/contrib/libmad/bit.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: bit.c,v 1.3 2004/04/22 00:22:35 miguelfreitas Exp $
+ * $Id: bit.c,v 1.12 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/bit.h b/contrib/libmad/bit.h
index 6c09d5493..5a51570b2 100644
--- a/src/libmad/bit.h
+++ b/contrib/libmad/bit.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: bit.h,v 1.3 2004/04/22 00:22:36 miguelfreitas Exp $
+ * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBMAD_BIT_H
diff --git a/contrib/libmad/decoder.c b/contrib/libmad/decoder.c
new file mode 100644
index 000000000..6d6df0db5
--- /dev/null
+++ b/contrib/libmad/decoder.c
@@ -0,0 +1,582 @@
+/*
+ * libmad - MPEG audio decoder library
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: decoder.c,v 1.22 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+# endif
+
+# ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+# endif
+
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+# ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+# endif
+
+# include <stdlib.h>
+
+# ifdef HAVE_ERRNO_H
+# include <errno.h>
+# endif
+
+# include "stream.h"
+# include "frame.h"
+# include "synth.h"
+# include "decoder.h"
+
+/*
+ * NAME: decoder->init()
+ * DESCRIPTION: initialize a decoder object with callback routines
+ */
+void mad_decoder_init(struct mad_decoder *decoder, void *data,
+ enum mad_flow (*input_func)(void *,
+ struct mad_stream *),
+ enum mad_flow (*header_func)(void *,
+ struct mad_header const *),
+ enum mad_flow (*filter_func)(void *,
+ struct mad_stream const *,
+ struct mad_frame *),
+ enum mad_flow (*output_func)(void *,
+ struct mad_header const *,
+ struct mad_pcm *),
+ enum mad_flow (*error_func)(void *,
+ struct mad_stream *,
+ struct mad_frame *),
+ enum mad_flow (*message_func)(void *,
+ void *, unsigned int *))
+{
+ decoder->mode = -1;
+
+ decoder->options = 0;
+
+ decoder->async.pid = 0;
+ decoder->async.in = -1;
+ decoder->async.out = -1;
+
+ decoder->sync = 0;
+
+ decoder->cb_data = data;
+
+ decoder->input_func = input_func;
+ decoder->header_func = header_func;
+ decoder->filter_func = filter_func;
+ decoder->output_func = output_func;
+ decoder->error_func = error_func;
+ decoder->message_func = message_func;
+}
+
+int mad_decoder_finish(struct mad_decoder *decoder)
+{
+# if defined(USE_ASYNC)
+ if (decoder->mode == MAD_DECODER_MODE_ASYNC && decoder->async.pid) {
+ pid_t pid;
+ int status;
+
+ close(decoder->async.in);
+
+ do
+ pid = waitpid(decoder->async.pid, &status, 0);
+ while (pid == -1 && errno == EINTR);
+
+ decoder->mode = -1;
+
+ close(decoder->async.out);
+
+ decoder->async.pid = 0;
+ decoder->async.in = -1;
+ decoder->async.out = -1;
+
+ if (pid == -1)
+ return -1;
+
+ return (!WIFEXITED(status) || WEXITSTATUS(status)) ? -1 : 0;
+ }
+# endif
+
+ return 0;
+}
+
+# if defined(USE_ASYNC)
+static
+enum mad_flow send_io(int fd, void const *data, size_t len)
+{
+ char const *ptr = data;
+ ssize_t count;
+
+ while (len) {
+ do
+ count = write(fd, ptr, len);
+ while (count == -1 && errno == EINTR);
+
+ if (count == -1)
+ return MAD_FLOW_BREAK;
+
+ len -= count;
+ ptr += count;
+ }
+
+ return MAD_FLOW_CONTINUE;
+}
+
+static
+enum mad_flow receive_io(int fd, void *buffer, size_t len)
+{
+ char *ptr = buffer;
+ ssize_t count;
+
+ while (len) {
+ do
+ count = read(fd, ptr, len);
+ while (count == -1 && errno == EINTR);
+
+ if (count == -1)
+ return (errno == EAGAIN) ? MAD_FLOW_IGNORE : MAD_FLOW_BREAK;
+ else if (count == 0)
+ return MAD_FLOW_STOP;
+
+ len -= count;
+ ptr += count;
+ }
+
+ return MAD_FLOW_CONTINUE;
+}
+
+static
+enum mad_flow receive_io_blocking(int fd, void *buffer, size_t len)
+{
+ int flags, blocking;
+ enum mad_flow result;
+
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1)
+ return MAD_FLOW_BREAK;
+
+ blocking = flags & ~O_NONBLOCK;
+
+ if (blocking != flags &&
+ fcntl(fd, F_SETFL, blocking) == -1)
+ return MAD_FLOW_BREAK;
+
+ result = receive_io(fd, buffer, len);
+
+ if (flags != blocking &&
+ fcntl(fd, F_SETFL, flags) == -1)
+ return MAD_FLOW_BREAK;
+
+ return result;
+}
+
+static
+enum mad_flow send(int fd, void const *message, unsigned int size)
+{
+ enum mad_flow result;
+
+ /* send size */
+
+ result = send_io(fd, &size, sizeof(size));
+
+ /* send message */
+
+ if (result == MAD_FLOW_CONTINUE)
+ result = send_io(fd, message, size);
+
+ return result;
+}
+
+static
+enum mad_flow receive(int fd, void **message, unsigned int *size)
+{
+ enum mad_flow result;
+ unsigned int actual;
+
+ if (*message == 0)
+ *size = 0;
+
+ /* receive size */
+
+ result = receive_io(fd, &actual, sizeof(actual));
+
+ /* receive message */
+
+ if (result == MAD_FLOW_CONTINUE) {
+ if (actual > *size)
+ actual -= *size;
+ else {
+ *size = actual;
+ actual = 0;
+ }
+
+ if (*size > 0) {
+ if (*message == 0) {
+ *message = malloc(*size);
+ if (*message == 0)
+ return MAD_FLOW_BREAK;
+ }
+
+ result = receive_io_blocking(fd, *message, *size);
+ }
+
+ /* throw away remainder of message */
+
+ while (actual && result == MAD_FLOW_CONTINUE) {
+ char sink[256];
+ unsigned int len;
+
+ len = actual > sizeof(sink) ? sizeof(sink) : actual;
+
+ result = receive_io_blocking(fd, sink, len);
+
+ actual -= len;
+ }
+ }
+
+ return result;
+}
+
+static
+enum mad_flow check_message(struct mad_decoder *decoder)
+{
+ enum mad_flow result;
+ void *message = 0;
+ unsigned int size;
+
+ result = receive(decoder->async.in, &message, &size);
+
+ if (result == MAD_FLOW_CONTINUE) {
+ if (decoder->message_func == 0)
+ size = 0;
+ else {
+ result = decoder->message_func(decoder->cb_data, message, &size);
+
+ if (result == MAD_FLOW_IGNORE ||
+ result == MAD_FLOW_BREAK)
+ size = 0;
+ }
+
+ if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE)
+ result = MAD_FLOW_BREAK;
+ }
+
+ if (message)
+ free(message);
+
+ return result;
+}
+# endif
+
+static
+enum mad_flow error_default(void *data, struct mad_stream *stream,
+ struct mad_frame *frame)
+{
+ int *bad_last_frame = data;
+
+ switch (stream->error) {
+ case MAD_ERROR_BADCRC:
+ if (*bad_last_frame)
+ mad_frame_mute(frame);
+ else
+ *bad_last_frame = 1;
+
+ return MAD_FLOW_IGNORE;
+
+ default:
+ return MAD_FLOW_CONTINUE;
+ }
+}
+
+static
+int run_sync(struct mad_decoder *decoder)
+{
+ enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
+ void *error_data;
+ int bad_last_frame = 0;
+ struct mad_stream *stream;
+ struct mad_frame *frame;
+ struct mad_synth *synth;
+ int result = 0;
+
+ if (decoder->input_func == 0)
+ return 0;
+
+ if (decoder->error_func) {
+ error_func = decoder->error_func;
+ error_data = decoder->cb_data;
+ }
+ else {
+ error_func = error_default;
+ error_data = &bad_last_frame;
+ }
+
+ stream = &decoder->sync->stream;
+ frame = &decoder->sync->frame;
+ synth = &decoder->sync->synth;
+
+ mad_stream_init(stream);
+ mad_frame_init(frame);
+ mad_synth_init(synth);
+
+ mad_stream_options(stream, decoder->options);
+
+ do {
+ switch (decoder->input_func(decoder->cb_data, stream)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ continue;
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+
+ while (1) {
+# if defined(USE_ASYNC)
+ if (decoder->mode == MAD_DECODER_MODE_ASYNC) {
+ switch (check_message(decoder)) {
+ case MAD_FLOW_IGNORE:
+ case MAD_FLOW_CONTINUE:
+ break;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_STOP:
+ goto done;
+ }
+ }
+# endif
+
+ if (decoder->header_func) {
+ if (mad_header_decode(&frame->header, stream) == -1) {
+ if (!MAD_RECOVERABLE(stream->error))
+ break;
+
+ switch (error_func(error_data, stream, frame)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ case MAD_FLOW_CONTINUE:
+ default:
+ continue;
+ }
+ }
+
+ switch (decoder->header_func(decoder->cb_data, &frame->header)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ continue;
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+ }
+
+ if (mad_frame_decode(frame, stream) == -1) {
+ if (!MAD_RECOVERABLE(stream->error))
+ break;
+
+ switch (error_func(error_data, stream, frame)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ break;
+ case MAD_FLOW_CONTINUE:
+ default:
+ continue;
+ }
+ }
+ else
+ bad_last_frame = 0;
+
+ if (decoder->filter_func) {
+ switch (decoder->filter_func(decoder->cb_data, stream, frame)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ continue;
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+ }
+
+ mad_synth_frame(synth, frame);
+
+ if (decoder->output_func) {
+ switch (decoder->output_func(decoder->cb_data,
+ &frame->header, &synth->pcm)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+ }
+ }
+ }
+ while (stream->error == MAD_ERROR_BUFLEN);
+
+ fail:
+ result = -1;
+
+ done:
+ mad_synth_finish(synth);
+ mad_frame_finish(frame);
+ mad_stream_finish(stream);
+
+ return result;
+}
+
+# if defined(USE_ASYNC)
+static
+int run_async(struct mad_decoder *decoder)
+{
+ pid_t pid;
+ int ptoc[2], ctop[2], flags;
+
+ if (pipe(ptoc) == -1)
+ return -1;
+
+ if (pipe(ctop) == -1) {
+ close(ptoc[0]);
+ close(ptoc[1]);
+ return -1;
+ }
+
+ flags = fcntl(ptoc[0], F_GETFL);
+ if (flags == -1 ||
+ fcntl(ptoc[0], F_SETFL, flags | O_NONBLOCK) == -1) {
+ close(ctop[0]);
+ close(ctop[1]);
+ close(ptoc[0]);
+ close(ptoc[1]);
+ return -1;
+ }
+
+ pid = fork();
+ if (pid == -1) {
+ close(ctop[0]);
+ close(ctop[1]);
+ close(ptoc[0]);
+ close(ptoc[1]);
+ return -1;
+ }
+
+ decoder->async.pid = pid;
+
+ if (pid) {
+ /* parent */
+
+ close(ptoc[0]);
+ close(ctop[1]);
+
+ decoder->async.in = ctop[0];
+ decoder->async.out = ptoc[1];
+
+ return 0;
+ }
+
+ /* child */
+
+ close(ptoc[1]);
+ close(ctop[0]);
+
+ decoder->async.in = ptoc[0];
+ decoder->async.out = ctop[1];
+
+ _exit(run_sync(decoder));
+
+ /* not reached */
+ return -1;
+}
+# endif
+
+/*
+ * NAME: decoder->run()
+ * DESCRIPTION: run the decoder thread either synchronously or asynchronously
+ */
+int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
+{
+ int result;
+ int (*run)(struct mad_decoder *) = 0;
+
+ switch (decoder->mode = mode) {
+ case MAD_DECODER_MODE_SYNC:
+ run = run_sync;
+ break;
+
+ case MAD_DECODER_MODE_ASYNC:
+# if defined(USE_ASYNC)
+ run = run_async;
+# endif
+ break;
+ }
+
+ if (run == 0)
+ return -1;
+
+ decoder->sync = malloc(sizeof(*decoder->sync));
+ if (decoder->sync == 0)
+ return -1;
+
+ result = run(decoder);
+
+ free(decoder->sync);
+ decoder->sync = 0;
+
+ return result;
+}
+
+/*
+ * NAME: decoder->message()
+ * DESCRIPTION: send a message to and receive a reply from the decoder process
+ */
+int mad_decoder_message(struct mad_decoder *decoder,
+ void *message, unsigned int *len)
+{
+# if defined(USE_ASYNC)
+ if (decoder->mode != MAD_DECODER_MODE_ASYNC ||
+ send(decoder->async.out, message, *len) != MAD_FLOW_CONTINUE ||
+ receive(decoder->async.in, &message, len) != MAD_FLOW_CONTINUE)
+ return -1;
+
+ return 0;
+# else
+ return -1;
+# endif
+}
diff --git a/contrib/libmad/decoder.h b/contrib/libmad/decoder.h
new file mode 100644
index 000000000..f0ad758dd
--- /dev/null
+++ b/contrib/libmad/decoder.h
@@ -0,0 +1,91 @@
+/*
+ * libmad - MPEG audio decoder library
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifndef LIBMAD_DECODER_H
+# define LIBMAD_DECODER_H
+
+# include "stream.h"
+# include "frame.h"
+# include "synth.h"
+
+enum mad_decoder_mode {
+ MAD_DECODER_MODE_SYNC = 0,
+ MAD_DECODER_MODE_ASYNC
+};
+
+enum mad_flow {
+ MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
+ MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
+ MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
+ MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
+};
+
+struct mad_decoder {
+ enum mad_decoder_mode mode;
+
+ int options;
+
+ struct {
+ long pid;
+ int in;
+ int out;
+ } async;
+
+ struct {
+ struct mad_stream stream;
+ struct mad_frame frame;
+ struct mad_synth synth;
+ } *sync;
+
+ void *cb_data;
+
+ enum mad_flow (*input_func)(void *, struct mad_stream *);
+ enum mad_flow (*header_func)(void *, struct mad_header const *);
+ enum mad_flow (*filter_func)(void *,
+ struct mad_stream const *, struct mad_frame *);
+ enum mad_flow (*output_func)(void *,
+ struct mad_header const *, struct mad_pcm *);
+ enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
+ enum mad_flow (*message_func)(void *, void *, unsigned int *);
+};
+
+void mad_decoder_init(struct mad_decoder *, void *,
+ enum mad_flow (*)(void *, struct mad_stream *),
+ enum mad_flow (*)(void *, struct mad_header const *),
+ enum mad_flow (*)(void *,
+ struct mad_stream const *,
+ struct mad_frame *),
+ enum mad_flow (*)(void *,
+ struct mad_header const *,
+ struct mad_pcm *),
+ enum mad_flow (*)(void *,
+ struct mad_stream *,
+ struct mad_frame *),
+ enum mad_flow (*)(void *, void *, unsigned int *));
+int mad_decoder_finish(struct mad_decoder *);
+
+# define mad_decoder_options(decoder, opts) \
+ ((void) ((decoder)->options = (opts)))
+
+int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode);
+int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
+
+# endif
diff --git a/src/libmad/fixed.c b/contrib/libmad/fixed.c
index ae02360ca..9785466f6 100644
--- a/src/libmad/fixed.c
+++ b/contrib/libmad/fixed.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: fixed.c,v 1.3 2004/04/22 00:22:36 miguelfreitas Exp $
+ * $Id: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/fixed.h b/contrib/libmad/fixed.h
index 658b3399e..4b58abf56 100755..100644
--- a/src/libmad/fixed.h
+++ b/contrib/libmad/fixed.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: fixed.h,v 1.3 2004/04/28 19:57:40 mroi Exp $
+ * $Id: fixed.h,v 1.38 2004/02/17 02:02:03 rob Exp $
*/
# ifndef LIBMAD_FIXED_H
diff --git a/src/libmad/frame.c b/contrib/libmad/frame.c
index 6fe1970c0..0cb3d0f33 100755..100644
--- a/src/libmad/frame.c
+++ b/contrib/libmad/frame.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: frame.c,v 1.3 2004/04/22 00:22:36 miguelfreitas Exp $
+ * $Id: frame.c,v 1.29 2004/02/04 22:59:19 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/frame.h b/contrib/libmad/frame.h
index 270420ab8..3f5bf37ef 100755..100644
--- a/src/libmad/frame.h
+++ b/contrib/libmad/frame.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: frame.h,v 1.3 2004/04/22 00:22:36 miguelfreitas Exp $
+ * $Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBMAD_FRAME_H
diff --git a/src/libmad/global.h b/contrib/libmad/global.h
index 2f4b41db5..a6debfd8b 100644
--- a/src/libmad/global.h
+++ b/contrib/libmad/global.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: global.h,v 1.4 2004/04/22 00:22:36 miguelfreitas Exp $
+ * $Id: global.h,v 1.11 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBMAD_GLOBAL_H
diff --git a/src/libmad/huffman.c b/contrib/libmad/huffman.c
index 5d34c0142..a230a9c10 100644
--- a/src/libmad/huffman.c
+++ b/contrib/libmad/huffman.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: huffman.c,v 1.4 2004/04/22 00:22:36 miguelfreitas Exp $
+ * $Id: huffman.c,v 1.10 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/huffman.h b/contrib/libmad/huffman.h
index 2f00c00a1..6325db44a 100644
--- a/src/libmad/huffman.h
+++ b/contrib/libmad/huffman.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: huffman.h,v 1.4 2004/04/22 00:22:41 miguelfreitas Exp $
+ * $Id: huffman.h,v 1.11 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBMAD_HUFFMAN_H
diff --git a/src/libmad/imdct_s.dat b/contrib/libmad/imdct_s.dat
index c938859e0..476710eaf 100644
--- a/src/libmad/imdct_s.dat
+++ b/contrib/libmad/imdct_s.dat
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: imdct_s.dat,v 1.3 2004/04/22 00:22:41 miguelfreitas Exp $
+ * $Id: imdct_s.dat,v 1.8 2004/01/23 09:41:32 rob Exp $
*/
/* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */,
diff --git a/src/libmad/layer12.c b/contrib/libmad/layer12.c
index 25fd04d70..6981f9ce1 100755..100644
--- a/src/libmad/layer12.c
+++ b/contrib/libmad/layer12.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: layer12.c,v 1.3 2004/04/22 00:22:41 miguelfreitas Exp $
+ * $Id: layer12.c,v 1.17 2004/02/05 09:02:39 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/layer12.h b/contrib/libmad/layer12.h
index 645bb6405..e1c499696 100644
--- a/src/libmad/layer12.h
+++ b/contrib/libmad/layer12.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: layer12.h,v 1.3 2004/04/22 00:22:49 miguelfreitas Exp $
+ * $Id: layer12.h,v 1.10 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBMAD_LAYER12_H
diff --git a/src/libmad/layer3.c b/contrib/libmad/layer3.c
index c5d46e8d1..4e5d3fa02 100755..100644
--- a/src/libmad/layer3.c
+++ b/contrib/libmad/layer3.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: layer3.c,v 1.7 2006/09/26 00:12:20 dgp85 Exp $
+ * $Id: layer3.c,v 1.43 2004/01/23 09:41:32 rob Exp $
*/
# ifdef HAVE_CONFIG_H
@@ -1547,8 +1547,8 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines)
for (xr += 18; xr < bound; xr += 18) {
for (i = 0; i < 8; ++i) {
register mad_fixed_t a, b;
- register mad_fixed64hi_t hi = 0;
- register mad_fixed64lo_t lo = 0;
+ register mad_fixed64hi_t hi;
+ register mad_fixed64lo_t lo;
a = xr[-1 - i];
b = xr[ i];
diff --git a/src/libmad/layer3.h b/contrib/libmad/layer3.h
index 3dca5b3b8..2504d461a 100644
--- a/src/libmad/layer3.h
+++ b/contrib/libmad/layer3.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: layer3.h,v 1.3 2004/04/22 00:23:06 miguelfreitas Exp $
+ * $Id: layer3.h,v 1.10 2004/01/23 09:41:32 rob Exp $
*/
# ifndef LIBMAD_LAYER3_H
diff --git a/src/libmad/qc_table.dat b/contrib/libmad/qc_table.dat
index 1848e0011..35a22234f 100644
--- a/src/libmad/qc_table.dat
+++ b/contrib/libmad/qc_table.dat
@@ -1,6 +1,6 @@
/*
* libmad - MPEG audio decoder library
- * Copyright (C) 2000-2001 Robert Leslie
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: qc_table.dat,v 1.2 2002/04/30 18:46:58 miguelfreitas Exp $
+ * $Id: qc_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
/*
diff --git a/src/libmad/rq_table.dat b/contrib/libmad/rq_table.dat
index 7db10fd33..059c4f318 100644
--- a/src/libmad/rq_table.dat
+++ b/contrib/libmad/rq_table.dat
@@ -1,6 +1,6 @@
/*
* libmad - MPEG audio decoder library
- * Copyright (C) 2000-2001 Robert Leslie
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: rq_table.dat,v 1.2 2002/04/30 18:46:58 miguelfreitas Exp $
+ * $Id: rq_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $
*/
/*
diff --git a/src/libmad/sf_table.dat b/contrib/libmad/sf_table.dat
index ea7a1c191..db1484a0e 100644
--- a/src/libmad/sf_table.dat
+++ b/contrib/libmad/sf_table.dat
@@ -1,6 +1,6 @@
/*
* libmad - MPEG audio decoder library
- * Copyright (C) 2000-2001 Robert Leslie
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
* 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
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: sf_table.dat,v 1.2 2002/04/30 18:46:58 miguelfreitas Exp $
+ * $Id: sf_table.dat,v 1.7 2004/01/23 09:41:33 rob Exp $
*/
/*
@@ -26,6 +26,11 @@
* There is some error introduced by the 32-bit fixed-point representation;
* the amount of error is shown. For 16-bit PCM output, this shouldn't be
* too much of a problem.
+ *
+ * Strictly speaking, Table B.1 has only 63 entries (0-62), thus a strict
+ * interpretation of ISO/IEC 11172-3 would suggest that a scalefactor index of
+ * 63 is invalid. However, for better compatibility with current practices, we
+ * add a 64th entry.
*/
MAD_F(0x20000000), /* 2.000000000000 => 2.000000000000, e 0.000000000000 */
@@ -97,4 +102,5 @@
MAD_F(0x00000285), /* 0.000002403109 => 0.000002402812, e 0.000000000296 */
MAD_F(0x00000200), /* 0.000001907349 => 0.000001907349, e -0.000000000000 */
MAD_F(0x00000196), /* 0.000001513864 => 0.000001512468, e 0.000000001396 */
- MAD_F(0x00000143) /* 0.000001201554 => 0.000001203269, e -0.000000001714 */
+ MAD_F(0x00000143), /* 0.000001201554 => 0.000001203269, e -0.000000001714 */
+ MAD_F(0x00000000) /* this compatibility entry is not part of Table B.1 */
diff --git a/src/libmad/stream.c b/contrib/libmad/stream.c
index fecc87434..8bb4d6a49 100644
--- a/src/libmad/stream.c
+++ b/contrib/libmad/stream.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: stream.c,v 1.3 2004/04/22 00:23:07 miguelfreitas Exp $
+ * $Id: stream.c,v 1.12 2004/02/05 09:02:39 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/stream.h b/contrib/libmad/stream.h
index b99b87582..8bff8b49d 100644
--- a/src/libmad/stream.h
+++ b/contrib/libmad/stream.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: stream.h,v 1.3 2004/04/22 00:23:12 miguelfreitas Exp $
+ * $Id: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp $
*/
# ifndef LIBMAD_STREAM_H
diff --git a/src/libmad/synth.c b/contrib/libmad/synth.c
index c05ad3efc..1d28d438c 100755..100644
--- a/src/libmad/synth.c
+++ b/contrib/libmad/synth.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: synth.c,v 1.4 2006/09/26 03:02:20 dgp85 Exp $
+ * $Id: synth.c,v 1.25 2004/01/23 09:41:33 rob Exp $
*/
# ifdef HAVE_CONFIG_H
@@ -563,8 +563,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
mad_fixed_t const (*sbsample)[36][32];
register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
register mad_fixed_t const (*Dptr)[32], *ptr;
- register mad_fixed64hi_t hi = 0;
- register mad_fixed64lo_t lo = 0;
+ register mad_fixed64hi_t hi;
+ register mad_fixed64lo_t lo;
for (ch = 0; ch < nch; ++ch) {
sbsample = &frame->sbsample[ch];
@@ -700,8 +700,8 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
mad_fixed_t const (*sbsample)[36][32];
register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
register mad_fixed_t const (*Dptr)[32], *ptr;
- register mad_fixed64hi_t hi = 0;
- register mad_fixed64lo_t lo = 0;
+ register mad_fixed64hi_t hi;
+ register mad_fixed64lo_t lo;
for (ch = 0; ch < nch; ++ch) {
sbsample = &frame->sbsample[ch];
diff --git a/src/libmad/synth.h b/contrib/libmad/synth.h
index d5a63589e..8ae4bc95e 100644
--- a/src/libmad/synth.h
+++ b/contrib/libmad/synth.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: synth.h,v 1.3 2004/04/22 00:23:24 miguelfreitas Exp $
+ * $Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $
*/
# ifndef LIBMAD_SYNTH_H
diff --git a/src/libmad/timer.c b/contrib/libmad/timer.c
index 9aa2e8924..4b909aba9 100755..100644
--- a/src/libmad/timer.c
+++ b/contrib/libmad/timer.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: timer.c,v 1.6 2004/04/22 00:23:26 miguelfreitas Exp $
+ * $Id: timer.c,v 1.18 2004/01/23 09:41:33 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/timer.h b/contrib/libmad/timer.h
index 88e997d5e..eb4542bb9 100755..100644
--- a/src/libmad/timer.h
+++ b/contrib/libmad/timer.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: timer.h,v 1.3 2004/04/22 00:23:27 miguelfreitas Exp $
+ * $Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp $
*/
# ifndef LIBMAD_TIMER_H
diff --git a/src/libmad/version.c b/contrib/libmad/version.c
index 8fc70f408..e643fa71e 100644
--- a/src/libmad/version.c
+++ b/contrib/libmad/version.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: version.c,v 1.2 2004/04/22 00:23:27 miguelfreitas Exp $
+ * $Id: version.c,v 1.15 2004/01/23 09:41:33 rob Exp $
*/
# ifdef HAVE_CONFIG_H
diff --git a/src/libmad/version.h b/contrib/libmad/version.h
index c056e6fc9..d215d4c10 100644
--- a/src/libmad/version.h
+++ b/contrib/libmad/version.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: version.h,v 1.2 2004/04/22 00:23:29 miguelfreitas Exp $
+ * $Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp $
*/
# ifndef LIBMAD_VERSION_H
diff --git a/m4/decoders.m4 b/m4/decoders.m4
index 094f406ea..535af20bf 100644
--- a/m4/decoders.m4
+++ b/m4/decoders.m4
@@ -260,6 +260,14 @@ use internal ffmpeg.
;;
esac
fi
+ if test x"$have_external_libmad" != x"yes"; then
+ LIBMAD_CFLAGS='-I$(top_srcdir)/contrib/libmad'
+ LIBMAD_LIBS='$(top_builddir)/contrib/libmad/libmad.la'
+ LIBMAD_DEPS='$(top_builddir)/contrib/libmad/libmad.la'
+ fi
+ AC_SUBST(LIBMAD_CFLAGS)
+ AC_SUBST(LIBMAD_DEPS)
+ AC_SUBST(LIBMAD_LIBS)
fi
AM_CONDITIONAL([ENABLE_MAD], [test x"$enable_mad" != x"no"])
AM_CONDITIONAL([WITH_EXTERNAL_MAD], [test x"$have_external_libmad" = x"yes"])
diff --git a/src/libmad/Makefile.am b/src/libmad/Makefile.am
index 482d68bb3..76d378465 100644
--- a/src/libmad/Makefile.am
+++ b/src/libmad/Makefile.am
@@ -1,51 +1,16 @@
include $(top_srcdir)/misc/Makefile.common
AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG)
-AM_CPPFLAGS = -DOPT_SPEED
AM_LDFLAGS = $(xineplug_ldflags)
-EXTRA_DIST = imdct_l_arm.S
-
-noinst_HEADERS = \
- D.dat \
- imdct_s.dat \
- qc_table.dat \
- rq_table.dat \
- sf_table.dat \
- bit.h \
- fixed.h \
- frame.h \
- global.h \
- huffman.h \
- layer12.h \
- layer3.h \
- stream.h \
- synth.h \
- timer.h \
- version.h
+$(top_builddir)/contrib/libmad/libmad.la:
+ $(MAKE) -C $(top_builddir)/contrib/libmad
if ENABLE_MAD
xineplug_LTLIBRARIES = xineplug_decode_mad.la
endif
-if WITH_EXTERNAL_MAD
-internal_sources =
-external_libs = $(LIBMAD_LIBS)
-else
-internal_sources = \
- bit.c \
- fixed.c \
- frame.c \
- huffman.c \
- layer12.c \
- layer3.c \
- stream.c \
- synth.c \
- timer.c \
- version.c
-external_libs =
-endif
-
-xineplug_decode_mad_la_SOURCES = xine_mad_decoder.c $(internal_sources)
-xineplug_decode_mad_la_LIBADD = $(XINE_LIB) $(external_libs)
+xineplug_decode_mad_la_SOURCES = xine_mad_decoder.c
+xineplug_decode_mad_la_DEPENDENCIES = $(LIBMAD_DEPS)
+xineplug_decode_mad_la_LIBADD = $(XINE_LIB) $(LIBMAD_LIBS)
xineplug_decode_mad_la_CFLAGS = $(AM_CFLAGS) $(LIBMAD_CFLAGS)
diff --git a/src/libmad/imdct_l_arm.S b/src/libmad/imdct_l_arm.S
deleted file mode 100644
index 35b2e2626..000000000
--- a/src/libmad/imdct_l_arm.S
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*****************************************************************************
-* Copyright (C) 2000-2001 Andre McCurdy <armccurdy@yahoo.co.uk>
-*
-* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*
-*****************************************************************************
-*
-* Notes:
-*
-*
-*****************************************************************************
-*
-* $Id: imdct_l_arm.S,v 1.1 2002/04/30 18:46:58 miguelfreitas Exp $
-*
-* 2001/03/24: Andre McCurdy <armccurdy@yahoo.co.uk>
-* - Corrected PIC unsafe loading of address of 'imdct36_long_karray'
-*
-* 2000/09/20: Robert Leslie <rob@mars.org>
-* - Added a global symbol with leading underscore per suggestion of
-* Simon Burge to support linking with the a.out format.
-*
-* 2000/09/15: Robert Leslie <rob@mars.org>
-* - Fixed a small bug where flags were changed before a conditional branch.
-*
-* 2000/09/15: Andre McCurdy <armccurdy@yahoo.co.uk>
-* - Applied Nicolas Pitre's rounding optimisation in all remaining places.
-*
-* 2000/09/09: Nicolas Pitre <nico@cam.org>
-* - Optimized rounding + scaling operations.
-*
-* 2000/08/09: Andre McCurdy <armccurdy@yahoo.co.uk>
-* - Original created.
-*
-****************************************************************************/
-
-
-/*
- On entry:
-
- r0 = pointer to 18 element input array
- r1 = pointer to 36 element output array
- r2 = windowing block type
-
-
- Stack frame created during execution of the function:
-
- Initial Holds:
- Stack
- pointer
- minus:
-
- 0
- 4 lr
- 8 r11
- 12 r10
- 16 r9
- 20 r8
- 24 r7
- 28 r6
- 32 r5
- 36 r4
-
- 40 r2 : windowing block type
-
- 44 ct00 high
- 48 ct00 low
- 52 ct01 high
- 56 ct01 low
- 60 ct04 high
- 64 ct04 low
- 68 ct06 high
- 72 ct06 low
- 76 ct05 high
- 80 ct05 low
- 84 ct03 high
- 88 ct03 low
- 92 -ct05 high
- 96 -ct05 low
- 100 -ct07 high
- 104 -ct07 low
- 108 ct07 high
- 112 ct07 low
- 116 ct02 high
- 120 ct02 low
-*/
-
-#define BLOCK_MODE_NORMAL 0
-#define BLOCK_MODE_START 1
-#define BLOCK_MODE_STOP 3
-
-
-#define X0 0x00
-#define X1 0x04
-#define X2 0x08
-#define X3 0x0C
-#define X4 0x10
-#define X5 0x14
-#define X6 0x18
-#define X7 0x1c
-#define X8 0x20
-#define X9 0x24
-#define X10 0x28
-#define X11 0x2c
-#define X12 0x30
-#define X13 0x34
-#define X14 0x38
-#define X15 0x3c
-#define X16 0x40
-#define X17 0x44
-
-#define x0 0x00
-#define x1 0x04
-#define x2 0x08
-#define x3 0x0C
-#define x4 0x10
-#define x5 0x14
-#define x6 0x18
-#define x7 0x1c
-#define x8 0x20
-#define x9 0x24
-#define x10 0x28
-#define x11 0x2c
-#define x12 0x30
-#define x13 0x34
-#define x14 0x38
-#define x15 0x3c
-#define x16 0x40
-#define x17 0x44
-#define x18 0x48
-#define x19 0x4c
-#define x20 0x50
-#define x21 0x54
-#define x22 0x58
-#define x23 0x5c
-#define x24 0x60
-#define x25 0x64
-#define x26 0x68
-#define x27 0x6c
-#define x28 0x70
-#define x29 0x74
-#define x30 0x78
-#define x31 0x7c
-#define x32 0x80
-#define x33 0x84
-#define x34 0x88
-#define x35 0x8c
-
-#define K00 0x0ffc19fd
-#define K01 0x00b2aa3e
-#define K02 0x0fdcf549
-#define K03 0x0216a2a2
-#define K04 0x0f9ee890
-#define K05 0x03768962
-#define K06 0x0f426cb5
-#define K07 0x04cfb0e2
-#define K08 0x0ec835e8
-#define K09 0x061f78aa
-#define K10 0x0e313245
-#define K11 0x07635284
-#define K12 0x0d7e8807
-#define K13 0x0898c779
-#define K14 0x0cb19346
-#define K15 0x09bd7ca0
-#define K16 0x0bcbe352
-#define K17 0x0acf37ad
-
-#define minus_K02 0xf0230ab7
-
-#define WL0 0x00b2aa3e
-#define WL1 0x0216a2a2
-#define WL2 0x03768962
-#define WL3 0x04cfb0e2
-#define WL4 0x061f78aa
-#define WL5 0x07635284
-#define WL6 0x0898c779
-#define WL7 0x09bd7ca0
-#define WL8 0x0acf37ad
-#define WL9 0x0bcbe352
-#define WL10 0x0cb19346
-#define WL11 0x0d7e8807
-#define WL12 0x0e313245
-#define WL13 0x0ec835e8
-#define WL14 0x0f426cb5
-#define WL15 0x0f9ee890
-#define WL16 0x0fdcf549
-#define WL17 0x0ffc19fd
-
-
-@*****************************************************************************
-
-
- .text
- .align
-
- .global III_imdct_l
- .global _III_imdct_l
-
-III_imdct_l:
-_III_imdct_l:
-
- stmdb sp!, { r2, r4 - r11, lr } @ all callee saved regs, plus arg3
-
- ldr r4, =K08 @ r4 = K08
- ldr r5, =K09 @ r5 = K09
- ldr r8, [r0, #X4] @ r8 = X4
- ldr r9, [r0, #X13] @ r9 = X13
- rsb r6, r4, #0 @ r6 = -K08
- rsb r7, r5, #0 @ r7 = -K09
-
- smull r2, r3, r4, r8 @ r2..r3 = (X4 * K08)
- smlal r2, r3, r5, r9 @ r2..r3 = (X4 * K08) + (X13 * K09) = ct01
-
- smull r10, lr, r8, r5 @ r10..lr = (X4 * K09)
- smlal r10, lr, r9, r6 @ r10..lr = (X4 * K09) + (X13 * -K08) = ct00
-
- ldr r8, [r0, #X7] @ r8 = X7
- ldr r9, [r0, #X16] @ r9 = X16
-
- stmdb sp!, { r2, r3, r10, lr } @ stack ct00_h, ct00_l, ct01_h, ct01_l
-
- add r8, r8, r9 @ r8 = (X7 + X16)
- ldr r9, [r0, #X1] @ r9 = X1
-
- smlal r2, r3, r6, r8 @ r2..r3 = ct01 + ((X7 + X16) * -K08)
- smlal r2, r3, r7, r9 @ r2..r3 += (X1 * -K09)
-
- ldr r7, [r0, #X10] @ r7 = X10
-
- rsbs r10, r10, #0
- rsc lr, lr, #0 @ r10..lr = -ct00
-
- smlal r2, r3, r5, r7 @ r2..r3 += (X10 * K09) = ct06
-
- smlal r10, lr, r9, r6 @ r10..lr = -ct00 + ( X1 * -K08)
- smlal r10, lr, r8, r5 @ r10..lr += ((X7 + X16) * K09)
- smlal r10, lr, r7, r4 @ r10..lr += ( X10 * K08) = ct04
-
- stmdb sp!, { r2, r3, r10, lr } @ stack ct04_h, ct04_l, ct06_h, ct06_l
-
- @----
-
- ldr r7, [r0, #X0]
- ldr r8, [r0, #X11]
- ldr r9, [r0, #X12]
- sub r7, r7, r8
- sub r7, r7, r9 @ r7 = (X0 - X11 -X12) = ct14
-
- ldr r9, [r0, #X3]
- ldr r8, [r0, #X8]
- ldr r11, [r0, #X15]
- sub r8, r8, r9
- add r8, r8, r11 @ r8 = (X8 - X3 + X15) = ct16
-
- add r11, r7, r8 @ r11 = ct14 + ct16 = ct18
-
- smlal r2, r3, r6, r11 @ r2..r3 = ct06 + ((X0 - X11 - X3 + X15 + X8 - X12) * -K08)
-
- ldr r6, [r0, #X2]
- ldr r9, [r0, #X9]
- ldr r12, [r0, #X14]
- sub r6, r6, r9
- sub r6, r6, r12 @ r6 = (X2 - X9 - X14) = ct15
-
- ldr r9, [r0, #X5]
- ldr r12, [r0, #X6]
- sub r9, r9, r12
- ldr r12, [r0, #X17]
- sub r9, r9, r12 @ r9 = (X5 - X6 - X17) = ct17
-
- add r12, r9, r6 @ r12 = ct15 + ct17 = ct19
-
- smlal r2, r3, r5, r12 @ r2..r3 += ((X2 - X9 + X5 - X6 - X17 - X14) * K09)
-
- smlal r10, lr, r11, r5 @ r10..lr = ct04 + (ct18 * K09)
- smlal r10, lr, r12, r4 @ r10..lr = ct04 + (ct18 * K09) + (ct19 * K08)
-
- movs r2, r2, lsr #28
- adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3
- str r2, [r1, #x22] @ store result x22
-
- movs r10, r10, lsr #28
- adc r10, r10, lr, lsl #4 @ r10 = bits[59..28] of r10..lr
- str r10, [r1, #x4] @ store result x4
-
- @----
-
- ldmia sp, { r2, r3, r4, r5 } @ r2..r3 = ct06, r4..r5 = ct04 (dont update sp)
-
- @ r2..r3 = ct06
- @ r4..r5 = ct04
- @ r6 = ct15
- @ r7 = ct14
- @ r8 = ct16
- @ r9 = ct17
- @ r10 = .
- @ r11 = .
- @ r12 = .
- @ lr = .
-
- ldr r10, =K03 @ r10 = K03
- ldr lr, =K15 @ lr = K15
-
- smlal r2, r3, r10, r7 @ r2..r3 = ct06 + (ct14 * K03)
- smlal r4, r5, lr, r7 @ r4..r5 = ct04 + (ct14 * K15)
-
- ldr r12, =K14 @ r12 = K14
- rsb r10, r10, #0 @ r10 = -K03
-
- smlal r2, r3, lr, r6 @ r2..r3 += (ct15 * K15)
- smlal r4, r5, r10, r6 @ r4..r5 += (ct15 * -K03)
- smlal r2, r3, r12, r8 @ r2..r3 += (ct16 * K14)
-
- ldr r11, =minus_K02 @ r11 = -K02
- rsb r12, r12, #0 @ r12 = -K14
-
- smlal r4, r5, r12, r9 @ r4..r5 += (ct17 * -K14)
- smlal r2, r3, r11, r9 @ r2..r3 += (ct17 * -K02)
- smlal r4, r5, r11, r8 @ r4..r5 += (ct16 * -K02)
-
- movs r2, r2, lsr #28
- adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3
- str r2, [r1, #x7] @ store result x7
-
- movs r4, r4, lsr #28
- adc r4, r4, r5, lsl #4 @ r4 = bits[59..28] of r4..r5
- str r4, [r1, #x1] @ store result x1
-
- @----
-
- ldmia sp, { r2, r3, r4, r5 } @ r2..r3 = ct06, r4..r5 = ct04 (dont update sp)
-
- @ r2..r3 = ct06
- @ r4..r5 = ct04
- @ r6 = ct15
- @ r7 = ct14
- @ r8 = ct16
- @ r9 = ct17
- @ r10 = -K03
- @ r11 = -K02
- @ r12 = -K14
- @ lr = K15
-
- rsbs r2, r2, #0
- rsc r3, r3, #0 @ r2..r3 = -ct06
-
- smlal r2, r3, r12, r7 @ r2..r3 = -ct06 + (ct14 * -K14)
- smlal r2, r3, r10, r8 @ r2..r3 += (ct16 * -K03)
-
- smlal r4, r5, r12, r6 @ r4..r5 = ct04 + (ct15 * -K14)
- smlal r4, r5, r10, r9 @ r4..r5 += (ct17 * -K03)
- smlal r4, r5, lr, r8 @ r4..r5 += (ct16 * K15)
- smlal r4, r5, r11, r7 @ r4..r5 += (ct14 * -K02)
-
- rsb lr, lr, #0 @ lr = -K15
- rsb r11, r11, #0 @ r11 = K02
-
- smlal r2, r3, lr, r9 @ r2..r3 += (ct17 * -K15)
- smlal r2, r3, r11, r6 @ r2..r3 += (ct15 * K02)
-
- movs r4, r4, lsr #28
- adc r4, r4, r5, lsl #4 @ r4 = bits[59..28] of r4..r5
- str r4, [r1, #x25] @ store result x25
-
- movs r2, r2, lsr #28
- adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3
- str r2, [r1, #x19] @ store result x19
-
- @----
-
- ldr r2, [sp, #16] @ r2 = ct01_l
- ldr r3, [sp, #20] @ r3 = ct01_h
-
- ldr r6, [r0, #X1]
- ldr r8, [r0, #X7]
- ldr r9, [r0, #X10]
- ldr r7, [r0, #X16]
-
- rsbs r2, r2, #0
- rsc r3, r3, #0 @ r2..r3 = -ct01
-
- mov r4, r2
- mov r5, r3 @ r4..r5 = -ct01
-
- @ r2..r3 = -ct01
- @ r4..r5 = -ct01
- @ r6 = X1
- @ r7 = X16
- @ r8 = X7
- @ r9 = X10
- @ r10 = -K03
- @ r11 = K02
- @ r12 = -K14
- @ lr = -K15
-
- smlal r4, r5, r12, r7 @ r4..r5 = -ct01 + (X16 * -K14)
- smlal r2, r3, lr, r9 @ r2..r3 = -ct01 + (X10 * -K15)
-
- smlal r4, r5, r10, r8 @ r4..r5 += (X7 * -K03)
- smlal r2, r3, r10, r7 @ r2..r3 += (X16 * -K03)
-
- smlal r4, r5, r11, r9 @ r4..r5 += (X10 * K02)
- smlal r2, r3, r12, r8 @ r2..r3 += (X7 * -K14)
-
- rsb lr, lr, #0 @ lr = K15
- rsb r11, r11, #0 @ r11 = -K02
-
- smlal r4, r5, lr, r6 @ r4..r5 += (X1 * K15) = ct05
- smlal r2, r3, r11, r6 @ r2..r3 += (X1 * -K02) = ct03
-
- stmdb sp!, { r2, r3, r4, r5 } @ stack ct05_h, ct05_l, ct03_h, ct03_l
-
- rsbs r4, r4, #0
- rsc r5, r5, #0 @ r4..r5 = -ct05
-
- stmdb sp!, { r4, r5 } @ stack -ct05_h, -ct05_l
-
- ldr r2, [sp, #48] @ r2 = ct00_l
- ldr r3, [sp, #52] @ r3 = ct00_h
-
- rsb r10, r10, #0 @ r10 = K03
-
- rsbs r4, r2, #0
- rsc r5, r3, #0 @ r4..r5 = -ct00
-
- @ r2..r3 = ct00
- @ r4..r5 = -ct00
- @ r6 = X1
- @ r7 = X16
- @ r8 = X7
- @ r9 = X10
- @ r10 = K03
- @ r11 = -K02
- @ r12 = -K14
- @ lr = K15
-
- smlal r4, r5, r10, r6 @ r4..r5 = -ct00 + (X1 * K03)
- smlal r2, r3, r10, r9 @ r2..r3 = ct00 + (X10 * K03)
-
- smlal r4, r5, r12, r9 @ r4..r5 += (X10 * -K14)
- smlal r2, r3, r12, r6 @ r2..r3 += (X1 * -K14)
-
- smlal r4, r5, r11, r7 @ r4..r5 += (X16 * -K02)
- smlal r4, r5, lr, r8 @ r4..r5 += (X7 * K15) = ct07
-
- rsb lr, lr, #0 @ lr = -K15
- rsb r11, r11, #0 @ r11 = K02
-
- smlal r2, r3, r11, r8 @ r2..r3 += (X7 * K02)
- smlal r2, r3, lr, r7 @ r2..r3 += (X16 * -K15) = ct02
-
- rsbs r6, r4, #0
- rsc r7, r5, #0 @ r6..r7 = -ct07
-
- stmdb sp!, { r2 - r7 } @ stack -ct07_h, -ct07_l, ct07_h, ct07_l, ct02_h, ct02_l
-
-
- @----
-
- add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?)
-
-
-loop:
- ldr r12, [r0, #X0]
-
- ldmia r2!, { r5 - r11 } @ first 7 words from Karray element
-
- smull r3, r4, r5, r12 @ sum = (Kxx * X0)
- ldr r12, [r0, #X2]
- ldr r5, [r0, #X3]
- smlal r3, r4, r6, r12 @ sum += (Kxx * X2)
- ldr r12, [r0, #X5]
- ldr r6, [r0, #X6]
- smlal r3, r4, r7, r5 @ sum += (Kxx * X3)
- smlal r3, r4, r8, r12 @ sum += (Kxx * X5)
- ldr r12, [r0, #X8]
- ldr r5, [r0, #X9]
- smlal r3, r4, r9, r6 @ sum += (Kxx * X6)
- smlal r3, r4, r10, r12 @ sum += (Kxx * X8)
- smlal r3, r4, r11, r5 @ sum += (Kxx * X9)
-
- ldmia r2!, { r5 - r10 } @ final 6 words from Karray element
-
- ldr r11, [r0, #X11]
- ldr r12, [r0, #X12]
- smlal r3, r4, r5, r11 @ sum += (Kxx * X11)
- ldr r11, [r0, #X14]
- ldr r5, [r0, #X15]
- smlal r3, r4, r6, r12 @ sum += (Kxx * X12)
- smlal r3, r4, r7, r11 @ sum += (Kxx * X14)
- ldr r11, [r0, #X17]
- smlal r3, r4, r8, r5 @ sum += (Kxx * X15)
- smlal r3, r4, r9, r11 @ sum += (Kxx * X17)
-
- add r5, sp, r10, lsr #16 @ create index back into stack for required ctxx
-
- ldmia r5, { r6, r7 } @ r6..r7 = ctxx
-
- mov r8, r10, lsl #16 @ push ctxx index off the top end
-
- adds r3, r3, r6 @ add low words
- adc r4, r4, r7 @ add high words, with carry
- movs r3, r3, lsr #28
- adc r3, r3, r4, lsl #4 @ r3 = bits[59..28] of r3..r4
-
- str r3, [r1, r8, lsr #24] @ push completion flag off the bottom end
-
- movs r8, r8, lsl #8 @ push result location index off the top end
- beq loop @ loop back if completion flag not set
- b imdct_l_windowing @ branch to windowing stage if looping finished
-
-imdct36_long_karray:
-
- .word K17, -K13, K10, -K06, -K05, K01, -K00, K04, -K07, K11, K12, -K16, 0x00000000
- .word K13, K07, K16, K01, K10, -K05, K04, -K11, K00, -K17, K06, -K12, 0x00200800
- .word K11, K17, K05, K12, -K01, K06, -K07, K00, -K13, K04, -K16, K10, 0x00200c00
- .word K07, K00, -K12, K05, -K16, -K10, K11, -K17, K04, K13, K01, K06, 0x00001400
- .word K05, K10, -K00, -K17, K07, -K13, K12, K06, -K16, K01, -K11, -K04, 0x00181800
- .word K01, K05, -K07, -K11, K13, K17, -K16, -K12, K10, K06, -K04, -K00, 0x00102000
- .word -K16, K12, -K11, K07, K04, -K00, -K01, K05, -K06, K10, K13, -K17, 0x00284800
- .word -K12, K06, K17, -K00, -K11, K04, K05, -K10, K01, K16, -K07, -K13, 0x00085000
- .word -K10, K16, K04, -K13, -K00, K07, K06, -K01, -K12, -K05, K17, K11, 0x00105400
- .word -K06, -K01, K13, K04, K17, -K11, -K10, -K16, -K05, K12, K00, K07, 0x00185c00
- .word -K04, -K11, -K01, K16, K06, K12, K13, -K07, -K17, -K00, -K10, -K05, 0x00006000
- .word -K00, -K04, -K06, -K10, -K12, -K16, -K17, -K13, -K11, -K07, -K05, -K01, 0x00206801
-
-
- @----
- @-------------------------------------------------------------------------
- @----
-
-imdct_l_windowing:
-
- ldr r11, [sp, #80] @ fetch function parameter 3 from out of the stack
- ldmia r1!, { r0, r2 - r9 } @ load 9 words from x0, update pointer
-
- @ r0 = x0
- @ r1 = &x[9]
- @ r2 = x1
- @ r3 = x2
- @ r4 = x3
- @ r5 = x4
- @ r6 = x5
- @ r7 = x6
- @ r8 = x7
- @ r9 = x8
- @ r10 = .
- @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block)
- @ r12 = .
- @ lr = .
-
- cmp r11, #BLOCK_MODE_STOP @ setup flags
- rsb r10, r0, #0 @ r10 = -x0 (DONT change flags !!)
- beq stop_block_x0_to_x17
-
-
- @ start and normal blocks are treated the same for x[0]..x[17]
-
-normal_block_x0_to_x17:
-
- ldr r12, =WL9 @ r12 = window_l[9]
-
- rsb r0, r9, #0 @ r0 = -x8
- rsb r9, r2, #0 @ r9 = -x1
- rsb r2, r8, #0 @ r2 = -x7
- rsb r8, r3, #0 @ r8 = -x2
- rsb r3, r7, #0 @ r3 = -x6
- rsb r7, r4, #0 @ r7 = -x3
- rsb r4, r6, #0 @ r4 = -x5
- rsb r6, r5, #0 @ r6 = -x4
-
- @ r0 = -x8
- @ r1 = &x[9]
- @ r2 = -x7
- @ r3 = -x6
- @ r4 = -x5
- @ r5 = .
- @ r6 = -x4
- @ r7 = -x3
- @ r8 = -x2
- @ r9 = -x1
- @ r10 = -x0
- @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block)
- @ r12 = window_l[9]
- @ lr = .
-
- smull r5, lr, r12, r0 @ r5..lr = (window_l[9] * (x[9] == -x[8]))
- ldr r12, =WL10 @ r12 = window_l[10]
- movs r5, r5, lsr #28
- adc r0, r5, lr, lsl #4 @ r0 = bits[59..28] of windowed x9
-
- smull r5, lr, r12, r2 @ r5..lr = (window_l[10] * (x[10] == -x[7]))
- ldr r12, =WL11 @ r12 = window_l[11]
- movs r5, r5, lsr #28
- adc r2, r5, lr, lsl #4 @ r2 = bits[59..28] of windowed x10
-
- smull r5, lr, r12, r3 @ r5..lr = (window_l[11] * (x[11] == -x[6]))
- ldr r12, =WL12 @ r12 = window_l[12]
- movs r5, r5, lsr #28
- adc r3, r5, lr, lsl #4 @ r3 = bits[59..28] of windowed x11
-
- smull r5, lr, r12, r4 @ r5..lr = (window_l[12] * (x[12] == -x[5]))
- ldr r12, =WL13 @ r12 = window_l[13]
- movs r5, r5, lsr #28
- adc r4, r5, lr, lsl #4 @ r4 = bits[59..28] of windowed x12
-
- smull r5, lr, r12, r6 @ r5..lr = (window_l[13] * (x[13] == -x[4]))
- ldr r12, =WL14 @ r12 = window_l[14]
- movs r5, r5, lsr #28
- adc r6, r5, lr, lsl #4 @ r6 = bits[59..28] of windowed x13
-
- smull r5, lr, r12, r7 @ r5..lr = (window_l[14] * (x[14] == -x[3]))
- ldr r12, =WL15 @ r12 = window_l[15]
- movs r5, r5, lsr #28
- adc r7, r5, lr, lsl #4 @ r7 = bits[59..28] of windowed x14
-
- smull r5, lr, r12, r8 @ r5..lr = (window_l[15] * (x[15] == -x[2]))
- ldr r12, =WL16 @ r12 = window_l[16]
- movs r5, r5, lsr #28
- adc r8, r5, lr, lsl #4 @ r8 = bits[59..28] of windowed x15
-
- smull r5, lr, r12, r9 @ r5..lr = (window_l[16] * (x[16] == -x[1]))
- ldr r12, =WL17 @ r12 = window_l[17]
- movs r5, r5, lsr #28
- adc r9, r5, lr, lsl #4 @ r9 = bits[59..28] of windowed x16
-
- smull r5, lr, r12, r10 @ r5..lr = (window_l[17] * (x[17] == -x[0]))
- ldr r12, =WL0 @ r12 = window_l[0]
- movs r5, r5, lsr #28
- adc r10, r5, lr, lsl #4 @ r10 = bits[59..28] of windowed x17
-
-
- stmia r1, { r0, r2 - r4, r6 - r10 } @ store windowed x[9] .. x[17]
- ldmdb r1!, { r0, r2 - r9 } @ load 9 words downto (and including) x0
-
-
- smull r10, lr, r12, r0 @ r10..lr = (window_l[0] * x[0])
- ldr r12, =WL1 @ r12 = window_l[1]
- movs r10, r10, lsr #28
- adc r0, r10, lr, lsl #4 @ r0 = bits[59..28] of windowed x0
-
- smull r10, lr, r12, r2 @ r10..lr = (window_l[1] * x[1])
- ldr r12, =WL2 @ r12 = window_l[2]
- movs r10, r10, lsr #28
- adc r2, r10, lr, lsl #4 @ r2 = bits[59..28] of windowed x1
-
- smull r10, lr, r12, r3 @ r10..lr = (window_l[2] * x[2])
- ldr r12, =WL3 @ r12 = window_l[3]
- movs r10, r10, lsr #28
- adc r3, r10, lr, lsl #4 @ r3 = bits[59..28] of windowed x2
-
- smull r10, lr, r12, r4 @ r10..lr = (window_l[3] * x[3])
- ldr r12, =WL4 @ r12 = window_l[4]
- movs r10, r10, lsr #28
- adc r4, r10, lr, lsl #4 @ r4 = bits[59..28] of windowed x3
-
- smull r10, lr, r12, r5 @ r10..lr = (window_l[4] * x[4])
- ldr r12, =WL5 @ r12 = window_l[5]
- movs r10, r10, lsr #28
- adc r5, r10, lr, lsl #4 @ r5 = bits[59..28] of windowed x4
-
- smull r10, lr, r12, r6 @ r10..lr = (window_l[5] * x[5])
- ldr r12, =WL6 @ r12 = window_l[6]
- movs r10, r10, lsr #28
- adc r6, r10, lr, lsl #4 @ r6 = bits[59..28] of windowed x5
-
- smull r10, lr, r12, r7 @ r10..lr = (window_l[6] * x[6])
- ldr r12, =WL7 @ r12 = window_l[7]
- movs r10, r10, lsr #28
- adc r7, r10, lr, lsl #4 @ r7 = bits[59..28] of windowed x6
-
- smull r10, lr, r12, r8 @ r10..lr = (window_l[7] * x[7])
- ldr r12, =WL8 @ r12 = window_l[8]
- movs r10, r10, lsr #28
- adc r8, r10, lr, lsl #4 @ r8 = bits[59..28] of windowed x7
-
- smull r10, lr, r12, r9 @ r10..lr = (window_l[8] * x[8])
- movs r10, r10, lsr #28
- adc r9, r10, lr, lsl #4 @ r9 = bits[59..28] of windowed x8
-
- stmia r1, { r0, r2 - r9 } @ store windowed x[0] .. x[8]
-
- cmp r11, #BLOCK_MODE_START
- beq start_block_x18_to_x35
-
-
- @----
-
-
-normal_block_x18_to_x35:
-
- ldr r11, =WL3 @ r11 = window_l[3]
- ldr r12, =WL4 @ r12 = window_l[4]
-
- add r1, r1, #(18*4) @ r1 = &x[18]
-
- ldmia r1!, { r0, r2 - r4, r6 - r10 } @ load 9 words from x18, update pointer
-
- @ r0 = x18
- @ r1 = &x[27]
- @ r2 = x19
- @ r3 = x20
- @ r4 = x21
- @ r5 = .
- @ r6 = x22
- @ r7 = x23
- @ r8 = x24
- @ r9 = x25
- @ r10 = x26
- @ r11 = window_l[3]
- @ r12 = window_l[4]
- @ lr = .
-
- smull r5, lr, r12, r6 @ r5..lr = (window_l[4] * (x[22] == x[31]))
- movs r5, r5, lsr #28
- adc r5, r5, lr, lsl #4 @ r5 = bits[59..28] of windowed x31
-
- smull r6, lr, r11, r4 @ r5..lr = (window_l[3] * (x[21] == x[32]))
- ldr r12, =WL5 @ r12 = window_l[5]
- movs r6, r6, lsr #28
- adc r6, r6, lr, lsl #4 @ r6 = bits[59..28] of windowed x32
-
- smull r4, lr, r12, r7 @ r4..lr = (window_l[5] * (x[23] == x[30]))
- ldr r11, =WL1 @ r11 = window_l[1]
- ldr r12, =WL2 @ r12 = window_l[2]
- movs r4, r4, lsr #28
- adc r4, r4, lr, lsl #4 @ r4 = bits[59..28] of windowed x30
-
- smull r7, lr, r12, r3 @ r7..lr = (window_l[2] * (x[20] == x[33]))
- ldr r12, =WL6 @ r12 = window_l[6]
- movs r7, r7, lsr #28
- adc r7, r7, lr, lsl #4 @ r7 = bits[59..28] of windowed x33
-
- smull r3, lr, r12, r8 @ r3..lr = (window_l[6] * (x[24] == x[29]))
- movs r3, r3, lsr #28
- adc r3, r3, lr, lsl #4 @ r3 = bits[59..28] of windowed x29
-
- smull r8, lr, r11, r2 @ r7..lr = (window_l[1] * (x[19] == x[34]))
- ldr r12, =WL7 @ r12 = window_l[7]
- ldr r11, =WL8 @ r11 = window_l[8]
- movs r8, r8, lsr #28
- adc r8, r8, lr, lsl #4 @ r8 = bits[59..28] of windowed x34
-
- smull r2, lr, r12, r9 @ r7..lr = (window_l[7] * (x[25] == x[28]))
- ldr r12, =WL0 @ r12 = window_l[0]
- movs r2, r2, lsr #28
- adc r2, r2, lr, lsl #4 @ r2 = bits[59..28] of windowed x28
-
- smull r9, lr, r12, r0 @ r3..lr = (window_l[0] * (x[18] == x[35]))
- movs r9, r9, lsr #28
- adc r9, r9, lr, lsl #4 @ r9 = bits[59..28] of windowed x35
-
- smull r0, lr, r11, r10 @ r7..lr = (window_l[8] * (x[26] == x[27]))
- ldr r11, =WL16 @ r11 = window_l[16]
- ldr r12, =WL17 @ r12 = window_l[17]
- movs r0, r0, lsr #28
- adc r0, r0, lr, lsl #4 @ r0 = bits[59..28] of windowed x27
-
-
- stmia r1, { r0, r2 - r9 } @ store windowed x[27] .. x[35]
- ldmdb r1!, { r0, r2 - r9 } @ load 9 words downto (and including) x18
-
-
- smull r10, lr, r12, r0 @ r10..lr = (window_l[17] * x[18])
- movs r10, r10, lsr #28
- adc r0, r10, lr, lsl #4 @ r0 = bits[59..28] of windowed x0
-
- smull r10, lr, r11, r2 @ r10..lr = (window_l[16] * x[19])
- ldr r11, =WL14 @ r11 = window_l[14]
- ldr r12, =WL15 @ r12 = window_l[15]
- movs r10, r10, lsr #28
- adc r2, r10, lr, lsl #4 @ r2 = bits[59..28] of windowed x1
-
- smull r10, lr, r12, r3 @ r10..lr = (window_l[15] * x[20])
- movs r10, r10, lsr #28
- adc r3, r10, lr, lsl #4 @ r3 = bits[59..28] of windowed x2
-
- smull r10, lr, r11, r4 @ r10..lr = (window_l[14] * x[21])
- ldr r11, =WL12 @ r11 = window_l[12]
- ldr r12, =WL13 @ r12 = window_l[13]
- movs r10, r10, lsr #28
- adc r4, r10, lr, lsl #4 @ r4 = bits[59..28] of windowed x3
-
- smull r10, lr, r12, r5 @ r10..lr = (window_l[13] * x[22])
- movs r10, r10, lsr #28
- adc r5, r10, lr, lsl #4 @ r5 = bits[59..28] of windowed x4
-
- smull r10, lr, r11, r6 @ r10..lr = (window_l[12] * x[23])
- ldr r11, =WL10 @ r12 = window_l[10]
- ldr r12, =WL11 @ r12 = window_l[11]
- movs r10, r10, lsr #28
- adc r6, r10, lr, lsl #4 @ r6 = bits[59..28] of windowed x5
-
- smull r10, lr, r12, r7 @ r10..lr = (window_l[11] * x[24])
- movs r10, r10, lsr #28
- adc r7, r10, lr, lsl #4 @ r7 = bits[59..28] of windowed x6
-
- smull r10, lr, r11, r8 @ r10..lr = (window_l[10] * x[25])
- ldr r12, =WL9 @ r12 = window_l[9]
- movs r10, r10, lsr #28
- adc r8, r10, lr, lsl #4 @ r8 = bits[59..28] of windowed x7
-
- smull r10, lr, r12, r9 @ r10..lr = (window_l[9] * x[26])
-
- movs r10, r10, lsr #28
- adc r9, r10, lr, lsl #4 @ r9 = bits[59..28] of windowed x8
-
- stmia r1, { r0, r2 - r9 } @ store windowed x[18] .. x[26]
-
- @----
- @ NB there are 2 possible exits from this function - this is only one of them
- @----
-
- add sp, sp, #(21*4) @ return stack frame
- ldmia sp!, { r4 - r11, pc } @ restore callee saved regs, and return
-
- @----
-
-
-stop_block_x0_to_x17:
-
- @ r0 = x0
- @ r1 = &x[9]
- @ r2 = x1
- @ r3 = x2
- @ r4 = x3
- @ r5 = x4
- @ r6 = x5
- @ r7 = x6
- @ r8 = x7
- @ r9 = x8
- @ r10 = -x0
- @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block)
- @ r12 = .
- @ lr = .
-
- rsb r0, r6, #0 @ r0 = -x5
- rsb r6, r2, #0 @ r6 = -x1
- rsb r2, r5, #0 @ r2 = -x4
- rsb r5, r3, #0 @ r5 = -x2
- rsb r3, r4, #0 @ r3 = -x3
-
- add r1, r1, #(3*4) @ r1 = &x[12]
- stmia r1, { r0, r2, r3, r5, r6, r10 } @ store unchanged x[12] .. x[17]
-
- ldr r0, =WL1 @ r0 = window_l[1] == window_s[0]
-
- rsb r10, r9, #0 @ r10 = -x8
- rsb r12, r8, #0 @ r12 = -x7
- rsb lr, r7, #0 @ lr = -x6
-
- @ r0 = WL1
- @ r1 = &x[12]
- @ r2 = .
- @ r3 = .
- @ r4 = .
- @ r5 = .
- @ r6 = .
- @ r7 = x6
- @ r8 = x7
- @ r9 = x8
- @ r10 = -x8
- @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block)
- @ r12 = -x7
- @ lr = -x6
-
- smull r5, r6, r0, r7 @ r5..r6 = (window_l[1] * x[6])
- ldr r2, =WL4 @ r2 = window_l[4] == window_s[1]
- movs r5, r5, lsr #28
- adc r7, r5, r6, lsl #4 @ r7 = bits[59..28] of windowed x6
-
- smull r5, r6, r2, r8 @ r5..r6 = (window_l[4] * x[7])
- ldr r3, =WL7 @ r3 = window_l[7] == window_s[2]
- movs r5, r5, lsr #28
- adc r8, r5, r6, lsl #4 @ r8 = bits[59..28] of windowed x7
-
- smull r5, r6, r3, r9 @ r5..r6 = (window_l[7] * x[8])
- ldr r4, =WL10 @ r4 = window_l[10] == window_s[3]
- movs r5, r5, lsr #28
- adc r9, r5, r6, lsl #4 @ r9 = bits[59..28] of windowed x8
-
- smull r5, r6, r4, r10 @ r5..r6 = (window_l[10] * (x[9] == -x[8]))
- ldr r0, =WL13 @ r0 = window_l[13] == window_s[4]
- movs r5, r5, lsr #28
- adc r10, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9
-
- smull r5, r6, r0, r12 @ r5..r6 = (window_l[13] * (x[10] == -x[7]))
- ldr r2, =WL16 @ r2 = window_l[16] == window_s[5]
- movs r5, r5, lsr #28
- adc r12, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9
-
- smull r5, r6, r2, lr @ r5..r6 = (window_l[16] * (x[11] == -x[6]))
-
- ldr r0, =0x00
-
- movs r5, r5, lsr #28
- adc lr, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9
-
- stmdb r1!, { r7 - r10, r12, lr } @ store windowed x[6] .. x[11]
-
- ldr r5, =0x00
- ldr r6, =0x00
- ldr r2, =0x00
- ldr r3, =0x00
- ldr r4, =0x00
-
- stmdb r1!, { r0, r2 - r6 } @ store windowed x[0] .. x[5]
-
- b normal_block_x18_to_x35
-
-
- @----
-
-
-start_block_x18_to_x35:
-
- ldr r4, =WL1 @ r0 = window_l[1] == window_s[0]
-
- add r1, r1, #(24*4) @ r1 = &x[24]
-
- ldmia r1, { r0, r2, r3 } @ load 3 words from x24, dont update pointer
-
- @ r0 = x24
- @ r1 = &x[24]
- @ r2 = x25
- @ r3 = x26
- @ r4 = WL1
- @ r5 = WL4
- @ r6 = WL7
- @ r7 = WL10
- @ r8 = WL13
- @ r9 = WL16
- @ r10 = .
- @ r11 = .
- @ r12 = .
- @ lr = .
-
- ldr r5, =WL4 @ r5 = window_l[4] == window_s[1]
-
- smull r10, r11, r4, r0 @ r10..r11 = (window_l[1] * (x[24] == x[29]))
- ldr r6, =WL7 @ r6 = window_l[7] == window_s[2]
- movs r10, r10, lsr #28
- adc lr, r10, r11, lsl #4 @ lr = bits[59..28] of windowed x29
-
- smull r10, r11, r5, r2 @ r10..r11 = (window_l[4] * (x[25] == x[28]))
- ldr r7, =WL10 @ r7 = window_l[10] == window_s[3]
- movs r10, r10, lsr #28
- adc r12, r10, r11, lsl #4 @ r12 = bits[59..28] of windowed x28
-
- smull r10, r11, r6, r3 @ r10..r11 = (window_l[7] * (x[26] == x[27]))
- ldr r8, =WL13 @ r8 = window_l[13] == window_s[4]
- movs r10, r10, lsr #28
- adc r4, r10, r11, lsl #4 @ r4 = bits[59..28] of windowed x27
-
- smull r10, r11, r7, r3 @ r10..r11 = (window_l[10] * x[26])
- ldr r9, =WL16 @ r9 = window_l[16] == window_s[5]
- movs r10, r10, lsr #28
- adc r3, r10, r11, lsl #4 @ r3 = bits[59..28] of windowed x26
-
- smull r10, r11, r8, r2 @ r10..r11 = (window_l[13] * x[25])
- ldr r5, =0x00
- movs r10, r10, lsr #28
- adc r2, r10, r11, lsl #4 @ r2 = bits[59..28] of windowed x25
-
- smull r10, r11, r9, r0 @ r10..r11 = (window_l[16] * x[24])
- ldr r6, =0x00
- movs r10, r10, lsr #28
- adc r0, r10, r11, lsl #4 @ r0 = bits[59..28] of windowed x24
-
- stmia r1!, { r0, r2, r3, r4, r12, lr } @ store windowed x[24] .. x[29]
-
- ldr r7, =0x00
- ldr r8, =0x00
- ldr r9, =0x00
- ldr r10, =0x00
-
- stmia r1!, { r5 - r10 } @ store windowed x[30] .. x[35]
-
- @----
- @ NB there are 2 possible exits from this function - this is only one of them
- @----
-
- add sp, sp, #(21*4) @ return stack frame
- ldmia sp!, { r4 - r11, pc } @ restore callee saved regs, and return
-
- @----
- @END
- @----
-