summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CREDITS2
-rw-r--r--ChangeLog2
-rw-r--r--configure.ac13
-rw-r--r--contrib/Makefile.am2
-rw-r--r--contrib/libdca/COPYING339
-rw-r--r--contrib/libdca/Makefile.am15
-rw-r--r--contrib/libdca/bitstream.c (renamed from src/libdts/bitstream.c)25
-rw-r--r--contrib/libdca/bitstream.h (renamed from src/libdts/bitstream.h)23
-rw-r--r--contrib/libdca/dca_internal.h (renamed from src/libdts/dts_internal.h)83
-rw-r--r--contrib/libdca/downmix.c (renamed from src/libdts/downmix.c)365
-rw-r--r--contrib/libdca/include/dca.h86
-rw-r--r--contrib/libdca/include/dts.h55
-rw-r--r--contrib/libdca/parse.c (renamed from src/libdts/parse.c)176
-rw-r--r--contrib/libdca/tables.h (renamed from src/libdts/tables.h)21
-rw-r--r--contrib/libdca/tables_adpcm.h (renamed from src/libdts/tables_adpcm.h)13
-rw-r--r--contrib/libdca/tables_fir.h (renamed from src/libdts/tables_fir.h)13
-rw-r--r--contrib/libdca/tables_huffman.h (renamed from src/libdts/tables_huffman.h)16
-rw-r--r--contrib/libdca/tables_quantization.h (renamed from src/libdts/tables_quantization.h)13
-rw-r--r--contrib/libdca/tables_vq.h (renamed from src/libdts/tables_vq.h)13
-rw-r--r--src/libdts/Makefile.am26
-rw-r--r--src/libdts/internal-dts.h85
-rw-r--r--src/libdts/xine_dts_decoder.c6
22 files changed, 904 insertions, 488 deletions
diff --git a/CREDITS b/CREDITS
index 6603ce708..37aa99872 100644
--- a/CREDITS
+++ b/CREDITS
@@ -17,7 +17,7 @@ goom 2k4-0
gsm610 1.0.10 Mike Melanson
liba52 0.7.4
libcdio 0.71 [o]
-libdts 0.0.2
+libca 0.0.5
libdvdnav 0.1.10 Michael Roitzsch
libfaad cvs-2005-01-30 [GPL] Miguel Freitas
libmad 0.15.1b Miguel Freitas
diff --git a/ChangeLog b/ChangeLog
index d28e4814f..5b534a72b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,8 @@ xine-lib (1.1.90) (Unreleased)
* Use XDG-defined cache home directory for win32codecs fake registry.
* Use XDG-defined data directories to look up fonts files both while using
FreeType2 and the standard bitmap fonts for OSD.
+ * Replace internal libdts 0.0.2 with libdca 0.0.5, and contextually move it
+ to contrib/libdca to separate from xine's own code.
xine-lib (1.1.7) (unreleased)
* Support libdca (new name for libdts) by shuffling around the dts.h file.
diff --git a/configure.ac b/configure.ac
index c4799d04e..8436f7a43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1914,7 +1914,7 @@ dnl ---------------------------------------------
AC_ARG_ENABLE(dts, AS_HELP_STRING([--disable-dts], [Disable support for DTS decoding library (default: enabled)]),
[enable_libdts="$enableval"], [enable_libdts="yes"])
-AC_ARG_WITH(external-libdts, AS_HELP_STRING([--with-external-libdts], [use external libdts library (not recommended)]),
+AC_ARG_WITH(external-libdts, AS_HELP_STRING([--with-external-libdts], [use external libdts/libdca library (not recommended)]),
[external_libdts="$withval"], [external_libdts="no"])
have_dts="no"
@@ -1923,16 +1923,20 @@ if test "x$enable_libdts" = "xno"; then
AC_MSG_RESULT([libdts support disabled])
elif test "x$external_libdts" = "xyes"; then
PKG_CHECK_MODULES(LIBDTS, [libdts], have_dts=yes, have_dts=no)
- AC_CHECK_HEADERS([dts.h])
- AC_SUBST(LIBDTS_LIBS)
- AC_SUBST(LIBDTS_CFLAGS)
if test "x$have_dts" = "xno"; then
AC_MSG_RESULT([*** no usable version of libdts found, using internal copy ***])
fi
else
AC_MSG_RESULT([Use included libdts support])
+ LIBDTS_CFLAGS='-I$(top_srcdir)/contrib/libdca'
+ LIBDTS_DEPS='$(top_builddir)/contrib/libdca/libdca.la'
+ LIBDTS_LIBS='$(top_builddir)/contrib/libdca/libdca.la'
fi
+AC_SUBST(LIBDTS_LIBS)
+AC_SUBST(LIBDTS_DEPS)
+AC_SUBST(LIBDTS_CFLAGS)
+
AM_CONDITIONAL(DTS, test "x$enable_libdts" = "xyes")
AM_CONDITIONAL(EXTERNAL_LIBDTS, test "x$have_dts" = "xyes")
@@ -2590,6 +2594,7 @@ doc/hackersguide/Makefile
doc/faq/Makefile
doc/Doxyfile
contrib/Makefile
+contrib/libdca/Makefile
contrib/libmpcdec/Makefile
contrib/libxdg-basedir/Makefile
include/Makefile
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index f7d0c9c88..2eabf662a 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = libmpcdec libxdg-basedir
+SUBDIRS = libmpcdec libxdg-basedir libdca
srcdir = $(shell cd @srcdir@; pwd)
diff --git a/contrib/libdca/COPYING b/contrib/libdca/COPYING
new file mode 100644
index 000000000..d511905c1
--- /dev/null
+++ b/contrib/libdca/COPYING
@@ -0,0 +1,339 @@
+ 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 Lesser 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 Lesser General
+Public License instead of this License.
diff --git a/contrib/libdca/Makefile.am b/contrib/libdca/Makefile.am
new file mode 100644
index 000000000..14206a363
--- /dev/null
+++ b/contrib/libdca/Makefile.am
@@ -0,0 +1,15 @@
+if DTS
+if !EXTERNAL_LIBDTS
+noinst_LTLIBRARIES = libdca.la
+endif
+endif
+
+libdca_la_SOURCES = dca_internal.h tables.h tables_quantization.h \
+ tables_huffman.h tables_fir.h tables_adpcm.h tables_vq.h \
+ bitstream.h bitstream.c parse.c downmix.c \
+ include/dca.h include/dts.h
+
+libdca_la_CFLAGS = -I$(srcdir)/include $(VISIBILITY_FLAG)
+libdca_la_LIBADD = -lm
+
+EXTRA_DIST = COPYING
diff --git a/src/libdts/bitstream.c b/contrib/libdca/bitstream.c
index 8a5c4caac..b92714868 100644
--- a/src/libdts/bitstream.c
+++ b/contrib/libdca/bitstream.c
@@ -4,41 +4,42 @@
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <inttypes.h>
-#include "dts.h"
-#include "dts_internal.h"
+#include "dca.h"
+#include "dca_internal.h"
#include "bitstream.h"
#define BUFFER_SIZE 4096
-void dts_bitstream_init (dts_state_t * state, uint8_t * buf, int word_mode,
+void dca_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode,
int bigendian_mode)
{
intptr_t align;
align = (uintptr_t)buf & 3;
- state->buffer_start = (uint32_t *) (buf - align);
+ state->buffer_start = (uint32_t *) ((uintptr_t)buf - align);
state->bits_left = 0;
state->current_word = 0;
state->word_mode = word_mode;
@@ -46,7 +47,7 @@ void dts_bitstream_init (dts_state_t * state, uint8_t * buf, int word_mode,
bitstream_get (state, align * 8);
}
#include<stdio.h>
-static inline void bitstream_fill_current (dts_state_t * state)
+static inline void bitstream_fill_current (dca_state_t * state)
{
uint32_t tmp;
@@ -73,7 +74,7 @@ static inline void bitstream_fill_current (dts_state_t * state)
* -ah
*/
-uint32_t dts_bitstream_get_bh (dts_state_t * state, uint32_t num_bits)
+uint32_t dca_bitstream_get_bh (dca_state_t * state, uint32_t num_bits)
{
uint32_t result;
diff --git a/src/libdts/bitstream.h b/contrib/libdca/bitstream.h
index 105dc0e9b..4bce80aab 100644
--- a/src/libdts/bitstream.h
+++ b/contrib/libdca/bitstream.h
@@ -4,22 +4,23 @@
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef WORDS_BIGENDIAN
@@ -43,15 +44,15 @@
#else
# define swable32(x)\
-((((uint16_t*)&x)[0] << 16) | (((uint16_t*)&x)[1]))
+((((uint32_t)x) >> 16) | (((uint32_t)x) << 16))
#endif
-void dts_bitstream_init (dts_state_t * state, uint8_t * buf, int word_mode,
+void dca_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode,
int endian_mode);
-uint32_t dts_bitstream_get_bh (dts_state_t * state, uint32_t num_bits);
+uint32_t dca_bitstream_get_bh (dca_state_t * state, uint32_t num_bits);
-static inline uint32_t bitstream_get (dts_state_t * state, uint32_t num_bits)
+static inline uint32_t bitstream_get (dca_state_t * state, uint32_t num_bits)
{
uint32_t result;
@@ -63,5 +64,5 @@ static inline uint32_t bitstream_get (dts_state_t * state, uint32_t num_bits)
return result;
}
- return dts_bitstream_get_bh (state, num_bits);
+ return dca_bitstream_get_bh (state, num_bits);
}
diff --git a/src/libdts/dts_internal.h b/contrib/libdca/dca_internal.h
index e834e96a8..2c43cf049 100644
--- a/src/libdts/dts_internal.h
+++ b/contrib/libdca/dca_internal.h
@@ -1,35 +1,36 @@
/*
- * dts_internal.h
+ * dca_internal.h
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#define DTS_SUBFRAMES_MAX (16)
-#define DTS_PRIM_CHANNELS_MAX (5)
-#define DTS_SUBBANDS (32)
-#define DTS_ABITS_MAX (32) /* Should be 28 */
-#define DTS_SUBSUBFAMES_MAX (4)
-#define DTS_LFE_MAX (3)
+#define DCA_SUBFRAMES_MAX (16)
+#define DCA_PRIM_CHANNELS_MAX (5)
+#define DCA_SUBBANDS (32)
+#define DCA_ABITS_MAX (32) /* Should be 28 */
+#define DCA_SUBSUBFAMES_MAX (4)
+#define DCA_LFE_MAX (3)
-struct dts_state_s {
+struct dca_state_s {
/* Frame header */
int frame_type; /* type of the current frame */
@@ -64,55 +65,55 @@ struct dts_state_s {
int subframes; /* number of subframes */
int prim_channels; /* number of primary audio channels */
/* subband activity count */
- int subband_activity[DTS_PRIM_CHANNELS_MAX];
+ int subband_activity[DCA_PRIM_CHANNELS_MAX];
/* high frequency vq start subband */
- int vq_start_subband[DTS_PRIM_CHANNELS_MAX];
+ int vq_start_subband[DCA_PRIM_CHANNELS_MAX];
/* joint intensity coding index */
- int joint_intensity[DTS_PRIM_CHANNELS_MAX];
+ int joint_intensity[DCA_PRIM_CHANNELS_MAX];
/* transient mode code book */
- int transient_huffman[DTS_PRIM_CHANNELS_MAX];
+ int transient_huffman[DCA_PRIM_CHANNELS_MAX];
/* scale factor code book */
- int scalefactor_huffman[DTS_PRIM_CHANNELS_MAX];
+ int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX];
/* bit allocation quantizer select */
- int bitalloc_huffman[DTS_PRIM_CHANNELS_MAX];
+ int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX];
/* quantization index codebook select */
- int quant_index_huffman[DTS_PRIM_CHANNELS_MAX][DTS_ABITS_MAX];
+ int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX];
/* scale factor adjustment */
- float scalefactor_adj[DTS_PRIM_CHANNELS_MAX][DTS_ABITS_MAX];
+ float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX];
/* Primary audio coding side information */
int subsubframes; /* number of subsubframes */
int partial_samples; /* partial subsubframe samples count */
/* prediction mode (ADPCM used or not) */
- int prediction_mode[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS];
+ int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];
/* prediction VQ coefs */
- int prediction_vq[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS];
+ int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];
/* bit allocation index */
- int bitalloc[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS];
+ int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];
/* transition mode (transients) */
- int transition_mode[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS];
+ int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];
/* scale factors (2 if transient)*/
- int scale_factor[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS][2];
+ int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2];
/* joint subband scale factors codebook */
- int joint_huff[DTS_PRIM_CHANNELS_MAX];
+ int joint_huff[DCA_PRIM_CHANNELS_MAX];
/* joint subband scale factors */
- int joint_scale_factor[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS];
+ int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];
/* stereo downmix coefficients */
- int downmix_coef[DTS_PRIM_CHANNELS_MAX][2];
+ int downmix_coef[DCA_PRIM_CHANNELS_MAX][2];
/* dynamic range coefficient */
int dynrange_coef;
/* VQ encoded high frequency subbands */
- int high_freq_vq[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS];
+ int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];
/* Low frequency effect data */
- double lfe_data[2*DTS_SUBSUBFAMES_MAX*DTS_LFE_MAX * 2 /*history*/];
+ double lfe_data[2*DCA_SUBSUBFAMES_MAX*DCA_LFE_MAX * 2 /*history*/];
int lfe_scale_factor;
/* Subband samples history (for ADPCM) */
- double subband_samples_hist[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS][4];
- double subband_fir_hist[DTS_PRIM_CHANNELS_MAX][512];
- double subband_fir_noidea[DTS_PRIM_CHANNELS_MAX][64];
+ double subband_samples_hist[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4];
+ double subband_fir_hist[DCA_PRIM_CHANNELS_MAX][512];
+ double subband_fir_noidea[DCA_PRIM_CHANNELS_MAX][64];
/* Audio output */
level_t clev; /* centre channel mix level */
@@ -154,17 +155,17 @@ struct dts_state_s {
#define LEVEL_45DB 0.5946035575013605
#define LEVEL_6DB 0.5
-int dts_downmix_init (int input, int flags, level_t * level,
+int dca_downmix_init (int input, int flags, level_t * level,
level_t clev, level_t slev);
-int dts_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
+int dca_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
level_t clev, level_t slev);
-void dts_downmix (sample_t * samples, int acmod, int output, sample_t bias,
+void dca_downmix (sample_t * samples, int acmod, int output, sample_t bias,
level_t clev, level_t slev);
-void dts_upmix (sample_t * samples, int acmod, int output);
+void dca_upmix (sample_t * samples, int acmod, int output);
#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
-#ifndef LIBDTS_FIXED
+#ifndef LIBDCA_FIXED
typedef sample_t quantizer_t;
#define SAMPLE(x) (x)
@@ -175,7 +176,7 @@ typedef sample_t quantizer_t;
#define DIV(a,b) ((a) / (b))
#define BIAS(x) ((x) + bias)
-#else /* LIBDTS_FIXED */
+#else /* LIBDCA_FIXED */
typedef int16_t quantizer_t;
#define SAMPLE(x) (sample_t)((x) * (1 << 30))
diff --git a/src/libdts/downmix.c b/contrib/libdca/downmix.c
index 3614c5e8b..ff02127f4 100644
--- a/src/libdts/downmix.c
+++ b/contrib/libdca/downmix.c
@@ -4,22 +4,23 @@
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
@@ -27,149 +28,149 @@
#include <string.h>
#include <inttypes.h>
-#include "dts.h"
-#include "dts_internal.h"
+#include "dca.h"
+#include "dca_internal.h"
-#define CONVERT(acmod,output) (((output) << DTS_CHANNEL_BITS) + (acmod))
+#define CONVERT(acmod,output) (((output) << DCA_CHANNEL_BITS) + (acmod))
-int dts_downmix_init (int input, int flags, level_t * level,
+int dca_downmix_init (int input, int flags, level_t * level,
level_t clev, level_t slev)
{
static uint8_t table[11][10] = {
- /* DTS_MONO */
- {DTS_MONO, DTS_MONO, DTS_MONO, DTS_MONO,
- DTS_MONO, DTS_MONO, DTS_MONO, DTS_MONO,
- DTS_MONO, DTS_MONO},
- /* DTS_CHANNEL */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO},
- /* DTS_STEREO */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO},
- /* DTS_STEREO_SUMDIFF */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO},
- /* DTS_STEREO_TOTAL */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO},
- /* DTS_3F */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_3F, DTS_3F, DTS_3F,
- DTS_3F, DTS_3F},
- /* DTS_2F1R */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_2F1R, DTS_2F1R, DTS_2F1R,
- DTS_2F1R, DTS_2F1R},
- /* DTS_3F1R */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_3F, DTS_3F1R, DTS_3F1R,
- DTS_3F1R, DTS_3F1R},
- /* DTS_2F2R */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_STEREO, DTS_2F2R, DTS_2F2R,
- DTS_2F2R, DTS_2F2R},
- /* DTS_3F2R */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_3F, DTS_3F2R, DTS_3F2R,
- DTS_3F2R, DTS_3F2R},
- /* DTS_4F2R */
- {DTS_MONO, DTS_CHANNEL, DTS_STEREO, DTS_STEREO,
- DTS_STEREO, DTS_4F2R, DTS_4F2R, DTS_4F2R,
- DTS_4F2R, DTS_4F2R},
+ /* DCA_MONO */
+ {DCA_MONO, DCA_MONO, DCA_MONO, DCA_MONO,
+ DCA_MONO, DCA_MONO, DCA_MONO, DCA_MONO,
+ DCA_MONO, DCA_MONO},
+ /* DCA_CHANNEL */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO},
+ /* DCA_STEREO */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO},
+ /* DCA_STEREO_SUMDIFF */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO},
+ /* DCA_STEREO_TOTAL */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO},
+ /* DCA_3F */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_3F, DCA_3F, DCA_3F,
+ DCA_3F, DCA_3F},
+ /* DCA_2F1R */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_2F1R, DCA_2F1R, DCA_2F1R,
+ DCA_2F1R, DCA_2F1R},
+ /* DCA_3F1R */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_3F, DCA_3F1R, DCA_3F1R,
+ DCA_3F1R, DCA_3F1R},
+ /* DCA_2F2R */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_STEREO, DCA_2F2R, DCA_2F2R,
+ DCA_2F2R, DCA_2F2R},
+ /* DCA_3F2R */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_3F, DCA_3F2R, DCA_3F2R,
+ DCA_3F2R, DCA_3F2R},
+ /* DCA_4F2R */
+ {DCA_MONO, DCA_CHANNEL, DCA_STEREO, DCA_STEREO,
+ DCA_STEREO, DCA_4F2R, DCA_4F2R, DCA_4F2R,
+ DCA_4F2R, DCA_4F2R},
};
int output;
- output = flags & DTS_CHANNEL_MASK;
+ output = flags & DCA_CHANNEL_MASK;
- if (output > DTS_CHANNEL_MAX)
+ if (output > DCA_CHANNEL_MAX)
return -1;
output = table[output][input];
- if (output == DTS_STEREO &&
- (input == DTS_DOLBY || (input == DTS_3F && clev == LEVEL (LEVEL_3DB))))
- output = DTS_DOLBY;
+ if (output == DCA_STEREO &&
+ (input == DCA_DOLBY || (input == DCA_3F && clev == LEVEL (LEVEL_3DB))))
+ output = DCA_DOLBY;
- if (flags & DTS_ADJUST_LEVEL) {
+ if (flags & DCA_ADJUST_LEVEL) {
level_t adjust;
switch (CONVERT (input & 7, output)) {
- case CONVERT (DTS_3F, DTS_MONO):
+ case CONVERT (DCA_3F, DCA_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev);
break;
- case CONVERT (DTS_STEREO, DTS_MONO):
- case CONVERT (DTS_2F2R, DTS_2F1R):
- case CONVERT (DTS_3F2R, DTS_3F1R):
+ case CONVERT (DCA_STEREO, DCA_MONO):
+ case CONVERT (DCA_2F2R, DCA_2F1R):
+ case CONVERT (DCA_3F2R, DCA_3F1R):
level_3db:
adjust = LEVEL (LEVEL_3DB);
break;
- case CONVERT (DTS_3F2R, DTS_2F1R):
+ case CONVERT (DCA_3F2R, DCA_2F1R):
if (clev < LEVEL (LEVEL_PLUS3DB - 1))
goto level_3db;
/* break thru */
- case CONVERT (DTS_3F, DTS_STEREO):
- case CONVERT (DTS_3F1R, DTS_2F1R):
- case CONVERT (DTS_3F1R, DTS_2F2R):
- case CONVERT (DTS_3F2R, DTS_2F2R):
+ case CONVERT (DCA_3F, DCA_STEREO):
+ case CONVERT (DCA_3F1R, DCA_2F1R):
+ case CONVERT (DCA_3F1R, DCA_2F2R):
+ case CONVERT (DCA_3F2R, DCA_2F2R):
adjust = DIV (1, LEVEL (1) + clev);
break;
- case CONVERT (DTS_2F1R, DTS_MONO):
+ case CONVERT (DCA_2F1R, DCA_MONO):
adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev);
break;
- case CONVERT (DTS_2F1R, DTS_STEREO):
- case CONVERT (DTS_3F1R, DTS_3F):
+ case CONVERT (DCA_2F1R, DCA_STEREO):
+ case CONVERT (DCA_3F1R, DCA_3F):
adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB));
break;
- case CONVERT (DTS_3F1R, DTS_MONO):
+ case CONVERT (DCA_3F1R, DCA_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5));
break;
- case CONVERT (DTS_3F1R, DTS_STEREO):
+ case CONVERT (DCA_3F1R, DCA_STEREO):
adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB));
break;
- case CONVERT (DTS_2F2R, DTS_MONO):
+ case CONVERT (DCA_2F2R, DCA_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + slev);
break;
- case CONVERT (DTS_2F2R, DTS_STEREO):
- case CONVERT (DTS_3F2R, DTS_3F):
+ case CONVERT (DCA_2F2R, DCA_STEREO):
+ case CONVERT (DCA_3F2R, DCA_3F):
adjust = DIV (1, LEVEL (1) + slev);
break;
- case CONVERT (DTS_3F2R, DTS_MONO):
+ case CONVERT (DCA_3F2R, DCA_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev);
break;
- case CONVERT (DTS_3F2R, DTS_STEREO):
+ case CONVERT (DCA_3F2R, DCA_STEREO):
adjust = DIV (1, LEVEL (1) + clev + slev);
break;
- case CONVERT (DTS_MONO, DTS_DOLBY):
+ case CONVERT (DCA_MONO, DCA_DOLBY):
adjust = LEVEL (LEVEL_PLUS3DB);
break;
- case CONVERT (DTS_3F, DTS_DOLBY):
- case CONVERT (DTS_2F1R, DTS_DOLBY):
+ case CONVERT (DCA_3F, DCA_DOLBY):
+ case CONVERT (DCA_2F1R, DCA_DOLBY):
adjust = LEVEL (1 / (1 + LEVEL_3DB));
break;
- case CONVERT (DTS_3F1R, DTS_DOLBY):
- case CONVERT (DTS_2F2R, DTS_DOLBY):
+ case CONVERT (DCA_3F1R, DCA_DOLBY):
+ case CONVERT (DCA_2F2R, DCA_DOLBY):
adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB));
break;
- case CONVERT (DTS_3F2R, DTS_DOLBY):
+ case CONVERT (DCA_3F2R, DCA_DOLBY):
adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB));
break;
@@ -183,158 +184,158 @@ int dts_downmix_init (int input, int flags, level_t * level,
return output;
}
-int dts_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
+int dca_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
level_t clev, level_t slev)
{
level_t level_3db;
level_3db = MUL_C (level, LEVEL_3DB);
- switch (CONVERT (acmod, output & DTS_CHANNEL_MASK)) {
-
- case CONVERT (DTS_CHANNEL, DTS_CHANNEL):
- case CONVERT (DTS_MONO, DTS_MONO):
- case CONVERT (DTS_STEREO, DTS_STEREO):
- case CONVERT (DTS_3F, DTS_3F):
- case CONVERT (DTS_2F1R, DTS_2F1R):
- case CONVERT (DTS_3F1R, DTS_3F1R):
- case CONVERT (DTS_2F2R, DTS_2F2R):
- case CONVERT (DTS_3F2R, DTS_3F2R):
- case CONVERT (DTS_STEREO, DTS_DOLBY):
+ switch (CONVERT (acmod, output & DCA_CHANNEL_MASK)) {
+
+ case CONVERT (DCA_CHANNEL, DCA_CHANNEL):
+ case CONVERT (DCA_MONO, DCA_MONO):
+ case CONVERT (DCA_STEREO, DCA_STEREO):
+ case CONVERT (DCA_3F, DCA_3F):
+ case CONVERT (DCA_2F1R, DCA_2F1R):
+ case CONVERT (DCA_3F1R, DCA_3F1R):
+ case CONVERT (DCA_2F2R, DCA_2F2R):
+ case CONVERT (DCA_3F2R, DCA_3F2R):
+ case CONVERT (DCA_STEREO, DCA_DOLBY):
coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
return 0;
- case CONVERT (DTS_CHANNEL, DTS_MONO):
+ case CONVERT (DCA_CHANNEL, DCA_MONO):
coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB);
return 3;
- case CONVERT (DTS_STEREO, DTS_MONO):
+ case CONVERT (DCA_STEREO, DCA_MONO):
coeff[0] = coeff[1] = level_3db;
return 3;
- case CONVERT (DTS_3F, DTS_MONO):
+ case CONVERT (DCA_3F, DCA_MONO):
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
return 7;
- case CONVERT (DTS_2F1R, DTS_MONO):
+ case CONVERT (DCA_2F1R, DCA_MONO):
coeff[0] = coeff[1] = level_3db;
coeff[2] = MUL_L (level_3db, slev);
return 7;
- case CONVERT (DTS_2F2R, DTS_MONO):
+ case CONVERT (DCA_2F2R, DCA_MONO):
coeff[0] = coeff[1] = level_3db;
coeff[2] = coeff[3] = MUL_L (level_3db, slev);
return 15;
- case CONVERT (DTS_3F1R, DTS_MONO):
+ case CONVERT (DCA_3F1R, DCA_MONO):
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
coeff[3] = MUL_L (level_3db, slev);
return 15;
- case CONVERT (DTS_3F2R, DTS_MONO):
+ case CONVERT (DCA_3F2R, DCA_MONO):
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
coeff[3] = coeff[4] = MUL_L (level_3db, slev);
return 31;
- case CONVERT (DTS_MONO, DTS_DOLBY):
+ case CONVERT (DCA_MONO, DCA_DOLBY):
coeff[0] = level_3db;
return 0;
- case CONVERT (DTS_3F, DTS_DOLBY):
+ case CONVERT (DCA_3F, DCA_DOLBY):
coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
coeff[1] = level_3db;
return 7;
- case CONVERT (DTS_3F, DTS_STEREO):
- case CONVERT (DTS_3F1R, DTS_2F1R):
- case CONVERT (DTS_3F2R, DTS_2F2R):
+ case CONVERT (DCA_3F, DCA_STEREO):
+ case CONVERT (DCA_3F1R, DCA_2F1R):
+ case CONVERT (DCA_3F2R, DCA_2F2R):
coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
coeff[1] = MUL_L (level, clev);
return 7;
- case CONVERT (DTS_2F1R, DTS_DOLBY):
+ case CONVERT (DCA_2F1R, DCA_DOLBY):
coeff[0] = coeff[1] = level;
coeff[2] = level_3db;
return 7;
- case CONVERT (DTS_2F1R, DTS_STEREO):
+ case CONVERT (DCA_2F1R, DCA_STEREO):
coeff[0] = coeff[1] = level;
coeff[2] = MUL_L (level_3db, slev);
return 7;
- case CONVERT (DTS_3F1R, DTS_DOLBY):
+ case CONVERT (DCA_3F1R, DCA_DOLBY):
coeff[0] = coeff[2] = level;
coeff[1] = coeff[3] = level_3db;
return 15;
- case CONVERT (DTS_3F1R, DTS_STEREO):
+ case CONVERT (DCA_3F1R, DCA_STEREO):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = MUL_L (level_3db, slev);
return 15;
- case CONVERT (DTS_2F2R, DTS_DOLBY):
+ case CONVERT (DCA_2F2R, DCA_DOLBY):
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = level_3db;
return 15;
- case CONVERT (DTS_2F2R, DTS_STEREO):
+ case CONVERT (DCA_2F2R, DCA_STEREO):
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = MUL_L (level, slev);
return 15;
- case CONVERT (DTS_3F2R, DTS_DOLBY):
+ case CONVERT (DCA_3F2R, DCA_DOLBY):
coeff[0] = coeff[2] = level;
coeff[1] = coeff[3] = coeff[4] = level_3db;
return 31;
- case CONVERT (DTS_3F2R, DTS_2F1R):
+ case CONVERT (DCA_3F2R, DCA_2F1R):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = coeff[4] = level_3db;
return 31;
- case CONVERT (DTS_3F2R, DTS_STEREO):
+ case CONVERT (DCA_3F2R, DCA_STEREO):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = coeff[4] = MUL_L (level, slev);
return 31;
- case CONVERT (DTS_3F1R, DTS_3F):
+ case CONVERT (DCA_3F1R, DCA_3F):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = MUL_L (level_3db, slev);
return 13;
- case CONVERT (DTS_3F2R, DTS_3F):
+ case CONVERT (DCA_3F2R, DCA_3F):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = coeff[4] = MUL_L (level, slev);
return 29;
- case CONVERT (DTS_2F2R, DTS_2F1R):
+ case CONVERT (DCA_2F2R, DCA_2F1R):
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = level_3db;
return 12;
- case CONVERT (DTS_3F2R, DTS_3F1R):
+ case CONVERT (DCA_3F2R, DCA_3F1R):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = coeff[4] = level_3db;
return 24;
- case CONVERT (DTS_2F1R, DTS_2F2R):
+ case CONVERT (DCA_2F1R, DCA_2F2R):
coeff[0] = coeff[1] = level;
coeff[2] = level_3db;
return 0;
- case CONVERT (DTS_3F1R, DTS_2F2R):
+ case CONVERT (DCA_3F1R, DCA_2F2R):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = level_3db;
return 7;
- case CONVERT (DTS_3F1R, DTS_3F2R):
+ case CONVERT (DCA_3F1R, DCA_3F2R):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = level_3db;
return 0;
@@ -491,200 +492,202 @@ static void zero (sample_t * samples)
samples[i] = 0;
}
-void dts_downmix (sample_t * samples, int acmod, int output, sample_t bias,
+void dca_downmix (sample_t * samples, int acmod, int output, sample_t bias,
level_t clev, level_t slev)
{
- switch (CONVERT (acmod, output & DTS_CHANNEL_MASK)) {
+ (void)clev;
- case CONVERT (DTS_CHANNEL, DTS_MONO):
- case CONVERT (DTS_STEREO, DTS_MONO):
+ switch (CONVERT (acmod, output & DCA_CHANNEL_MASK)) {
+
+ case CONVERT (DCA_CHANNEL, DCA_MONO):
+ case CONVERT (DCA_STEREO, DCA_MONO):
mix_2to1:
mix2to1 (samples, samples + 256, bias);
break;
- case CONVERT (DTS_2F1R, DTS_MONO):
+ case CONVERT (DCA_2F1R, DCA_MONO):
if (slev == 0)
goto mix_2to1;
- case CONVERT (DTS_3F, DTS_MONO):
+ case CONVERT (DCA_3F, DCA_MONO):
mix_3to1:
mix3to1 (samples, bias);
break;
- case CONVERT (DTS_3F1R, DTS_MONO):
+ case CONVERT (DCA_3F1R, DCA_MONO):
if (slev == 0)
goto mix_3to1;
- case CONVERT (DTS_2F2R, DTS_MONO):
+ case CONVERT (DCA_2F2R, DCA_MONO):
if (slev == 0)
goto mix_2to1;
mix4to1 (samples, bias);
break;
- case CONVERT (DTS_3F2R, DTS_MONO):
+ case CONVERT (DCA_3F2R, DCA_MONO):
if (slev == 0)
goto mix_3to1;
mix5to1 (samples, bias);
break;
- case CONVERT (DTS_MONO, DTS_DOLBY):
+ case CONVERT (DCA_MONO, DCA_DOLBY):
memcpy (samples + 256, samples, 256 * sizeof (sample_t));
break;
- case CONVERT (DTS_3F, DTS_STEREO):
- case CONVERT (DTS_3F, DTS_DOLBY):
+ case CONVERT (DCA_3F, DCA_STEREO):
+ case CONVERT (DCA_3F, DCA_DOLBY):
mix_3to2:
mix3to2 (samples, bias);
break;
- case CONVERT (DTS_2F1R, DTS_STEREO):
+ case CONVERT (DCA_2F1R, DCA_STEREO):
if (slev == 0)
break;
mix21to2 (samples, samples + 256, bias);
break;
- case CONVERT (DTS_2F1R, DTS_DOLBY):
+ case CONVERT (DCA_2F1R, DCA_DOLBY):
mix21toS (samples, bias);
break;
- case CONVERT (DTS_3F1R, DTS_STEREO):
+ case CONVERT (DCA_3F1R, DCA_STEREO):
if (slev == 0)
goto mix_3to2;
mix31to2 (samples, bias);
break;
- case CONVERT (DTS_3F1R, DTS_DOLBY):
+ case CONVERT (DCA_3F1R, DCA_DOLBY):
mix31toS (samples, bias);
break;
- case CONVERT (DTS_2F2R, DTS_STEREO):
+ case CONVERT (DCA_2F2R, DCA_STEREO):
if (slev == 0)
break;
mix2to1 (samples, samples + 512, bias);
mix2to1 (samples + 256, samples + 768, bias);
break;
- case CONVERT (DTS_2F2R, DTS_DOLBY):
+ case CONVERT (DCA_2F2R, DCA_DOLBY):
mix22toS (samples, bias);
break;
- case CONVERT (DTS_3F2R, DTS_STEREO):
+ case CONVERT (DCA_3F2R, DCA_STEREO):
if (slev == 0)
goto mix_3to2;
mix32to2 (samples, bias);
break;
- case CONVERT (DTS_3F2R, DTS_DOLBY):
+ case CONVERT (DCA_3F2R, DCA_DOLBY):
mix32toS (samples, bias);
break;
- case CONVERT (DTS_3F1R, DTS_3F):
+ case CONVERT (DCA_3F1R, DCA_3F):
if (slev == 0)
break;
mix21to2 (samples, samples + 512, bias);
break;
- case CONVERT (DTS_3F2R, DTS_3F):
+ case CONVERT (DCA_3F2R, DCA_3F):
if (slev == 0)
break;
mix2to1 (samples, samples + 768, bias);
mix2to1 (samples + 512, samples + 1024, bias);
break;
- case CONVERT (DTS_3F1R, DTS_2F1R):
+ case CONVERT (DCA_3F1R, DCA_2F1R):
mix3to2 (samples, bias);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
break;
- case CONVERT (DTS_2F2R, DTS_2F1R):
+ case CONVERT (DCA_2F2R, DCA_2F1R):
mix2to1 (samples + 512, samples + 768, bias);
break;
- case CONVERT (DTS_3F2R, DTS_2F1R):
+ case CONVERT (DCA_3F2R, DCA_2F1R):
mix3to2 (samples, bias);
move2to1 (samples + 768, samples + 512, bias);
break;
- case CONVERT (DTS_3F2R, DTS_3F1R):
+ case CONVERT (DCA_3F2R, DCA_3F1R):
mix2to1 (samples + 768, samples + 1024, bias);
break;
- case CONVERT (DTS_2F1R, DTS_2F2R):
+ case CONVERT (DCA_2F1R, DCA_2F2R):
memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
break;
- case CONVERT (DTS_3F1R, DTS_2F2R):
+ case CONVERT (DCA_3F1R, DCA_2F2R):
mix3to2 (samples, bias);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
break;
- case CONVERT (DTS_3F2R, DTS_2F2R):
+ case CONVERT (DCA_3F2R, DCA_2F2R):
mix3to2 (samples, bias);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
break;
- case CONVERT (DTS_3F1R, DTS_3F2R):
+ case CONVERT (DCA_3F1R, DCA_3F2R):
memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
break;
}
}
-void dts_upmix (sample_t * samples, int acmod, int output)
+void dca_upmix (sample_t * samples, int acmod, int output)
{
- switch (CONVERT (acmod, output & DTS_CHANNEL_MASK)) {
+ switch (CONVERT (acmod, output & DCA_CHANNEL_MASK)) {
- case CONVERT (DTS_3F2R, DTS_MONO):
+ case CONVERT (DCA_3F2R, DCA_MONO):
zero (samples + 1024);
- case CONVERT (DTS_3F1R, DTS_MONO):
- case CONVERT (DTS_2F2R, DTS_MONO):
+ case CONVERT (DCA_3F1R, DCA_MONO):
+ case CONVERT (DCA_2F2R, DCA_MONO):
zero (samples + 768);
- case CONVERT (DTS_3F, DTS_MONO):
- case CONVERT (DTS_2F1R, DTS_MONO):
+ case CONVERT (DCA_3F, DCA_MONO):
+ case CONVERT (DCA_2F1R, DCA_MONO):
zero (samples + 512);
- case CONVERT (DTS_CHANNEL, DTS_MONO):
- case CONVERT (DTS_STEREO, DTS_MONO):
+ case CONVERT (DCA_CHANNEL, DCA_MONO):
+ case CONVERT (DCA_STEREO, DCA_MONO):
zero (samples + 256);
break;
- case CONVERT (DTS_3F2R, DTS_STEREO):
- case CONVERT (DTS_3F2R, DTS_DOLBY):
+ case CONVERT (DCA_3F2R, DCA_STEREO):
+ case CONVERT (DCA_3F2R, DCA_DOLBY):
zero (samples + 1024);
- case CONVERT (DTS_3F1R, DTS_STEREO):
- case CONVERT (DTS_3F1R, DTS_DOLBY):
+ case CONVERT (DCA_3F1R, DCA_STEREO):
+ case CONVERT (DCA_3F1R, DCA_DOLBY):
zero (samples + 768);
- case CONVERT (DTS_3F, DTS_STEREO):
- case CONVERT (DTS_3F, DTS_DOLBY):
+ case CONVERT (DCA_3F, DCA_STEREO):
+ case CONVERT (DCA_3F, DCA_DOLBY):
mix_3to2:
memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
zero (samples + 256);
break;
- case CONVERT (DTS_2F2R, DTS_STEREO):
- case CONVERT (DTS_2F2R, DTS_DOLBY):
+ case CONVERT (DCA_2F2R, DCA_STEREO):
+ case CONVERT (DCA_2F2R, DCA_DOLBY):
zero (samples + 768);
- case CONVERT (DTS_2F1R, DTS_STEREO):
- case CONVERT (DTS_2F1R, DTS_DOLBY):
+ case CONVERT (DCA_2F1R, DCA_STEREO):
+ case CONVERT (DCA_2F1R, DCA_DOLBY):
zero (samples + 512);
break;
- case CONVERT (DTS_3F2R, DTS_3F):
+ case CONVERT (DCA_3F2R, DCA_3F):
zero (samples + 1024);
- case CONVERT (DTS_3F1R, DTS_3F):
- case CONVERT (DTS_2F2R, DTS_2F1R):
+ case CONVERT (DCA_3F1R, DCA_3F):
+ case CONVERT (DCA_2F2R, DCA_2F1R):
zero (samples + 768);
break;
- case CONVERT (DTS_3F2R, DTS_3F1R):
+ case CONVERT (DCA_3F2R, DCA_3F1R):
zero (samples + 1024);
break;
- case CONVERT (DTS_3F2R, DTS_2F1R):
+ case CONVERT (DCA_3F2R, DCA_2F1R):
zero (samples + 1024);
- case CONVERT (DTS_3F1R, DTS_2F1R):
+ case CONVERT (DCA_3F1R, DCA_2F1R):
mix_31to21:
memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
goto mix_3to2;
- case CONVERT (DTS_3F2R, DTS_2F2R):
+ case CONVERT (DCA_3F2R, DCA_2F2R):
memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
goto mix_31to21;
}
diff --git a/contrib/libdca/include/dca.h b/contrib/libdca/include/dca.h
new file mode 100644
index 000000000..00b837393
--- /dev/null
+++ b/contrib/libdca/include/dca.h
@@ -0,0 +1,86 @@
+/*
+ * dca.h
+ * Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
+ *
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
+ *
+ * libdca 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.
+ *
+ * libdca 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.
+ */
+
+#ifndef LIBDCA_DCA_H
+#define LIBDCA_DCA_H
+
+/* x86 accelerations */
+#define MM_ACCEL_X86_MMX 0x80000000
+#define MM_ACCEL_X86_3DNOW 0x40000000
+#define MM_ACCEL_X86_MMXEXT 0x20000000
+
+uint32_t mm_accel (void);
+
+#if defined(LIBDCA_FIXED)
+typedef int32_t sample_t;
+typedef int32_t level_t;
+#elif defined(LIBDCA_DOUBLE)
+typedef double sample_t;
+typedef double level_t;
+#else
+typedef float sample_t;
+typedef float level_t;
+#endif
+
+typedef struct dca_state_s dca_state_t;
+
+#define DCA_MONO 0
+#define DCA_CHANNEL 1
+#define DCA_STEREO 2
+#define DCA_STEREO_SUMDIFF 3
+#define DCA_STEREO_TOTAL 4
+#define DCA_3F 5
+#define DCA_2F1R 6
+#define DCA_3F1R 7
+#define DCA_2F2R 8
+#define DCA_3F2R 9
+#define DCA_4F2R 10
+
+#define DCA_DOLBY 101 /* FIXME */
+
+#define DCA_CHANNEL_MAX DCA_3F2R /* We don't handle anything above that */
+#define DCA_CHANNEL_BITS 6
+#define DCA_CHANNEL_MASK 0x3F
+
+#define DCA_LFE 0x80
+#define DCA_ADJUST_LEVEL 0x100
+
+dca_state_t * dca_init (uint32_t mm_accel);
+
+int dca_syncinfo (dca_state_t *state, uint8_t * buf, int * flags,
+ int * sample_rate, int * bit_rate, int *frame_length);
+
+int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
+ level_t * level, sample_t bias);
+
+void dca_dynrng (dca_state_t * state,
+ level_t (* call) (level_t, void *), void * data);
+
+int dca_blocks_num (dca_state_t * state);
+int dca_block (dca_state_t * state);
+
+sample_t * dca_samples (dca_state_t * state);
+
+void dca_free (dca_state_t * state);
+
+#endif /* LIBDCA_DCA_H */
diff --git a/contrib/libdca/include/dts.h b/contrib/libdca/include/dts.h
new file mode 100644
index 000000000..e6dc8b137
--- /dev/null
+++ b/contrib/libdca/include/dts.h
@@ -0,0 +1,55 @@
+/*
+ * dts.h
+ * Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
+ *
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
+ *
+ * libdca 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.
+ *
+ * libdca 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.
+ */
+
+#ifndef LIBDCA_COMPAT_H
+# define LIBDCA_COMPAT_H 1
+# include <dca.h>
+
+typedef struct dca_state_s dts_state_t;
+# define DTS_MONO DCA_MONO
+# define DTS_CHANNEL DCA_CHANNEL
+# define DTS_STEREO DCA_STEREO
+# define DTS_STEREO_SUMDIFF DCA_STEREO_SUMDIFF
+# define DTS_STEREO_TOTAL DCA_STEREO_TOTAL
+# define DTS_3F DCA_3F
+# define DTS_2F1R DCA_2F1R
+# define DTS_3F1R DCA_3F1R
+# define DTS_2F2R DCA_2F2R
+# define DTS_3F2R DCA_3F2R
+# define DTS_4F2R DCA_4F2R
+# define DTS_DOLBY DCA_DOLBY
+# define DTS_CHANNEL_MAX DCA_CHANNEL_MAX
+# define DTS_CHANNEL_BITS DCA_CHANNEL_BITS
+# define DTS_CHANNEL_MASK DCA_CHANNEL_MASK
+# define DTS_LFE DCA_LFE
+# define DTS_ADJUST_LEVEL DCA_ADJUST_LEVEL
+
+# define dts_init dca_init
+# define dts_syncinfo dca_syncinfo
+# define dts_frame dca_frame
+# define dts_dynrng dca_dynrng
+# define dts_blocks_num dca_blocks_num
+# define dts_block dca_block
+# define dts_samples dca_samples
+# define dts_free dca_free
+#endif
diff --git a/src/libdts/parse.c b/contrib/libdca/parse.c
index 3806a5594..5a0c95f17 100644
--- a/src/libdts/parse.c
+++ b/contrib/libdca/parse.c
@@ -2,22 +2,23 @@
* parse.c
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
@@ -34,8 +35,8 @@
#define M_PI 3.1415926535897932384626433832795029
#endif
-#include "dts.h"
-#include "dts_internal.h"
+#include "dca.h"
+#include "dca_internal.h"
#include "bitstream.h"
#include "tables.h"
@@ -45,7 +46,7 @@
#include "tables_fir.h"
#include "tables_vq.h"
-/* #define LOG_DEBUG */
+/* #define DEBUG */
#if defined(HAVE_MEMALIGN) && !defined(__cplusplus)
/* some systems have memalign() but no declaration for it */
@@ -57,7 +58,7 @@ void * memalign (size_t align, size_t size);
static int decode_blockcode (int code, int levels, int *values);
-static void qmf_32_subbands (dts_state_t * state, int chans,
+static void qmf_32_subbands (dca_state_t * state, int chans,
double samples_in[32][8], sample_t *samples_out,
double rScale, sample_t bias);
@@ -65,18 +66,19 @@ static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
double *samples_in, sample_t *samples_out,
double rScale, sample_t bias );
-static void pre_calc_cosmod( dts_state_t * state );
+static void pre_calc_cosmod( dca_state_t * state );
-dts_state_t * dts_init (uint32_t mm_accel)
+dca_state_t * dca_init (uint32_t mm_accel)
{
- dts_state_t * state;
+ dca_state_t * state;
int i;
- state = (dts_state_t *) malloc (sizeof (dts_state_t));
+ (void)mm_accel;
+ state = (dca_state_t *) malloc (sizeof (dca_state_t));
if (state == NULL)
return NULL;
- memset (state, 0, sizeof(dts_state_t));
+ memset (state, 0, sizeof(dca_state_t));
state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t));
if (state->samples == NULL) {
@@ -95,18 +97,18 @@ dts_state_t * dts_init (uint32_t mm_accel)
return state;
}
-sample_t * dts_samples (dts_state_t * state)
+sample_t * dca_samples (dca_state_t * state)
{
return state->samples;
}
-int dts_blocks_num (dts_state_t * state)
+int dca_blocks_num (dca_state_t * state)
{
/* 8 samples per subsubframe and per subband */
return state->sample_blocks / 8;
}
-static int syncinfo (dts_state_t * state, int * flags,
+static int syncinfo (dca_state_t * state, int * flags,
int * sample_rate, int * bit_rate, int * frame_length)
{
int frame_size;
@@ -130,25 +132,25 @@ static int syncinfo (dts_state_t * state, int * flags,
return 0;
*sample_rate = bitstream_get (state, 4);
- if (*sample_rate >= sizeof (dts_sample_rates) / sizeof (int))
+ if ((size_t)*sample_rate >= sizeof (dca_sample_rates) / sizeof (int))
return 0;
- *sample_rate = dts_sample_rates[ *sample_rate ];
+ *sample_rate = dca_sample_rates[ *sample_rate ];
if (!*sample_rate) return 0;
*bit_rate = bitstream_get (state, 5);
- if (*bit_rate >= sizeof (dts_bit_rates) / sizeof (int))
+ if ((size_t)*bit_rate >= sizeof (dca_bit_rates) / sizeof (int))
return 0;
- *bit_rate = dts_bit_rates[ *bit_rate ];
+ *bit_rate = dca_bit_rates[ *bit_rate ];
if (!*bit_rate) return 0;
/* LFE */
bitstream_get (state, 10);
- if (bitstream_get (state, 2)) *flags |= DTS_LFE;
+ if (bitstream_get (state, 2)) *flags |= DCA_LFE;
return frame_size;
}
-int dts_syncinfo (dts_state_t * state, uint8_t * buf, int * flags,
+int dca_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate, int * frame_length)
{
/*
@@ -161,7 +163,7 @@ int dts_syncinfo (dts_state_t * state, uint8_t * buf, int * flags,
(buf[4] & 0xf0) == 0xf0 && buf[5] == 0x07)
{
int frame_size;
- dts_bitstream_init (state, buf, 0, 0);
+ dca_bitstream_init (state, buf, 0, 0);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
@@ -173,7 +175,7 @@ int dts_syncinfo (dts_state_t * state, uint8_t * buf, int * flags,
buf[4] == 0x07 && (buf[5] & 0xf0) == 0xf0)
{
int frame_size;
- dts_bitstream_init (state, buf, 0, 1);
+ dca_bitstream_init (state, buf, 0, 1);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
@@ -184,7 +186,7 @@ int dts_syncinfo (dts_state_t * state, uint8_t * buf, int * flags,
buf[2] == 0x01 && buf[3] == 0x80)
{
int frame_size;
- dts_bitstream_init (state, buf, 1, 0);
+ dca_bitstream_init (state, buf, 1, 0);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
@@ -195,7 +197,7 @@ int dts_syncinfo (dts_state_t * state, uint8_t * buf, int * flags,
buf[2] == 0x80 && buf[3] == 0x01)
{
int frame_size;
- dts_bitstream_init (state, buf, 1, 1);
+ dca_bitstream_init (state, buf, 1, 1);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
@@ -204,13 +206,13 @@ int dts_syncinfo (dts_state_t * state, uint8_t * buf, int * flags,
return 0;
}
-int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
+int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
level_t * level, sample_t bias)
{
int i, j;
static float adj_table[] = { 1.0, 1.1250, 1.2500, 1.4375 };
- dts_bitstream_init (state, buf, state->word_mode, state->bigendian_mode);
+ dca_bitstream_init (state, buf, state->word_mode, state->bigendian_mode);
/* Sync code */
bitstream_get (state, 32);
@@ -249,13 +251,13 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
/* FIME: channels mixing levels */
state->clev = state->slev = 1;
- state->output = dts_downmix_init (state->amode, *flags, level,
+ state->output = dca_downmix_init (state->amode, *flags, level,
state->clev, state->slev);
if (state->output < 0)
return 1;
- if (state->lfe && (*flags & DTS_LFE))
- state->output |= DTS_LFE;
+ if (state->lfe && (*flags & DCA_LFE))
+ state->output |= DCA_LFE;
*flags = state->output;
@@ -264,7 +266,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
state->dynrnge = 1;
state->dynrngcall = NULL;
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "frame type: %i\n", state->frame_type);
fprintf (stderr, "samples deficit: %i\n", state->samples_deficit);
fprintf (stderr, "crc present: %i\n", state->crc_present);
@@ -272,11 +274,11 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
state->sample_blocks, state->sample_blocks * 32);
fprintf (stderr, "frame size: %i bytes\n", state->frame_size);
fprintf (stderr, "amode: %i (%i channels)\n",
- state->amode, dts_channels[state->amode]);
+ state->amode, dca_channels[state->amode]);
fprintf (stderr, "sample rate: %i (%i Hz)\n",
- state->sample_rate, dts_sample_rates[state->sample_rate]);
+ state->sample_rate, dca_sample_rates[state->sample_rate]);
fprintf (stderr, "bit rate: %i (%i bits/s)\n",
- state->bit_rate, dts_bit_rates[state->bit_rate]);
+ state->bit_rate, dca_bit_rates[state->bit_rate]);
fprintf (stderr, "downmix: %i\n", state->downmix);
fprintf (stderr, "dynrange: %i\n", state->dynrange);
fprintf (stderr, "timestamp: %i\n", state->timestamp);
@@ -293,7 +295,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
fprintf (stderr, "copy history: %i\n", state->copy_history);
fprintf (stderr, "source pcm resolution: %i (%i bits/sample)\n",
state->source_pcm_res,
- dts_bits_per_sample[state->source_pcm_res]);
+ dca_bits_per_sample[state->source_pcm_res]);
fprintf (stderr, "front sum: %i\n", state->front_sum);
fprintf (stderr, "surround sum: %i\n", state->surround_sum);
fprintf (stderr, "dialog norm: %i\n", state->dialog_norm);
@@ -304,7 +306,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
state->subframes = bitstream_get (state, 4) + 1;
state->prim_channels = bitstream_get (state, 3) + 1;
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "subframes: %i\n", state->subframes);
fprintf (stderr, "prim channels: %i\n", state->prim_channels);
#endif
@@ -312,25 +314,25 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
for (i = 0; i < state->prim_channels; i++)
{
state->subband_activity[i] = bitstream_get (state, 5) + 2;
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "subband activity: %i\n", state->subband_activity[i]);
#endif
- if (state->subband_activity[i] > DTS_SUBBANDS)
- state->subband_activity[i] = DTS_SUBBANDS;
+ if (state->subband_activity[i] > DCA_SUBBANDS)
+ state->subband_activity[i] = DCA_SUBBANDS;
}
for (i = 0; i < state->prim_channels; i++)
{
state->vq_start_subband[i] = bitstream_get (state, 5) + 1;
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "vq start subband: %i\n", state->vq_start_subband[i]);
#endif
- if (state->vq_start_subband[i] > DTS_SUBBANDS)
- state->vq_start_subband[i] = DTS_SUBBANDS;
+ if (state->vq_start_subband[i] > DCA_SUBBANDS)
+ state->vq_start_subband[i] = DCA_SUBBANDS;
}
for (i = 0; i < state->prim_channels; i++)
{
state->joint_intensity[i] = bitstream_get (state, 3);
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "joint intensity: %i\n", state->joint_intensity[i]);
if (state->joint_intensity[i]) {fprintf (stderr, "JOINTINTENSITY\n");}
#endif
@@ -338,7 +340,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
for (i = 0; i < state->prim_channels; i++)
{
state->transient_huffman[i] = bitstream_get (state, 2);
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "transient mode codebook: %i\n",
state->transient_huffman[i]);
#endif
@@ -346,7 +348,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
for (i = 0; i < state->prim_channels; i++)
{
state->scalefactor_huffman[i] = bitstream_get (state, 3);
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "scale factor codebook: %i\n",
state->scalefactor_huffman[i]);
#endif
@@ -355,7 +357,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
{
state->bitalloc_huffman[i] = bitstream_get (state, 3);
/* if (state->bitalloc_huffman[i] == 7) bailout */
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "bit allocation quantizer: %i\n",
state->bitalloc_huffman[i]);
#endif
@@ -377,7 +379,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
for (i = 0; i < state->prim_channels; i++)
state->quant_index_huffman[i][j] = 0; /* Not transmitted */
-#ifdef LOG_DEBUG
+#ifdef DEBUG
for (i = 0; i < state->prim_channels; i++)
{
fprintf( stderr, "quant index huff:" );
@@ -418,7 +420,7 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
adj_table[bitstream_get (state, 2)];
}
-#ifdef LOG_DEBUG
+#ifdef DEBUG
for (i = 0; i < state->prim_channels; i++)
{
fprintf (stderr, "scalefac adj:");
@@ -440,20 +442,20 @@ int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
return 0;
}
-static int dts_subframe_header (dts_state_t * state)
+static int dca_subframe_header (dca_state_t * state)
{
/* Primary audio coding side information */
int j, k;
/* Subsubframe count */
state->subsubframes = bitstream_get (state, 2) + 1;
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "subsubframes: %i\n", state->subsubframes);
#endif
/* Partial subsubframe sample count */
state->partial_samples = bitstream_get (state, 3);
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "partial samples: %i\n", state->partial_samples);
#endif
@@ -462,7 +464,7 @@ static int dts_subframe_header (dts_state_t * state)
{
for (k = 0; k < state->subband_activity[j]; k++)
state->prediction_mode[j][k] = bitstream_get (state, 1);
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "prediction mode:");
for (k = 0; k < state->subband_activity[j]; k++)
fprintf (stderr, " %i", state->prediction_mode[j][k]);
@@ -479,7 +481,7 @@ static int dts_subframe_header (dts_state_t * state)
{
/* (Prediction coefficient VQ address) */
state->prediction_vq[j][k] = bitstream_get (state, 12);
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "prediction coefs: %f, %f, %f, %f\n",
(double)adpcm_vb[state->prediction_vq[j][k]][0]/8192,
(double)adpcm_vb[state->prediction_vq[j][k]][1]/8192,
@@ -513,7 +515,7 @@ static int dts_subframe_header (dts_state_t * state)
}
}
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "bitalloc index: ");
for (k = 0; k < state->vq_start_subband[j]; k++)
fprintf (stderr, "%2.2i ", state->bitalloc[j][k]);
@@ -535,7 +537,7 @@ static int dts_subframe_header (dts_state_t * state)
tmode[state->transient_huffman[j]]);
}
}
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "Transition mode:");
for (k = 0; k < state->subband_activity[j]; k++)
fprintf (stderr, " %i", state->transition_mode[j][k]);
@@ -607,7 +609,7 @@ static int dts_subframe_header (dts_state_t * state)
}
}
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "Scale factor:");
for (k = 0; k < state->subband_activity[j]; k++)
{
@@ -670,7 +672,7 @@ static int dts_subframe_header (dts_state_t * state)
state->debug_flag |= 0x02;
}
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "Joint scale factor index:\n");
for (k = state->subband_activity[j];
k < state->subband_activity[source_channel]; k++)
@@ -712,7 +714,7 @@ static int dts_subframe_header (dts_state_t * state)
/* 1 vector -> 32 samples */
state->high_freq_vq[j][k] = bitstream_get (state, 10);
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf( stderr, "VQ index: %i\n", state->high_freq_vq[j][k] );
#endif
}
@@ -742,7 +744,7 @@ static int dts_subframe_header (dts_state_t * state)
for (j = lfe_samples; j < lfe_samples * 2; j++)
state->lfe_data[j] *= lfe_scale;
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf (stderr, "LFE samples:\n");
for (j = lfe_samples; j < lfe_samples * 2; j++)
fprintf (stderr, " %f", state->lfe_data[j]);
@@ -754,7 +756,7 @@ static int dts_subframe_header (dts_state_t * state)
return 0;
}
-static int dts_subsubframe (dts_state_t * state)
+static int dca_subsubframe (dca_state_t * state)
{
int k, l;
int subsubframe = state->current_subsubframe;
@@ -762,7 +764,7 @@ static int dts_subsubframe (dts_state_t * state)
double *quant_step_table;
/* FIXME */
- double subband_samples[DTS_PRIM_CHANNELS_MAX][DTS_SUBBANDS][8];
+ double subband_samples[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8];
/*
* Audio data
@@ -954,7 +956,7 @@ static int dts_subsubframe (dts_state_t * state)
{
if (0xFFFF == bitstream_get (state, 16)) /* 0xFFFF */
{
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf( stderr, "Got subframe DSYNC\n" );
#endif
}
@@ -990,21 +992,21 @@ static int dts_subsubframe (dts_state_t * state)
}
/* Down/Up mixing */
- if (state->prim_channels < dts_channels[state->output & DTS_CHANNEL_MASK])
+ if (state->prim_channels < dca_channels[state->output & DCA_CHANNEL_MASK])
{
- dts_upmix (state->samples, state->amode, state->output);
+ dca_upmix (state->samples, state->amode, state->output);
} else
- if (state->prim_channels > dts_channels[state->output & DTS_CHANNEL_MASK])
+ if (state->prim_channels > dca_channels[state->output & DCA_CHANNEL_MASK])
{
- dts_downmix (state->samples, state->amode, state->output, state->bias,
+ dca_downmix (state->samples, state->amode, state->output, state->bias,
state->clev, state->slev);
}
/* Generate LFE samples for this subsubframe FIXME!!! */
- if (state->output & DTS_LFE)
+ if (state->output & DCA_LFE)
{
int lfe_samples = 2 * state->lfe * state->subsubframes;
- int i_channels = dts_channels[state->output & DTS_CHANNEL_MASK];
+ int i_channels = dca_channels[state->output & DCA_CHANNEL_MASK];
lfe_interpolation_fir (state->lfe, 2 * state->lfe,
state->lfe_data + lfe_samples +
@@ -1017,7 +1019,7 @@ static int dts_subsubframe (dts_state_t * state)
return 0;
}
-static int dts_subframe_footer (dts_state_t * state)
+static int dca_subframe_footer (dca_state_t * state)
{
int aux_data_count = 0, i;
int lfe_samples;
@@ -1047,14 +1049,14 @@ static int dts_subframe_footer (dts_state_t * state)
state->lfe_data[i] = state->lfe_data[i+lfe_samples];
}
-#ifdef LOG_DEBUG
+#ifdef DEBUG
fprintf( stderr, "\n" );
#endif
return 0;
}
-int dts_block (dts_state_t * state)
+int dca_block (dca_state_t * state)
{
/* Sanity check */
if (state->current_subframe >= state->subframes)
@@ -1066,18 +1068,18 @@ int dts_block (dts_state_t * state)
if (!state->current_subsubframe)
{
-#ifdef LOG_DEBUG
- fprintf (stderr, "DSYNC dts_subframe_header\n");
+#ifdef DEBUG
+ fprintf (stderr, "DSYNC dca_subframe_header\n");
#endif
/* Read subframe header */
- if (dts_subframe_header (state)) return -1;
+ if (dca_subframe_header (state)) return -1;
}
/* Read subsubframe */
-#ifdef LOG_DEBUG
- fprintf (stderr, "DSYNC dts_subsubframe\n");
+#ifdef DEBUG
+ fprintf (stderr, "DSYNC dca_subsubframe\n");
#endif
- if (dts_subsubframe (state)) return -1;
+ if (dca_subsubframe (state)) return -1;
/* Update state */
state->current_subsubframe++;
@@ -1088,11 +1090,11 @@ int dts_block (dts_state_t * state)
}
if (state->current_subframe >= state->subframes)
{
-#ifdef LOG_DEBUG
- fprintf(stderr, "DSYNC dts_subframe_footer\n");
+#ifdef DEBUG
+ fprintf(stderr, "DSYNC dca_subframe_footer\n");
#endif
/* Read subframe footer */
- if (dts_subframe_footer (state)) return -1;
+ if (dca_subframe_footer (state)) return -1;
}
return 0;
@@ -1120,7 +1122,7 @@ int decode_blockcode( int code, int levels, int *values )
}
}
-static void pre_calc_cosmod( dts_state_t * state )
+static void pre_calc_cosmod( dca_state_t * state )
{
int i, j, k;
@@ -1139,7 +1141,7 @@ static void pre_calc_cosmod( dts_state_t * state )
state->cos_mod[j++] = -0.25/(2.0*sin((2*k+1)*M_PI/128));
}
-static void qmf_32_subbands (dts_state_t * state, int chans,
+static void qmf_32_subbands (dca_state_t * state, int chans,
double samples_in[32][8], sample_t *samples_out,
double scale, sample_t bias)
{
@@ -1272,7 +1274,7 @@ static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
}
}
-void dts_dynrng (dts_state_t * state,
+void dca_dynrng (dca_state_t * state,
level_t (* call) (level_t, void *), void * data)
{
state->dynrange = 0;
@@ -1283,7 +1285,7 @@ void dts_dynrng (dts_state_t * state,
}
}
-void dts_free (dts_state_t * state)
+void dca_free (dca_state_t * state)
{
free (state->samples);
free (state);
diff --git a/src/libdts/tables.h b/contrib/libdca/tables.h
index 73d109ea3..ca336cf29 100644
--- a/src/libdts/tables.h
+++ b/contrib/libdca/tables.h
@@ -2,31 +2,32 @@
* tables.h
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-static const int dts_sample_rates[] =
+static const int dca_sample_rates[] =
{
0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
12000, 24000, 48000, 96000, 192000
};
-static const int dts_bit_rates[] =
+static const int dca_bit_rates[] =
{
32000, 56000, 64000, 96000, 112000, 128000,
192000, 224000, 256000, 320000, 384000,
@@ -36,12 +37,12 @@ static const int dts_bit_rates[] =
2048000, 3072000, 3840000, 1/*open*/, 2/*variable*/, 3/*lossless*/
};
-static const uint8_t dts_channels[] =
+static const uint8_t dca_channels[] =
{
1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8
};
-static const uint8_t dts_bits_per_sample[] =
+static const uint8_t dca_bits_per_sample[] =
{
16, 16, 20, 20, 0, 24, 24
};
diff --git a/src/libdts/tables_adpcm.h b/contrib/libdca/tables_adpcm.h
index 0c63a6020..c19378dab 100644
--- a/src/libdts/tables_adpcm.h
+++ b/contrib/libdca/tables_adpcm.h
@@ -2,22 +2,23 @@
* tables_adpcm.h
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* 16bits signed fractional Q13 binary codes */
diff --git a/src/libdts/tables_fir.h b/contrib/libdca/tables_fir.h
index 892a93204..a127fee6f 100644
--- a/src/libdts/tables_fir.h
+++ b/contrib/libdca/tables_fir.h
@@ -2,22 +2,23 @@
* fir.h
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
double fir_32bands_perfect[] =
diff --git a/src/libdts/tables_huffman.h b/contrib/libdca/tables_huffman.h
index 6690d356c..abe4c138c 100644
--- a/src/libdts/tables_huffman.h
+++ b/contrib/libdca/tables_huffman.h
@@ -2,23 +2,25 @@
* huffman_tables.h
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
typedef struct huff_entry_s
{
int length;
@@ -1045,7 +1047,7 @@ huff_entry_t *bitalloc_select[11][8] =
bitalloc_e_129, bitalloc_f_129, bitalloc_g_129, 0 },
};
-static int InverseQ( dts_state_t * state, huff_entry_t * huff )
+static int InverseQ( dca_state_t * state, huff_entry_t * huff )
{
int value = 0;
int length = 0, j;
diff --git a/src/libdts/tables_quantization.h b/contrib/libdca/tables_quantization.h
index 904b1014e..4dc3cd0fe 100644
--- a/src/libdts/tables_quantization.h
+++ b/contrib/libdca/tables_quantization.h
@@ -2,22 +2,23 @@
* tables_quantization.h
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
int scale_factor_quant6[] =
diff --git a/src/libdts/tables_vq.h b/contrib/libdca/tables_vq.h
index eae1ed94c..2aafd762c 100644
--- a/src/libdts/tables_vq.h
+++ b/contrib/libdca/tables_vq.h
@@ -2,22 +2,23 @@
* tables_vq.h
* Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
*
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
+ * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
+ * See http://www.videolan.org/developers/libdca.html for updates.
*
- * dtsdec is free software; you can redistribute it and/or modify
+ * libdca 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.
*
- * dtsdec is distributed in the hope that it will be useful,
+ * libdca 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
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* 8bits signed fractional Q4 binary codes */
diff --git a/src/libdts/Makefile.am b/src/libdts/Makefile.am
index ea09aab2e..c142d3945 100644
--- a/src/libdts/Makefile.am
+++ b/src/libdts/Makefile.am
@@ -4,25 +4,13 @@ if DTS
dts_module = xineplug_decode_dts.la
endif
-xineplug_LTLIBRARIES = $(dts_module)
+$(top_builddir)/contrib/libdca/libdca.la:
+ $(MAKE) -C $(top_builddir)/contrib/libdca
-if EXTERNAL_LIBDTS
-fnsa =
-internal_sources =
-else
-fnsa = -fno-strict-aliasing
-internal_sources = bitstream.c downmix.c parse.c
-endif
+xineplug_LTLIBRARIES = $(dts_module)
-xineplug_decode_dts_la_SOURCES = xine_dts_decoder.c $(internal_sources)
-xineplug_decode_dts_la_CFLAGS = $(LIBDTS_CFLAGS) $(VISIBILITY_FLAG) $(fnsa)
+xineplug_decode_dts_la_SOURCES = xine_dts_decoder.c
+xineplug_decode_dts_la_CFLAGS = $(LIBDTS_CFLAGS) $(VISIBILITY_FLAG)
+xineplug_decode_dts_la_DEPENDENCIES = $(LIBDTS_DEPS)
+xineplug_decode_dts_la_LIBADD = $(XINE_LIB) $(LIBDTS_LIBS)
xineplug_decode_dts_la_LDFLAGS = $(xineplug_ldflags)
-
-if EXTERNAL_LIBDTS
-xineplug_decode_dts_la_LIBADD = $(XINE_LIB) $(LIBDTS_LIBS) -lm
-else
-xineplug_decode_dts_la_LIBADD = $(XINE_LIB) -lm
-endif
-
-noinst_HEADERS = bitstream.h internal-dts.h dts_internal.h tables.h tables_adpcm.h \
- tables_fir.h tables_huffman.h tables_quantization.h tables_vq.h
diff --git a/src/libdts/internal-dts.h b/src/libdts/internal-dts.h
deleted file mode 100644
index 30f3a197b..000000000
--- a/src/libdts/internal-dts.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * dts.h
- * Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
- *
- * This file is part of dtsdec, a free DTS Coherent Acoustics stream decoder.
- * See http://www.videolan.org/dtsdec.html for updates.
- *
- * dtsdec 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.
- *
- * dtsdec 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
- */
-
-#ifndef DTS_H
-#define DTS_H
-
-/* x86 accelerations */
-#define MM_ACCEL_X86_MMX 0x80000000
-#define MM_ACCEL_X86_3DNOW 0x40000000
-#define MM_ACCEL_X86_MMXEXT 0x20000000
-
-uint32_t mm_accel (void);
-
-#if defined(LIBDTS_FIXED)
-typedef int32_t sample_t;
-typedef int32_t level_t;
-#elif defined(LIBDTS_DOUBLE)
-typedef double sample_t;
-typedef double level_t;
-#else
-typedef float sample_t;
-typedef float level_t;
-#endif
-
-typedef struct dts_state_s dts_state_t;
-
-#define DTS_MONO 0
-#define DTS_CHANNEL 1
-#define DTS_STEREO 2
-#define DTS_STEREO_SUMDIFF 3
-#define DTS_STEREO_TOTAL 4
-#define DTS_3F 5
-#define DTS_2F1R 6
-#define DTS_3F1R 7
-#define DTS_2F2R 8
-#define DTS_3F2R 9
-#define DTS_4F2R 10
-
-#define DTS_DOLBY 101 /* FIXME */
-
-#define DTS_CHANNEL_MAX DTS_3F2R /* We don't handle anything above that */
-#define DTS_CHANNEL_BITS 6
-#define DTS_CHANNEL_MASK 0x3F
-
-#define DTS_LFE 0x80
-#define DTS_ADJUST_LEVEL 0x100
-
-dts_state_t * dts_init (uint32_t mm_accel);
-
-int dts_syncinfo (dts_state_t *state, uint8_t * buf, int * flags,
- int * sample_rate, int * bit_rate, int *frame_length);
-
-int dts_frame (dts_state_t * state, uint8_t * buf, int * flags,
- level_t * level, sample_t bias);
-
-void dts_dynrng (dts_state_t * state,
- level_t (* call) (level_t, void *), void * data);
-
-int dts_blocks_num (dts_state_t * state);
-int dts_block (dts_state_t * state);
-
-sample_t * dts_samples (dts_state_t * state);
-
-void dts_free (dts_state_t * state);
-
-#endif /* DTS_H */
diff --git a/src/libdts/xine_dts_decoder.c b/src/libdts/xine_dts_decoder.c
index 0ef9afa17..920672cf9 100644
--- a/src/libdts/xine_dts_decoder.c
+++ b/src/libdts/xine_dts_decoder.c
@@ -50,11 +50,7 @@
#include "audio_out.h"
#include "buffer.h"
-#ifdef HAVE_DTS_H
-# include <dts.h>
-#else
-# include "internal-dts.h"
-#endif
+#include <dts.h>
#define MAX_AC5_FRAME 4096