pax_global_header00006660000000000000000000000064135515731430014521gustar00rootroot0000000000000052 comment=78d8e0141600ac006a94ac6fd5601f599fa5b65b faac-1_30/000077500000000000000000000000001355157314300124175ustar00rootroot00000000000000faac-1_30/.gitignore000066400000000000000000000005711355157314300144120ustar00rootroot00000000000000*.o *.so *.a *.ncb *.plg *.aps *.opt *.aac *.wav *.mp4 *.m4a *.lo Makefile* *.deps *.libs *.la *~ /frontend/faac /aclocal.m4 /autom4te.cache /compile /config.guess /config.h /config.h.in /config.log /config.status /config.sub /configure /depcomp /install-sh /libtool /ltmain.sh /missing /stamp-h1 .vs/ /project/msvc/bin/ /project/msvc/intermediate/ *.user /libfaac/win32_ver.h faac-1_30/AUTHORS000066400000000000000000000024211355157314300134660ustar00rootroot00000000000000Currently maintained by knik . The following list contains the user names of all FAAC developers with their first appearance in the ChangeLog: 1999-12-13 lenox (Tony Lenox) 1999-12-13 menno 2000-02-07 oxygene2000/oxygene (?) 2000-02-22 thebard (wmilas@rarcoa.com) 2000-07-22 prkoat (?) 2001-03-18 xfhobbes (?) 2001-04-27 flyingfox (?) 2001-09-21 eraser (?) 2002-08-07 knik (Krzysztof Nikiel) 2003-08-02 stux (Stuart Espey) 2003-09-07 ca5e (Janne Hyvrinen) 2004-03-17 danchr (Dan Christiansen) 2004-07-04 corrados (Volker Fischer) 2012-04-08 arcen (Arcen@github) Furthermore there are other contributors from the SourceForge mailing list and trackers as well as from the web forum or via email whose patches were checked in by members of the FAAC project. Among them are Antonio Foranna (Winamp and CoolEdit plugins), Bill May, Stephen Shultz (sms00), Jordan Breeding, Brandon Forehand, Andrew Voznytsa, Mns Rullgrd, RageOMatic and Ivan Dimkovic. You can find their names and/or aliases in the ChangeLog most of the time. Question marks mean that neither the real name nor the email address is known. If you think your name should also be in this list or know who some of the early developers are, please email me: hans-juergen.bardenhagen@arcor.de faac-1_30/COPYING000066400000000000000000000613141355157314300134570ustar00rootroot00000000000000 GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, 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 library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, 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 companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Library 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! faac-1_30/ChangeLog000066400000000000000000000062211355157314300141720ustar00rootroot000000000000001.30 [ Robert Kausch ] * Fix Joint Stereo coding [ Krzysztof Nikiel ] * Code cleanup and compilation fixes * Fix endianness conversion functions [ Takashi Yoshi ] * Fix compilation with GCC < 4.6 * Fix compilation on big endian systems [ Fabian Greffrath ] * Fix division by zero errors * Fix compilation with GCC <= 4.7.3 * Change pointer type for proper arithmetics * Fix logic error in compiler detection * Revert back to some more generic SSE2 code * Fix a memory leak * Fix some cppcheck warnings in the Cfaac code * Check index ranges before dereferencing book arrays (CVE-2018-19886) * Clean up stdint.h header inclusions * Consistently use stdint.h types [ Michael Fink ] * Update Visual Studio 2017 projects * Add stdint.h header inclusions * Port over ac2ver tool from faad2 to generate PACKAGE_VERSION when compiling with Visual Studio [ Eugène Filin ] * Memory allocations redefined 1.29.9.2 * fixed max MP4 bitrate calculation 1.29.9: * initial version of PNS coding * Intensity Stereo coding * more speed improvements * finer bandwidth/cutoff setting (doesn't work with PNS) * fixed more bugs * rewritten mid/side coding * fixed bug in blockswitch 1.29.8 * changed default mode to ABR 64kbps/channel * implemented short windows grouping * new huffman coder * SSE quantizer * modified functioning of ABR mode (-b option) * improved autotools support * allowed even higher bitrates, including ADTS * framebuffer size bug fixed * removed broken object types: Main and LTP * some mp4 atoms fixed for better compalibility * stdin seek bug fixed 1.29.7 * quantizer tweaked to better support high bitrates * allow higher quality for mp4 files (-q 5000 max) * removed mid frequency boost (it turned out useless) * cutoff frequency adjusted to fully utilize upper band * --help-long option removed, it was just an alias for -H * -b option bug fixed 1.29.6: - quality related bug fixed 1.29.5: - updated manpage - check if output file exists; --overwrite option added - help/usage options reorganized - block switching is now tuned to match quality/bitrate - give more quality to lower frequancies (less to highs) - quantizer updated again 1.29.4: - rewritten quantizer: faster, diffrerent quality, different bitrates - ftyp atom: set brands like itunes does, shoud be more compatible with picky tools - new option(--tag) to add named tags (iTunes '----') - faster and better short/long window type switch - Don't build DRM(Digital Radio Mondiale) by default. Use ./configure --enable-drm to build DRM version. - fixed bugs * rounding in QuantizeReflectionCoeffs (tns.c) * use +60 value for scalefactor. * use clipped diff instead of original value (huffman.c) 1.29.3: - MP4 tag options improved - fixed MP4 'meta' atom bug - new option to set verbosity (-v0 to silence output) 1.29.2: - new mp4 output code 1.29: - various patches applied and bugs fixed 2009-02-02 - Version 1.28 * Prevent out of range scalefactors * Updated to latest mpeg4ip mp4 file format library * Added -s option to make the encoder output optimized mp4 layout * Improved JPEG detection for album art * Lot's of compilation issues solved faac-1_30/INSTALL000066400000000000000000000013651355157314300134550ustar00rootroot00000000000000___________________________________ General FAAC compiling instructions 1. Make sure you have recent versions of autoconf, automake and libtool installed. For MP4 writing and tagging support, you must enable compiling with internal libmp4v2 (included in /common/mp4v2/). 2. cd to FAAC source dir 3. Run: ./bootstrap ./configure make make install __________________________________ MS Windows FAAC build using Cygwin 1. Install Cygwin (http://cygwin.com/) (make sure to include autoconf, automake and libtool packages) 2. cd to FAAC source dir (folder) To install Cygwin binary follow general instructions. To install Mingw binary: 1. Run: ./bootstrap CC='gcc -mno-cygwin' ./configure make 2. Copy frontend/faac.exe to destination folder. faac-1_30/Makefile.am000066400000000000000000000000521355157314300144500ustar00rootroot00000000000000SUBDIRS = include libfaac common frontend faac-1_30/NEWS000066400000000000000000000003041355157314300131130ustar00rootroot000000000000002017: FAAC thread on hydrogenaudio: https://hydrogenaud.io/index.php/topic,114363.0.html FAAC mirrored on github: https://github.com/knik0/faac FAAC download page: http://faac.sourceforge.net/ faac-1_30/README000066400000000000000000000057271355157314300133120ustar00rootroot00000000000000__________ COPYRIGHTS FAAC is based on the ISO MPEG-4 reference code. For this base code the following license applies: ********************************************************************** This software module was originally developed by FirstName LastName (CompanyName) and edited by FirstName LastName (CompanyName) FirstName LastName (CompanyName) in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products. The original developer retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1997. ********************************************************************** For the changes made for the FAAC project the GNU Library General Public License (LGPL), version 2 1991 applies. For the changes the following statement applies: ********************************************************************** FAAC - Freeware Advanced Audio Coder Copyright (C) 2001 M. Bakker This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ********************************************************************** Please note that the use of this software may require the payment of patent royalties. You need to consider this issue before you start building derivative works. We are not warranting or indemnifying you in any way for patent royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!faac-1_30/TODO000066400000000000000000000004771355157314300131170ustar00rootroot00000000000000- fix scalefactor encoding check (-60 .. 60) - test DRM - optimize quantization bias - optimize codebook list (section_data) - optimize CPE windows grouping - Add bit reservoir control - Add resampler and downmixer (hans-juergen, Oct 17, 2004) - Add HE AAC (hans-juergen, Oct 17, 2004) - Test TNS(arcen, Apr 8th, 2012) faac-1_30/bootstrap000077500000000000000000000002451355157314300143630ustar00rootroot00000000000000#! /bin/sh aclocal -I . autoheader if test "`uname -s`" = Darwin; then glibtoolize --automake else libtoolize --automake fi automake --add-missing autoconf faac-1_30/common/000077500000000000000000000000001355157314300137075ustar00rootroot00000000000000faac-1_30/common/Cfaac/000077500000000000000000000000001355157314300147045ustar00rootroot00000000000000faac-1_30/common/Cfaac/AudioCoding.bmp000066400000000000000000001156561355157314300176070ustar00rootroot00000000000000BM6( 2|mymvmtmsmsmsmsmtmtmtmtmsmumumvmxmzmzmzmzmymzm|m~mm~mzmxmvmvmwm{m}m~m~m{mzmzmzm|m|m~m~m~m~mm~mmm~mmmmm~m{mymxmvmvmvmvmvmvmwmwmxmymym{m{m|m~mmmmm|mymxmwmxmxmymymymymzmzm|m|m}m~mmmmmmm|mzmymxmxmwmwmvmvmumumumwmzm|m~m|mzmzm{m}m~m}m{mzm{m{m}m~mmmmmmmmmm~m}m|m|m}mmmm|mzmxmwmwmwmwmxmzm|m~mmmmmmmmmmmmmmmm~m}mzmymxmxmxmymzmymvmtmumumvmvmwmxmymzm|m~mmmmmmmmmmmmmmm}mzmxmwmvmvmvmumumumsmsmvmxm{mmmmmmm~m}mymxmwmwmwmxmymymzm{m~mmmm|mzmymzmzm{mzm{m{m{m{m{m{m|m_bekrrronkhifbc``]\\\ZZWWW\bhhhe_]YY\]\ZYYWWVTTSSSTS~S}SzVz]behkkkkkknnnkkknli`}\{X}Y\_b`]\YYZZWWUUTTS}S}SzSzV}\biihihihhhkkeb\\\]ZVUTUWZYYYYYYY\Y}Y}V}VVYY\\\YV}V\bhkhif_\YVV}WzVzVzVzZxYxYxYxXzVzVzYz\}\_bbeffeb__bihhecb`]]YYVV}SzSwQxQwSwQwSzR}S~TS~WZ]]`acehknqqke\VS}SzS}V}Y}\`ehknnnnooni_}Y}VYY]_\\ZYWWWWWU$1?OYYXQKFB?62.,! ,>EE<."   |{xvzx y&6>FGFGFGNOOJFGGB3 tqy'-,$ zzqr y(2:7:=:6>?FF=-#  } }  %7?=:2( }u q q qijiin q qxz$+-/2360%#,:>=6.+% sja_baijrw{}#(/7?HSVN9# sqs zy'5>FNOOHKKH:$zz $ 4DQ\\\WSSKLC@=4, ,?LSPB1(zyy{zys q rz { 6CLOKQOSSRRTKJD:*vrr~ -9<<4,'! y yv r y#+37:<;>CJKL@4,$%" $&&#$ &+,+%#0;<;3.%{ rrrnllpsrwz #,,//267<3%+;KH=<4,& rc ^ \ b g k jjmsy  %*4=JRZZD, r s r{%3;DLRRSSKB?/#zy )--%$)zo*s+y"0<=B8+'>HHHI@@<<6*ru0DWXQE<4+# z r qrrz "*37;:72+0475.+,$#+,+  %,38>>>99870'!! zvsrroprq8yp~|~q|m{j}v{t{v{w~~zg<"!/?IHC=4/$w$t&s,{-$~ne a g j j r zz%7ITUJ3 qjj js09HIHJ?3( &+)(,/0/+$YXURNJINIB<81ys v z #!.@PW^\B2&&*-&zk)s#07EJJNI<1& 6MQQPJJ;:2#v}*BTcc\M8/,# zzrppt{{ $/3:8,/1;BBC:0& #+(*% !)8;?CIBBBIFGFB8$**'&! {{wtttllkn|s}f|\~PE(2~~~|{xs'*CPQPKC3*vp"s4z<4,"xnhk ns{ {}zz4FPUSD' |jcjly1>IQPQC64*''*1,2;;<0~~~22~2+&"TSMJEBC;d~{{f}b{c|`~`}b~{zUt|x~}z||rkJÄy~z~kr}| 1=:2I|wz}sv~~|z{w~I#P|~xx|yu~f|f}v~y}z~t~tt3 +N}|w~z}eh~}|z{w~B$0Wƒ}y~z~_h~|MKK)#rkc*mr}yv~u}t~~#~{}{|{|{|{|{;+#Eŀ}w{~e`}{~y~|uR | {1y}w~z~}ok}zw}1u jr8+535-,$ RLJGBB<43j|~y{yx|x~~|c ~}~TFrq~~~QV 5@:4~~~We~~~$T}x~~~M~"}xyzIzy~}ri^I(}~~~&<~~|!-9~~~-:SQJ,}~yqju|~~~~'" :N[[TN:+~}~?65)}z|z w|~}~?9~}} jr. 8/;2+# KKCBC;:3+.q~~s4'i~~}n|~~J5~~~~~~rs{~~[Y99:8s~{~~~~Qb}{t}}}yuz{} "t~{~~~+@~~~~~{t*7;|~~~@KTTJ~~~~~+#~~~~~.y~~~~}|zyr~~~~~~~~~~&@PPG<4+v{~~~OEPJ=,{'z&yy s ro}{~~~~>2~~~~{r jr~~J5~~~~~OE~}:4+#KFBA>;3.+#)x}^U}u~ z}y|y|y|z|y}yC*z~y}y}y}y~ys#zB~|w|y{y{y{{$>|x|x|x|x}x}x?:9=q~{wyzw{|y{yzw|ys9 }v~~1}{{z{ { }"8q~z}w~y~yxy|y|y{w}zp3+:6G~~w~y}z|yw{SNK|x|x|x}x|x|x+#~y~y~yyy~uyyyzywc|zyJz€|xyyyptxyzy~y~y%CRSC:2')}l|y~w}y|zzuxozo}p~q|~Dws q rtk}{|w}y}zxuyywzj|p kr~y~y~y}y~y~t~y~z~y}y}y{w}}{t~w|y|y{y{yzwp;3+#RDC;853*%}5z}~~}}~~%v~|mrtuut4"moqoml}$s$z ;^szzyt~~~~}}*Cuz~~}vD<80/FK:03C]fefYF9.#)>]RJB:0+"r!s'z8FVWWA- oi lor#+5<7.)>C9*#&>G6}&"4Ree`XF=-"3Jg~aF23*#{{)>LVYL:# z rk*oMj^I,%4A=4%u j c9vtrR0'3C6+*.1*"9JVZVQLF?6/772,( $ yrrjdcc]` ftz"9UxyP5)#~2EOJ:3"zry"3NafZN>1# jbjrz~ v z#2B`i_B-+9CJN;*+BWdeeYK;0$"2NbVNJ?5+#~r&s*z3#*BvuN3*$r0BKIA1!zr'uQwM-$0-&rt(6??2${sDwY9(*2BKJB1%y$uJb;(*3)+BC8)"+"z8Tee_WJB:0)" $*1-) zvnlc b a a bk"s:ah*""2?B<8-(&|1YcdYB*hcchl rzw|"**+(!||;l`FBQYZS=+*;KZ_ZJ:+#;^QROGB;+~6}KONKRQI:* r kffj r|"%.=-".<;::;J[[WON>:AP[^ZJA4*#?v^<+sr!288,"zw'yWnG."*2CGD;5.~=mzO0"*2**BI:*#'#z|.Ndef[J<4+#+362& {  ~&z)w,rjgd bbk#s:\t*"#,:;9:3.*#z2UbcZB+x`^cc j rz&&zrsv#*'! z{7swQCSZZRC1+3DSZZM;**HmKNJA?6*"C7"*58:9;IQRNTkY@:ERYVJB:,":vU5#yr-23)zq3zgwV6!#*2>BABLLaf>$#*2.#BJC.")*$zx})E^eeaO=3+$)2;:/' z v $/~6|8{/tljddks:}Zu+#"&68:993/"v4R[^YB&n]]cbls(~0,$zrqrz"#! {z2~gbKO[ZSI7*2=KVYL9#3SyJJE;50$"CioiWRJC0"ul jrr t rt}';CB:"%225:=BKEDYX@>IQOKB;+:sR/r{*00#{#u@twe?$"*29BH`ssM+"*22"BLJ4'+**{wz9TdefTE9,# #3::6+ zm t"*8@G;|/t#plkk"s:[e& # 0689:21#zq9RYYWC" j]] bgr(z7;2+!zrmr$z$" y { uv1zg{VQUZZL9,09EMQE3#%;\JEB50*!(LuydTMA*#}m h j s xztz,BFB:""-327:BDBDgvOB@HJIB8+:sM"uw%**"zt-zSpgM*"-8@C[h3"-87*$BSM<-*-0)zt*CZceYK<1& | x 0:;2+ zj dt"%*;HRK8{,y(u$q"q's:ZR *34:42* z$uBRXYU<# j_ a bq2y4BRRC1*361!tw4O\_ZJ@6, z oz*483( zjcl$#%+*:K]XC9{1z4y4z4yC^pA !*24722*t6}MYXYR9 k b bi3yMSULD><3{-u({*0-! z orlk)tZ_RNROC2*1?BC7/'*+39BCB_{L:;;:72$!zAse-{#**"z*{BQP8{z+28Tc7~+28SfMFRUI5.3<6)~rz&?OZVJG;+# z jt$+1/#z jc-n<6--1>TedOB9~<~CEPmW/z"*2223,${-yR_ZXXK3{k ef$oJmmfZNJJF=~/z123*~ jkgk-savZMOJJ6*,6::.!#z6ZVB3#"@wwY>*yg \ ^cr/D^_OGB>1&"+*29BBMW<5/2.+!'zFxC)**""z2zAE9}%vr v06I{{I%|z06I{pLRYK;4:;;/rr}.AOPKF:+ skn*+)y jh?wWTE63CSmr_K>AJQ`tn>vz#'*31..)zMpp\WSJ1zlii/tc}hYVXYO;~20.+# rjcd2scgTIIF:*)-31)~"z?gbB2!.PbD*{c \`k(wGhzbPB9+!!%*19BFgbB1))%&{,zLg0,*""$z2z;}9}#ql kr$7Jp]3}rz$7JpSRYRB;;;;3 rkp%5EKIB;+ r e j!&# sh'kNssR@CWt}nVGHP]oS+yqz!)++*-**(#}7{sf[RJ1zrl kAxvgbfi_C4*))# r j ac1se\LDB9*#(-+!y'zGssH2 !;hrP/ucack=htTB4%"*1=BUkB, " x4zYB2*%%+|3z5z*ui b hr ,DiJ$urz",DicRVRH@:;80 xkk"|/;C@A5+ s b ez pe0m^}YQ^v}cSPXevB!qr z$*/255,***+#$yWsZRJ1#|rk,mMqpptjM:+ u j \c7spkTJB9+ "$%|{-zMzS2 )L|U2ufdf*rS^B2"#+5;KyvI*!s>~e\;1***,z+zm`a er)?jw9y!lr#z+?juRTRKI>42*zkk"t+47:72% p c b t { jf8skzijqZU_ln2u"kr%z3AMJA;3**+'z3|ydUJ2"r k5t_|{|x]@(t d\c=v}^JB:'zw5}Yb:5`_9{"lj"k7zmnE2 {z"*%rl)oOP2 } zz%.:MU.~}z6z[N:2442*vc \ ]h/^[+m!l&t>_\RRRKC7*"yl)s*s&}%&*%&ykc` j y ~ nc0lUrgiwV.o"o*wHpoR;1+&##"y>p`N:,+{6wOwqK,{}rc`.i[{VB2#z{yu*zKsM,zz$}9ezG/w)s8u^\7} z wz (4BnZ5zz'z@qX;8::2)rc ]bmOT1s's1zVgRRRRJ<*"w)w9|3w+z"!" rkbc j r { } ue c@wg|svU1t+u8|dvR;+%"""~0~VrW<33zB}^|T2zzre%eCxqbB1! yur s9~YR2z(z2PT8}3uH{tl< ytt{#|-;[`:{xz| |2zUZ@<==8*ueci4zvU2u0xBwhRRRRJ@*$*{:}H=~,z#r$k&ccg r t w pb,iN}zvU4x4zMR5("#$|*Dv~cH=BRq[8{z|zr"k8rXsH2 | rrr(xEjU8{3|Ki_D@~YwF#{rrw%z5Oc:{!szz|,zCt_CACC;+{li&qOW8}<~\nURRRQC1-|<LTH3z"zz!s+k-j'dk l r rk f~nZ=Juw[RRRSC9DW`bN:{&z{{)s1k3l.jkj olk-kRZAO}K*~"z"y*z6Ity[T_tb?{#swz$z5yI{hb:zr"s1yEjtYXngjJ)srr&w?abDz.s%t'z:~W~oQGJJ;/{/w7{R\HXzZRRRQJLiuvm]Cz+tz"v4s>v:s6o&kljl.o@xk`NcN+z#v&x3z@\lblbEz*s r"z/{C_uC'~{zt.vE`}shqwvI*s(s't5|TcI~7t0z9~TvxWJJKA@@JgfTny]RRROXq|eI1syz}z.tCxM}Gz@x0p's(p0tBx`kZsY7z*t/z;~PobE|3s+w0{EbM,zz z1zFZxsL:x9zA|RofRB}IWtz[LMJNVZ]yrczgRRSTvoR~4srzz}*z=}VWRH{Ax:t:yHbwiqB:}:|JfdOz*s$s&z8}Qj~qjdcm{kl{zcbmxUELb}z{oZUhvYS_cGz5t/y7}QsztytstYXj^Zee[\ubQA|FTqshqjY]|rZZqpXU`sf^leZe}jitun}mfvyywfaac-1_30/common/Cfaac/CRegistry.cpp000066400000000000000000000241161355157314300173270ustar00rootroot00000000000000/* CRegistry class Copyright (C) 2002-2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include "CRegistry.h" //************************************************************************************************ CRegistry::CRegistry() { regKey=NULL; path=NULL; } //------------------------------------------------------------------------------------------------ CRegistry::~CRegistry() { Close(); } //************************************************************************************************ /* void CRegistry::ShowLastError(char *Caption) { LPVOID MsgBuf; if(FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &MsgBuf, 0, NULL )) MessageBox(NULL, (LPCTSTR)MsgBuf, Caption, MB_OK|MB_ICONSTOP); if(MsgBuf) LocalFree(MsgBuf); }*/ //************************************************************************************************ #define setPath(SubKey) \ { \ if(path) \ free(path); \ path=strdup(SubKey); \ } BOOL CRegistry::Open(HKEY hKey, char *SubKey) { if(regKey) RegCloseKey(regKey); if(RegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, ®Key)==ERROR_SUCCESS) { setPath(SubKey); return TRUE; } else // can't open the key -> error { regKey=0; setPath(""); return FALSE; } } //************************************************************************************************ BOOL CRegistry::OpenCreate(HKEY hKey, char *SubKey) { if(regKey) RegCloseKey(regKey); if(RegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, ®Key)==ERROR_SUCCESS) { setPath(SubKey); return TRUE; } else // open failed -> create the key { DWORD disp; RegCreateKeyEx(hKey, SubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ®Key, &disp); if(disp==REG_CREATED_NEW_KEY) { setPath(SubKey); return TRUE; } else // can't create the key -> error { regKey=0; setPath(""); return FALSE; } } } //************************************************************************************************ void CRegistry::Close() { if(regKey) RegCloseKey(regKey); regKey=NULL; if(path) free(path); path=NULL; } //************************************************************************************************ //************************************************************************************************ //************************************************************************************************ void CRegistry::DeleteVal(char *SubKey) { RegDeleteValue(regKey,SubKey); } //************************************************************************************************ void CRegistry::DeleteKey(char *SubKey) { RegDeleteKey(regKey,SubKey); } //************************************************************************************************ //************************************************************************************************ //************************************************************************************************ void CRegistry::SetBool(char *keyStr, bool val) { bool tempVal; DWORD len=sizeof(bool); if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS || tempVal!=val) RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(bool)); } //************************************************************************************************ void CRegistry::SetByte(char *keyStr, BYTE val) { DWORD t=val; DWORD tempVal; DWORD len; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS || tempVal!=val) RegSetValueEx(regKey, keyStr, 0, REG_DWORD, (BYTE *)&t, sizeof(DWORD)); } //************************************************************************************************ void CRegistry::SetWord(char *keyStr, WORD val) { DWORD t=val; DWORD tempVal; DWORD len; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS || tempVal!=val) RegSetValueEx(regKey, keyStr, 0, REG_DWORD, (BYTE *)&t, sizeof(DWORD)); } //************************************************************************************************ void CRegistry::SetDword(char *keyStr, DWORD val) { DWORD tempVal; DWORD len; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS || tempVal!=val) RegSetValueEx(regKey, keyStr, 0, REG_DWORD, (BYTE *)&val, sizeof(DWORD)); } //************************************************************************************************ void CRegistry::SetFloat(char *keyStr, float val) { float tempVal; DWORD len; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS || tempVal!=val) RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(float)); } //************************************************************************************************ void CRegistry::SetStr(char *keyStr, char *valStr) { DWORD len; DWORD slen=strlen(valStr)+1; if(!valStr || !*valStr) return; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, NULL, &len )!=ERROR_SUCCESS || len!=slen) RegSetValueEx(regKey, keyStr, 0, REG_SZ, (BYTE *)valStr, slen); else { char *tempVal=new char[slen]; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)tempVal, &len )!=ERROR_SUCCESS || strcmpi(tempVal,valStr)) RegSetValueEx(regKey, keyStr, 0, REG_SZ, (BYTE *)valStr, slen); delete [] tempVal; } } //************************************************************************************************ void CRegistry::SetValN(char *keyStr, BYTE *addr, DWORD size) { DWORD len; if(!addr || !size) return; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, NULL, &len )!=ERROR_SUCCESS || len!=size) RegSetValueEx(regKey, keyStr, 0, REG_BINARY, addr, size); else { BYTE *tempVal=new BYTE[size]; if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)tempVal, &len )!=ERROR_SUCCESS || memcmp(tempVal,addr,len)) RegSetValueEx(regKey, keyStr, 0, REG_BINARY, addr, size); delete [] tempVal; } } //************************************************************************************************ //************************************************************************************************ //************************************************************************************************ bool CRegistry::GetSetBool(char *keyStr, bool val) { bool tempVal; DWORD len=sizeof(bool); if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS) { RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(bool)); return val; } return tempVal; } //************************************************************************************************ BYTE CRegistry::GetSetByte(char *keyStr, BYTE val) { DWORD tempVal; DWORD len=sizeof(DWORD); if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS) { tempVal=val; RegSetValueEx(regKey, keyStr, 0, REG_DWORD, (BYTE *)&tempVal, sizeof(DWORD)); return val; } return (BYTE)tempVal; } //************************************************************************************************ WORD CRegistry::GetSetWord(char *keyStr, WORD val) { DWORD tempVal; DWORD len=sizeof(DWORD); if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS) { tempVal=val; RegSetValueEx(regKey, keyStr, 0, REG_DWORD, (BYTE *)&tempVal, sizeof(DWORD)); return val; } return (WORD)tempVal; } //************************************************************************************************ DWORD CRegistry::GetSetDword(char *keyStr, DWORD val) { DWORD tempVal; DWORD len=sizeof(DWORD); if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS) { RegSetValueEx(regKey, keyStr, 0, REG_DWORD, (BYTE *)&val, sizeof(DWORD)); return val; } return (DWORD)tempVal; } //************************************************************************************************ float CRegistry::GetSetFloat(char *keyStr, float val) { float tempVal; DWORD len=sizeof(float); if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS) { RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(float)); return val; } return tempVal; } //************************************************************************************************ char *CRegistry::GetSetStr(char *keyStr, char *String) { long retVal; DWORD Len; char *dest=NULL; if((retVal=RegQueryValueEx(regKey , keyStr , NULL , NULL, NULL, &Len))==ERROR_SUCCESS) if(dest=(char *)malloc(Len+1)) retVal=RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)dest , &Len); if(retVal!=ERROR_SUCCESS) { if(dest) free(dest); if(!String) return NULL; Len=strlen(String)+1; if(!(dest=strdup(String))) return NULL; RegSetValueEx(regKey , keyStr , NULL , REG_SZ , (BYTE *)dest , Len); } return dest; } // ----------------------------------------------------------------------------------------------- int CRegistry::GetSetValN(char *keyStr, BYTE *defData, DWORD defSize, BYTE **dest) { long retVal; DWORD size; *dest=NULL; if((retVal=RegQueryValueEx(regKey , keyStr , NULL , NULL, NULL, &size))==ERROR_SUCCESS) if(*dest=(BYTE *)malloc(size+1)) retVal=RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)*dest , &size); if(retVal!=ERROR_SUCCESS) { if(*dest) free(*dest); if(!defData) return 0; size=defSize; if(!(*dest=(BYTE *)malloc(size))) return 0; memcpy(*dest,defData,size); RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , (BYTE *)*dest , size); } return size; } faac-1_30/common/Cfaac/CRegistry.h000066400000000000000000000035471355157314300170010ustar00rootroot00000000000000/* CRegistry class Copyright (C) 2002-2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ //--------------------------------------------------------------------------- #ifndef CRegistryH #define CRegistryH //--------------------------------------------------------------------------- #include #include #include //#include class CRegistry { public: CRegistry(); ~CRegistry(); BOOL Open(HKEY hKey, char *SubKey); BOOL OpenCreate(HKEY hKey, char *SubKey); void Close(); void DeleteVal(char *SubKey); void DeleteKey(char *SubKey); void SetBool(char *keyStr , bool val); void SetByte(char *keyStr , BYTE val); void SetWord(char *keyStr , WORD val); void SetDword(char *keyStr , DWORD val); void SetFloat(char *keyStr , float val); void SetStr(char *keyStr , char *valStr); void SetValN(char *keyStr , BYTE *addr, DWORD size); bool GetSetBool(char *keyStr, bool var); BYTE GetSetByte(char *keyStr, BYTE var); WORD GetSetWord(char *keyStr, WORD var); DWORD GetSetDword(char *keyStr, DWORD var); float GetSetFloat(char *keyStr, float var); char *GetSetStr(char *keyStr, char *String); int GetSetValN(char *keyStr, BYTE *defData, DWORD defSize, BYTE **dest); HKEY regKey; char *path; }; #endif faac-1_30/common/Cfaac/CTag.cpp000066400000000000000000000237551355157314300162420ustar00rootroot00000000000000/* CTag - Class to read/write id3v2/mp4 tags Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include #include #define HAVE_INT32_T #include #include "CTag.h" // ********************************************************************************************* // CMP4Tag // ********************************************************************************************* CMP4Tag::CMP4Tag() { // memset(this,0,sizeof(*this)); copyright=NULL; artist=title=album=year=genre=writer=comment=NULL; trackno=ntracks=discno=ndiscs=0; compilation=0; artFilename=NULL; art.pictureType=0; // = other memset(&art,0,sizeof(art)); } // ********************************************************************************************* void CMP4Tag::FreeTag() { FREE_ARRAY(artist); FREE_ARRAY(title); FREE_ARRAY(album); FREE_ARRAY(year); FREE_ARRAY(genre); FREE_ARRAY(writer); FREE_ARRAY(comment); FREE_ARRAY(artFilename); FREE_ARRAY(art.data); FREE_ARRAY(art.description); FREE_ARRAY(art.mimeType); FREE_ARRAY(art.format); } // *********************************************************************************************** int CMP4Tag::check_image_header(const char *buf) { if(!strncmp(buf, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8)) return 1; /* PNG */ if(!strncmp(buf, "\xFF\xD8\xFF\xE0", 4) && !strncmp(buf + 6, "JFIF\0", 5)) return 2; /* JPEG */ if(!strncmp(buf, "GIF87a", 6) || !strncmp(buf, "GIF89a", 6)) return 3; /* GIF */ return 0; } // ----------------------------------------------------------------------------------------------- int CMP4Tag::ReadCoverArtFile(char *pCoverArtFile, char **artData) { FILE *artFile; if(!pCoverArtFile || !*pCoverArtFile) return 0; if(!(artFile=fopen(pCoverArtFile, "rb"))) { char buf[25+MAX_PATH+1]; sprintf(buf,"ReadCoverArtFile: can't open \"%s\"",pCoverArtFile); MessageBox(NULL,buf,NULL,MB_OK); return 0; } int r; char *art; int artSize=0; fseek(artFile, 0, SEEK_END); artSize=ftell(artFile); fseek(artFile, 0, SEEK_SET); if(!(art=(char *)malloc(artSize))) { fclose(artFile); MessageBox(NULL,"ReadCoverArtFile: Memory allocation error!", NULL, MB_OK); return 0; } r=fread(art, 1, artSize, artFile); if(r!=artSize) { free(art); fclose(artFile); MessageBox(NULL,"ReadCoverArtFile: Error reading cover art file!", NULL, MB_OK); return 0; } else if(artSize<12 || !check_image_header(art)) { // the above expression checks the image signature free(art); fclose(artFile); MessageBox(NULL,"ReadCoverArtFile: Unsupported cover image file format!", NULL, MB_OK); return 0; } FREE_ARRAY(*artData); *artData=art; fclose(artFile); return artSize; } // ********************************************************************************************* int CMP4Tag::WriteMP4Tag(MP4FileHandle MP4File) { char buf[512], *faac_id_string, *faac_copyright_string; if(MP4File==NULL) { MessageBox(NULL,"WriteMp4Tag: can't open file!",NULL,MB_OK); return 1; } sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version"); MP4SetMetadataTool(MP4File, buf); if(artist) MP4SetMetadataArtist(MP4File, artist); if(writer) MP4SetMetadataWriter(MP4File, writer); if(title) MP4SetMetadataName(MP4File, title); if(album) MP4SetMetadataAlbum(MP4File, album); if(trackno>0) MP4SetMetadataTrack(MP4File, trackno, ntracks); if(discno>0) MP4SetMetadataDisk(MP4File, discno, ndiscs); if(compilation) MP4SetMetadataCompilation(MP4File, compilation); if(year) MP4SetMetadataYear(MP4File, year); if(genre) MP4SetMetadataGenre(MP4File, genre); if(comment) MP4SetMetadataComment(MP4File, comment); if(art.size=ReadCoverArtFile(artFilename,&art.data)) { MP4SetMetadataCoverArt(MP4File, (unsigned __int8 *)art.data, art.size); FREE_ARRAY(art.data); } return 0; } // ********************************************************************************************* int CMP4Tag::ReadMp4Tag(char *Filename) { MP4FileHandle MP4File; if(!(MP4File=MP4Read(Filename, 0))) { char buf[25+MAX_PATH+1]; sprintf(buf,"ReadMp4Tag: can't open \"%s\"",Filename); MessageBox(NULL,buf,NULL,MB_OK); return 1; } FREE_ARRAY(copyright); MP4GetMetadataTool(MP4File, ©right); FREE_ARRAY(artist); MP4GetMetadataArtist(MP4File, &artist); FREE_ARRAY(writer); MP4GetMetadataWriter(MP4File, &writer); FREE_ARRAY(title); MP4GetMetadataName(MP4File, &title); FREE_ARRAY(album); MP4GetMetadataAlbum(MP4File, &album); MP4GetMetadataTrack(MP4File, (unsigned __int16 *)&trackno, (unsigned __int16 *)&ntracks); MP4GetMetadataDisk(MP4File, (unsigned __int16 *)&discno, (unsigned __int16 *)&ndiscs); MP4GetMetadataCompilation(MP4File, (unsigned __int8 *)&compilation); FREE_ARRAY(year); MP4GetMetadataYear(MP4File, &year); FREE_ARRAY(genre); MP4GetMetadataGenre(MP4File, &genre); FREE_ARRAY(comment); MP4GetMetadataComment(MP4File, &comment); FREE_ARRAY(art.data); MP4GetMetadataCoverArt(MP4File, (unsigned __int8 **)&art.data, (uint32_t *)&art.size); MP4Close(MP4File); /* FILE *f=fopen("D:\\prova.jpg","wb"); fwrite(artFile,1,artSize,f); fclose(f);*/ return 0; } // ********************************************************************************************* #define DEL_FIELD(id3Tag,ID3FID) \ { \ ID3_Frame *Frame=id3Tag.Find(ID3FID); \ if(Frame!=NULL) \ id3Tag.RemoveFrame(Frame); \ } // ----------------------------------------------------------------------------------------------- #define ADD_FIELD(id3Tag,ID3FID,ID3FN,data) \ { \ ID3_Frame *NewFrame=new ID3_Frame(ID3FID); \ NewFrame->Field(ID3FN)=data; \ DEL_FIELD(id3Tag,ID3FID); \ id3Tag.AttachFrame(NewFrame); \ } // ----------------------------------------------------------------------------------------------- int CMP4Tag::WriteAacTag(char *Filename) { char buf[512], *faac_id_string, *faac_copyright_string; ID3_Tag id3Tag; FILE *file; if((file=fopen(Filename,"r"))==NULL) { char buf[25+MAX_PATH+1]; sprintf(buf,"WriteAacTag: can't open \"%s\"",Filename); MessageBox(NULL,buf,NULL,MB_OK); return 1; } else fclose(file); id3Tag.Link(Filename); sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version"); ADD_FIELD(id3Tag,ID3FID_ENCODEDBY,ID3FN_TEXT,buf); ADD_FIELD(id3Tag,ID3FID_LEADARTIST,ID3FN_TEXT,artist); ADD_FIELD(id3Tag,ID3FID_COMPOSER,ID3FN_TEXT,writer); ADD_FIELD(id3Tag,ID3FID_TITLE,ID3FN_TEXT,title); ADD_FIELD(id3Tag,ID3FID_ALBUM,ID3FN_TEXT,album); sprintf(buf,"%d",trackno); ADD_FIELD(id3Tag,ID3FID_TRACKNUM,ID3FN_TEXT,buf); ADD_FIELD(id3Tag,ID3FID_YEAR,ID3FN_TEXT,year); ADD_FIELD(id3Tag,ID3FID_CONTENTTYPE,ID3FN_TEXT,genre); ADD_FIELD(id3Tag,ID3FID_COMMENT,ID3FN_TEXT,comment); art.size=ReadCoverArtFile(artFilename,&art.data); if(art.size) { ID3_Frame *NewFrame=new ID3_Frame(ID3FID_PICTURE); char name[_MAX_FNAME], ext[_MAX_EXT]; _splitpath(artFilename,NULL,NULL,name,ext); NewFrame->Field(ID3FN_DESCRIPTION)=name; char buf[15]; sprintf(buf,"image/%s",check_image_header(art.data)==2 ? "jpeg" : strlwr(ext+1)); NewFrame->Field(ID3FN_MIMETYPE)=buf; // NewFrame->Field(ID3FN_IMAGEFORMAT)=; NewFrame->Field(ID3FN_PICTURETYPE)=(DWORD)art.pictureType; NewFrame->Field(ID3FN_DATA).Set((BYTE *)art.data,art.size); id3Tag.AttachFrame(NewFrame); } // setup all our rendering parameters id3Tag.SetUnsync(false); id3Tag.SetExtendedHeader(true); id3Tag.SetCompression(true); id3Tag.SetPadding(true); // write any changes to the file id3Tag.Update(); FREE_ARRAY(art.data); return 0; } // ********************************************************************************************* #define GET_FIELD_STR(id3Tag,ID3FID,ID3FN,data) \ { \ Frame=id3Tag.Find(ID3FID); \ if(Frame!=NULL) \ { \ DWORD size=Frame->Field(ID3FN).Size(); \ FREE_ARRAY(data); \ if(data=(char *)malloc(size+1)) \ Frame->Field(ID3FN).Get(data,size+1); \ } \ else \ FREE_ARRAY(data); \ } // ----------------------------------------------------------------------------------------------- int CMP4Tag::ReadAacTag(char *Filename) { char *buf=NULL; ID3_Tag id3Tag; ID3_Frame *Frame; if(!id3Tag.Link(Filename)) { char buf[25+MAX_PATH+1]; sprintf(buf,"ReadAacTag: can't open \"%s\"",Filename); MessageBox(NULL,buf,NULL,MB_OK); return 1; } GET_FIELD_STR(id3Tag,ID3FID_ENCODEDBY,ID3FN_TEXT,copyright); GET_FIELD_STR(id3Tag,ID3FID_LEADARTIST,ID3FN_TEXT,artist); GET_FIELD_STR(id3Tag,ID3FID_COMPOSER,ID3FN_TEXT,writer); GET_FIELD_STR(id3Tag,ID3FID_TITLE,ID3FN_TEXT,title); GET_FIELD_STR(id3Tag,ID3FID_ALBUM,ID3FN_TEXT,album); GET_FIELD_STR(id3Tag,ID3FID_TRACKNUM,ID3FN_TEXT,buf); if(buf) trackno=atoi(buf); FREE_ARRAY(buf); GET_FIELD_STR(id3Tag,ID3FID_YEAR,ID3FN_TEXT,year); GET_FIELD_STR(id3Tag,ID3FID_CONTENTTYPE,ID3FN_TEXT,genre); GET_FIELD_STR(id3Tag,ID3FID_COMMENT,ID3FN_TEXT,comment); if(Frame=id3Tag.Find(ID3FID_PICTURE)) { art.size=Frame->Field(ID3FN_DATA).Size(); FREE_ARRAY(art.data); if(art.data=(char *)malloc(art.size)) memcpy(art.data,Frame->Field(ID3FN_DATA).GetBinary(),art.size); GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_MIMETYPE,art.mimeType); GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_DESCRIPTION,art.description); GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_IMAGEFORMAT,art.format); art.pictureType=Frame->Field(ID3FN_PICTURETYPE).Get(); /* FILE *f=fopen("D:\\prova.jpg","wb"); fwrite(artFile,1,artSize,f); fclose(f);*/ } return 0; }faac-1_30/common/Cfaac/CTag.h000066400000000000000000000046621355157314300157030ustar00rootroot00000000000000/* CTag - Class to read/write id3v2/mp4 tags Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #ifndef _CTag_H #define _CTag_H // ********************************************************************************************* #include #include // id3 tag #include "CRegistry.h" #include "Defines.h" // ********************************************************************************************* #define REG_TAGON "Tag On" #define REG_TAGIMPORT "Tag import" #define REG_ARTIST "Tag Artist" #define REG_TITLE "Tag Title" #define REG_ALBUM "Tag Album" #define REG_YEAR "Tag Year" #define REG_GENRE "Tag Genre" #define REG_WRITER "Tag Writer" #define REG_COMMENT "Tag Comment" #define REG_TRACK "Tag Track" #define REG_NTRACKS "Tag Tracks" #define REG_DISK "Tag Disk" #define REG_NDISKS "Tag Disks" #define REG_COMPILATION "Tag Compilation" #define REG_ARTFILE "Tag Art file" // ********************************************************************************************* typedef struct { char *data; DWORD size; DWORD pictureType; // front, back, icon, ... char *mimeType, // jpg, png, gif *format, // ??? *description; // text description } id3Picture; class CMP4Tag { private: int check_image_header(const char *buf); int ReadCoverArtFile(char *pCoverArtFile, char **artBuf); public: CMP4Tag(); virtual ~CMP4Tag() { FreeTag(); } virtual void FreeTag(); virtual int WriteMP4Tag(MP4FileHandle MP4File); virtual int WriteAacTag(char *Filename); virtual int ReadMp4Tag(char *Filename); virtual int ReadAacTag(char *Filename); char *copyright; // used in Cfaad char *artist, *title, *album, *year, *genre, *writer, *comment; WORD trackno,ntracks, discno,ndiscs; BYTE compilation; char *artFilename; id3Picture art; // used in ReadAacTag(). Remark: field not stored into registry }; #endiffaac-1_30/common/Cfaac/Cfaac.cpp000066400000000000000000000456671355157314300164270ustar00rootroot00000000000000/* CFAAC - set of classes to import/export .aac/.mp4 files Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include "Cfaac.h" // ********************************************************************************************* // CMyEncCfg // ********************************************************************************************* void CMyEncCfg::getCfg(CMyEncCfg *cfg) { CRegistry reg; if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC")) { cfg->AutoCfg=reg.GetSetBool(REG_AUTO,DEF_AUTO); cfg->SaveMP4=reg.GetSetByte(REG_WRITEMP4,DEF_WRITEMP4); cfg->EncCfg.mpegVersion=reg.GetSetDword(REG_MPEGVER,DEF_MPEGVER); cfg->EncCfg.aacObjectType=reg.GetSetDword(REG_PROFILE,DEF_PROFILE); cfg->EncCfg.allowMidside=reg.GetSetDword(REG_MIDSIDE,DEF_MIDSIDE); cfg->EncCfg.useTns=reg.GetSetDword(REG_TNS,DEF_TNS); cfg->EncCfg.useLfe=reg.GetSetDword(REG_LFE,DEF_LFE); cfg->UseQuality=reg.GetSetBool(REG_USEQUALTY,DEF_USEQUALTY); cfg->EncCfg.quantqual=reg.GetSetDword(REG_QUALITY,DEF_QUALITY); cfg->EncCfg.bitRate=reg.GetSetDword(REG_BITRATE,DEF_BITRATE); cfg->EncCfg.bandWidth=reg.GetSetDword(REG_BANDWIDTH,DEF_BANDWIDTH); cfg->EncCfg.outputFormat=reg.GetSetDword(REG_HEADER,DEF_HEADER); FREE_ARRAY(cfg->OutDir); cfg->OutDir=reg.GetSetStr(REG_OutFolder,""); cfg->TagOn=reg.GetSetByte(REG_TAGON,0); #ifdef USE_IMPORT_TAG cfg->TagImport=reg.GetSetByte(REG_TAGIMPORT,0); #ifdef USE_PATHEXT FREE_ARRAY(cfg->TagSrcPath); FREE_ARRAY(cfg->TagSrcExt); cfg->TagSrcPath=reg.GetSetStr(REG_InFolder,""); cfg->TagSrcExt=reg.GetSetStr(REG_SrcExt,""); #endif #endif cfg->Tag.artist=reg.GetSetStr(REG_ARTIST,""); cfg->Tag.title=reg.GetSetStr(REG_TITLE,""); cfg->Tag.album=reg.GetSetStr(REG_ALBUM,""); cfg->Tag.year=reg.GetSetStr(REG_YEAR,""); cfg->Tag.genre=reg.GetSetStr(REG_GENRE,""); cfg->Tag.writer=reg.GetSetStr(REG_WRITER,""); cfg->Tag.comment=reg.GetSetStr(REG_COMMENT,""); cfg->Tag.trackno=reg.GetSetWord(REG_TRACK,0); cfg->Tag.ntracks=reg.GetSetWord(REG_NTRACKS,0); cfg->Tag.discno=reg.GetSetWord(REG_DISK,0); cfg->Tag.ndiscs=reg.GetSetWord(REG_NDISKS,0); cfg->Tag.compilation=reg.GetSetByte(REG_COMPILATION,0); cfg->Tag.artFilename=reg.GetSetStr(REG_ARTFILE,""); } else MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP); } // ----------------------------------------------------------------------------------------------- void CMyEncCfg::setCfg(CMyEncCfg *cfg) { CRegistry reg; if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC")) { reg.SetBool(REG_AUTO,cfg->AutoCfg); reg.SetByte(REG_WRITEMP4,cfg->SaveMP4); reg.SetDword(REG_MPEGVER,cfg->EncCfg.mpegVersion); reg.SetDword(REG_PROFILE,cfg->EncCfg.aacObjectType); reg.SetDword(REG_MIDSIDE,cfg->EncCfg.allowMidside); reg.SetDword(REG_TNS,cfg->EncCfg.useTns); reg.SetDword(REG_LFE,cfg->EncCfg.useLfe); reg.SetBool(REG_USEQUALTY,cfg->UseQuality); reg.SetDword(REG_QUALITY,cfg->EncCfg.quantqual); reg.SetDword(REG_BITRATE,cfg->EncCfg.bitRate); reg.SetDword(REG_BANDWIDTH,cfg->EncCfg.bandWidth); reg.SetDword(REG_HEADER,cfg->EncCfg.outputFormat); reg.SetStr(REG_OutFolder,cfg->OutDir); reg.SetByte(REG_TAGON,cfg->TagOn); #ifdef USE_IMPORT_TAG reg.SetByte(REG_TAGIMPORT,cfg->TagImport); #ifdef USE_PATHEXT reg.SetStr(REG_InFolder,cfg->TagSrcPath); reg.SetStr(REG_SrcExt,cfg->TagSrcExt); #endif #endif reg.SetStr(REG_ARTIST,cfg->Tag.artist); reg.SetStr(REG_TITLE,cfg->Tag.title); reg.SetStr(REG_ALBUM,cfg->Tag.album); reg.SetStr(REG_YEAR,cfg->Tag.year); reg.SetStr(REG_GENRE,cfg->Tag.genre); reg.SetStr(REG_WRITER,cfg->Tag.writer); reg.SetStr(REG_COMMENT,cfg->Tag.comment); reg.SetWord(REG_TRACK,cfg->Tag.trackno); reg.SetWord(REG_NTRACKS,cfg->Tag.ntracks); reg.SetWord(REG_DISK,cfg->Tag.discno); reg.SetWord(REG_NDISKS,cfg->Tag.ndiscs); reg.SetByte(REG_COMPILATION,cfg->Tag.compilation); reg.SetStr(REG_ARTFILE,cfg->Tag.artFilename); } else MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP); } // ********************************************************************************************* // Cfaac // ********************************************************************************************* Cfaac::Cfaac(HANDLE hOut) { if(hOut) { hOutput=hOut; return; } if(!(hOutput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYOUTPUT)))) { MessageBox(0, "Memory allocation error: hOutput", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \ return; } // dontAskGetFilename=false; } // ----------------------------------------------------------------------------------------------- Cfaac::~Cfaac() { if(!hOutput) return; MYOUTPUT *mo; GLOBALLOCK(mo,hOutput,MYOUTPUT,return); if(mo->WrittenSamples) { int BytesWritten; if(mo->bytes_into_buffer>0) memset(mo->bufIn+mo->bytes_into_buffer, 0, (mo->samplesInput*(mo->BitsPerSample>>3))-mo->bytes_into_buffer); do { if((BytesWritten=processData(hOutput,mo->bufIn,mo->bytes_into_buffer))<0) MessageBox(0, "~Cfaac: processData", APP_NAME " plugin", MB_OK|MB_ICONSTOP); mo->bytes_into_buffer=0; }while(BytesWritten>0); } if(mo->aacFile) { fclose(mo->aacFile); mo->aacFile=0; CMyEncCfg cfg(false); if(cfg.TagOn && mo->OutFilename) { int error=0; #ifdef USE_IMPORT_TAG if(cfg.TagImport && mo->InFilename) { int l=strlen(mo->InFilename); if( !strcmpi(mo->InFilename+l-4,".mp4") || !strcmpi(mo->InFilename+l-4,".m4a") || !strcmpi(mo->InFilename+l-4,".m4b")) error=cfg.Tag.ReadMp4Tag(mo->InFilename); else error=cfg.Tag.ReadAacTag(mo->InFilename); } #endif if(!error) cfg.Tag.WriteAacTag(mo->OutFilename); } } else { MP4Close(mo->MP4File); mo->MP4File=0; } if(mo->hEncoder) faacEncClose(mo->hEncoder); FREE_ARRAY(mo->bitbuf) FREE_ARRAY(mo->buf32bit) FREE_ARRAY(mo->bufIn) FREE_ARRAY(mo->OutFilename) FREE_ARRAY(mo->InFilename) GlobalUnlock(hOutput); GlobalFree(hOutput); } // ********************************************************************************************* // Utilities // ********************************************************************************************* char *Cfaac::getSourceFilename(char *path, char *src, char *ext) { char *dst, chExt, *pname, *pext; if(!src) return NULL; if(!path) path=""; if(!ext) ext=""; pname=pext=src+strlen(src); while(pname!=src && *pname!='\\' && *pname!='/') pname--; if(*pname=='\\' || *pname=='/') pname++; while(pext!=src && *pext!='.') pext--; chExt=*pext; if(chExt=='.') *pext='\0'; if(*path) { int l; if(!(dst=(char *)malloc(strlen(path)+strlen(pname)+strlen(ext)+3))) // '\0','\\','.' return dst; l=strlen(path); if(l>0 && path[l-1]=='\\') sprintf(dst,"%s%s.%s",path,pname,ext); else sprintf(dst,"%s\\%s.%s",path,pname,ext); } else { if(!(dst=(char *)malloc(strlen(pname)+strlen(ext)+2))) return dst; sprintf(dst,"%s.%s",pname,ext); } *pext=chExt; if(!strcmpi(src,dst)) { // if(!dontAskGetFilename) { char buf[MAX_PATH+100]; sprintf(buf,"%s\nSource file=Destination file...aborting!\n\n\tSuppress this warning?",dst); // if(MessageBox(NULL,buf,NULL,MB_YESNO)==IDYES) // dontAskGetFilename=true; } FREE_ARRAY(dst); return NULL; } return dst; } // ********************************************************************************************* #define SWAP32(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8) \ | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24)) #define SWAP16(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8)) void Cfaac::To32bit(int32_t *buf, BYTE *bufi, int size, BYTE samplebytes, BYTE bigendian) { int i; switch(samplebytes) { case 1: // this is endian clean for (i = 0; i < size; i++) buf[i] = (bufi[i] - 128) * 65536; break; case 2: #ifdef WORDS_BIGENDIAN if (!bigendian) #else if (bigendian) #endif { // swap bytes for (i = 0; i < size; i++) { int16_t s = ((int16_t *)bufi)[i]; s = SWAP16(s); buf[i] = ((uint32_t)s) << 8; } } else { // no swap for (i = 0; i < size; i++) { int s = ((int16_t *)bufi)[i]; buf[i] = s << 8; } } break; case 3: if (!bigendian) { for (i = 0; i < size; i++) { int s = bufi[3 * i] | (bufi[3 * i + 1] << 8) | (bufi[3 * i + 2] << 16); // fix sign if (s & 0x800000) s |= 0xff000000; buf[i] = s; } } else // big endian input { for (i = 0; i < size; i++) { int s = (bufi[3 * i] << 16) | (bufi[3 * i + 1] << 8) | bufi[3 * i + 2]; // fix sign if (s & 0x800000) s |= 0xff000000; buf[i] = s; } } break; case 4: #ifdef WORDS_BIGENDIAN if (!bigendian) #else if (bigendian) #endif { // swap bytes for (i = 0; i < size; i++) { int s = bufi[i]; buf[i] = SWAP32(s); } } else memcpy(buf,bufi,size*sizeof(uint32_t)); /* int exponent, mantissa; float *bufo=(float *)buf; for (i = 0; i < size; i++) { exponent=bufi[(i<<2)+3]<<1; if(bufi[i*4+2] & 0x80) exponent|=0x01; exponent-=126; mantissa=(DWORD)bufi[(i<<2)+2]<<16; mantissa|=(DWORD)bufi[(i<<2)+1]<<8; mantissa|=bufi[(i<<2)]; bufo[i]=(float)ldexp(mantissa,exponent); }*/ break; } } // ********************************************************************************************* // Main functions // ********************************************************************************************* void Cfaac::DisplayError(char *ProcName, char *str) { char buf[100]=""; if(str && *str) { if(ProcName && *ProcName) sprintf(buf,"%s: ", ProcName); strcat(buf,str); MessageBox(0, buf, APP_NAME " plugin", MB_OK|MB_ICONSTOP); } MYOUTPUT *mo; GLOBALLOCK(mo,hOutput,MYOUTPUT,return); mo->bytes_into_buffer=-1; GlobalUnlock(hOutput); GlobalUnlock(hOutput); } // ********************************************************************************************* HANDLE Cfaac::Init(LPSTR InFileName, LPSTR OutFileName,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize) { MYOUTPUT *mo; CMyEncCfg cfg(false); DWORD samplesInput, maxBytesOutput; // if(wBitsPerSample!=8 && wBitsPerSample!=16) // 32 bit audio from cooledit is in unsupported format // return 0; if(wChannels>48) // FAAC supports max 48 tracks! return NULL; GLOBALLOCK(mo,hOutput,MYOUTPUT,return NULL); // open the encoder library if(!(mo->hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput))) return ERROR_Init("Can't open library"); if(!(mo->bitbuf=(unsigned char *)malloc(maxBytesOutput*sizeof(unsigned char)))) return ERROR_Init("Memory allocation error: output buffer"); if(!(mo->bufIn=(BYTE *)malloc(samplesInput*sizeof(int32_t)))) return ERROR_Init("Memory allocation error: input buffer"); if(!(mo->buf32bit=(int32_t *)malloc(samplesInput*sizeof(int32_t)))) return ERROR_Init("Memory allocation error: 32 bit buffer"); if(cfg.SaveMP4)// || cfg.Tag.On) { int ExtPos=0, // append new ext fnLen=lstrlen(OutFileName); // if(OutFileName[lstrlen(OutFileName)-4]=='.') if( fnLen>=4 && (!strcmpi(OutFileName+fnLen-4,".aac") || !strcmpi(OutFileName+fnLen-4,".mp4") || !strcmpi(OutFileName+fnLen-4,".m4a") || !strcmpi(OutFileName+fnLen-4,".m4b"))) // no aac/mp4 ext => append new ext if( (cfg.SaveMP4==1 && strcmpi(OutFileName+fnLen-4,".mp4")) || (cfg.SaveMP4==2 && strcmpi(OutFileName+fnLen-4,".m4a")) || (cfg.SaveMP4==3 && strcmpi(OutFileName+fnLen-4,".m4b"))) ExtPos=4; // wrong ext => replace it else ExtPos=-1; // correct ext => no action if(ExtPos!=-1) { switch(cfg.SaveMP4) { case 1: strcpy(OutFileName+fnLen-ExtPos,".mp4"); break; case 2: strcpy(OutFileName+fnLen-ExtPos,".m4a"); break; case 3: strcpy(OutFileName+fnLen-ExtPos,".m4b"); break; } FILE *f=fopen(OutFileName,"rb"); if(f) { char buf[MAX_PATH+20]; sprintf(buf,"Overwrite \"%s\" ?",OutFileName); fclose(f); if(MessageBox(NULL,buf,"File already exists!",MB_YESNO|MB_ICONQUESTION)==IDNO) return ERROR_Init(0);//"User abort"); } } } mo->WriteMP4= !strcmpi(OutFileName+lstrlen(OutFileName)-4,".mp4") || !strcmpi(OutFileName+lstrlen(OutFileName)-4,".m4a") || !strcmpi(OutFileName+lstrlen(OutFileName)-4,".m4b"); faacEncConfigurationPtr CurFormat=faacEncGetCurrentConfiguration(mo->hEncoder); CurFormat->inputFormat=FAAC_INPUT_32BIT; /* switch(wBitsPerSample) { case 16: CurFormat->inputFormat=FAAC_INPUT_16BIT; break; case 24: CurFormat->inputFormat=FAAC_INPUT_24BIT; break; case 32: CurFormat->inputFormat=FAAC_INPUT_32BIT; break; default: CurFormat->inputFormat=FAAC_INPUT_NULL; break; }*/ if(!cfg.AutoCfg) { faacEncConfigurationPtr myFormat=&cfg.EncCfg; if(cfg.UseQuality) { CurFormat->quantqual=myFormat->quantqual; CurFormat->bitRate=0;//myFormat->bitRate; } else { CurFormat->bitRate=(myFormat->bitRate*1000)/wChannels; CurFormat->quantqual=100; } switch(CurFormat->bandWidth) { case 0: // Auto break; case 0xffffffff: // Full CurFormat->bandWidth=lSamprate/2; break; default: CurFormat->bandWidth=myFormat->bandWidth; break; } CurFormat->mpegVersion=myFormat->mpegVersion; CurFormat->outputFormat=myFormat->outputFormat; CurFormat->mpegVersion=myFormat->mpegVersion; CurFormat->aacObjectType=myFormat->aacObjectType; CurFormat->allowMidside=myFormat->allowMidside; // CurFormat->useTns=myFormat->useTns; CurFormat->useTns=false; } else { CurFormat->mpegVersion=DEF_MPEGVER; CurFormat->aacObjectType=DEF_PROFILE; CurFormat->allowMidside=DEF_MIDSIDE; // CurFormat->useTns=DEF_TNS; CurFormat->useTns=false; CurFormat->useLfe=DEF_LFE; CurFormat->quantqual=DEF_QUALITY; CurFormat->bitRate=DEF_BITRATE; CurFormat->bandWidth=DEF_BANDWIDTH; CurFormat->outputFormat=DEF_HEADER; } if(mo->WriteMP4) CurFormat->outputFormat=RAW; CurFormat->useLfe=wChannels>=6 ? 1 : 0; if(!faacEncSetConfiguration(mo->hEncoder, CurFormat)) return ERROR_Init("Unsupported parameters!"); // mo->src_size=lSize; // mi->dst_name=strdup(OutFileName); mo->Samprate=lSamprate; mo->BitsPerSample=wBitsPerSample; mo->Channels=wChannels; mo->samplesInput=samplesInput; mo->samplesInputSize=samplesInput*(mo->BitsPerSample>>3); mo->maxBytesOutput=maxBytesOutput; if(mo->WriteMP4) // Create MP4 file -------------------------------------------------------------------------- { BYTE *ASC=0; DWORD ASCLength=0; if((mo->MP4File=MP4Create(OutFileName, 0, 0))==MP4_INVALID_FILE_HANDLE) return ERROR_Init("Can't create file"); MP4SetTimeScale(mo->MP4File, 90000); mo->MP4track=MP4AddAudioTrack(mo->MP4File, lSamprate, MP4_INVALID_DURATION, MP4_MPEG4_AUDIO_TYPE); MP4SetAudioProfileLevel(mo->MP4File, 0x0F); faacEncGetDecoderSpecificInfo(mo->hEncoder, &ASC, &ASCLength); MP4SetTrackESConfiguration(mo->MP4File, mo->MP4track, (unsigned __int8 *)ASC, ASCLength); mo->frameSize=samplesInput/wChannels; mo->ofs=mo->frameSize; if(cfg.TagOn) { int error=0; #ifdef USE_IMPORT_TAG if(cfg.TagImport && InFileName) { int l=strlen(InFileName); if( !strcmpi(InFileName+l-4,".mp4") || !strcmpi(InFileName+l-4,".m4a") || !strcmpi(InFileName+l-4,".m4b")) error=cfg.Tag.ReadMp4Tag(InFileName); else error=cfg.Tag.ReadAacTag(InFileName); } #endif if(!error) cfg.Tag.WriteMP4Tag(mo->MP4File); } } else // Create AAC file ----------------------------------------------------------------------------- { // open the aac output file if(!(mo->aacFile=fopen(OutFileName, "wb"))) return ERROR_Init("Can't create file"); // use bufferized stream setvbuf(mo->aacFile,NULL,_IOFBF,32767); mo->InFilename=strdup(InFileName); mo->OutFilename=strdup(OutFileName); } showInfo(mo); GlobalUnlock(hOutput); return hOutput; } // ********************************************************************************************* int Cfaac::processData(HANDLE hOutput, BYTE *bufIn, DWORD len) { if(!hOutput) return -1; int bytesWritten=0; int bytesEncoded; MYOUTPUT far *mo; GLOBALLOCK(mo,hOutput,MYOUTPUT,return 0); int32_t *buf=mo->buf32bit; if((int)lensamplesInputSize) { mo->samplesInput=(len<<3)/mo->BitsPerSample; mo->samplesInputSize=mo->samplesInput*(mo->BitsPerSample>>3); } // if(mo->BitsPerSample==8 || mo->BitsPerSample==32) To32bit(buf,bufIn,mo->samplesInput,mo->BitsPerSample>>3,false); // call the actual encoding routine if((bytesEncoded=faacEncEncode(mo->hEncoder, (int32_t *)buf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput))<0) return ERROR_processData("faacEncEncode()"); // write bitstream to aac file if(mo->aacFile) { if(bytesEncoded>0) { if((bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->aacFile))!=bytesEncoded) return ERROR_processData("Write failed!"); mo->WrittenSamples=1; // needed into destructor } } else // write bitstream to mp4 file { MP4Duration dur, SamplesLeft; if(len>0) { mo->srcSize+=len; dur=mo->frameSize; } else { mo->TotalSamples=(mo->srcSize<<3)/(mo->BitsPerSample*mo->Channels); SamplesLeft=(mo->TotalSamples-mo->WrittenSamples)+mo->frameSize; dur=SamplesLeft>mo->frameSize ? mo->frameSize : SamplesLeft; } if(bytesEncoded>0) { if(!(bytesWritten=MP4WriteSample(mo->MP4File, mo->MP4track, (unsigned __int8 *)mo->bitbuf, (DWORD)bytesEncoded, dur, mo->ofs, true) ? bytesEncoded : -1)) return ERROR_processData("MP4WriteSample()"); mo->ofs=0; mo->WrittenSamples+=dur; } } showProgress(mo); GlobalUnlock(hOutput); return bytesWritten; } // ----------------------------------------------------------------------------------------------- int Cfaac::processDataBufferized(HANDLE hOutput, BYTE *bufIn, long lBytes) { if(!hOutput) return -1; int bytesWritten=0, tot=0; MYOUTPUT far *mo; GLOBALLOCK(mo,hOutput,MYOUTPUT,return 0); if(mo->bytes_into_buffer>=0) do { if(mo->bytes_into_buffer+lBytessamplesInputSize) { memmove(mo->bufIn+mo->bytes_into_buffer, bufIn, lBytes); mo->bytes_into_buffer+=lBytes; lBytes=0; } else { int shift=mo->samplesInputSize-mo->bytes_into_buffer; memmove(mo->bufIn+mo->bytes_into_buffer, bufIn, shift); mo->bytes_into_buffer+=shift; bufIn+=shift; lBytes-=shift; tot+=bytesWritten=processData(hOutput,mo->bufIn,mo->bytes_into_buffer); if(bytesWritten<0) return ERROR_processData(0); mo->bytes_into_buffer=0; } }while(lBytes); GlobalUnlock(hOutput); return tot; } faac-1_30/common/Cfaac/Cfaac.h000066400000000000000000000113401355157314300160510ustar00rootroot00000000000000/* CFAAC - set of classes to import/export .aac/.mp4 files Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #ifndef _Cfaac_H #define _Cfaac_H // ********************************************************************************************* #include // int32_t, ... #include //#include // FAAD2 version #ifdef MAIN #undef MAIN #endif #ifdef SSR #undef SSR #endif #ifdef LTP #undef LTP #endif #define HAVE_INT32_T #include #include // mpeg4ip version #include #include #include "Defines.h" // my defines // ********************************************************************************************* #ifdef ADTS #undef ADTS #define ADTS 1 #endif // ********************************************************************************************* #define REG_AUTO "Auto" #define DEF_AUTO true #define REG_WRITEMP4 "Write MP4" #define DEF_WRITEMP4 0 #define REG_MPEGVER "MPEG version" #define DEF_MPEGVER MPEG4 #define REG_PROFILE "Profile" #define DEF_PROFILE LOW #define REG_MIDSIDE "MidSide" #define DEF_MIDSIDE true #define REG_TNS "TNS" #define DEF_TNS true #define REG_LFE "LFE" #define DEF_LFE false #define REG_USEQUALTY "Use quality" #define DEF_USEQUALTY true #define REG_QUALITY "Quality" #define DEF_QUALITY 100 #define REG_BITRATE "BitRate" #define DEF_BITRATE 0 /* quality on */ #define REG_BANDWIDTH "BandWidth" #define DEF_BANDWIDTH 0 #define REG_HEADER "Header" #define DEF_HEADER ADTS #define REG_OutFolder "Output folder" #define REG_InFolder "Source folder" #define REG_SrcExt "Source extensions" // ********************************************************************************************* class CMyEncCfg { private: bool SaveCfgOnDestroy; public: CMyEncCfg(bool SaveOnDestroy=true) { OutDir=TagSrcPath=TagSrcExt=NULL; getCfg(this); SaveCfgOnDestroy=SaveOnDestroy; } virtual ~CMyEncCfg() { if(SaveCfgOnDestroy) setCfg(this); FreeCfg(this); } void FreeCfg(CMyEncCfg *cfg) { Tag.FreeTag(); FREE_ARRAY(OutDir); FREE_ARRAY(TagSrcPath); FREE_ARRAY(TagSrcExt); } void getCfg(CMyEncCfg *cfg); void setCfg(CMyEncCfg *cfg); bool AutoCfg, UseQuality; BYTE SaveMP4; char *OutDir; faacEncConfiguration EncCfg; CMP4Tag Tag; BYTE TagOn; BYTE TagImport; char *TagSrcPath, *TagSrcExt; }; // ----------------------------------------------------------------------------------------------- typedef struct output_tag // any special vars associated with output file { // MP4 MP4FileHandle MP4File; MP4TrackId MP4track; MP4Duration TotalSamples, WrittenSamples, encoded_samples; DWORD frameSize, ofs; // AAC FILE *aacFile; char *InFilename, *OutFilename; // GLOBAL long Samprate; WORD BitsPerSample; WORD Channels; DWORD srcSize; //char *dst_name; // name of compressed file faacEncHandle hEncoder; int32_t *buf32bit; BYTE *bufIn; unsigned char *bitbuf; long bytes_into_buffer; DWORD maxBytesOutput; long samplesInput, samplesInputSize; bool WriteMP4; } MYOUTPUT; // ********************************************************************************************* class Cfaac { private: virtual void DisplayError(char *ProcName, char *str); virtual HANDLE ERROR_Init(char *str) { DisplayError("Init", str); return NULL; } virtual int ERROR_processData(char *str) { DisplayError("processData", str); return -1; } virtual void showInfo(MYOUTPUT *mi) {} virtual void showProgress(MYOUTPUT *mi) {} void To32bit(int32_t *buf, BYTE *bufi, int size, BYTE samplebytes, BYTE bigendian); public: Cfaac(HANDLE hOutput=NULL); virtual ~Cfaac(); virtual char *getSourceFilename(char *path, char *src, char *ext); virtual HANDLE Init(LPSTR InFilename,LPSTR OutFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize); virtual int processData(HANDLE hOutput, BYTE *bufIn, DWORD len); virtual int processDataBufferized(HANDLE hOutput, BYTE *bufIn, long lBytes); /* // AAC bool BlockSeeking; // GLOBAL long newpos_ms; BOOL IsSeekable; MYINPUT *mi; */ HANDLE hOutput; // bool dontAskGetFilename; }; #endif faac-1_30/common/Cfaac/Cfaad.cpp000066400000000000000000000564441355157314300164230ustar00rootroot00000000000000/* CFAAC - set of classes to import/export .aac/.mp4 files Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include "Cfaad.h" // ********************************************************************************************* Cfaad::Cfaad(HANDLE hIn) { ShowDlg4RawAAC=NULL; pCfg=NULL; if(hIn) { hInput=hIn; return; } MYINPUT *mi; if(!(hInput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYINPUT)))) MessageBox(0, "Memory allocation error: hInput", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \ if(!(mi=(MYINPUT *)GlobalLock(hInput))) MessageBox(0, "GlobalLock(hInput)", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \ /* mi->mp4File=0; mi->aacFile=0; mi->hDecoder=0; mi->buffer=0; mi->bytes_read=0;*/ mi->BitsPerSample=16; mi->FindBitrate=FALSE; newpos_ms=-1; mi->seek_table=NULL; mi->seek_table_length=0; mi->LockSeeking=false; GlobalUnlock(hInput); } // ----------------------------------------------------------------------------------------------- Cfaad::~Cfaad() { MYINPUT *mi; if(!hInput) return; GLOBALLOCK(mi,hInput,MYINPUT,return); if(mi->mp4File) MP4Close(mi->mp4File); if(mi->aacFile) fclose(mi->aacFile); if(mi->hDecoder) faacDecClose(mi->hDecoder); FREE_ARRAY(mi->buffer); FREE_ARRAY(mi->seek_table); GlobalUnlock(hInput); GlobalFree(hInput); } // ********************************************************************************************* // Utilities // ********************************************************************************************* int Cfaad::GetAACTrack(MP4FileHandle infile) { // find AAC track int i, rc; int numTracks = MP4GetNumberOfTracks(infile, NULL, 0); for (i = 0; i < numTracks; i++) { MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, 0); const char* trackType = MP4GetTrackType(infile, trackId); if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)) { unsigned char *buff = NULL; unsigned __int32 buff_size = 0; mp4AudioSpecificConfig mp4ASC; MP4GetTrackESConfiguration(infile, trackId, (unsigned __int8 **)&buff, &buff_size); if (buff) { rc = AudioSpecificConfig(buff, buff_size, &mp4ASC); free(buff); if (rc < 0) return -1; return trackId; } } } // can't decode this return -1; } // ********************************************************************************************* int Cfaad::IsMP4(LPSTR lpstrFilename) { DWORD mp4file = 0; FILE *hMP4File = fopen(lpstrFilename, "rb"); BYTE header[8]; if(!hMP4File) return -1; fread(header, 1, 8, hMP4File); fclose(hMP4File); if(header[4]=='f' && header[5]=='t' && header[6]=='y' && header[7]=='p') return 1; return 0; } // ********************************************************************************************* long Cfaad::id3v2_TagSize(unsigned char *buffer) { if(StringComp((const char *)buffer, "ID3", 3) == 0) { unsigned long tagsize; // high bit is not used tagsize = (buffer[6] << 21) | (buffer[7] << 14) | (buffer[8] << 7) | (buffer[9] << 0); tagsize += 10; return tagsize; } return 0; } /* long Cfaad::id3v2_TagSize(aac_buffer *b) { DWORD tagsize = 0; if (!memcmp(b->buffer, "ID3", 3)) { // high bit is not used tagsize = (b->buffer[6] << 21) | (b->buffer[7] << 14) | (b->buffer[8] << 7) | (b->buffer[9] << 0); tagsize += 10; advance_buffer(b, tagsize); fill_buffer(b); } return tagsize; } // ********************************************************************************************* int Cfaad::fill_buffer(aac_buffer *b) { int bread; if (b->bytes_consumed > 0) { if (b->bytes_into_buffer) { memmove((void*)b->buffer, (void*)(b->buffer + b->bytes_consumed), b->bytes_into_buffer*sizeof(unsigned char)); } if (!b->at_eof) { bread = fread((void*)(b->buffer + b->bytes_into_buffer), 1, b->bytes_consumed, b->infile); if (bread != b->bytes_consumed) b->at_eof = 1; b->bytes_into_buffer += bread; } b->bytes_consumed = 0; if (b->bytes_into_buffer > 3) { if (memcmp(b->buffer, "TAG", 3) == 0) b->bytes_into_buffer = 0; } if (b->bytes_into_buffer > 11) { if (memcmp(b->buffer, "LYRICSBEGIN", 11) == 0) b->bytes_into_buffer = 0; } if (b->bytes_into_buffer > 8) { if (memcmp(b->buffer, "APETAGEX", 8) == 0) b->bytes_into_buffer = 0; } } return 1; } // ********************************************************************************************* void Cfaad::advance_buffer(aac_buffer *b, int bytes) { b->file_offset += bytes; b->bytes_consumed = bytes; b->bytes_into_buffer -= bytes; } // ********************************************************************************************* static int adts_sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350,0,0,0}; int Cfaad::adts_parse(aac_buffer *b, int *bitrate, float *length) { int frames, frame_length; int t_framelength = 0; int samplerate; float frames_per_sec, bytes_per_frame; // Read all frames to ensure correct time and bitrate for (frames = 0; ; frames++) { fill_buffer(b); if (b->bytes_into_buffer > 7) { // check syncword if (!((b->buffer[0] == 0xFF)&&((b->buffer[1] & 0xF6) == 0xF0))) break; if (frames == 0) samplerate = adts_sample_rates[(b->buffer[2]&0x3c)>>2]; frame_length = ((((unsigned int)b->buffer[3] & 0x3)) << 11) | (((unsigned int)b->buffer[4]) << 3) | (b->buffer[5] >> 5); t_framelength += frame_length; if (frame_length > b->bytes_into_buffer) break; advance_buffer(b, frame_length); } else { break; } } frames_per_sec = (float)samplerate/1024.0f; if (frames != 0) bytes_per_frame = (float)t_framelength/(float)(frames*1000); else bytes_per_frame = 0; *bitrate = (int)(8. * bytes_per_frame * frames_per_sec + 0.5); if (frames_per_sec != 0) *length = (float)frames/frames_per_sec; else *length = 1; return 1; } // ********************************************************************************************* // get AAC infos for printing void Cfaad::GetAACInfos(aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate, long filesize) { int bitrate=0; float length=0; int bread; long tagsize=id3v2_TagSize(b); *header_type = 0; b->file_offset=tagsize; if ((b->buffer[0] == 0xFF) && ((b->buffer[1] & 0xF6) == 0xF0)) { adts_parse(b, &bitrate, &length); fseek(b->infile, tagsize, SEEK_SET); bread = fread(b->buffer, 1, FAAD_MIN_STREAMSIZE*MAX_CHANNELS, b->infile); if (bread != FAAD_MIN_STREAMSIZE*MAX_CHANNELS) b->at_eof = 1; else b->at_eof = 0; b->bytes_into_buffer = bread; b->bytes_consumed = 0; b->file_offset = tagsize; *header_type = 1; } else if (memcmp(b->buffer, "ADIF", 4) == 0) { int skip_size = (b->buffer[4] & 0x80) ? 9 : 0; bitrate = ((unsigned int)(b->buffer[4 + skip_size] & 0x0F)<<19) | ((unsigned int)b->buffer[5 + skip_size]<<11) | ((unsigned int)b->buffer[6 + skip_size]<<3) | ((unsigned int)b->buffer[7 + skip_size] & 0xE0); length = (float)filesize; if (length != 0) { length = ((float)length*8.f)/((float)bitrate) + 0.5f; } bitrate = (int)((float)bitrate/1000.0f + 0.5f); *header_type = 2; } *song_length = length; *pbitrate=bitrate; } void Cfaad::GetAACInfos(char *Filename, aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate) { if(!(b->infile=fopen(Filename,"rb"))) { MessageBox(NULL,"Error opening file",NULL,MB_OK); return; } fseek(b->infile, 0, SEEK_END); long src_size=ftell(b->infile); fseek(b->infile, 0, SEEK_SET); if(!(b->buffer=(BYTE *)malloc(FAAD_STREAMSIZE))) { MessageBox(NULL,"Memory allocation error: b->buffer",NULL,MB_OK); return; } int tread=src_sizebytes_into_buffer=fread(b->buffer, 1, tread, b->infile); if(b->bytes_into_buffer!=tread) { MessageBox(NULL,"Read failed!",NULL,MB_OK); return; } b->bytes_consumed=0; b->file_offset=0; b->at_eof=(b->bytes_into_buffer!=tread) ? 1 : 0; *header_type = 0; b->file_offset=0; GetAACInfos(b,header_type,song_length,pbitrate,src_size); free(b->buffer); fclose(b->infile); } */ // ********************************************************************************************* // Main functions // ********************************************************************************************* void CMyDecCfg::getCfg(CMyDecCfg *cfg) { CRegistry reg; if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAD")) { cfg->DefaultCfg=reg.GetSetBool(REG_DEFAULT,true); cfg->DecCfg.defObjectType=reg.GetSetByte(REG_PROFILE,LC); cfg->DecCfg.defSampleRate=reg.GetSetDword(REG_SAMPLERATE,44100); cfg->DecCfg.outputFormat=reg.GetSetByte(REG_BPS,FAAD_FMT_16BIT); cfg->DecCfg.downMatrix=reg.GetSetByte(REG_DOWNMATRIX,0); cfg->DecCfg.useOldADTSFormat=reg.GetSetByte(REG_OLDADTS,0); cfg->DecCfg.dontUpSampleImplicitSBR=reg.GetSetByte(REG_DONTUPSAMPLESBR,1); // cfg->Channels=reg.GetSetByte("Channels",2); } else MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP); } // ----------------------------------------------------------------------------------------------- void CMyDecCfg::setCfg(CMyDecCfg *cfg) { CRegistry reg; if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAD")) { reg.SetBool(REG_DEFAULT,cfg->DefaultCfg); reg.SetByte(REG_PROFILE,cfg->DecCfg.defObjectType); reg.SetDword(REG_SAMPLERATE,cfg->DecCfg.defSampleRate); reg.SetByte(REG_BPS,cfg->DecCfg.outputFormat); reg.SetByte(REG_DOWNMATRIX,cfg->DecCfg.downMatrix); reg.SetByte(REG_OLDADTS,cfg->DecCfg.useOldADTSFormat); reg.SetByte(REG_DONTUPSAMPLESBR,cfg->DecCfg.dontUpSampleImplicitSBR); // reg.SetByte("Channels",cfg->Channels); } else MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP); } // ********************************************************************************************* void Cfaad::setFaadCfg(faacDecHandle hDecoder, CMyDecCfg Cfg) { faacDecConfigurationPtr config=faacDecGetCurrentConfiguration(hDecoder); if(!Cfg.DefaultCfg) { config->defObjectType=Cfg.DecCfg.defObjectType; config->outputFormat=Cfg.DecCfg.outputFormat; config->defSampleRate=Cfg.DecCfg.defSampleRate; config->downMatrix=Cfg.DecCfg.downMatrix; config->useOldADTSFormat=Cfg.DecCfg.useOldADTSFormat; config->dontUpSampleImplicitSBR=1; } else { config->defObjectType=LC; config->outputFormat=FAAD_FMT_16BIT; config->defSampleRate=44100; config->downMatrix=0; config->useOldADTSFormat=0; config->dontUpSampleImplicitSBR=1; } faacDecSetConfiguration(hDecoder, config); } // ----------------------------------------------------------------------------------------------- void Cfaad::setDefaultFaadCfg(faacDecHandle hDecoder, BOOL showDlg) { if(showDlg && ShowDlg4RawAAC) ShowDlg4RawAAC(); CMyDecCfg Cfg(false); setFaadCfg(hDecoder,Cfg); } // ----------------------------------------------------------------------------------------------- void Cfaad::DisplayError(char *ProcName, char *str) { MYINPUT *mi; char buf[100]=""; GlobalUnlock(hInput); // it wasn't done in getInfos() GLOBALLOCK(mi,hInput,MYINPUT,return); if(ProcName && *ProcName) sprintf(buf,"%s: ", ProcName); if(str && *str) strcat(buf,str); if(*buf && str) MessageBox(0, buf, APP_NAME " plugin", MB_OK|MB_ICONSTOP); mi->bytes_into_buffer=-1; GlobalUnlock(hInput); } // ********************************************************************************************* HANDLE Cfaad::getInfos(LPSTR lpstrFilename) { MYINPUT *mi; // test tags //CMyDecCfg cfg; cfg.Tag.ReadMp4Tag(lpstrFilename); //CMyDecCfg cfg; cfg.Tag.ReadAacTag(lpstrFilename); GLOBALLOCK(mi,hInput,MYINPUT,return NULL); // mi->IsAAC=strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac")==0; if((mi->IsMP4=IsMP4(lpstrFilename))==-1) return ERROR_getInfos("Error opening file"); if(mi->IsMP4) // MP4 file --------------------------------------------------------------------- { MP4Duration length; unsigned __int32 buffer_size; DWORD timeScale; BYTE sf; mp4AudioSpecificConfig mp4ASC; if(!(mi->mp4File=MP4Read(lpstrFilename, 0))) return ERROR_getInfos("Error opening file"); if((mi->track=GetAACTrack(mi->mp4File))<0) return ERROR_getInfos(0); //"Unable to find correct AAC sound track"); if(!(mi->hDecoder=faacDecOpen())) return ERROR_getInfos("Error initializing decoder library"); MP4GetTrackESConfiguration(mi->mp4File, mi->track, (unsigned __int8 **)&mi->buffer, &buffer_size); if(!mi->buffer) return ERROR_getInfos("MP4GetTrackESConfiguration()"); AudioSpecificConfig(mi->buffer, buffer_size, &mp4ASC); timeScale = mp4ASC.samplingFrequency; mi->Channels=mp4ASC.channelsConfiguration; sf = mp4ASC.samplingFrequencyIndex; mi->type = mp4ASC.objectTypeIndex; // mi->SBR=mp4ASC.sbr_present_flag; if(faacDecInit2(mi->hDecoder, mi->buffer, buffer_size, &mi->Samprate, &mi->Channels) < 0) return ERROR_getInfos("Error initializing decoder library"); FREE_ARRAY(mi->buffer); length=MP4GetTrackDuration(mi->mp4File, mi->track); mi->len_ms=(DWORD)MP4ConvertFromTrackDuration(mi->mp4File, mi->track, length, MP4_MSECS_TIME_SCALE); mi->file_info.bitrate=MP4GetTrackBitRate(mi->mp4File, mi->track); mi->file_info.version=MP4GetTrackAudioType(mi->mp4File, mi->track)==MP4_MPEG4_AUDIO_TYPE ? 4 : 2; mi->numSamples=MP4GetTrackNumberOfSamples(mi->mp4File, mi->track); mi->sampleId=1; mi->IsSeekable=true; mi->LockSeeking=!mi->IsSeekable; } else // AAC file ------------------------------------------------------------------------------ { DWORD read, tmp; BYTE Channels4Raw=0; if(!(mi->aacFile=fopen(lpstrFilename,"rb"))) return ERROR_getInfos("Error opening file"); // use bufferized stream setvbuf(mi->aacFile,NULL,_IOFBF,32767); // get size of file fseek(mi->aacFile, 0, SEEK_END); mi->src_size=ftell(mi->aacFile); fseek(mi->aacFile, 0, SEEK_SET); if(!(mi->buffer=(BYTE *)malloc(FAAD_STREAMSIZE))) return ERROR_getInfos("Memory allocation error: mi->buffer"); tmp=mi->src_sizesrc_size : FAAD_STREAMSIZE; read=fread(mi->buffer, 1, tmp, mi->aacFile); if(read==tmp) { mi->bytes_read=read; mi->bytes_into_buffer=read; } else return ERROR_getInfos("Read failed!"); // skip Tag long tagsize; if(tagsize=id3v2_TagSize(mi->buffer)) { if(tagsize>(long)mi->src_size) ERROR_getInfos("Corrupt stream!"); if(tagsizebytes_into_buffer) { mi->bytes_into_buffer-=tagsize; memcpy(mi->buffer,mi->buffer+tagsize,mi->bytes_into_buffer); } else { mi->bytes_read=tagsize; mi->bytes_into_buffer=0; if(tagsize>mi->bytes_into_buffer) fseek(mi->aacFile, tagsize, SEEK_SET); } if(mi->src_sizebytes_read+FAAD_STREAMSIZE-mi->bytes_into_buffer) tmp=mi->src_size-mi->bytes_read; else tmp=FAAD_STREAMSIZE-mi->bytes_into_buffer; read=fread(mi->buffer+mi->bytes_into_buffer, 1, tmp, mi->aacFile); if(read==tmp) { mi->bytes_read+=read; mi->bytes_into_buffer+=read; } else ERROR_getInfos("Read failed!"); } if(get_AAC_format(lpstrFilename, &mi->file_info, &mi->seek_table, &mi->seek_table_length, 0)) ERROR_getInfos("get_AAC_format()"); mi->IsSeekable=mi->file_info.headertype==ADTS && mi->seek_table && mi->seek_table_length>0; mi->LockSeeking=!mi->IsSeekable; /* aac_buffer b; float fLength; DWORD headertype; b.infile=mi->aacFile; b.buffer=mi->buffer; b.bytes_into_buffer=read; b.bytes_consumed=mi->bytes_consumed; b.file_offset=0; b.at_eof=(read!=tmp) ? 1 : 0; GetAACInfos(&b,&headertype,&fLength,&mi->file_info.bitrate,mi->src_size); mi->file_info.bitrate*=1024; mi->file_info.headertype=headertype; mi->bytes_into_buffer=b.bytes_into_buffer; mi->bytes_consumed=b.bytes_consumed; IsSeekable=false; // only mp4 can be seeked */ if(!mi->FindBitrate) // open a new instance to get info from decoder { MYINPUT *miTmp; Cfaad *NewInst; if(!(NewInst=new Cfaad())) return ERROR_getInfos("Memory allocation error: NewInst"); GLOBALLOCK(miTmp,NewInst->hInput,MYINPUT,return 0); miTmp->FindBitrate=TRUE; NewInst->ShowDlg4RawAAC=ShowDlg4RawAAC; NewInst->pCfg=pCfg; if(!NewInst->getInfos(lpstrFilename)) return ERROR_getInfos(0); mi->Channels=miTmp->frameInfo.channels; if(mi->file_info.headertype==RAW) mi->file_info.bitrate=miTmp->file_info.bitrate;//*mi->Channels; mi->Samprate=miTmp->Samprate; mi->file_info.headertype=miTmp->file_info.headertype; mi->file_info.object_type=miTmp->file_info.object_type; mi->file_info.version=miTmp->file_info.version; GlobalUnlock(NewInst->hInput); delete NewInst; } if(!(mi->hDecoder=faacDecOpen())) return ERROR_getInfos("Can't open library"); if(mi->file_info.headertype==RAW) if(pCfg) setFaadCfg(mi->hDecoder,*pCfg); else setDefaultFaadCfg(mi->hDecoder,mi->FindBitrate); BYTE Channels; // faacDecInit doesn't report correctly the number of channels in raw aac files if((mi->bytes_consumed=faacDecInit(mi->hDecoder, mi->buffer, mi->bytes_into_buffer, &mi->Samprate, &Channels))<0) return ERROR_getInfos("faacDecInit()"); mi->bytes_into_buffer-=mi->bytes_consumed; if(mi->FindBitrate) // get info from decoder { DWORD Samples, BytesConsumed; if(!processData(hInput,0,0)) return ERROR_getInfos(0); Samples=mi->frameInfo.samples/sizeof(short); BytesConsumed=mi->frameInfo.bytesconsumed; if(mi->file_info.headertype==RAW || !mi->file_info.bitrate) mi->file_info.bitrate=(BytesConsumed*8*mi->Samprate)/(Samples*2); if(!mi->file_info.bitrate) return ERROR_getInfos("Can't determine the bitrate"); } mi->len_ms=(DWORD)((mi->src_size<<3)/(mi->file_info.bitrate>>10)); // mi->len_ms=(DWORD)((1000*((float)mi->src_size*8))/mi->file_info.bitrate); } if(mi->len_ms) mi->dst_size=(DWORD)(mi->len_ms*((float)mi->Samprate/1000)*mi->Channels*(mi->BitsPerSample/8)); else return ERROR_getInfos("Can't determine the length"); showInfo(mi); GlobalUnlock(hInput); return hInput; } // ********************************************************************************************* int Cfaad::processData(HANDLE hInput, unsigned char far *bufout, long lBytes) { BYTE *buffer; DWORD BytesDecoded=0; char *sample_buffer=0; int read; MYINPUT *mi; GLOBALLOCK(mi,hInput,MYINPUT,return 0); if(mi->LockSeeking) { NoSeek(); mi->LockSeeking=false; } if(mi->IsMP4) // MP4 file -------------------------------------------------------------------------- { unsigned __int32 buffer_size=0; int rc; if(newpos_ms>-1) { MP4Duration duration=MP4ConvertToTrackDuration(mi->mp4File,mi->track,newpos_ms,MP4_MSECS_TIME_SCALE); MP4SampleId sampleId=MP4GetSampleIdFromTime(mi->mp4File,mi->track,duration,0); mi->bytes_read=(DWORD)(((float)newpos_ms*mi->file_info.bitrate)/(8*1000)); if(seek(mi->bytes_read)) // update the slider return ERROR_processData(0); newpos_ms=-1; } do { buffer=NULL; if(mi->sampleId>=mi->numSamples) return ERROR_processData(0); rc=MP4ReadSample(mi->mp4File, mi->track, mi->sampleId++, (unsigned __int8 **)&buffer, &buffer_size, NULL, NULL, NULL, NULL); if(rc==0 || buffer==NULL) { FREE_ARRAY(buffer); return ERROR_processData("MP4ReadSample()"); } sample_buffer=(char *)faacDecDecode(mi->hDecoder,&mi->frameInfo,buffer,buffer_size); BytesDecoded=mi->frameInfo.samples*sizeof(short); if(BytesDecoded>(DWORD)lBytes) BytesDecoded=lBytes; memmove(bufout,sample_buffer,BytesDecoded); FREE_ARRAY(buffer); // to update the slider mi->bytes_read+=buffer_size; if(seek(mi->bytes_read)) return ERROR_processData(0); }while(!BytesDecoded && !mi->frameInfo.error); } else // AAC file -------------------------------------------------------------------------- { if(newpos_ms>-1) { if(mi->IsSeekable) { DWORD normalized=mi->len_ms/(mi->seek_table_length-1); if(normalized<1000) normalized=1000; mi->bytes_read=mi->seek_table[newpos_ms/normalized]; fseek(mi->aacFile, mi->bytes_read, SEEK_SET); if(seek(mi->bytes_read)) // update the slider return ERROR_processData(0); mi->bytes_into_buffer=0; mi->bytes_consumed=FAAD_STREAMSIZE; } newpos_ms=-1; } buffer=mi->buffer; do { if(mi->bytes_consumed>0) { if(mi->bytes_into_buffer) memmove(buffer,buffer+mi->bytes_consumed,mi->bytes_into_buffer); if(mi->bytes_readsrc_size) { int tmp; if(mi->bytes_read+mi->bytes_consumedsrc_size) tmp=mi->bytes_consumed; else tmp=mi->src_size-mi->bytes_read; read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->aacFile); if(read==tmp) { mi->bytes_read+=read; mi->bytes_into_buffer+=read; } } else if(mi->bytes_into_buffer) memset(buffer+mi->bytes_into_buffer, 0, mi->bytes_consumed); mi->bytes_consumed=0; if( (mi->bytes_into_buffer>3 && !memcmp(mi->buffer, "TAG", 3)) || (mi->bytes_into_buffer>11 && !memcmp(mi->buffer, "LYRICSBEGIN", 11)) || (mi->bytes_into_buffer>8 && !memcmp(mi->buffer, "APETAGEX", 8))) return ERROR_processData(0); } if(mi->bytes_into_buffer<1) if(mi->bytes_readsrc_size) return ERROR_processData("Buffer empty!"); else return ERROR_processData(0); sample_buffer=(char *)faacDecDecode(mi->hDecoder,&mi->frameInfo,buffer,mi->bytes_into_buffer); BytesDecoded=mi->frameInfo.samples*sizeof(short); if(bufout) { if(BytesDecoded>(DWORD)lBytes) BytesDecoded=lBytes; if(sample_buffer && BytesDecoded && !mi->frameInfo.error) memmove(bufout,sample_buffer,BytesDecoded); } else // Data needed to decode Raw files { mi->Channels=mi->frameInfo.channels; mi->file_info.object_type=mi->frameInfo.object_type; } mi->bytes_consumed+=mi->frameInfo.bytesconsumed; mi->bytes_into_buffer-=mi->bytes_consumed; }while(!BytesDecoded && !mi->frameInfo.error); } // END AAC file -------------------------------------------------------------------------- if(mi->frameInfo.error) return ERROR_processData((char *)faacDecGetErrorMessage(mi->frameInfo.error)); showProgress(mi); GlobalUnlock(hInput); return BytesDecoded; } faac-1_30/common/Cfaac/Cfaad.h000066400000000000000000000133751355157314300160640ustar00rootroot00000000000000/* CFAAC - set of classes to import/export .aac/.mp4 files Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #ifndef _Cfaad_H #define _Cfaad_H #include #define HAVE_INT32_T #include #ifdef MAIN #undef MAIN #endif #ifdef SSR #undef SSR #endif #ifdef LTP #undef LTP #endif #include //#include extern "C" { #include // get_AAC_format() } #include "Defines.h" #include #include // ********************************************************************************************* // make this higher to support files with more channels #define MAX_CHANNELS 6 #if FAAD_MIN_STREAMSIZE<2048 #undef FAAD_MIN_STREAMSIZE // 960 for LD or else 1024 (expanded to 2048 for HE-AAC) #define FAAD_MIN_STREAMSIZE 2048 #endif #define FAAD_STREAMSIZE (FAAD_MIN_STREAMSIZE*MAX_CHANNELS) // ----------------------------------------------------------------------------------------------- #define REG_DEFAULT "Default" #define REG_PROFILE "Profile" #define REG_SAMPLERATE "SampleRate" #define REG_BPS "Bps" #define REG_DOWNMATRIX "Downmatrix" #define REG_OLDADTS "Old ADTS" #define REG_DONTUPSAMPLESBR "Don\'t upsample implicit SBR" // ********************************************************************************************* /* FAAD file buffering routines */ /*typedef struct { long bytes_into_buffer; long bytes_consumed; long file_offset; unsigned char *buffer; int at_eof; FILE *infile; } aac_buffer; // ----------------------------------------------------------------------------------------------- typedef struct { int version; int channels; int sampling_rate; int bitrate; int length; int object_type; int headertype; } faadAACInfo; */ // ********************************************************************************************* class CMyDecCfg { private: bool SaveCfgOnDestroy; public: CMyDecCfg(bool SaveOnDestroy=true) { getCfg(this); SaveCfgOnDestroy=SaveOnDestroy; } virtual ~CMyDecCfg() { if(SaveCfgOnDestroy) setCfg(this); FreeCfg(this); } void FreeCfg(CMyDecCfg *cfg) { cfg->Tag.FreeTag(); } void FreeCfg() { this->Tag.FreeTag(); } void getCfg(CMyDecCfg *cfg); void getCfg() { getCfg(this); } void setCfg(CMyDecCfg *cfg); void setCfg() { setCfg(this); } bool DefaultCfg; BYTE Channels; DWORD BitRate; faacDecConfiguration DecCfg; CMP4Tag Tag; }; // ----------------------------------------------------------------------------------------------- typedef struct input_tag // any special vars associated with input file { //MP4 MP4FileHandle mp4File; MP4SampleId sampleId, numSamples; int track; BYTE type; //AAC FILE *aacFile; DWORD src_size; // size of compressed file long tagsize; DWORD bytes_read; // from file long bytes_consumed; // from buffer by faadDecDecode long bytes_into_buffer; unsigned char *buffer; DWORD *seek_table; int seek_table_length; // Raw AAC BOOL FindBitrate; // GLOBAL faacDecHandle hDecoder; faadAACInfo file_info; faacDecFrameInfo frameInfo; DWORD len_ms; // length of file in milliseconds BYTE Channels; DWORD Samprate; WORD BitsPerSample; DWORD dst_size; // size of decoded file. Cooledit needs it to update its progress bar //char *src_name; // name of compressed file int IsMP4; bool LockSeeking, IsSeekable; } MYINPUT; // ----------------------------------------------------------------------------------------------- class Cfaad { private: virtual int GetAACTrack(MP4FileHandle infile); long id3v2_TagSize(unsigned char *buffer); /* long id3v2_TagSize(aac_buffer *b); int fill_buffer(aac_buffer *b); void advance_buffer(aac_buffer *b, int bytes); int adts_parse(aac_buffer *b, int *bitrate, float *length); void GetAACInfos(aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate, long filesize); */ virtual void DisplayError(char *ProcName, char *str); virtual HANDLE ERROR_getInfos(char *str) { DisplayError("getInfos", str); return NULL; } virtual int ERROR_processData(char *str) { DisplayError("processData", str); return 0; } virtual void showInfo(MYINPUT *mi) {} virtual void showProgress(MYINPUT *mi) {} virtual void setDefaultFaadCfg(faacDecHandle hDecoder, BOOL showDlg); virtual void setFaadCfg(faacDecHandle hDecoder, CMyDecCfg Cfg); virtual int seek(int newpos_bytes) { return 0; } // !=0 => error virtual void NoSeek() {} // put here the code to block seeking of player public: Cfaad(HANDLE hInput=NULL); virtual ~Cfaad(); int (*ShowDlg4RawAAC)(); // set this to show your dialog (to decode raw aac files) int IsMP4(LPSTR lpstrFilename); inline bool CanSeek() { MYINPUT *mi; GLOBALLOCK(mi,hInput,MYINPUT,return 0); bool IsSeekable=mi->IsSeekable; GlobalUnlock(hInput); return IsSeekable; } // virtual void GetAACInfos(char *Filename, aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate); virtual HANDLE getInfos(LPSTR lpstrFilename); virtual int processData(HANDLE hInput, unsigned char far *bufout, long lBytes); // GLOBAL long newpos_ms; // set this to change position HANDLE hInput; CMyDecCfg *pCfg; // set this to use your cfg (to decode raw aac files) }; #endif faac-1_30/common/Cfaac/DecDialog.cpp000066400000000000000000000154451355157314300172340ustar00rootroot00000000000000/* CFAAC - set of classes to import/export .aac/.mp4 files Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include #include "resource.h" #include // my defines #include "Cfaad.h" #include "DecDialog.h" #include "EncDialog.h" // ********************************************************************************************* extern HINSTANCE hInstance; extern HBITMAP hBmBrowse; // ----------------------------------------------------------------------------------------------- #ifndef FAAD_FMT_64BIT #define FAAD_FMT_64BIT 5 #endif // ********************************************************************************************* int ShowDlg4RawAAC() { return DialogBoxParam((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_DECODER),(HWND)NULL, (DLGPROC)DialogMsgProcDec, 0); // return DialogBoxParam((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_DECODER),(HWND)hWnd, (DLGPROC)DialogMsgProcDec, (DWORD)&cfg); } // ********************************************************************************************* #define INIT_CB(hWnd,nID,list,IdSelected) \ { \ for(int i=0; list[i]; i++) \ SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \ SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \ } // ----------------------------------------------------------------------------------------------- // EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled); #define DISABLE_CTRLS_DEC(Enabled) \ { \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_DOWNMATRIX), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_OLDADTS), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_SAMPLERATE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), Enabled); \ } // ----------------------------------------------------------------------------------------------- BOOL DialogMsgProcDec(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_INITDIALOG: { /* if(!lParam) { MessageBox(hWndDlg,"Pointer==NULL",0,MB_OK|MB_ICONSTOP); EndDialog(hWndDlg, 0); return TRUE; } */ char buf[50]; char *SampleRate[]={"6000","8000","16000","22050","32000","44100","48000","64000","88200","96000","192000",0}, *BitsPerSample[]={"16","24","32","32 bit FLOAT","64 bit FLOAT",0}; CMyDecCfg cfg(false); SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_DEFAULTCFG),GetDlgItem(hWndDlg,IDC_GRP_DEFAULT),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); INIT_CB(hWndDlg,IDC_CB_BITSPERSAMPLE,BitsPerSample,0); INIT_CB(hWndDlg,IDC_CB_SAMPLERATE,SampleRate,5); sprintf(buf,"%lu",cfg.DecCfg.defSampleRate); SetDlgItemText(hWndDlg, IDC_CB_SAMPLERATE, buf); switch(cfg.DecCfg.defObjectType) { case MAIN: CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); break; case LC: CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE); break; case SSR: CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE); break; case LTP: CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE); break; case HE_AAC: CheckDlgButton(hWndDlg,IDC_RADIO_HE,TRUE); break; } switch(cfg.DecCfg.outputFormat) { case FAAD_FMT_16BIT: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 0, 0); break; case FAAD_FMT_24BIT: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 1, 0); break; case FAAD_FMT_32BIT: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 2, 0); break; case FAAD_FMT_FLOAT: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 3, 0); break; case FAAD_FMT_64BIT: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 4, 0); break; } CheckDlgButton(hWndDlg,IDC_CHK_DOWNMATRIX, cfg.DecCfg.downMatrix); CheckDlgButton(hWndDlg,IDC_CHK_OLDADTS, cfg.DecCfg.useOldADTSFormat); CheckDlgButton(hWndDlg,IDC_CHK_DEFAULTCFG, cfg.DefaultCfg); DISABLE_CTRLS_DEC(!cfg.DefaultCfg); } break; // End of WM_INITDIALOG case WM_CLOSE: // Closing the Dialog behaves the same as Cancel PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0); break; // End of WM_CLOSE case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_CHK_DEFAULTCFG: { char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_DEFAULTCFG); DISABLE_CTRLS_DEC(Enabled); } break; case IDOK: { CMyDecCfg cfg; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN)) cfg.DecCfg.defObjectType=MAIN; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW)) cfg.DecCfg.defObjectType=LC; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR)) cfg.DecCfg.defObjectType=SSR; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) cfg.DecCfg.defObjectType=LTP; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_HE)) cfg.DecCfg.defObjectType=HE_AAC; switch(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_GETCURSEL, 0, 0)) { case 0: cfg.DecCfg.outputFormat=FAAD_FMT_16BIT; break; case 1: cfg.DecCfg.outputFormat=FAAD_FMT_24BIT; break; case 2: cfg.DecCfg.outputFormat=FAAD_FMT_32BIT; break; case 3: cfg.DecCfg.outputFormat=FAAD_FMT_FLOAT; break; case 4: cfg.DecCfg.outputFormat=FAAD_FMT_64BIT; break; } cfg.DecCfg.defSampleRate=GetDlgItemInt(hWndDlg, IDC_CB_SAMPLERATE, 0, FALSE); cfg.DecCfg.downMatrix=IsDlgButtonChecked(hWndDlg,IDC_CHK_DOWNMATRIX) ? TRUE : FALSE; cfg.DecCfg.useOldADTSFormat=IsDlgButtonChecked(hWndDlg,IDC_CHK_OLDADTS) ? TRUE : FALSE; cfg.DefaultCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_DEFAULTCFG) ? TRUE : FALSE; EndDialog(hWndDlg, (DWORD)TRUE); } break; case IDCANCEL: // Ignore data values entered into the controls // and dismiss the dialog window returning FALSE EndDialog(hWndDlg, (DWORD)FALSE); break; case IDC_BTN_ABOUT: DialogBox((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout); break; } break; // End of WM_COMMAND default: return FALSE; } return TRUE; } faac-1_30/common/Cfaac/DecDialog.h000066400000000000000000000013701355157314300166710ustar00rootroot00000000000000extern BOOL DialogMsgProcDec(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam); extern int ShowDlg4RawAAC(); static const char* mpeg4AudioNames[]= { "Raw PCM", "AAC Main", "AAC LC (Low Complexity)", "AAC SSR", "AAC LTP (Long Term Prediction)", "AAC HE (High Efficiency)", "AAC Scalable", "TwinVQ", "CELP", "HVXC", "Reserved", "Reserved", "TTSI", "Main synthetic", "Wavetable synthesis", "General MIDI", "Algorithmic Synthesis and Audio FX", // defined in MPEG-4 version 2 "ER AAC LC (Low Complexity)", "Reserved", "ER AAC LTP (Long Term Prediction)", "ER AAC Scalable", "ER TwinVQ", "ER BSAC", "ER AAC LD (Low Delay)", "ER CELP", "ER HVXC", "ER HILN", "ER Parametric", "Reserved", "Reserved", "Reserved", "Reserved" }; faac-1_30/common/Cfaac/Email.bmp000066400000000000000000000107441355157314300164410ustar00rootroot00000000000000BM6(3ohm i 1v4 8B FI(Q  } 2  g"AMCv?r5h4g,W'N<2 v|}$ASMCv?r5h4g,W&L92  ~ %AZSMCv?r5h4g,W&L92s 'A0I.G(B'@!;8'N4g,W&L/oG[5h4g7Z$H^?r.I[#GIK%4Q&k"%9K@3x_o y:1*B9>*q&w~5|yfaac-1_30/common/Cfaac/EncDialog.cpp000066400000000000000000000767351355157314300172570ustar00rootroot00000000000000/* CFAAC - set of classes to import/export .aac/.mp4 files Copyright (C) 2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include #include // Browse #include // ShellExecute #include #include "resource.h" #include "Defines.h" // my defines #include "CTag.h" #include "Cfaac.h" #include "EncDialog.h" #include #include #include <..\..\common\id3lib\win32\config.h> // ID3LIB_FULLNAME // ********************************************************************************************* #ifdef USE_OUTPUT_FOLDER extern char config_AACoutdir[MAX_PATH]; #endif extern HINSTANCE hInstance; extern HBITMAP hBmBrowse; // ********************************************************************************************* /* DWORD PackCfg(MY_ENC_CFG *cfg) { DWORD dwOptions=0; if(cfg->AutoCfg) dwOptions=1<<31; dwOptions|=(DWORD)cfg->EncCfg.mpegVersion<<30; dwOptions|=(DWORD)cfg->EncCfg.aacObjectType<<28; dwOptions|=(DWORD)cfg->EncCfg.allowMidside<<27; dwOptions|=(DWORD)cfg->EncCfg.useTns<<26; dwOptions|=(DWORD)cfg->EncCfg.useLfe<<25; dwOptions|=(DWORD)cfg->EncCfg.outputFormat<<24; if(cfg->UseQuality) dwOptions|=(((DWORD)cfg->EncCfg.quantqual>>1)&0xff)<<16; // [2,512] else dwOptions|=(((DWORD)cfg->EncCfg.bitRate>>1)&0xff)<<16; // [2,512] if(cfg->UseQuality) dwOptions|=1<<15; dwOptions|=((DWORD)cfg->EncCfg.bandWidth>>1)&&0x7fff; // [0,65536] return dwOptions; } // ----------------------------------------------------------------------------------------------- void UnpackCfg(MY_ENC_CFG *cfg, DWORD dwOptions) { cfg->AutoCfg=dwOptions>>31; cfg->EncCfg.mpegVersion=(dwOptions>>30)&1; cfg->EncCfg.aacObjectType=(dwOptions>>28)&3; cfg->EncCfg.allowMidside=(dwOptions>>27)&1; cfg->EncCfg.useTns=(dwOptions>>26)&1; cfg->EncCfg.useLfe=(dwOptions>>25)&1; cfg->EncCfg.outputFormat=(dwOptions>>24)&1; cfg->EncCfg.bitRate=((dwOptions>>16)&0xff)<<1; cfg->UseQuality=(dwOptions>>15)&1; cfg->EncCfg.bandWidth=(dwOptions&0x7fff)<<1; }*/ // ----------------------------------------------------------------------------------------------- #define INIT_CB(hWnd,nID,list,FillList,IdSelected) \ { \ if(FillList) \ for(int i=0; list[i]; i++) \ SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \ SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \ } // ----------------------------------------------------------------------------------------------- #define INIT_CB_GENRES(hWnd,nID,ID3Genres,IdSelected) \ { \ for(int i=0; i<(sizeof(ID3Genres)/sizeof(ID3Genres[0])); i++) \ SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)ID3Genres[i].name); \ SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \ } // ----------------------------------------------------------------------------------------------- #define DISABLE_LTP \ { \ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \ IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \ { \ CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \ CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \ } \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \ } // ----------------------------------------------------------------------------------------------- // EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled); // EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); #define DISABLE_CTRLS_ENC(Enabled) \ { \ CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \ else \ DISABLE_LTP \ } // ----------------------------------------------------------------------------------------------- #define ENABLE_TAG(Enabled) \ { \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTIST), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_TITLE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_ALBUM), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_YEAR), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_GENRE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_WRITER), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMMENT), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_TRACK), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTFILE), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), Enabled); \ } // ----------------------------------------------------------------------------------------------- #define ENABLE_AACTAGS(Enabled) \ { \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \ EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \ } // ----------------------------------------------------------------------------------------------- #ifdef USE_OUTPUT_FOLDER static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { if (uMsg == BFFM_INITIALIZED) { SetWindowText(hwnd,"Select folder"); SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)TRUE,(LPARAM)lpData); } return 0; } #else #ifdef USE_IMPORT_TAG static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { if (uMsg == BFFM_INITIALIZED) { SetWindowText(hwnd,"Select folder"); SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)TRUE,(LPARAM)lpData); } return 0; } #endif #endif // ----------------------------------------------------------------------------------------------- BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_INITDIALOG: { char buf[512]; char *faac_id_string, *faac_copyright_string; sprintf(buf, APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n" "Libraries used:\n" "\tlibfaac v%s\n" "\tFAAD2 v" FAAD2_VERSION "\n" "\t" MPEG4IP_PACKAGE " v" MPEG4IP_VERSION "\n" "\t" ID3LIB_FULLNAME "\n\n" "This code is given with FAAC package and does not contain executables.\n" "This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n" "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n" "Compiled on %s\n", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version", __DATE__ ); SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf); } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: EndDialog(hWndDlg, TRUE); break; case IDCANCEL: // Ignore data values entered into the controls and dismiss the dialog window returning FALSE EndDialog(hWndDlg, FALSE); break; case IDC_AUDIOCODING: ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW); break; case IDC_MPEG4IP: ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW); break; case IDC_ID3: ShellExecute(hWndDlg, NULL, "http://id3lib.sourceforge.net", NULL, NULL, SW_SHOW); break; case IDC_EMAIL: ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW); break; } break; default: return FALSE; } return TRUE; } // ----------------------------------------------------------------------------------------------- // ripped from id3v2tag.c ID3GENRES ID3Genres[]= { 123, "Acapella", 34, "Acid", 74, "Acid Jazz", 73, "Acid Punk", 99, "Acoustic", 20, "Alternative", 40, "AlternRock", 26, "Ambient", 90, "Avantgarde", 116, "Ballad", 41, "Bass", 85, "Bebob", 96, "Big Band", 89, "Bluegrass", 0, "Blues", 107, "Booty Bass", 65, "Cabaret", 88, "Celtic", 104, "Chamber Music", 102, "Chanson", 97, "Chorus", 61, "Christian Rap", 1, "Classic Rock", 32, "Classical", 112, "Club", 57, "Comedy", 2, "Country", 58, "Cult", 3, "Dance", 125, "Dance Hall", 50, "Darkwave", 254, "Data", 22, "Death Metal", 4, "Disco", 55, "Dream", 122, "Drum Solo", 120, "Duet", 98, "Easy Listening", 52, "Electronic", 48, "Ethnic", 124, "Euro-House", 25, "Euro-Techno", 54, "Eurodance", 84, "Fast Fusion", 80, "Folk", 81, "Folk-Rock", 115, "Folklore", 119, "Freestyle", 5, "Funk", 30, "Fusion", 36, "Game", 59, "Gangsta", 38, "Gospel", 49, "Gothic", 91, "Gothic Rock", 6, "Grunge", 79, "Hard Rock", 7, "Hip-Hop", 35, "House", 100, "Humour", 19, "Industrial", 33, "Instrumental", 46, "Instrumental Pop", 47, "Instrumental Rock", 8, "Jazz", 29, "Jazz+Funk", 63, "Jungle", 86, "Latin", 71, "Lo-Fi", 45, "Meditative", 9, "Metal", 77, "Musical", 82, "National Folk", 64, "Native American", 10, "New Age", 66, "New Wave", 39, "Noise", 255, "Not Set", 11, "Oldies", 103, "Opera", 12, "Other", 75, "Polka", 13, "Pop", 62, "Pop/Funk", 53, "Pop-Folk", 109, "Porn Groove", 117, "Power Ballad", 23, "Pranks", 108, "Primus", 92, "Progressive Rock", 67, "Psychadelic", 93, "Psychedelic Rock", 43, "Punk", 121, "Punk Rock", 14, "R&B", 15, "Rap", 68, "Rave", 16, "Reggae", 76, "Retro", 87, "Revival", 118, "Rhythmic Soul", 17, "Rock", 78, "Rock & Roll", 114, "Samba", 110, "Satire", 69, "Showtunes", 21, "Ska", 111, "Slow Jam", 95, "Slow Rock", 105, "Sonata", 42, "Soul", 37, "Sound Clip", 24, "Soundtrack", 56, "Southern Rock", 44, "Space", 101, "Speech", 83, "Swing", 94, "Symphonic Rock", 106, "Symphony", 113, "Tango", 18, "Techno", 51, "Techno-Industrial", 60, "Top 40", 70, "Trailer", 31, "Trance", 72, "Tribal", 27, "Trip-Hop", 28, "Vocal" }; BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_INITDIALOG: { char buf[50]; char FillList=wParam||lParam ? 1 : 0; char *Quality[]={"Default (100)","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","200","300","400","500",0}; char *BitRate[]={"Auto","8","16","18","20","24","32","40","48","56","64","80","96","112","128","160","192","224","256","320","384",0}; char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000",0}; char *Ext[]={".aac",".mp4",".m4a",".m4b",0}; CMyEncCfg cfg(false); // sprintf(Quality[0]+8,"%3d",3); SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_TAG),GetDlgItem(hWndDlg,IDC_GRP_TAG),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,FillList,0); INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,FillList,0); INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,FillList,0); INIT_CB(hWndDlg,IDC_CB_EXT,Ext,FillList,0); INIT_CB_GENRES(hWndDlg,IDC_CB_GENRE,ID3Genres,0); SendMessage(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse); #ifdef USE_OUTPUT_FOLDER SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse); if(!cfg.OutDir || !*cfg.OutDir) { GetCurrentDirectory(MAX_PATH,config_AACoutdir); FREE_ARRAY(cfg.OutDir); cfg.OutDir=strdup(config_AACoutdir); } else strcpy(config_AACoutdir,cfg.OutDir); SetDlgItemText(hWndDlg, IDC_E_BROWSE, cfg.OutDir); #else ShowWindow(GetDlgItem(hWndDlg, IDC_BTN_BROWSE),SW_HIDE); ShowWindow(GetDlgItem(hWndDlg, IDC_E_BROWSE),SW_HIDE); ShowWindow(GetDlgItem(hWndDlg, IDC_L_BROWSE),SW_HIDE); #endif CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,FALSE); if(cfg.EncCfg.mpegVersion==MPEG4) CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE); else CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE); CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_SSR,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); switch(cfg.EncCfg.aacObjectType) { case MAIN: CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); break; case LOW: CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE); break; case SSR: CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE); break; case LTP: CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE); DISABLE_LTP break; } CheckDlgButton(hWndDlg,IDC_RADIO_RAW,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,FALSE); switch(cfg.EncCfg.outputFormat) { case RAW: CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE); break; case ADTS: CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE); break; } CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, cfg.EncCfg.allowMidside); CheckDlgButton(hWndDlg, IDC_CHK_USETNS, cfg.EncCfg.useTns); CheckDlgButton(hWndDlg, IDC_CHK_USELFE, cfg.EncCfg.useLfe); if(cfg.UseQuality) CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,TRUE); else CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,TRUE); switch(cfg.EncCfg.quantqual) { case 100: SendMessage(GetDlgItem(hWndDlg, IDC_CB_QUALITY), CB_SETCURSEL, 0, 0); break; default: if(cfg.EncCfg.quantqual<10) cfg.EncCfg.quantqual=10; if(cfg.EncCfg.quantqual>500) cfg.EncCfg.quantqual=500; sprintf(buf,"%lu",cfg.EncCfg.quantqual); SetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf); break; } switch(cfg.EncCfg.bitRate) { case 0: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0); break; default: sprintf(buf,"%lu",cfg.EncCfg.bitRate); SetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf); break; } switch(cfg.EncCfg.bandWidth) { case 0: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0); break; case 0xffffffff: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0); break; default: sprintf(buf,"%lu",cfg.EncCfg.bandWidth); SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf); break; } SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_SETCURSEL, cfg.SaveMP4, 0); if(wParam|lParam) { CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg); DISABLE_CTRLS_ENC(!cfg.AutoCfg); } #ifdef USE_IMPORT_TAG CheckDlgButton(hWndDlg,IDC_CHK_IMPORTTAG, cfg.TagImport); cfg.TagImport=IsDlgButtonChecked(hWndDlg,IDC_CHK_IMPORTTAG) ? 1 : 0; ShowWindow(GetDlgItem(hWndDlg, IDC_CHK_IMPORTTAG),SW_SHOW); #ifdef USE_PATHEXT SetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, cfg.TagSrcPath); SetDlgItemText(hWndDlg, IDC_E_SOURCEEXT, cfg.TagSrcExt); SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSEIMPORT), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse); ShowWindow(GetDlgItem(hWndDlg, IDC_E_SOURCEEXT),SW_SHOW); ShowWindow(GetDlgItem(hWndDlg, IDC_E_SOURCEPATH),SW_SHOW); ShowWindow(GetDlgItem(hWndDlg, IDC_BTN_BROWSEIMPORT),SW_SHOW); #endif #endif CheckDlgButton(hWndDlg,IDC_CHK_TAG, cfg.TagOn); ENABLE_TAG(cfg.TagOn && !cfg.TagImport); ENABLE_AACTAGS(cfg.TagOn && !cfg.TagImport && cfg.SaveMP4); SetDlgItemText(hWndDlg, IDC_E_ARTIST, cfg.Tag.artist); SetDlgItemText(hWndDlg, IDC_E_TITLE, cfg.Tag.title); SetDlgItemText(hWndDlg, IDC_E_ALBUM, cfg.Tag.album); SetDlgItemText(hWndDlg, IDC_E_YEAR, cfg.Tag.year); SetDlgItemText(hWndDlg, IDC_CB_GENRE, cfg.Tag.genre); SetDlgItemText(hWndDlg, IDC_E_WRITER, cfg.Tag.writer); SetDlgItemText(hWndDlg, IDC_E_COMMENT, cfg.Tag.comment); SetDlgItemText(hWndDlg, IDC_E_ARTFILE, cfg.Tag.artFilename); SetDlgItemInt(hWndDlg, IDC_E_TRACK, cfg.Tag.trackno, FALSE); SetDlgItemInt(hWndDlg, IDC_E_NTRACKS, cfg.Tag.ntracks, FALSE); SetDlgItemInt(hWndDlg, IDC_E_DISK, cfg.Tag.discno, FALSE); SetDlgItemInt(hWndDlg, IDC_E_NDISKS, cfg.Tag.ndiscs, FALSE); SetDlgItemInt(hWndDlg, IDC_E_COMPILATION, cfg.Tag.compilation, FALSE); CheckDlgButton(hWndDlg, IDC_CHK_COMPILATION, cfg.Tag.compilation); } break; // End of WM_INITDIALOG case WM_CLOSE: // Closing the Dialog behaves the same as Cancel PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L); break; // End of WM_CLOSE case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: { // HANDLE hCfg=(HANDLE)lParam; char buf[50]; CMyEncCfg cfg; cfg.AutoCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG) ? TRUE : FALSE; if(!cfg.AutoCfg) { cfg.EncCfg.mpegVersion=IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4) ? MPEG4 : MPEG2; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN)) cfg.EncCfg.aacObjectType=MAIN; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW)) cfg.EncCfg.aacObjectType=LOW; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR)) cfg.EncCfg.aacObjectType=SSR; if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) cfg.EncCfg.aacObjectType=LTP; cfg.EncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_CHK_ALLOWMIDSIDE); cfg.EncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_CHK_USETNS); cfg.EncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_CHK_USELFE); GetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf, 50); switch(*buf) { case 'A': // Auto cfg.EncCfg.bitRate=0; break; default: cfg.EncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE); } GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf, 50); switch(*buf) { case 'A': // Auto cfg.EncCfg.bandWidth=0; break; case 'F': // Full cfg.EncCfg.bandWidth=0xffffffff; break; default: cfg.EncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE); } cfg.UseQuality=IsDlgButtonChecked(hWndDlg,IDC_RADIO_QUALITY) ? TRUE : FALSE; GetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf, 50); switch(*buf) { case 'D': // Default cfg.EncCfg.quantqual=100; break; default: cfg.EncCfg.quantqual=GetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 0, FALSE); } } cfg.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? RAW : ADTS; #ifdef USE_OUTPUT_FOLDER GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH); FREE_ARRAY(cfg.OutDir); cfg.OutDir=strdup(config_AACoutdir); #endif cfg.SaveMP4=(BYTE)SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_GETCURSEL, 0, 0); cfg.TagOn=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG) ? 1 : 0; char buffer[MAX_PATH]; #ifdef USE_IMPORT_TAG cfg.TagImport=IsDlgButtonChecked(hWndDlg,IDC_CHK_IMPORTTAG) ? 1 : 0; #ifdef USE_PATHEXT GetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, buffer, MAX_PATH); cfg.TagSrcPath=strdup(buffer); GetDlgItemText(hWndDlg, IDC_E_SOURCEEXT, buffer, MAX_PATH); cfg.TagSrcExt=strdup(buffer); #endif #endif GetDlgItemText(hWndDlg, IDC_E_ARTIST, buffer, MAX_PATH); cfg.Tag.artist=strdup(buffer); GetDlgItemText(hWndDlg, IDC_E_TITLE, buffer, MAX_PATH); cfg.Tag.title=strdup(buffer); GetDlgItemText(hWndDlg, IDC_E_ALBUM, buffer, MAX_PATH); cfg.Tag.album=strdup(buffer); GetDlgItemText(hWndDlg, IDC_E_YEAR, buffer, MAX_PATH); cfg.Tag.year=strdup(buffer); GetDlgItemText(hWndDlg, IDC_CB_GENRE, buffer, MAX_PATH); cfg.Tag.genre=strdup(buffer); GetDlgItemText(hWndDlg, IDC_E_WRITER, buffer, MAX_PATH); cfg.Tag.writer=strdup(buffer); GetDlgItemText(hWndDlg, IDC_E_COMMENT, buffer, MAX_PATH); cfg.Tag.comment=strdup(buffer); GetDlgItemText(hWndDlg, IDC_E_ARTFILE, buffer, MAX_PATH); cfg.Tag.artFilename=strdup(buffer); cfg.Tag.trackno=GetDlgItemInt(hWndDlg, IDC_E_TRACK, 0, FALSE); cfg.Tag.ntracks=GetDlgItemInt(hWndDlg, IDC_E_NTRACKS, 0, FALSE); cfg.Tag.discno=GetDlgItemInt(hWndDlg, IDC_E_DISK, 0, FALSE); cfg.Tag.ndiscs=GetDlgItemInt(hWndDlg, IDC_E_NDISKS, 0, FALSE); cfg.Tag.compilation=(BYTE)GetDlgItemInt(hWndDlg, IDC_E_COMPILATION, 0, FALSE); cfg.Tag.compilation=IsDlgButtonChecked(hWndDlg, IDC_CHK_COMPILATION) ? 1 : 0; EndDialog(hWndDlg, TRUE);//(DWORD)hCfg); } break; case IDCANCEL: // Ignore data values entered into the controls // and dismiss the dialog window returning FALSE EndDialog(hWndDlg, FALSE); break; case IDC_BTN_ABOUT: DialogBox((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout); break; case IDC_BTN_LICENSE: { char *license = "\nPlease note that the use of this software may require the payment of patent royalties.\n" "You need to consider this issue before you start building derivative works.\n" "We are not warranting or indemnifying you in any way for patent royalities!\n" "YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n" "\n" "FAAC is based on the ISO MPEG-4 reference code. For this code base the\n" "following license applies:\n" "\n" /* "This software module was originally developed by\n" "\n" "FirstName LastName (CompanyName)\n" "\n" "and edited by\n" "\n" "FirstName LastName (CompanyName)\n" "FirstName LastName (CompanyName)\n" "\n" */ "in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n" "ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n" "implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n" "as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n" "users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n" "software module or modifications thereof for use in hardware or\n" "software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n" "standards. Those intending to use this software module in hardware or\n" "software products are advised that this use may infringe existing\n" "patents. The original developer of this software module and his/her\n" "company, the subsequent editors and their companies, and ISO/IEC have\n" "no liability for use of this software module or modifications thereof\n" "in an implementation. Copyright is not released for non MPEG-2\n" "NBC/MPEG-4 Audio conforming products. The original developer retains\n" "full right to use the code for his/her own purpose, assign or donate\n" "the code to a third party and to inhibit third party from using the\n" "code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n" "copyright notice must be included in all copies or derivative works.\n" "\n" "Copyright (c) 1997.\n" "\n" "For the changes made for the FAAC project the GNU Lesser General Public\n" "License (LGPL), version 2 1991 applies:\n" "\n" "FAAC - Freeware Advanced Audio Coder\n" "Copyright (C) 2001-2004 The individual contributors\n" "\n" "This library is free software; you can redistribute it and/or modify it under the terms of\n" "the GNU Lesser General Public License as published by the Free Software Foundation;\n" "either version 2.1 of the License, or (at your option) any later version.\n" "\n" "This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n" "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" "See the GNU Lesser General Public License for more details.\n" "\n" "You should have received a copy of the GNU Lesser General Public\n" "License along with this library; if not, write to the Free Software\n" "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"; MessageBox(hWndDlg,license,"FAAC libray License",MB_OK|MB_ICONINFORMATION); } break; #ifdef USE_OUTPUT_FOLDER case IDC_BTN_BROWSE: { BROWSEINFO bi; ITEMIDLIST *idlist; GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH); bi.hwndOwner = hWndDlg; bi.pidlRoot = 0; bi.pszDisplayName = config_AACoutdir; bi.lpszTitle = "Select a directory for aac/mp4 file output:"; bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = BrowseCallbackProc; bi.lParam = (LPARAM)config_AACoutdir; idlist = SHBrowseForFolder(&bi); if(idlist) { SHGetPathFromIDList(idlist, config_AACoutdir); SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir); } } break; #endif case IDC_BTN_ARTFILE: { OPENFILENAME ofn; char ArtFilename[MAX_PATH]=""; GetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename, MAX_PATH); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = (HWND)hWndDlg; ofn.lpstrFilter = "Cover art files (*.gif,*jpg,*.png)\0*.gif;*.jpg;*.png\0"; ofn.lpstrCustomFilter = NULL; ofn.nFilterIndex = 1; ofn.lpstrFile = ArtFilename; ofn.nMaxFile = MAX_PATH; //sizeof ArtFilename; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.lpstrTitle = "Select cover art file"; ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING; ofn.lpstrDefExt = NULL;//"jpg"; ofn.hInstance = hInstance; if(GetOpenFileName(&ofn)) SetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename); } break; #ifdef USE_IMPORT_TAG case IDC_BTN_BROWSEIMPORT: { char path[MAX_PATH]; BROWSEINFO bi; ITEMIDLIST *idlist; GetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, path, MAX_PATH); bi.hwndOwner = hWndDlg; bi.pidlRoot = 0; bi.pszDisplayName = path; bi.lpszTitle = "Select the folder where source files are stored:"; bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = BrowseCallbackProc; bi.lParam = (LPARAM)path; idlist=SHBrowseForFolder(&bi); if(idlist) { SHGetPathFromIDList(idlist, path); SetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, path); } } break; #endif case IDC_RADIO_MPEG4: EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG)); break; case IDC_RADIO_MPEG2: EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); DISABLE_LTP break; case IDC_CHK_AUTOCFG: { BYTE Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG); DISABLE_CTRLS_ENC(!Enabled); if(!Enabled) SendMessage(hWndDlg, WM_INITDIALOG, 0L, 0L); else { SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, DEF_QUALITY, FALSE); SetDlgItemInt(hWndDlg, IDC_CB_BITRATE, DEF_BITRATE, FALSE); SetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, DEF_BANDWIDTH, FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,FALSE); if(DEF_MPEGVER==MPEG4) CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE); else CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE); CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_SSR,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); switch(DEF_PROFILE) { case MAIN: CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); break; case LOW: CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE); break; case SSR: CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE); break; case LTP: CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE); DISABLE_LTP break; } CheckDlgButton(hWndDlg,IDC_RADIO_RAW,FALSE); CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,FALSE); switch(DEF_HEADER) { case RAW: CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE); break; case ADTS: CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE); break; } CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, DEF_MIDSIDE); CheckDlgButton(hWndDlg, IDC_CHK_USETNS, DEF_TNS); CheckDlgButton(hWndDlg, IDC_CHK_USELFE, DEF_LFE); if(DEF_USEQUALTY) CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,true); else CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,true); if(DEF_QUALITY<10) SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 10, FALSE); else if(DEF_QUALITY>500) SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 500, FALSE); else SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, DEF_QUALITY, FALSE); switch(DEF_BITRATE) { case 0: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0); // SetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 128, FALSE); break; default: SetDlgItemInt(hWndDlg, IDC_CB_BITRATE, DEF_BITRATE, FALSE); break; } switch(DEF_BANDWIDTH) { case 0: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0); break; case 0xffffffff: SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0); break; default: SetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, DEF_BANDWIDTH, FALSE); break; } SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_SETCURSEL, DEF_WRITEMP4, 0); // DISABLE_CTRLS_ENC(!Enabled); } } break; case IDC_CHK_TAG: case IDC_CB_EXT: { char TagImport=IsDlgButtonChecked(hWndDlg,IDC_CHK_IMPORTTAG); char TagEnabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG); ENABLE_TAG(TagEnabled && !TagImport); char Enabled=SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_GETCURSEL, 0, 0)!=0; ENABLE_AACTAGS(TagEnabled && !TagImport && Enabled); } break; #ifdef USE_IMPORT_TAG case IDC_CHK_IMPORTTAG: SendMessage(hWndDlg, WM_COMMAND, IDC_CHK_TAG, 0); break; #endif } break; // End of WM_COMMAND default: return FALSE; } return TRUE; } // End of DIALOGSMsgProc faac-1_30/common/Cfaac/EncDialog.h000066400000000000000000000002731355157314300167040ustar00rootroot00000000000000extern BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam); extern BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam); faac-1_30/common/Cfaac/FAAC.rc000066400000000000000000000274741355157314300157420ustar00rootroot00000000000000// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_ENCODER DIALOGEX 0, 0, 338, 219 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "MPEG4-AAC options" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN DEFPUSHBUTTON "&OK",IDOK,12,200,36,14 PUSHBUTTON "&Cancel",IDCANCEL,48,200,36,14 PUSHBUTTON "&About",IDC_BTN_ABOUT,84,200,36,14 PUSHBUTTON "&License",IDC_BTN_LICENSE,120,200,36,14 CONTROL "Automatic configuration",IDC_CHK_AUTOCFG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,4,4,90,10 CONTROL "Main",IDC_RADIO_MAIN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,28,31,10 CONTROL "LC",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,9,40,25, 10 CONTROL "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,9,52,29, 10 CONTROL "SSR",IDC_RADIO_SSR,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED,9,63,31,10 CONTROL "MPEG4",IDC_RADIO_MPEG4,"Button",BS_AUTORADIOBUTTON | WS_GROUP,62,27,40,10 CONTROL "MPEG2",IDC_RADIO_MPEG2,"Button",BS_AUTORADIOBUTTON,62, 40,40,9 CONTROL "Raw",IDC_RADIO_RAW,"Button",BS_AUTORADIOBUTTON | WS_GROUP,112,27,42,10 CONTROL "ADTS",IDC_RADIO_ADTS,"Button",BS_AUTORADIOBUTTON,112,40, 41,9 CONTROL "Quality",IDC_RADIO_QUALITY,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,84,37,10 COMBOBOX IDC_CB_QUALITY,102,81,48,97,CBS_DROPDOWN | WS_VSCROLL | WS_GROUP | WS_TABSTOP CONTROL "Bitrate",IDC_RADIO_BITRATE,"Button",BS_AUTORADIOBUTTON, 9,100,36,10 COMBOBOX IDC_CB_BITRATE,102,97,48,86,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP LTEXT "Cutoff",IDC_STATIC,21,121,20,8 COMBOBOX IDC_CB_BANDWIDTH,102,118,48,81,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP LTEXT "Write",IDC_STATIC,22,138,18,8 COMBOBOX IDC_CB_EXT,102,135,48,81,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Allow Mid/Side",IDC_CHK_ALLOWMIDSIDE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,9,152,63,10 CONTROL "Use TNS",IDC_CHK_USETNS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,9,162,45,10 CONTROL "Use LFE channel",IDC_CHK_USELFE,"Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,88,152,67,10 EDITTEXT IDC_E_BROWSE,50,172,83,14,ES_AUTOHSCROLL PUSHBUTTON "Browse",IDC_BTN_BROWSE,137,172,18,14,BS_BITMAP | BS_FLAT GROUPBOX "",IDC_GRP_TAG,160,4,174,210 CONTROL "Tag",IDC_CHK_TAG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 165,3,29,10 CONTROL "Import",IDC_CHK_IMPORTTAG,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,165,15,35,10 EDITTEXT IDC_E_SOURCEPATH,207,11,63,14,ES_AUTOHSCROLL | NOT WS_VISIBLE PUSHBUTTON "Browse",IDC_BTN_BROWSEIMPORT,273,11,18,14,BS_BITMAP | BS_FLAT | NOT WS_VISIBLE EDITTEXT IDC_E_SOURCEEXT,294,11,34,14,ES_AUTOHSCROLL | NOT WS_VISIBLE EDITTEXT IDC_E_ARTIST,207,27,121,14,ES_AUTOHSCROLL EDITTEXT IDC_E_TITLE,207,42,121,14,ES_AUTOHSCROLL EDITTEXT IDC_E_ALBUM,207,57,121,14,ES_AUTOHSCROLL EDITTEXT IDC_E_YEAR,207,72,121,14,ES_AUTOHSCROLL COMBOBOX IDC_CB_GENRE,207,87,121,161,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_E_WRITER,207,101,121,14,ES_AUTOHSCROLL EDITTEXT IDC_E_COMMENT,207,116,121,29,ES_MULTILINE | ES_AUTOHSCROLL EDITTEXT IDC_E_COMPILATION,207,146,121,14,ES_AUTOHSCROLL | NOT WS_VISIBLE CONTROL "Part of a compilation",IDC_CHK_COMPILATION,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,165,148,80,10 EDITTEXT IDC_E_TRACK,233,162,40,14,ES_AUTOHSCROLL EDITTEXT IDC_E_NTRACKS,288,162,40,14,ES_AUTOHSCROLL EDITTEXT IDC_E_DISK,233,177,40,14,ES_AUTOHSCROLL EDITTEXT IDC_E_NDISKS,288,177,40,14,ES_AUTOHSCROLL EDITTEXT IDC_E_ARTFILE,207,192,98,14,ES_AUTOHSCROLL PUSHBUTTON "&...",IDC_BTN_ARTFILE,311,192,17,14,BS_BITMAP | BS_FLAT GROUPBOX "AAC type",IDC_STATIC,56,16,48,52 GROUPBOX "Profile",IDC_STATIC,4,16,48,52 GROUPBOX "Header",IDC_STATIC,108,16,48,52 GROUPBOX "Encoding mode",IDC_STATIC,4,73,152,42 LTEXT "Artist",IDC_STATIC,165,29,16,8 LTEXT "Title",IDC_STATIC,165,44,14,8 LTEXT "Album",IDC_STATIC,165,59,20,8 LTEXT "Year",IDC_STATIC,165,74,16,8 LTEXT "Genre",IDC_STATIC,165,89,20,8 LTEXT "Writer",IDC_STATIC,165,103,20,8 LTEXT "Comment\n(ctrl-Enter\nto go down)",IDC_STATIC,165,118, 37,26 LTEXT "Track",IDC_STATIC,165,166,20,8 LTEXT "/",IDC_STATIC,277,166,8,8 LTEXT "Disk",IDC_STATIC,165,180,15,8 LTEXT "/",IDC_STATIC,277,180,8,8 LTEXT "Cover art file",IDC_STATIC,165,195,40,8 LTEXT "Output folder",IDC_L_BROWSE,4,175,42,8 END IDD_DECODER DIALOGEX 0, 0, 162, 153 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Raw .AAC options" FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN DEFPUSHBUTTON "&OK",IDOK,47,132,36,14 PUSHBUTTON "&Cancel",IDCANCEL,83,132,36,14 PUSHBUTTON "&About",IDC_BTN_ABOUT,119,132,36,14 CONTROL "Main",IDC_RADIO_MAIN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,19,33,31,10 CONTROL "Low",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,19,44,29, 10 CONTROL "SSR",IDC_RADIO_SSR,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,19,56,31,10 CONTROL "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,19,68,29, 10 GROUPBOX "Profile",IDC_STATIC,13,23,48,70 COMBOBOX IDC_CB_SAMPLERATE,72,74,69,87,CBS_DROPDOWN | WS_DISABLED | WS_VSCROLL | WS_TABSTOP CONTROL "Default settings",IDC_CHK_DEFAULTCFG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,7,64,10 GROUPBOX "Sample rate",IDC_STATIC,66,61,81,32 CONTROL "HE",IDC_RADIO_HE,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,19,80,26,10 CONTROL "Down matrix 5.1 to 2 channels",IDC_CHK_DOWNMATRIX, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,98,111,10 CONTROL "Assume old ADTS format",IDC_CHK_OLDADTS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,110,95,10 COMBOBOX IDC_CB_BITSPERSAMPLE,72,35,69,87,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP GROUPBOX "Output bits per sample",IDC_STATIC,66,23,81,32 GROUPBOX "",IDC_GRP_DEFAULT,7,8,147,118 END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN IDD_ENCODER, DIALOG BEGIN LEFTMARGIN, 4 RIGHTMARGIN, 334 TOPMARGIN, 4 BOTTOMMARGIN, 214 END IDD_DECODER, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 154 TOPMARGIN, 7 BOTTOMMARGIN, 146 END END #endif // APSTUDIO_INVOKED #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Italian (Italy) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA) #ifdef _WIN32 LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_ABOUT DIALOGEX 0, 0, 191, 230 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION CAPTION "About" FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN DEFPUSHBUTTON "&OK",IDOK,145,208,39,14 CONTROL 104,IDC_AUDIOCODING,"Static",SS_BITMAP | SS_NOTIFY | SS_SUNKEN,7,7,178,69 CONTROL 107,IDC_MPEG4IP,"Static",SS_BITMAP | SS_NOTIFY | SS_SUNKEN,7,202,59,20 CONTROL 106,IDC_EMAIL,"Static",SS_BITMAP | SS_NOTIFY,96,204,43, 18 LTEXT "Text",IDC_L_ABOUT,7,55,177,142 ICON IDI_ID3,IDC_ID3,70,202,20,20,SS_NOTIFY | SS_SUNKEN END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN IDD_ABOUT, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 184 TOPMARGIN, 7 BOTTOMMARGIN, 222 END END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Bitmap // IDB_AUDIOCODING BITMAP "AudioCoding.bmp" IDB_EMAIL BITMAP "Email.bmp" IDB_MPEG4IP BITMAP "mpeg4ip-v.bmp" IDB_BROWSE BITMAP "Open.bmp" ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ID3 ICON "id3v2.ico" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,3,0,0 PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "041004b0" BEGIN VALUE "FileDescription", "CFAAC" VALUE "FileVersion", "1, 3, 0, 0" VALUE "InternalName", "FAAC" VALUE "LegalCopyright", "Copyright (C) 2004" VALUE "OriginalFilename", "FAAC.dll" VALUE "ProductName", " FAAC Dynamic Link Library" VALUE "ProductVersion", "1, 0, 0, 0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x410, 1200 END END #endif // Italian (Italy) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED faac-1_30/common/Cfaac/Open.bmp000066400000000000000000000003661355157314300163120ustar00rootroot00000000000000BMv(''ʦ wwwwwwUUUUUU'Ufffe'FFFCWdddRWQEFDF$WQ4WUUUUUUDWDDDDWAAWUUPQUPfaac-1_30/common/Cfaac/ReadMe.txt000066400000000000000000000016661355157314300166130ustar00rootroot00000000000000+----------------------------------------------------------------+ | | | Cfaac Readme | | ------------ | | | +----------------------------------------------------------------+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. ---------------------------------------------------------------------------- Cfaac is a set of classes to develop plugins (to import/export .aac/.mp4 files) with ease. ---------------------------------------------------------------------------- For suggestions, bugs report, etc., you can contact me at ntnfrn_email-temp@yahoo.it faac-1_30/common/Cfaac/TypeDef.h000066400000000000000000000024441355157314300164210ustar00rootroot00000000000000/* FAAC - codec plugin for Cooledit Copyright (C) 2002-2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ //--------------------------------------------------------------------------- #ifndef TypeDefH #define TypeDefH //--------------------------------------------------------------------------- /* typedef.h */ #ifndef BYTE typedef unsigned char BYTE; #endif #ifndef WORD typedef unsigned short WORD; #endif #ifndef DWORD typedef unsigned long DWORD; #endif #ifndef QWORD typedef unsigned __int64 QWORD; #endif //--------------------------------------------------------------------------- #endif //--------------------------------------------------------------------------- faac-1_30/common/Cfaac/id3v2.ico000066400000000000000000000013761355157314300163360ustar00rootroot00000000000000 ( @999ccc{{{cZPpP0P @P@A 0DP@ED @PE"TT1PTPBp@@  P   P? #1!9  !?faac-1_30/common/Cfaac/mpeg4ip-v.bmp000066400000000000000000000063441355157314300172230ustar00rootroot00000000000000BM :(V   cƻDzu4ͼ|A\Jwk˹ƩƬĥjQ|˾ex:{=Ĺr^az<¡}~DlWw7x:pRhNɶgĶfy<lȾ`µy;g{?VngGǵͿc^|@}Brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr[P@Q[@r[ @rrrr@c @@  $r @rrr@ [r@ uuuu ruuuuurr: /..!P !!![rrr@P!!!!!!!/EQ!!/!/HcPrrrPH! Pg''`P g''' @rr] /.@$ @$!P !!![rrr@P!!!!!!!/[r!/!!!q!!BcPPPH!!rg''gP g''' @rrr !/r!! !/!P W!/!/[rrr@P!///!!Q!!/! /!/!Bcr r[H!/!@_'''gP g''F @rrrr !/:B!! !/!P W!/!/[rrr@P!//!7.!//!r !/!7 ////H[X'''gP g''F @rrrr !/c//!B !/!P W!/!/[rrr@P!// EPPZ !//!@!/!7!!!!////!!w'''gP g''F @rrrr //!!/[./!P !/!![rrr@P!!/ @Pr !/!!r!/!7!/!////!!w'''gP g''F @rrrr W!///!/.!/!P W!/!/[EPP@@P!//.EPPr !//!r!/!7$!!7.H!/!BX'''gP '''FrPPPr %6%lP % @@%%:r%%%?%%Z:0%%l58O2P e854p r@ l0600006600P 0000000:P000000]60000000?000?000l P58O2P e8882r 0000600P 000000P000000]6000%0crt?00l P58O2P e888O5 l000l00?0l00P l0000?000rt00000%]60000:ccr@0Q$000l P58O2P e8oOI HH$HH$P ?:6@.@rP[7H$ P5L^^K2P AL^LA 2L^Lz /!Hq$HB!!P !!!!!!7 !!! PaPr !!! 77B q7!! P_'''gP g''Fr_g'g- !///!!!////!P W!/!//!!7 !// EPPr !//!H!HPP!!7!/! P_'''gP '''Fr_''g- !///!/!////!P W!/!//!!7 !// @P@.!//! 7!/!7P[q!HH//! P_'''gP '''Fr_''g- !///!/c/////!P W!/!/!/! r!//!7. ]!//! H!/! PPr!////! P_'''gP g''Fuzg'gz !///! /!///!P W!///H///!///!!7r!!/! /// P@@@!////! P_'''gP g'''F'''g !!!r:/!!!!P !!!!!!/!!!!!7 r!/!!//H[PrrP!!!!! Pg''`P g'''g''gu /HHH/.@ /HHH/@ /HHHHHHPP/qHHHH/  /!!![@@rrP/HHH/ P_'FF'P A'FFFFFz4rr[[[@r[[[[@rQ[[[[[cr@@@[[[[[[Qr@  Prrrrrc[[[Qr@ruuuu r uuuuu rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrfaac-1_30/common/Cfaac/resource.h000066400000000000000000000064251355157314300167130ustar00rootroot00000000000000//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by FAAC.rc // #define IDD_ENCODER 101 #define IDD_DECODER 102 #define IDD_ABOUT 103 #define IDB_AUDIOCODING 104 #define IDB_EMAIL 106 #define IDB_MPEG4IP 107 #define IDB_BROWSE 108 #define IDI_ID3 110 #define IDC_CHK_DEFAULTCFG 1000 #define IDC_CHK_DOWNMATRIX 1001 #define IDC_CHK_OLDADTS 1002 #define IDC_CB_SAMPLERATE 1003 #define IDC_AUDIOCODING 1004 #define IDC_CB_BITSPERSAMPLE 1004 #define IDC_EMAIL 1005 #define IDC_MPEG4IP 1006 #define IDC_E_BROWSE 1007 #define IDC_BTN_BROWSE 1008 #define IDC_RADIO_MPEG4 1009 #define IDC_RADIO_MPEG2 1010 #define IDC_RADIO_LOW 1011 #define IDC_RADIO_MAIN 1012 #define IDC_RADIO_SSR 1013 #define IDC_RADIO_LTP 1014 #define IDC_RADIO_RAW 1015 #define IDC_RADIO_HE 1016 #define IDC_BTN_BROWSE2 1016 #define IDC_BTN_BROWSEIMPORT 1016 #define IDC_RADIO_ADTS 1017 #define IDC_CB_BANDWIDTH 1018 #define IDC_CB_BITRATE 1019 #define IDC_CHK_ALLOWMIDSIDE 1020 #define IDC_CHK_USETNS 1021 #define IDC_CHK_USELFE 1022 #define IDC_CHK_AUTOCFG 1023 #define IDC_BTN_ABOUT 1024 #define IDC_L_ABOUT 1025 #define IDC_BTN_ARTFILE 1026 #define IDC_CHK_USETNS2 1027 #define IDC_CB_EXT 1028 #define IDC_RADIO_BITRATE 1030 #define IDC_RADIO_QUALITY 1031 #define IDC_CB_QUALITY 1032 #define IDC_E_ARTIST 1034 #define IDC_CHK_TAG 1035 #define IDC_E_TITLE 1036 #define IDC_E_ALBUM 1037 #define IDC_E_YEAR 1038 #define IDC_CB_GENRE 1039 #define IDC_E_WRITER 1040 #define IDC_E_COMMENT 1041 #define IDC_E_TRACK 1042 #define IDC_E_NTRACKS 1043 #define IDC_E_DISK 1044 #define IDC_E_NDISKS 1045 #define IDC_GRP_TAG 1046 #define IDC_E_COMPILATION 1047 #define IDC_E_ARTFILE 1048 #define IDC_BTN_LICENSE 1049 #define IDC_CHK_COMPILATION 1050 #define IDC_GRP_DEFAULT 1051 #define IDC_ID3 1052 #define IDC_L_BROWSE 1054 #define IDC_CHK_IMPORTTAG 1055 #define IDC_E_SOURCEEXT 1056 #define IDC_E_SOURCEPATH 1057 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 111 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1057 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif faac-1_30/common/Makefile.am000066400000000000000000000000121355157314300157340ustar00rootroot00000000000000SUBDIRS = faac-1_30/configure.ac000066400000000000000000000032271355157314300147110ustar00rootroot00000000000000AC_PREREQ(2.50) AC_INIT(faac, 1.30, https://sourceforge.net/p/faac/bugs/) AC_CONFIG_AUX_DIR(.) AM_INIT_AUTOMAKE([subdir-objects]) AM_CONFIG_HEADER(config.h) AH_TOP([#ifndef CONFIG_H #define CONFIG_H]) AH_BOTTOM([#endif /* CONFIG_H */]) AC_ARG_ENABLE( drm, [ --enable-drm Digital Radio Mondiale support], enable_drm=$enableval, enable_drm=no) AC_DEFUN([MY_DEFINE], [ AC_DEFINE($1, 1, [define if needed]) ]) CFLAGS=${CFLAGS:-"-O2 -Wall -fexceptions"} AC_PROG_CC AC_PROG_CXX AM_PROG_LIBTOOL AC_CHECK_HEADERS(getopt.h immintrin.h) AC_CHECK_DECL(strcasecmp, MY_DEFINE(HAVE_STRCASECMP)) AC_CHECK_LIB(gnugetopt, getopt_long) dnl Check for DRM mode if test "x$enable_drm" = "xyes"; then AC_DEFINE(DRM, 1, [Define if you want to encode for DRM]) AM_CONDITIONAL(USE_DRM, true) CFLAGS="$CFLAGS -DDRM" else AM_CONDITIONAL(USE_DRM, false) fi AM_CONDITIONAL(MINGW, test "$host_os" = "mingw32") AM_CONDITIONAL(CPUSSE, test "$host_cpu" = "x86_64" || test "$host_cpu" = "i686") AC_CHECK_TOOL(WINDRES, windres) AC_C_BIGENDIAN dnl Checks for header files required for mp4.h AC_HEADER_STDC AC_SYS_LARGEFILE AC_CHECK_HEADERS(stdint.h inttypes.h) AC_CHECK_HEADERS(mathf.h) AC_CHECK_HEADERS(float.h) AC_CHECK_DECL(strchr, MY_DEFINE(HAVE_STRCHR)) AC_CHECK_DECL(memcpy, MY_DEFINE(HAVE_MEMCPY)) AC_CHECK_DECL(strsep, MY_DEFINE(HAVE_STRSEP)) AC_CHECK_HEADERS(sys/time.h) AC_HEADER_TIME AC_TYPE_OFF_T AC_CHECK_TYPES([in_port_t, socklen_t], , , [#include #include #include ]) AC_CHECK_MEMBERS(fpos_t.__pos,,, [#include ]) AC_OUTPUT([ common/Makefile libfaac/Makefile frontend/Makefile include/Makefile Makefile]) faac-1_30/docs/000077500000000000000000000000001355157314300133475ustar00rootroot00000000000000faac-1_30/docs/faac.1000066400000000000000000000114621355157314300143270ustar00rootroot00000000000000.TH FAAC 1 "2017-08-16" "1.29.5" "Free Advanced Audio Coder" .SH NAME faac \- open source MPEG-4 and MPEG-2 AAC encoder .SH SYNOPSIS .B faac .RI [ options ] .RI [\-o\ outfile ] .I infiles .RI ... .PP .RI < infiles > and/or .RI < outfile > can be "\-", which means stdin/stdout. .SH DESCRIPTION .B FAAC is an open source MPEG-4 and MPEG-2 AAC encoder, it is licensed under the LGPL license. Note that the quality of .B FAAC is not up to par with the currently best AAC encoders available. .SH FEATURES .TP * Portable .TP * Fast .TP * LC, Main, LTP support .TP * DRM support through DreaM (optional) .SH HELP OPTIONS .TP .BR -h Short help on using FAAC .TP .BR -H Description of all options for FAAC .TP .BR --license License terms for FAAC. .TP .BR --help-qual Quality-related options .TP .BR --help-io Input/output options .TP .BR --help-mp4 MP4 specific options Quality-related options .TP .BR --help-advanced Advanced options, only for testing purposes .SH QUALITY-RELATED OPTIONS .TP .BR -q\ <\fIquality\fP> Set encoding quality. Set default variable bitrate (VBR) quality level in percent. max. 5000, min. 10. default: 100, averages at approx. 120 kbps VBR for a normal stereo input file with 16 bit and 44.1 kHz sample rate .TP .BR -b\ <\fIbitrate\fP> Set average bitrate (ABR) to approximately kbps. max. ~500 (stereo) .TP .BR -c\ <\fIfreq\fP> Set the bandwidth in Hz. The actual frequency is adjusted to maximize upper spectral band usage. .SH INPUT/OUTPUT OPTIONS .TP .BR -o\ <\fIfilename\fP> Set output file to X (only for one input file) only for one input file; you can use *.aac, *.mp4, *.m4a or *.m4b as file extension, and the file format will be set automatically to ADTS or MP4). .TP .BR - Use stdin/stdout. If you simply use a hyphen/minus sign instead of a filename, FAAC can encode directly from stdin, thus enabling piping from other applications and utilities. The same works for stdout as well, so FAAC can pipe its output to other apps such as a server. .TP .BR -v\ <\fIvebose\fP> Verbosity level (-v0 is quiet mode) .TP .BR -r Use RAW AAC output file. Generate raw AAC bitstream (i.e. without any headers). Not advised!!!, RAW AAC files are practically useless!!! .TP .BR -P Raw PCM input mode (default 44100Hz 16bit stereo). Raw PCM input mode (default: off, i.e. expecting a WAV header; necessary for input files or bitstreams without a header; using only -P assumes the default values for -R, -B and -C in the input file). .TP .BR -R\ <\fIsamplerate\fP> Raw PCM input rate. Raw PCM input sample rate in Hz (default: 44100 Hz, max. 96 kHz) .TP .BR -B\ <\fIsamplebits\fP> Raw PCM input sample size (8, 16 (default), 24 or 32bits). Raw PCM input sample size (default: 16, also possible 8, 24, 32 bit fixed or float input). .TP .BR -C\ <\fIchannels\fP> Raw PCM input channels. Raw PCM input channels (default: 2, max. 33 + 1 LFE). .TP .BR -X Raw PCM swap input bytes Raw PCM swap input bytes (default: bigendian). .TP .BR -I\ <\fIC[,LFE]\fP> Input channel config, default is 3,4 (Center third, LF fourth) Input multichannel configuration (default: 3,4 which means Center is third and LFE is fourth like in 5.1 WAV, so you only have to specify a different position of these two mono channels in your multichannel input files if they haven't been reordered already). .TP .BR --ignorelength Ignore wav length from header (useful with files over 4 GB) .TP .BR --overwrite Overwrite existing output file .SH MP4 SPECIFIC OPTIONS .TP .BR -w Wrap AAC data in MP4 container. (default for *.mp4, *.m4a and *.m4b) .TP .BR --tag\ <\fItagname,tagvalue\fP> Add named tag (iTunes '----') .TP .BR --artist\ <\fIname\fP> Set artist name .TP .BR --composer\ <\fIname\fP> Set composer name .TP .BR --title\ <\fIname\fP> Set title/track name .TP .BR --genre\ <\fInumber\fP> Set genre number .TP .BR --album\ <\fIname\fP> Set album/performer .TP .BR --compilation Mark as compilation .TP .BR --track\ <\fInumber/total\fP> Set track number .TP .BR --disc\ <\fInumber/total\fP> Set disc number .TP .BR --year\ <\fInumber\fP> Set year .TP .BR --cover-art\ <\fIfilename\fP> Read cover art from file X Supported image formats are GIF, JPEG, and PNG. .TP .BR --comment\ <\fIstring\fP> Set comment .SH ADVANCED OPTIONS, ONLY FOR TESTING PURPOSES .TP .BR --tns Enable coding of TNS, temporal noise shaping. .TP .BR --no-tns Disable coding of TNS, temporal noise shaping. .TP .BR --no-midside Don't use mid/side coding. .TP .BR --mpeg-vers\ \fIX\fP Force AAC MPEG version, X can be 2 or 4 .TP .BR --shortctl\ \fIX\fP Enforce block type (0 = both (default); 1 = no short; 2 = no long). .SH AUTHORS .B FAAC was written by M. Bakker . .PP .nh 2 Developed and maintained by Krzysztof Nikiel . .PP This manpage was written by Fabian Greffrath for the Debian Unofficial project (but may be used by others, of course). .nh 1 faac-1_30/docs/faac.html000066400000000000000000000162321355157314300151330ustar00rootroot00000000000000 FAAC - Freeware Advanced Audio Coder

FAAC 1.18 beta (www.audiocoding.com)


Contents

  • Usage
  • options
  • notes
  • Copyrights
  • Patents
  • People


  • Usage

    (More up to date info can be found at
    FAAC wiki page by Hans-Jürgen Bardenhagen)

    faac [options] <infile> <outfile>

    Options:
  • -a X Set average bitrate to approximately X kbps per channel (i.e. using -a 64 averages at 128 kbps/stereo).
  • -c <bandwidth> Set the bandwidth in Hz (default value depends on sample rate)
  • -q <quality> Set quantizer quality (default: 100, averages at approx. 128 kbps VBR for a normal stereo input file at 16 bit and 44.1 kHz sample rate).
  • --tns Enable TNS coding.
  • --notns Disable TNS coding.
  • -n Disable mid/side coding.
  • -m X AAC MPEG version, X can be 2 or 4 (default: MPEG-2, so for the sake of interoperability with non-standard compliant players like QuickTime 6 you should set it to "4").
  • -o X AAC object type, X can be LC, MAIN or LTP (default: LC, for the same reason as with the MPEG version don't use Main or LTP).
  • -r RAW AAC output file (i.e. without ADTS headers).
  • -P Raw PCM input mode.
  • -R Raw PCM input sample rate in Hz (default: 44100 Hz).
  • -B Raw PCM input bit depth (default: 16 bits, also possible 8 bits).
  • -C Raw PCM input channels (default: 2).
  • - <stdin> If you simply use a hyphen/minus sign instead of an input file name, FAAC can encode directly from stdin, thus enabling piping within other applications like foobar2000 or mp4live.

    Note: VBR output bitrate depends on -q AND -c, so you should only vary the default setting -q 100 -c 16000 if you know what you're doing and/or want to experiment with other cutoff frequencies at a given quality setting.

    The ABR setting with -a is an approximate average bitrate that does not use a bit reservoir, i.e -a 64 and -q 100 at 44.1 kHz will result in exactly the same output file.

    The following list should give some orientation for useful -q and -c settings, based on FAAC v1.17. The resulting VBR bitrates are referring to an average sounding stereo file with 16bit, 44.1 kHz, i.e. ct_reference.wav in this case. Multiplexing these AAC files to MP4 with e.g. mp4creator will result in a ~3 kbps lower bitrate because of the stripped ADTS headers:

    -q 130 -c 22000 -m 4 (~218 kbps)
    -q 120 -c 20000 -m 4 (~194 kbps)
    -q 110 -c 18000 -m 4 (~158 kbps)
    -q 100 -c 16000 -m 4 (~129 kbps)
    -q 90 -c 14000 -m 4 (~103 kbps)
    -q 80 -c 12000 -m 4 (~79 kbps)
    -q 70 -c 10000 -m 4 (~62 kbps)

    The added -m 4 switch does not change the bitrate or sound of course, but is recommended for most AAC/MP4 players that use an updated FAAD2-based plugin from this year (Winamp 2.x, foobar2000 etc.) or can't decode MPEG-2 AAC LC files like QuickTime 6. Philips Expanium users should not use this switch, because their CD portable does not know MPEG-4 AAC files.



    Copyrights

    FAAC - Freeware Advanced Audio Coder (
    www.audiocoding.com)
    	Portions Copyright © 1999,2000,2001 Menno Bakker
    	Portions Copyright © 2002,2003 Krzysztof Nikiel
    
    FAAC is based on the ISO MPEG-4 reference code. For this base code the following license applies:
    This software module was originally developed by
    
    FirstName LastName (CompanyName)
    
    and edited by
    
    FirstName LastName (CompanyName)
    FirstName LastName (CompanyName)
    
    in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard
    ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an
    implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools
    as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives
    users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this
    software module or modifications thereof for use in hardware or
    software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio
    standards. Those intending to use this software module in hardware or
    software products are advised that this use may infringe existing
    patents. The original developer of this software module and his/her
    company, the subsequent editors and their companies, and ISO/IEC have
    no liability for use of this software module or modifications thereof
    in an implementation. Copyright is not released for non MPEG-2
    NBC/MPEG-4 Audio conforming products. The original developer retains
    full right to use the code for his/her own purpose, assign or donate
    the code to a third party and to inhibit third party from using the
    code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This
    copyright notice must be included in all copies or derivative works.
    
    Copyright © 1997.
    

    For the changes made for the FAAC project the GNU Library General Public License (LGPL), version 2 1991 applies. For the changes the following statement applies:
    FAAC - Freeware Advanced Audio Coder
    Copyright © 1999,2000,2001,2002,2003 FAAC developers
    
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
    
    This library 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
    Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    

    Patents

    Please note that the use of this software may require the payment of patent royalties. You need to consider this issue before you start building derivative works. We are not warranting or indemnifying you in any way for patent royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!



    People

    Currently maintained by M. Bakker (menno)


    Other contributors:
    Tony Lenox
    RageOMatic
    thebard
    Ivan Dimkovic
    Krzysztof Nikiel (knik)
    Janne Hyvrinen (ca5e)
    Stuart Espey (stux)
    Andrew Voznytsa
    Mns Rullgrd
    Bill May


    Copyright © 2003 AudioCoding.com
    faac-1_30/docs/libfaac.html000066400000000000000000000114511355157314300156200ustar00rootroot00000000000000 FAAC - ISO/MPEG 2/4 AAC Encoder Library

    FAAC - ISO/MPEG 2/4 AAC Encoder Library version 1.0
    (www.audiocoding.com)

    Contents

  • Scope
  • Interface description
  • Usage
  • Calling sequence
  • Function reference
  • Initialization / De-initialization
  • faacEncOpen()
  • faacEncClose()
  • Encoder configuration
  • faacEncGetCurrentConfiguration()
  • faacEncSetConfiguration()
  • Encoding functions
  • faacEncEncode()
  • Data structures reference
  • faacEncConfiguration
  • Scope

    This document describes the interface and usage of the FAAC - ISO/MPEG 2/4 AAC Encoder Library Developed for the Freeware Advanced Audio Coding project.

    Interface description

    The ISO/MPEG 2/4 AAC Encoder Library provides a high-level interface for encoding MPEG2 and MPEG4 ISO AAC files. The following header file is provided for usage in C/C++ programs:

    faac.h: function prototypes

    The encoder core resides in a statically linkable library called libfaac.lib (Microsoft Windows) or libfaac.a (UNIX). There are various example programs that show how to use the library.

    Usage

    Calling sequence

    For encoding AAC bitstreams the following calling sequence is mandatory:
  • Call faacEncOpen() for every encoder instance you need.
  • To set encoder options, call faacEncGetCurrentConfiguration(), change the parameters in the structure accessible by the returned pointer and then call faacEncSetConfiguration().
  • As long as there are still samples left to encode, call faacEncEncode() to encode the data. The encoder returns the bitstream data in a client-supplied buffer.
  • Once you call faacEncEncode() with zero samples of input the flushing process is initiated; afterwards you may call faacEncEncode() with zero samples input only.
    faacEncEncode() will continue to write out data until all audio samples have been encoded.
  • Once faacEncEncode() has returned with zero bytes written, call faacEncClose() to destroy this encoder instance.
  • Function reference

    Initialization / De-initialization

    faacEncOpen()
    Prototype
    faacEncHandle FAACAPI faacEncOpen
    (
    unsigned long sampleRate,
    unsigned int numChannels,
    unsigned long *inputSamples,
    unsigned long *maxOutputBytes
    );
    Description
    Open and initialize one instance of the encoder.
    Parameters
    
  • sampleRate The samplerate of the encoder input data.
  • numChannels The number of channels of the encoder input data.
  • inputSamples Receives the total number of samples that should be fed to faacEncEncode() in each call.
  • maxOutputBytes Receives the maximum number of bytes that can be in the output buffer after a call to faacEncEncode(). Return value An initialized encoder handle. If anything goes wrong NULL is returned.
  • faacEncClose()
    Prototype
    void FAACAPI faacEncClose
    (
    faacEncHandle hEncoder
    );
    Description
    Closes an encoder instance.
    Parameters
    
  • hEncoder An encoder handle returned by faacEncOpen().
  • Encoder configuration

    faacEncGetCurrentConfiguration()
    Prototype
    faacEncConfigurationPtr FAACAPI
    faacEncGetCurrentConfiguration
    (
    faacEncHandle hEncoder
    );
    Description
    Get a pointer to a structure describing the current encoder
    configuration. You may change this structure and feed it into
    faacEncSetConfiguration().
    
    faacEncSetConfiguration()
    Prototype
    int FAACAPI faacEncSetConfiguration
    (
    faacDecHandle hDecoder,
    faacEncConfigurationPtr config
    );
    Description
    Set a new encoder configuration. See
    faacEncGetCurrentConfiguration().
    


    Copyright © 2001,2003
    AudioCoding.com. All rights reserved.
    faac-1_30/docs/libfaac.pdf000066400000000000000000000616711355157314300154360ustar00rootroot00000000000000%PDF-1.2 % 12 0 obj << /Length 13 0 R /Filter /FlateDecode >> stream Hn0 te~;7M6`FznK 7$ˋӤ( lQG*1(%tkH%E6[nftկD VUx]AV!BOB1JB~IQ0ZLQkY(?H2XgYbwr ڂCP\eHtf\zVO{"T1mVHdmgg^F,0% endstream endobj 13 0 obj 461 endobj 4 0 obj << /Type /Page /Parent 5 0 R /Resources << /Font << /F0 6 0 R /F1 8 0 R /F2 10 0 R >> /ProcSet 2 0 R >> /Contents 12 0 R >> endobj 17 0 obj << /Length 18 0 R /Filter /FlateDecode >> stream HWMo8<u"@] =UdC@NeEׯDiɎ6#J͛ym9Q V݄\lAT_&SOi5Z@#Z3ϝ[}څ A@EXejCX}  0_P_k}+Rf)F0._D_ˤrT6[PD) ,CS ~JVh6&i>;uՔĘF#L DBXe)vYH VTt"&Բ")ƥ6|lJ Q9ʡ\2$~l!ͣVr=r`mG7,Fic xC"y mDGQ#p 4PRQKmܰٸ zpECKҜTbtVN]nm6{ 3cKP\%imZ/|S8̀tҟ+U74̛Miv*fx&_Y " 'XS&bQK3s#н1,U,yk;"u,3.ޙLLzq:-6QB `%.EZO!Tf*7+_/ + ..%h+n_f[ c BwoJ8FjN#axixe. 1~ u'PTQ%ҽrX endstream endobj 18 0 obj 1044 endobj 14 0 obj << /Type /Page /Parent 5 0 R /Resources << /Font << /F0 6 0 R /F1 8 0 R /F2 10 0 R /F3 15 0 R >> /ProcSet 2 0 R >> /Contents 17 0 R >> endobj 20 0 obj << /Length 21 0 R /Filter /FlateDecode >> stream Hn0 ŠHY}50`ؽk+.~sca'ʟLs&AK%@8 [8hVUD.8CWP?L2ae.ʰTeLBrNCǔ3B.abTKDJj÷VEB~chUov쌅m*J)Q + 7# _**&<0(;TrԌ.Iy2襘7I*R|.p!,a8*5ܶ㣉>;<ؘ|K< QʸЍNP.m"*3w{p2vߴ9>Eox!gNŧe`S?tՏ+FO<2!z.XO-^&?`l +sJzܺABG<_n&:؏6<7{jEfv|0EMvc[gH endstream endobj 21 0 obj 467 endobj 19 0 obj << /Type /Page /Parent 5 0 R /Resources << /Font << /F0 6 0 R /F1 8 0 R /F2 10 0 R >> /ProcSet 2 0 R >> /Contents 20 0 R >> endobj 23 0 obj << /Length 24 0 R /Filter /FlateDecode >> stream HUn0;6Ls,E-Pw9ȔV I/7mӠ0zΛG]/$F@R/ܫbuA"(F$Wfo ,¯\O4IC :)A1EY%K(,baJIĺ>?")eLxquUe4ot _ $4 *,=,t0fMB^a=QْHDE@2+eӖXKI=-AD4%T3M3fM [-qGzI1%-՟HD"μ. K 4.XHDLeѓG()͓)c4d S^7`٢ڂk61 29UNw^E4 t""ǰuYbgAAm{w#cWQ3ƣ/j k endstream endobj 24 0 obj 747 endobj 22 0 obj << /Type /Page /Parent 5 0 R /Resources << /Font << /F0 6 0 R /F1 8 0 R /F2 10 0 R >> /ProcSet 2 0 R >> /Contents 23 0 R >> endobj 30 0 obj << /Length 31 0 R /Filter /FlateDecode >> stream HWَ6'@!).R4uf-&@> -3*dr%n @` {=\B Ȁ`P0V+X?! `b 1Wa;k a/fg~ p[d imI~K ( !8zzxX[#ԥT߂z=6c]jo庑!r0'!CN%M)NJmFjIKd;ܩ̖d)J0ͦQh!7#%"5{"4))C9'4!Yd#(bzA>)O`FߴUU֯U.|[a HإGȈn57ڂˮ%w-Xߋ̭4j1aʧdn?<;m Zl+S0pqPεrE.y1!1+[igTI˂ y80}W˻ aE6t^-B"RBr}QUh̲n;iq=@'&)sO#b͈t+m +uݾw6j|24Qu˾iT-u-_`_bL̻F[mH60/\Ԙ8e'Bq#1A#أtMmrYʺW(M)MtFY/Mϭ"#4$`/q`[|a{q$gG\I2%MFL\pphCf;Q2cgeT>g΍s6<wXOiB$jYvĔ<`09'kqk0Mz jZ i' endstream endobj 31 0 obj 1219 endobj 25 0 obj << /Type /Page /Parent 5 0 R /Resources << /Font 34 0 R /ProcSet 2 0 R >> /Contents 30 0 R >> endobj 34 0 obj << /F0 6 0 R /F1 8 0 R /F2 10 0 R /F4 26 0 R /F5 28 0 R /F6 32 0 R >> endobj 38 0 obj << /Length 39 0 R /Filter /FlateDecode >> stream HWNF~\1szrhhAi1ɄJl8l٧lNE+$?D_M 0?3@ )1_&0A\O 5S~OXϕMPS'D ̬1 &AuAusqqՈuia? N/?\ 9Fu(wSUo/@q쵝 P1s4j a3 Zd}j$9cSHPi(# EJUX( 9}RfXtSHB*Z%Ǒ r Zۜ!cSs[umo \y!O^RQOC "pcԥ9U4Nd(40fہJ̈́(پl{n ]Vs.=ٜ߯\.>ڎH8+OH1nj餔%3X㋍RDd='\d=Y:v]n]=Ȩk1ԥUC.޿2_0\T2H1jd2bk7M*bSuR?M0 1Ҹm!X5 [2sR?`,Z糵~5yczzs ݠYs-*񼸞Oѳ endstream endobj 39 0 obj 1428 endobj 35 0 obj << /Type /Page /Parent 5 0 R /Resources << /Font 42 0 R /ProcSet 2 0 R >> /Contents 38 0 R >> endobj 42 0 obj << /F0 6 0 R /F1 8 0 R /F2 10 0 R /F4 26 0 R /F5 28 0 R /F6 32 0 R /F7 36 0 R /F8 40 0 R >> endobj 45 0 obj << /Length 46 0 R /Filter /FlateDecode >> stream HWnFˊdMDHOvMiR8d"ŐC^Rph(ԓ蟙 .:M q m7&/ UQExvW[a#_N-䔞Yg׋q endstream endobj 46 0 obj 1246 endobj 43 0 obj << /Type /Page /Parent 44 0 R /Resources << /Font 47 0 R /ProcSet 2 0 R >> /Contents 45 0 R >> endobj 47 0 obj << /F0 6 0 R /F1 8 0 R /F4 26 0 R /F5 28 0 R /F6 32 0 R /F7 36 0 R >> endobj 49 0 obj << /Length 50 0 R /Filter /FlateDecode >> stream HUn8*^Nٸ\)Ze'6&܅vfߕ|%Кe3CȪ4 ,Qa_;ZΆOgQ;^G)l+ē-ϓ)/죋 ]MB=%VFqԖ!9YwIMkr( AL&vp4zee]C˛bcÔ%]wWbKc.7]YΆL?–i朖)~Af?> /ProcSet 2 0 R >> /Contents 49 0 R >> endobj 52 0 obj << /Length 53 0 R /Filter /FlateDecode >> stream HW[OFy1sODtWbTݗd 6l޹QՊ L||gsm~$`ƀ``/ 0?^A 2)1/VG0C\觅~ X_X~yDH0b!މ`$^y]Wgg^!&-ԫ|wswO)0/ET .yP:ıvzBK0$JN$%r{Il;w`%)XD;z1L(]]tFQ+ըj ceq(@$!$2,̇ZB2rUQ,7jUMѕuR8 3oBʪ\_1a0!y7:Y8''T+8!::w$c}b$S|&n"p-)>jmՖJ-AYuI?" PW$QnhYy;fS?(mDf,$a>m*9!Ww7B(X6ueGх;1|HX8U*ĕj\vJr+'j55O2d}><}AXWv1`M:԰FByZ#ES>O 렕"rA-/IM]?l_[x`QT`PTk*\j2&T.bdkeH@W,[紩"A>^Ҩsk\ŮIH&>*6b#zب-A$Wf_BεﵳK*yA5) FD0"r魯=$Ə1$CRcb1ݱl8Wo|Ҁٜ+Gƹx 3ҿ+SZjNքWjF~ug]2[E('8rFo>GpvZb !lQQd\oiG,s̾u"5\mCS &+AȞr̉\wJi pM2 ,3g$2vm[mP?ScН'ZJCSQ 5Θ|JFM"vb<).nv1|$Hrġd$ bkե**Bq5PmE,,=6U݁vT7L=Nk:si|v ͺWጞVO,50σ!9a^2G Q!]Tߙ1 V+tSEsoŻZϜhzUzk2-xU!#s9K[|<Úi]{8,[ y{,\P?`_j*Y=}sl"s9?,o$ endstream endobj 53 0 obj 1415 endobj 51 0 obj << /Type /Page /Parent 44 0 R /Resources << /Font 54 0 R /ProcSet 2 0 R >> /Contents 52 0 R >> endobj 54 0 obj << /F0 6 0 R /F1 8 0 R /F2 10 0 R /F4 26 0 R /F5 28 0 R /F6 32 0 R >> endobj 6 0 obj << /Type /Font /Subtype /TrueType /Name /F0 /BaseFont /Verdana,Italic /FirstChar 32 /LastChar 255 /Widths [ 352 394 459 818 636 1076 727 269 454 454 636 818 364 454 364 454 636 636 636 636 636 636 636 636 636 636 454 454 818 818 818 545 1000 683 686 698 766 632 575 775 751 421 455 693 557 843 748 787 603 787 695 684 616 732 683 990 685 615 685 454 454 454 818 636 636 601 623 521 623 596 352 622 633 274 344 587 274 973 633 607 623 623 427 521 394 633 591 818 592 591 525 635 454 635 818 1000 636 1000 269 636 459 818 636 636 636 1519 684 454 1070 1000 685 1000 1000 269 269 459 459 545 636 1000 636 977 521 454 980 1000 525 615 352 394 636 636 636 636 454 636 636 1000 545 645 818 454 1000 636 542 818 542 542 636 642 636 364 636 542 545 645 1000 1000 1000 545 683 683 683 683 683 683 989 698 632 632 632 632 421 421 421 421 766 748 787 787 787 787 787 818 787 732 732 732 732 615 605 620 601 601 601 601 601 601 955 521 596 596 596 596 274 274 274 274 612 633 607 607 607 607 607 818 607 633 633 633 633 591 623 591 ] /Encoding /WinAnsiEncoding /FontDescriptor 7 0 R >> endobj 7 0 obj << /Type /FontDescriptor /FontName /Verdana,Italic /Flags 96 /FontBBox [ -250 -210 1830 1005 ] /MissingWidth 456 /StemV 92 /StemH 92 /ItalicAngle -11 /CapHeight 1005 /XHeight 503 /Ascent 1005 /Descent -210 /Leading 215 /MaxWidth 1525 /AvgWidth 508 >> endobj 8 0 obj << /Type /Font /Subtype /TrueType /Name /F1 /BaseFont /Verdana /FirstChar 32 /LastChar 255 /Widths [ 352 394 459 818 636 1076 727 269 454 454 636 818 364 454 364 454 636 636 636 636 636 636 636 636 636 636 454 454 818 818 818 545 1000 684 686 698 771 632 575 775 751 421 455 693 557 843 748 787 603 787 695 684 616 732 684 989 685 615 685 454 454 454 818 636 636 601 623 521 623 596 352 623 633 274 344 592 274 973 633 607 623 623 427 521 394 633 592 818 592 592 525 635 454 635 818 1000 636 1000 269 636 459 818 636 636 636 1521 684 454 1070 1000 685 1000 1000 269 269 459 459 545 636 1000 636 977 521 454 981 1000 525 615 352 394 636 636 636 636 454 636 636 1000 545 645 818 454 1000 636 542 818 542 542 636 642 636 364 636 542 545 645 1000 1000 1000 545 684 684 684 684 684 684 984 698 632 632 632 632 421 421 421 421 775 748 787 787 787 787 787 818 787 732 732 732 732 615 605 620 601 601 601 601 601 601 955 521 596 596 596 596 274 274 274 274 612 633 607 607 607 607 607 818 607 633 633 633 633 592 623 592 ] /Encoding /WinAnsiEncoding /FontDescriptor 9 0 R >> endobj 9 0 obj << /Type /FontDescriptor /FontName /Verdana /Flags 32 /FontBBox [ -250 -210 1822 1005 ] /MissingWidth 453 /StemV 92 /StemH 92 /ItalicAngle 0 /CapHeight 1005 /XHeight 503 /Ascent 1005 /Descent -210 /Leading 215 /MaxWidth 1518 /AvgWidth 508 >> endobj 10 0 obj << /Type /Font /Subtype /TrueType /Name /F2 /BaseFont /Verdana,Bold /FirstChar 32 /LastChar 255 /Widths [ 342 402 587 867 711 1272 862 332 543 543 711 867 361 480 361 689 711 711 711 711 711 711 711 711 711 711 402 402 867 867 867 617 964 776 762 724 830 683 650 811 837 546 555 771 637 948 847 850 733 850 782 710 682 812 764 1128 764 737 692 543 689 543 867 711 711 668 699 588 699 664 422 699 712 342 403 671 342 1058 712 687 699 699 497 593 456 712 650 979 669 651 597 711 543 711 867 1000 711 1000 332 711 587 1049 711 711 711 1777 710 543 1135 1000 692 1000 1000 332 332 587 587 711 711 1000 711 964 593 543 1068 1000 597 737 342 402 711 711 711 711 543 711 711 964 598 850 867 480 964 711 587 867 598 598 711 721 711 361 711 598 598 850 1182 1182 1182 617 776 776 776 776 776 776 1094 724 683 683 683 683 546 546 546 546 830 847 850 850 850 850 850 867 850 812 812 812 812 737 735 713 668 668 668 668 668 668 1018 588 664 664 664 664 342 342 342 342 679 712 687 687 687 687 687 867 687 712 712 712 712 651 699 651 ] /Encoding /WinAnsiEncoding /FontDescriptor 11 0 R >> endobj 11 0 obj << /Type /FontDescriptor /FontName /Verdana,Bold /Flags 16416 /FontBBox [ -250 -210 2129 1005 ] /MissingWidth 542 /StemV 181 /StemH 181 /ItalicAngle 0 /CapHeight 1005 /XHeight 503 /Ascent 1005 /Descent -210 /Leading 215 /MaxWidth 1774 /AvgWidth 568 >> endobj 15 0 obj << /Type /Font /Subtype /TrueType /Name /F3 /BaseFont /TimesNewRoman /FirstChar 32 /LastChar 255 /Widths [ 250 333 408 500 500 833 778 180 333 333 500 564 250 333 250 278 500 500 500 500 500 500 500 500 500 500 278 278 564 564 564 444 921 722 667 667 722 611 556 722 722 333 389 722 611 889 722 722 556 722 667 556 611 722 722 944 722 722 611 333 278 333 469 500 333 444 500 444 500 444 333 500 500 278 278 500 278 778 500 500 500 500 333 389 278 500 500 722 500 500 444 480 200 480 541 778 500 778 333 500 444 1000 500 500 333 1000 556 333 889 778 611 778 778 333 333 444 444 350 500 1000 333 980 389 333 722 778 444 722 250 333 500 500 500 500 200 500 333 760 276 500 564 333 760 500 400 549 300 300 333 576 453 250 333 300 310 500 750 750 750 444 722 722 722 722 722 722 889 667 611 611 611 611 333 333 333 333 722 722 722 722 722 722 722 564 722 722 722 722 722 722 556 500 444 444 444 444 444 444 667 444 444 444 444 444 278 278 278 278 500 500 500 500 500 500 500 549 500 500 500 500 500 500 500 500 ] /Encoding /WinAnsiEncoding /FontDescriptor 16 0 R >> endobj 16 0 obj << /Type /FontDescriptor /FontName /TimesNewRoman /Flags 34 /FontBBox [ -250 -216 1166 1000 ] /MissingWidth 324 /StemV 73 /StemH 73 /ItalicAngle 0 /CapHeight 891 /XHeight 446 /Ascent 891 /Descent -216 /Leading 149 /MaxWidth 972 /AvgWidth 401 >> endobj 26 0 obj << /Type /Font /Subtype /TrueType /Name /F4 /BaseFont /Arial,BoldItalic /FirstChar 32 /LastChar 255 /Widths [ 278 333 474 556 556 889 722 238 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 333 333 584 584 584 611 975 722 722 722 722 667 611 778 722 278 556 722 611 833 722 778 667 778 722 667 611 722 667 944 667 667 611 333 278 333 584 556 333 556 611 556 611 556 333 611 611 278 278 556 278 889 611 611 611 611 389 556 333 611 556 778 556 556 500 389 280 389 584 750 556 750 278 556 500 1000 556 556 333 1000 667 333 1000 750 611 750 750 278 278 500 500 350 556 1000 333 1000 556 333 944 750 500 667 278 333 556 556 556 556 280 556 333 737 370 556 584 333 737 552 400 549 333 333 333 576 556 278 333 333 365 556 834 834 834 611 722 722 722 722 722 722 1000 722 667 667 667 667 278 278 278 278 722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611 556 556 556 556 556 556 889 556 556 556 556 556 278 278 278 278 611 611 611 611 611 611 611 549 611 611 611 611 611 556 611 556 ] /Encoding /WinAnsiEncoding /FontDescriptor 27 0 R >> endobj 27 0 obj << /Type /FontDescriptor /FontName /Arial,BoldItalic /Flags 16480 /FontBBox [ -250 -212 1174 1000 ] /MissingWidth 326 /StemV 153 /StemH 153 /ItalicAngle -11 /CapHeight 905 /XHeight 453 /Ascent 905 /Descent -212 /Leading 150 /MaxWidth 978 /AvgWidth 479 >> endobj 28 0 obj << /Type /Font /Subtype /TrueType /Name /F5 /BaseFont /Symbol /FirstChar 30 /LastChar 255 /Widths [ 600 600 250 333 713 500 549 833 778 439 333 333 500 549 250 549 250 278 500 500 500 500 500 500 500 500 500 500 278 278 549 549 549 444 549 722 667 722 612 611 763 603 722 333 631 722 686 889 722 722 768 741 556 592 611 690 439 768 645 795 611 333 863 333 658 500 500 631 549 549 494 439 521 411 603 329 603 549 549 576 521 549 549 521 549 603 439 576 713 686 493 686 494 480 200 480 549 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 620 247 549 167 713 500 753 753 753 753 1042 987 603 987 603 400 549 411 549 549 713 494 460 549 549 549 549 1000 603 1000 658 823 686 795 987 768 768 823 768 768 713 713 713 713 713 713 713 768 713 790 790 890 823 549 250 713 603 603 1042 987 603 987 603 494 329 790 790 786 713 384 384 384 384 384 384 494 494 494 494 600 329 274 686 686 686 384 384 384 384 384 384 494 494 494 600 ] /FontDescriptor 29 0 R >> endobj 29 0 obj << /Type /FontDescriptor /FontName /Symbol /Flags 6 /FontBBox [ -250 -220 1249 1005 ] /MissingWidth 333 /StemV 109 /StemH 109 /ItalicAngle 0 /CapHeight 1005 /XHeight 503 /Ascent 1005 /Descent -220 /Leading 225 /MaxWidth 1041 /AvgWidth 600 >> endobj 32 0 obj << /Type /Font /Subtype /TrueType /Name /F6 /BaseFont /CourierNew,Bold /FirstChar 32 /LastChar 255 /Widths [ 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 ] /Encoding /WinAnsiEncoding /FontDescriptor 33 0 R >> endobj 33 0 obj << /Type /FontDescriptor /FontName /CourierNew,Bold /Flags 16418 /FontBBox [ -250 -300 716 1000 ] /MissingWidth 597 /StemV 191 /StemH 191 /ItalicAngle 0 /CapHeight 833 /XHeight 417 /Ascent 833 /Descent -300 /Leading 133 /MaxWidth 597 /AvgWidth 600 >> endobj 36 0 obj << /Type /Font /Subtype /TrueType /Name /F7 /BaseFont /Arial,Bold /FirstChar 32 /LastChar 255 /Widths [ 278 333 474 556 556 889 722 238 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 333 333 584 584 584 611 975 722 722 722 722 667 611 778 722 278 556 722 611 833 722 778 667 778 722 667 611 722 667 944 667 667 611 333 278 333 584 556 333 556 611 556 611 556 333 611 611 278 278 556 278 889 611 611 611 611 389 556 333 611 556 778 556 556 500 389 280 389 584 750 556 750 278 556 500 1000 556 556 333 1000 667 333 1000 750 611 750 750 278 278 500 500 350 556 1000 333 1000 556 333 944 750 500 667 278 333 556 556 556 556 280 556 333 737 370 556 584 333 737 552 400 549 333 333 333 576 556 278 333 333 365 556 834 834 834 611 722 722 722 722 722 722 1000 722 667 667 667 667 278 278 278 278 722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611 556 556 556 556 556 556 889 556 556 556 556 556 278 278 278 278 611 611 611 611 611 611 611 549 611 611 611 611 611 556 611 556 ] /Encoding /WinAnsiEncoding /FontDescriptor 37 0 R >> endobj 37 0 obj << /Type /FontDescriptor /FontName /Arial,Bold /Flags 16416 /FontBBox [ -250 -212 1165 1000 ] /MissingWidth 323 /StemV 153 /StemH 153 /ItalicAngle 0 /CapHeight 905 /XHeight 453 /Ascent 905 /Descent -212 /Leading 150 /MaxWidth 971 /AvgWidth 479 >> endobj 40 0 obj << /Type /Font /Subtype /TrueType /Name /F8 /BaseFont /TrebuchetMS /FirstChar 32 /LastChar 255 /Widths [ 301 367 325 524 524 600 706 160 367 367 367 524 367 367 367 524 524 524 524 524 524 524 524 524 524 524 367 367 524 524 524 367 771 590 566 598 613 536 525 676 654 278 477 576 506 709 638 674 558 676 582 481 581 648 587 852 557 570 550 367 355 367 524 524 524 525 557 495 557 545 370 502 546 285 367 504 295 830 546 537 557 557 389 405 396 546 490 744 501 493 475 367 524 367 524 500 524 500 367 388 524 734 459 459 524 913 481 367 993 500 550 500 500 367 367 524 524 524 367 734 524 635 405 367 924 500 475 570 301 367 524 524 524 570 524 454 524 713 367 524 524 367 713 524 524 524 451 454 524 546 524 367 524 451 367 524 814 814 814 367 590 590 590 590 590 590 867 598 536 536 536 536 278 278 278 278 613 638 674 674 674 674 674 524 657 648 648 648 648 570 556 546 525 525 525 525 525 525 873 495 545 545 545 545 285 285 285 285 549 546 537 537 537 537 537 524 545 546 546 546 546 493 553 493 ] /Encoding /WinAnsiEncoding /FontDescriptor 41 0 R >> endobj 41 0 obj << /Type /FontDescriptor /FontName /TrebuchetMS /Flags 32 /FontBBox [ -250 -222 1104 1000 ] /MissingWidth 340 /StemV 83 /StemH 83 /ItalicAngle 0 /CapHeight 939 /XHeight 470 /Ascent 939 /Descent -222 /Leading 161 /MaxWidth 920 /AvgWidth 454 >> endobj 2 0 obj [ /PDF /Text ] endobj 5 0 obj << /Kids [4 0 R 14 0 R 19 0 R 22 0 R 25 0 R 35 0 R ] /Count 6 /Type /Pages /Parent 55 0 R >> endobj 44 0 obj << /Kids [43 0 R 48 0 R 51 0 R ] /Count 3 /Type /Pages /Parent 55 0 R >> endobj 55 0 obj << /Kids [5 0 R 44 0 R ] /Count 9 /Type /Pages /MediaBox [ 0 0 596 842 ] >> endobj 1 0 obj << /Creator /CreationDate (D:20010518230136) /Title /Author /Producer (Acrobat PDFWriter 5.0 for Windows NT) >> endobj 3 0 obj << /Pages 55 0 R /Type /Catalog >> endobj xref 0 56 0000000000 65535 f 0000023881 00000 n 0000023561 00000 n 0000024205 00000 n 0000000578 00000 n 0000023592 00000 n 0000011365 00000 n 0000012468 00000 n 0000012734 00000 n 0000013830 00000 n 0000014087 00000 n 0000015193 00000 n 0000000019 00000 n 0000000558 00000 n 0000001863 00000 n 0000015461 00000 n 0000016552 00000 n 0000000720 00000 n 0000001842 00000 n 0000002583 00000 n 0000002018 00000 n 0000002563 00000 n 0000003571 00000 n 0000002726 00000 n 0000003551 00000 n 0000005032 00000 n 0000016813 00000 n 0000017910 00000 n 0000018181 00000 n 0000019247 00000 n 0000003714 00000 n 0000005011 00000 n 0000019505 00000 n 0000020595 00000 n 0000005142 00000 n 0000006755 00000 n 0000020862 00000 n 0000021953 00000 n 0000005228 00000 n 0000006734 00000 n 0000022216 00000 n 0000023302 00000 n 0000006865 00000 n 0000008318 00000 n 0000023700 00000 n 0000006973 00000 n 0000008297 00000 n 0000008429 00000 n 0000009498 00000 n 0000008515 00000 n 0000009478 00000 n 0000011168 00000 n 0000009654 00000 n 0000011147 00000 n 0000011279 00000 n 0000023789 00000 n trailer << /Size 56 /Root 3 0 R /Info 1 0 R /ID [<41022e51d44c0d7cc8d6eac38733ab06><41022e51d44c0d7cc8d6eac38733ab06>] >> startxref 24255 %%EOF faac-1_30/frontend/000077500000000000000000000000001355157314300142365ustar00rootroot00000000000000faac-1_30/frontend/Makefile.am000066400000000000000000000011121355157314300162650ustar00rootroot00000000000000if !USE_DRM # no frontend for DRM version bin_PROGRAMS = faac dist_man_MANS = ../docs/faac.1 faac_SOURCES = main.c input.c mp4write.c input.h mp4write.h EXTRA_faac_SOURCES = getopt.c faacgui.rc icon.rc faac.ico AM_CPPFLAGS = -I$(top_srcdir)/include faac_LDADD = $(top_builddir)/libfaac/libfaac.la -lm if MINGW bin_PROGRAMS += faacgui faacgui_SOURCES = maingui.c input.c input.h resource.h faac_LDADD += -lws2_32 icon.o faacgui_LDADD = $(faac_LDADD) faacguires.o -lcomdlg32 faacguires.o: $(WINDRES) faacgui.rc faacguires.o icon.o: $(WINDRES) icon.rc icon.o endif endif # !USE_DRM faac-1_30/frontend/faac.ico000066400000000000000000000226761355157314300156410ustar00rootroot0000000000000000 %(0`    $,16899861,$ %1;AGKNPQQPNKGA;1%(7BJQW\_beffeb_\WQJB7( "7K[cceimrtvvvvtrmiecc[K7" ,A_~ry{~~{yr~_A,3EdwTBF``FBTwdE36F^Y5 "=kk=" 5Y^F66HYwtF!&SS&!FtwYH63GWkd5, @yy@ ,5dkWG3 ,CUd|W)!D62ii26D!)W|dUC, ">QaqK"+YJ'[['JY+"KqaQ>"5K]k}s?":m]$NN$]m:"?s}k]K5(BVgug4&Lo3BB3oL&4gugVB(7M_o~].-]B7tt7B]-.]~o_M7%AWhwR+7oQ.hh.Qo7+RwhWA% 1J^o~|G+F_ &]]& _F+G|~o^J1 ;MYpr<)Sl,RR,lT-=q{k\N;$CGx|E|d!Ji_9Et~y9ITybp,Nlp.H9|q*E}f35gQfp,{xg=1̡q=#,HPgwOjY=e]Bo~/E B~pcE1ͣs;}>E>z6v>=N|sx p+f>n0ւ{ xbG .>TMmxNlO1AUw0Q3Gp*}l3r2R cDm2 7cqhq9# |f>r' BpThHwxMnxE2"Zus#h;A@>>g9Bne0zs LovBU_}u4rQzdlPzxXY1â}Qjg@;ccHQfdpwuW]9[LJwCvzQ6Nf?e@w!Rce*goq:J.Y *±i:xq&R6Q{oNH&buXwf Hk{;bvGjyc E = bD{]N $b$![_nf0um%]fPn19݄{kl5%F G e ZH[gTkt4 Kf 6{k@lvrn)]jQ\bS\dS`qLGy s(pm3l/PR:C{wD~?zyt mi3akHgi>rv Tza7 X7wwt sq'so'sr'tx&w|ZVMot%7y:DDnm0_}LKrsfm?pn+mn2XnZ$tS  ?ip[UcD8ww8?dU\qi? &QsN-ii-NsQ&8Um~Y#\\#Y~mU8(AVhub$OO$buhVA(5K]lym/AA/myl]K5">Qap|w9 3oo3 9w|paQ>" ,CUdq}D&^^&D}qdUC, 3GWeq|OLLO|qeWG36HWdpyZ$ 99 $ZypdWH66GUalu~g1 && 1g~ulaUG63CQ]gow~w??w~wog]QC3,>KV_hotyP$ $Pytoh_VK>, "5BMW^dini>&&>inid^WMB5" (7AJQW[fdNNdf[WQJA7(%1;AGKThvvhTKGA;1% $,169;;961,$   ??faac-1_30/frontend/faacgui.rc000066400000000000000000000110071355157314300161620ustar00rootroot00000000000000//Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_MAINDIALOG DIALOGEX 0, 0, 264, 190 STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "FAAC GUI" FONT 8, "MS Sans Serif" BEGIN PUSHBUTTON "...",IDC_SELECT_INPUTFILE,225,12,19,14,0, WS_EX_STATICEDGE PUSHBUTTON "...",IDC_SELECT_OUTPUTFILE,225,33,19,14,WS_DISABLED, WS_EX_STATICEDGE CONTROL "Allow Mid/Side",IDC_ALLOWMIDSIDE,"Button", BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,14,81,71,10 LTEXT "Quantizer\nquality", IDC_STATIC, 98, 73, 44, 18 EDITTEXT IDC_QUALITY, 138, 76, 30, 12, ES_AUTOHSCROLL CONTROL "", IDC_STATIC, "static", SS_SUNKEN, 98, 94, 70, 30 CONTROL "Set bandwidth", IDC_BWCTL, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 102, 96, 62, 12 EDITTEXT IDC_BANDWIDTH,102,109,34,12,ES_AUTOHSCROLL | WS_DISABLED | WS_TABSTOP LTEXT "Hz", IDC_STATIC, 140, 111, 10, 8 DEFPUSHBUTTON "Encode",IDOK,200,152,50,14,WS_DISABLED PUSHBUTTON "Quit",IDCANCEL,200,170,50,14 LTEXT "",IDC_TIME,7,151,190,20 LTEXT "", IDC_COMPILEDATE, 20, 176, 150, 8 EDITTEXT IDC_INPUTFILENAME,61,12,158,14,ES_AUTOHSCROLL EDITTEXT IDC_OUTPUTFILENAME,61,33,158,14,ES_AUTOHSCROLL | WS_DISABLED LTEXT "Input File:",IDC_STATIC,18,13,38,8 LTEXT "Output File:",IDC_STATIC,18,34,37,8 CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,54, 250,1 LTEXT "-",IDC_INPUTPARAMS,32,66,55,8 LTEXT "In:",IDC_STATIC,14,66,12,8 CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7, 135,250,10 GROUPBOX "Output Format",IDC_STATIC,93,62,164,67 CONTROL "Use RAW output",IDC_USERAW,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,14,103,71,10 CONTROL "Use TNS",IDC_USETNS,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,14,92,71,10 COMBOBOX IDC_MPEGVERSION,183,82,67,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_OBJECTTYPE,183,109,67,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "MPEG Verion",IDC_STATIC,183,73,44,8 LTEXT "AAC Object Type",IDC_STATIC,183,100,56,8 CONTROL "Use LFE channel",IDC_USELFE,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_DISABLED | WS_TABSTOP,14,114,71,10 END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN IDD_MAINDIALOG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 257 TOPMARGIN, 7 BOTTOMMARGIN, 178 END END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Dialog Info // IDD_MAINDIALOG DLGINIT BEGIN IDC_MPEGVERSION, 0x403, 1, 0, "\000", 0 END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED faac-1_30/frontend/getopt.c000066400000000000000000000542261355157314300157150ustar00rootroot00000000000000/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef __STDC__ # ifndef const # define const # endif #endif /* This tells Alpha OSF/1 not to define a getopt prototype in . */ #ifndef _NO_PROTO #define _NO_PROTO #endif #include //#include "tailor.h" /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #if defined (_LIBC) || !defined (__GNU_LIBRARY__) || !__MacOSX__ /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #endif /* GNU C library. */ /* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a long-named option. Because this is not POSIX.2 compliant, it is being phased out. */ /* #define GETOPT_COMPAT */ /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = 0; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* XXX 1003.2 says this must be 1 before any call. */ int optind = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ #define BAD_OPTION '\0' int optopt = BAD_OPTION; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return EOF with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; #if defined(__GNU_LIBRARY__) || defined(__APPLE__) /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include #define my_index strchr #define my_strlen strlen #else /* Avoid depending on library functions or files whose names are inconsistent. */ #if __STDC__ || defined(PROTO) extern char *getenv(const char *name); extern int strcmp (const char *s1, const char *s2); extern int strncmp(const char *s1, const char *s2, size_t n); static int my_strlen(const char *s); static char *my_index (const char *str, int chr); #else extern char *getenv (); #endif static int my_strlen (str) const char *str; { int n = 0; while (*str++) n++; return n; } static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } #endif /* GNU C library. */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. To perform the swap, we first reverse the order of all elements. So all options now come before all non options, but they are in the wrong order. So we put back the options and non options in original order by reversing them again. For example: original input: a b c -x -y reverse all: -y -x c b a reverse options: -x -y c b a reverse non options: -x -y a b c */ #if __STDC__ || defined(PROTO) static void exchange (char **argv); #endif static void exchange (argv) char **argv; { char *temp, **first, **last; /* Reverse all the elements [first_nonopt, optind) */ first = &argv[first_nonopt]; last = &argv[optind-1]; while (first < last) { temp = *first; *first = *last; *last = temp; first++; last--; } /* Put back the options in order */ first = &argv[first_nonopt]; first_nonopt += (optind - last_nonopt); last = &argv[first_nonopt - 1]; while (first < last) { temp = *first; *first = *last; *last = temp; first++; last--; } /* Put back the non options in order */ first = &argv[first_nonopt]; last_nonopt = optind; last = &argv[last_nonopt-1]; while (first < last) { temp = *first; *first = *last; *last = temp; first++; last--; } } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns `EOF'. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return BAD_OPTION after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return BAD_OPTION. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int option_index; optarg = 0; /* Initialize the internal data when the first call is made. Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ if (optind == 0) { first_nonopt = last_nonopt = optind = 1; nextchar = NULL; /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (getenv ("POSIXLY_CORRECT") != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; } if (nextchar == NULL || *nextchar == '\0') { if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Now skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0') #ifdef GETOPT_COMPAT && (longopts == NULL || argv[optind][0] != '+' || argv[optind][1] == '\0') #endif /* GETOPT_COMPAT */ ) optind++; last_nonopt = optind; } /* Special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return EOF; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if ((argv[optind][0] != '-' || argv[optind][1] == '\0') #ifdef GETOPT_COMPAT && (longopts == NULL || argv[optind][0] != '+' || argv[optind][1] == '\0') #endif /* GETOPT_COMPAT */ ) { if (ordering == REQUIRE_ORDER) return EOF; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Start decoding its characters. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } if (longopts != NULL && ((argv[optind][0] == '-' && (argv[optind][1] == '-' || long_only)) #ifdef GETOPT_COMPAT || argv[optind][0] == '+' #endif /* GETOPT_COMPAT */ )) { const struct option *p; char *s = nextchar; int exact = 0; int ambig = 0; const struct option *pfound = NULL; int indfound = 0; while (*s && *s != '=') s++; /* Test all options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, s - nextchar)) { if (s - nextchar == my_strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, "%s: option `%s' is ambiguous\n", argv[0], argv[optind]); nextchar += my_strlen (nextchar); optind++; return BAD_OPTION; } if (pfound != NULL) { option_index = indfound; optind++; if (*s) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = s + 1; else { if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, "%s: option `--%s' doesn't allow an argument\n", argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, "%s: option `%c%s' doesn't allow an argument\n", argv[0], argv[optind - 1][0], pfound->name); } nextchar += my_strlen (nextchar); return BAD_OPTION; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, "%s: option `%s' requires an argument\n", argv[0], argv[optind - 1]); nextchar += my_strlen (nextchar); return optstring[0] == ':' ? ':' : BAD_OPTION; } } nextchar += my_strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' #ifdef GETOPT_COMPAT || argv[optind][0] == '+' #endif /* GETOPT_COMPAT */ || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, "%s: unrecognized option `--%s'\n", argv[0], nextchar); else /* +option or -option */ fprintf (stderr, "%s: unrecognized option `%c%s'\n", argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; return BAD_OPTION; } } /* Look at and handle the next option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { #if 0 if (c < 040 || c >= 0177) fprintf (stderr, "%s: unrecognized option, character code 0%o\n", argv[0], c); else fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); #else /* 1003.2 specifies the format of this message. */ fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); #endif } optopt = c; return BAD_OPTION; } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = 0; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { #if 0 fprintf (stderr, "%s: option `-%c' requires an argument\n", argv[0], c); #else /* 1003.2 specifies the format of this message. */ fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], c); #endif } optopt = c; if (optstring[0] == ':') c = ':'; else c = BAD_OPTION; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } #endif /* _LIBC or not __GNU_LIBRARY__. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == EOF) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case BAD_OPTION: break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ faac-1_30/frontend/getopt.h000066400000000000000000000106601355157314300157140ustar00rootroot00000000000000/* Declarations for getopt. Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GETOPT_H #define _GETOPT_H 1 #ifdef __cplusplus extern "C" { #endif #ifndef __MacOSX__ /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #endif /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { #if __STDC__ const char *name; #else char *name; #endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 //#if __STDC__ || defined(PROTO) #if defined(__GNU_LIBRARY__) /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); #endif /* not __GNU_LIBRARY__ */ extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind, int long_only); //#else /* not __STDC__ */ extern int getopt (int argc, char *const *argv, const char *shortopts); //extern int getopt_long (); //extern int getopt_long_only (); //extern int _getopt_internal (); //#endif /* not __STDC__ */ #ifdef __cplusplus } #endif #endif /* _GETOPT_H */ faac-1_30/frontend/icon.rc000066400000000000000000000000601355157314300155100ustar00rootroot00000000000000#include "resource.h" ID_ICON1 ICON "faac.ico" faac-1_30/frontend/input.c000066400000000000000000000243611355157314300155470ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2002 Krzysztof Nikiel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: input.c,v 1.21 2017/07/02 14:35:23 knik Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #ifdef _WIN32 #include #include #endif #include "input.h" #define SWAP32(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8) \ | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24)) #define SWAP16(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8)) #ifdef WORDS_BIGENDIAN # define UINT32(x) SWAP32(x) # define UINT16(x) SWAP16(x) #else # define UINT32(x) (x) # define UINT16(x) (x) #endif typedef struct { uint32_t label; /* 'RIFF' */ uint32_t length; /* Length of rest of file */ uint32_t chunk_type; /* 'WAVE' */ } riff_t; typedef struct { uint32_t label; uint32_t len; } riffsub_t; #ifdef _MSC_VER #pragma pack(push, 1) #endif #define WAVE_FORMAT_PCM 1 #define WAVE_FORMAT_FLOAT 3 #define WAVE_FORMAT_EXTENSIBLE 0xfffe struct WAVEFORMATEX { uint16_t wFormatTag; uint16_t nChannels; uint32_t nSamplesPerSec; uint32_t nAvgBytesPerSec; uint16_t nBlockAlign; uint16_t wBitsPerSample; uint16_t cbSize; } #ifdef __GNUC__ __attribute__((packed)) #endif ; struct WAVEFORMATEXTENSIBLE { struct WAVEFORMATEX Format; union { uint16_t wValidBitsPerSample; // bits of precision uint16_t wSamplesPerBlock; // valid if wBitsPerSample==0 uint16_t wReserved; // If neither applies, set to zero. } Samples; uint32_t dwChannelMask; // which channels are present in stream unsigned char SubFormat[16]; // guid } #ifdef __GNUC__ __attribute__((packed)) #endif ; #ifdef _MSC_VER #pragma pack(pop) #endif static unsigned char waveformat_pcm_guid[16] = { WAVE_FORMAT_PCM,0,0,0, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }; static void unsuperr(const char *name) { fprintf(stderr, "%s: file format not supported\n", name); } static void seekcur(FILE *f, int ofs) { int cnt; for (cnt = 0; cnt < ofs; cnt++) fgetc(f); } static int seekchunk(FILE *f, riffsub_t *riffsub, char *name) { int skipped; for(skipped = 0; skipped < 10; skipped++) { if (fread(riffsub, 1, sizeof(*riffsub), f) != sizeof(*riffsub)) return 0; riffsub->len = UINT32(riffsub->len); if (riffsub->len & 1) riffsub->len++; if (!memcmp(&(riffsub->label), name, 4)) return 1; seekcur(f, riffsub->len); } return 0; } pcmfile_t *wav_open_read(const char *name, int rawinput) { FILE *wave_f; riff_t riff; riffsub_t riffsub; struct WAVEFORMATEXTENSIBLE wave; char *riffl = "RIFF"; char *wavel = "WAVE"; char *fmtl = "fmt "; char *datal = "data"; int fmtsize; pcmfile_t *sndf; int dostdin = 0; if (!strcmp(name, "-")) { #ifdef _WIN32 _setmode(_fileno(stdin), O_BINARY); #endif wave_f = stdin; dostdin = 1; } else if (!(wave_f = fopen(name, "rb"))) { perror(name); return NULL; } if (!rawinput) // header input { if (fread(&riff, 1, sizeof(riff), wave_f) != sizeof(riff)) return NULL; if (memcmp(&(riff.label), riffl, 4)) return NULL; if (memcmp(&(riff.chunk_type), wavel, 4)) return NULL; if (!seekchunk(wave_f, &riffsub, fmtl)) return NULL; if (memcmp(&(riffsub.label), fmtl, 4)) return NULL; memset(&wave, 0, sizeof(wave)); fmtsize = (riffsub.len < sizeof(wave)) ? riffsub.len : sizeof(wave); // check if format is at least 16 bytes long if (fmtsize < 16) return NULL; if (fread(&wave, 1, fmtsize, wave_f) != fmtsize) return NULL; seekcur(wave_f, riffsub.len - fmtsize); if (!seekchunk(wave_f, &riffsub, datal)) return NULL; if (UINT16(wave.Format.wFormatTag) != WAVE_FORMAT_PCM && UINT16(wave.Format.wFormatTag) != WAVE_FORMAT_FLOAT) { if (UINT16(wave.Format.wFormatTag) == WAVE_FORMAT_EXTENSIBLE) { if (UINT16(wave.Format.cbSize) < 22) // struct too small return NULL; if (memcmp(wave.SubFormat, waveformat_pcm_guid, 16)) { waveformat_pcm_guid[0] = WAVE_FORMAT_FLOAT; if (memcmp(wave.SubFormat, waveformat_pcm_guid, 16)) { unsuperr(name); return NULL; } } } else { unsuperr(name); return NULL; } } } sndf = (pcmfile_t*)malloc(sizeof(*sndf)); memset(sndf, 0, sizeof(*sndf)); sndf->f = wave_f; if (UINT16(wave.Format.wFormatTag) == WAVE_FORMAT_FLOAT) { sndf->isfloat = 1; } else { sndf->isfloat = (wave.SubFormat[0] == WAVE_FORMAT_FLOAT); } if (rawinput) { sndf->bigendian = 1; if (dostdin) sndf->samples = 0; else { fseek(sndf->f, 0 , SEEK_END); sndf->samples = ftell(sndf->f); rewind(sndf->f); } } else { sndf->bigendian = 0; sndf->channels = UINT16(wave.Format.nChannels); sndf->samplebytes = UINT16(wave.Format.wBitsPerSample) / 8; sndf->samplerate = UINT32(wave.Format.nSamplesPerSec); if (!sndf->samplebytes || !sndf->channels) return NULL; sndf->samples = riffsub.len / (sndf->samplebytes * sndf->channels); } return sndf; } static void chan_remap(int32_t *buf, int channels, int blocks, int *map) { int i; int32_t *tmp = (int32_t*)malloc(channels * sizeof(int32_t)); for (i = 0; i < blocks; i++) { int chn; memcpy(tmp, buf + i * channels, sizeof(int32_t) * channels); for (chn = 0; chn < channels; chn++) buf[i * channels + chn] = tmp[map[chn]]; } free(tmp); } size_t wav_read_float32(pcmfile_t *sndf, float *buf, size_t num, int *map) { size_t cnt; size_t isize; char *bufi; if ((sndf->samplebytes > 4) || (sndf->samplebytes < 1)) return 0; isize = num * sndf->samplebytes; bufi = (char*)(buf + num); bufi -= isize; isize = fread(bufi, 1, isize, sndf->f); isize /= sndf->samplebytes; // perform in-place conversion for (cnt = 0; cnt < num; cnt++) { if (cnt >= isize) break; if (sndf->isfloat) { switch (sndf->samplebytes) { case 4: buf[cnt] *= 32768.0; break; default: return 0; } continue; } switch (sndf->samplebytes) { case 1: { uint8_t *in = (uint8_t*)bufi; uint8_t s = in[cnt]; buf[cnt] = ((float)s - 128.0) * (float)256; } break; case 2: { int16_t *in = (int16_t*)bufi; int16_t s = in[cnt]; #ifdef WORDS_BIGENDIAN if (!sndf->bigendian) #else if (sndf->bigendian) #endif buf[cnt] = (float)SWAP16(s); else buf[cnt] = (float)s; } break; case 3: { int s; uint8_t *in = (uint8_t*)bufi; in += 3 * cnt; if (!sndf->bigendian) s = in[0] | (in[1] << 8) | (in[2] << 16); else s = (in[0] << 16) | (in[1] << 8) | in[2]; // fix sign if (s & 0x800000) s |= 0xff000000; buf[cnt] = (float)s / 256; } break; case 4: { int32_t *in = (int32_t*)bufi; int s = in[cnt]; #ifdef WORDS_BIGENDIAN if (!sndf->bigendian) #else if (sndf->bigendian) #endif buf[cnt] = (float)SWAP32(s) / 65536; else buf[cnt] = (float)s / 65536; } break; default: return 0; } } if (map) chan_remap((int32_t *)buf, sndf->channels, cnt / sndf->channels, map); return cnt; } size_t wav_read_int24(pcmfile_t *sndf, int32_t *buf, size_t num, int *map) { int size; int i; uint8_t *bufi; if ((sndf->samplebytes > 4) || (sndf->samplebytes < 1)) return 0; bufi = (uint8_t *)buf + sizeof(*buf) * num - sndf->samplebytes * (num - 1) - sizeof(*buf); size = fread(bufi, sndf->samplebytes, num, sndf->f); // convert to 24 bit // fix endianness switch (sndf->samplebytes) { case 1: /* this is endian clean */ for (i = 0; i < size; i++) buf[i] = (bufi[i] - 128) * 65536; break; case 2: #ifdef WORDS_BIGENDIAN if (!sndf->bigendian) #else if (sndf->bigendian) #endif { // swap bytes for (i = 0; i < size; i++) { int16_t s = ((int16_t *)bufi)[i]; s = SWAP16(s); buf[i] = ((uint32_t)s) << 8; } } else { // no swap for (i = 0; i < size; i++) { int s = ((int16_t *)bufi)[i]; buf[i] = s << 8; } } break; case 3: if (!sndf->bigendian) { for (i = 0; i < size; i++) { int s = bufi[3 * i] | (bufi[3 * i + 1] << 8) | (bufi[3 * i + 2] << 16); // fix sign if (s & 0x800000) s |= 0xff000000; buf[i] = s; } } else // big endian input { for (i = 0; i < size; i++) { int s = (bufi[3 * i] << 16) | (bufi[3 * i + 1] << 8) | bufi[3 * i + 2]; // fix sign if (s & 0x800000) s |= 0xff000000; buf[i] = s; } } break; case 4: #ifdef WORDS_BIGENDIAN if (!sndf->bigendian) #else if (sndf->bigendian) #endif { // swap bytes for (i = 0; i < size; i++) { int s = buf[i]; buf[i] = SWAP32(s); } } break; } if (map) chan_remap(buf, sndf->channels, size / sndf->channels, map); return size; } int wav_close(pcmfile_t *sndf) { int i = fclose(sndf->f); free(sndf); return i; } faac-1_30/frontend/input.h000066400000000000000000000030231355157314300155440ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2002 Krzysztof Nikiel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: input.h,v 1.7 2008/11/24 22:00:11 menno Exp $ */ #ifndef _INPUT_H #define _INPUT_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #ifdef HAVE_SYS_TYPES_H # include #endif #include #ifdef __cplusplus extern "C" { #endif typedef struct { FILE *f; int channels; int samplebytes; int samplerate; int samples; int bigendian; int isfloat; } pcmfile_t; pcmfile_t *wav_open_read(const char *path, int rawchans); size_t wav_read_float32(pcmfile_t *sndf, float *buf, size_t num, int *map); size_t wav_read_int24(pcmfile_t *sndf, int32_t *buf, size_t num, int *map); int wav_close(pcmfile_t *file); #ifdef __cplusplus } #endif #endif /* _INPUT_H */ faac-1_30/frontend/main.c000066400000000000000000001077251355157314300153420ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * Copyright (C) 2002-2017 Krzysztof Nikiel * Copyright (C) 2004 Dan Villiom P. Christiansen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef _WIN32 #include #include #else #include #endif /* the BSD derivatives don't define __unix__ */ #if defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__bsdi__) #define __unix__ #endif #ifdef __unix__ #include #include #include #include #endif #include #include #include #include #include #ifdef HAVE_GETOPT_H # include #else # include "getopt.h" # include "getopt.c" #endif #include "mp4write.h" #if !defined(HAVE_STRCASECMP) && !defined(_WIN32) # define strcasecmp strcmp #endif #ifdef _WIN32 # undef stderr # define stderr stdout #endif #include "input.h" #include #define FALSE 0 #define TRUE 1 enum flags { SHORTCTL_FLAG = 300, MPEGVERS_FLAG, ARTIST_FLAG, TITLE_FLAG, GENRE_FLAG, ALBUM_FLAG, TRACK_FLAG, DISC_FLAG, YEAR_FLAG, COVER_ART_FLAG, COMMENT_FLAG, WRITER_FLAG, TAG_FLAG, HELP_QUAL, HELP_IO, HELP_MP4, HELP_ADVANCED, OPT_JOINT, OPT_PNS }; typedef struct { char *shorthelp; char *longhelp; } help_t; const char *usage = "Usage: %s [options] infile\n\n"; static help_t help_qual[] = { {"-q \tSet encoding quality.\n", "\t\tSet default variable bitrate (VBR) quantizer quality in percent.\n" "\t\tmax. 5000, min. 10.\n" "\t\tdefault: 100, averages at approx. 120 kbps VBR for a normal\n" "\t\tstereo input file with 16 bit and 44.1 kHz sample rate\n" }, {"-b \tSet average bitrate to x kbps. (ABR)\n", "\t\tSet average bitrate (ABR) to approximately kbps.\n" "\t\tmax. ~500 (stereo)\n"}, {"-c \tSet the bandwidth in Hz.\n", "\t\tThe actual frequency is adjusted to maximize upper spectral band\n" "\t\tusage.\n"}, {0} }; static help_t help_io[] = { {"-o \tSet output file to X (only for one input file)\n", "\t\tonly for one input file; you can use *.aac, *.mp4, *.m4a or\n" "\t\t*.m4b as file extension, and the file format will be set\n" "\t\tautomatically to ADTS or MP4).\n"}, {"-\t\tUse stdin/stdout\n", "\t\tIf you simply use a hyphen/minus sign instead\n" "\t\tof a filename, FAAC can encode directly from stdin,\n" "\t\tthus enabling piping from other applications and utilities. The\n" "\t\tsame works for stdout as well, so FAAC can pipe its output to\n" "\t\tother apps such as a server.\n"}, {"-v \t\tverbosity level (-v0 is quiet mode)\n"}, {"-r\t\tUse RAW AAC output file.\n", "\t\tGenerate raw AAC bitstream (i.e. without any headers).\n" "\t\tNot advised!!!, RAW AAC files are practically useless!!!\n"}, {"-P\t\tRaw PCM input mode (default 44100Hz 16bit stereo).\n", "\t\tRaw PCM input mode (default: off, i.e. expecting a WAV header;\n" "\t\tnecessary for input files or bitstreams without a header; using\n" "\t\tonly -P assumes the default values for -R, -B and -C in the\n" "\t\tinput file).\n"}, {"-R \tRaw PCM input rate.\n", "\t\tRaw PCM input sample rate in Hz (default: 44100 Hz, max. 96 kHz)\n"}, {"-B \tRaw PCM input sample size (8, 16 (default), 24 or 32bits).\n", "\t\tRaw PCM input sample size (default: 16, also possible 8, 24, 32\n" "\t\tbit fixed or float input).\n"}, {"-C \tRaw PCM input channels.\n", "\t\tRaw PCM input channels (default: 2, max. 33 + 1 LFE).\n"}, {"-X\t\tRaw PCM swap input bytes\n", "\t\tRaw PCM swap input bytes (default: bigendian).\n"}, {"-I \tInput channel config, default is 3,4 (Center third, LF fourth)\n", "\t\tInput multichannel configuration (default: 3,4 which means\n" "\t\tCenter is third and LFE is fourth like in 5.1 WAV, so you only\n" "\t\thave to specify a different position of these two mono channels\n" "\t\tin your multichannel input files if they haven't been reordered\n" "\t\talready).\n"}, {"--ignorelength\tIgnore wav length from header (useful with files over 4 GB)\n"}, {"--overwrite\t\tOverwrite existing output file"}, {0} }; static help_t help_mp4[] = { {"-w\t\tWrap AAC data in MP4 container. (default for *.mp4 and *.m4a)\n", "\t\tWrap AAC data in MP4 container. (default for *.mp4, *.m4a and\n" "\t\t*.m4b)\n"}, {"--tag Add named tag (iTunes '----')\n"}, {"--artist \tSet artist name\n"}, {"--composer \tSet composer name\n"}, {"--title \tSet title/track name\n"}, {"--genre \tSet genre number\n"}, {"--album \tSet album/performer\n"}, {"--compilation\tMark as compilation\n"}, {"--track \tSet track number\n"}, {"--disc \tSet disc number\n"}, {"--year \tSet year\n"}, {"--cover-art \tRead cover art from file X\n", "\t\tSupported image formats are GIF, JPEG, and PNG.\n"}, {"--comment \tSet comment\n"}, {0} }; static help_t help_advanced[] = { {"--tns \tEnable coding of TNS, temporal noise shaping.\n"}, {"--no-tns\tDisable coding of TNS, temporal noise shaping.\n"}, {"--joint 0\tDisable joint stereo coding.\n"}, {"--joint 1\tUse Mid/Side coding.\n"}, {"--joint 2\tUse Intensity Stereo coding.\n"}, {"--pns <0 .. 10>\tPNS level; 0=disabled.\n"}, {"--mpeg-vers X\tForce AAC MPEG version, X can be 2 or 4\n"}, {"--shortctl X\tEnforce block type (0 = both (default); 1 = no short; 2 = no\n" "\t\tlong).\n"}, {0} }; static struct { int id; char *name; char *option; help_t *help; } g_help[] = { {HELP_QUAL, "Quality-related options", "--help-qual", help_qual}, {HELP_IO, "Input/output options", "--help-io", help_io}, {HELP_MP4, "MP4 specific options", "--help-mp4", help_mp4}, {HELP_ADVANCED, "Advanced options, only for testing purposes", "--help-advanced", help_advanced}, {0} }; char *license = "\nPlease note that the use of this software may require the payment of patent\n" "royalties. You need to consider this issue before you start building derivative\n" "works. We are not warranting or indemnifying you in any way for patent\n" "royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n" "\n" "FAAC is based on the ISO MPEG-4 reference code. For this code base the\n" "following license applies:\n" "\n" "This software module was originally developed by\n" "\n" "FirstName LastName (CompanyName)\n" "\n" "and edited by\n" "\n" "FirstName LastName (CompanyName)\n" "FirstName LastName (CompanyName)\n" "\n" "in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n" "ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n" "implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n" "as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n" "users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n" "software module or modifications thereof for use in hardware or\n" "software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n" "standards. Those intending to use this software module in hardware or\n" "software products are advised that this use may infringe existing\n" "patents. The original developer of this software module and his/her\n" "company, the subsequent editors and their companies, and ISO/IEC have\n" "no liability for use of this software module or modifications thereof\n" "in an implementation. Copyright is not released for non MPEG-2\n" "NBC/MPEG-4 Audio conforming products. The original developer retains\n" "full right to use the code for his/her own purpose, assign or donate\n" "the code to a third party and to inhibit third party from using the\n" "code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n" "copyright notice must be included in all copies or derivative works.\n" "\n" "Copyright (c) 1997.\n" "\n" "For the changes made for the FAAC project the GNU Lesser General Public\n" "License (LGPL), version 2 1991 applies:\n" "\n" "FAAC - Freeware Advanced Audio Coder\n" "Copyright (C) 2001-2004 The individual contributors\n" "\n" "This library is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" "License as published by the Free Software Foundation; either\n" "version 2.1 of the License, or (at your option) any later version.\n" "\n" "This library is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" "Lesser General Public License for more details.\n" "\n" "You should have received a copy of the GNU Lesser General Public\n" "License along with this library; if not, write to the Free Software\n" "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" "\n"; #ifndef min #define min(a,b) ( (a) < (b) ? (a) : (b) ) #endif /* globals */ char *progName; #ifndef _WIN32 volatile int running = 1; #endif enum container_format { NO_CONTAINER, MP4_CONTAINER, }; #ifndef _WIN32 void signal_handler(int signal) { running = 0; } #endif static void help0(help_t *h, int l) { int cnt; for (cnt = 0; h[cnt].shorthelp; cnt++) { printf(" %s", h[cnt].shorthelp); if (l && h[cnt].longhelp) printf("%s", h[cnt].longhelp); } printf("\n\n"); } static void help(int mode) { int cnt; static const char *name = "faac"; printf(usage, name); switch (mode) { case '?': case 'h': case 'H': printf("Help options:\n" "\t-h\t\tShort help on using FAAC\n" "\t-H\t\tDescription of all options for FAAC.\n" "\t--license\tLicense terms for FAAC.\n"); for (cnt = 0; g_help[cnt].id; cnt++) printf("\t%s\t%s\n", g_help[cnt].option, g_help[cnt].name); if (mode == 'h') { for (cnt = 0; cnt < 2; cnt++) { printf("%s:\n", g_help[cnt].name); help0(g_help[cnt].help, 0); } } if (mode == 'H') { for (cnt = 0; cnt < g_help[cnt].id; cnt++) { printf("%s:\n", g_help[cnt].name); help0(g_help[cnt].help, 1); } } break; default: for (cnt = 0; g_help[cnt].id; cnt++) if (g_help[cnt].id == mode) { printf("%s:\n", g_help[cnt].name); help0(g_help[cnt].help, 1); break; } break; } } static int check_image_header(const char *buf) { if (!strncmp(buf, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8)) return 1; /* PNG */ else if (!strncmp(buf, "\xFF\xD8\xFF\xE0", 4) || !strncmp(buf, "\xFF\xD8\xFF\xE1", 4)) return 1; /* JPEG */ else if (!strncmp(buf, "GIF87a", 6) || !strncmp(buf, "GIF89a", 6)) return 1; /* GIF */ else return 0; } static int *mkChanMap(int channels, int center, int lf) { int *map; int inpos; int outpos; if (!center && !lf) return NULL; if (channels < 3) return NULL; if (lf > 0) lf--; else lf = channels - 1; // default AAC position if (center > 0) center--; else center = 0; // default AAC position map = malloc(channels * sizeof(map[0])); memset(map, 0, channels * sizeof(map[0])); outpos = 0; if ((center >= 0) && (center < channels)) map[outpos++] = center; inpos = 0; for (; outpos < (channels - 1); inpos++) { if (inpos == center) continue; if (inpos == lf) continue; map[outpos++] = inpos; } if (outpos < channels) { if ((lf >= 0) && (lf < channels)) map[outpos] = lf; else map[outpos] = inpos; } return map; } #define fprintf if(verbose)fprintf int main(int argc, char *argv[]) { int frames, currentFrame; faacEncHandle hEncoder; pcmfile_t *infile = NULL; unsigned long samplesInput, maxBytesOutput, totalBytesWritten = 0; faacEncConfigurationPtr myFormat; unsigned int mpegVersion = MPEG2; unsigned int objectType = LOW; int jointmode = -1; int pnslevel = -1; static int useTns = 0; enum container_format container = NO_CONTAINER; enum stream_format stream = ADTS_STREAM; int cutOff = -1; int bitRate = 0; unsigned long quantqual = 0; int chanC = 3; int chanLF = 4; char *audioFileName = NULL; char *aacFileName = NULL; char *aacFileExt = NULL; int aacFileNameGiven = 0; float *pcmbuf; int *chanmap = NULL; unsigned char *bitbuf; int samplesRead = 0; const char *dieMessage = NULL; int rawChans = 0; // disabled by default int rawBits = 16; int rawRate = 44100; int rawEndian = 1; int shortctl = SHORTCTL_NORMAL; FILE *outfile = NULL; unsigned int ntracks = 0, trackno = 0; unsigned int ndiscs = 0, discno = 0; static int compilation = 0; const char *artist = NULL, *title = NULL, *album = NULL, *year = NULL, *comment = NULL, *composer = NULL, *tagname = 0, *tagval = 0; int genre = 0; uint8_t *artData = NULL; uint64_t artSize = 0; uint64_t encoded_samples = 0; unsigned int delay_samples; unsigned int frameSize; uint64_t input_samples = 0; char *faac_id_string; char *faac_copyright_string; static int ignorelen = 0; int verbose = 1; static int overwrite = 0; #ifndef _WIN32 // install signal handler signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); #endif // get faac version if (faacEncGetVersion(&faac_id_string, &faac_copyright_string) == FAAC_CFG_VERSION) { fprintf(stderr, "Freeware Advanced Audio Coder\nFAAC %s\n\n", faac_id_string); } else { fprintf(stderr, __FILE__ "(%d): wrong libfaac version\n", __LINE__); return 1; } /* begin process command line */ progName = argv[0]; if (argc < 2) { help('?'); return 1; } while (1) { static struct option long_options[] = { {"help", 0, 0, 'h'}, {"help-qual", 0, 0, HELP_QUAL}, {"help-io", 0, 0, HELP_IO}, {"help-mp4", 0, 0, HELP_MP4}, {"help-advanced", 0, 0, HELP_ADVANCED}, {"raw", 0, 0, 'r'}, {"joint", required_argument, 0, OPT_JOINT}, {"pns", required_argument, 0, OPT_PNS}, {"cutoff", 1, 0, 'c'}, {"quality", 1, 0, 'q'}, {"pcmraw", 0, 0, 'P'}, {"pcmsamplerate", 1, 0, 'R'}, {"pcmsamplebits", 1, 0, 'B'}, {"pcmchannels", 1, 0, 'C'}, {"shortctl", 1, 0, SHORTCTL_FLAG}, {"tns", 0, &useTns, 1}, {"no-tns", 0, &useTns, 0}, {"mpeg-version", 1, 0, MPEGVERS_FLAG}, {"license", 0, 0, 'L'}, {"createmp4", 0, 0, 'w'}, {"artist", 1, 0, ARTIST_FLAG}, {"title", 1, 0, TITLE_FLAG}, {"album", 1, 0, ALBUM_FLAG}, {"track", 1, 0, TRACK_FLAG}, {"disc", 1, 0, DISC_FLAG}, {"genre", 1, 0, GENRE_FLAG}, {"year", 1, 0, YEAR_FLAG}, {"cover-art", 1, 0, COVER_ART_FLAG}, {"comment", 1, 0, COMMENT_FLAG}, {"composer", 1, 0, WRITER_FLAG}, {"compilation", 0, &compilation, 1}, {"pcmswapbytes", 0, 0, 'X'}, {"ignorelength", 0, &ignorelen, 1}, {"tag", 1, 0, TAG_FLAG}, {"overwrite", 0, &overwrite, 1}, {0, 0, 0, 0} }; int c = -1; int option_index = 0; c = getopt_long(argc, argv, "Hhb:m:o:rnc:q:PR:B:C:I:Xwv:", long_options, &option_index); if (c == -1) break; if (!c) continue; switch (c) { case 'o': { int l = strlen(optarg); aacFileName = malloc(l + 1); memcpy(aacFileName, optarg, l); aacFileName[l] = '\0'; aacFileNameGiven = 1; } break; case 'r': { stream = RAW_STREAM; break; } case 'c': { unsigned int i; if (sscanf(optarg, "%u", &i) > 0) { cutOff = i; } break; } case 'b': { unsigned int i; if (sscanf(optarg, "%u", &i) > 0) { bitRate = 1000 * i; } break; } case 'q': { unsigned int i; if (sscanf(optarg, "%u", &i) > 0) { if (i > 0) quantqual = i; } break; } case 'I': sscanf(optarg, "%d,%d", &chanC, &chanLF); break; case 'P': rawChans = 2; // enable raw input break; case 'R': { unsigned int i; if (sscanf(optarg, "%u", &i) > 0) { rawRate = i; rawChans = (rawChans > 0) ? rawChans : 2; } break; } case 'B': { unsigned int i; if (sscanf(optarg, "%u", &i) > 0) { if (i > 32) i = 32; if (i < 8) i = 8; rawBits = i; rawChans = (rawChans > 0) ? rawChans : 2; } break; } case 'C': { unsigned int i; if (sscanf(optarg, "%u", &i) > 0) rawChans = i; break; } case 'w': container = MP4_CONTAINER; break; case ARTIST_FLAG: artist = optarg; break; case WRITER_FLAG: composer = optarg; break; case TITLE_FLAG: title = optarg; break; case ALBUM_FLAG: album = optarg; break; case TRACK_FLAG: if (sscanf(optarg, "%d/%d", &trackno, &ntracks) < 1) dieMessage = "Wrong track number.\n"; break; case DISC_FLAG: if (sscanf(optarg, "%d/%d", &discno, &ndiscs) < 1) dieMessage = "Wrong disc number.\n"; break; case GENRE_FLAG: genre = atoi(optarg); if ((genre < 0) || (genre > 146)) dieMessage = "Genre number out of range.\n"; genre++; break; case YEAR_FLAG: year = optarg; break; case COMMENT_FLAG: comment = optarg; break; case TAG_FLAG: tagname = optarg; if (!(tagval = strchr(optarg, ','))) dieMessage = "Missing tag value.\n"; else *(char *)tagval++ = 0; mp4tag_add(tagname, tagval); break; case COVER_ART_FLAG: { FILE *artFile = fopen(optarg, "rb"); if (artFile) { uint64_t r; fseek(artFile, 0, SEEK_END); artSize = ftell(artFile); artData = malloc(artSize); fseek(artFile, 0, SEEK_SET); clearerr(artFile); r = fread(artData, artSize, 1, artFile); if (r != 1) { dieMessage = "Error reading cover art file!\n"; free(artData); artData = NULL; } else if (artSize < 12 || !check_image_header((const char *) artData)) { /* the above expression checks the image signature */ dieMessage = "Unsupported cover image file format!\n"; free(artData); artData = NULL; } fclose(artFile); } else { dieMessage = "Error opening cover art file!\n"; } break; } case SHORTCTL_FLAG: shortctl = atoi(optarg); break; case MPEGVERS_FLAG: mpegVersion = atoi(optarg); switch (mpegVersion) { case 2: mpegVersion = MPEG2; break; case 4: mpegVersion = MPEG4; break; default: dieMessage = "Unrecognised MPEG version!\n"; } break; case 'L': fprintf(stderr, "%s", faac_copyright_string); dieMessage = license; break; case 'X': rawEndian = 0; break; case 'v': verbose = atoi(optarg); break; case HELP_QUAL: case HELP_IO: case HELP_MP4: case HELP_ADVANCED: case 'H': case 'h': help(c); return 1; break; case OPT_JOINT: jointmode = atoi(optarg); break; case OPT_PNS: pnslevel = atoi(optarg); break; case '?': default: help('?'); return 1; break; } } /* check that we have at least one non-option arguments */ if (!dieMessage && (argc - optind) > 1 && aacFileNameGiven) dieMessage = "Cannot encode several input files to one output file.\n"; if (argc - optind < 1 || dieMessage) { fprintf(stderr, dieMessage, progName, progName, progName, progName); return 1; } while (argc - optind > 0) { /* get the input file name */ audioFileName = argv[optind++]; } /* generate the output file name, if necessary */ if (!aacFileNameGiven) { char *t = strrchr(audioFileName, '.'); int l = t ? strlen(audioFileName) - strlen(t) : strlen(audioFileName); aacFileExt = container == MP4_CONTAINER ? ".m4a" : ".aac"; aacFileName = malloc(l + 1 + 4); memcpy(aacFileName, audioFileName, l); memcpy(aacFileName + l, aacFileExt, 4); aacFileName[l + 4] = '\0'; } else { aacFileExt = strrchr(aacFileName, '.'); if (aacFileExt && (!strcmp(".m4a", aacFileExt) || !strcmp(".m4b", aacFileExt) || !strcmp(".mp4", aacFileExt))) container = MP4_CONTAINER; } /* open the audio input file */ if (rawChans > 0) // use raw input { infile = wav_open_read(audioFileName, 1); if (infile) { infile->bigendian = rawEndian; infile->channels = rawChans; infile->samplebytes = rawBits / 8; infile->samplerate = rawRate; infile->samples /= (infile->channels * infile->samplebytes); } } else // header input infile = wav_open_read(audioFileName, 0); if (infile == NULL) { fprintf(stderr, "Couldn't open input file %s\n", audioFileName); return 1; } /* open the encoder library */ hEncoder = faacEncOpen(infile->samplerate, infile->channels, &samplesInput, &maxBytesOutput); if (hEncoder == NULL) { fprintf(stderr, "Couldn't open encoder instance for input file %s\n", audioFileName); wav_close(infile); return 1; } if (container != MP4_CONTAINER && (ntracks || trackno || artist || title || album || year || artData || genre || comment || discno || ndiscs || composer || compilation)) { fprintf(stderr, "Metadata requires MP4 output!\n"); return 1; } if (container == MP4_CONTAINER) { mpegVersion = MPEG4; stream = RAW_STREAM; } frameSize = samplesInput / infile->channels; delay_samples = frameSize; // encoder delay 1024 samples pcmbuf = (float *) malloc(samplesInput * sizeof(float)); bitbuf = (unsigned char *) malloc(maxBytesOutput * sizeof(unsigned char)); chanmap = mkChanMap(infile->channels, chanC, chanLF); if (chanmap) { fprintf(stderr, "Remapping input channels: Center=%d, LFE=%d\n", chanC, chanLF); } if (cutOff <= 0) { if (cutOff < 0) // default cutOff = 0; else // disabled cutOff = infile->samplerate / 2; } if (cutOff > (infile->samplerate / 2)) cutOff = infile->samplerate / 2; /* put the options in the configuration struct */ myFormat = faacEncGetCurrentConfiguration(hEncoder); myFormat->aacObjectType = objectType; myFormat->mpegVersion = mpegVersion; myFormat->useTns = useTns; switch (shortctl) { case SHORTCTL_NOSHORT: fprintf(stderr, "disabling short blocks\n"); myFormat->shortctl = shortctl; break; case SHORTCTL_NOLONG: fprintf(stderr, "disabling long blocks\n"); myFormat->shortctl = shortctl; break; } if (infile->channels >= 6) myFormat->useLfe = 1; if (jointmode >= 0) myFormat->jointmode = jointmode; if (pnslevel >= 0) myFormat->pnslevel = pnslevel; if (quantqual > 0) { myFormat->quantqual = quantqual; myFormat->bitRate = 0; } if (bitRate) myFormat->bitRate = bitRate / infile->channels; myFormat->bandWidth = cutOff; myFormat->outputFormat = stream; myFormat->inputFormat = FAAC_INPUT_FLOAT; if (!faacEncSetConfiguration(hEncoder, myFormat)) { fprintf(stderr, "Unsupported output format!\n"); return 1; } /* initialize MP4 creation */ if (container == MP4_CONTAINER) { if (!strcmp(aacFileName, "-")) { fprintf(stderr, "cannot encode MP4 to stdout\n"); return 1; } if (mp4atom_open(aacFileName, overwrite)) { fprintf(stderr, "Couldn't create output file %s\n", aacFileName); return 1; } mp4atom_head(); mp4config.samplerate = infile->samplerate; mp4config.channels = infile->channels; mp4config.bits = infile->samplebytes * 8; } else { /* open the aac output file */ if (!strcmp(aacFileName, "-")) { outfile = stdout; } else { outfile = fopen(aacFileName, "wb"); } if (!outfile) { fprintf(stderr, "Couldn't create output file %s\n", aacFileName); return 1; } } cutOff = myFormat->bandWidth; quantqual = myFormat->quantqual; bitRate = myFormat->bitRate; if (bitRate) { fprintf(stderr, "Initial quantization quality: %ld\n", quantqual); fprintf(stderr, "Average bitrate: %d kbps/channel\n", (bitRate + 500) / 1000); } else fprintf(stderr, "Quantization quality: %ld\n", quantqual); fprintf(stderr, "Bandwidth: %d Hz\n", cutOff); if (myFormat->pnslevel > 0) fprintf(stderr, "PNS level: %d\n", myFormat->pnslevel); fprintf(stderr, "Object type: "); switch (objectType) { case LOW: fprintf(stderr, "Low Complexity"); break; case MAIN: fprintf(stderr, "Main"); break; case LTP: fprintf(stderr, "LTP"); break; } fprintf(stderr, "(MPEG-%d)", (mpegVersion == MPEG4) ? 4 : 2); if (myFormat->useTns) fprintf(stderr, " + TNS"); switch(myFormat->jointmode) { case JOINT_MS: fprintf(stderr, " + M/S"); break; case JOINT_IS: fprintf(stderr, " + IS"); break; } if (myFormat->pnslevel > 0) fprintf(stderr, " + PNS"); fprintf(stderr, "\n"); fprintf(stderr, "Container format: "); switch (container) { case NO_CONTAINER: switch (stream) { case RAW_STREAM: fprintf(stderr, "Headerless AAC (RAW)\n"); break; case ADTS_STREAM: fprintf(stderr, "Transport Stream (ADTS)\n"); break; } break; case MP4_CONTAINER: fprintf(stderr, "MPEG-4 File Format (MP4)\n"); break; } int showcnt = 0; #ifdef _WIN32 long begin = GetTickCount(); #endif if (infile->samples) frames = ((infile->samples + 1023) / 1024) + 1; else frames = 0; currentFrame = 0; fprintf(stderr, "Encoding %s to %s\n", audioFileName, aacFileName); if (frames != 0) { fprintf(stderr, " frame | bitrate | elapsed/estim | " "play/CPU | ETA\n"); } else { fprintf(stderr, " frame | elapsed | play/CPU\n"); } /* encoding loop */ #ifdef _WIN32 for (;;) #else while (running) #endif { int bytesWritten; if (!ignorelen) { if (input_samples < infile->samples || infile->samples == 0) samplesRead = wav_read_float32(infile, pcmbuf, samplesInput, chanmap); else samplesRead = 0; if (input_samples + (samplesRead / infile->channels) > infile->samples && infile->samples != 0) samplesRead = (infile->samples - input_samples) * infile->channels; } else samplesRead = wav_read_float32(infile, pcmbuf, samplesInput, chanmap); input_samples += samplesRead / infile->channels; /* call the actual encoding routine */ bytesWritten = faacEncEncode(hEncoder, (int32_t *) pcmbuf, samplesRead, bitbuf, maxBytesOutput); if (bytesWritten) { currentFrame++; showcnt--; totalBytesWritten += bytesWritten; } if ((showcnt <= 0) || !bytesWritten) { double timeused; #ifdef __unix__ struct rusage usage; #endif #ifdef _WIN32 char percent[MAX_PATH + 20]; timeused = (GetTickCount() - begin) * 1e-3; #else #ifdef __unix__ if (getrusage(RUSAGE_SELF, &usage) == 0) { timeused = (double) usage.ru_utime.tv_sec + (double) usage.ru_utime.tv_usec * 1e-6; } else timeused = 0; #else timeused = (double) clock() * (1.0 / CLOCKS_PER_SEC); #endif #endif if (currentFrame && (timeused > 0.1)) { showcnt += 50; if (frames != 0) { fprintf(stderr, "\r%5d/%-5d (%3d%%)| %5.1f | %6.1f/%-6.1f | %7.2fx | %.1f ", currentFrame, frames, currentFrame * 100 / frames, ((double) totalBytesWritten * 8.0 / 1000.0) / ((double) infile->samples / infile->samplerate * currentFrame / frames), timeused, timeused * frames / currentFrame, (1024.0 * currentFrame / infile->samplerate) / timeused, timeused * (frames - currentFrame) / currentFrame); } else { fprintf(stderr, "\r %5d | %6.1f | %7.2fx ", currentFrame, timeused, (1024.0 * currentFrame / infile->samplerate) / timeused); } fflush(stderr); #ifdef _WIN32 if (frames != 0) { sprintf(percent, "%.2f%% encoding %s", 100.0 * currentFrame / frames, audioFileName); SetConsoleTitle(percent); } #endif } } /* all done, bail out */ if (!samplesRead && !bytesWritten) break; if (bytesWritten < 0) { fprintf(stderr, "faacEncEncode() failed\n"); break; } if (bytesWritten > 0) { uint64_t frame_samples = input_samples - encoded_samples; if (frame_samples > delay_samples) frame_samples = delay_samples; if (container == MP4_CONTAINER) mp4atom_frame(bitbuf, bytesWritten, frame_samples); else fwrite(bitbuf, 1, bytesWritten, outfile); encoded_samples += frame_samples; } } fprintf(stderr, "\n"); if (container == MP4_CONTAINER) { char *version_string = malloc(strlen(faac_id_string) + 6); faacEncGetDecoderSpecificInfo(hEncoder, &mp4config.asc.data, &mp4config.asc.size); strcpy(version_string, "FAAC "); strcpy(version_string + 5, faac_id_string); mp4config.tag.encoder = version_string; #define SETTAG(x) if(x)mp4config.tag.x=x SETTAG(artist); SETTAG(composer); SETTAG(title); SETTAG(album); SETTAG(trackno); SETTAG(ntracks); SETTAG(discno); SETTAG(ndiscs); SETTAG(compilation); SETTAG(year); SETTAG(genre); SETTAG(comment); if (artData && artSize) { mp4config.tag.cover.data = artData; mp4config.tag.cover.size = artSize; } mp4atom_tail(); mp4atom_close(); free(version_string); if (verbose >= 2) { fprintf(stderr, "%u frames\n", mp4config.frame.ents); fprintf(stderr, "%u output samples\n", mp4config.samples); fprintf(stderr, "max bitrate: %u\n", mp4config.bitrate.max); fprintf(stderr, "avg bitrate: %u\n", mp4config.bitrate.avg); fprintf(stderr, "max frame size: %u\n", mp4config.buffersize); } } else { fclose(outfile); } faacEncClose(hEncoder); wav_close(infile); if (artData) free(artData); if (pcmbuf) free(pcmbuf); if (bitbuf) free(bitbuf); if (aacFileNameGiven) free(aacFileName); return 0; } faac-1_30/frontend/maingui.c000066400000000000000000000331341355157314300160370ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: maingui.c,v 1.21 2007/03/19 19:57:40 menno Exp $ */ #include #include #include #include #include "input.h" #include #include "resource.h" static HINSTANCE hInstance; static char inputFilename[_MAX_PATH], outputFilename[_MAX_PATH]; static BOOL Encoding = FALSE; static BOOL SelectFileName(HWND hParent, char *filename, BOOL forReading) { OPENFILENAME ofn; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hParent; ofn.hInstance = hInstance; ofn.nFilterIndex = 0; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 31; filename [0] = 0x00; ofn.lpstrFile = (LPSTR)filename; ofn.nMaxFile = _MAX_PATH; ofn.lpstrInitialDir = NULL; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFileOffset = 0; ofn.nFileExtension = 0; ofn.lCustData = 0; ofn.lpfnHook = NULL; ofn.lpTemplateName = NULL; if (forReading) { char filters[] = { "Wave Files (*.wav)\0*.wav\0" \ "AIFF Files (*.aif;*.aiff;*.aifc)\0*.aif;*.aiff;*.aifc\0" \ "AU Files (*.au)\0*.au\0" \ "All Files (*.*)\0*.*\0\0" }; ofn.lpstrFilter = filters; ofn.lpstrDefExt = "wav"; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrTitle = "Select Source File"; return GetOpenFileName (&ofn); } else { char filters [] = { "AAC Files (*.aac)\0*.aac\0" \ "All Files (*.*)\0*.*\0\0" }; ofn.lpstrFilter = filters; ofn.lpstrDefExt = "aac"; ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; ofn.lpstrTitle = "Select Output File"; return GetSaveFileName(&ofn); } } static void AwakeDialogControls(HWND hWnd) { char szTemp[64]; pcmfile_t *infile = NULL; unsigned int sampleRate, numChannels; char *pExt; if ((infile = wav_open_read(inputFilename, 0)) == NULL) return; /* determine input file parameters */ sampleRate = infile->samplerate; numChannels = infile->channels; wav_close(infile); SetDlgItemText (hWnd, IDC_INPUTFILENAME, inputFilename); strncpy(outputFilename, inputFilename, sizeof(outputFilename) - 5); pExt = strrchr(outputFilename, '.'); if (pExt == NULL) lstrcat(outputFilename, ".aac"); else lstrcpy(pExt, ".aac"); EnableWindow(GetDlgItem(hWnd, IDC_OUTPUTFILENAME), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_SELECT_OUTPUTFILE), TRUE); SetDlgItemText(hWnd, IDC_OUTPUTFILENAME, outputFilename); wsprintf(szTemp, "%iHz %ich", sampleRate, numChannels); SetDlgItemText(hWnd, IDC_INPUTPARAMS, szTemp); EnableWindow(GetDlgItem(hWnd, IDOK), TRUE); } static DWORD WINAPI EncodeFile(LPVOID pParam) { HWND hWnd = (HWND) pParam; pcmfile_t *infile = NULL; GetDlgItemText(hWnd, IDC_INPUTFILENAME, inputFilename, sizeof(inputFilename)); GetDlgItemText(hWnd, IDC_OUTPUTFILENAME, outputFilename, sizeof(outputFilename)); /* open the input file */ if ((infile = wav_open_read(inputFilename, 0)) != NULL) { /* determine input file parameters */ unsigned int sampleRate = infile->samplerate; unsigned int numChannels = infile->channels; unsigned long inputSamples; unsigned long maxOutputBytes; /* open and setup the encoder */ faacEncHandle hEncoder = faacEncOpen(sampleRate, numChannels, &inputSamples, &maxOutputBytes); if (hEncoder) { HANDLE hOutfile; char szTemp[256]; /* set encoder configuration */ faacEncConfigurationPtr config = faacEncGetCurrentConfiguration(hEncoder); config->jointmode = IsDlgButtonChecked(hWnd, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0; config->useTns = IsDlgButtonChecked(hWnd, IDC_USETNS) == BST_CHECKED ? 1 : 0; config->useLfe = IsDlgButtonChecked(hWnd, IDC_USELFE) == BST_CHECKED ? 1 : 0; config->outputFormat = IsDlgButtonChecked(hWnd, IDC_USERAW) == BST_CHECKED ? 0 : 1; config->mpegVersion = SendMessage(GetDlgItem(hWnd, IDC_MPEGVERSION), CB_GETCURSEL, 0, 0); config->aacObjectType = SendMessage(GetDlgItem(hWnd, IDC_OBJECTTYPE), CB_GETCURSEL, 0, 0); if (config->aacObjectType == SSR) /* Set to LTP */ config->aacObjectType = LTP; GetDlgItemText(hWnd, IDC_QUALITY, szTemp, sizeof(szTemp)); config->quantqual = atoi(szTemp); if (IsDlgButtonChecked(hWnd, IDC_BWCTL) == BST_CHECKED) { GetDlgItemText(hWnd, IDC_BANDWIDTH, szTemp, sizeof(szTemp)); config->bandWidth = atoi(szTemp); } else config->bandWidth = 0; if (!faacEncSetConfiguration(hEncoder, config)) { faacEncClose(hEncoder); wav_close(infile); MessageBox (hWnd, "faacEncSetConfiguration failed!", "Error", MB_OK | MB_ICONSTOP); SendMessage(hWnd,WM_SETTEXT,0,(long)"FAAC GUI"); Encoding = FALSE; SetDlgItemText(hWnd, IDOK, "Encode"); return 0; } sprintf(szTemp, "%ld", config->quantqual); SetDlgItemText(hWnd, IDC_QUALITY, szTemp); sprintf(szTemp, "%d", config->bandWidth); SetDlgItemText(hWnd, IDC_BANDWIDTH, szTemp); /* open the output file */ hOutfile = CreateFile(outputFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hOutfile != INVALID_HANDLE_VALUE) { UINT startTime = GetTickCount(), lastUpdated = 50; DWORD totalBytesRead = 0; unsigned int bytesInput = 0; DWORD numberOfBytesWritten = 0; int *pcmbuf; unsigned char *bitbuf; char HeaderText[50]; char Percentage[5]; pcmbuf = (int*)LocalAlloc(0, inputSamples*sizeof(int)); bitbuf = (unsigned char*)LocalAlloc(0, maxOutputBytes*sizeof(unsigned char)); SendDlgItemMessage(hWnd, IDC_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0, 1024)); SendDlgItemMessage(hWnd, IDC_PROGRESS, PBM_SETPOS, 0, 0); for ( ;; ) { int bytesWritten; UINT timeElapsed, timeEncoded; bytesInput = wav_read_int24(infile, pcmbuf, inputSamples, NULL) * sizeof(int); SendDlgItemMessage (hWnd, IDC_PROGRESS, PBM_SETPOS, (unsigned long)((float)totalBytesRead * 1024.0f / (infile->samples*sizeof(int)*numChannels)), 0); /* Percentage for Dialog Output */ _itoa((int)((float)totalBytesRead * 100.0f / (infile->samples*sizeof(int)*numChannels)),Percentage,10); lstrcpy(HeaderText,"FAAC GUI: "); lstrcat(HeaderText,Percentage); lstrcat(HeaderText,"%"); SendMessage(hWnd,WM_SETTEXT,0,(long)HeaderText); totalBytesRead += bytesInput; timeElapsed = (GetTickCount () - startTime) / 10; timeEncoded = 100.0 * totalBytesRead / (sampleRate * numChannels * sizeof (int)); if (timeElapsed > (lastUpdated + 20)) { float factor; unsigned timeLeft; lastUpdated = timeElapsed; factor = (float) timeEncoded / (float) (timeElapsed ? timeElapsed : 1); timeLeft = 10.0 * infile->samples / sampleRate / factor - 0.1 * timeElapsed; sprintf(szTemp, "Playing time: %2.2i:%04.1f\tEncoding time: %2.2i:%04.1f\n" "Play/enc factor: %.2f\tEstimated time left: %2.2i:%04.1f", timeEncoded / 6000, 0.01 * (timeEncoded % 6000), timeElapsed / 6000, 0.01 * (timeElapsed % 6000), factor, timeLeft / 600, 0.1 * (timeLeft % 600) ); SetDlgItemText(hWnd, IDC_TIME, szTemp); } /* call the actual encoding routine */ bytesWritten = faacEncEncode(hEncoder, pcmbuf, bytesInput/sizeof(int), bitbuf, maxOutputBytes); /* Stop Pressed */ if ( !Encoding ) break; /* all done, bail out */ if (!bytesInput && !bytesWritten) break; if (bytesWritten < 0) { MessageBox (hWnd, "faacEncEncodeFrame failed!", "Error", MB_OK | MB_ICONSTOP); break; } WriteFile(hOutfile, bitbuf, bytesWritten, &numberOfBytesWritten, NULL); } CloseHandle(hOutfile); if (pcmbuf) LocalFree(pcmbuf); if (bitbuf) LocalFree(bitbuf); } faacEncClose(hEncoder); } wav_close(infile); MessageBeep(1); SendDlgItemMessage(hWnd, IDC_PROGRESS, PBM_SETPOS, 0, 0); } else { MessageBox(hWnd, "Couldn't open input file!", "Error", MB_OK | MB_ICONSTOP); } SendMessage(hWnd,WM_SETTEXT,0,(long)"FAAC GUI"); Encoding = FALSE; SetDlgItemText(hWnd, IDOK, "Encode"); return 0; } static BOOL WINAPI DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { unsigned long samplesInput, maxBytesOutput; faacEncHandle hEncoder = faacEncOpen(44100, 2, &samplesInput, &maxBytesOutput); faacEncConfigurationPtr myFormat = faacEncGetCurrentConfiguration(hEncoder); if (myFormat->version == FAAC_CFG_VERSION) { char txt[100]; sprintf(txt, "libfaac version %s", myFormat->name); SetDlgItemText(hWnd, IDC_COMPILEDATE, txt); } else { MessageBox(hWnd, "wrong libfaac version", "FAAC", MB_OK | MB_ICONERROR); PostMessage(hWnd, WM_CLOSE, 0, 0); } faacEncClose(hEncoder); } inputFilename[0] = 0x00; SendMessage(GetDlgItem(hWnd, IDC_MPEGVERSION), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"MPEG4"); SendMessage(GetDlgItem(hWnd, IDC_MPEGVERSION), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"MPEG2"); SendMessage(GetDlgItem(hWnd, IDC_MPEGVERSION), CB_SETCURSEL, 0, 0); // SendMessage(GetDlgItem(hWnd, IDC_OBJECTTYPE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"Main"); SendMessage(GetDlgItem(hWnd, IDC_OBJECTTYPE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"Low Complexity"); // SendMessage(GetDlgItem(hWnd, IDC_OBJECTTYPE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"LTP"); SendMessage(GetDlgItem(hWnd, IDC_OBJECTTYPE), CB_SETCURSEL, 0, 0); CheckDlgButton(hWnd, IDC_ALLOWMIDSIDE, TRUE); CheckDlgButton(hWnd, IDC_USELFE, FALSE); CheckDlgButton(hWnd, IDC_USERAW, FALSE); CheckDlgButton(hWnd, IDC_USETNS, TRUE); SetDlgItemText(hWnd, IDC_QUALITY, "100"); SetDlgItemText(hWnd, IDC_BANDWIDTH, "0"); DragAcceptFiles(hWnd, TRUE); return TRUE; case WM_DROPFILES: if (DragQueryFile((HDROP) wParam, 0, (LPSTR) inputFilename, _MAX_PATH - 1)) AwakeDialogControls(hWnd); DragFinish((HDROP) wParam); return FALSE; case WM_COMMAND: switch (wParam) { case IDOK: if ( !Encoding ) { DWORD retval; CreateThread(NULL,0,EncodeFile,hWnd,0,&retval); Encoding = TRUE; SetDlgItemText(hWnd, IDOK, "Stop"); } else { Encoding = FALSE; SetDlgItemText(hWnd, IDOK, "Encode"); } return TRUE; case IDCANCEL: EndDialog(hWnd, TRUE); return TRUE; case IDC_SELECT_INPUTFILE: if (SelectFileName(hWnd, inputFilename, TRUE)) AwakeDialogControls(hWnd); break; case IDC_SELECT_OUTPUTFILE: if (SelectFileName(hWnd, outputFilename, FALSE)) { SetDlgItemText(hWnd, IDC_OUTPUTFILENAME, outputFilename); } break; case IDC_BWCTL: switch (IsDlgButtonChecked(hWnd, IDC_BWCTL)) { case BST_CHECKED: EnableWindow(GetDlgItem(hWnd, IDC_BANDWIDTH), TRUE); //SetDlgItemText(hWnd, IDC_BANDWIDTH, "0"); break; case BST_UNCHECKED: EnableWindow(GetDlgItem(hWnd, IDC_BANDWIDTH), FALSE); //SetDlgItemText(hWnd, IDC_BANDWIDTH, ""); break; } break; } break; } return FALSE; } int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { hInstance = hInst; return DialogBox(hInstance, MAKEINTRESOURCE (IDD_MAINDIALOG), NULL, (DLGPROC) DialogProc); } faac-1_30/frontend/mp4write.c000066400000000000000000000474071355157314300161710ustar00rootroot00000000000000/**************************************************************************** MP4 output module Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #ifndef WORDS_BIGENDIAN //#include #endif #include #include #include #include "mp4write.h" enum ATOM_TYPE { ATOM_STOP = 0 /* end of atoms */ , ATOM_NAME /* plain atom */ , ATOM_DESCENT, /* starts group of children */ ATOM_ASCENT, /* ends group */ ATOM_DATA, }; typedef struct { uint16_t opcode; void *data; } creator_t; mp4config_t mp4config = { 0 }; static FILE *g_fout = NULL; static inline uint32_t be32(uint32_t u32) { #ifndef WORDS_BIGENDIAN #if defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) return __builtin_bswap32(u32); #elif defined (_MSC_VER) return _byteswap_ulong(u32); #else return (u32 << 24) | ((u32 << 8) & 0xFF0000) | ((u32 >> 8) & 0xFF00) | (u32 >> 24); #endif #else return u32; #endif } static inline uint16_t be16(uint16_t u16) { #ifndef WORDS_BIGENDIAN #if defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))) return __builtin_bswap16(u16); #elif defined (_MSC_VER) return _byteswap_ushort(u16); #else return (u16 << 8) | (u16 >> 8); #endif #else return u16; #endif } static int dataout(const void *data, int size) { if (fwrite(data, 1, size, g_fout) != size) { perror("mp4out"); return -1; } return size; } static int stringout(const char *txt) { return dataout(txt, strlen(txt)); } static int u32out(uint32_t u32) { u32 = be32(u32); return dataout(&u32, 4); } static int u16out(uint16_t u16) { u16 = be16(u16); return dataout(&u16, 2); } static int u8out(uint8_t u8) { if (fwrite(&u8, 1, 1, g_fout) != 1) { perror("mp4 out"); return 0; } return 1; } static int ftypout(void) { int size = 0; size += stringout("M4A "); size += u32out(0); size += stringout("M4A "); size += stringout("mp42"); size += stringout("isom"); size += u32out(0); return size; } enum { SECSINDAY = 24 * 60 * 60 }; static time_t mp4time(void) { int y; time_t t; time(&t); // add some time from the start of 1904 to the start of 1970 for (y = 1904; y < 1970; y++) { t += 365 * SECSINDAY; if (!(y & 3)) t += SECSINDAY; } return t; } static int mvhdout(void) { int size = 0; int cnt; // version size += u8out(0); // flags size += u8out(0); size += u16out(0); // Creation time size += u32out(mp4time()); // Modification time size += u32out(mp4time()); // Time scale (samplerate) size += u32out(mp4config.samplerate); // Duration size += u32out(mp4config.samples); // rate size += u32out(0x00010000); // volume size += u16out(0x0100); // reserved size += u16out(0); size += u32out(0); size += u32out(0); // matrix size += u32out(0x00010000); size += u32out(0); size += u32out(0); size += u32out(0); size += u32out(0x00010000); size += u32out(0); size += u32out(0); size += u32out(0); size += u32out(0x40000000); for (cnt = 0; cnt < 6; cnt++) size += u32out(0); // Next track ID size += u32out(2); return size; }; static int tkhdout(void) { int size = 0; // version size += u8out(0); // flags // bits 8-23 size += u16out(0); // bits 0-7 size += u8out(1 /*track enabled */ ); // Creation time size += u32out(mp4time()); // Modification time size += u32out(mp4time()); // Track ID size += u32out(1); // Reserved size += u32out(0); // Duration size += u32out(mp4config.samples); // Reserved size += u32out(0); size += u32out(0); // Layer size += u16out(0); // Alternate group size += u16out(0); // Volume size += u16out(0x0100); // Reserved size += u16out(0); // matrix size += u32out(0x00010000); size += u32out(0); size += u32out(0); size += u32out(0); size += u32out(0x00010000); size += u32out(0); size += u32out(0); size += u32out(0); size += u32out(0x40000000); // Track width size += u32out(0); // Track height size += u32out(0); return size; }; static int mdhdout(void) { int size = 0; // version/flags size += u32out(0); // Creation time size += u32out(mp4time()); // Modification time size += u32out(mp4time()); // Time scale size += u32out(mp4config.samplerate); // Duration size += u32out(mp4config.samples); // Language size += u16out(0 /*0=English */ ); // pre_defined size += u16out(0); return size; }; static int hdlr1out(void) { int size = 0; // version/flags size += u32out(0); // pre_defined size += u32out(0); // Component subtype size += stringout("soun"); // reserved size += u32out(0); size += u32out(0); size += u32out(0); // name // null terminate size += u8out(0); return size; }; static int smhdout(void) { int size = 0; // version/flags size += u32out(0); // Balance size += u16out(0 /*center */ ); // Reserved size += u16out(0); return size; }; static int drefout(void) { int size = 0; // version/flags size += u32out(0); // Number of entries size += u32out(1 /*url reference */ ); return size; }; static int urlout(void) { int size = 0; size += u32out(1); return size; }; static int stsdout(void) { int size = 0; // version/flags size += u32out(0); // Number of entries(one 'mp4a') size += u32out(1); return size; }; static int mp4aout(void) { int size = 0; // Reserved (6 bytes) size += u32out(0); size += u16out(0); // Data reference index size += u16out(1); // Version size += u16out(0); // Revision level size += u16out(0); // Vendor size += u32out(0); // Number of channels size += u16out(mp4config.channels); // Sample size (bits) size += u16out(mp4config.bits); // Compression ID size += u16out(0); // Packet size size += u16out(0); // Sample rate (16.16) // rate integer part size += u16out(mp4config.samplerate); // rate reminder part size += u16out(0); return size; } static int esdsout(void) { int size = 0; // descriptor definitions: // systems/mp4_file_format/libisomediafile/src/MP4Descriptors.h // systems/mp4_file_format/libisomediafile/src/MP4Descriptors.c // // descriptor tree: // MP4ES_Descriptor // MP4DecoderConfigDescriptor // MP4DecSpecificInfoDescriptor // MP4SLConfigDescriptor struct { int es; int dc; // DecoderConfig int dsi; // DecSpecificInfo int sl; // SLConfig } dsize; enum { TAG_ES = 3, TAG_DC = 4, TAG_DSI = 5, TAG_SLC = 6 }; // calc sizes #define DESCSIZE(x) (x + 5/*.tag+.size*/) dsize.sl = 1; dsize.dsi = mp4config.asc.size; dsize.dc = 13 + DESCSIZE(dsize.dsi); dsize.es = 3 + DESCSIZE(dsize.dc) + DESCSIZE(dsize.sl); // output esds atom data // version/flags ? size += u32out(0); // mp4es size += u8out(TAG_ES); size += u8out(0x80); size += u8out(0x80); size += u8out(0x80); size += u8out(dsize.es); // ESID size += u16out(0); // flags(url(bit 6); ocr(5); streamPriority (0-4)): size += u8out(0); size += u8out(TAG_DC); size += u8out(0x80); size += u8out(0x80); size += u8out(0x80); size += u8out(dsize.dc); size += u8out(0x40 /*MPEG-4 audio */ ); size += u8out((5 << 2) /* AudioStream */ | 1 /* reserved = 1 */); // decode buffer size bytes #if 0 size += u16out(mp4config.buffersize >> 8); size += u8out(mp4config.buffersize && 0xff); #else size += u8out(0); size += u8out(0x18); size += u8out(0); #endif // bitrate size += u32out(mp4config.bitrate.max); size += u32out(mp4config.bitrate.avg); size += u8out(TAG_DSI); size += u8out(0x80); size += u8out(0x80); size += u8out(0x80); size += u8out(dsize.dsi); // AudioSpecificConfig size += dataout(mp4config.asc.data, mp4config.asc.size); size += u8out(TAG_SLC); size += u8out(0x80); size += u8out(0x80); size += u8out(0x80); size += u8out(dsize.sl); // "predefined" (no idea) size += u8out(2); return size; } static int sttsout(void) { int size = 0; // version/flags size += u32out(0); // Number of entries size += u32out(1); // only one entry // Sample count (number of frames) size += u32out(mp4config.frame.ents); // Sample duration (samples per frame) size += u32out(mp4config.framesamples); return size; } static int stszout(void) { int size = 0; int cnt; // version/flags size += u32out(0); // Sample size size += u32out(0 /*i.e. variable size */ ); // Number of entries if (!mp4config.frame.ents) return size; if (!mp4config.frame.data) return size; size += u32out(mp4config.frame.ents); for (cnt = 0; cnt < mp4config.frame.ents; cnt++) size += u32out(mp4config.frame.data[cnt]); return size; } static int stscout(void) { int size = 0; // version/flags size += u32out(0); // Number of entries size += u32out(1); // first chunk size += u32out(1); // frames in chunk size += u32out(mp4config.frame.ents); // sample id size += u32out(1); return size; } static int stcoout(void) { int size = 0; // version/flags size += u32out(0); // Number of entries size += u32out(1); // Chunk offset table size += u32out(mp4config.mdatofs); return size; } static int tagtxt(char *tagname, const char *tagtxt) { int txtsize = strlen(tagtxt); int size = 0; int datasize = txtsize + 16; size += u32out(datasize + 8); size += dataout(tagname, 4); size += u32out(datasize); size += dataout("data", 4); size += u32out(1); // data type text size += u32out(0); size += dataout(tagtxt, txtsize); return size; } static int tagu16(char *tagname, int n /*number of stored fields*/) { int numsize = n * 2; int size = 0; int datasize = numsize + 16; size += u32out(datasize + 8); size += dataout(tagname, 4); size += u32out(datasize); size += dataout("data", 4); size += u32out(0); // data type uint16 size += u32out(0); return size; } static int tagu8(char *tagname, int n /*number of stored fields*/) { int numsize = n * 1; int size = 0; int datasize = numsize + 16; size += u32out(datasize + 8); size += dataout(tagname, 4); size += u32out(datasize); size += dataout("data", 4); size += u32out(0x15); // data type uint8 size += u32out(0); return size; } static int tagimage(char *tagname, int n /*image size*/) { int numsize = n; int size = 0; int datasize = numsize + 16; size += u32out(datasize + 8); size += dataout(tagname, 4); size += u32out(datasize); size += dataout("data", 4); size += u32out(0x0d); // data type: image size += u32out(0); return size; } static int metaout(void) { int size = 0; // version/flags size += u32out(0); return size; } static int hdlr2out(void) { int size = 0; // version/flags size += u32out(0); // Predefined size += u32out(0); // Handler type size += stringout("mdir"); size += stringout("appl"); // Reserved size += u32out(0); size += u32out(0); // null terminator size += u8out(0); return size; }; static int ilstout(void) { int size = 0; int cnt; size += tagtxt("\xa9" "too", mp4config.tag.encoder); if (mp4config.tag.artist) size += tagtxt("\xa9" "ART", mp4config.tag.artist); if (mp4config.tag.composer) size += tagtxt("\xa9" "wrt", mp4config.tag.composer); if (mp4config.tag.title) size += tagtxt("\xa9" "nam", mp4config.tag.title); if (mp4config.tag.genre) { size += tagu16("gnre", 1); size += u16out(mp4config.tag.genre); } if (mp4config.tag.album) size += tagtxt("\xa9" "alb", mp4config.tag.album); if (mp4config.tag.compilation) { size += tagu8("cpil", 1); size += u8out(mp4config.tag.compilation); } if (mp4config.tag.trackno) { size += tagu16("trkn", 4); size += u16out(0); size += u16out(mp4config.tag.trackno); size += u16out(mp4config.tag.ntracks); size += u16out(0); } if (mp4config.tag.discno) { size += tagu16("disk", 4); size += u16out(0); size += u16out(mp4config.tag.discno); size += u16out(mp4config.tag.ndiscs); size += u16out(0); } if (mp4config.tag.year) size += tagtxt("\xa9" "day", mp4config.tag.year); if (mp4config.tag.cover.data) { size += tagimage("covr", mp4config.tag.cover.size); size += dataout(mp4config.tag.cover.data, mp4config.tag.cover.size); } if (mp4config.tag.comment) size += tagtxt("\xa9" "cmt", mp4config.tag.comment); // ----(mean(com.apple.iTunes),name(name),data(data)) for (cnt = 0; cnt < mp4config.tag.extnum; cnt++) { static const char *mean = "faac";//"com.apple.iTunes"; const char *name = mp4config.tag.ext[cnt].name; const char *data = mp4config.tag.ext[cnt].data; uint32_t len1 = 8 + strlen(mean) + 4; uint32_t len2 = 8 + strlen(name) + 4; uint32_t len3 = 8 + strlen(data) + 4 + 4; u32out(8 + len1 + len2 + len3); size += 8 + len1 + len2 + len3; stringout("----"); u32out(len1); stringout("mean"); u32out(0); stringout(mean); u32out(len2); stringout("name"); u32out(0); stringout(name); u32out(len3); stringout("data"); u32out(1); u32out(0); stringout(data); } return size; }; static creator_t g_head[] = { {ATOM_NAME, "ftyp"}, {ATOM_DATA, ftypout}, {ATOM_NAME, "free"}, {ATOM_NAME, "mdat"}, {0} }; static creator_t g_tail[] = { {ATOM_NAME, "moov"}, {ATOM_DESCENT}, {ATOM_NAME, "mvhd"}, {ATOM_DATA, mvhdout}, {ATOM_NAME, "trak"}, {ATOM_DESCENT}, {ATOM_NAME, "tkhd"}, {ATOM_DATA, tkhdout}, {ATOM_NAME, "mdia"}, {ATOM_DESCENT}, {ATOM_NAME, "mdhd"}, {ATOM_DATA, mdhdout}, {ATOM_NAME, "hdlr"}, {ATOM_DATA, hdlr1out}, {ATOM_NAME, "minf"}, {ATOM_DESCENT}, {ATOM_NAME, "smhd"}, {ATOM_DATA, smhdout}, {ATOM_NAME, "dinf"}, {ATOM_DESCENT}, {ATOM_NAME, "dref"}, {ATOM_DATA, drefout}, {ATOM_DESCENT}, {ATOM_NAME, "url "}, {ATOM_DATA, urlout}, {ATOM_ASCENT}, {ATOM_ASCENT}, {ATOM_NAME, "stbl"}, {ATOM_DESCENT}, {ATOM_NAME, "stsd"}, {ATOM_DATA, stsdout}, {ATOM_DESCENT}, {ATOM_NAME, "mp4a"}, {ATOM_DATA, mp4aout}, {ATOM_DESCENT}, {ATOM_NAME, "esds"}, {ATOM_DATA, esdsout}, {ATOM_ASCENT}, {ATOM_ASCENT}, {ATOM_NAME, "stts"}, {ATOM_DATA, sttsout}, {ATOM_NAME, "stsc"}, {ATOM_DATA, stscout}, {ATOM_NAME, "stsz"}, {ATOM_DATA, stszout}, {ATOM_NAME, "stco"}, {ATOM_DATA, stcoout}, {ATOM_ASCENT}, {ATOM_ASCENT}, {ATOM_ASCENT}, {ATOM_ASCENT}, {ATOM_NAME, "udta"}, {ATOM_DESCENT}, {ATOM_NAME, "meta"}, {ATOM_DATA, metaout}, {ATOM_DESCENT}, {ATOM_NAME, "hdlr"}, {ATOM_DATA, hdlr2out}, {ATOM_NAME, "ilst"}, {ATOM_DATA, ilstout}, {0} }; static creator_t *g_atom = 0; static int create(void) { long apos = ftell(g_fout);; int size; size = u32out(8); size += dataout(g_atom->data, 4); g_atom++; if (g_atom->opcode == ATOM_DATA) { size += ((int (*)(void)) g_atom->data) (); g_atom++; } if (g_atom->opcode == ATOM_DESCENT) { g_atom++; while (g_atom->opcode != ATOM_STOP) { if (g_atom->opcode == ATOM_ASCENT) { g_atom++; break; } size += create(); } } fseek(g_fout, apos, SEEK_SET); u32out(size); fseek(g_fout, apos + size, SEEK_SET); return size; } enum {BUFSTEP = 0x4000}; int mp4atom_frame(uint8_t * buf, int size, int samples) { if (mp4config.framesamples <= samples) { int bitrate; mp4config.bitrate.samples += samples; mp4config.bitrate.size += size; if (mp4config.bitrate.samples >= mp4config.samplerate) { bitrate = 8.0 * mp4config.bitrate.size * mp4config.samplerate / mp4config.bitrate.samples; mp4config.bitrate.size = 0; mp4config.bitrate.samples = 0; if (mp4config.bitrate.max < bitrate) mp4config.bitrate.max = bitrate; } mp4config.framesamples = samples; } if (mp4config.buffersize < size) mp4config.buffersize = size; mp4config.samples += samples; mp4config.mdatsize += dataout(buf, size); if (((mp4config.frame.ents + 1) * sizeof(*(mp4config.frame.data))) > mp4config.frame.bufsize) { mp4config.frame.bufsize += BUFSTEP; mp4config.frame.data = realloc(mp4config.frame.data, mp4config.frame.bufsize); } mp4config.frame.data[mp4config.frame.ents++] = size; return 0; } int mp4atom_close(void) { if (g_fout) { fseek(g_fout, mp4config.mdatofs - 8, SEEK_SET); u32out(mp4config.mdatsize + 8); fclose(g_fout); g_fout = 0; } if (mp4config.frame.data) { free(mp4config.frame.data); mp4config.frame.data = 0; } return 0; } int mp4atom_open(char *name, int over) { mp4atom_close(); if (!access(name, W_OK) && !over) { fprintf(stderr, "output file exists, use --overwrite option\n"); return 1; } if (!(g_fout = fopen(name, "wb"))) { perror(name); return 1; } mp4config.mdatsize = 0; mp4config.frame.bufsize = BUFSTEP; mp4config.frame.data = malloc(mp4config.frame.bufsize); return 0; } int mp4atom_head(void) { g_atom = g_head; while (g_atom->opcode != ATOM_STOP) create(); mp4config.mdatofs = ftell(g_fout); return 0; } int mp4atom_tail(void) { mp4config.bitrate.avg = 8.0 * mp4config.mdatsize * mp4config.samplerate / mp4config.samples; if (!mp4config.bitrate.max) mp4config.bitrate.max = mp4config.bitrate.avg; g_atom = g_tail; while (g_atom->opcode != ATOM_STOP) create(); return 0; } int mp4tag_add(const char *name, const char *data) { int idx = mp4config.tag.extnum; if (idx >= TAGMAX) { fprintf(stderr, "To many tags\n"); return -1; } mp4config.tag.ext[idx].name = name; mp4config.tag.ext[idx].data = data; mp4config.tag.extnum++; return 0; } faac-1_30/frontend/mp4write.h000066400000000000000000000045401355157314300161650ustar00rootroot00000000000000/**************************************************************************** MP4 output module Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include enum {TAGMAX = 100}; typedef struct { uint32_t samplerate; // total sound samples uint32_t samples; uint32_t channels; // sample depth uint32_t bits; // buffer config uint16_t buffersize; struct { uint32_t max; uint32_t avg; int size; int samples; } bitrate; uint32_t framesamples; struct { uint16_t *data; uint32_t ents; uint32_t bufsize; } frame; // AudioSpecificConfig data: struct { uint8_t *data; unsigned long size; } asc; uint32_t mdatofs; uint32_t mdatsize; struct { // meta fields const char *encoder; const char *artist; const char *composer; const char *title; const char *album; uint8_t compilation; uint32_t trackno; uint32_t ntracks; uint32_t discno; uint32_t ndiscs; int genre; const char *year; struct { uint8_t *data; int size; } cover; const char *comment; struct { const char *name; const char *data; } ext[TAGMAX]; int extnum; } tag; } mp4config_t; extern mp4config_t mp4config; int mp4atom_open(char *name, int over); int mp4atom_head(void); int mp4atom_tail(void); int mp4atom_frame(uint8_t * bitbuf, int bytesWritten, int frame_samples); int mp4atom_close(void); int mp4tag_add(const char *name, const char *data); faac-1_30/frontend/resource.h000066400000000000000000000023701355157314300162400ustar00rootroot00000000000000//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by faacgui.rc // #define ID_ICON1 200 #define IDD_MAINDIALOG 102 #define IDC_INPUTFILENAME 1000 #define IDC_SELECT_INPUTFILE 1001 #define IDC_OUTPUTFILENAME 1002 #define IDC_SELECT_OUTPUTFILE 1003 #define IDC_INPUTPARAMS 1004 #define IDC_PROGRESS 1006 #define IDC_ALLOWMIDSIDE 1007 #define IDC_TIME 1008 #define IDC_BANDWIDTH 1009 #define IDC_QUALITY 1010 #define IDC_USERAW 1011 #define IDC_USETNS 1012 #define IDC_USELFE2 1013 #define IDC_USELFE 1013 #define IDC_BWCTL 1014 #define IDC_COMPILEDATE 1018 #define IDC_MPEGVERSION 1020 #define IDC_OBJECTTYPE 1021 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 104 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1022 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif faac-1_30/include/000077500000000000000000000000001355157314300140425ustar00rootroot00000000000000faac-1_30/include/Makefile.am000066400000000000000000000000431355157314300160730ustar00rootroot00000000000000include_HEADERS = faac.h faaccfg.h faac-1_30/include/faac.h000066400000000000000000000046661355157314300151210ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: faac.h,v 1.38 2012/03/01 18:34:17 knik Exp $ */ #ifndef _FAAC_H_ #define _FAAC_H_ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #if !defined(FAACAPI) && defined(__GNUC__) && (__GNUC__ >= 4) # if defined(_WIN32) # define FAACAPI __stdcall __declspec(dllexport) # else # define FAACAPI __attribute__((visibility("default"))) # endif #endif #ifndef FAACAPI # define FAACAPI #endif #pragma pack(push, 1) typedef struct { void *ptr; char *name; } psymodellist_t; #include #include "faaccfg.h" typedef void *faacEncHandle; /* Allows an application to get FAAC version info. This is intended purely for informative purposes. Returns FAAC_CFG_VERSION. */ int FAACAPI faacEncGetVersion(char **faac_id_string, char **faac_copyright_string); faacEncConfigurationPtr FAACAPI faacEncGetCurrentConfiguration(faacEncHandle hEncoder); int FAACAPI faacEncSetConfiguration(faacEncHandle hEncoder, faacEncConfigurationPtr config); faacEncHandle FAACAPI faacEncOpen(unsigned long sampleRate, unsigned int numChannels, unsigned long *inputSamples, unsigned long *maxOutputBytes ); int FAACAPI faacEncGetDecoderSpecificInfo(faacEncHandle hEncoder, unsigned char **ppBuffer, unsigned long *pSizeOfDecoderSpecificInfo); int FAACAPI faacEncEncode(faacEncHandle hEncoder, int32_t * inputBuffer, unsigned int samplesInput, unsigned char *outputBuffer, unsigned int bufferSize); int FAACAPI faacEncClose(faacEncHandle hEncoder); #pragma pack(pop) #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _FAAC_H_ */ faac-1_30/include/faaccfg.h000066400000000000000000000063151355157314300155720ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: faaccfg.h,v 1.3 2004/07/04 12:12:05 corrados Exp $ */ #ifndef _FAACCFG_H_ #define _FAACCFG_H_ #define FAAC_CFG_VERSION 105 /* MPEG ID's */ #define MPEG2 1 #define MPEG4 0 /* AAC object types */ #define MAIN 1 #define LOW 2 #define SSR 3 #define LTP 4 /* Input Formats */ #define FAAC_INPUT_NULL 0 #define FAAC_INPUT_16BIT 1 #define FAAC_INPUT_24BIT 2 #define FAAC_INPUT_32BIT 3 #define FAAC_INPUT_FLOAT 4 #define SHORTCTL_NORMAL 0 #define SHORTCTL_NOSHORT 1 #define SHORTCTL_NOLONG 2 enum stream_format { RAW_STREAM = 0, ADTS_STREAM = 1, }; enum {JOINT_NONE = 0, JOINT_MS, JOINT_IS}; #pragma pack(push, 1) typedef struct faacEncConfiguration { /* config version */ int version; /* library version */ char *name; /* copyright string */ char *copyright; /* MPEG version, 2 or 4 */ unsigned int mpegVersion; /* AAC object type */ unsigned int aacObjectType; union { /* Joint coding mode */ unsigned int jointmode; /* compatibility alias */ unsigned int allowMidside; }; /* Use one of the channels as LFE channel */ unsigned int useLfe; /* Use Temporal Noise Shaping */ unsigned int useTns; /* bitrate / channel of AAC file */ unsigned long bitRate; /* AAC file frequency bandwidth */ unsigned int bandWidth; /* Quantizer quality */ unsigned long quantqual; /* Bitstream output format (0 = Raw; 1 = ADTS) */ unsigned int outputFormat; /* psychoacoustic model list */ psymodellist_t *psymodellist; /* selected index in psymodellist */ unsigned int psymodelidx; /* PCM Sample Input Format 0 FAAC_INPUT_NULL invalid, signifies a misconfigured config 1 FAAC_INPUT_16BIT native endian 16bit 2 FAAC_INPUT_24BIT native endian 24bit in 24 bits (not implemented) 3 FAAC_INPUT_32BIT native endian 24bit in 32 bits (DEFAULT) 4 FAAC_INPUT_FLOAT 32bit floating point */ unsigned int inputFormat; /* block type enforcing (SHORTCTL_NORMAL/SHORTCTL_NOSHORT/SHORTCTL_NOLONG) */ int shortctl; /* Channel Remapping Default 0, 1, 2, 3 ... 63 (64 is MAX_CHANNELS in coder.h) WAVE 4.0 2, 0, 1, 3 WAVE 5.0 2, 0, 1, 3, 4 WAVE 5.1 2, 0, 1, 4, 5, 3 AIFF 5.1 2, 0, 3, 1, 4, 5 */ int channel_map[64]; int pnslevel; } faacEncConfiguration, *faacEncConfigurationPtr; #pragma pack(pop) #endif /* _FAACCFG_H_ */ faac-1_30/libfaac/000077500000000000000000000000001355157314300140005ustar00rootroot00000000000000faac-1_30/libfaac/Makefile.am000066400000000000000000000020321355157314300160310ustar00rootroot00000000000000common_SOURCES = bitstream.c fft.c frame.c blockswitch.c util.c channels.c filtbank.c tns.c quantize.c huff2.c huffdata.c stereo.c common_INCLUDES = channels.h filtbank.h blockswitch.h coder.h frame.h tns.h bitstream.h fft.h util.h quantize.h huffdata.h huff2.h stereo.h common_LIBADD = -lm common_CFLAGS = -fvisibility=hidden if CPUSSE common_CFLAGS += -msse2 endif if USE_DRM lib_LTLIBRARIES = libfaac_drm.la libfaac_drm_la_SOURCES = ${common_SOURCES} ${common_INCLUDES} kiss_fft/kiss_fftr.c kiss_fft/kiss_fft.c kiss_fft/kiss_fft.h EXTRA_libfaac_drm_la_SOURCES = kiss_fft/_kiss_fft_guts.h kiss_fft/kiss_fftr.h kiss_fft/README kiss_fft/README.kiss_fft libfaac_drm_la_LIBADD = ${common_LIBADD} libfaac_drm_la_CFLAGS = ${common_CFLAGS} -DDRM else lib_LTLIBRARIES = libfaac.la libfaac_la_SOURCES = ${common_SOURCES} ${common_INCLUDES} libfaac_la_LIBADD = ${common_LIBADD} libfaac_la_CFLAGS = ${common_CFLAGS} endif libfaac_la_LDFLAGS = -no-undefined if MINGW libfaac_la_LDFLAGS += -Wl,--add-stdcall-alias endif AM_CPPFLAGS = -I$(top_srcdir)/include faac-1_30/libfaac/bitstream.c000066400000000000000000001344671355157314300161550ustar00rootroot00000000000000/********************************************************************** This software module was originally developed by and edited by Texas Instruments in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products. The original developer retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1997. **********************************************************************/ #include #include #include #include "coder.h" #include "channels.h" #include "huff2.h" #include "bitstream.h" #include "util.h" static int CountBitstream(faacEncStruct* hEncoder, CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int numChannels); static int WriteADTSHeader(faacEncStruct* hEncoder, BitStream *bitStream, int writeFlag); static int WriteCPE(CoderInfo *coderInfoL, CoderInfo *coderInfoR, ChannelInfo *channelInfo, BitStream* bitStream, int objectType, int writeFlag); static int WriteSCE(CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int objectType, int writeFlag); static int WriteLFE(CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int objectType, int writeFlag); static int WriteICSInfo(CoderInfo *coderInfo, BitStream *bitStream, int objectType, int common_window, int writeFlag); static int WriteICS(CoderInfo *coderInfo, BitStream *bitStream, int commonWindow, int objectType, int writeFlag); static int WritePulseData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag); static int WriteTNSData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag); static int WriteGainControlData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag); static int WriteSpectralData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag); static int WriteAACFillBits(BitStream* bitStream, int numBits, int writeFlag); static int FindGroupingBits(CoderInfo *coderInfo); static long BufferNumBit(BitStream *bitStream); static int WriteByte(BitStream *bitStream, unsigned long data, int numBit); static int ByteAlign(BitStream* bitStream, int writeFlag, int bitsSoFar); #ifdef DRM static int PutBitHcr(BitStream *bitStream, unsigned long curpos, unsigned long data, int numBit); static int rewind_word(int W, int len); static int WriteReorderedSpectralData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag); static void calc_CRC(BitStream *bitStream, int len); #endif static int WriteFAACStr(BitStream *bitStream, char *version, int write) { int i; char str[200]; int len, padbits, count; int bitcnt; sprintf(str, "libfaac %s", version); len = strlen(str) + 1; padbits = (8 - ((bitStream->numBit + 7) % 8)) % 8; count = len + 3; bitcnt = LEN_SE_ID + 4 + ((count < 15) ? 0 : 8) + count * 8; if (!write) return bitcnt; PutBit(bitStream, ID_FIL, LEN_SE_ID); if (count < 15) { PutBit(bitStream, count, 4); } else { PutBit(bitStream, 15, 4); PutBit(bitStream, count - 14, 8); } PutBit(bitStream, 0, padbits); PutBit(bitStream, 0, 8); PutBit(bitStream, 0, 8); // just in case for (i = 0; i < len; i++) PutBit(bitStream, str[i], 8); PutBit(bitStream, 0, 8 - padbits); return bitcnt; } int WriteBitstream(faacEncStruct* hEncoder, CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int numChannel) { int channel; int bits = 0; int bitsLeftAfterFill, numFillBits; if (CountBitstream(hEncoder, coderInfo, channelInfo, bitStream, numChannel) < 0) return -1; if(hEncoder->config.outputFormat == 1){ bits += WriteADTSHeader(hEncoder, bitStream, 1); }else{ bits = 0; // compilier will remove it, byt anyone will see that current size of bitstream is 0 } /* sur: faad2 complains about scalefactor error if we are writing FAAC String */ #ifndef DRM if (hEncoder->frameNum == 4) WriteFAACStr(bitStream, hEncoder->config.name, 1); #endif for (channel = 0; channel < numChannel; channel++) { if (channelInfo[channel].present) { /* Write out a single_channel_element */ if (!channelInfo[channel].cpe) { if (channelInfo[channel].lfe) { /* Write out lfe */ bits += WriteLFE(&coderInfo[channel], &channelInfo[channel], bitStream, hEncoder->config.aacObjectType, 1); } else { /* Write out sce */ bits += WriteSCE(&coderInfo[channel], &channelInfo[channel], bitStream, hEncoder->config.aacObjectType, 1); } } else { if (channelInfo[channel].ch_is_left) { /* Write out cpe */ bits += WriteCPE(&coderInfo[channel], &coderInfo[channelInfo[channel].paired_ch], &channelInfo[channel], bitStream, hEncoder->config.aacObjectType, 1); } } } } /* Compute how many fill bits are needed to avoid overflowing bit reservoir */ /* Save room for ID_END terminator */ if (bits < (8 - LEN_SE_ID) ) { numFillBits = 8 - LEN_SE_ID - bits; } else { numFillBits = 0; } /* Write AAC fill_elements, smallest fill element is 7 bits. */ /* Function may leave up to 6 bits left after fill, so tell it to fill a few extra */ numFillBits += 6; bitsLeftAfterFill = WriteAACFillBits(bitStream, numFillBits, 1); bits += (numFillBits - bitsLeftAfterFill); /* Write ID_END terminator */ bits += LEN_SE_ID; PutBit(bitStream, ID_END, LEN_SE_ID); /* Now byte align the bitstream */ /* * This byte_alignment() is correct for both MPEG2 and MPEG4, although * in MPEG4 the byte_alignment() is officially done before the new frame * instead of at the end. But this is basically the same. */ bits += ByteAlign(bitStream, 1, bits); return bits; } static int CountBitstream(faacEncStruct* hEncoder, CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int numChannel) { int channel; int bits = 0; int bitsLeftAfterFill, numFillBits; if(hEncoder->config.outputFormat == 1){ bits += WriteADTSHeader(hEncoder, bitStream, 0); }else{ bits = 0; // compilier will remove it, byt anyone will see that current size of bitstream is 0 } /* sur: faad2 complains about scalefactor error if we are writing FAAC String */ #ifndef DRM if (hEncoder->frameNum == 4) bits += WriteFAACStr(bitStream, hEncoder->config.name, 0); #endif for (channel = 0; channel < numChannel; channel++) { if (channelInfo[channel].present) { /* Write out a single_channel_element */ if (!channelInfo[channel].cpe) { if (channelInfo[channel].lfe) { /* Write out lfe */ bits += WriteLFE(&coderInfo[channel], &channelInfo[channel], bitStream, hEncoder->config.aacObjectType, 0); } else { /* Write out sce */ bits += WriteSCE(&coderInfo[channel], &channelInfo[channel], bitStream, hEncoder->config.aacObjectType, 0); } } else { if (channelInfo[channel].ch_is_left) { /* Write out cpe */ bits += WriteCPE(&coderInfo[channel], &coderInfo[channelInfo[channel].paired_ch], &channelInfo[channel], bitStream, hEncoder->config.aacObjectType, 0); } } } } /* Compute how many fill bits are needed to avoid overflowing bit reservoir */ /* Save room for ID_END terminator */ if (bits < (8 - LEN_SE_ID) ) { numFillBits = 8 - LEN_SE_ID - bits; } else { numFillBits = 0; } /* Write AAC fill_elements, smallest fill element is 7 bits. */ /* Function may leave up to 6 bits left after fill, so tell it to fill a few extra */ numFillBits += 6; bitsLeftAfterFill = WriteAACFillBits(bitStream, numFillBits, 0); bits += (numFillBits - bitsLeftAfterFill); /* Write ID_END terminator */ bits += LEN_SE_ID; /* Now byte align the bitstream */ bits += ByteAlign(bitStream, 0, bits); hEncoder->usedBytes = bit2byte(bits); if (hEncoder->usedBytes > bitStream->size) { fprintf(stderr, "frame buffer overrun\n"); return -1; } if (hEncoder->usedBytes >= ADTS_FRAMESIZE) { fprintf(stderr, "frame size limit exceeded\n"); return -1; } return bits; } static int WriteADTSHeader(faacEncStruct* hEncoder, BitStream *bitStream, int writeFlag) { int bits = 56; if (writeFlag) { /* Fixed ADTS header */ PutBit(bitStream, 0xFFFF, 12); /* 12 bit Syncword */ PutBit(bitStream, hEncoder->config.mpegVersion, 1); /* ID == 0 for MPEG4 AAC, 1 for MPEG2 AAC */ PutBit(bitStream, 0, 2); /* layer == 0 */ PutBit(bitStream, 1, 1); /* protection absent */ PutBit(bitStream, hEncoder->config.aacObjectType - 1, 2); /* profile */ PutBit(bitStream, hEncoder->sampleRateIdx, 4); /* sampling rate */ PutBit(bitStream, 0, 1); /* private bit */ PutBit(bitStream, hEncoder->numChannels, 3); /* ch. config (must be > 0) */ /* simply using numChannels only works for 6 channels or less, else a channel configuration should be written */ PutBit(bitStream, 0, 1); /* original/copy */ PutBit(bitStream, 0, 1); /* home */ #if 0 // Removed in corrigendum 14496-3:2002 if (hEncoder->config.mpegVersion == 0) PutBit(bitStream, 0, 2); /* emphasis */ #endif /* Variable ADTS header */ PutBit(bitStream, 0, 1); /* copyr. id. bit */ PutBit(bitStream, 0, 1); /* copyr. id. start */ PutBit(bitStream, hEncoder->usedBytes, 13); PutBit(bitStream, 0x7FF, 11); /* buffer fullness (0x7FF for VBR) */ PutBit(bitStream, 0, 2); /* raw data blocks (0+1=1) */ } /* * MPEG2 says byte_aligment() here, but ADTS always is multiple of 8 bits * MPEG4 has no byte_alignment() here */ /* if (hEncoder->config.mpegVersion == 1) bits += ByteAlign(bitStream, writeFlag); */ #if 0 // Removed in corrigendum 14496-3:2002 if (hEncoder->config.mpegVersion == 0) bits += 2; /* emphasis */ #endif return bits; } static int WriteCPE(CoderInfo *coderInfoL, CoderInfo *coderInfoR, ChannelInfo *channelInfo, BitStream* bitStream, int objectType, int writeFlag) { int bits = 0; #ifndef DRM if (writeFlag) { /* write ID_CPE, single_element_channel() identifier */ PutBit(bitStream, ID_CPE, LEN_SE_ID); /* write the element_identifier_tag */ PutBit(bitStream, channelInfo->tag, LEN_TAG); /* common_window? */ PutBit(bitStream, channelInfo->common_window, LEN_COM_WIN); } bits += LEN_SE_ID; bits += LEN_TAG; bits += LEN_COM_WIN; #endif /* if common_window, write ics_info */ if (channelInfo->common_window) { int numWindows, maxSfb; bits += WriteICSInfo(coderInfoL, bitStream, objectType, channelInfo->common_window, writeFlag); numWindows = coderInfoL->groups.n; maxSfb = coderInfoL->sfbn; if (writeFlag) { PutBit(bitStream, channelInfo->msInfo.is_present, LEN_MASK_PRES); if (channelInfo->msInfo.is_present == 1) { int g; int b; for (g=0;gmsInfo.ms_used[g*maxSfb+b], LEN_MASK); } } } } bits += LEN_MASK_PRES; if (channelInfo->msInfo.is_present == 1) bits += (numWindows*maxSfb*LEN_MASK); } /* Write individual_channel_stream elements */ bits += WriteICS(coderInfoL, bitStream, channelInfo->common_window, objectType, writeFlag); bits += WriteICS(coderInfoR, bitStream, channelInfo->common_window, objectType, writeFlag); return bits; } static int WriteSCE(CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int objectType, int writeFlag) { int bits = 0; #ifndef DRM if (writeFlag) { /* write Single Element Channel (SCE) identifier */ PutBit(bitStream, ID_SCE, LEN_SE_ID); /* write the element identifier tag */ PutBit(bitStream, channelInfo->tag, LEN_TAG); } bits += LEN_SE_ID; bits += LEN_TAG; #endif /* Write an Individual Channel Stream element */ bits += WriteICS(coderInfo, bitStream, 0, objectType, writeFlag); return bits; } static int WriteLFE(CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int objectType, int writeFlag) { int bits = 0; if (writeFlag) { /* write ID_LFE, lfe_element_channel() identifier */ PutBit(bitStream, ID_LFE, LEN_SE_ID); /* write the element_identifier_tag */ PutBit(bitStream, channelInfo->tag, LEN_TAG); } bits += LEN_SE_ID; bits += LEN_TAG; /* Write an individual_channel_stream element */ bits += WriteICS(coderInfo, bitStream, 0, objectType, writeFlag); return bits; } static int WriteICSInfo(CoderInfo *coderInfo, BitStream *bitStream, int objectType, int common_window, int writeFlag) { int grouping_bits; int bits = 0; if (writeFlag) { /* write out ics_info() information */ PutBit(bitStream, 0, LEN_ICS_RESERV); /* reserved Bit*/ /* Write out window sequence */ PutBit(bitStream, coderInfo->block_type, LEN_WIN_SEQ); /* block type */ /* Write out window shape */ PutBit(bitStream, coderInfo->window_shape, LEN_WIN_SH); /* window shape */ } bits += LEN_ICS_RESERV; bits += LEN_WIN_SEQ; bits += LEN_WIN_SH; /* For short windows, write out max_sfb and scale_factor_grouping */ if (coderInfo->block_type == ONLY_SHORT_WINDOW){ if (writeFlag) { PutBit(bitStream, coderInfo->sfbn, LEN_MAX_SFBS); grouping_bits = FindGroupingBits(coderInfo); PutBit(bitStream, grouping_bits, MAX_SHORT_WINDOWS - 1); /* the grouping bits */ } bits += LEN_MAX_SFBS; bits += MAX_SHORT_WINDOWS - 1; } else { /* Otherwise, write out max_sfb and predictor data */ if (writeFlag) { PutBit(bitStream, coderInfo->sfbn, LEN_MAX_SFBL); } bits += LEN_MAX_SFBL; #ifdef DRM } if (writeFlag) { PutBit(bitStream,coderInfo->tnsInfo.tnsDataPresent,LEN_TNS_PRES); } bits += LEN_TNS_PRES; #endif bits++; if (writeFlag) PutBit(bitStream, 0, LEN_PRED_PRES); /* predictor_data_present */ #ifndef DRM } #endif return bits; } static int WriteICS(CoderInfo *coderInfo, BitStream *bitStream, int commonWindow, int objectType, int writeFlag) { /* this function writes out an individual_channel_stream to the bitstream and */ /* returns the number of bits written to the bitstream */ int bits = 0; #ifndef DRM /* Write the 8-bit global_gain */ if (writeFlag) PutBit(bitStream, coderInfo->global_gain, LEN_GLOB_GAIN); bits += LEN_GLOB_GAIN; #endif /* Write ics information */ if (!commonWindow) { bits += WriteICSInfo(coderInfo, bitStream, objectType, commonWindow, writeFlag); } #ifdef DRM /* Write the 8-bit global_gain */ if (writeFlag) PutBit(bitStream, coderInfo->global_gain, LEN_GLOB_GAIN); bits += LEN_GLOB_GAIN; #endif bits += writebooks(coderInfo, bitStream, writeFlag); bits += writesf(coderInfo, bitStream, writeFlag); #ifdef DRM if (writeFlag) { /* length_of_reordered_spectral_data */ PutBit(bitStream, coderInfo->iLenReordSpData, LEN_HCR_REORDSD); /* length_of_longest_codeword */ PutBit(bitStream, coderInfo->iLenLongestCW, LEN_HCR_LONGCW); } bits += LEN_HCR_REORDSD + LEN_HCR_LONGCW; #else bits += WritePulseData(coderInfo, bitStream, writeFlag); #endif bits += WriteTNSData(coderInfo, bitStream, writeFlag); #ifndef DRM bits += WriteGainControlData(coderInfo, bitStream, writeFlag); #endif #ifdef DRM /* DRM CRC calculation */ if (writeFlag) calc_CRC(bitStream, bits); bits += WriteReorderedSpectralData(coderInfo, bitStream, writeFlag); #else bits += WriteSpectralData(coderInfo, bitStream, writeFlag); #endif /* Return number of bits */ return bits; } static int WritePulseData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag) { int bits = 0; if (writeFlag) { PutBit(bitStream, 0, LEN_PULSE_PRES); /* no pulse_data_present */ } bits += LEN_PULSE_PRES; return bits; } static int WriteTNSData(CoderInfo *coderInfo, BitStream *bitStream, int writeFlag) { int bits = 0; int numWindows; int len_tns_nfilt; int len_tns_length; int len_tns_order; int filtNumber; int resInBits; int bitsToTransmit; unsigned long unsignedIndex; int w; TnsInfo* tnsInfoPtr = &coderInfo->tnsInfo; #ifndef DRM if (writeFlag) { PutBit(bitStream,tnsInfoPtr->tnsDataPresent,LEN_TNS_PRES); } bits += LEN_TNS_PRES; #endif /* If TNS is not present, bail */ if (!tnsInfoPtr->tnsDataPresent) { return bits; } /* Set window-dependent TNS parameters */ if (coderInfo->block_type == ONLY_SHORT_WINDOW) { numWindows = MAX_SHORT_WINDOWS; len_tns_nfilt = LEN_TNS_NFILTS; len_tns_length = LEN_TNS_LENGTHS; len_tns_order = LEN_TNS_ORDERS; } else { numWindows = 1; len_tns_nfilt = LEN_TNS_NFILTL; len_tns_length = LEN_TNS_LENGTHL; len_tns_order = LEN_TNS_ORDERL; } /* Write TNS data */ bits += (numWindows * len_tns_nfilt); for (w=0;wwindowData[w]; int numFilters = windowDataPtr->numFilters; if (writeFlag) { PutBit(bitStream,numFilters,len_tns_nfilt); /* n_filt[] = 0 */ } if (numFilters) { bits += LEN_TNS_COEFF_RES; resInBits = windowDataPtr->coefResolution; if (writeFlag) { PutBit(bitStream,resInBits-DEF_TNS_RES_OFFSET,LEN_TNS_COEFF_RES); } bits += numFilters * (len_tns_length+len_tns_order); for (filtNumber=0;filtNumbertnsFilter[filtNumber]; int order = tnsFilterPtr->order; if (writeFlag) { PutBit(bitStream,tnsFilterPtr->length,len_tns_length); PutBit(bitStream,order,len_tns_order); } if (order) { bits += (LEN_TNS_DIRECTION + LEN_TNS_COMPRESS); if (writeFlag) { PutBit(bitStream,tnsFilterPtr->direction,LEN_TNS_DIRECTION); PutBit(bitStream,tnsFilterPtr->coefCompress,LEN_TNS_COMPRESS); } bitsToTransmit = resInBits - tnsFilterPtr->coefCompress; bits += order * bitsToTransmit; if (writeFlag) { int i; for (i=1;i<=order;i++) { unsignedIndex = (unsigned long) (tnsFilterPtr->index[i])&(~(~0<datacnt; i++) { int data = coderInfo->s[i].data; int len = coderInfo->s[i].len; if (len > 0) { PutBit(bitStream, data, len); bits += len; } } } else { for(i = 0; i < coderInfo->datacnt; i++) { bits += coderInfo->s[i].len; } } return bits; } static int WriteAACFillBits(BitStream* bitStream, int numBits, int writeFlag) { int numberOfBitsLeft = numBits; /* Need at least (LEN_SE_ID + LEN_F_CNT) bits for a fill_element */ int minNumberOfBits = LEN_SE_ID + LEN_F_CNT; while (numberOfBitsLeft >= minNumberOfBits) { int numberOfBytes; int maxCount; if (writeFlag) { PutBit(bitStream, ID_FIL, LEN_SE_ID); /* Write fill_element ID */ } numberOfBitsLeft -= minNumberOfBits; /* Subtract for ID,count */ numberOfBytes = (int)(numberOfBitsLeft/LEN_BYTE); maxCount = (1< maxNumberOfBytes ) ? (maxNumberOfBytes) : (numberOfBytes); escCount = numberOfBytes - maxCount; if (writeFlag) { PutBit(bitStream, escCount, LEN_BYTE); for (i = 0; i < numberOfBytes-1; i++) { PutBit(bitStream, 0, LEN_BYTE); } } } numberOfBitsLeft -= LEN_BYTE*numberOfBytes; } return numberOfBitsLeft; } static int FindGroupingBits(CoderInfo *coderInfo) { /* This function inputs the grouping information and outputs the seven bit 'grouping_bits' field that the AAC decoder expects. */ int grouping_bits = 0; int tmp[8]; int i, j; int index = 0; for(i = 0; i < coderInfo->groups.n; i++){ for (j = 0; j < coderInfo->groups.len[i]; j++){ tmp[index++] = i; } } for(i = 1; i < 8; i++){ grouping_bits = grouping_bits << 1; if(tmp[i] == tmp[i-1]) { grouping_bits++; } } return grouping_bits; } /* size in bytes! */ BitStream *OpenBitStream(int size, unsigned char *buffer) { BitStream *bitStream; bitStream = AllocMemory(sizeof(BitStream)); bitStream->size = size; #ifdef DRM /* skip first byte for CRC */ bitStream->numBit = 8; bitStream->currentBit = 8; #else bitStream->numBit = 0; bitStream->currentBit = 0; #endif bitStream->data = buffer; SetMemory(bitStream->data, 0, size); return bitStream; } int CloseBitStream(BitStream *bitStream) { int bytes = bit2byte(bitStream->numBit); FreeMemory(bitStream); return bytes; } static long BufferNumBit(BitStream *bitStream) { return bitStream->numBit; } static int WriteByte(BitStream *bitStream, unsigned long data, int numBit) { long numUsed,idx; idx = (bitStream->currentBit / BYTE_NUMBIT) % bitStream->size; numUsed = bitStream->currentBit % BYTE_NUMBIT; #ifndef DRM if (numUsed == 0) bitStream->data[idx] = 0; #endif bitStream->data[idx] |= (data & ((1<currentBit += numBit; bitStream->numBit = bitStream->currentBit; return 0; } int PutBit(BitStream *bitStream, unsigned long data, int numBit) { int num,maxNum,curNum; unsigned long bits; if (numBit == 0) return 0; /* write bits in packets according to buffer byte boundaries */ num = 0; maxNum = BYTE_NUMBIT - bitStream->currentBit % BYTE_NUMBIT; while (num < numBit) { curNum = min(numBit-num,maxNum); bits = data>>(numBit-num-curNum); if (WriteByte(bitStream, bits, curNum)) { return 1; } num += curNum; maxNum = BYTE_NUMBIT; } return 0; } static int ByteAlign(BitStream *bitStream, int writeFlag, int bitsSoFar) { int len, i,j; if (writeFlag) { len = BufferNumBit(bitStream); } else { len = bitsSoFar; } j = (8 - (len%8))%8; if ((len % 8) == 0) j = 0; if (writeFlag) { for( i=0; icurrentBit = curpos; return PutBit(bitStream, data, numBit); } static int rewind_word(int W, int len) { /* rewind len (max. 32) bits so that the MSB becomes LSB */ short i; int tmp_W = 0; for (i = 0; i < len; i++) { tmp_W <<= 1; if (W & (1<groups.len; int* sfb_offset = coder->sfb_offset; cw_info_t cw_info[FRAME_LEN]; cw_info_t cw_info_preso[FRAME_LEN]; int num_cw = coder->cur_cw; int window_cw_cnt[MAX_SHORT_WINDOWS] = {0,0,0,0,0,0,0,0}; int presort, set, num_sets; unsigned short cur_cb, cw_cnt; short is_backwards; int diff, tmp_data, cw_part_cnt, cur_cw_part; int cur_cw_len, cur_data; int sfb_cnt, win_cnt, acc_win_cnt, win_grp_cnt; int coeff_cnt, last_sfb, cur_sfb_len; /* set up local pointers to data and len */ /* data array contains data to be written */ /* len array contains lengths of data words */ int* num_data = coder->num_data_cw; if (writeFlag) { /* build offset table */ cur_data = 0; cw_info[0].cw_offset = 0; for (i = 0; i < num_cw; i++) { cur_cw_len = 0; for (j = 0; j < num_data[i]; j++) { cur_cw_len += coder->s[cur_data++].len; } cw_info[i].num_data = num_data[i]; cw_info[i].cw_len = cur_cw_len; if (i > 0) /* calculate offset (codeword info parameter) */ cw_info[i].cw_offset = cw_info[i - 1].cw_offset + num_data[i - 1]; } /* presort codewords ------------------------------------------------ */ /* classify codewords first */ sfb_cnt = win_cnt = win_grp_cnt = coeff_cnt = last_sfb = acc_win_cnt = 0; cur_sfb_len = sfb_offset[1] / groups[0]; cur_cb = coder->book[0]; for (i = 0; i < num_cw; i++) { /* Set codeword info parameters */ cw_info[i].cb = cur_cb; cw_info[i].num_sl_cw = (cur_cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN; cw_info[i].window = acc_win_cnt + win_cnt; cw_info[i].cw_nr = window_cw_cnt[cw_info[i].window]; window_cw_cnt[cw_info[i].window]++; coeff_cnt += cw_info[i].num_sl_cw; if (coeff_cnt - last_sfb >= cur_sfb_len) { last_sfb += cur_sfb_len; win_cnt++; /* next window */ if (win_cnt == groups[win_grp_cnt]) { win_cnt = 0; sfb_cnt++; /* next sfb */ if (sfb_cnt == coder->all_sfb) { sfb_cnt = 0; acc_win_cnt += groups[win_grp_cnt]; win_grp_cnt++; /* next window group */ } /* new codebook and sfb length */ cur_cb = coder->book[sfb_cnt]; if (last_sfb < FRAME_LEN) { cur_sfb_len = (sfb_offset[sfb_cnt + 1] - sfb_offset[sfb_cnt]) / groups[win_grp_cnt]; } } } } /* presorting (first presorting step) */ /* only needed for short windows */ /* Somehow the second presorting step does not give expected results. Disabling the following code surprisingly gives good results. TODO: find the bug */ if (0) {//coder->block_type == ONLY_SHORT_WINDOW) { for (i = 0; i < MAX_SHORT_WINDOWS; i++) window_cw_cnt[i] = 0; /* reset all counters */ win_cnt = 0; cw_cnt = 0; for (i = 0; i < num_cw; i++) { for (j = 0; j < num_cw; j++) { if (cw_info[j].window == win_cnt) { if (cw_info[j].cw_nr == window_cw_cnt[win_cnt]) { cw_info_preso[cw_cnt++] = cw_info[j]; window_cw_cnt[win_cnt]++; /* check if two one-dimensional codewords */ if (cw_info[j].num_sl_cw == PAIR_LEN) { cw_info_preso[cw_cnt++] = cw_info[j + 1]; window_cw_cnt[win_cnt]++; } win_cnt++; /* next window */ if (win_cnt == MAX_SHORT_WINDOWS) win_cnt = 0; } } } } } else { for (i = 0; i < num_cw; i++) { cw_info_preso[i] = cw_info[i]; /* just copy */ } } /* presorting (second presorting step) */ cw_cnt = 0; for (presort = 0; presort < LEN_PRESORT_CODEBOOK; presort++) { /* next codebook that has to be processed according to presorting */ unsigned short nextCB = PresortedCodebook_VCB11[presort]; for (i = 0; i < num_cw; i++) { /* process only codewords that are due now */ if ((cw_info_preso[i].cb == nextCB) || ((nextCB < HCB_ESC) && (cw_info_preso[i].cb == nextCB + 1))) { cw_info[cw_cnt++] = cw_info_preso[i]; } } } /* init segments */ accsegmsize = 0; for (i = 0; i < num_cw; i++) { /* 8.5.3.3.3.2 Derivation of segment width */ cursegmsize = min(maxCwLen[cw_info[i].cb], coder->iLenLongestCW); if (accsegmsize + cursegmsize > coder->iLenReordSpData) { /* the last segment is extended until iLenReordSpData */ segment[segmcnt - 1].right = coder->iLenReordSpData - 1; segment[segmcnt - 1].len = coder->iLenReordSpData - segment[segmcnt - 1].left; break; } segment[segmcnt].left = accsegmsize; segment[segmcnt].right = accsegmsize + cursegmsize - 1; segment[segmcnt++].len = cursegmsize; accsegmsize += cursegmsize; } /* store current bit position */ startbitpos = bitStream->currentBit; /* write write priority codewords (PCWs) and nonPCWs ---------------- */ num_sets = num_cw / segmcnt; /* number of sets */ for (set = 0; set <= num_sets; set++) { int trial; /* ever second set the bit order is reversed */ is_backwards = set % 2; for (trial = 0; trial < segmcnt; trial++) { int codewordBase; int set_encoded = segmcnt; if (set == num_sets) set_encoded = num_cw - set * segmcnt; /* last set is shorter than the rest */ for (codewordBase = 0; codewordBase < segmcnt; codewordBase++) { int segment_index = (trial + codewordBase) % segmcnt; int codeword_index = codewordBase + set * segmcnt; if (codeword_index >= num_cw) break; if ((cw_info[codeword_index].cw_len > 0) && (segment[segment_index].len > 0)) { /* codeword is not yet written (completely) */ /* space left in this segment */ short tmplen; /* how many bits can be written? */ if (segment[segment_index].len >= cw_info[codeword_index].cw_len) { tmplen = cw_info[codeword_index].cw_len; set_encoded--; /* CW fits into segment */ } else { tmplen = segment[segment_index].len; } /* Adjust lengths */ cw_info[codeword_index].cw_len -= tmplen; segment[segment_index].len -= tmplen; /* write codewords to bitstream */ for (cw_part_cnt = 0; cw_part_cnt < cw_info[codeword_index].num_data; cw_part_cnt++) { cur_cw_part = cw_info[codeword_index].cw_offset + cw_part_cnt; if (coder->s[cur_cw_part].len <= tmplen) { /* write complete data, no partitioning */ if (is_backwards) { /* write data in reversed bit-order */ PutBitHcr(bitStream, startbitpos + segment[segment_index].right - coder->s[cur_cw_part].len + 1, rewind_word(coder->s[cur_cw_part].data, coder->s[cur_cw_part].len), coder->s[cur_cw_part].len); segment[segment_index].right -= coder->s[cur_cw_part].len; } else { PutBitHcr(bitStream, startbitpos + segment[segment_index].left, coder->s[cur_cw_part].data, coder->s[cur_cw_part].len); segment[segment_index].left += coder->s[cur_cw_part].len; } tmplen -= coder->s[cur_cw_part].len; coder->s[cur_cw_part].len = 0; } else { /* codeword part must be partitioned */ /* data must be taken from the left side */ tmp_data = coder->s[cur_cw_part].data; diff = coder->s[cur_cw_part].len - tmplen; tmp_data >>= diff; /* remove bits which are already used */ coder->s[cur_cw_part].data &= (1 << diff) - 1 /* diff number of ones */; coder->s[cur_cw_part].len = diff; if (is_backwards) { /* write data in reversed bit-order */ PutBitHcr(bitStream, startbitpos + segment[segment_index].right - tmplen + 1, rewind_word(tmp_data, tmplen), tmplen); segment[segment_index].right -= tmplen; } else { PutBitHcr(bitStream, startbitpos + segment[segment_index].left, tmp_data, tmplen); segment[segment_index].left += tmplen; } tmplen = 0; } if (tmplen == 0) break; /* all data written for this segment trial */ } } } /* of codewordBase */ if (set_encoded == 0) break; /* no unencoded codewords left in this set */ } /* of trial */ } /* set parameter for bit stream to current correct position */ bitStream->currentBit = startbitpos + coder->iLenReordSpData; bitStream->numBit = bitStream->currentBit; } return coder->iLenReordSpData; } /* CRC8 x^8 + x^4 + x^3 + x^2 + 1 */ static const unsigned char _crctable[256] = { 0x00, 0x1D, 0x3A, 0x27, 0x74, 0x69, 0x4E, 0x53, 0xE8, 0xF5, 0xD2, 0xCF, 0x9C, 0x81, 0xA6, 0xBB, 0xCD, 0xD0, 0xF7, 0xEA, 0xB9, 0xA4, 0x83, 0x9E, 0x25, 0x38, 0x1F, 0x02, 0x51, 0x4C, 0x6B, 0x76, 0x87, 0x9A, 0xBD, 0xA0, 0xF3, 0xEE, 0xC9, 0xD4, 0x6F, 0x72, 0x55, 0x48, 0x1B, 0x06, 0x21, 0x3C, 0x4A, 0x57, 0x70, 0x6D, 0x3E, 0x23, 0x04, 0x19, 0xA2, 0xBF, 0x98, 0x85, 0xD6, 0xCB, 0xEC, 0xF1, 0x13, 0x0E, 0x29, 0x34, 0x67, 0x7A, 0x5D, 0x40, 0xFB, 0xE6, 0xC1, 0xDC, 0x8F, 0x92, 0xB5, 0xA8, 0xDE, 0xC3, 0xE4, 0xF9, 0xAA, 0xB7, 0x90, 0x8D, 0x36, 0x2B, 0x0C, 0x11, 0x42, 0x5F, 0x78, 0x65, 0x94, 0x89, 0xAE, 0xB3, 0xE0, 0xFD, 0xDA, 0xC7, 0x7C, 0x61, 0x46, 0x5B, 0x08, 0x15, 0x32, 0x2F, 0x59, 0x44, 0x63, 0x7E, 0x2D, 0x30, 0x17, 0x0A, 0xB1, 0xAC, 0x8B, 0x96, 0xC5, 0xD8, 0xFF, 0xE2, 0x26, 0x3B, 0x1C, 0x01, 0x52, 0x4F, 0x68, 0x75, 0xCE, 0xD3, 0xF4, 0xE9, 0xBA, 0xA7, 0x80, 0x9D, 0xEB, 0xF6, 0xD1, 0xCC, 0x9F, 0x82, 0xA5, 0xB8, 0x03, 0x1E, 0x39, 0x24, 0x77, 0x6A, 0x4D, 0x50, 0xA1, 0xBC, 0x9B, 0x86, 0xD5, 0xC8, 0xEF, 0xF2, 0x49, 0x54, 0x73, 0x6E, 0x3D, 0x20, 0x07, 0x1A, 0x6C, 0x71, 0x56, 0x4B, 0x18, 0x05, 0x22, 0x3F, 0x84, 0x99, 0xBE, 0xA3, 0xF0, 0xED, 0xCA, 0xD7, 0x35, 0x28, 0x0F, 0x12, 0x41, 0x5C, 0x7B, 0x66, 0xDD, 0xC0, 0xE7, 0xFA, 0xA9, 0xB4, 0x93, 0x8E, 0xF8, 0xE5, 0xC2, 0xDF, 0x8C, 0x91, 0xB6, 0xAB, 0x10, 0x0D, 0x2A, 0x37, 0x64, 0x79, 0x5E, 0x43, 0xB2, 0xAF, 0x88, 0x95, 0xC6, 0xDB, 0xFC, 0xE1, 0x5A, 0x47, 0x60, 0x7D, 0x2E, 0x33, 0x14, 0x09, 0x7F, 0x62, 0x45, 0x58, 0x0B, 0x16, 0x31, 0x2C, 0x97, 0x8A, 0xAD, 0xB0, 0xE3, 0xFE, 0xD9, 0xC4 }; static void calc_CRC(BitStream *bitStream, int len) { //int i; //unsigned char r = ~0; /* Initialize to all ones */ unsigned char crc = ~0; /* Initialize to all ones */ /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */ unsigned int cb = len / 8; unsigned int taillen = len & 0x7; unsigned char* pb = &bitStream->data[1]; //compatible, but slower unsigned char b = ( bitStream->data[cb + 1] ) >> ( 8 - taillen ); unsigned char b = bitStream->data[cb + 1]; //#define GPOLY 0435 // // for (i = 8; i < len + 8; i++) { // r = ( (r << 1) ^ (( ( // ( bitStream->data[i / 8] >> (7 - (i % 8)) ) // & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF; // } #define GP 0x1d //fprintf( stderr, "\nfaac:" ); while ( cb-- ) { //fprintf( stderr, " %02X", *pb ); crc = _crctable[ crc ^ *pb++ ]; } //compatible, but slower switch ( taillen ) //{ //case 7: // crc = ( ( crc << 1 ) ^ ( ( ( ( b >> 6 ) & 1 ) ^ ( ( crc >> 7 ) & 1 ) ) * GP ) ) & 0xFF; // // goto next case //case 6: // crc = ( ( crc << 1 ) ^ ( ( ( ( b >> 5 ) & 1 ) ^ ( ( crc >> 7 ) & 1 ) ) * GP ) ) & 0xFF; // // goto next case //case 5: // crc = ( ( crc << 1 ) ^ ( ( ( ( b >> 4 ) & 1 ) ^ ( ( crc >> 7 ) & 1 ) ) * GP ) ) & 0xFF; // // goto next case //case 4: // crc = ( ( crc << 1 ) ^ ( ( ( ( b >> 3 ) & 1 ) ^ ( ( crc >> 7 ) & 1 ) ) * GP ) ) & 0xFF; // // goto next case //case 3: // crc = ( ( crc << 1 ) ^ ( ( ( ( b >> 2 ) & 1 ) ^ ( ( crc >> 7 ) & 1 ) ) * GP ) ) & 0xFF; // // goto next case //case 2: // crc = ( ( crc << 1 ) ^ ( ( ( ( b >> 1 ) & 1 ) ^ ( ( crc >> 7 ) & 1 ) ) * GP ) ) & 0xFF; // // goto next case //case 1: // crc = ( ( crc << 1 ) ^ ( ( ( b & 1 ) ^ ( ( crc >> 7 ) & 1 ) ) * GP ) ) & 0xFF; // break; //} //fprintf( stderr, " %02X", ( b >> ( 8 - taillen ) ) << 7 ); switch ( taillen ) { case 7: crc = ( ( crc << 1 ) ^ ( ( (signed char)( b ^ crc ) >> 7 ) & GP ) ) & 0xFF; b <<= 1; // goto next case case 6: crc = ( ( crc << 1 ) ^ ( ( (signed char)( b ^ crc ) >> 7 ) & GP ) ) & 0xFF; b <<= 1; // goto next case case 5: crc = ( ( crc << 1 ) ^ ( ( (signed char)( b ^ crc ) >> 7 ) & GP ) ) & 0xFF; b <<= 1; // goto next case case 4: crc = ( ( crc << 1 ) ^ ( ( (signed char)( b ^ crc ) >> 7 ) & GP ) ) & 0xFF; b <<= 1; // goto next case case 3: crc = ( ( crc << 1 ) ^ ( ( (signed char)( b ^ crc ) >> 7 ) & GP ) ) & 0xFF; b <<= 1; // goto next case case 2: crc = ( ( crc << 1 ) ^ ( ( (signed char)( b ^ crc ) >> 7 ) & GP ) ) & 0xFF; b <<= 1; // goto next case case 1: crc = ( ( crc << 1 ) ^ ( ( (signed char)( b ^ crc ) >> 7 ) & GP ) ) & 0xFF; break; } //if ( crc != r ) //{ // fprintf( stderr, "%08X != %08X\n", crc, r ); //} //fprintf( stderr, " (%5d bits), CRC is %02X\n", len, ~crc & 0xFF ); /* CRC is stored inverted, per definition at first byte in stream */ bitStream->data[0] = ~crc; } #endif faac-1_30/libfaac/bitstream.h000066400000000000000000000102301355157314300161370ustar00rootroot00000000000000/********************************************************************** MPEG-4 Audio VM Bit stream module This software module was originally developed by Heiko Purnhagen (University of Hannover) and edited by in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products. The original developer retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1996. **********************************************************************/ #ifndef BITSTREAM_H #define BITSTREAM_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "frame.h" #include "coder.h" #include "channels.h" /* * Raw bitstream constants */ #define LEN_SE_ID 3 #define LEN_TAG 4 #define LEN_GLOB_GAIN 8 #define LEN_COM_WIN 1 #define LEN_ICS_RESERV 1 #define LEN_WIN_SEQ 2 #define LEN_WIN_SH 1 #define LEN_MAX_SFBL 6 #define LEN_MAX_SFBS 4 #define LEN_CB 4 #define LEN_SCL_PCM 8 #define LEN_PRED_PRES 1 #define LEN_PRED_RST 1 #define LEN_PRED_RSTGRP 5 #define LEN_PRED_ENAB 1 #define LEN_MASK_PRES 2 #define LEN_MASK 1 #define LEN_PULSE_PRES 1 #define LEN_TNS_PRES 1 #define LEN_TNS_NFILTL 2 #define LEN_TNS_NFILTS 1 #define LEN_TNS_COEFF_RES 1 #define LEN_TNS_LENGTHL 6 #define LEN_TNS_LENGTHS 4 #define LEN_TNS_ORDERL 5 #define LEN_TNS_ORDERS 3 #define LEN_TNS_DIRECTION 1 #define LEN_TNS_COMPRESS 1 #define LEN_GAIN_PRES 1 #define LEN_NEC_NPULSE 2 #define LEN_NEC_ST_SFB 6 #define LEN_NEC_POFF 5 #define LEN_NEC_PAMP 4 #define NUM_NEC_LINES 4 #define NEC_OFFSET_AMP 4 #define LEN_NCC 3 #define LEN_IS_CPE 1 #define LEN_CC_LR 1 #define LEN_CC_DOM 1 #define LEN_CC_SGN 1 #define LEN_CCH_GES 2 #define LEN_CCH_CGP 1 #define LEN_D_CNT 4 #define LEN_D_ESC 12 #define LEN_F_CNT 4 #define LEN_F_ESC 8 #define LEN_BYTE 8 #define LEN_PAD_DATA 8 #define LEN_PC_COMM 8 #ifdef DRM # define LEN_HCR_REORDSD 14 # define LEN_HCR_LONGCW 6 # define FIRST_PAIR_HCB 5 # define QUAD_LEN 4 # define PAIR_LEN 2 #endif #define ID_SCE 0 #define ID_CPE 1 #define ID_CCE 2 #define ID_LFE 3 #define ID_DSE 4 #define ID_PCE 5 #define ID_FIL 6 #define ID_END 7 /* MPEG ID's */ #define MPEG2 1 #define MPEG4 0 /* AAC object types */ #define MAIN 1 #define LOW 2 #define SSR 3 #define LTP 4 #define BYTE_NUMBIT 8 /* bits in byte (char) */ #define LONG_NUMBIT 32 /* bits in unsigned long */ #define bit2byte(a) (((a)+BYTE_NUMBIT-1)/BYTE_NUMBIT) enum {ADTS_FRAMESIZE = 1 << 13}; typedef struct { unsigned char *data; /* data bits */ long numBit; /* number of bits in buffer */ long size; /* buffer size in bytes */ long currentBit; /* current bit position in bit stream */ long numByte; /* number of bytes read/written (only file) */ } BitStream; int WriteBitstream(faacEncStruct* hEncoder, CoderInfo *coderInfo, ChannelInfo *channelInfo, BitStream *bitStream, int numChannels); BitStream *OpenBitStream(int size, unsigned char *buffer); int CloseBitStream(BitStream *bitStream); int PutBit(BitStream *bitStream, unsigned long data, int numBit); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* BITSTREAM_H */ faac-1_30/libfaac/blockswitch.c000066400000000000000000000302461355157314300164650ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2002 Krzysztof Nikiel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: psychkni.c,v 1.19 2012/03/01 18:34:17 knik Exp $ */ #include #include #include #include "blockswitch.h" #include "coder.h" #include "fft.h" #include "util.h" #include typedef float psyfloat; typedef struct { /* bandwidth */ int bandS; int lastband; /* band volumes */ psyfloat *engPrev[8]; psyfloat *eng[8]; psyfloat *engNext[8]; psyfloat *engNext2[8]; } psydata_t; static void Hann(GlobalPsyInfo * gpsyInfo, double *inSamples, int size) { int i; /* Applying Hann window */ if (size == BLOCK_LEN_LONG * 2) { for (i = 0; i < size; i++) inSamples[i] *= gpsyInfo->hannWindow[i]; } else { for (i = 0; i < size; i++) inSamples[i] *= gpsyInfo->hannWindowS[i]; } } #define PRINTSTAT 0 #if PRINTSTAT static struct { int tot; int s; } frames; #endif static void PsyCheckShort(PsyInfo * psyInfo, double quality) { enum {PREVS = 2, NEXTS = 2}; psydata_t *psydata = psyInfo->data; int lastband = psydata->lastband; int firstband = 2; int sfb, win; psyfloat *lasteng; psyInfo->block_type = ONLY_LONG_WINDOW; lasteng = NULL; for (win = 0; win < PREVS + 8 + NEXTS; win++) { psyfloat *eng; if (win < PREVS) eng = psydata->engPrev[win + 8 - PREVS]; else if (win < (PREVS + 8)) eng = psydata->eng[win - PREVS]; else eng = psydata->engNext[win - PREVS - 8]; if (lasteng) { double toteng = 0.0; double volchg = 0.0; for (sfb = firstband; sfb < lastband; sfb++) { toteng += (eng[sfb] < lasteng[sfb]) ? eng[sfb] : lasteng[sfb]; volchg += fabs(eng[sfb] - lasteng[sfb]); } if ((volchg / toteng * quality) > 3.0) { psyInfo->block_type = ONLY_SHORT_WINDOW; break; } } lasteng = eng; } #if PRINTSTAT frames.tot++; if (psyInfo->block_type == ONLY_SHORT_WINDOW) frames.s++; #endif } static void PsyInit(GlobalPsyInfo * gpsyInfo, PsyInfo * psyInfo, unsigned int numChannels, unsigned int sampleRate, int *cb_width_long, int num_cb_long, int *cb_width_short, int num_cb_short) { unsigned int channel; int i, j, size; gpsyInfo->hannWindow = (double *) AllocMemory(2 * BLOCK_LEN_LONG * sizeof(double)); gpsyInfo->hannWindowS = (double *) AllocMemory(2 * BLOCK_LEN_SHORT * sizeof(double)); for (i = 0; i < BLOCK_LEN_LONG * 2; i++) gpsyInfo->hannWindow[i] = 0.5 * (1 - cos(2.0 * M_PI * (i + 0.5) / (BLOCK_LEN_LONG * 2))); for (i = 0; i < BLOCK_LEN_SHORT * 2; i++) gpsyInfo->hannWindowS[i] = 0.5 * (1 - cos(2.0 * M_PI * (i + 0.5) / (BLOCK_LEN_SHORT * 2))); gpsyInfo->sampleRate = (double) sampleRate; for (channel = 0; channel < numChannels; channel++) { psydata_t *psydata = AllocMemory(sizeof(psydata_t)); psyInfo[channel].data = psydata; } size = BLOCK_LEN_LONG; for (channel = 0; channel < numChannels; channel++) { psyInfo[channel].size = size; psyInfo[channel].prevSamples = (double *) AllocMemory(size * sizeof(double)); memset(psyInfo[channel].prevSamples, 0, size * sizeof(double)); } size = BLOCK_LEN_SHORT; for (channel = 0; channel < numChannels; channel++) { psydata_t *psydata = psyInfo[channel].data; psyInfo[channel].sizeS = size; for (j = 0; j < 8; j++) { psydata->engPrev[j] = (psyfloat *) AllocMemory(NSFB_SHORT * sizeof(psyfloat)); memset(psydata->engPrev[j], 0, NSFB_SHORT * sizeof(psyfloat)); psydata->eng[j] = (psyfloat *) AllocMemory(NSFB_SHORT * sizeof(psyfloat)); memset(psydata->eng[j], 0, NSFB_SHORT * sizeof(psyfloat)); psydata->engNext[j] = (psyfloat *) AllocMemory(NSFB_SHORT * sizeof(psyfloat)); memset(psydata->engNext[j], 0, NSFB_SHORT * sizeof(psyfloat)); psydata->engNext2[j] = (psyfloat *) AllocMemory(NSFB_SHORT * sizeof(psyfloat)); memset(psydata->engNext2[j], 0, NSFB_SHORT * sizeof(psyfloat)); } } } static void PsyEnd(GlobalPsyInfo * gpsyInfo, PsyInfo * psyInfo, unsigned int numChannels) { unsigned int channel; int j; if (gpsyInfo->hannWindow) FreeMemory(gpsyInfo->hannWindow); if (gpsyInfo->hannWindowS) FreeMemory(gpsyInfo->hannWindowS); for (channel = 0; channel < numChannels; channel++) { if (psyInfo[channel].prevSamples) FreeMemory(psyInfo[channel].prevSamples); } for (channel = 0; channel < numChannels; channel++) { psydata_t *psydata = psyInfo[channel].data; for (j = 0; j < 8; j++) { if (psydata->engPrev[j]) FreeMemory(psydata->engPrev[j]); if (psydata->eng[j]) FreeMemory(psydata->eng[j]); if (psydata->engNext[j]) FreeMemory(psydata->engNext[j]); if (psydata->engNext2[j]) FreeMemory(psydata->engNext2[j]); } } for (channel = 0; channel < numChannels; channel++) { if (psyInfo[channel].data) FreeMemory(psyInfo[channel].data); } #if PRINTSTAT printf("short frames: %d/%d (%.2f %%)\n", frames.s, frames.tot, 100.0*frames.s/frames.tot); #endif } /* Do psychoacoustical analysis */ static void PsyCalculate(ChannelInfo * channelInfo, GlobalPsyInfo * gpsyInfo, PsyInfo * psyInfo, int *cb_width_long, int num_cb_long, int *cb_width_short, int num_cb_short, unsigned int numChannels, double quality ) { unsigned int channel; // limit switching threshold if (quality < 0.4) quality = 0.4; for (channel = 0; channel < numChannels; channel++) { if (channelInfo[channel].present) { if (channelInfo[channel].cpe && channelInfo[channel].ch_is_left) { /* CPE */ int leftChan = channel; int rightChan = channelInfo[channel].paired_ch; PsyCheckShort(&psyInfo[leftChan], quality); PsyCheckShort(&psyInfo[rightChan], quality); } else if (!channelInfo[channel].cpe && channelInfo[channel].lfe) { /* LFE */ // Only set block type and it should be OK psyInfo[channel].block_type = ONLY_LONG_WINDOW; } else if (!channelInfo[channel].cpe) { /* SCE */ PsyCheckShort(&psyInfo[channel], quality); } } } } // imported from filtbank.c static void mdct( FFT_Tables *fft_tables, double *data, int N ) { double tempr, tempi, c, s, cold, cfreq, sfreq; /* temps for pre and post twiddle */ double freq = 2.0 * M_PI / N; double cosfreq8, sinfreq8; int i, n; double xi[BLOCK_LEN_LONG / 2]; double xr[BLOCK_LEN_LONG / 2]; /* prepare for recurrence relation in pre-twiddle */ cfreq = cos (freq); sfreq = sin (freq); cosfreq8 = cos (freq * 0.125); sinfreq8 = sin (freq * 0.125); c = cosfreq8; s = sinfreq8; for (i = 0; i < (N >> 2); i++) { /* calculate real and imaginary parts of g(n) or G(p) */ n = 2 * i; if (n < (N >> 2)) tempr = data [(N>>2) + (N>>1) - 1 - n] + data [N - (N>>2) + n]; else tempr = data [(N>>2) + (N>>1) - 1 - n] - data [-(N>>2) + n]; if (n < (N >> 2)) tempi = data [(N>>2) + n] - data [(N>>2) - 1 - n]; else tempi = data [(N>>2) + n] + data [N + (N>>2) - 1 - n]; /* calculate pre-twiddled FFT input */ xr[i] = tempr * c + tempi * s; xi[i] = tempi * c - tempr * s; /* use recurrence to prepare cosine and sine for next value of i */ cold = c; c = c * cfreq - s * sfreq; s = s * cfreq + cold * sfreq; } /* Perform in-place complex FFT of length N/4 */ switch (N) { case BLOCK_LEN_SHORT * 2: fft( fft_tables, xr, xi, 6); break; case BLOCK_LEN_LONG * 2: fft( fft_tables, xr, xi, 9); } /* prepare for recurrence relations in post-twiddle */ c = cosfreq8; s = sinfreq8; /* post-twiddle FFT output and then get output data */ for (i = 0; i < (N >> 2); i++) { /* get post-twiddled FFT output */ tempr = 2. * (xr[i] * c + xi[i] * s); tempi = 2. * (xi[i] * c - xr[i] * s); /* fill in output values */ data [2 * i] = -tempr; /* first half even */ data [(N >> 1) - 1 - 2 * i] = tempi; /* first half odd */ data [(N >> 1) + 2 * i] = -tempi; /* second half even */ data [N - 1 - 2 * i] = tempr; /* second half odd */ /* use recurrence to prepare cosine and sine for next value of i */ cold = c; c = c * cfreq - s * sfreq; s = s * cfreq + cold * sfreq; } } static void PsyBufferUpdate( FFT_Tables *fft_tables, GlobalPsyInfo * gpsyInfo, PsyInfo * psyInfo, double *newSamples, unsigned int bandwidth, int *cb_width_short, int num_cb_short) { int win; double transBuff[2 * BLOCK_LEN_LONG]; double transBuffS[2 * BLOCK_LEN_SHORT]; psydata_t *psydata = psyInfo->data; psyfloat *tmp; int sfb; psydata->bandS = psyInfo->sizeS * bandwidth * 2 / gpsyInfo->sampleRate; memcpy(transBuff, psyInfo->prevSamples, psyInfo->size * sizeof(double)); memcpy(transBuff + psyInfo->size, newSamples, psyInfo->size * sizeof(double)); for (win = 0; win < 8; win++) { int first = 0; int last = 0; memcpy(transBuffS, transBuff + (win * BLOCK_LEN_SHORT) + (BLOCK_LEN_LONG - BLOCK_LEN_SHORT) / 2, 2 * psyInfo->sizeS * sizeof(double)); Hann(gpsyInfo, transBuffS, 2 * psyInfo->sizeS); mdct( fft_tables, transBuffS, 2 * psyInfo->sizeS); // shift bufs tmp = psydata->engPrev[win]; psydata->engPrev[win] = psydata->eng[win]; psydata->eng[win] = psydata->engNext[win]; psydata->engNext[win] = psydata->engNext2[win]; psydata->engNext2[win] = tmp; for (sfb = 0; sfb < num_cb_short; sfb++) { double e; int l; first = last; last = first + cb_width_short[sfb]; if (first < 1) first = 1; if (first >= psydata->bandS) // band out of range break; e = 0.0; for (l = first; l < last; l++) e += transBuffS[l] * transBuffS[l]; psydata->engNext2[win][sfb] = e; } psydata->lastband = sfb; for (; sfb < num_cb_short; sfb++) { psydata->engNext2[win][sfb] = 0; } } memcpy(psyInfo->prevSamples, newSamples, psyInfo->size * sizeof(double)); } static void BlockSwitch(CoderInfo * coderInfo, PsyInfo * psyInfo, unsigned int numChannels) { unsigned int channel; int desire = ONLY_LONG_WINDOW; /* Use the same block type for all channels If there is 1 channel that wants a short block, use a short block on all channels. */ for (channel = 0; channel < numChannels; channel++) { if (psyInfo[channel].block_type == ONLY_SHORT_WINDOW) desire = ONLY_SHORT_WINDOW; } for (channel = 0; channel < numChannels; channel++) { int lasttype = coderInfo[channel].block_type; if (desire == ONLY_SHORT_WINDOW || coderInfo[channel].desired_block_type == ONLY_SHORT_WINDOW) { if (lasttype == ONLY_LONG_WINDOW || lasttype == SHORT_LONG_WINDOW) coderInfo[channel].block_type = LONG_SHORT_WINDOW; else coderInfo[channel].block_type = ONLY_SHORT_WINDOW; } else { if (lasttype == ONLY_SHORT_WINDOW || lasttype == LONG_SHORT_WINDOW) coderInfo[channel].block_type = SHORT_LONG_WINDOW; else coderInfo[channel].block_type = ONLY_LONG_WINDOW; } coderInfo[channel].desired_block_type = desire; } } psymodel_t psymodel2 = { PsyInit, PsyEnd, PsyCalculate, PsyBufferUpdate, BlockSwitch }; faac-1_30/libfaac/blockswitch.h000066400000000000000000000043441355157314300164720ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: psych.h,v 1.15 2009/06/05 16:32:15 menno Exp $ */ #ifndef PSYCH_H #define PSYCH_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #ifndef M_PI #define M_PI 3.14159265358979323846 #endif #include "coder.h" #include "channels.h" #include "fft.h" typedef struct { int size; int sizeS; /* Previous input samples */ double *prevSamples; int block_type; void *data; } PsyInfo; typedef struct { double sampleRate; /* Hann window */ double *hannWindow; double *hannWindowS; void *data; } GlobalPsyInfo; typedef struct { void (*PsyInit) (GlobalPsyInfo *gpsyInfo, PsyInfo *psyInfo, unsigned int numChannels, unsigned int sampleRate, int *cb_width_long, int num_cb_long, int *cb_width_short, int num_cb_short); void (*PsyEnd) (GlobalPsyInfo *gpsyInfo, PsyInfo *psyInfo, unsigned int numChannels); void (*PsyCalculate) (ChannelInfo *channelInfo, GlobalPsyInfo *gpsyInfo, PsyInfo *psyInfo, int *cb_width_long, int num_cb_long, int *cb_width_short, int num_cb_short, unsigned int numChannels, double quality); void (*PsyBufferUpdate) ( FFT_Tables *fft_tables, GlobalPsyInfo * gpsyInfo, PsyInfo * psyInfo, double *newSamples, unsigned int bandwidth, int *cb_width_short, int num_cb_short); void (*BlockSwitch) (CoderInfo *coderInfo, PsyInfo *psyInfo, unsigned int numChannels); } psymodel_t; extern psymodel_t psymodel2; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* PSYCH_H */faac-1_30/libfaac/channels.c000066400000000000000000000132571355157314300157470ustar00rootroot00000000000000/************************* MPEG-2 NBC Audio Decoder ************************** * * "This software module was originally developed in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original developer retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must be included in all copies or derivative works." Copyright(c)1996. * * ****************************************************************************/ /* * $Id: channels.c,v 1.5 2001/09/04 18:39:35 menno Exp $ */ #include "channels.h" #include "coder.h" #include "util.h" /* If LFE present */ /* Num channels # of SCE's # of CPE's #of LFE's */ /* ============ ========== ========== ========= */ /* 1 1 0 0 */ /* 2 0 1 0 */ /* 3 1 1 0 */ /* 4 1 1 1 */ /* 5 1 2 0 */ /* For more than 5 channels, use the following elements: */ /* 2*N 1 2*(N-1) 1 */ /* 2*N+1 1 2*N 0 */ /* */ /* Else: */ /* */ /* Num channels # of SCE's # of CPE's #of LFE's */ /* ============ ========== ========== ========= */ /* 1 1 0 0 */ /* 2 0 1 0 */ /* 3 1 1 0 */ /* 4 2 1 0 */ /* 5 1 2 0 */ /* For more than 5 channels, use the following elements: */ /* 2*N 2 2*(N-1) 0 */ /* 2*N+1 1 2*N 0 */ void GetChannelInfo(ChannelInfo *channelInfo, int numChannels, int useLfe) { int sceTag = 0; int lfeTag = 0; int cpeTag = 0; int numChannelsLeft = numChannels; /* First element is sce, except for 2 channel case */ if (numChannelsLeft != 2) { channelInfo[numChannels-numChannelsLeft].present = 1; channelInfo[numChannels-numChannelsLeft].tag = sceTag++; channelInfo[numChannels-numChannelsLeft].cpe = 0; channelInfo[numChannels-numChannelsLeft].lfe = 0; numChannelsLeft--; } /* Next elements are cpe's */ while (numChannelsLeft > 1) { /* Left channel info */ channelInfo[numChannels-numChannelsLeft].present = 1; channelInfo[numChannels-numChannelsLeft].tag = cpeTag++; channelInfo[numChannels-numChannelsLeft].cpe = 1; channelInfo[numChannels-numChannelsLeft].common_window = 0; channelInfo[numChannels-numChannelsLeft].ch_is_left = 1; channelInfo[numChannels-numChannelsLeft].paired_ch = numChannels-numChannelsLeft+1; channelInfo[numChannels-numChannelsLeft].lfe = 0; numChannelsLeft--; /* Right channel info */ channelInfo[numChannels-numChannelsLeft].present = 1; channelInfo[numChannels-numChannelsLeft].cpe = 1; channelInfo[numChannels-numChannelsLeft].common_window = 0; channelInfo[numChannels-numChannelsLeft].ch_is_left = 0; channelInfo[numChannels-numChannelsLeft].paired_ch = numChannels-numChannelsLeft-1; channelInfo[numChannels-numChannelsLeft].lfe = 0; numChannelsLeft--; } /* Is there another channel left ? */ if (numChannelsLeft) { if (useLfe) { channelInfo[numChannels-numChannelsLeft].present = 1; channelInfo[numChannels-numChannelsLeft].tag = lfeTag++; channelInfo[numChannels-numChannelsLeft].cpe = 0; channelInfo[numChannels-numChannelsLeft].lfe = 1; } else { channelInfo[numChannels-numChannelsLeft].present = 1; channelInfo[numChannels-numChannelsLeft].tag = sceTag++; channelInfo[numChannels-numChannelsLeft].cpe = 0; channelInfo[numChannels-numChannelsLeft].lfe = 0; } numChannelsLeft--; } } faac-1_30/libfaac/channels.h000066400000000000000000000025761355157314300157560ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: channels.h,v 1.7 2003/06/26 19:19:41 knik Exp $ */ #ifndef CHANNEL_H #define CHANNEL_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "coder.h" typedef struct { int is_present; int ms_used[MAX_SCFAC_BANDS]; } MSInfo; typedef struct { int tag; int present; int ch_is_left; int paired_ch; int common_window; int cpe; int sce; int lfe; MSInfo msInfo; } ChannelInfo; void GetChannelInfo(ChannelInfo *channelInfo, int numChannels, int useLfe); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* CHANNEL_H */ faac-1_30/libfaac/coder.h000066400000000000000000000104171355157314300152500ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: coder.h,v 1.13 2005/02/02 07:49:10 sur Exp $ */ #ifndef CODER_H #define CODER_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Allow encoding of Digital Radio Mondiale (DRM) */ //#define DRM /* Allow encoding of Digital Radio Mondiale (DRM) with transform length 1024 */ //#define DRM_1024 #define MAX_CHANNELS 64 #ifdef DRM #ifdef DRM_1024 # define FRAME_LEN 1024 # define BLOCK_LEN_LONG 1024 # define BLOCK_LEN_SHORT 128 #else # define FRAME_LEN 960 # define BLOCK_LEN_LONG 960 # define BLOCK_LEN_SHORT 120 #endif /* DRM_1024 */ #else # define FRAME_LEN 1024 # define BLOCK_LEN_LONG 1024 # define BLOCK_LEN_SHORT 128 #endif #define NSFB_LONG 51 #define NSFB_SHORT 15 #define MAX_SHORT_WINDOWS 8 #define MAX_SCFAC_BANDS ((NSFB_SHORT+1)*MAX_SHORT_WINDOWS) enum WINDOW_TYPE { ONLY_LONG_WINDOW, LONG_SHORT_WINDOW, ONLY_SHORT_WINDOW, SHORT_LONG_WINDOW }; #define TNS_MAX_ORDER 20 #define DEF_TNS_GAIN_THRESH 1.4 #define DEF_TNS_COEFF_THRESH 0.1 #define DEF_TNS_COEFF_RES 4 #define DEF_TNS_RES_OFFSET 3 #define LEN_TNS_NFILTL 2 #define LEN_TNS_NFILTS 1 #define LPC 2 typedef struct { int order; /* Filter order */ int direction; /* Filtering direction */ int coefCompress; /* Are coeffs compressed? */ int length; /* Length, in bands */ double aCoeffs[TNS_MAX_ORDER+1]; /* AR Coefficients */ double kCoeffs[TNS_MAX_ORDER+1]; /* Reflection Coefficients */ int index[TNS_MAX_ORDER+1]; /* Coefficient indices */ } TnsFilterData; typedef struct { int numFilters; /* Number of filters */ int coefResolution; /* Coefficient resolution */ TnsFilterData tnsFilter[1< #include #include #include "fft.h" #include "util.h" #define MAXLOGM 9 #define MAXLOGR 8 #if defined DRM && !defined DRM_1024 #include "kiss_fft/kiss_fft.h" #include "kiss_fft/kiss_fftr.h" static const int logm_to_nfft[] = { /* 0 1 2 3 */ 0, 0, 0, 0, /* 4 5 6 7 */ 0, 0, 60, 0, /* 8 9 */ 240, 480 }; void fft_initialize( FFT_Tables *fft_tables ) { memset( fft_tables->cfg, 0, sizeof( fft_tables->cfg ) ); } void fft_terminate( FFT_Tables *fft_tables ) { unsigned int i; for ( i = 0; i < sizeof( fft_tables->cfg ) / sizeof( fft_tables->cfg[0] ); i++ ) { if ( fft_tables->cfg[i][0] ) { free( fft_tables->cfg[i][0] ); fft_tables->cfg[i][0] = NULL; } if ( fft_tables->cfg[i][1] ) { free( fft_tables->cfg[i][1] ); fft_tables->cfg[i][1] = NULL; } } } void rfft( FFT_Tables *fft_tables, double *x, int logm ) { /* sur: use real-only optimized FFT */ int nfft = 0; kiss_fft_scalar fin[1 << MAXLOGR]; kiss_fft_cpx fout[1 << MAXLOGR]; if ( logm > MAXLOGR ) { fprintf(stderr, "fft size too big\n"); exit(1); } nfft = logm_to_nfft[logm]; if ( fft_tables->cfg[logm][0] == NULL ) { if ( nfft ) { fft_tables->cfg[logm][0] = kiss_fftr_alloc( nfft, 0, NULL, NULL ); } else { fprintf(stderr, "bad logm = %d\n", logm); exit( 1 ); } } if ( fft_tables->cfg[logm][0] ) { unsigned int i; for ( i = 0; i < nfft; i++ ) { fin[i] = x[i]; } kiss_fftr( (kiss_fftr_cfg)fft_tables->cfg[logm][0], fin, fout ); for ( i = 0; i < nfft / 2; i++ ) { x[i] = fout[i].r; x[i + nfft / 2] = fout[i].i; } } else { fprintf( stderr, "bad config for logm = %d\n", logm); exit( 1 ); } } void fft( FFT_Tables *fft_tables, double *xr, double *xi, int logm ) { int nfft = 0; kiss_fft_cpx fin[1 << MAXLOGM]; kiss_fft_cpx fout[1 << MAXLOGM]; if ( logm > MAXLOGM ) { fprintf(stderr, "fft size too big\n"); exit(1); } nfft = logm_to_nfft[logm]; if ( fft_tables->cfg[logm][0] == NULL ) { if ( nfft ) { fft_tables->cfg[logm][0] = kiss_fft_alloc( nfft, 0, NULL, NULL ); } else { fprintf(stderr, "bad logm = %d\n", logm); exit( 1 ); } } if ( fft_tables->cfg[logm][0] ) { unsigned int i; for ( i = 0; i < nfft; i++ ) { fin[i].r = xr[i]; fin[i].i = xi[i]; } kiss_fft( (kiss_fft_cfg)fft_tables->cfg[logm][0], fin, fout ); for ( i = 0; i < nfft; i++ ) { xr[i] = fout[i].r; xi[i] = fout[i].i; } } else { fprintf( stderr, "bad config for logm = %d\n", logm); exit( 1 ); } } void ffti( FFT_Tables *fft_tables, double *xr, double *xi, int logm ) { int nfft = 0; kiss_fft_cpx fin[1 << MAXLOGM]; kiss_fft_cpx fout[1 << MAXLOGM]; if ( logm > MAXLOGM ) { fprintf(stderr, "fft size too big\n"); exit(1); } nfft = logm_to_nfft[logm]; if ( fft_tables->cfg[logm][1] == NULL ) { if ( nfft ) { fft_tables->cfg[logm][1] = kiss_fft_alloc( nfft, 1, NULL, NULL ); } else { fprintf(stderr, "bad logm = %d\n", logm); exit( 1 ); } } if ( fft_tables->cfg[logm][1] ) { unsigned int i; double fac = 1.0 / (double)nfft; for ( i = 0; i < nfft; i++ ) { fin[i].r = xr[i]; fin[i].i = xi[i]; } kiss_fft( (kiss_fft_cfg)fft_tables->cfg[logm][1], fin, fout ); for ( i = 0; i < nfft; i++ ) { xr[i] = fout[i].r * fac; xi[i] = fout[i].i * fac; } } else { fprintf( stderr, "bad config for logm = %d\n", logm); exit( 1 ); } } #else /* !defined DRM || defined DRM_1024 */ void fft_initialize( FFT_Tables *fft_tables ) { int i; fft_tables->costbl = AllocMemory( (MAXLOGM+1) * sizeof( fft_tables->costbl[0] ) ); fft_tables->negsintbl = AllocMemory( (MAXLOGM+1) * sizeof( fft_tables->negsintbl[0] ) ); fft_tables->reordertbl = AllocMemory( (MAXLOGM+1) * sizeof( fft_tables->reordertbl[0] ) ); for( i = 0; i< MAXLOGM+1; i++ ) { fft_tables->costbl[i] = NULL; fft_tables->negsintbl[i] = NULL; fft_tables->reordertbl[i] = NULL; } } void fft_terminate( FFT_Tables *fft_tables ) { int i; for( i = 0; i< MAXLOGM+1; i++ ) { if( fft_tables->costbl[i] != NULL ) FreeMemory( fft_tables->costbl[i] ); if( fft_tables->negsintbl[i] != NULL ) FreeMemory( fft_tables->negsintbl[i] ); if( fft_tables->reordertbl[i] != NULL ) FreeMemory( fft_tables->reordertbl[i] ); } FreeMemory( fft_tables->costbl ); FreeMemory( fft_tables->negsintbl ); FreeMemory( fft_tables->reordertbl ); fft_tables->costbl = NULL; fft_tables->negsintbl = NULL; fft_tables->reordertbl = NULL; } static void reorder( FFT_Tables *fft_tables, double *x, int logm) { int i; int size = 1 << logm; unsigned short *r; //size if ( fft_tables->reordertbl[logm] == NULL ) // create bit reversing table { fft_tables->reordertbl[logm] = AllocMemory(size * sizeof(*(fft_tables->reordertbl[0]))); for (i = 0; i < size; i++) { int reversed = 0; int b0; int tmp = i; for (b0 = 0; b0 < logm; b0++) { reversed = (reversed << 1) | (tmp & 1); tmp >>= 1; } fft_tables->reordertbl[logm][i] = reversed; } } r = fft_tables->reordertbl[logm]; for (i = 0; i < size; i++) { int j = r[i]; double tmp; if (j <= i) continue; tmp = x[i]; x[i] = x[j]; x[j] = tmp; } } static void fft_proc( double *xr, double *xi, fftfloat *refac, fftfloat *imfac, int size) { int step, shift, pos; int exp, estep; estep = size; for (step = 1; step < size; step *= 2) { int x1; int x2 = 0; estep >>= 1; for (pos = 0; pos < size; pos += (2 * step)) { x1 = x2; x2 += step; exp = 0; for (shift = 0; shift < step; shift++) { double v2r, v2i; v2r = xr[x2] * refac[exp] - xi[x2] * imfac[exp]; v2i = xr[x2] * imfac[exp] + xi[x2] * refac[exp]; xr[x2] = xr[x1] - v2r; xr[x1] += v2r; xi[x2] = xi[x1] - v2i; xi[x1] += v2i; exp += estep; x1++; x2++; } } } } static void check_tables( FFT_Tables *fft_tables, int logm) { if( fft_tables->costbl[logm] == NULL ) { int i; int size = 1 << logm; if( fft_tables->negsintbl[logm] != NULL ) FreeMemory( fft_tables->negsintbl[logm] ); fft_tables->costbl[logm] = AllocMemory((size / 2) * sizeof(*(fft_tables->costbl[0]))); fft_tables->negsintbl[logm] = AllocMemory((size / 2) * sizeof(*(fft_tables->negsintbl[0]))); for (i = 0; i < (size >> 1); i++) { double theta = 2.0 * M_PI * ((double) i) / (double) size; fft_tables->costbl[logm][i] = cos(theta); fft_tables->negsintbl[logm][i] = -sin(theta); } } } void fft( FFT_Tables *fft_tables, double *xr, double *xi, int logm) { if (logm > MAXLOGM) { fprintf(stderr, "fft size too big\n"); exit(1); } if (logm < 1) { //printf("logm < 1\n"); return; } check_tables( fft_tables, logm); reorder( fft_tables, xr, logm); reorder( fft_tables, xi, logm); fft_proc( xr, xi, fft_tables->costbl[logm], fft_tables->negsintbl[logm], 1 << logm ); } void rfft( FFT_Tables *fft_tables, double *x, int logm) { double xi[1 << MAXLOGR]; if (logm > MAXLOGR) { fprintf(stderr, "rfft size too big\n"); exit(1); } memset(xi, 0, (1 << logm) * sizeof(xi[0])); fft( fft_tables, x, xi, logm); memcpy(x + (1 << (logm - 1)), xi, (1 << (logm - 1)) * sizeof(*x)); } void ffti( FFT_Tables *fft_tables, double *xr, double *xi, int logm) { int i, size; double fac; double *xrp, *xip; fft( fft_tables, xi, xr, logm); size = 1 << logm; fac = 1.0 / size; xrp = xr; xip = xi; for (i = 0; i < size; i++) { *xrp++ *= fac; *xip++ *= fac; } } #endif /* defined DRM && !defined DRM_1024 */ faac-1_30/libfaac/fft.h000066400000000000000000000031031355157314300147250ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * $Id: fft.h,v 1.6 2005/02/02 07:50:35 sur Exp $ * Copyright (C) 2002 Krzysztof Nikiel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _FFT_H_ #define _FFT_H_ typedef float fftfloat; #if defined DRM && !defined DRM_1024 #define MAX_FFT 10 typedef struct { /* cfg[Max FFT][FFT and inverse FFT] */ void* cfg[MAX_FFT][2]; } FFT_Tables; #else /* use own FFT */ typedef struct { fftfloat **costbl; fftfloat **negsintbl; unsigned short **reordertbl; } FFT_Tables; #endif /* defined DRM && !defined DRM_1024 */ void fft_initialize ( FFT_Tables *fft_tables ); void fft_terminate ( FFT_Tables *fft_tables ); void rfft ( FFT_Tables *fft_tables, double *x, int logm ); void fft ( FFT_Tables *fft_tables, double *xr, double *xi, int logm ); void ffti ( FFT_Tables *fft_tables, double *xr, double *xi, int logm ); #endif faac-1_30/libfaac/filtbank.c000066400000000000000000000523721355157314300157470ustar00rootroot00000000000000/************************* MPEG-2 NBC Audio Decoder ************************** * * "This software module was originally developed by AT&T, Dolby Laboratories, Fraunhofer Gesellschaft IIS in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original developer retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must be included in all copies or derivative works." Copyright(c)1996. * * ****************************************************************************/ /* * $Id: filtbank.c,v 1.14 2012/03/01 18:34:17 knik Exp $ */ /* * CHANGES: * 2001/01/17: menno: Added frequency cut off filter. * */ #include #include #include #include "coder.h" #include "filtbank.h" #include "frame.h" #include "fft.h" #include "util.h" #define TWOPI 2*M_PI static void CalculateKBDWindow ( double* win, double alpha, int length ); static double Izero ( double x); static void MDCT ( FFT_Tables *fft_tables, double *data, int N ); static void IMDCT ( FFT_Tables *fft_tables, double *data, int N ); void FilterBankInit(faacEncStruct* hEncoder) { unsigned int i, channel; for (channel = 0; channel < hEncoder->numChannels; channel++) { hEncoder->freqBuff[channel] = (double*)AllocMemory(2*FRAME_LEN*sizeof(double)); hEncoder->overlapBuff[channel] = (double*)AllocMemory(FRAME_LEN*sizeof(double)); SetMemory(hEncoder->overlapBuff[channel], 0, FRAME_LEN*sizeof(double)); } hEncoder->sin_window_long = (double*)AllocMemory(BLOCK_LEN_LONG*sizeof(double)); hEncoder->sin_window_short = (double*)AllocMemory(BLOCK_LEN_SHORT*sizeof(double)); hEncoder->kbd_window_long = (double*)AllocMemory(BLOCK_LEN_LONG*sizeof(double)); hEncoder->kbd_window_short = (double*)AllocMemory(BLOCK_LEN_SHORT*sizeof(double)); for( i=0; isin_window_long[i] = sin((M_PI/(2*BLOCK_LEN_LONG)) * (i + 0.5)); for( i=0; isin_window_short[i] = sin((M_PI/(2*BLOCK_LEN_SHORT)) * (i + 0.5)); CalculateKBDWindow(hEncoder->kbd_window_long, 4, BLOCK_LEN_LONG*2); CalculateKBDWindow(hEncoder->kbd_window_short, 6, BLOCK_LEN_SHORT*2); } void FilterBankEnd(faacEncStruct* hEncoder) { unsigned int channel; for (channel = 0; channel < hEncoder->numChannels; channel++) { if (hEncoder->freqBuff[channel]) FreeMemory(hEncoder->freqBuff[channel]); if (hEncoder->overlapBuff[channel]) FreeMemory(hEncoder->overlapBuff[channel]); } if (hEncoder->sin_window_long) FreeMemory(hEncoder->sin_window_long); if (hEncoder->sin_window_short) FreeMemory(hEncoder->sin_window_short); if (hEncoder->kbd_window_long) FreeMemory(hEncoder->kbd_window_long); if (hEncoder->kbd_window_short) FreeMemory(hEncoder->kbd_window_short); } void FilterBank(faacEncStruct* hEncoder, CoderInfo *coderInfo, double *p_in_data, double *p_out_mdct, double *p_overlap, int overlap_select) { double *p_o_buf, *first_window, *second_window; double *transf_buf; int k, i; int block_type = coderInfo->block_type; transf_buf = (double*)AllocMemory(2*BLOCK_LEN_LONG*sizeof(double)); /* create / shift old values */ /* We use p_overlap here as buffer holding the last frame time signal*/ if(overlap_select != MNON_OVERLAPPED) { memcpy(transf_buf, p_overlap, FRAME_LEN*sizeof(double)); memcpy(transf_buf+BLOCK_LEN_LONG, p_in_data, FRAME_LEN*sizeof(double)); memcpy(p_overlap, p_in_data, FRAME_LEN*sizeof(double)); } else { memcpy(transf_buf, p_in_data, 2*FRAME_LEN*sizeof(double)); } /* Window shape processing */ if(overlap_select != MNON_OVERLAPPED) { switch (coderInfo->prev_window_shape) { case SINE_WINDOW: if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW)) first_window = hEncoder->sin_window_long; else first_window = hEncoder->sin_window_short; break; default: case KBD_WINDOW: if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW)) first_window = hEncoder->kbd_window_long; else first_window = hEncoder->kbd_window_short; break; } switch (coderInfo->window_shape){ case SINE_WINDOW: default: if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW)) second_window = hEncoder->sin_window_long; else second_window = hEncoder->sin_window_short; break; case KBD_WINDOW: if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW)) second_window = hEncoder->kbd_window_long; else second_window = hEncoder->kbd_window_short; break; } } else { /* Always long block and sine window for LTP */ first_window = hEncoder->sin_window_long; second_window = hEncoder->sin_window_long; } /* Set ptr to transf-Buffer */ p_o_buf = transf_buf; /* Separate action for each Block Type */ switch (block_type) { case ONLY_LONG_WINDOW : for ( i = 0 ; i < BLOCK_LEN_LONG ; i++){ p_out_mdct[i] = p_o_buf[i] * first_window[i]; p_out_mdct[i+BLOCK_LEN_LONG] = p_o_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1]; } MDCT( &hEncoder->fft_tables, p_out_mdct, 2*BLOCK_LEN_LONG ); break; case LONG_SHORT_WINDOW : for ( i = 0 ; i < BLOCK_LEN_LONG ; i++) p_out_mdct[i] = p_o_buf[i] * first_window[i]; memcpy(p_out_mdct+BLOCK_LEN_LONG,p_o_buf+BLOCK_LEN_LONG,NFLAT_LS*sizeof(double)); for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++) p_out_mdct[i+BLOCK_LEN_LONG+NFLAT_LS] = p_o_buf[i+BLOCK_LEN_LONG+NFLAT_LS] * second_window[BLOCK_LEN_SHORT-i-1]; SetMemory(p_out_mdct+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizeof(double)); MDCT( &hEncoder->fft_tables, p_out_mdct, 2*BLOCK_LEN_LONG ); break; case SHORT_LONG_WINDOW : SetMemory(p_out_mdct,0,NFLAT_LS*sizeof(double)); for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++) p_out_mdct[i+NFLAT_LS] = p_o_buf[i+NFLAT_LS] * first_window[i]; memcpy(p_out_mdct+NFLAT_LS+BLOCK_LEN_SHORT,p_o_buf+NFLAT_LS+BLOCK_LEN_SHORT,NFLAT_LS*sizeof(double)); for ( i = 0 ; i < BLOCK_LEN_LONG ; i++) p_out_mdct[i+BLOCK_LEN_LONG] = p_o_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1]; MDCT( &hEncoder->fft_tables, p_out_mdct, 2*BLOCK_LEN_LONG ); break; case ONLY_SHORT_WINDOW : p_o_buf += NFLAT_LS; for ( k=0; k < MAX_SHORT_WINDOWS; k++ ) { for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++ ){ p_out_mdct[i] = p_o_buf[i] * first_window[i]; p_out_mdct[i+BLOCK_LEN_SHORT] = p_o_buf[i+BLOCK_LEN_SHORT] * second_window[BLOCK_LEN_SHORT-i-1]; } MDCT( &hEncoder->fft_tables, p_out_mdct, 2*BLOCK_LEN_SHORT ); p_out_mdct += BLOCK_LEN_SHORT; p_o_buf += BLOCK_LEN_SHORT; first_window = second_window; } break; } if (transf_buf) FreeMemory(transf_buf); } void IFilterBank(faacEncStruct* hEncoder, CoderInfo *coderInfo, double *p_in_data, double *p_out_data, double *p_overlap, int overlap_select) { double *o_buf, *transf_buf, *overlap_buf; double *first_window, *second_window; double *fp; int k, i; int block_type = coderInfo->block_type; transf_buf = (double*)AllocMemory(2*BLOCK_LEN_LONG*sizeof(double)); overlap_buf = (double*)AllocMemory(2*BLOCK_LEN_LONG*sizeof(double)); /* Window shape processing */ if (overlap_select != MNON_OVERLAPPED) { // switch (coderInfo->prev_window_shape){ // case SINE_WINDOW: if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW)) first_window = hEncoder->sin_window_long; else first_window = hEncoder->sin_window_short; // break; // case KBD_WINDOW: // if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW)) // first_window = hEncoder->kbd_window_long; // else // first_window = hEncoder->kbd_window_short; // break; // } // switch (coderInfo->window_shape){ // case SINE_WINDOW: if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW)) second_window = hEncoder->sin_window_long; else second_window = hEncoder->sin_window_short; // break; // case KBD_WINDOW: // if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW)) // second_window = hEncoder->kbd_window_long; // else // second_window = hEncoder->kbd_window_short; // break; // } } else { /* Always long block and sine window for LTP */ first_window = hEncoder->sin_window_long; second_window = hEncoder->sin_window_long; } /* Assemble overlap buffer */ memcpy(overlap_buf,p_overlap,BLOCK_LEN_LONG*sizeof(double)); o_buf = overlap_buf; /* Separate action for each Block Type */ switch( block_type ) { case ONLY_LONG_WINDOW : memcpy(transf_buf, p_in_data,BLOCK_LEN_LONG*sizeof(double)); IMDCT( &hEncoder->fft_tables, transf_buf, 2*BLOCK_LEN_LONG ); for ( i = 0 ; i < BLOCK_LEN_LONG ; i++) transf_buf[i] *= first_window[i]; if (overlap_select != MNON_OVERLAPPED) { for ( i = 0 ; i < BLOCK_LEN_LONG; i++ ){ o_buf[i] += transf_buf[i]; o_buf[i+BLOCK_LEN_LONG] = transf_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1]; } } else { /* overlap_select == NON_OVERLAPPED */ for ( i = 0 ; i < BLOCK_LEN_LONG; i++ ) transf_buf[i+BLOCK_LEN_LONG] *= second_window[BLOCK_LEN_LONG-i-1]; } break; case LONG_SHORT_WINDOW : memcpy(transf_buf, p_in_data,BLOCK_LEN_LONG*sizeof(double)); IMDCT( &hEncoder->fft_tables, transf_buf, 2*BLOCK_LEN_LONG ); for ( i = 0 ; i < BLOCK_LEN_LONG ; i++) transf_buf[i] *= first_window[i]; if (overlap_select != MNON_OVERLAPPED) { for ( i = 0 ; i < BLOCK_LEN_LONG; i++ ) o_buf[i] += transf_buf[i]; memcpy(o_buf+BLOCK_LEN_LONG,transf_buf+BLOCK_LEN_LONG,NFLAT_LS*sizeof(double)); for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++) o_buf[i+BLOCK_LEN_LONG+NFLAT_LS] = transf_buf[i+BLOCK_LEN_LONG+NFLAT_LS] * second_window[BLOCK_LEN_SHORT-i-1]; SetMemory(o_buf+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizeof(double)); } else { /* overlap_select == NON_OVERLAPPED */ for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++) transf_buf[i+BLOCK_LEN_LONG+NFLAT_LS] *= second_window[BLOCK_LEN_SHORT-i-1]; SetMemory(transf_buf+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizeof(double)); } break; case SHORT_LONG_WINDOW : memcpy(transf_buf, p_in_data,BLOCK_LEN_LONG*sizeof(double)); IMDCT( &hEncoder->fft_tables, transf_buf, 2*BLOCK_LEN_LONG ); for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++) transf_buf[i+NFLAT_LS] *= first_window[i]; if (overlap_select != MNON_OVERLAPPED) { for ( i = 0 ; i < BLOCK_LEN_SHORT; i++ ) o_buf[i+NFLAT_LS] += transf_buf[i+NFLAT_LS]; memcpy(o_buf+BLOCK_LEN_SHORT+NFLAT_LS,transf_buf+BLOCK_LEN_SHORT+NFLAT_LS,NFLAT_LS*sizeof(double)); for ( i = 0 ; i < BLOCK_LEN_LONG ; i++) o_buf[i+BLOCK_LEN_LONG] = transf_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1]; } else { /* overlap_select == NON_OVERLAPPED */ SetMemory(transf_buf,0,NFLAT_LS*sizeof(double)); for ( i = 0 ; i < BLOCK_LEN_LONG ; i++) transf_buf[i+BLOCK_LEN_LONG] *= second_window[BLOCK_LEN_LONG-i-1]; } break; case ONLY_SHORT_WINDOW : if (overlap_select != MNON_OVERLAPPED) { fp = o_buf + NFLAT_LS; } else { /* overlap_select == NON_OVERLAPPED */ fp = transf_buf; } for ( k=0; k < MAX_SHORT_WINDOWS; k++ ) { memcpy(transf_buf,p_in_data,BLOCK_LEN_SHORT*sizeof(double)); IMDCT( &hEncoder->fft_tables, transf_buf, 2*BLOCK_LEN_SHORT ); p_in_data += BLOCK_LEN_SHORT; if (overlap_select != MNON_OVERLAPPED) { for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++){ transf_buf[i] *= first_window[i]; fp[i] += transf_buf[i]; fp[i+BLOCK_LEN_SHORT] = transf_buf[i+BLOCK_LEN_SHORT] * second_window[BLOCK_LEN_SHORT-i-1]; } fp += BLOCK_LEN_SHORT; } else { /* overlap_select == NON_OVERLAPPED */ for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++){ fp[i] *= first_window[i]; fp[i+BLOCK_LEN_SHORT] *= second_window[BLOCK_LEN_SHORT-i-1]; } fp += 2*BLOCK_LEN_SHORT; } first_window = second_window; } SetMemory(o_buf+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizeof(double)); break; } if (overlap_select != MNON_OVERLAPPED) memcpy(p_out_data,o_buf,BLOCK_LEN_LONG*sizeof(double)); else /* overlap_select == NON_OVERLAPPED */ memcpy(p_out_data,transf_buf,2*BLOCK_LEN_LONG*sizeof(double)); /* save unused output data */ memcpy(p_overlap,o_buf+BLOCK_LEN_LONG,BLOCK_LEN_LONG*sizeof(double)); if (overlap_buf) FreeMemory(overlap_buf); if (transf_buf) FreeMemory(transf_buf); } void specFilter(double *freqBuff, int sampleRate, int lowpassFreq, int specLen ) { int lowpass,xlowpass; /* calculate the last line which is not zero */ lowpass = (lowpassFreq * specLen) / (sampleRate>>1) + 1; xlowpass = (lowpass < specLen) ? lowpass : specLen ; SetMemory(freqBuff+xlowpass,0,(specLen-xlowpass)*sizeof(double)); } static double Izero(double x) { const double IzeroEPSILON = 1E-41; /* Max error acceptable in Izero */ double sum, u, halfx, temp; int n; sum = u = n = 1; halfx = x/2.0; do { temp = halfx/(double)n; n += 1; temp *= temp; u *= temp; sum += u; } while (u >= IzeroEPSILON*sum); return(sum); } static void CalculateKBDWindow(double* win, double alpha, int length) { int i; double IBeta; double tmp; double sum = 0.0; alpha *= M_PI; IBeta = 1.0/Izero(alpha); /* calculate lower half of Kaiser Bessel window */ for(i=0; i<(length>>1); i++) { tmp = 4.0*(double)i/(double)length - 1.0; win[i] = Izero(alpha*sqrt(1.0-tmp*tmp))*IBeta; sum += win[i]; } sum = 1.0/sum; tmp = 0.0; /* calculate lower half of window */ for(i=0; i<(length>>1); i++) { tmp += win[i]; win[i] = sqrt(tmp*sum); } } static void MDCT( FFT_Tables *fft_tables, double *data, int N ) { double *xi, *xr; double tempr, tempi, c, s, cold, cfreq, sfreq; /* temps for pre and post twiddle */ double freq = TWOPI / N; double cosfreq8, sinfreq8; int i, n; xi = (double*)AllocMemory((N >> 2)*sizeof(double)); xr = (double*)AllocMemory((N >> 2)*sizeof(double)); /* prepare for recurrence relation in pre-twiddle */ cfreq = cos (freq); sfreq = sin (freq); cosfreq8 = cos (freq * 0.125); sinfreq8 = sin (freq * 0.125); c = cosfreq8; s = sinfreq8; for (i = 0; i < (N >> 2); i++) { /* calculate real and imaginary parts of g(n) or G(p) */ n = (N >> 1) - 1 - 2 * i; if (i < (N >> 3)) tempr = data [(N >> 2) + n] + data [N + (N >> 2) - 1 - n]; /* use second form of e(n) for n = N / 2 - 1 - 2i */ else tempr = data [(N >> 2) + n] - data [(N >> 2) - 1 - n]; /* use first form of e(n) for n = N / 2 - 1 - 2i */ n = 2 * i; if (i < (N >> 3)) tempi = data [(N >> 2) + n] - data [(N >> 2) - 1 - n]; /* use first form of e(n) for n=2i */ else tempi = data [(N >> 2) + n] + data [N + (N >> 2) - 1 - n]; /* use second form of e(n) for n=2i*/ /* calculate pre-twiddled FFT input */ xr[i] = tempr * c + tempi * s; xi[i] = tempi * c - tempr * s; /* use recurrence to prepare cosine and sine for next value of i */ cold = c; c = c * cfreq - s * sfreq; s = s * cfreq + cold * sfreq; } /* Perform in-place complex FFT of length N/4 */ switch (N) { case BLOCK_LEN_SHORT * 2: fft( fft_tables, xr, xi, 6); break; case BLOCK_LEN_LONG * 2: fft( fft_tables, xr, xi, 9); } /* prepare for recurrence relations in post-twiddle */ c = cosfreq8; s = sinfreq8; /* post-twiddle FFT output and then get output data */ for (i = 0; i < (N >> 2); i++) { /* get post-twiddled FFT output */ tempr = 2. * (xr[i] * c + xi[i] * s); tempi = 2. * (xi[i] * c - xr[i] * s); /* fill in output values */ data [2 * i] = -tempr; /* first half even */ data [(N >> 1) - 1 - 2 * i] = tempi; /* first half odd */ data [(N >> 1) + 2 * i] = -tempi; /* second half even */ data [N - 1 - 2 * i] = tempr; /* second half odd */ /* use recurrence to prepare cosine and sine for next value of i */ cold = c; c = c * cfreq - s * sfreq; s = s * cfreq + cold * sfreq; } if (xr) FreeMemory(xr); if (xi) FreeMemory(xi); } static void IMDCT( FFT_Tables *fft_tables, double *data, int N) { double *xi, *xr; double tempr, tempi, c, s, cold, cfreq, sfreq; /* temps for pre and post twiddle */ double freq = 2.0 * M_PI / N; double fac, cosfreq8, sinfreq8; int i; xi = (double*)AllocMemory((N >> 2)*sizeof(double)); xr = (double*)AllocMemory((N >> 2)*sizeof(double)); /* Choosing to allocate 2/N factor to Inverse Xform! */ fac = 2. / N; /* remaining 2/N from 4/N IFFT factor */ /* prepare for recurrence relation in pre-twiddle */ cfreq = cos (freq); sfreq = sin (freq); cosfreq8 = cos (freq * 0.125); sinfreq8 = sin (freq * 0.125); c = cosfreq8; s = sinfreq8; for (i = 0; i < (N >> 2); i++) { /* calculate real and imaginary parts of g(n) or G(p) */ tempr = -data[2 * i]; tempi = data[(N >> 1) - 1 - 2 * i]; /* calculate pre-twiddled FFT input */ xr[i] = tempr * c - tempi * s; xi[i] = tempi * c + tempr * s; /* use recurrence to prepare cosine and sine for next value of i */ cold = c; c = c * cfreq - s * sfreq; s = s * cfreq + cold * sfreq; } /* Perform in-place complex IFFT of length N/4 */ switch (N) { case BLOCK_LEN_SHORT * 2: ffti( fft_tables, xr, xi, 6); break; case BLOCK_LEN_LONG * 2: ffti( fft_tables, xr, xi, 9); } /* prepare for recurrence relations in post-twiddle */ c = cosfreq8; s = sinfreq8; /* post-twiddle FFT output and then get output data */ for (i = 0; i < (N >> 2); i++) { /* get post-twiddled FFT output */ tempr = fac * (xr[i] * c - xi[i] * s); tempi = fac * (xi[i] * c + xr[i] * s); /* fill in output values */ data [(N >> 1) + (N >> 2) - 1 - 2 * i] = tempr; if (i < (N >> 3)) data [(N >> 1) + (N >> 2) + 2 * i] = tempr; else data [2 * i - (N >> 2)] = -tempr; data [(N >> 2) + 2 * i] = tempi; if (i < (N >> 3)) data [(N >> 2) - 1 - 2 * i] = -tempi; else data [(N >> 2) + N - 1 - 2*i] = tempi; /* use recurrence to prepare cosine and sine for next value of i */ cold = c; c = c * cfreq - s * sfreq; s = s * cfreq + cold * sfreq; } if (xr) FreeMemory(xr); if (xi) FreeMemory(xi); } faac-1_30/libfaac/filtbank.h000066400000000000000000000034551355157314300157520ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: filtbank.h,v 1.12 2012/03/01 18:34:17 knik Exp $ */ #ifndef FILTBANK_H #define FILTBANK_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "frame.h" #ifdef DRM #define NFLAT_LS (( BLOCK_LEN_LONG - BLOCK_LEN_SHORT ) / 2) #else #define NFLAT_LS 448 #endif #define MOVERLAPPED 0 #define MNON_OVERLAPPED 1 #define SINE_WINDOW 0 #define KBD_WINDOW 1 void FilterBankInit ( faacEncStruct* hEncoder ); void FilterBankEnd ( faacEncStruct* hEncoder ); void FilterBank( faacEncStruct* hEncoder, CoderInfo *coderInfo, double *p_in_data, double *p_out_mdct, double *p_overlap, int overlap_select ); void IFilterBank( faacEncStruct* hEncoder, CoderInfo *coderInfo, double *p_in_data, double *p_out_mdct, double *p_overlap, int overlap_select ); void specFilter( double *freqBuff, int sampleRate, int lowpassFreq, int specLen ); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* FILTBANK_H */ faac-1_30/libfaac/frame.c000066400000000000000000000725671355157314300152570ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #include "frame.h" #include "coder.h" #include "channels.h" #include "bitstream.h" #include "filtbank.h" #include "util.h" #include "tns.h" #include "stereo.h" #if (defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined(PACKAGE_VERSION) #include "win32_ver.h" #endif static char *libfaacName = PACKAGE_VERSION; static char *libCopyright = "FAAC - Freeware Advanced Audio Coder (http://faac.sourceforge.net/)\n" " Copyright (C) 1999,2000,2001 Menno Bakker\n" " Copyright (C) 2002,2003,2017 Krzysztof Nikiel\n" "This software is based on the ISO MPEG-4 reference source code.\n"; static const psymodellist_t psymodellist[] = { {&psymodel2, "knipsycho psychoacoustic"}, {NULL} }; static SR_INFO srInfo[12+1]; // default bandwidth/samplerate ratio static const struct { double fac; double freq; } g_bw = {0.42, 18000}; int FAACAPI faacEncGetVersion( char **faac_id_string, char **faac_copyright_string) { if (faac_id_string) *faac_id_string = libfaacName; if (faac_copyright_string) *faac_copyright_string = libCopyright; return FAAC_CFG_VERSION; } int FAACAPI faacEncGetDecoderSpecificInfo(faacEncHandle hpEncoder,unsigned char** ppBuffer,unsigned long* pSizeOfDecoderSpecificInfo) { faacEncStruct* hEncoder = (faacEncStruct*)hpEncoder; BitStream* pBitStream = NULL; if((hEncoder == NULL) || (ppBuffer == NULL) || (pSizeOfDecoderSpecificInfo == NULL)) { return -1; } if(hEncoder->config.mpegVersion == MPEG2){ return -2; /* not supported */ } *pSizeOfDecoderSpecificInfo = 2; *ppBuffer = malloc(2); if(*ppBuffer != NULL){ memset(*ppBuffer,0,*pSizeOfDecoderSpecificInfo); pBitStream = OpenBitStream(*pSizeOfDecoderSpecificInfo, *ppBuffer); PutBit(pBitStream, hEncoder->config.aacObjectType, 5); PutBit(pBitStream, hEncoder->sampleRateIdx, 4); PutBit(pBitStream, hEncoder->numChannels, 4); CloseBitStream(pBitStream); return 0; } else { return -3; } } faacEncConfigurationPtr FAACAPI faacEncGetCurrentConfiguration(faacEncHandle hpEncoder) { faacEncStruct* hEncoder = (faacEncStruct*)hpEncoder; faacEncConfigurationPtr config = &(hEncoder->config); return config; } int FAACAPI faacEncSetConfiguration(faacEncHandle hpEncoder, faacEncConfigurationPtr config) { faacEncStruct* hEncoder = (faacEncStruct*)hpEncoder; int i; int maxqual = hEncoder->config.outputFormat ? MAXQUALADTS : MAXQUAL; hEncoder->config.jointmode = config->jointmode; hEncoder->config.useLfe = config->useLfe; hEncoder->config.useTns = config->useTns; hEncoder->config.aacObjectType = config->aacObjectType; hEncoder->config.mpegVersion = config->mpegVersion; hEncoder->config.outputFormat = config->outputFormat; hEncoder->config.inputFormat = config->inputFormat; hEncoder->config.shortctl = config->shortctl; assert((hEncoder->config.outputFormat == 0) || (hEncoder->config.outputFormat == 1)); switch( hEncoder->config.inputFormat ) { case FAAC_INPUT_16BIT: //case FAAC_INPUT_24BIT: case FAAC_INPUT_32BIT: case FAAC_INPUT_FLOAT: break; default: return 0; break; } if (hEncoder->config.aacObjectType != LOW) return 0; #ifdef DRM config->pnslevel = 0; #endif /* Re-init TNS for new profile */ TnsInit(hEncoder); /* Check for correct bitrate */ if (!hEncoder->sampleRate || !hEncoder->numChannels) return 0; if (config->bitRate > (MaxBitrate(hEncoder->sampleRate) / hEncoder->numChannels)) config->bitRate = MaxBitrate(hEncoder->sampleRate) / hEncoder->numChannels; #if 0 if (config->bitRate < MinBitrate()) return 0; #endif if (config->bitRate && !config->bandWidth) { config->bandWidth = (double)config->bitRate * hEncoder->sampleRate * g_bw.fac / 50000.0; if (config->bandWidth > g_bw.freq) config->bandWidth = g_bw.freq; if (!config->quantqual) { config->quantqual = (double)config->bitRate * hEncoder->numChannels / 1280; if (config->quantqual > 100) config->quantqual = (config->quantqual - 100) * 3.0 + 100; } } if (!config->quantqual) config->quantqual = DEFQUAL; hEncoder->config.bitRate = config->bitRate; if (!config->bandWidth) { config->bandWidth = g_bw.fac * hEncoder->sampleRate; } hEncoder->config.bandWidth = config->bandWidth; // check bandwidth if (hEncoder->config.bandWidth < 100) hEncoder->config.bandWidth = 100; if (hEncoder->config.bandWidth > (hEncoder->sampleRate / 2)) hEncoder->config.bandWidth = hEncoder->sampleRate / 2; if (config->quantqual > maxqual) config->quantqual = maxqual; if (config->quantqual < MINQUAL) config->quantqual = MINQUAL; hEncoder->config.quantqual = config->quantqual; if (config->jointmode == JOINT_MS) config->pnslevel = 0; if (config->pnslevel < 0) config->pnslevel = 0; if (config->pnslevel > 10) config->pnslevel = 10; hEncoder->aacquantCfg.pnslevel = config->pnslevel; /* set quantization quality */ hEncoder->aacquantCfg.quality = config->quantqual; CalcBW(&hEncoder->config.bandWidth, hEncoder->sampleRate, hEncoder->srInfo, &hEncoder->aacquantCfg); // reset psymodel hEncoder->psymodel->PsyEnd(&hEncoder->gpsyInfo, hEncoder->psyInfo, hEncoder->numChannels); if (config->psymodelidx >= (sizeof(psymodellist) / sizeof(psymodellist[0]) - 1)) config->psymodelidx = (sizeof(psymodellist) / sizeof(psymodellist[0])) - 2; hEncoder->config.psymodelidx = config->psymodelidx; hEncoder->psymodel = (psymodel_t *)psymodellist[hEncoder->config.psymodelidx].ptr; hEncoder->psymodel->PsyInit(&hEncoder->gpsyInfo, hEncoder->psyInfo, hEncoder->numChannels, hEncoder->sampleRate, hEncoder->srInfo->cb_width_long, hEncoder->srInfo->num_cb_long, hEncoder->srInfo->cb_width_short, hEncoder->srInfo->num_cb_short); /* load channel_map */ for( i = 0; i < MAX_CHANNELS; i++ ) hEncoder->config.channel_map[i] = config->channel_map[i]; /* OK */ return 1; } faacEncHandle FAACAPI faacEncOpen(unsigned long sampleRate, unsigned int numChannels, unsigned long *inputSamples, unsigned long *maxOutputBytes) { unsigned int channel; faacEncStruct* hEncoder; if (numChannels > MAX_CHANNELS) return NULL; *inputSamples = FRAME_LEN*numChannels; *maxOutputBytes = ADTS_FRAMESIZE; #ifdef DRM *maxOutputBytes += 1; /* for CRC */ #endif hEncoder = (faacEncStruct*)AllocMemory(sizeof(faacEncStruct)); SetMemory(hEncoder, 0, sizeof(faacEncStruct)); hEncoder->numChannels = numChannels; hEncoder->sampleRate = sampleRate; hEncoder->sampleRateIdx = GetSRIndex(sampleRate); /* Initialize variables to default values */ hEncoder->frameNum = 0; hEncoder->flushFrame = 0; /* Default configuration */ hEncoder->config.version = FAAC_CFG_VERSION; hEncoder->config.name = libfaacName; hEncoder->config.copyright = libCopyright; hEncoder->config.mpegVersion = MPEG4; hEncoder->config.aacObjectType = LOW; hEncoder->config.jointmode = JOINT_IS; hEncoder->config.pnslevel = 4; hEncoder->config.useLfe = 1; hEncoder->config.useTns = 0; hEncoder->config.bitRate = 64000; hEncoder->config.bandWidth = g_bw.fac * hEncoder->sampleRate; hEncoder->config.quantqual = 0; hEncoder->config.psymodellist = (psymodellist_t *)psymodellist; hEncoder->config.psymodelidx = 0; hEncoder->psymodel = (psymodel_t *)hEncoder->config.psymodellist[hEncoder->config.psymodelidx].ptr; hEncoder->config.shortctl = SHORTCTL_NORMAL; /* default channel map is straight-through */ for( channel = 0; channel < MAX_CHANNELS; channel++ ) hEncoder->config.channel_map[channel] = channel; hEncoder->config.outputFormat = ADTS_STREAM; /* be compatible with software which assumes 24bit in 32bit PCM */ hEncoder->config.inputFormat = FAAC_INPUT_32BIT; /* find correct sampling rate depending parameters */ hEncoder->srInfo = &srInfo[hEncoder->sampleRateIdx]; for (channel = 0; channel < numChannels; channel++) { hEncoder->coderInfo[channel].prev_window_shape = SINE_WINDOW; hEncoder->coderInfo[channel].window_shape = SINE_WINDOW; hEncoder->coderInfo[channel].block_type = ONLY_LONG_WINDOW; hEncoder->coderInfo[channel].groups.n = 1; hEncoder->coderInfo[channel].groups.len[0] = 1; hEncoder->sampleBuff[channel] = NULL; hEncoder->nextSampleBuff[channel] = NULL; hEncoder->next2SampleBuff[channel] = NULL; } /* Initialize coder functions */ fft_initialize( &hEncoder->fft_tables ); hEncoder->psymodel->PsyInit(&hEncoder->gpsyInfo, hEncoder->psyInfo, hEncoder->numChannels, hEncoder->sampleRate, hEncoder->srInfo->cb_width_long, hEncoder->srInfo->num_cb_long, hEncoder->srInfo->cb_width_short, hEncoder->srInfo->num_cb_short); FilterBankInit(hEncoder); TnsInit(hEncoder); /* Return handle */ return hEncoder; } int FAACAPI faacEncClose(faacEncHandle hpEncoder) { faacEncStruct* hEncoder = (faacEncStruct*)hpEncoder; unsigned int channel; /* Deinitialize coder functions */ hEncoder->psymodel->PsyEnd(&hEncoder->gpsyInfo, hEncoder->psyInfo, hEncoder->numChannels); FilterBankEnd(hEncoder); fft_terminate(&hEncoder->fft_tables); /* Free remaining buffer memory */ for (channel = 0; channel < hEncoder->numChannels; channel++) { if (hEncoder->sampleBuff[channel]) FreeMemory(hEncoder->sampleBuff[channel]); if (hEncoder->nextSampleBuff[channel]) FreeMemory(hEncoder->nextSampleBuff[channel]); if (hEncoder->next2SampleBuff[channel]) FreeMemory (hEncoder->next2SampleBuff[channel]); if (hEncoder->next3SampleBuff[channel]) FreeMemory (hEncoder->next3SampleBuff[channel]); } /* Free handle */ if (hEncoder) FreeMemory(hEncoder); BlocStat(); return 0; } int FAACAPI faacEncEncode(faacEncHandle hpEncoder, int32_t *inputBuffer, unsigned int samplesInput, unsigned char *outputBuffer, unsigned int bufferSize ) { faacEncStruct* hEncoder = (faacEncStruct*)hpEncoder; unsigned int channel, i; int sb, frameBytes; unsigned int offset; BitStream *bitStream; /* bitstream used for writing the frame to */ #ifdef DRM int desbits, diff; double fix; #endif /* local copy's of parameters */ ChannelInfo *channelInfo = hEncoder->channelInfo; CoderInfo *coderInfo = hEncoder->coderInfo; unsigned int numChannels = hEncoder->numChannels; unsigned int useLfe = hEncoder->config.useLfe; unsigned int useTns = hEncoder->config.useTns; unsigned int jointmode = hEncoder->config.jointmode; unsigned int bandWidth = hEncoder->config.bandWidth; unsigned int shortctl = hEncoder->config.shortctl; int maxqual = hEncoder->config.outputFormat ? MAXQUALADTS : MAXQUAL; /* Increase frame number */ hEncoder->frameNum++; if (samplesInput == 0) hEncoder->flushFrame++; /* After 4 flush frames all samples have been encoded, return 0 bytes written */ if (hEncoder->flushFrame > 4) return 0; /* Determine the channel configuration */ GetChannelInfo(channelInfo, numChannels, useLfe); /* Update current sample buffers */ for (channel = 0; channel < numChannels; channel++) { double *tmp; if (!hEncoder->sampleBuff[channel]) hEncoder->sampleBuff[channel] = (double*)AllocMemory(FRAME_LEN*sizeof(double)); tmp = hEncoder->sampleBuff[channel]; hEncoder->sampleBuff[channel] = hEncoder->nextSampleBuff[channel]; hEncoder->nextSampleBuff[channel] = hEncoder->next2SampleBuff[channel]; hEncoder->next2SampleBuff[channel] = hEncoder->next3SampleBuff[channel]; hEncoder->next3SampleBuff[channel] = tmp; if (samplesInput == 0) { /* start flushing*/ for (i = 0; i < FRAME_LEN; i++) hEncoder->next3SampleBuff[channel][i] = 0.0; } else { int samples_per_channel = samplesInput/numChannels; /* handle the various input formats and channel remapping */ switch( hEncoder->config.inputFormat ) { case FAAC_INPUT_16BIT: { short *input_channel = (short*)inputBuffer + hEncoder->config.channel_map[channel]; for (i = 0; i < samples_per_channel; i++) { hEncoder->next3SampleBuff[channel][i] = (double)*input_channel; input_channel += numChannels; } } break; case FAAC_INPUT_32BIT: { int32_t *input_channel = (int32_t*)inputBuffer + hEncoder->config.channel_map[channel]; for (i = 0; i < samples_per_channel; i++) { hEncoder->next3SampleBuff[channel][i] = (1.0/256) * (double)*input_channel; input_channel += numChannels; } } break; case FAAC_INPUT_FLOAT: { float *input_channel = (float*)inputBuffer + hEncoder->config.channel_map[channel]; for (i = 0; i < samples_per_channel; i++) { hEncoder->next3SampleBuff[channel][i] = (double)*input_channel; input_channel += numChannels; } } break; default: return -1; /* invalid input format */ break; } for (i = (int)(samplesInput/numChannels); i < FRAME_LEN; i++) hEncoder->next3SampleBuff[channel][i] = 0.0; } /* Psychoacoustics */ /* Update buffers and run FFT on new samples */ /* LFE psychoacoustic can run without it */ if (!channelInfo[channel].lfe || channelInfo[channel].cpe) { hEncoder->psymodel->PsyBufferUpdate( &hEncoder->fft_tables, &hEncoder->gpsyInfo, &hEncoder->psyInfo[channel], hEncoder->next3SampleBuff[channel], bandWidth, hEncoder->srInfo->cb_width_short, hEncoder->srInfo->num_cb_short); } } if (hEncoder->frameNum <= 3) /* Still filling up the buffers */ return 0; /* Psychoacoustics */ hEncoder->psymodel->PsyCalculate(channelInfo, &hEncoder->gpsyInfo, hEncoder->psyInfo, hEncoder->srInfo->cb_width_long, hEncoder->srInfo->num_cb_long, hEncoder->srInfo->cb_width_short, hEncoder->srInfo->num_cb_short, numChannels, (double)hEncoder->aacquantCfg.quality / DEFQUAL); hEncoder->psymodel->BlockSwitch(coderInfo, hEncoder->psyInfo, numChannels); /* force block type */ if (shortctl == SHORTCTL_NOSHORT) { for (channel = 0; channel < numChannels; channel++) { coderInfo[channel].block_type = ONLY_LONG_WINDOW; } } else if ((hEncoder->frameNum <= 4) || (shortctl == SHORTCTL_NOLONG)) { for (channel = 0; channel < numChannels; channel++) { coderInfo[channel].block_type = ONLY_SHORT_WINDOW; } } /* AAC Filterbank, MDCT with overlap and add */ for (channel = 0; channel < numChannels; channel++) { FilterBank(hEncoder, &coderInfo[channel], hEncoder->sampleBuff[channel], hEncoder->freqBuff[channel], hEncoder->overlapBuff[channel], MOVERLAPPED); } for (channel = 0; channel < numChannels; channel++) { channelInfo[channel].msInfo.is_present = 0; if (coderInfo[channel].block_type == ONLY_SHORT_WINDOW) { coderInfo[channel].sfbn = hEncoder->aacquantCfg.max_cbs; offset = 0; for (sb = 0; sb < coderInfo[channel].sfbn; sb++) { coderInfo[channel].sfb_offset[sb] = offset; offset += hEncoder->srInfo->cb_width_short[sb]; } coderInfo[channel].sfb_offset[sb] = offset; BlocGroup(hEncoder->freqBuff[channel], coderInfo + channel, &hEncoder->aacquantCfg); } else { coderInfo[channel].sfbn = hEncoder->aacquantCfg.max_cbl; coderInfo[channel].groups.n = 1; coderInfo[channel].groups.len[0] = 1; offset = 0; for (sb = 0; sb < coderInfo[channel].sfbn; sb++) { coderInfo[channel].sfb_offset[sb] = offset; offset += hEncoder->srInfo->cb_width_long[sb]; } coderInfo[channel].sfb_offset[sb] = offset; } } /* Perform TNS analysis and filtering */ for (channel = 0; channel < numChannels; channel++) { if ((!channelInfo[channel].lfe) && (useTns)) { TnsEncode(&(coderInfo[channel].tnsInfo), coderInfo[channel].sfbn, coderInfo[channel].sfbn, coderInfo[channel].block_type, coderInfo[channel].sfb_offset, hEncoder->freqBuff[channel]); } else { coderInfo[channel].tnsInfo.tnsDataPresent = 0; /* TNS not used for LFE */ } } for (channel = 0; channel < numChannels; channel++) { // reduce LFE bandwidth if (!channelInfo[channel].cpe && channelInfo[channel].lfe) { coderInfo[channel].sfbn = 3; } } AACstereo(coderInfo, channelInfo, hEncoder->freqBuff, numChannels, (double)hEncoder->aacquantCfg.quality/DEFQUAL, jointmode); #ifdef DRM /* loop the quantization until the desired bit-rate is reached */ diff = 1; /* to enter while loop */ hEncoder->aacquantCfg.quality = 120; /* init quality setting */ while (diff > 0) { /* if too many bits, do it again */ #endif for (channel = 0; channel < numChannels; channel++) { BlocQuant(&coderInfo[channel], hEncoder->freqBuff[channel], &(hEncoder->aacquantCfg)); } #ifdef DRM /* Write the AAC bitstream */ bitStream = OpenBitStream(bufferSize, outputBuffer); WriteBitstream(hEncoder, coderInfo, channelInfo, bitStream, numChannels); /* Close the bitstream and return the number of bytes written */ frameBytes = CloseBitStream(bitStream); /* now calculate desired bits and compare with actual encoded bits */ desbits = (int) ((double) numChannels * (hEncoder->config.bitRate * FRAME_LEN) / hEncoder->sampleRate); diff = ((frameBytes - 1 /* CRC */) * 8) - desbits; /* do linear correction according to relative difference */ fix = (double) desbits / ((frameBytes - 1 /* CRC */) * 8); /* speed up convergence. A value of 0.92 gives approx up to 10 iterations */ if (fix > 0.92) fix = 0.92; hEncoder->aacquantCfg.quality *= fix; /* quality should not go lower than 1, set diff to exit loop */ if (hEncoder->aacquantCfg.quality <= 1) diff = -1; } #endif // fix max_sfb in CPE mode for (channel = 0; channel < numChannels; channel++) { if (channelInfo[channel].present && (channelInfo[channel].cpe) && (channelInfo[channel].ch_is_left)) { CoderInfo *cil, *cir; cil = &coderInfo[channel]; cir = &coderInfo[channelInfo[channel].paired_ch]; cil->sfbn = cir->sfbn = max(cil->sfbn, cir->sfbn); } } #ifndef DRM /* Write the AAC bitstream */ bitStream = OpenBitStream(bufferSize, outputBuffer); if (WriteBitstream(hEncoder, coderInfo, channelInfo, bitStream, numChannels) < 0) return -1; /* Close the bitstream and return the number of bytes written */ frameBytes = CloseBitStream(bitStream); /* Adjust quality to get correct average bitrate */ if (hEncoder->config.bitRate) { int desbits = numChannels * (hEncoder->config.bitRate * FRAME_LEN) / hEncoder->sampleRate; double fix = (double)desbits / (double)(frameBytes * 8); if (fix < 0.9) fix += 0.1; else if (fix > 1.1) fix -= 0.1; else fix = 1.0; fix = (fix - 1.0) * 0.5 + 1.0; // printf("q: %.1f(f:%.4f)\n", hEncoder->aacquantCfg.quality, fix); hEncoder->aacquantCfg.quality *= fix; if (hEncoder->aacquantCfg.quality > maxqual) hEncoder->aacquantCfg.quality = maxqual; if (hEncoder->aacquantCfg.quality < 10) hEncoder->aacquantCfg.quality = 10; } #endif return frameBytes; } #ifdef DRM /* Scalefactorband data table for 960 transform length */ /* all parameters which are different from the 1024 transform length table are marked with an "x" */ static SR_INFO srInfo[12+1] = { { 96000, 40/*x*/, 12, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0/*x*/ },{ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 28/*x*/ } }, { 88200, 40/*x*/, 12, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0/*x*/ },{ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 28/*x*/ } }, { 64000, 45/*x*/, 12, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 16/*x*/, 0/*x*/ },{ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 28/*x*/ } }, { 48000, 49, 14, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32/*x*/ }, { 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 8/*x*/ } }, { 44100, 49, 14, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32/*x*/ }, { 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 8/*x*/ } }, { 32000, 49/*x*/, 14, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 0/*x*/, 0/*x*/ },{ 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16 } }, { 24000, 46/*x*/, 15, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 0/*x*/ }, { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 12/*x*/ } }, { 22050, 46/*x*/, 15, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 0/*x*/ }, { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 12/*x*/ } }, { 16000, 42/*x*/, 15, { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 0/*x*/ }, { 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 12/*x*/ } }, { 12000, 42/*x*/, 15, { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 0/*x*/ }, { 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 12/*x*/ } }, { 11025, 42/*x*/, 15, { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 0/*x*/ }, { 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 12/*x*/ } }, { 8000, 40, 15, { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 16/*x*/ }, { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 12/*x*/ } }, { -1 } }; #else /* Scalefactorband data table for 1024 transform length */ static SR_INFO srInfo[12+1] = { { 96000, 41, 12, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },{ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36 } }, { 88200, 41, 12, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },{ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36 } }, { 64000, 47, 12, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },{ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 32 } }, { 48000, 49, 14, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 96 }, { 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16 } }, { 44100, 49, 14, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 96 }, { 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16 } }, { 32000, 51, 14, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 },{ 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16 } }, { 24000, 47, 15, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64 }, { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20 } }, { 22050, 47, 15, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64 }, { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20 } }, { 16000, 43, 15, { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64 }, { 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20 } }, { 12000, 43, 15, { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64 }, { 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20 } }, { 11025, 43, 15, { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64 }, { 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20 } }, { 8000, 40, 15, { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28, 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80 }, { 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20 } }, { -1 } }; #endif faac-1_30/libfaac/frame.h000066400000000000000000000047121355157314300152470ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef FRAME_H #define FRAME_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "coder.h" #include "channels.h" #include "blockswitch.h" #include "fft.h" #include "quantize.h" #pragma pack(push, 1) #include typedef struct { /* number of channels in AAC file */ unsigned int numChannels; /* samplerate of AAC file */ unsigned long sampleRate; unsigned int sampleRateIdx; unsigned int usedBytes; /* frame number */ unsigned int frameNum; unsigned int flushFrame; /* Scalefactorband data */ SR_INFO *srInfo; /* sample buffers of current next and next next frame*/ double *sampleBuff[MAX_CHANNELS]; double *nextSampleBuff[MAX_CHANNELS]; double *next2SampleBuff[MAX_CHANNELS]; double *next3SampleBuff[MAX_CHANNELS]; /* Filterbank buffers */ double *sin_window_long; double *sin_window_short; double *kbd_window_long; double *kbd_window_short; double *freqBuff[MAX_CHANNELS]; double *overlapBuff[MAX_CHANNELS]; double *msSpectrum[MAX_CHANNELS]; /* Channel and Coder data for all channels */ CoderInfo coderInfo[MAX_CHANNELS]; ChannelInfo channelInfo[MAX_CHANNELS]; /* Psychoacoustics data */ PsyInfo psyInfo[MAX_CHANNELS]; GlobalPsyInfo gpsyInfo; /* Configuration data */ faacEncConfiguration config; psymodel_t *psymodel; /* quantizer specific config */ AACQuantCfg aacquantCfg; /* FFT Tables */ FFT_Tables fft_tables; } faacEncStruct; #pragma pack(pop) #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* FRAME_H */ faac-1_30/libfaac/huff2.c000066400000000000000000000355321355157314300151660ustar00rootroot00000000000000/**************************************************************************** Huffman coding Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include #include #include "coder.h" #include "huffdata.h" #include "huff2.h" #include "bitstream.h" #ifdef DRM static int vcb11; #endif static int escape(int x, int *code) { int preflen = 0; int base = 32; if (x >= 8192) { fprintf(stderr, "%s(%d): x_quant >= 8192\n", __FILE__, __LINE__); return 0; } *code = 0; while (base <= x) { base <<= 1; *code <<= 1; *code |= 1; preflen++; } base >>= 1; // separator *code <<= 1; *code <<= (preflen + 4); *code |= (x - base); return (preflen << 1) + 5; } #ifdef DRM # define DRMDATA if(coder){coder->num_data_cw[coder->cur_cw++]=1;\ coder->iLenReordSpData+=blen;if(coder->iLenLongestCWiLenLongestCW=blen;} #else # define DRMDATA #endif #define arrlen(array) (sizeof(array) / sizeof(*array)) static int huffcode(int *qs /* quantized spectrum */, int len, int bnum, CoderInfo *coder) { static hcode16_t * const hmap[12] = {0, book01, book02, book03, book04, book05, book06, book07, book08, book09, book10, book11}; hcode16_t *book; int cnt; int bits = 0, blen; int ofs, *qp; int data; int idx; int datacnt; #ifdef DRM int drmbits = 0; int maxesc = 0; #endif if (coder) datacnt = coder->datacnt; else datacnt = 0; book = hmap[bnum]; switch (bnum) { #ifdef DRM case HCB_ZERO: case HCB_INTENSITY: case HCB_INTENSITY2: for(ofs = 0; ofs < len; ofs += 4) { coder->s[datacnt].data = 0; coder->s[datacnt++].len = 0; coder->num_data_cw[coder->cur_cw++] = 1; } break; #endif case 1: case 2: for(ofs = 0; ofs < len; ofs += 4) { qp = qs+ofs; idx = 27 * qp[0] + 9 * qp[1] + 3 * qp[2] + qp[3] + 40; if (idx < 0 || idx >= arrlen(book01)) { return -1; } blen = book[idx].len; if (coder) { data = book[idx].data; coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; DRMDATA; } bits += blen; } break; case 3: case 4: for(ofs = 0; ofs < len; ofs += 4) { qp = qs+ofs; idx = 27 * abs(qp[0]) + 9 * abs(qp[1]) + 3 * abs(qp[2]) + abs(qp[3]); if (idx < 0 || idx >= arrlen(book03)) { return -1; } blen = book[idx].len; if (!coder) { // add sign bits for(cnt = 0; cnt < 4; cnt++) if(qp[cnt]) blen++; } else { data = book[idx].data; // add sign bits for(cnt = 0; cnt < 4; cnt++) { if(qp[cnt]) { blen++; data <<= 1; if (qp[cnt] < 0) data |= 1; } } coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; DRMDATA; } bits += blen; } break; case 5: case 6: for(ofs = 0; ofs < len; ofs += 2) { qp = qs+ofs; idx = 9 * qp[0] + qp[1] + 40; if (idx < 0 || idx >= arrlen(book05)) { return -1; } blen = book[idx].len; if (coder) { data = book[idx].data; coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; DRMDATA; } bits += blen; } break; case 7: case 8: for(ofs = 0; ofs < len; ofs += 2) { qp = qs+ofs; idx = 8 * abs(qp[0]) + abs(qp[1]); if (idx < 0 || idx >= arrlen(book07)) { return -1; } blen = book[idx].len; if (!coder) { for(cnt = 0; cnt < 2; cnt++) if(qp[cnt]) blen++; } else { data = book[idx].data; for(cnt = 0; cnt < 2; cnt++) { if(qp[cnt]) { blen++; data <<= 1; if (qp[cnt] < 0) data |= 1; } } coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; DRMDATA; } bits += blen; } break; case 9: case 10: for(ofs = 0; ofs < len; ofs += 2) { qp = qs+ofs; idx = 13 * abs(qp[0]) + abs(qp[1]); if (idx < 0 || idx >= arrlen(book09)) { return -1; } blen = book[idx].len; if (!coder) { for(cnt = 0; cnt < 2; cnt++) if(qp[cnt]) blen++; } else { data = book[idx].data; for(cnt = 0; cnt < 2; cnt++) { if(qp[cnt]) { blen++; data <<= 1; if (qp[cnt] < 0) data |= 1; } } coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; DRMDATA; } bits += blen; } break; case HCB_ESC: for(ofs = 0; ofs < len; ofs += 2) { int x0, x1; qp = qs+ofs; x0 = abs(qp[0]); x1 = abs(qp[1]); if (x0 > 16) x0 = 16; if (x1 > 16) x1 = 16; idx = 17 * x0 + x1; if (idx < 0 || idx >= arrlen(book11)) { return -1; } blen = book[idx].len; if (!coder) { for(cnt = 0; cnt < 2; cnt++) if(qp[cnt]) blen++; } else { data = book[idx].data; for(cnt = 0; cnt < 2; cnt++) { if(qp[cnt]) { blen++; data <<= 1; if (qp[cnt] < 0) data |= 1; } } coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; #ifdef DRM coder->num_data_cw[coder->cur_cw] = 1; drmbits = blen; #endif } bits += blen; if (x0 >= 16) { blen = escape(abs(qp[0]), &data); if (coder) { coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; #ifdef DRM coder->num_data_cw[coder->cur_cw]++; drmbits += blen; if (maxesc < data) maxesc = data; #endif } bits += blen; } if (x1 >= 16) { blen = escape(abs(qp[1]), &data); if (coder) { coder->s[datacnt].data = data; coder->s[datacnt++].len = blen; #ifdef DRM coder->num_data_cw[coder->cur_cw]++; drmbits += blen; if (maxesc < data) maxesc = data; #endif } bits += blen; } #ifdef DRM coder->iLenReordSpData += drmbits; if (coder->iLenLongestCW < drmbits) coder->iLenLongestCW = drmbits; coder->cur_cw++; #endif } #ifdef DRM /* VCB11: check which codebook should be used using max escape sequence */ /* 8.5.3.1.3, table 157 */ if (maxesc <= 15) vcb11 = 16; else if (maxesc <= 31) vcb11 = 17; else if (maxesc <= 47) vcb11 = 18; else if (maxesc <= 63) vcb11 = 19; else if (maxesc <= 95) vcb11 = 20; else if (maxesc <= 127) vcb11 = 21; else if (maxesc <= 159) vcb11 = 22; else if (maxesc <= 191) vcb11 = 23; else if (maxesc <= 223) vcb11 = 24; else if (maxesc <= 255) vcb11 = 25; else if (maxesc <= 319) vcb11 = 26; else if (maxesc <= 383) vcb11 = 27; else if (maxesc <= 511) vcb11 = 28; else if (maxesc <= 767) vcb11 = 29; else if (maxesc <= 1023) vcb11 = 30; else if (maxesc <= 2047) vcb11 = 31; /* else: codebook 11 -> it is already 11 */ #endif break; default: fprintf(stderr, "%s(%d) book %d out of range\n", __FILE__, __LINE__, bnum); return -1; } if (coder) coder->datacnt = datacnt; return bits; } int huffbook(CoderInfo *coder, int *qs /* quantized spectrum */, int len) { int cnt; int maxq = 0; int bookmin, lenmin; for (cnt = 0; cnt < len; cnt++) { int q = abs(qs[cnt]); if (maxq < q) maxq = q; } #define BOOKMIN(n)bookmin=n;lenmin=huffcode(qs,len,bookmin,0);if(huffcode(qs,len,bookmin+1,0) HCB_ZERO) huffcode(qs, len, bookmin, coder); #endif coder->book[coder->bandcnt] = bookmin; return 0; } int writebooks(CoderInfo *coder, BitStream *stream, int write) { int bits = 0; int maxcnt, cntbits; int group; int bookbits = 4; #ifdef DRM bookbits = 5; /* 5 bits in case of VCB11 */ #endif if (coder->block_type == ONLY_SHORT_WINDOW){ maxcnt = 7; cntbits = 3; } else { maxcnt = 31; cntbits = 5; } for (group = 0; group < coder->groups.n; group++) { int band = group * coder->sfbn; int maxband = band + coder->sfbn; while (band < maxband) { int book = coder->book[band++]; int bookcnt = 1; if (write) { PutBit(stream, book, bookbits); } bits += bookbits; #ifdef DRM /* sect_len is not transmitted in case the codebook for a */ /* section is 11 or in the range of 16 and 31 */ if ((book == 11) || ((book >= 16) && (book <= 32))) continue; #endif if (band < maxband) { while (book == coder->book[band]) { band++; bookcnt++; if (band >= maxband) break; } } while (bookcnt >= maxcnt) { if (write) PutBit(stream, maxcnt, cntbits); bits += cntbits; bookcnt -= maxcnt; } if (write) PutBit(stream, bookcnt, cntbits); bits += cntbits; } } return bits; } int writesf(CoderInfo *coder, BitStream *stream, int write) { int cnt; int bits = 0; int diff, length; int lastsf; int lastis; int lastpns; int initpns = 1; lastsf = coder->global_gain; lastis = 0; lastpns = coder->global_gain - 90; // fixme: move range check to quantizer for (cnt = 0; cnt < coder->bandcnt; cnt++) { int book = coder->book[cnt]; if ((book == HCB_INTENSITY) || (book== HCB_INTENSITY2)) { diff = coder->sf[cnt] - lastis; if (diff > 60) diff = 60; if (diff < -60) diff = -60; length = book12[60 + diff].len; bits += length; lastis += diff; if (write) PutBit(stream, book12[60 + diff].data, length); } else if (book == HCB_PNS) { diff = coder->sf[cnt] - lastpns; if (initpns) { initpns = 0; length = 9; bits += length; lastpns += diff; if (write) PutBit(stream, diff + 256, length); continue; } if (diff > 60) diff = 60; if (diff < -60) diff = -60; length = book12[60 + diff].len; bits += length; lastpns += diff; if (write) PutBit(stream, book12[60 + diff].data, length); } else if (book) { diff = coder->sf[cnt] - lastsf; if (diff > 60) diff = 60; if (diff < -60) diff = -60; length = book12[60 + diff].len; bits += length; lastsf += diff; if (write) PutBit(stream, book12[60 + diff].data, length); } } return bits; } faac-1_30/libfaac/huff2.h000066400000000000000000000023561355157314300151710ustar00rootroot00000000000000/**************************************************************************** Huffman coding Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include "bitstream.h" enum { HCB_ZERO = 0, HCB_ESC = 11, HCB_PNS = 13, HCB_INTENSITY2 = 14, HCB_INTENSITY = 15, HCB_NONE }; int huffbook(CoderInfo *coderInfo, int *qs /* quantized spectrum */, int len); int writebooks(CoderInfo *coder, BitStream *stream, int writeFlag); int writesf(CoderInfo *coder, BitStream *bitStream, int writeFlag); faac-1_30/libfaac/huffdata.c000066400000000000000000000322401355157314300157270ustar00rootroot00000000000000/**************************************************************************** Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include "huffdata.h" hcode16_t book01[81] = { {11,2040},{9,497},{11,2045},{10,1013},{7,104},{10,1008},{11,2039},{9,492}, {11,2037},{10,1009},{7,114},{10,1012},{7,116},{5,17},{7,118},{9,491}, {7,108},{10,1014},{11,2044},{9,481},{11,2033},{9,496},{7,97},{9,502}, {11,2034},{9,490},{11,2043},{9,498},{7,105},{9,493},{7,119},{5,23}, {7,111},{9,486},{7,100},{9,485},{7,103},{5,21},{7,98},{5,18}, {1,0},{5,20},{7,101},{5,22},{7,109},{9,489},{7,99},{9,484}, {7,107},{5,19},{7,113},{9,483},{7,112},{9,499},{11,2046},{9,487}, {11,2035},{9,495},{7,96},{9,494},{11,2032},{9,482},{11,2042},{10,1011}, {7,106},{9,488},{7,117},{5,16},{7,115},{9,500},{7,110},{10,1015}, {11,2038},{9,480},{11,2041},{10,1010},{7,102},{9,501},{11,2047},{9,503}, {11,2036}, }; hcode16_t book02[81] = { {9,499},{7,111},{9,509},{8,235},{6,35},{8,234},{9,503},{8,232}, {9,506},{8,242},{6,45},{7,112},{6,32},{5,6},{6,43},{7,110}, {6,40},{8,233},{9,505},{7,102},{8,248},{8,231},{6,27},{8,241}, {9,500},{7,107},{9,501},{8,236},{6,42},{7,108},{6,44},{5,10}, {6,39},{7,103},{6,26},{8,245},{6,36},{5,8},{6,31},{5,9}, {3,0},{5,7},{6,29},{5,11},{6,48},{8,239},{6,28},{7,100}, {6,30},{5,12},{6,41},{8,243},{6,47},{8,240},{9,508},{7,113}, {9,498},{8,244},{6,33},{8,230},{8,247},{7,104},{9,504},{8,238}, {6,34},{7,101},{6,49},{4,2},{6,38},{8,237},{6,37},{7,106}, {9,507},{7,114},{9,510},{7,105},{6,46},{8,246},{9,511},{7,109}, {9,502}, }; hcode16_t book03[81] = { {1,0},{4,9},{8,239},{4,11},{5,25},{8,240},{9,491},{9,486}, {10,1010},{4,10},{6,53},{9,495},{6,52},{6,55},{9,489},{9,493}, {9,487},{10,1011},{9,494},{10,1005},{13,8186},{9,492},{9,498},{11,2041}, {11,2040},{10,1016},{12,4088},{4,8},{6,56},{10,1014},{6,54},{7,117}, {10,1009},{10,1003},{10,1004},{12,4084},{5,24},{7,118},{11,2036},{6,57}, {7,116},{10,1007},{9,499},{9,500},{11,2038},{9,488},{10,1002},{13,8188}, {8,242},{9,497},{12,4091},{10,1013},{11,2035},{12,4092},{8,238},{10,1015}, {15,32766},{9,496},{11,2037},{15,32765},{13,8187},{14,16378},{16,65535},{8,241}, {10,1008},{14,16380},{9,490},{10,1006},{14,16379},{12,4086},{12,4090},{15,32764}, {11,2034},{12,4085},{16,65534},{10,1012},{11,2039},{15,32763},{12,4087},{12,4089}, {15,32762}, }; hcode16_t book04[81] = { {4,7},{5,22},{8,246},{5,24},{4,8},{8,239},{9,495},{8,243}, {11,2040},{5,25},{5,23},{8,237},{5,21},{4,1},{8,226},{8,240}, {7,112},{10,1008},{9,494},{8,241},{11,2042},{8,238},{8,228},{10,1010}, {11,2038},{10,1007},{11,2045},{4,5},{5,20},{8,242},{4,9},{4,4}, {8,229},{8,244},{8,232},{10,1012},{4,6},{4,2},{8,231},{4,3}, {4,0},{7,107},{8,227},{7,105},{9,499},{8,235},{8,230},{10,1014}, {7,110},{7,106},{9,500},{10,1004},{9,496},{10,1017},{8,245},{8,236}, {11,2043},{8,234},{7,111},{10,1015},{11,2041},{10,1011},{12,4095},{8,233}, {7,109},{10,1016},{7,108},{7,104},{9,501},{10,1006},{9,498},{11,2036}, {11,2039},{10,1009},{12,4094},{10,1005},{9,497},{11,2037},{11,2046},{10,1013}, {11,2044}, }; hcode16_t book05[81] = { {13,8191},{12,4087},{11,2036},{11,2024},{10,1009},{11,2030},{11,2041},{12,4088}, {13,8189},{12,4093},{11,2033},{10,1000},{9,488},{8,240},{9,492},{10,1006}, {11,2034},{12,4090},{12,4084},{10,1007},{9,498},{8,232},{7,112},{8,236}, {9,496},{10,1002},{11,2035},{11,2027},{9,491},{8,234},{5,26},{4,8}, {5,25},{8,238},{9,495},{11,2029},{10,1008},{8,242},{7,115},{4,11}, {1,0},{4,10},{7,113},{8,243},{11,2025},{11,2031},{9,494},{8,239}, {5,24},{4,9},{5,27},{8,235},{9,489},{11,2028},{11,2038},{10,1003}, {9,499},{8,237},{7,114},{8,233},{9,497},{10,1005},{11,2039},{12,4086}, {11,2032},{10,1001},{9,493},{8,241},{9,490},{10,1004},{11,2040},{12,4089}, {13,8188},{12,4092},{12,4085},{11,2026},{10,1011},{10,1010},{11,2037},{12,4091}, {13,8190}, }; hcode16_t book06[81] = { {11,2046},{10,1021},{9,497},{9,491},{9,500},{9,490},{9,496},{10,1020}, {11,2045},{10,1014},{9,485},{8,234},{7,108},{7,113},{7,104},{8,240}, {9,486},{10,1015},{9,499},{8,239},{6,50},{6,39},{6,40},{6,38}, {6,49},{8,235},{9,503},{9,488},{7,111},{6,46},{4,8},{4,4}, {4,6},{6,41},{7,107},{9,494},{9,495},{7,114},{6,45},{4,2}, {4,0},{4,3},{6,47},{7,115},{9,506},{9,487},{7,110},{6,43}, {4,7},{4,1},{4,5},{6,44},{7,109},{9,492},{9,505},{8,238}, {6,48},{6,36},{6,42},{6,37},{6,51},{8,236},{9,498},{10,1016}, {9,484},{8,237},{7,106},{7,112},{7,105},{7,116},{8,241},{10,1018}, {11,2047},{10,1017},{9,502},{9,493},{9,504},{9,489},{9,501},{10,1019}, {11,2044}, }; hcode16_t book07[64] = { {1,0},{3,5},{6,55},{7,116},{8,242},{9,491},{10,1005},{11,2039}, {3,4},{4,12},{6,53},{7,113},{8,236},{8,238},{9,494},{9,501}, {6,54},{6,52},{7,114},{8,234},{8,241},{9,489},{9,499},{10,1013}, {7,115},{7,112},{8,235},{8,240},{9,497},{9,496},{10,1004},{10,1018}, {8,243},{8,237},{9,488},{9,495},{10,1007},{10,1009},{10,1017},{11,2043}, {9,493},{8,239},{9,490},{9,498},{10,1011},{10,1016},{11,2041},{11,2044}, {10,1006},{9,492},{9,500},{10,1012},{10,1015},{11,2040},{12,4093},{12,4094}, {11,2038},{10,1008},{10,1010},{10,1014},{11,2042},{11,2045},{12,4092},{12,4095}, }; hcode16_t book08[64] = { {5,14},{4,5},{5,16},{6,48},{7,111},{8,241},{9,506},{10,1022}, {4,3},{3,0},{4,4},{5,18},{6,44},{7,106},{7,117},{8,248}, {5,15},{4,2},{4,6},{5,20},{6,46},{7,105},{7,114},{8,245}, {6,47},{5,17},{5,19},{6,42},{6,50},{7,108},{8,236},{8,250}, {7,113},{6,43},{6,45},{6,49},{7,109},{7,112},{8,242},{9,505}, {8,239},{7,104},{6,51},{7,107},{7,110},{8,238},{8,249},{10,1020}, {9,504},{7,116},{7,115},{8,237},{8,240},{8,246},{9,502},{9,509}, {10,1021},{8,243},{8,244},{8,247},{9,503},{9,507},{9,508},{10,1023}, }; hcode16_t book09[169] = { {1,0},{3,5},{6,55},{8,231},{9,478},{10,974},{10,985},{11,1992}, {11,1997},{12,4040},{12,4061},{13,8164},{13,8172},{3,4},{4,12},{6,53}, {7,114},{8,234},{8,237},{9,482},{10,977},{10,979},{10,992},{11,2008}, {12,4047},{12,4053},{6,54},{6,52},{7,113},{8,232},{8,236},{9,481}, {10,975},{10,989},{10,987},{11,2000},{12,4039},{12,4052},{12,4068},{8,230}, {7,112},{8,233},{9,477},{9,483},{10,978},{10,988},{11,1996},{11,1994}, {11,2014},{12,4056},{12,4074},{13,8155},{9,479},{8,235},{9,476},{9,486}, {10,981},{10,990},{11,1995},{11,2013},{11,2012},{12,4045},{12,4066},{12,4071}, {13,8161},{10,976},{9,480},{9,484},{10,982},{11,1989},{11,2001},{11,2011}, {12,4050},{11,2016},{12,4057},{12,4075},{13,8163},{13,8169},{11,1988},{9,485}, {10,983},{11,1990},{11,1999},{11,2010},{12,4043},{12,4058},{12,4067},{12,4073}, {13,8166},{13,8179},{13,8183},{11,2003},{10,984},{10,993},{11,2004},{11,2009}, {12,4051},{12,4062},{13,8157},{13,8153},{13,8162},{13,8170},{13,8177},{13,8182}, {11,2002},{10,980},{10,986},{11,1991},{11,2007},{11,2018},{12,4046},{12,4059}, {13,8152},{13,8174},{14,16368},{13,8180},{14,16370},{11,2017},{10,991},{11,1993}, {11,2006},{12,4042},{12,4048},{12,4069},{12,4070},{13,8171},{13,8175},{14,16371}, {14,16372},{14,16373},{12,4064},{11,1998},{11,2005},{12,4038},{12,4049},{12,4065}, {13,8160},{13,8168},{13,8176},{14,16369},{14,16376},{14,16374},{15,32764},{12,4072}, {11,2015},{12,4041},{12,4055},{12,4060},{13,8156},{13,8159},{13,8173},{13,8181}, {14,16377},{14,16379},{15,32765},{15,32766},{13,8167},{12,4044},{12,4054},{12,4063}, {13,8158},{13,8154},{13,8165},{13,8178},{14,16378},{14,16375},{14,16380},{14,16381}, {15,32767}, }; hcode16_t book10[169] = { {6,34},{5,8},{6,29},{6,38},{7,95},{8,211},{9,463},{10,976}, {10,983},{10,1005},{11,2032},{11,2038},{12,4093},{5,7},{4,0},{4,1}, {5,9},{6,32},{7,84},{7,96},{8,213},{8,220},{9,468},{10,973}, {10,990},{11,2023},{6,28},{4,2},{5,6},{5,12},{6,30},{6,40}, {7,91},{8,205},{8,217},{9,462},{9,476},{10,985},{10,1009},{6,37}, {5,11},{5,10},{5,13},{6,36},{7,87},{7,97},{8,204},{8,221}, {9,460},{9,478},{10,979},{10,999},{7,93},{6,33},{6,31},{6,35}, {6,39},{7,89},{7,100},{8,216},{8,223},{9,466},{9,482},{10,989}, {10,1006},{8,209},{7,85},{6,41},{7,86},{7,88},{7,98},{8,206}, {8,224},{8,226},{9,474},{10,980},{10,995},{11,2027},{9,457},{7,94}, {7,90},{7,92},{7,99},{8,202},{8,218},{9,455},{9,458},{9,480}, {10,987},{10,1000},{11,2028},{9,483},{8,210},{8,203},{8,208},{8,215}, {8,219},{9,454},{9,469},{9,472},{10,970},{10,986},{11,2026},{11,2033}, {9,481},{8,212},{8,207},{8,214},{8,222},{8,225},{9,464},{9,470}, {10,977},{10,981},{10,1010},{11,2030},{11,2043},{10,1001},{9,461},{9,456}, {9,459},{9,465},{9,471},{9,479},{10,975},{10,992},{10,1007},{11,2022}, {11,2040},{12,4090},{10,1003},{9,477},{9,467},{9,473},{9,475},{10,978}, {10,972},{10,988},{10,1002},{11,2029},{11,2035},{11,2041},{12,4089},{11,2034}, {10,974},{9,484},{10,971},{10,984},{10,982},{10,994},{10,997},{11,2024}, {11,2036},{11,2037},{11,2039},{12,4091},{11,2042},{10,1004},{10,991},{10,993}, {10,996},{10,998},{10,1008},{11,2025},{11,2031},{12,4088},{12,4094},{12,4092}, {12,4095}, }; hcode16_t book11[289] = { {4,0},{5,6},{6,25},{7,61},{8,156},{8,198},{9,423},{10,912}, {10,962},{10,991},{11,2022},{11,2035},{12,4091},{11,2028},{12,4090},{12,4094}, {10,910},{5,5},{4,1},{5,8},{6,20},{7,55},{7,66},{8,146}, {8,175},{9,401},{9,421},{9,437},{10,926},{10,960},{10,930},{10,973}, {11,2006},{8,174},{6,23},{5,7},{5,9},{6,24},{7,57},{7,64}, {8,142},{8,163},{8,184},{9,409},{9,428},{9,449},{10,945},{10,918}, {10,958},{10,970},{8,157},{7,60},{6,21},{6,22},{6,26},{7,59}, {7,68},{8,145},{8,165},{8,190},{9,406},{9,430},{9,441},{10,929}, {10,913},{10,933},{10,981},{8,148},{8,154},{7,54},{7,56},{7,58}, {7,65},{8,140},{8,155},{8,176},{8,195},{9,414},{9,427},{9,444}, {10,927},{10,911},{10,937},{10,975},{8,147},{8,191},{7,62},{7,63}, {7,67},{7,69},{8,158},{8,167},{8,185},{9,404},{9,418},{9,442}, {9,451},{10,934},{10,935},{10,955},{10,980},{8,159},{9,416},{8,143}, {8,141},{8,144},{8,152},{8,166},{8,182},{8,196},{9,415},{9,431}, {9,447},{10,921},{10,959},{10,948},{10,969},{10,999},{8,168},{9,438}, {8,171},{8,164},{8,170},{8,178},{8,194},{8,197},{9,408},{9,420}, {9,440},{10,908},{10,932},{10,964},{10,966},{10,989},{10,1000},{8,173}, {10,943},{9,402},{8,189},{8,188},{9,398},{9,407},{9,410},{9,419}, {9,433},{10,909},{10,920},{10,951},{10,979},{10,977},{10,987},{11,2013}, {8,180},{10,990},{9,425},{9,411},{9,412},{9,417},{9,426},{9,429}, {9,435},{10,907},{10,946},{10,952},{10,974},{10,993},{10,992},{11,2002}, {11,2021},{8,183},{11,2019},{9,443},{9,424},{9,422},{9,432},{9,434}, {9,439},{10,923},{10,922},{10,954},{10,949},{10,982},{11,2007},{10,996}, {11,2008},{11,2026},{8,186},{11,2024},{10,928},{9,445},{9,436},{10,906}, {9,452},{10,914},{10,938},{10,944},{10,956},{10,983},{11,2004},{11,2012}, {11,2011},{11,2005},{11,2032},{8,193},{11,2043},{10,968},{10,931},{10,917}, {10,925},{10,940},{10,942},{10,965},{10,984},{10,994},{10,998},{11,2020}, {11,2023},{11,2016},{11,2025},{11,2039},{9,400},{11,2034},{10,915},{9,446}, {9,448},{10,916},{10,919},{10,941},{10,963},{10,961},{10,978},{11,2010}, {11,2009},{11,2015},{11,2027},{11,2036},{11,2042},{9,405},{11,2040},{10,957}, {10,924},{10,939},{10,936},{10,947},{10,953},{10,976},{10,995},{10,997}, {11,2018},{11,2014},{11,2029},{11,2033},{11,2041},{11,2044},{9,403},{12,4093}, {10,988},{10,950},{10,967},{10,972},{10,971},{10,985},{10,986},{11,2003}, {11,2017},{11,2030},{11,2031},{11,2037},{11,2038},{12,4092},{12,4095},{9,413}, {9,450},{8,181},{8,161},{8,150},{8,151},{8,149},{8,153},{8,160}, {8,162},{8,172},{8,169},{8,177},{8,179},{8,187},{8,192},{9,399}, {5,4}, }; hcode32_t book12[121] = { {18,262120},{18,262118},{18,262119},{18,262117},{19,524277},{19,524273},{19,524269},{19,524278}, {19,524270},{19,524271},{19,524272},{19,524284},{19,524285},{19,524287},{19,524286},{19,524279}, {19,524280},{19,524283},{19,524281},{18,262116},{19,524282},{18,262115},{17,131055},{17,131056}, {16,65525},{17,131054},{16,65522},{16,65523},{16,65524},{16,65521},{15,32758},{15,32759}, {14,16377},{14,16373},{14,16375},{14,16371},{14,16374},{14,16370},{13,8183},{13,8181}, {12,4089},{12,4087},{12,4086},{11,2041},{12,4084},{11,2040},{10,1017},{10,1015}, {10,1013},{9,504},{9,503},{8,250},{8,248},{8,246},{7,121},{6,58}, {6,56},{5,26},{4,11},{3,4},{1,0},{4,10},{4,12},{5,27}, {6,57},{6,59},{7,120},{7,122},{8,247},{8,249},{9,502},{9,505}, {10,1012},{10,1014},{10,1016},{11,2037},{11,2036},{11,2038},{11,2039},{12,4085}, {12,4088},{13,8180},{13,8182},{13,8184},{14,16376},{14,16372},{16,65520},{15,32756}, {16,65526},{15,32757},{18,262114},{19,524249},{19,524250},{19,524251},{19,524252},{19,524253}, {19,524254},{19,524248},{19,524242},{19,524243},{19,524244},{19,524245},{19,524246},{19,524274}, {19,524255},{19,524263},{19,524264},{19,524265},{19,524266},{19,524267},{19,524262},{19,524256}, {19,524257},{19,524258},{19,524259},{19,524260},{19,524261},{19,524247},{19,524268},{19,524276}, {19,524275}, }; faac-1_30/libfaac/huffdata.h000066400000000000000000000025471355157314300157430ustar00rootroot00000000000000/**************************************************************************** Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include typedef struct { const uint16_t len; const uint16_t data; } hcode16_t; typedef struct { const uint32_t len; const uint32_t data; } hcode32_t; extern hcode16_t book01[81]; extern hcode16_t book02[81]; extern hcode16_t book03[81]; extern hcode16_t book04[81]; extern hcode16_t book05[81]; extern hcode16_t book06[81]; extern hcode16_t book07[64]; extern hcode16_t book08[64]; extern hcode16_t book09[169]; extern hcode16_t book10[169]; extern hcode16_t book11[289]; extern hcode32_t book12[121]; faac-1_30/libfaac/kiss_fft/000077500000000000000000000000001355157314300156105ustar00rootroot00000000000000faac-1_30/libfaac/kiss_fft/CHANGELOG000066400000000000000000000041771355157314300170330ustar00rootroot000000000000001.2.1 (April 4, 2004) compiles cleanly with just about every -W warning flag under the sun reorganized kiss_fft_state so it could be read-only/const. This may be useful for embedded systems that are willing to predeclare twiddle factors, factorization. Fixed C_MUL,S_MUL on 16-bit platforms. tmpbuf will only be allocated if input & output buffers are same scratchbuf will only be allocated for ffts that are not multiples of 2,3,5 NOTE: The tmpbuf,scratchbuf changes may require synchronization code for multi-threaded apps. 1.2 (Feb 23, 2004) interface change -- cfg object is forward declaration of struct instead of void* This maintains type saftey and lets the compiler warn/error about stupid mistakes. (prompted by suggestion from Erik de Castro Lopo) small speed improvements added psdpng.c -- sample utility that will create png spectrum "waterfalls" from an input file ( not terribly useful yet) 1.1.1 (Feb 1, 2004 ) minor bug fix -- only affects odd rank, in-place, multi-dimensional FFTs 1.1 : (Jan 30,2004) split sample_code/ into test/ and tools/ Removed 2-D fft and added N-D fft (arbitrary) modified fftutil.c to allow multi-d FFTs Modified core fft routine to allow an input stride via kiss_fft_stride() (eased support of multi-D ffts) Added fast convolution filtering (FIR filtering using overlap-scrap method, with tail scrap) Add kfc.[ch]: the KISS FFT Cache. It takes care of allocs for you ( suggested by Oscar Lesta ). 1.0.1 (Dec 15, 2003) fixed bug that occurred when nfft==1 1.0 : (Dec 14, 2003) changed kiss_fft function from using a single buffer, to two buffers. If the same buffer pointer is supplied for both in and out, kiss will manage the buffer copies. added kiss_fft2d and kiss_fftr as separate source files (declarations in kiss_fft.h ) 0.4 :(Nov 4,2003) optimized for radix 2,3,4,5 0.3 :(Oct 28, 2003) woops, version 2 didn't actually factor out any radices other than 2 0.2 :(Oct 27, 2003) added mixed radix, only radix 2,4 optimized versions 0.1 :(May 19 2003) initial release, radix 2 only faac-1_30/libfaac/kiss_fft/COPYING000066400000000000000000000027031355157314300166450ustar00rootroot00000000000000Copyright (c) 2003-2004 Mark Borgerding All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. faac-1_30/libfaac/kiss_fft/README000066400000000000000000000103541355157314300164730ustar00rootroot00000000000000KISS FFT - A mixed-radix Fast Fourier Transform based up on the principle, "Keep It Simple, Stupid." There are many great fft libraries already around. Kiss FFT is not trying to be better than any of them. It only attempts to be a reasonably efficient, moderately useful FFT that can use fixed or floating data types and can be incorporated into someone's C program in a few minutes with trivial licensing. USAGE: The basic usage for 1-d complex FFT is: #include "kiss_fft.h" kiss_fft_cfg cfg = kiss_fft_alloc( nfft ,inverse_fft ); while ... ... // put kth sample in cx_in[k].r and cx_in[k].i kiss_fft( cfg , cx_in , cx_out ); ... // transformed. DC is in cx_out[0].r and cx_out[0].i free(cfg); Note: frequency-domain data is stored from dc up to 2pi. so cx_out[0] is the dc bin of the FFT and cx_out[nfft/2] is the Nyquist bin (if exists) Declarations are in "kiss_fft.h", along with a brief description of the functions you'll need to use. Code definitions for 1d complex FFTs are in kiss_fft.c. You can do other cool stuff with the extras you'll find in tools/ * arbitrary dimension complex FFTs * 1-d real FFTs * fast convolution FIR filtering * spectrum image creation The core fft and most tools/ code can be compiled to use float, double or Q15 short samples. The default is float. BACKGROUND: I started coding this because I couldn't find a fixed point FFT that didn't use assembly code. I started with floating point numbers so I could get the theory straight before working on fixed point issues. In the end, I had a little bit of code that could be recompiled easily to do ffts with short, float or double (other types should be easy too). Once I got my FFT working, I was curious about the speed compared to a well respected and highly optimized fft library. I don't want to criticize this great library, so let's call it FFT_BRANDX. During this process, I learned: 1. FFT_BRANDX has more than 100K lines of code. The core of kiss_fft is about 500 lines (cpx 1-d). 2. It took me an embarrassingly long time to get FFT_BRANDX working. 3. A simple program using FFT_BRANDX is 522KB. A similar program using kiss_fft is 18KB. 4. FFT_BRANDX is roughly twice as fast as KISS FFT. It is wonderful that free, highly optimized libraries like FFT_BRANDX exist. But such libraries carry a huge burden of complexity necessary to extract every last bit of performance. Sometimes simpler is better, even if it's not better. PERFORMANCE: (on Athlon XP 2100+, with gcc 2.96, float data type) Kiss performed 10000 1024-pt cpx ffts in .63 s of cpu time. For comparison, it took md5sum twice as long to process the same amount of data. Transforming 5 minutes of CD quality audio takes less than a second (nfft=1024). DO NOT: ... use Kiss if you need the Fastest Fourier Transform in the World ... ask me to add features that will bloat the code UNDER THE HOOD: Kiss FFT uses a time decimation, mixed-radix, out-of-place FFT. No scaling is done. Optimized butterflies are used for factors 2,3,4, and 5. The real optimization code only works for even length ffts. It does two half-length FFTs in parallel (packed into real&imag), and then combines them via twiddling. The fast convolution filtering uses the overlap-scrap method, slightly modified to put the scrap at the tail. LICENSE: BSD, see COPYING for details. Basically, "free to use&change, give credit where due, no guarantees" TODO: *) Add real optimization for odd length FFTs (DST?) *) Add real optimization to the n-dimensional FFT *) Add simple windowing function, e.g. Hamming : w(i)=.54-.46*cos(2pi*i/(n-1)) *) Make the fixed point scaling and bit shifts more easily configurable. *) Document/revisit the input/output fft scaling *) See if the fixed point code can be optimized a little without adding complexity. *) Make doc describing the overlap (tail) scrap fast convolution filtering in kiss_fastfir.c *) Test all the ./tools/ code with fixed point (kiss_fastfir.c doesn't work, maybe others) AUTHOR: Mark Borgerding Mark@Borgerding.net faac-1_30/libfaac/kiss_fft/README.kiss_fft000066400000000000000000000002151355157314300202750ustar00rootroot00000000000000See README and COPYING files for author and copyright information. kiss_fft.c is modified in order to eliminate static variables. -- sur. faac-1_30/libfaac/kiss_fft/TIPS000066400000000000000000000021471355157314300163160ustar00rootroot00000000000000Speed: * experiment with compiler flags Special thanks to Oscar Lesta. He suggested some compiler flags for gcc that make a big difference. They shave 10-15% off execution time on some systems. Try some combination of: -march=pentiumpro -ffast-math -fomit-frame-pointer * If the input data has no imaginary component, use the kiss_fftr code under tools/. Real ffts are roughly twice as fast as complex. Reducing code size: * remove some of the butterflies. There are currently butterflies optimized for radices 2,3,4,5. It is worth mentioning that you can still use FFT sizes that contain these factors, they just won't be quite as fast. You can decide for yourself whether to keep radix 2 or 4. If you do some work in this area, let me know what you find. * For platforms where ROM/code space is more plentiful than RAM, consider creating a hardcoded kiss_fft_state. In other words, decide which FFT size(s) you want and make a structure with the correct factors and twiddles. faac-1_30/libfaac/kiss_fft/_kiss_fft_guts.h000066400000000000000000000073241355157314300210000ustar00rootroot00000000000000/* Copyright (c) 2003-2004, Mark Borgerding All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* kiss_fft.h defines kiss_fft_scalar as either short or a float type and defines typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ #include "kiss_fft.h" #define MAXFACTORS 32 /* e.g. an fft of length 128 has 4 factors as far as kissfft is concerned 4*4*4*2 */ struct kiss_fft_state{ int nfft; int inverse; int factors[2*MAXFACTORS]; kiss_fft_cpx twiddles[1]; }; /* Explanation of macros dealing with complex math: C_MUL(m,a,b) : m = a*b C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise C_SUB( res, a,b) : res = a - b C_SUBFROM( res , a) : res -= a C_ADDTO( res , a) : res += a * */ #ifdef FIXED_POINT # define smul(a,b) ( (long)(a)*(b) ) # define sround( x ) (short)( ( (x) + (1<<14) ) >>15 ) # define S_MUL(a,b) sround( smul(a,b) ) # define C_MUL(m,a,b) \ do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) # define C_FIXDIV(c,div) \ do{ (c).r /= div; (c).i /=div; }while(0) # define C_MULBYSCALAR( c, s ) \ do{ (c).r = sround( smul( (c).r , s ) ) ;\ (c).i = sround( smul( (c).i , s ) ) ; }while(0) #else /* not FIXED_POINT*/ # define S_MUL(a,b) ( (a)*(b) ) #define C_MUL(m,a,b) \ do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) # define C_FIXDIV(c,div) /* NOOP */ # define C_MULBYSCALAR( c, s ) \ do{ (c).r *= (s);\ (c).i *= (s); }while(0) #endif #define C_ADD( res, a,b)\ do { (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; }while(0) #define C_SUB( res, a,b)\ do { (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; }while(0) #define C_ADDTO( res , a)\ do { (res).r += (a).r; (res).i += (a).i; }while(0) #define C_SUBFROM( res , a)\ do { (res).r -= (a).r; (res).i -= (a).i; }while(0) static void kf_cexp(kiss_fft_cpx * x,double phase) /* returns e ** (j*phase) */ { #ifdef FIXED_POINT x->r = (kiss_fft_scalar) (32767 * cos (phase)); x->i = (kiss_fft_scalar) (32767 * sin (phase)); #else x->r = cos (phase); x->i = sin (phase); #endif } /* a debugging function */ #define pcpx(c)\ fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) faac-1_30/libfaac/kiss_fft/kiss_fft.c000066400000000000000000000256051355157314300175740ustar00rootroot00000000000000/* Copyright (c) 2003-2004, Mark Borgerding All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "_kiss_fft_guts.h" /* The guts header contains all the multiplication and addition macros that are defined for fixed or floating point complex numbers. It also delares the kf_ internal functions. */ static void kf_bfly2( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, int m ) { kiss_fft_cpx * Fout2; kiss_fft_cpx * tw1 = st->twiddles; kiss_fft_cpx t; Fout2 = Fout + m; do{ C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); C_MUL (t, *Fout2 , *tw1); tw1 += fstride; C_SUB( *Fout2 , *Fout , t ); C_ADDTO( *Fout , t ); ++Fout2; ++Fout; }while (--m); } static void kf_bfly4( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, const size_t m ) { kiss_fft_cpx *tw1,*tw2,*tw3; kiss_fft_cpx scratch[6]; size_t k=m; const size_t m2=2*m; const size_t m3=3*m; tw3 = tw2 = tw1 = st->twiddles; do { C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4); C_MUL(scratch[0],Fout[m] , *tw1 ); C_MUL(scratch[1],Fout[m2] , *tw2 ); C_MUL(scratch[2],Fout[m3] , *tw3 ); C_SUB( scratch[5] , *Fout, scratch[1] ); C_ADDTO(*Fout, scratch[1]); C_ADD( scratch[3] , scratch[0] , scratch[2] ); C_SUB( scratch[4] , scratch[0] , scratch[2] ); C_SUB( Fout[m2], *Fout, scratch[3] ); tw1 += fstride; tw2 += fstride*2; tw3 += fstride*3; C_ADDTO( *Fout , scratch[3] ); if(st->inverse) { Fout[m].r = scratch[5].r - scratch[4].i; Fout[m].i = scratch[5].i + scratch[4].r; Fout[m3].r = scratch[5].r + scratch[4].i; Fout[m3].i = scratch[5].i - scratch[4].r; }else{ Fout[m].r = scratch[5].r + scratch[4].i; Fout[m].i = scratch[5].i - scratch[4].r; Fout[m3].r = scratch[5].r - scratch[4].i; Fout[m3].i = scratch[5].i + scratch[4].r; } ++Fout; }while(--k); } static void kf_bfly3( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, size_t m ) { size_t k=m; const size_t m2 = 2*m; kiss_fft_cpx *tw1,*tw2; kiss_fft_cpx scratch[5]; kiss_fft_cpx epi3; epi3 = st->twiddles[fstride*m]; tw1=tw2=st->twiddles; do{ C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); C_MUL(scratch[1],Fout[m] , *tw1); C_MUL(scratch[2],Fout[m2] , *tw2); C_ADD(scratch[3],scratch[1],scratch[2]); C_SUB(scratch[0],scratch[1],scratch[2]); tw1 += fstride; tw2 += fstride*2; Fout[m].r = Fout->r - scratch[3].r/2; Fout[m].i = Fout->i - scratch[3].i/2; C_MULBYSCALAR( scratch[0] , epi3.i ); C_ADDTO(*Fout,scratch[3]); Fout[m2].r = Fout[m].r + scratch[0].i; Fout[m2].i = Fout[m].i - scratch[0].r; Fout[m].r -= scratch[0].i; Fout[m].i += scratch[0].r; ++Fout; }while(--k); } static void kf_bfly5( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, int m ) { kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; int u; kiss_fft_cpx scratch[13]; kiss_fft_cpx * twiddles = st->twiddles; kiss_fft_cpx *tw; kiss_fft_cpx ya,yb; ya = twiddles[fstride*m]; yb = twiddles[fstride*2*m]; Fout0=Fout; Fout1=Fout0+m; Fout2=Fout0+2*m; Fout3=Fout0+3*m; Fout4=Fout0+4*m; tw=st->twiddles; for ( u=0; ur += scratch[7].r + scratch[8].r; Fout0->i += scratch[7].i + scratch[8].i; scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); C_SUB(*Fout1,scratch[5],scratch[6]); C_ADD(*Fout4,scratch[5],scratch[6]); scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); C_ADD(*Fout2,scratch[11],scratch[12]); C_SUB(*Fout3,scratch[11],scratch[12]); ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; } } /* perform the butterfly for one stage of a mixed radix FFT */ static void kf_bfly_generic( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, int m, int p ) { int u,k,q1,q; kiss_fft_cpx * twiddles = st->twiddles; kiss_fft_cpx t; int Norig = st->nfft; kiss_fft_cpx *scratchbuf=(kiss_fft_cpx *)malloc( sizeof(kiss_fft_cpx) * p ); for ( u=0; u=Norig) twidx-=Norig; C_MUL(t,scratchbuf[q] , twiddles[twidx] ); C_ADDTO( Fout[ k ] ,t); } k += m; } } free( scratchbuf ); } static void kf_work( kiss_fft_cpx * Fout, const kiss_fft_cpx * f, const size_t fstride, int in_stride, int * factors, const kiss_fft_cfg st ) { kiss_fft_cpx * Fout_beg=Fout; const int p=*factors++; /* the radix */ const int m=*factors++; /* stage's fft length/p */ const kiss_fft_cpx * Fout_end = Fout + p*m; if (m==1) { do{ *Fout = *f; f += fstride*in_stride; }while(++Fout != Fout_end ); }else{ do{ kf_work( Fout , f, fstride*p, in_stride, factors,st); f += fstride*in_stride; }while( (Fout += m) != Fout_end ); } Fout=Fout_beg; switch (p) { case 2: kf_bfly2(Fout,fstride,st,m); break; case 3: kf_bfly3(Fout,fstride,st,m); break; case 4: kf_bfly4(Fout,fstride,st,m); break; case 5: kf_bfly5(Fout,fstride,st,m); break; default: kf_bfly_generic(Fout,fstride,st,m,p); break; } } /* facbuf is populated by p1,m1,p2,m2, ... where p[i] * m[i] = m[i-1] m0 = n */ static void kf_factor(int n,int * facbuf) { int p=4; double floor_sqrt; floor_sqrt = floor( sqrt((double)n) ); /*factor out powers of 4, powers of 2, then any remaining primes */ do { while (n % p) { switch (p) { case 4: p = 2; break; case 2: p = 3; break; default: p += 2; break; } if (p > floor_sqrt) p = n; /* no more factors, skip to end */ } n /= p; *facbuf++ = p; *facbuf++ = n; } while (n > 1); } /* * * User-callable function to allocate all necessary storage space for the fft. * * The return value is a contiguous block of memory, allocated with malloc. As such, * It can be freed with free(), rather than a kiss_fft-specific function. * */ kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) { kiss_fft_cfg st=NULL; size_t memneeded = sizeof(struct kiss_fft_state) + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ if ( lenmem==NULL ) { st = ( kiss_fft_cfg)malloc( memneeded ); }else{ if (*lenmem >= memneeded) st = (kiss_fft_cfg)mem; *lenmem = memneeded; } if (st) { int i; const double pi=3.14159265358979323846264338327; const double phase0 = -2.0 * pi / (double)( nfft ); st->nfft=nfft; st->inverse = inverse_fft; for (i=0;iinverse) phase *= -1; kf_cexp(st->twiddles+i, phase ); } kf_factor(nfft,st->factors); } return st; } void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) { if (fin == fout) { kiss_fft_cpx *tmpbuf=(kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx) * st->nfft ); kf_work(tmpbuf,fin,1,in_stride, st->factors,st); memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); free( tmpbuf ); }else{ kf_work( fout, fin, 1,in_stride, st->factors,st ); } } void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) { kiss_fft_stride(cfg,fin,fout,1); } faac-1_30/libfaac/kiss_fft/kiss_fft.h000066400000000000000000000044021355157314300175710ustar00rootroot00000000000000#ifndef KISS_FFT_H #define KISS_FFT_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* ATTENTION! If you would like a : -- a utility that will handle the caching of fft objects -- real-only FFT -- a multi-dimensional FFT -- a command-line utility to perform ffts -- a command-line utility to perform fast-convolution filtering then see tools/ */ #ifdef FIXED_POINT # define kiss_fft_scalar short #else # ifndef kiss_fft_scalar /* default is float */ # define kiss_fft_scalar float # endif #endif typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; typedef struct kiss_fft_state* kiss_fft_cfg; /* * kiss_fft_alloc * * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. * * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); * * The return value from fft_alloc is a cfg buffer used internally * by the fft routine or NULL. * * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. * The returned value should be free()d when done to avoid memory leaks. * * The state can be placed in a user supplied buffer 'mem': * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, * then the function places the cfg in mem and the size used in *lenmem * and returns mem. * * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), * then the function returns NULL and places the minimum cfg * buffer size in *lenmem. * */ kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); /* * kiss_fft(cfg,in_out_buf) * * Perform an FFT on a complex input buffer. * for a forward FFT, * fin should be f[0] , f[1] , ... ,f[nfft-1] * fout will be F[0] , F[1] , ... ,F[nfft-1] * Note that each element is complex and can be accessed like f[k].r and f[k].i * */ void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); /* If kiss_fft_alloc allocated a buffer, it is one contiguous buffer and can be simply free()d when no longer needed*/ #define kiss_fft_free free #ifdef __cplusplus } #endif #endif faac-1_30/libfaac/kiss_fft/kiss_fftr.c000066400000000000000000000116151355157314300177520ustar00rootroot00000000000000/* Copyright (c) 2003-2004, Mark Borgerding All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "kiss_fftr.h" #include "_kiss_fft_guts.h" struct kiss_fftr_state{ kiss_fft_cfg substate; kiss_fft_cpx * tmpbuf; kiss_fft_cpx * super_twiddles; }; kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem) { int i; kiss_fftr_cfg st = NULL; size_t subsize, memneeded; if (nfft & 1) { fprintf(stderr,"Real FFT optimization must be even.\n"); return NULL; } nfft >>= 1; kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize); memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 2); if (lenmem == NULL) { st = (kiss_fftr_cfg) malloc (memneeded); } else { if (*lenmem >= memneeded) st = (kiss_fftr_cfg) mem; *lenmem = memneeded; } if (!st) return NULL; st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */ st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize); st->super_twiddles = st->tmpbuf + nfft; kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize); for (i = 0; i < nfft; ++i) { double phase = -3.14159265358979323846264338327 * ((double) i / nfft + .5); if (inverse_fft) phase *= -1; kf_cexp (st->super_twiddles+i,phase); } return st; } void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata) { /* input buffer timedata is stored row-wise */ int k,N; if ( st->substate->inverse) { fprintf(stderr,"kiss fft usage error: improper alloc\n"); exit(1); } N = st->substate->nfft; /*perform the parallel fft of two real signals packed in real,imag*/ kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf ); freqdata[0].r = st->tmpbuf[0].r + st->tmpbuf[0].i; freqdata[0].i = 0; C_FIXDIV(freqdata[0],2); for (k=1;k <= N/2 ; ++k ) { kiss_fft_cpx fpnk,fpk,f1k,f2k,tw; fpk = st->tmpbuf[k]; fpnk.r = st->tmpbuf[N-k].r; fpnk.i = -st->tmpbuf[N-k].i; C_FIXDIV(fpk,2); C_FIXDIV(fpnk,2); C_ADD( f1k, fpk , fpnk ); C_SUB( f2k, fpk , fpnk ); C_MUL( tw , f2k , st->super_twiddles[k]); C_ADD( freqdata[k] , f1k ,tw); freqdata[k].r = (f1k.r + tw.r) / 2; freqdata[k].i = (f1k.i + tw.i) / 2; freqdata[N-k].r = (f1k.r - tw.r)/2; freqdata[N-k].i = - (f1k.i - tw.i)/2; } freqdata[N].r = st->tmpbuf[0].r - st->tmpbuf[0].i; freqdata[N].i = 0; C_FIXDIV(freqdata[N],2); } void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata) { /* input buffer timedata is stored row-wise */ int k, N; if (st->substate->inverse == 0) { fprintf (stderr, "kiss fft usage error: improper alloc\n"); exit (1); } N = st->substate->nfft; st->tmpbuf[0].r = freqdata[0].r + freqdata[N].r; st->tmpbuf[0].i = freqdata[0].r - freqdata[N].r; for (k = 1; k <= N / 2; ++k) { kiss_fft_cpx fk, fnkc, fek, fok, tmpbuf; fk = freqdata[k]; fnkc.r = freqdata[N - k].r; fnkc.i = -freqdata[N - k].i; C_ADD (fek, fk, fnkc); C_SUB (tmpbuf, fk, fnkc); C_MUL (fok, tmpbuf, st->super_twiddles[k]); C_ADD (st->tmpbuf[k], fek, fok); C_SUB (st->tmpbuf[N - k], fek, fok); st->tmpbuf[N - k].i *= -1; } kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata); } faac-1_30/libfaac/kiss_fft/kiss_fftr.h000066400000000000000000000015321355157314300177540ustar00rootroot00000000000000#ifndef KISS_FTR_H #define KISS_FTR_H #include "kiss_fft.h" #ifdef __cplusplus extern "C" { #endif /* Real optimized version can save about 45% cpu time vs. complex fft of a real seq. */ typedef struct kiss_fftr_state *kiss_fftr_cfg; kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); /* nfft must be even If you don't care to allocate space, use mem = lenmem = NULL */ void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); /* input timedata has nfft scalar points output freqdata has nfft/2+1 complex points */ void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); /* input freqdata has nfft/2+1 complex points output timedata has nfft scalar points */ #define kiss_fftr_free free #ifdef __cplusplus } #endif #endif faac-1_30/libfaac/quantize.c000066400000000000000000000304111355157314300160030ustar00rootroot00000000000000/**************************************************************************** Quantizer core functions quality setting, error distribution, etc. Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include #include #include "quantize.h" #include "huff2.h" #ifdef HAVE_IMMINTRIN_H # include #endif #ifdef __SSE2__ # ifdef __GNUC__ # include # endif #endif #ifdef _MSC_VER # include # include # define __SSE2__ # define bit_SSE2 (1 << 26) #endif #ifdef __GNUC__ #define GCC_VERSION (__GNUC__ * 10000 \ + __GNUC_MINOR__ * 100 \ + __GNUC_PATCHLEVEL__) #endif #define MAGIC_NUMBER 0.4054 #define NOISEFLOOR 0.4 // band sound masking static void bmask(CoderInfo *coderInfo, double *xr0, double *bandqual, int gnum, double quality) { int sfb, start, end, cnt; int *cb_offset = coderInfo->sfb_offset; int last; double avgenrg; double powm = 0.4; double totenrg = 0.0; int gsize = coderInfo->groups.len[gnum]; double *xr; int win; int enrgcnt = 0; for (sfb = 0; sfb < coderInfo->sfbn; sfb++) { start = coderInfo->sfb_offset[sfb]; end = coderInfo->sfb_offset[sfb + 1]; xr = xr0; for (win = 0; win < gsize; win++) { for (cnt = start; cnt < end; cnt++) { totenrg += xr[cnt] * xr[cnt]; enrgcnt++; } xr += BLOCK_LEN_SHORT; } } if (totenrg < ((NOISEFLOOR * NOISEFLOOR) * (double)enrgcnt)) { for (sfb = 0; sfb < coderInfo->sfbn; sfb++) bandqual[sfb] = 0.0; return; } for (sfb = 0; sfb < coderInfo->sfbn; sfb++) { double avge, maxe; double target; start = cb_offset[sfb]; end = cb_offset[sfb + 1]; avge = 0.0; maxe = 0.0; xr = xr0; for (win = 0; win < gsize; win++) { for (cnt = start; cnt < end; cnt++) { double e = xr[cnt]*xr[cnt]; avge += e; if (maxe < e) maxe = e; } xr += BLOCK_LEN_SHORT; } maxe *= gsize; #define NOISETONE 0.2 if (coderInfo->block_type == ONLY_SHORT_WINDOW) { last = BLOCK_LEN_SHORT; avgenrg = totenrg / last; avgenrg *= end - start; target = NOISETONE * pow(avge/avgenrg, powm); target += (1.0 - NOISETONE) * 0.45 * pow(maxe/avgenrg, powm); target *= 1.5; } else { last = BLOCK_LEN_LONG; avgenrg = totenrg / last; avgenrg *= end - start; target = NOISETONE * pow(avge/avgenrg, powm); target += (1.0 - NOISETONE) * 0.45 * pow(maxe/avgenrg, powm); } target *= 10.0 / (1.0 + ((double)(start+end)/last)); bandqual[sfb] = target * quality; } } enum {MAXSHORTBAND = 36}; // use band quality levels to quantize a group of windows static void qlevel(CoderInfo *coderInfo, const double *xr0, const double *bandqual, int gnum, int pnslevel ) { int sb, cnt; #if !defined(__clang__) && defined(__GNUC__) && (GCC_VERSION >= 40600) /* 2^0.25 (1.50515 dB) step from AAC specs */ static const double sfstep = 1.0 / log10(sqrt(sqrt(2.0))); #else static const double sfstep = 20 / 1.50515; #endif int gsize = coderInfo->groups.len[gnum]; double pnsthr = 0.1 * pnslevel; #ifdef __SSE2__ int cpuid[4]; int sse2 = 0; cpuid[3] = 0; # ifdef __GNUC__ __cpuid(1, cpuid[0], cpuid[1], cpuid[2], cpuid[3]); # endif # ifdef _MSC_VER __cpuid(cpuid, 1); # endif if (cpuid[3] & bit_SSE2) sse2 = 1; #endif for (sb = 0; sb < coderInfo->sfbn; sb++) { double sfacfix; int sfac; double rmsx; double etot; int xitab[8 * MAXSHORTBAND]; int *xi; int start, end; const double *xr; int win; if (coderInfo->book[coderInfo->bandcnt] != HCB_NONE) { coderInfo->bandcnt++; continue; } start = coderInfo->sfb_offset[sb]; end = coderInfo->sfb_offset[sb+1]; etot = 0.0; xr = xr0; for (win = 0; win < gsize; win++) { for (cnt = start; cnt < end; cnt++) { double e = xr[cnt] * xr[cnt]; etot += e; } xr += BLOCK_LEN_SHORT; } etot /= (double)gsize; rmsx = sqrt(etot / (end - start)); if ((rmsx < NOISEFLOOR) || (!bandqual[sb])) { coderInfo->book[coderInfo->bandcnt++] = HCB_ZERO; continue; } #ifndef DRM if (bandqual[sb] < pnsthr) { coderInfo->book[coderInfo->bandcnt] = HCB_PNS; coderInfo->sf[coderInfo->bandcnt] += lrint(log10(etot) * (0.5 * sfstep)); coderInfo->bandcnt++; continue; } #endif sfac = lrint(log10(bandqual[sb] / rmsx) * sfstep); if ((SF_OFFSET - sfac) < 10) sfacfix = 0.0; else sfacfix = pow(10, sfac / sfstep); xr = xr0 + start; end -= start; xi = xitab; for (win = 0; win < gsize; win++) { #ifdef __SSE2__ if (sse2) { for (cnt = 0; cnt < end; cnt += 4) { __m128 x = {xr[cnt], xr[cnt + 1], xr[cnt + 2], xr[cnt + 3]}; x = _mm_max_ps(x, _mm_sub_ps((__m128){0, 0, 0, 0}, x)); x = _mm_mul_ps(x, (__m128){sfacfix, sfacfix, sfacfix, sfacfix}); x = _mm_mul_ps(x, _mm_sqrt_ps(x)); x = _mm_sqrt_ps(x); x = _mm_add_ps(x, (__m128){MAGIC_NUMBER, MAGIC_NUMBER, MAGIC_NUMBER, MAGIC_NUMBER}); *(__m128i*)(xi + cnt) = _mm_cvttps_epi32(x); } for (cnt = 0; cnt < end; cnt++) { if (xr[cnt] < 0) xi[cnt] = -xi[cnt]; } xi += cnt; xr += BLOCK_LEN_SHORT; continue; } #endif for (cnt = 0; cnt < end; cnt++) { double tmp = fabs(xr[cnt]); tmp *= sfacfix; tmp = sqrt(tmp * sqrt(tmp)); xi[cnt] = (int)(tmp + MAGIC_NUMBER); if (xr[cnt] < 0) xi[cnt] = -xi[cnt]; } xi += cnt; xr += BLOCK_LEN_SHORT; } huffbook(coderInfo, xitab, gsize * end); coderInfo->sf[coderInfo->bandcnt++] += SF_OFFSET - sfac; } } int BlocQuant(CoderInfo *coder, double *xr, AACQuantCfg *aacquantCfg) { double bandlvl[MAX_SCFAC_BANDS]; int cnt; double *gxr; coder->global_gain = 0; coder->bandcnt = 0; coder->datacnt = 0; #ifdef DRM coder->iLenReordSpData = 0; /* init length of reordered spectral data */ coder->iLenLongestCW = 0; /* init length of longest codeword */ coder->cur_cw = 0; /* init codeword counter */ #endif { int lastis; int lastsf; gxr = xr; for (cnt = 0; cnt < coder->groups.n; cnt++) { bmask(coder, gxr, bandlvl, cnt, (double)aacquantCfg->quality/DEFQUAL); qlevel(coder, gxr, bandlvl, cnt, aacquantCfg->pnslevel); gxr += coder->groups.len[cnt] * BLOCK_LEN_SHORT; } coder->global_gain = 0; for (cnt = 0; cnt < coder->bandcnt; cnt++) { int book = coder->book[cnt]; if (!book) continue; if ((book != HCB_INTENSITY) && (book != HCB_INTENSITY2)) { coder->global_gain = coder->sf[cnt]; break; } } lastsf = coder->global_gain; lastis = 0; // fixme: move SF range check to quantizer for (cnt = 0; cnt < coder->bandcnt; cnt++) { int book = coder->book[cnt]; if ((book == HCB_INTENSITY) || (book == HCB_INTENSITY2)) { int diff = coder->sf[cnt] - lastis; if (diff < -60) diff = -60; if (diff > 60) diff = 60; lastis += diff; coder->sf[cnt] = lastis; } else if (book == HCB_ESC) { int diff = coder->sf[cnt] - lastsf; if (diff < -60) diff = -60; if (diff > 60) diff = 60; lastsf += diff; coder->sf[cnt] = lastsf; } } return 1; } return 0; } void CalcBW(unsigned *bw, int rate, SR_INFO *sr, AACQuantCfg *aacquantCfg) { // find max short frame band int max = *bw * (BLOCK_LEN_SHORT << 1) / rate; int cnt; int l; l = 0; for (cnt = 0; cnt < sr->num_cb_short; cnt++) { if (l >= max) break; l += sr->cb_width_short[cnt]; } aacquantCfg->max_cbs = cnt; if (aacquantCfg->pnslevel) *bw = (double)l * rate / (BLOCK_LEN_SHORT << 1); // find max long frame band max = *bw * (BLOCK_LEN_LONG << 1) / rate; l = 0; for (cnt = 0; cnt < sr->num_cb_long; cnt++) { if (l >= max) break; l += sr->cb_width_long[cnt]; } aacquantCfg->max_cbl = cnt; aacquantCfg->max_l = l; *bw = (double)l * rate / (BLOCK_LEN_LONG << 1); } enum {MINSFB = 2}; static void calce(double *xr, int *bands, double e[NSFB_SHORT], int maxsfb, int maxl) { int sfb; int l; // mute lines above cutoff freq for (l = maxl; l < bands[maxsfb]; l++) xr[l] = 0.0; for (sfb = MINSFB; sfb < maxsfb; sfb++) { e[sfb] = 0; for (l = bands[sfb]; l < bands[sfb + 1]; l++) e[sfb] += xr[l] * xr[l]; } } static void resete(double min[NSFB_SHORT], double max[NSFB_SHORT], double e[NSFB_SHORT], int maxsfb) { int sfb; for (sfb = MINSFB; sfb < maxsfb; sfb++) min[sfb] = max[sfb] = e[sfb]; } #define PRINTSTAT 0 #if PRINTSTAT static int groups = 0; static int frames = 0; #endif void BlocGroup(double *xr, CoderInfo *coderInfo, AACQuantCfg *cfg) { int win, sfb; double e[NSFB_SHORT]; double min[NSFB_SHORT]; double max[NSFB_SHORT]; const double thr = 3.0; int win0; int fastmin; int maxsfb, maxl; if (coderInfo->block_type != ONLY_SHORT_WINDOW) { coderInfo->groups.n = 1; coderInfo->groups.len[0] = 1; return; } maxl = cfg->max_l / 8; maxsfb = cfg->max_cbs; fastmin = ((maxsfb - MINSFB) * 3) >> 2; #ifdef DRM coderInfo->groups.n = 1; coderInfo->groups.len[0] = 8; return; #endif #if PRINTSTAT frames++; #endif calce(xr, coderInfo->sfb_offset, e, maxsfb, maxl); resete(min, max, e, maxsfb); win0 = 0; coderInfo->groups.n = 0; for (win = 1; win < MAX_SHORT_WINDOWS; win++) { int fast = 0; calce(xr + win * BLOCK_LEN_SHORT, coderInfo->sfb_offset, e, maxsfb, maxl); for (sfb = MINSFB; sfb < maxsfb; sfb++) { if (min[sfb] > e[sfb]) min[sfb] = e[sfb]; if (max[sfb] < e[sfb]) max[sfb] = e[sfb]; if (max[sfb] > thr * min[sfb]) fast++; } if (fast > fastmin) { coderInfo->groups.len[coderInfo->groups.n++] = win - win0; win0 = win; resete(min, max, e, maxsfb); } } coderInfo->groups.len[coderInfo->groups.n++] = win - win0; #if PRINTSTAT groups += coderInfo->groups.n; #endif } void BlocStat(void) { #if PRINTSTAT printf("frames:%d; groups:%d; g/f:%f\n", frames, groups, (double)groups/frames); #endif } faac-1_30/libfaac/quantize.h000066400000000000000000000027051355157314300160150ustar00rootroot00000000000000/**************************************************************************** Quantizer core functions quality setting, error distribution, etc. Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #ifndef QUANTIZE_H #define QUANTIZE_H #include "coder.h" typedef struct { double quality; int max_cbl; int max_cbs; int max_l; int pnslevel; } AACQuantCfg; enum { DEFQUAL = 100, MAXQUAL = 5000, MAXQUALADTS = MAXQUAL, MINQUAL = 10, SF_OFFSET = 100, }; int BlocQuant(CoderInfo *coderInfo, double *xr, AACQuantCfg *aacquantCfg); void CalcBW(unsigned *bw, int rate, SR_INFO *sr, AACQuantCfg *aacquantCfg); void BlocGroup(double *xr, CoderInfo *coderInfo, AACQuantCfg *aacquantCfg); void BlocStat(void); #endif faac-1_30/libfaac/stereo.c000066400000000000000000000235331355157314300154530ustar00rootroot00000000000000/**************************************************************************** Intensity Stereo Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include #include "stereo.h" #include "huff2.h" static void stereo(CoderInfo *cl, CoderInfo *cr, double *sl0, double *sr0, int *sfcnt, int wstart, int wend, double phthr ) { int sfb; int win; int sfmin; if (!phthr) return; phthr = 1.0 / phthr; if (cl->block_type == ONLY_SHORT_WINDOW) sfmin = 1; else sfmin = 8; (*sfcnt) += sfmin; for (sfb = sfmin; sfb < cl->sfbn; sfb++) { int l, start, end; double sum, diff; double enrgs, enrgd, enrgl, enrgr; int hcb = HCB_NONE; const double step = 10/1.50515; double ethr; double vfix, efix; start = cl->sfb_offset[sfb]; end = cl->sfb_offset[sfb + 1]; enrgs = enrgd = enrgl = enrgr = 0.0; for (win = wstart; win < wend; win++) { double *sl = sl0 + win * BLOCK_LEN_SHORT; double *sr = sr0 + win * BLOCK_LEN_SHORT; for (l = start; l < end; l++) { double lx = sl[l]; double rx = sr[l]; sum = lx + rx; diff = lx - rx; enrgs += sum * sum; enrgd += diff * diff; enrgl += lx * lx; enrgr += rx * rx; } } ethr = sqrt(enrgl) + sqrt(enrgr); ethr *= ethr; ethr *= phthr; efix = enrgl + enrgr; if (enrgs >= ethr) { hcb = HCB_INTENSITY; vfix = sqrt(efix / enrgs); } else if (enrgd >= ethr) { hcb = HCB_INTENSITY2; vfix = sqrt(efix / enrgd); } if (hcb != HCB_NONE) { int sf = lrint(log10(enrgl / efix) * step); int pan = lrint(log10(enrgr/efix) * step) - sf; if (pan > 30) { cl->book[*sfcnt] = HCB_ZERO; (*sfcnt)++; continue; } if (pan < -30) { cr->book[*sfcnt] = HCB_ZERO; (*sfcnt)++; continue; } cl->sf[*sfcnt] = sf; cr->sf[*sfcnt] = -pan; cr->book[*sfcnt] = hcb; for (win = wstart; win < wend; win++) { double *sl = sl0 + win * BLOCK_LEN_SHORT; double *sr = sr0 + win * BLOCK_LEN_SHORT; for (l = start; l < end; l++) { if (hcb == HCB_INTENSITY) sum = sl[l] + sr[l]; else sum = sl[l] - sr[l]; sl[l] = sum * vfix; } } } (*sfcnt)++; } } static void midside(CoderInfo *coder, ChannelInfo *channel, double *sl0, double *sr0, int *sfcnt, int wstart, int wend, double thrmid, double thrside ) { int sfb; int win; int sfmin; if (coder->block_type == ONLY_SHORT_WINDOW) sfmin = 1; else sfmin = 8; for (sfb = 0; sfb < sfmin; sfb++) { channel->msInfo.ms_used[*sfcnt] = 0; (*sfcnt)++; } for (sfb = sfmin; sfb < coder->sfbn; sfb++) { int ms = 0; int l, start, end; double sum, diff; double enrgs, enrgd, enrgl, enrgr; start = coder->sfb_offset[sfb]; end = coder->sfb_offset[sfb + 1]; enrgs = enrgd = enrgl = enrgr = 0.0; for (win = wstart; win < wend; win++) { double *sl = sl0 + win * BLOCK_LEN_SHORT; double *sr = sr0 + win * BLOCK_LEN_SHORT; for (l = start; l < end; l++) { double lx = sl[l]; double rx = sr[l]; sum = 0.5 * (lx + rx); diff = 0.5 * (lx - rx); enrgs += sum * sum; enrgd += diff * diff; enrgl += lx * lx; enrgr += rx * rx; } } if ((min(enrgl, enrgr) * thrmid) >= max(enrgs, enrgd)) { enum {PH_NONE, PH_IN, PH_OUT}; int phase = PH_NONE; if ((enrgs * thrmid * 2.0) >= (enrgl + enrgr)) { ms = 1; phase = PH_IN; } else if ((enrgd * thrmid * 2.0) >= (enrgl + enrgr)) { ms = 1; phase = PH_OUT; } if (ms) { for (win = wstart; win < wend; win++) { double *sl = sl0 + win * BLOCK_LEN_SHORT; double *sr = sr0 + win * BLOCK_LEN_SHORT; for (l = start; l < end; l++) { if (phase == PH_IN) { sum = sl[l] + sr[l]; diff = 0; } else { sum = 0; diff = sl[l] - sr[l]; } sl[l] = 0.5 * sum; sr[l] = 0.5 * diff; } } } } if (min(enrgl, enrgr) <= (thrside * max(enrgl, enrgr))) { for (win = wstart; win < wend; win++) { double *sl = sl0 + win * BLOCK_LEN_SHORT; double *sr = sr0 + win * BLOCK_LEN_SHORT; for (l = start; l < end; l++) { if (enrgl < enrgr) sl[l] = 0.0; else sr[l] = 0.0; } } } channel->msInfo.ms_used[*sfcnt] = ms; (*sfcnt)++; } } void AACstereo(CoderInfo *coder, ChannelInfo *channel, double *s[MAX_CHANNELS], int maxchan, double quality, int mode ) { int chn; static const double thr075 = 1.09 /* ~0.75dB */ - 1.0; static const double thrmax = 1.25 /* ~2dB */ - 1.0; static const double sidemin = 0.1; /* -20dB */ static const double sidemax = 0.3; /* ~-10.5dB */ static const double isthrmax = M_SQRT2 - 1.0; double thrmid, thrside; double isthr; thrmid = 1.0; thrside = 0.0; isthr = 1.0; switch (mode) { case JOINT_MS: thrmid = thr075 / quality; if (thrmid > thrmax) thrmid = thrmax; thrside = sidemin / quality; if (thrside > sidemax) thrside = sidemax; thrmid += 1.0; break; case JOINT_IS: isthr = 0.18 / (quality * quality); if (isthr > isthrmax) isthr = isthrmax; isthr += 1.0; break; } // convert into energy thrmid *= thrmid; thrside *= thrside; isthr *= isthr; for (chn = 0; chn < maxchan; chn++) { int group; int bookcnt = 0; CoderInfo *cp = coder + chn; if (!channel[chn].present) continue; for (group = 0; group < cp->groups.n; group++) { int band; for (band = 0; band < cp->sfbn; band++) { cp->book[bookcnt] = HCB_NONE; cp->sf[bookcnt] = 0; bookcnt++; } } } for (chn = 0; chn < maxchan; chn++) { int rch; int cnt; int group; int sfcnt = 0; int start = 0; if (!channel[chn].present) continue; if (!((channel[chn].cpe) && (channel[chn].ch_is_left))) continue; rch = channel[chn].paired_ch; channel[chn].common_window = 0; channel[chn].msInfo.is_present = 0; channel[rch].msInfo.is_present = 0; if (coder[chn].block_type != coder[rch].block_type) continue; if (coder[chn].groups.n != coder[rch].groups.n) continue; channel[chn].common_window = 1; for (cnt = 0; cnt < coder[chn].groups.n; cnt++) if (coder[chn].groups.len[cnt] != coder[rch].groups.len[cnt]) { channel[chn].common_window = 0; goto skip; } if (mode == JOINT_MS) { channel[chn].common_window = 1; channel[chn].msInfo.is_present = 1; channel[rch].msInfo.is_present = 1; } for (group = 0; group < coder->groups.n; group++) { int end = start + coder->groups.len[group]; switch(mode) { case JOINT_MS: midside(coder + chn, channel + chn, s[chn], s[rch], &sfcnt, start, end, thrmid, thrside); break; case JOINT_IS: stereo(coder + chn, coder + rch, s[chn], s[rch], &sfcnt, start, end, isthr); break; } start = end; } skip:; } } faac-1_30/libfaac/stereo.h000066400000000000000000000021431355157314300154520ustar00rootroot00000000000000/**************************************************************************** Intensity Stereo Copyright (C) 2017 Krzysztof Nikiel 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 3 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, see . ****************************************************************************/ #include "channels.h" #include "util.h" void AACstereo(CoderInfo *coder, ChannelInfo *channel, double *s[MAX_CHANNELS], int maxchan, double quality, int mode ); faac-1_30/libfaac/tns.c000066400000000000000000000531041355157314300147530ustar00rootroot00000000000000/********************************************************************** This software module was originally developed by Texas Instruments and edited by in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products. The original developer retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1997. **********************************************************************/ /* * $Id: tns.c,v 1.11 2012/03/01 18:34:17 knik Exp $ */ #include #include "frame.h" #include "coder.h" #include "bitstream.h" #include "tns.h" #include "util.h" /***********************************************/ /* TNS Profile/Frequency Dependent Parameters */ /***********************************************/ /* Limit bands to > 2.0 kHz */ static unsigned short tnsMinBandNumberLong[12] = { 11, 12, 15, 16, 17, 20, 25, 26, 24, 28, 30, 31 }; static unsigned short tnsMinBandNumberShort[12] = { 2, 2, 2, 3, 3, 4, 6, 6, 8, 10, 10, 12 }; /**************************************/ /* Main/Low Profile TNS Parameters */ /**************************************/ static unsigned short tnsMaxBandsLongMainLow[12] = { 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39 }; static unsigned short tnsMaxBandsShortMainLow[12] = { 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14 }; static unsigned short tnsMaxOrderLongMain = 20; static unsigned short tnsMaxOrderLongLow = 12; static unsigned short tnsMaxOrderShortMainLow = 7; /*************************/ /* Function prototypes */ /*************************/ static void Autocorrelation(int maxOrder, /* Maximum autocorr order */ int dataSize, /* Size of the data array */ double* data, /* Data array */ double* rArray); /* Autocorrelation array */ static double LevinsonDurbin(int maxOrder, /* Maximum filter order */ int dataSize, /* Size of the data array */ double* data, /* Data array */ double* kArray); /* Reflection coeff array */ static void StepUp(int fOrder, double* kArray, double* aArray); static void QuantizeReflectionCoeffs(int fOrder,int coeffRes,double* rArray,int* indexArray); static int TruncateCoeffs(int fOrder,double threshold,double* kArray); static void TnsFilter(int length,double* spec,TnsFilterData* filter); static void TnsInvFilter(int length,double* spec,TnsFilterData* filter); /*****************************************************/ /* InitTns: */ /*****************************************************/ void TnsInit(faacEncStruct* hEncoder) { unsigned int channel; int fsIndex = hEncoder->sampleRateIdx; int profile = hEncoder->config.aacObjectType; for (channel = 0; channel < hEncoder->numChannels; channel++) { TnsInfo *tnsInfo = &hEncoder->coderInfo[channel].tnsInfo; switch( profile ) { case MAIN: case LTP: tnsInfo->tnsMaxBandsLong = tnsMaxBandsLongMainLow[fsIndex]; tnsInfo->tnsMaxBandsShort = tnsMaxBandsShortMainLow[fsIndex]; if (hEncoder->config.mpegVersion == 1) { /* MPEG2 */ tnsInfo->tnsMaxOrderLong = tnsMaxOrderLongMain; } else { /* MPEG4 */ if (fsIndex <= 5) /* fs > 32000Hz */ tnsInfo->tnsMaxOrderLong = 12; else tnsInfo->tnsMaxOrderLong = 20; } tnsInfo->tnsMaxOrderShort = tnsMaxOrderShortMainLow; break; case LOW : tnsInfo->tnsMaxBandsLong = tnsMaxBandsLongMainLow[fsIndex]; tnsInfo->tnsMaxBandsShort = tnsMaxBandsShortMainLow[fsIndex]; if (hEncoder->config.mpegVersion == 1) { /* MPEG2 */ tnsInfo->tnsMaxOrderLong = tnsMaxOrderLongLow; } else { /* MPEG4 */ if (fsIndex <= 5) /* fs > 32000Hz */ tnsInfo->tnsMaxOrderLong = 12; else tnsInfo->tnsMaxOrderLong = 20; } tnsInfo->tnsMaxOrderShort = tnsMaxOrderShortMainLow; break; } tnsInfo->tnsMinBandNumberLong = tnsMinBandNumberLong[fsIndex]; tnsInfo->tnsMinBandNumberShort = tnsMinBandNumberShort[fsIndex]; } } /*****************************************************/ /* TnsEncode: */ /*****************************************************/ void TnsEncode(TnsInfo* tnsInfo, /* TNS info */ int numberOfBands, /* Number of bands per window */ int maxSfb, /* max_sfb */ enum WINDOW_TYPE blockType, /* block type */ int* sfbOffsetTable, /* Scalefactor band offset table */ double* spec) /* Spectral data array */ { int numberOfWindows,windowSize; int startBand,stopBand,order; /* Bands over which to apply TNS */ int lengthInBands; /* Length to filter, in bands */ int w; int startIndex,length; double gain; switch( blockType ) { case ONLY_SHORT_WINDOW : /* TNS not used for short blocks currently */ tnsInfo->tnsDataPresent = 0; return; numberOfWindows = MAX_SHORT_WINDOWS; windowSize = BLOCK_LEN_SHORT; startBand = tnsInfo->tnsMinBandNumberShort; stopBand = numberOfBands; lengthInBands = stopBand-startBand; order = tnsInfo->tnsMaxOrderShort; startBand = min(startBand,tnsInfo->tnsMaxBandsShort); stopBand = min(stopBand,tnsInfo->tnsMaxBandsShort); break; default: numberOfWindows = 1; windowSize = BLOCK_LEN_SHORT; startBand = tnsInfo->tnsMinBandNumberLong; stopBand = numberOfBands; lengthInBands = stopBand - startBand; order = tnsInfo->tnsMaxOrderLong; startBand = min(startBand,tnsInfo->tnsMaxBandsLong); stopBand = min(stopBand,tnsInfo->tnsMaxBandsLong); break; } /* Make sure that start and stop bands < maxSfb */ /* Make sure that start and stop bands >= 0 */ startBand = min(startBand,maxSfb); stopBand = min(stopBand,maxSfb); startBand = max(startBand,0); stopBand = max(stopBand,0); tnsInfo->tnsDataPresent = 0; /* default TNS not used */ /* Perform analysis and filtering for each window */ for (w=0;wwindowData[w]; TnsFilterData* tnsFilter = windowData->tnsFilter; double* k = tnsFilter->kCoeffs; /* reflection coeffs */ double* a = tnsFilter->aCoeffs; /* prediction coeffs */ windowData->numFilters=0; windowData->coefResolution = DEF_TNS_COEFF_RES; startIndex = w * windowSize + sfbOffsetTable[startBand]; length = sfbOffsetTable[stopBand] - sfbOffsetTable[startBand]; gain = LevinsonDurbin(order,length,&spec[startIndex],k); if (gain>DEF_TNS_GAIN_THRESH) { /* Use TNS */ int truncatedOrder; windowData->numFilters++; tnsInfo->tnsDataPresent=1; tnsFilter->direction = 0; tnsFilter->coefCompress = 0; tnsFilter->length = lengthInBands; QuantizeReflectionCoeffs(order,DEF_TNS_COEFF_RES,k,tnsFilter->index); truncatedOrder = TruncateCoeffs(order,DEF_TNS_COEFF_THRESH,k); tnsFilter->order = truncatedOrder; StepUp(truncatedOrder,k,a); /* Compute predictor coefficients */ TnsInvFilter(length,&spec[startIndex],tnsFilter); /* Filter */ } } } /*****************************************************/ /* TnsEncodeFilterOnly: */ /* This is a stripped-down version of TnsEncode() */ /* which performs TNS analysis filtering only */ /*****************************************************/ void TnsEncodeFilterOnly(TnsInfo* tnsInfo, /* TNS info */ int numberOfBands, /* Number of bands per window */ int maxSfb, /* max_sfb */ enum WINDOW_TYPE blockType, /* block type */ int* sfbOffsetTable, /* Scalefactor band offset table */ double* spec) /* Spectral data array */ { int numberOfWindows,windowSize; int startBand,stopBand; /* Bands over which to apply TNS */ int w; int startIndex,length; switch( blockType ) { case ONLY_SHORT_WINDOW : numberOfWindows = MAX_SHORT_WINDOWS; windowSize = BLOCK_LEN_SHORT; startBand = tnsInfo->tnsMinBandNumberShort; stopBand = numberOfBands; startBand = min(startBand,tnsInfo->tnsMaxBandsShort); stopBand = min(stopBand,tnsInfo->tnsMaxBandsShort); break; default: numberOfWindows = 1; windowSize = BLOCK_LEN_LONG; startBand = tnsInfo->tnsMinBandNumberLong; stopBand = numberOfBands; startBand = min(startBand,tnsInfo->tnsMaxBandsLong); stopBand = min(stopBand,tnsInfo->tnsMaxBandsLong); break; } /* Make sure that start and stop bands < maxSfb */ /* Make sure that start and stop bands >= 0 */ startBand = min(startBand,maxSfb); stopBand = min(stopBand,maxSfb); startBand = max(startBand,0); stopBand = max(stopBand,0); /* Perform filtering for each window */ for(w=0;wwindowData[w]; TnsFilterData* tnsFilter = windowData->tnsFilter; startIndex = w * windowSize + sfbOffsetTable[startBand]; length = sfbOffsetTable[stopBand] - sfbOffsetTable[startBand]; if (tnsInfo->tnsDataPresent && windowData->numFilters) { /* Use TNS */ TnsInvFilter(length,&spec[startIndex],tnsFilter); } } } /*****************************************************/ /* TnsDecodeFilterOnly: */ /* This is a stripped-down version of TnsEncode() */ /* which performs TNS synthesis filtering only */ /*****************************************************/ void TnsDecodeFilterOnly(TnsInfo* tnsInfo, /* TNS info */ int numberOfBands, /* Number of bands per window */ int maxSfb, /* max_sfb */ enum WINDOW_TYPE blockType, /* block type */ int* sfbOffsetTable, /* Scalefactor band offset table */ double* spec) /* Spectral data array */ { int numberOfWindows,windowSize; int startBand,stopBand; /* Bands over which to apply TNS */ int w; int startIndex,length; switch( blockType ) { case ONLY_SHORT_WINDOW : numberOfWindows = MAX_SHORT_WINDOWS; windowSize = BLOCK_LEN_SHORT; startBand = tnsInfo->tnsMinBandNumberShort; stopBand = numberOfBands; startBand = min(startBand,tnsInfo->tnsMaxBandsShort); stopBand = min(stopBand,tnsInfo->tnsMaxBandsShort); break; default: numberOfWindows = 1; windowSize = BLOCK_LEN_LONG; startBand = tnsInfo->tnsMinBandNumberLong; stopBand = numberOfBands; startBand = min(startBand,tnsInfo->tnsMaxBandsLong); stopBand = min(stopBand,tnsInfo->tnsMaxBandsLong); break; } /* Make sure that start and stop bands < maxSfb */ /* Make sure that start and stop bands >= 0 */ startBand = min(startBand,maxSfb); stopBand = min(stopBand,maxSfb); startBand = max(startBand,0); stopBand = max(stopBand,0); /* Perform filtering for each window */ for(w=0;wwindowData[w]; TnsFilterData* tnsFilter = windowData->tnsFilter; startIndex = w * windowSize + sfbOffsetTable[startBand]; length = sfbOffsetTable[stopBand] - sfbOffsetTable[startBand]; if (tnsInfo->tnsDataPresent && windowData->numFilters) { /* Use TNS */ TnsFilter(length,&spec[startIndex],tnsFilter); } } } /*****************************************************/ /* TnsFilter: */ /* Filter the given spec with specified length */ /* using the coefficients specified in filter. */ /* Not that the order and direction are specified */ /* withing the TNS_FILTER_DATA structure. */ /*****************************************************/ static void TnsFilter(int length,double* spec,TnsFilterData* filter) { int i,j,k=0; int order=filter->order; double* a=filter->aCoeffs; /* Determine loop parameters for given direction */ if (filter->direction) { /* Startup, initial state is zero */ for (i=length-2;i>(length-1-order);i--) { k++; for (j=1;j<=k;j++) { spec[i]-=spec[i+j]*a[j]; } } /* Now filter completely inplace */ for (i=length-1-order;i>=0;i--) { for (j=1;j<=order;j++) { spec[i]-=spec[i+j]*a[j]; } } } else { /* Startup, initial state is zero */ for (i=1;iorder; double* a=filter->aCoeffs; double* temp; temp = (double *)AllocMemory(length * sizeof (double)); /* Determine loop parameters for given direction */ if (filter->direction) { /* Startup, initial state is zero */ temp[length-1]=spec[length-1]; for (i=length-2;i>(length-1-order);i--) { temp[i]=spec[i]; k++; for (j=1;j<=k;j++) { spec[i]+=temp[i+j]*a[j]; } } /* Now filter the rest */ for (i=length-1-order;i>=0;i--) { temp[i]=spec[i]; for (j=1;j<=order;j++) { spec[i]+=temp[i+j]*a[j]; } } } else { /* Startup, initial state is zero */ temp[0]=spec[0]; for (i=1;i= 0; i--) { kArray[i] = (fabs(kArray[i])>threshold) ? kArray[i] : 0.0; if (kArray[i]!=0.0) return i; } return 0; } /*****************************************************/ /* QuantizeReflectionCoeffs: */ /* Quantize the given array of reflection coeffs */ /* to the specified resolution in bits. */ /*****************************************************/ static void QuantizeReflectionCoeffs(int fOrder, int coeffRes, double* kArray, int* indexArray) { double iqfac,iqfac_m; int i; iqfac = ((1<<(coeffRes-1))-0.5)/(M_PI/2); iqfac_m = ((1<<(coeffRes-1))+0.5)/(M_PI/2); /* Quantize and inverse quantize */ for (i=1;i<=fOrder;i++) { indexArray[i] = (kArray[i]>=0)?(int)(0.5+(asin(kArray[i])*iqfac)):(int)(-0.5+(asin(kArray[i])*iqfac_m)); kArray[i] = sin((double)indexArray[i]/((indexArray[i]>=0)?iqfac:iqfac_m)); } } /*****************************************************/ /* Autocorrelation, */ /* Compute the autocorrelation function */ /* estimate for the given data. */ /*****************************************************/ static void Autocorrelation(int maxOrder, /* Maximum autocorr order */ int dataSize, /* Size of the data array */ double* data, /* Data array */ double* rArray) /* Autocorrelation array */ { int order,index; for (order=0;order<=maxOrder;order++) { rArray[order]=0.0; for (index=0;index #include "util.h" #include "coder.h" // FRAME_LEN /* Returns the sample rate index */ int GetSRIndex(unsigned int sampleRate) { if (92017 <= sampleRate) return 0; if (75132 <= sampleRate) return 1; if (55426 <= sampleRate) return 2; if (46009 <= sampleRate) return 3; if (37566 <= sampleRate) return 4; if (27713 <= sampleRate) return 5; if (23004 <= sampleRate) return 6; if (18783 <= sampleRate) return 7; if (13856 <= sampleRate) return 8; if (11502 <= sampleRate) return 9; if (9391 <= sampleRate) return 10; return 11; } /* Returns the maximum bitrate for that sampling frequency */ unsigned int MaxBitrate(unsigned long sampleRate) { /* max ADTS frame size 8k */ return 0x2000 * 8 * (double)sampleRate/(double)FRAME_LEN; } /* Returns the minimum bitrate per channel for that sampling frequency */ unsigned int MinBitrate() { return 8000; } /* Calculate bit_allocation based on PE */ unsigned int BitAllocation(double pe, int short_block) { double pew1; double pew2; double bit_allocation; if (short_block) { pew1 = 0.6; pew2 = 24.0; } else { pew1 = 0.3; pew2 = 6.0; } bit_allocation = pew1 * pe + pew2 * sqrt(pe); bit_allocation = min(max(0.0, bit_allocation), 6144.0); return (unsigned int)(bit_allocation+0.5); } /* Returns the maximum bit reservoir size */ unsigned int MaxBitresSize(unsigned long bitRate, unsigned long sampleRate) { return 6144 - (unsigned int)((double)bitRate/(double)sampleRate*(double)FRAME_LEN); } faac-1_30/libfaac/util.h000066400000000000000000000032721355157314300151320ustar00rootroot00000000000000/* * FAAC - Freeware Advanced Audio Coder * Copyright (C) 2001 Menno Bakker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: util.h,v 1.8 2003/12/20 04:32:48 stux Exp $ */ #ifndef UTIL_H #define UTIL_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include #include #ifndef max #define max(a, b) (((a) > (b)) ? (a) : (b)) #endif #ifndef min #define min(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef M_PI #define M_PI 3.14159265358979323846 #endif /* Memory functions */ #define AllocMemory(size) malloc(size) #define FreeMemory(block) free(block) #define SetMemory(block, value, size) memset(block, value, size) int GetSRIndex(unsigned int sampleRate); int GetMaxPredSfb(int samplingRateIdx); unsigned int MaxBitrate(unsigned long sampleRate); unsigned int MinBitrate(); unsigned int MaxBitresSize(unsigned long bitRate, unsigned long sampleRate); unsigned int BitAllocation(double pe, int short_block); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* UTIL_H */ faac-1_30/plugins/000077500000000000000000000000001355157314300141005ustar00rootroot00000000000000faac-1_30/plugins/cooledit/000077500000000000000000000000001355157314300157025ustar00rootroot00000000000000faac-1_30/plugins/cooledit/Copying000066400000000000000000000430761355157314300172470ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: 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. Copyright (C) 19yy 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., 675 Mass Ave, Cambridge, MA 02139, 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) 19yy 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. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. faac-1_30/plugins/cooledit/FAAC.def000066400000000000000000000004541355157314300170570ustar00rootroot00000000000000LIBRARY EXPORTS QueryCoolFilter OpenFilterOutput CloseFilterOutput WriteFilterOutput OpenFilterInput CloseFilterInput ReadFilterInput FilterUnderstandsFormat FilterGetFileSize FilterOptionsString FilterGetOptions GetSuggestedSampleType ; DIALOGMsgProc ; FilterOptions ; FilterSetOptions faac-1_30/plugins/cooledit/FAAC.sln000066400000000000000000000050161355157314300171140ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FAAC", "FAAC.vcproj", "{DEC2740A-F3D5-430C-BB81-C57006D20378}" ProjectSection(ProjectDependencies) = postProject {2E6FD2E8-55B9-4740-8882-CF823F77F7E1} = {2E6FD2E8-55B9-4740-8882-CF823F77F7E1} {429A062F-81E0-4EFD-832B-55E0DE931FC8} = {429A062F-81E0-4EFD-832B-55E0DE931FC8} {BD8FBE75-314D-476B-B13C-A206C52F0BD1} = {BD8FBE75-314D-476B-B13C-A206C52F0BD1} {7F01A591-0084-4749-B53F-F9D2BFE8DF6E} = {7F01A591-0084-4749-B53F-F9D2BFE8DF6E} {6440BFC6-57A6-4F6E-A8FB-F960D088ADEE} = {6440BFC6-57A6-4F6E-A8FB-F960D088ADEE} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aacInfoLib", "aacInfoLib.vcproj", "{3257D980-5029-486B-94DC-AA520B501C62}" EndProject Project("{059D6162-CD51-11D0-AE1F-00A0C90FFFC3}") = "id3lib", "..\..\..\faad2\common\id3lib\libprj\id3lib.dsp", "{7F01A591-0084-4749-B53F-F9D2BFE8DF6E}" EndProject Project("{059D6162-CD51-11D0-AE1F-00A0C90FFFC3}") = "libfaac", "..\..\libfaac\libfaac.dsp", "{2E6FD2E8-55B9-4740-8882-CF823F77F7E1}" EndProject Project("{059D6162-CD51-11D0-AE1F-00A0C90FFFC3}") = "libfaad", "..\..\..\faad2\libfaad\libfaad.dsp", "{429A062F-81E0-4EFD-832B-55E0DE931FC8}" EndProject Project("{059D6162-CD51-11D0-AE1F-00A0C90FFFC3}") = "libmp4v2_st", "..\..\..\faad2\common\mp4v2\libmp4v2_st60.dsp", "{BD8FBE75-314D-476B-B13C-A206C52F0BD1}" EndProject Project("{059D6162-CD51-11D0-AE1F-00A0C90FFFC3}") = "zlib", "..\..\..\faad2\common\id3lib\zlib\prj\zlib.dsp", "{6440BFC6-57A6-4F6E-A8FB-F960D088ADEE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {DEC2740A-F3D5-430C-BB81-C57006D20378}.Debug|Win32.ActiveCfg = Debug|Win32 {DEC2740A-F3D5-430C-BB81-C57006D20378}.Debug|Win32.Build.0 = Debug|Win32 {DEC2740A-F3D5-430C-BB81-C57006D20378}.Release|Win32.ActiveCfg = Release|Win32 {DEC2740A-F3D5-430C-BB81-C57006D20378}.Release|Win32.Build.0 = Release|Win32 {3257D980-5029-486B-94DC-AA520B501C62}.Debug|Win32.ActiveCfg = Debug|Win32 {3257D980-5029-486B-94DC-AA520B501C62}.Debug|Win32.Build.0 = Debug|Win32 {3257D980-5029-486B-94DC-AA520B501C62}.Release|Win32.ActiveCfg = Release|Win32 {3257D980-5029-486B-94DC-AA520B501C62}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal faac-1_30/plugins/cooledit/FAAC.vcproj000066400000000000000000000261701355157314300176270ustar00rootroot00000000000000 faac-1_30/plugins/cooledit/Faac.cpp000066400000000000000000000064651355157314300172530ustar00rootroot00000000000000/* FAAC - codec plugin for Cooledit Copyright (C) 2002-2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include #include "resource.h" #include "filters.h" // CoolEdit #include "Defines.h" // my defines #include "EncDialog.h" #include "Cfaac.h" // ********************************************************************************************* inline DWORD ERROR_FGO(char *msg) { if(msg) { char buf[100]; sprintf(buf,"FilterGetOptions: %s", msg); MessageBox(0, buf, APP_NAME " plugin", MB_OK|MB_ICONSTOP); } return 0; } // ----------------------------------------------------------------------------------------------- DWORD FAR PASCAL FilterGetOptions(HWND hWnd, HINSTANCE hInst, long lSamprate, WORD wChannels, WORD wBitsPerSample, DWORD dwOptions) { long retVal=DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_ENCODER), (HWND)hWnd, (DLGPROC)DIALOGMsgProcEnc, dwOptions); if(retVal==-1) /*return */ERROR_FGO("DialogBoxParam"); return !retVal ? dwOptions : retVal; } // ********************************************************************************************* // GetSuggestedSampleType() is called if OpenFilterOutput() returns NULL void FAR PASCAL GetSuggestedSampleType(LONG *lplSamprate, WORD *lpwBitsPerSample, WORD *wChannels) { *lplSamprate=0; // don't care *lpwBitsPerSample= *lpwBitsPerSample<=16 ? 0 : 16; *wChannels= *wChannels<49 ? 0 : 48; } // ********************************************************************************************* void FAR PASCAL CloseFilterOutput(HANDLE hOutput) { if(!hOutput) return; Cfaac tmp(hOutput); // this line frees memory } // ********************************************************************************************* HANDLE FAR PASCAL OpenFilterOutput(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long lSize, long far *lpChunkSize, DWORD dwOptions) { HANDLE hOutput; Cfaac tmp; CMyEncCfg cfg(false); char *srcFilename=tmp.getSourceFilename(cfg.TagSrcPath,lpstrFilename,cfg.TagSrcExt); if(hOutput=tmp.Init(srcFilename,lpstrFilename,lSamprate,wBitsPerSample,wChannels,lSize)) { MYOUTPUT *mo; GLOBALLOCK(mo,hOutput,MYOUTPUT,return NULL); *lpChunkSize=mo->samplesInput*(wBitsPerSample>>3); // size of samplesInput GlobalUnlock(hOutput); tmp.hOutput=NULL; } FREE_ARRAY(srcFilename); return hOutput; } // ********************************************************************************************* DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *bufIn, long lBytes) { if(!hOutput) return 0; Cfaac tmp; DWORD bytesWritten; bytesWritten=tmp.processData(hOutput,bufIn,lBytes); return bytesWritten ? bytesWritten : 0x7fffffff; // bytesWritten<=0 stops CoolEdit } faac-1_30/plugins/cooledit/Faad.cpp000066400000000000000000000133151355157314300172440ustar00rootroot00000000000000/* FAAC - codec plugin for Cooledit Copyright (C) 2002-2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include //#include "resource.h" #include "filters.h" // CoolEdit #include "DecDialog.h" #include "Cfaad.h" // ********************************************************************************************* BOOL FAR PASCAL FilterUnderstandsFormat(LPSTR filename) { WORD len; if((len=lstrlen(filename))>4 && (!strcmpi(filename+len-4,".aac") || !strcmpi(filename+len-4,".mp4") || !strcmpi(filename+len-4,".m4a"))) return TRUE; return FALSE; } // ********************************************************************************************* long FAR PASCAL FilterGetFileSize(HANDLE hInput) { if(!hInput) return 0; DWORD dst_size; MYINPUT *mi; GLOBALLOCK(mi,hInput,MYINPUT,return 0); dst_size=mi->dst_size; GlobalUnlock(hInput); return dst_size; } // ********************************************************************************************* DWORD FAR PASCAL FilterOptionsString(HANDLE hInput, LPSTR szString) { if(!hInput) { lstrcpy(szString,""); return 0; } MYINPUT *mi; GLOBALLOCK(mi,hInput,MYINPUT,return 0); sprintf(szString,"MPEG%d - %lu bps\n", mi->file_info.version ? 4 : 2, mi->file_info.bitrate); if(mi->IsMP4) // MP4 file -------------------------------------------------------------------- lstrcat(szString,mpeg4AudioNames[mi->type]); else // AAC file ----------------------------------------------------------------------------- { switch(mi->file_info.headertype) { case RAW: sprintf(szString,"MPEG%d\nRaw\n", mi->file_info.version ? 4 : 2); lstrcat(szString,mpeg4AudioNames[mi->file_info.object_type]); GlobalUnlock(hInput); return 1;//0; // call FilterGetOptions() case ADIF: lstrcat(szString,"ADIF\n"); break; case ADTS: lstrcat(szString,"ADTS\n"); break; } lstrcat(szString,mpeg4AudioNames[mi->file_info.object_type]); /* switch(mi->file_info.object_type) { case MAIN: lstrcat(szString,"Main"); break; case LC: lstrcat(szString,"LC (Low Complexity)"); break; case SSR: lstrcat(szString,"SSR (unsupported)"); break; case LTP: lstrcat(szString,"LTP (Long Term Prediction)"); break; case HE_AAC: lstrcat(szString,"HE (High Efficiency)"); break; }*/ } GlobalUnlock(hInput); return 1; // don't call FilterGetOptions() } // ********************************************************************************************* /* DWORD FAR PASCAL FilterOptions(HANDLE hInput) { // FilterGetOptions() is called if this function and FilterSetOptions() are exported and FilterOptionsString() returns 0 // FilterSetOptions() is called only if this function is exported and and it returns 0 return 1; } // --------------------------------------------------------------------------------------------- DWORD FAR PASCAL FilterSetOptions(HANDLE hInput, DWORD dwOptions, LONG lSamprate, WORD wChannels, WORD wBPS) { return dwOptions; }*/ // ********************************************************************************************* void FAR PASCAL CloseFilterInput(HANDLE hInput) { if(!hInput) return; /* if(mi->file_info.headertype==RAW) { CRegistry reg; if(reg.openCreateReg(HKEY_CURRENT_USER,REGISTRY_PROGRAM_NAME "\\FAAD")) reg.setRegBool("OpenDialog",FALSE); else MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP); }*/ Cfaad tmp(hInput); } // ********************************************************************************************* #define ERROR_OFI(msg) \ { \ if(msg) \ MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \ if(hInput) \ { \ GlobalUnlock(hInput); \ CloseFilterInput(hInput); \ } \ return 0; \ } // ----------------------------------------------------------------------------------------------- // return handle that will be passed in to close, and write routines HANDLE FAR PASCAL OpenFilterInput(LPSTR lpstrFilename, long far *lSamprate, WORD far *wBitsPerSample, WORD far *wChannels, HWND hWnd, long far *lChunkSize) { HANDLE hInput=NULL; Cfaad tmp; CMyDecCfg cfg(false); if(!*lSamprate && !tmp.IsMP4(lpstrFilename)) { /* aac_buffer b; float fLength; int bitrate; DWORD headertype; tmp.GetAACInfos(lpstrFilename,&b,&headertype,&fLength,&bitrate); if(headertype==RAW) tmp.ShowDlg4RawAAC=ShowDlg4RawAAC;*/ DWORD *seek_table; int seek_table_length; faadAACInfo file_info; if(!get_AAC_format(lpstrFilename, &file_info, &seek_table, &seek_table_length, 0)) if(file_info.headertype==RAW) tmp.ShowDlg4RawAAC=ShowDlg4RawAAC; } if(hInput=tmp.getInfos(lpstrFilename)) { MYINPUT *mi; GLOBALLOCK(mi,hInput,MYINPUT,return NULL); *wChannels=(WORD)mi->Channels; *lSamprate=mi->Samprate; *wBitsPerSample=mi->BitsPerSample; *lChunkSize=(*wBitsPerSample/8)*1024**wChannels*2; GlobalUnlock(hInput); tmp.hInput=NULL; } return hInput; } // ********************************************************************************************* DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes) { if(!hInput) return 0; Cfaad tmp; return tmp.processData(hInput,bufout,lBytes); } faac-1_30/plugins/cooledit/Main.cpp000066400000000000000000000100671355157314300172760ustar00rootroot00000000000000/* FAAC - codec plugin for Cooledit Copyright (C) 2002-2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #include #include "resource.h" #include "filters.h" //CoolEdit //#include "faac.h" #include "Defines.h" // my defines // Plugins of CoolEdit can be unloaded between each call of its exported funcs, // that's why no global variables can be used HINSTANCE hInstance=NULL; HBITMAP hBmBrowse=NULL; BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: hInstance=(HINSTANCE)hModule; if(!hBmBrowse) hBmBrowse=(HBITMAP)LoadImage(hInstance,MAKEINTRESOURCE(IDB_BROWSE),IMAGE_BITMAP,0,0,/*LR_CREATEDIBSECTION|*/LR_LOADTRANSPARENT|LR_LOADMAP3DCOLORS); /* Code from LibMain inserted here. Return TRUE to keep the DLL loaded or return FALSE to fail loading the DLL. You may have to modify the code in your original LibMain to account for the fact that it may be called more than once. You will get one DLL_PROCESS_ATTACH for each process that loads the DLL. This is different from LibMain which gets called only once when the DLL is loaded. The only time this is critical is when you are using shared data sections. If you are using shared data sections for statically allocated data, you will need to be careful to initialize it only once. Check your code carefully. Certain one-time initializations may now need to be done for each process that attaches. You may also not need code from your original LibMain because the operating system may now be doing it for you. */ break; case DLL_THREAD_ATTACH: /* Called each time a thread is created in a process that has already loaded (attached to) this DLL. Does not get called for each thread that exists in the process before it loaded the DLL. Do thread-specific initialization here. */ break; case DLL_THREAD_DETACH: /* Same as above, but called when a thread in the process exits. Do thread-specific cleanup here. */ break; case DLL_PROCESS_DETACH: /* Code from _WEP inserted here. This code may (like the LibMain) not be necessary. Check to make certain that the operating system is not doing it for you. */ hInstance=NULL; if(hBmBrowse) { DeleteObject(hBmBrowse); hBmBrowse=NULL; } break; } /* The return value is only used for DLL_PROCESS_ATTACH; all other conditions are ignored. */ return TRUE; // successful DLL_PROCESS_ATTACH } // Fill COOLQUERY structure with information regarding this file filter short FAR PASCAL QueryCoolFilter(COOLQUERY far * cq) { lstrcpy(cq->szName, APP_NAME); lstrcpy(cq->szCopyright, APP_NAME " codec"); lstrcpy(cq->szExt,"AAC"); lstrcpy(cq->szExt2,"MP4"); lstrcpy(cq->szExt3,"M4A"); cq->lChunkSize=16384; cq->dwFlags=QF_RATEADJUSTABLE|QF_CANLOAD|QF_CANSAVE|QF_HASOPTIONSBOX|QF_CANDO32BITFLOATS; cq->Mono8=R_5500|R_11025|R_22050|R_32075|R_44100|R_48000; cq->Mono12=0; // no support cq->Mono16=R_5500|R_11025|R_22050|R_32075|R_44100|R_48000; cq->Mono24=0; cq->Mono32=R_5500|R_11025|R_22050|R_32075|R_44100|R_48000; cq->Stereo8=R_5500|R_11025|R_22050|R_32075|R_44100|R_48000; cq->Stereo12=0; cq->Stereo16=R_5500|R_11025|R_22050|R_32075|R_44100|R_48000; cq->Stereo24=0; cq->Stereo32=R_5500|R_11025|R_22050|R_32075|R_44100|R_48000; cq->Quad8=0; cq->Quad16=0; cq->Quad32=0; return C_VALIDLIBRARY; } faac-1_30/plugins/cooledit/Readme.txt000066400000000000000000000024621355157314300176440ustar00rootroot00000000000000+-----------------------------------------------------------------+ | | | Cooledit/Audition plugin | | ------------------------ | | | +-----------------------------------------------------------------+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. ---------------------------------------------------------------------------- FAAC is a codec plugin for Cooledit/Audition to import and export .aac/.mp4 files. To use it: ---------- 1) put FAAC and FAAD2 packages into the same folder; 2) open the project, set "Active Configuration = FAAC - win32 Release" and compile; 3) copy FAAC.flt into CoolEdit folder and delete flt.dat To write .mp4 files: -------------------- Select "Write .mp4" in the config dialog or append .mp4 extension to the name of file in the "Save waveform as" dialog. ---------------------------------------------------------------------------- For suggestions, bugs report, etc., you can contact me at ntnfrn_email-temp@yahoo.it faac-1_30/plugins/cooledit/aacInfoLib.sln000066400000000000000000000015401355157314300204070ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aacInfoLib", "aacInfoLib.vcproj", "{3257D980-5029-486B-94DC-AA520B501C62}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {3257D980-5029-486B-94DC-AA520B501C62}.Debug|Win32.ActiveCfg = Debug|Win32 {3257D980-5029-486B-94DC-AA520B501C62}.Debug|Win32.Build.0 = Debug|Win32 {3257D980-5029-486B-94DC-AA520B501C62}.Release|Win32.ActiveCfg = Release|Win32 {3257D980-5029-486B-94DC-AA520B501C62}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal faac-1_30/plugins/cooledit/aacInfoLib.vcproj000066400000000000000000000116121355157314300211170ustar00rootroot00000000000000 faac-1_30/plugins/cooledit/defines.h000066400000000000000000000025461355157314300174770ustar00rootroot00000000000000/* FAAC - codec plugin for Cooledit Copyright (C) 2002-2004 Antonio Foranna 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. 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., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be contacted at: ntnfrn_email-temp@yahoo.it */ #define APP_NAME "MPEG4-AAC" #define APP_VER "v2.6" #define REGISTRY_PROGRAM_NAME "SOFTWARE\\4N\\CoolEdit\\AAC-MPEG4" //#define USE_OUTPUT_FOLDER #define USE_IMPORT_TAG #define USE_PATHEXT // ********************************************************************************************* #define FREE_ARRAY(ptr) \ { \ if(ptr!=NULL) \ free(ptr); \ ptr=NULL; \ } // ----------------------------------------------------------------------------------------------- #define GLOBALLOCK(ptr,handle,type,ret) \ { \ if(!(ptr=(type *)GlobalLock(handle))) \ { \ MessageBox(0, "GlobalLock", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \ ret; \ } \ } faac-1_30/plugins/cooledit/filters.h000066400000000000000000000107001355157314300175210ustar00rootroot00000000000000////////////////////////////////////////////////////// // GENERAL PURPOSE DEFS FOR CREATING CUSTOM FILTERS // ////////////////////////////////////////////////////// typedef struct riffspecialdata_t { HANDLE hSpecialData; HANDLE hData; // Actual data handle DWORD dwSize; // size of data in handle DWORD dwExtra; // optional extra data (usually a count) char szListType[8]; // Parent list type (usually "WAVE" or "INFO", or "adtl") char szType[8]; // Usually a four character code for data, but can be up to 7 chars } SPECIALDATA; // "CUE " dwExtra=number of cues, each cue is 8 bytes ([4] name [4] sample offset) // "LTXT" dwExtra=number of items, each one is 8 bytes ([4] ltxt len [4] name [4] cue length [4] purpose [n] data) // "NOTE" dwExtra=number of strings, each one is n bytes ([4] name [n-4] length zero term) // "LABL" dwExtra=number of strings, each one is n bytes ([4] name [n-4] length zero term) // "PLST" dwExtra=number if items, each one is 16 bytes ([4] name [4] dwLen [4] dwLoops [4] dwMode) // For special data, .FLT must implement FilterGetFirstSpecialData and FilterGetNextSpecialData typedef DWORD FOURCC; // a four character code struct cue_type { DWORD dwName; DWORD dwPosition; FOURCC fccChunk; DWORD dwChunkStart; DWORD dwBlockStart; DWORD dwSampleOffset; }; struct play_type {DWORD dwName; DWORD dwLength; DWORD dwLoops; }; typedef struct coolquery_tag {char szName[24]; char szCopyright[80]; // rate table, bits are set for modes that can be handled WORD Quad32; // Quads are 3-D encoded WORD Quad16; WORD Quad8; WORD Stereo8; // rates are from lowest bit: WORD Stereo12; // bit 0 set: 5500 (5512.5) WORD Stereo16; // bit 1 set: 11025 (11K) WORD Stereo24; // bit 2 set: 22050 (22K) WORD Stereo32; // bit 3 set: 32075 (32K, or 32000) WORD Mono8; // bit 4 set: 44100 (44K) WORD Mono12; // bit 5 set: 48000 (48K) WORD Mono16; // bit 6 set: 88200 (88K) (future ultra-sonic rates?) WORD Mono24; // bit 7 set: 96000 (96K) WORD Mono32; // bit 8 set: 132300 (132K) // bit 9 set: 176400 (176K) DWORD dwFlags; char szExt[4]; long lChunkSize; char szExt2[4]; char szExt3[4]; char szExt4[4]; } COOLQUERY; #define R_5500 1 #define R_11025 2 #define R_22050 4 #define R_32075 8 #define R_44100 16 #define R_48000 32 #define R_88200 64 #define R_96000 128 #define R_132300 256 #define R_176400 512 #define C_VALIDLIBRARY 1154 #define QF_RATEADJUSTABLE 0x001 // if can handle non-standard sample rates // if not, only rates in bit rate table understood #define QF_CANSAVE 0x002 #define QF_CANLOAD 0x004 #define QF_UNDERSTANDSALL 0x008 // will read ANYTHING, so it is the last resort if no other // formats match #define QF_READSPECIALFIRST 0x010 // read special info before trying to read data #define QF_READSPECIALLAST 0x020 // read special info after reading data #define QF_WRITESPECIALFIRST 0x040 // when writing a file, special info is sent to DLL before data #define QF_WRITESPECIALLAST 0x080 // when writing, special info is sent to DLL after data #define QF_HASOPTIONSBOX 0x100 // set if options box implemented #define QF_NOASKFORCONVERT 0x200 // set to bypass asking for conversion if original in different rate, auto convert #define QF_NOHEADER 0x400 // set if this is a raw data format with no header #define QF_CANDO32BITFLOATS 0x800 // set if file format can handle 32-bit sample data for input #define QF_CANOPENVIRTUAL 0x1000 // Set if data is in Intel 8-bit or 16-bit sample format, or floats // and the GetDataOffset() function is implemented // special types are read from and written to DLL in the order below /* // special types (particular to Windows waveforms) #define SP_IART 20 #define SP_ICMT 21 #define SP_ICOP 22 #define SP_ICRD 23 #define SP_IENG 24 #define SP_IGNR 25 #define SP_IKEY 26 #define SP_IMED 27 #define SP_INAM 28 #define SP_ISFT 29 #define SP_ISRC 30 #define SP_ITCH 31 #define SP_ISBJ 32 #define SP_ISRF 33 #define SP_DISP 34 #define SP_CUE 40 // returns number of cues of size cue_type #define SP_LTXT 41 // returns number of adtl texts of size 8 (4,id and 4,len) #define SP_NOTE 42 // returns LO=size, HI=number of strings (sz sz sz...) #define SP_LABL 43 // returns LO=size, HI=number of strings (sz sz sz...) #define SP_PLST 44 // returns number of playlist entries size play_type */faac-1_30/plugins/winamp/000077500000000000000000000000001355157314300153735ustar00rootroot00000000000000faac-1_30/plugins/winamp/filters.h000066400000000000000000000107001355157314300172120ustar00rootroot00000000000000////////////////////////////////////////////////////// // GENERAL PURPOSE DEFS FOR CREATING CUSTOM FILTERS // ////////////////////////////////////////////////////// typedef struct riffspecialdata_t { HANDLE hSpecialData; HANDLE hData; // Actual data handle DWORD dwSize; // size of data in handle DWORD dwExtra; // optional extra data (usually a count) char szListType[8]; // Parent list type (usually "WAVE" or "INFO", or "adtl") char szType[8]; // Usually a four character code for data, but can be up to 7 chars } SPECIALDATA; // "CUE " dwExtra=number of cues, each cue is 8 bytes ([4] name [4] sample offset) // "LTXT" dwExtra=number of items, each one is 8 bytes ([4] ltxt len [4] name [4] cue length [4] purpose [n] data) // "NOTE" dwExtra=number of strings, each one is n bytes ([4] name [n-4] length zero term) // "LABL" dwExtra=number of strings, each one is n bytes ([4] name [n-4] length zero term) // "PLST" dwExtra=number if items, each one is 16 bytes ([4] name [4] dwLen [4] dwLoops [4] dwMode) // For special data, .FLT must implement FilterGetFirstSpecialData and FilterGetNextSpecialData typedef DWORD FOURCC; // a four character code struct cue_type { DWORD dwName; DWORD dwPosition; FOURCC fccChunk; DWORD dwChunkStart; DWORD dwBlockStart; DWORD dwSampleOffset; }; struct play_type {DWORD dwName; DWORD dwLength; DWORD dwLoops; }; typedef struct coolquery_tag {char szName[24]; char szCopyright[80]; // rate table, bits are set for modes that can be handled WORD Quad32; // Quads are 3-D encoded WORD Quad16; WORD Quad8; WORD Stereo8; // rates are from lowest bit: WORD Stereo12; // bit 0 set: 5500 (5512.5) WORD Stereo16; // bit 1 set: 11025 (11K) WORD Stereo24; // bit 2 set: 22050 (22K) WORD Stereo32; // bit 3 set: 32075 (32K, or 32000) WORD Mono8; // bit 4 set: 44100 (44K) WORD Mono12; // bit 5 set: 48000 (48K) WORD Mono16; // bit 6 set: 88200 (88K) (future ultra-sonic rates?) WORD Mono24; // bit 7 set: 96000 (96K) WORD Mono32; // bit 8 set: 132300 (132K) // bit 9 set: 176400 (176K) DWORD dwFlags; char szExt[4]; long lChunkSize; char szExt2[4]; char szExt3[4]; char szExt4[4]; } COOLQUERY; #define R_5500 1 #define R_11025 2 #define R_22050 4 #define R_32075 8 #define R_44100 16 #define R_48000 32 #define R_88200 64 #define R_96000 128 #define R_132300 256 #define R_176400 512 #define C_VALIDLIBRARY 1154 #define QF_RATEADJUSTABLE 0x001 // if can handle non-standard sample rates // if not, only rates in bit rate table understood #define QF_CANSAVE 0x002 #define QF_CANLOAD 0x004 #define QF_UNDERSTANDSALL 0x008 // will read ANYTHING, so it is the last resort if no other // formats match #define QF_READSPECIALFIRST 0x010 // read special info before trying to read data #define QF_READSPECIALLAST 0x020 // read special info after reading data #define QF_WRITESPECIALFIRST 0x040 // when writing a file, special info is sent to DLL before data #define QF_WRITESPECIALLAST 0x080 // when writing, special info is sent to DLL after data #define QF_HASOPTIONSBOX 0x100 // set if options box implemented #define QF_NOASKFORCONVERT 0x200 // set to bypass asking for conversion if original in different rate, auto convert #define QF_NOHEADER 0x400 // set if this is a raw data format with no header #define QF_CANDO32BITFLOATS 0x800 // set if file format can handle 32-bit sample data for input #define QF_CANOPENVIRTUAL 0x1000 // Set if data is in Intel 8-bit or 16-bit sample format, or floats // and the GetDataOffset() function is implemented // special types are read from and written to DLL in the order below /* // special types (particular to Windows waveforms) #define SP_IART 20 #define SP_ICMT 21 #define SP_ICOP 22 #define SP_ICRD 23 #define SP_IENG 24 #define SP_IGNR 25 #define SP_IKEY 26 #define SP_IMED 27 #define SP_INAM 28 #define SP_ISFT 29 #define SP_ISRC 30 #define SP_ITCH 31 #define SP_ISBJ 32 #define SP_ISRF 33 #define SP_DISP 34 #define SP_CUE 40 // returns number of cues of size cue_type #define SP_LTXT 41 // returns number of adtl texts of size 8 (4,id and 4,len) #define SP_NOTE 42 // returns LO=size, HI=number of strings (sz sz sz...) #define SP_LABL 43 // returns LO=size, HI=number of strings (sz sz sz...) #define SP_PLST 44 // returns number of playlist entries size play_type */faac-1_30/plugins/winamp/out_FAAC.dsp000066400000000000000000000120751355157314300174710ustar00rootroot00000000000000# Microsoft Developer Studio Project File - Name="Out_FAAC" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=Out_FAAC - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "Out_FAAC.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "Out_FAAC.mak" CFG="Out_FAAC - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "Out_FAAC - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "Out_FAAC - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=xicl6.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "Out_FAAC - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_FAAC_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "../../common/mp4v2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x410 /d "NDEBUG" # ADD RSC /l 0x410 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/Out_AAC.dll" !ELSEIF "$(CFG)" == "Out_FAAC - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_FAAC_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../faad2/include" /I "../../../faad2/common/faad" /I "../../common/mp4v2" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x410 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\Audio\Gen\Winamp\Plugins\Out_AAC.dll" /pdbtype:sept !ENDIF # Begin Target # Name "Out_FAAC - Win32 Release" # Name "Out_FAAC - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\Cfaac.cpp # End Source File # Begin Source File SOURCE=.\CRegistry.cpp # End Source File # Begin Source File SOURCE=.\FAAC.rc # End Source File # Begin Source File SOURCE=.\Out_faac.cpp # End Source File # Begin Source File SOURCE=.\Out_FAAC.def # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\Cfaac.h # End Source File # Begin Source File SOURCE=.\CRegistry.h # End Source File # Begin Source File SOURCE=.\defines.h # End Source File # Begin Source File SOURCE=..\..\include\faac.h # End Source File # Begin Source File SOURCE=.\FILTERS.H # End Source File # Begin Source File SOURCE=.\OUT.H # End Source File # Begin Source File SOURCE=.\resource.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File SOURCE=.\AudioCoding.bmp # End Source File # Begin Source File SOURCE=.\Email.bmp # End Source File # Begin Source File SOURCE=".\mpeg4ip-v.bmp" # End Source File # Begin Source File SOURCE=.\Open.bmp # End Source File # Begin Source File SOURCE=.\Open.ico # End Source File # End Group # End Target # End Project faac-1_30/project/000077500000000000000000000000001355157314300140655ustar00rootroot00000000000000faac-1_30/project/msvc/000077500000000000000000000000001355157314300150355ustar00rootroot00000000000000faac-1_30/project/msvc/faac.sln000066400000000000000000000055701355157314300164540ustar00rootroot00000000000000Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaac_dll", "libfaac_dll.vcxproj", "{856BB8CF-B944-4D7A-9D59-4945316229AA}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaac_dll_drm", "libfaac_dll_drm.vcxproj", "{AA2D0EFE-E73D-40AD-ADCE-8A2B54F34C6F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaac", "libfaac.vcxproj", "{9CC48C6E-92EB-4814-AD37-97AB3622AB65}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "faac", "faac.vcxproj", "{92992E74-AEDE-46DC-AD8C-ADEA876F1A4C}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "faacgui", "faacgui.vcxproj", "{B4FD0E50-5379-48C3-8D3E-D948A8921CA8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {856BB8CF-B944-4D7A-9D59-4945316229AA}.Debug|Win32.ActiveCfg = Debug|Win32 {856BB8CF-B944-4D7A-9D59-4945316229AA}.Debug|Win32.Build.0 = Debug|Win32 {856BB8CF-B944-4D7A-9D59-4945316229AA}.Release|Win32.ActiveCfg = Release|Win32 {856BB8CF-B944-4D7A-9D59-4945316229AA}.Release|Win32.Build.0 = Release|Win32 {AA2D0EFE-E73D-40AD-ADCE-8A2B54F34C6F}.Debug|Win32.ActiveCfg = Debug|Win32 {AA2D0EFE-E73D-40AD-ADCE-8A2B54F34C6F}.Debug|Win32.Build.0 = Debug|Win32 {AA2D0EFE-E73D-40AD-ADCE-8A2B54F34C6F}.Debug|Win32.Deploy.0 = Debug|Win32 {AA2D0EFE-E73D-40AD-ADCE-8A2B54F34C6F}.Release|Win32.ActiveCfg = Release|Win32 {AA2D0EFE-E73D-40AD-ADCE-8A2B54F34C6F}.Release|Win32.Build.0 = Release|Win32 {9CC48C6E-92EB-4814-AD37-97AB3622AB65}.Debug|Win32.ActiveCfg = Debug|Win32 {9CC48C6E-92EB-4814-AD37-97AB3622AB65}.Debug|Win32.Build.0 = Debug|Win32 {9CC48C6E-92EB-4814-AD37-97AB3622AB65}.Release|Win32.ActiveCfg = Release|Win32 {9CC48C6E-92EB-4814-AD37-97AB3622AB65}.Release|Win32.Build.0 = Release|Win32 {92992E74-AEDE-46DC-AD8C-ADEA876F1A4C}.Debug|Win32.ActiveCfg = Debug|Win32 {92992E74-AEDE-46DC-AD8C-ADEA876F1A4C}.Debug|Win32.Build.0 = Debug|Win32 {92992E74-AEDE-46DC-AD8C-ADEA876F1A4C}.Release|Win32.ActiveCfg = Release|Win32 {92992E74-AEDE-46DC-AD8C-ADEA876F1A4C}.Release|Win32.Build.0 = Release|Win32 {B4FD0E50-5379-48C3-8D3E-D948A8921CA8}.Debug|Win32.ActiveCfg = Debug|Win32 {B4FD0E50-5379-48C3-8D3E-D948A8921CA8}.Debug|Win32.Build.0 = Debug|Win32 {B4FD0E50-5379-48C3-8D3E-D948A8921CA8}.Release|Win32.ActiveCfg = Release|Win32 {B4FD0E50-5379-48C3-8D3E-D948A8921CA8}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FEB55784-5428-470E-835B-D21D471570FE} EndGlobalSection EndGlobal faac-1_30/project/msvc/faac.vcxproj000066400000000000000000000133771355157314300173570ustar00rootroot00000000000000 Debug Win32 Release Win32 {92992E74-AEDE-46DC-AD8C-ADEA876F1A4C} 8.1 Application v141 Application v141 <_ProjectFileVersion>15.0.26730.12 .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ true .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ false Disabled .;../../include;../../common/mp4v2;../../common/libsndfile/src;../../common/getopt;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level3 true EditAndContinue Default _DEBUG;%(PreprocessorDefinitions) 0x0413 /MACHINE:I386 %(AdditionalOptions) true true Console OnlyExplicitInline .;../../include;../../common/mp4v2;../../common/libsndfile/src;../../common/getopt;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded true Level3 true NDEBUG;%(PreprocessorDefinitions) 0x0413 /MACHINE:I386 %(AdditionalOptions) true Console {9cc48c6e-92eb-4814-ad37-97ab3622ab65} faac-1_30/project/msvc/faac.vcxproj.filters000066400000000000000000000026041355157314300210150ustar00rootroot00000000000000 {c76ca49b-b803-46e5-a392-7c630b482af6} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {321d4908-5e90-4d86-b269-14d20fca0a59} h;hpp;hxx;hm;inl Source Files Source Files Source Files Header Files Header Files Header Files Header Files Header Files faac-1_30/project/msvc/faacgui.vcxproj000066400000000000000000000126661355157314300200640ustar00rootroot00000000000000 Debug Win32 Release Win32 {B4FD0E50-5379-48C3-8D3E-D948A8921CA8} 8.1 Application v141 Application v141 <_ProjectFileVersion>15.0.26730.12 .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ true .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ false Disabled ../../include;../../common/libsndfile/src;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level3 EditAndContinue _DEBUG;%(PreprocessorDefinitions) 0x0409 /MACHINE:I386 %(AdditionalOptions) true Windows OnlyExplicitInline ../../include;../../common/libsndfile/src;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreaded true Level3 NDEBUG;%(PreprocessorDefinitions) 0x0409 /MACHINE:I386 %(AdditionalOptions) true Windows {9cc48c6e-92eb-4814-ad37-97ab3622ab65} faac-1_30/project/msvc/faacgui.vcxproj.filters000066400000000000000000000027261355157314300215270ustar00rootroot00000000000000 {15442f02-1807-49f3-baea-57f94733975e} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {f1df32bb-4c02-4682-b956-6fb8f7f6db58} h;hpp;hxx;hm;inl {df6f7e21-d746-4dd4-96d7-f3abd45ce335} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Header Files Header Files Header Files Source Files faac-1_30/project/msvc/libfaac.def000066400000000000000000000004151355157314300170760ustar00rootroot00000000000000EXPORTS ; ; libfaac exports ; faacEncOpen @1 faacEncGetCurrentConfiguration @2 faacEncSetConfiguration @3 faacEncEncode @4 faacEncClose @5 faacEncGetDecoderSpecificInfo @6 faacEncGetVersion @7 faac-1_30/project/msvc/libfaac.vcxproj000066400000000000000000000142211355157314300200330ustar00rootroot00000000000000 Debug Win32 Release Win32 libfaac {9CC48C6E-92EB-4814-AD37-97AB3622AB65} 8.1 StaticLibrary v141 StaticLibrary v141 <_ProjectFileVersion>15.0.26730.12 .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ OnlyExplicitInline ../../include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_USE_MATH_DEFINES;%(PreprocessorDefinitions) true MultiThreaded true Level3 true true "$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faac" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaac\win32_ver.h" Retrieving package version... Disabled ../../include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_USE_MATH_DEFINES;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level3 true EditAndContinue true "$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faac" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaac\win32_ver.h" Retrieving package version... faac-1_30/project/msvc/libfaac.vcxproj.filters000066400000000000000000000066231355157314300215110ustar00rootroot00000000000000 {349c2ac9-04e9-4300-93df-39710715f031} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {e69450a4-7cd1-43b1-94d5-ccf9041f042e} h;hpp;hxx;hm;inl Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files faac-1_30/project/msvc/libfaac_dll.vcxproj000066400000000000000000000155601355157314300206750ustar00rootroot00000000000000 Debug Win32 Release Win32 libfaac_dll {856BB8CF-B944-4D7A-9D59-4945316229AA} 8.1 DynamicLibrary v141 DynamicLibrary v141 <_ProjectFileVersion>15.0.26730.12 .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ false .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ true OnlyExplicitInline true ../../include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBFAAC_DLL_EXPORTS;_USE_MATH_DEFINES;%(PreprocessorDefinitions) true MultiThreadedDLL true Level3 true /MACHINE:I386 %(AdditionalOptions) true .\libfaac.def MachineX86 Retrieving package version... "$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faac" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaac\win32_ver.h" Disabled ../../include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBFAAC_DLL_EXPORTS;_USE_MATH_DEFINES;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 true EditAndContinue /MACHINE:I386 %(AdditionalOptions) true .\libfaac.def true MachineX86 Retrieving package version... "$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faac" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaac\win32_ver.h" faac-1_30/project/msvc/libfaac_dll.vcxproj.filters000066400000000000000000000070011355157314300223330ustar00rootroot00000000000000 {35bf31c0-b124-46f6-9087-c32503a1d44b} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {d888c91e-6378-4ac5-ad49-f6ba46864a85} h;hpp;hxx;hm;inl Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Source Files faac-1_30/project/msvc/libfaac_dll_drm.vcxproj000066400000000000000000000165511355157314300215400ustar00rootroot00000000000000 Debug Win32 Release Win32 libfaac_dll_drm {AA2D0EFE-E73D-40AD-ADCE-8A2B54F34C6F} 8.1 DynamicLibrary v141 DynamicLibrary v141 <_ProjectFileVersion>15.0.26730.12 .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ false .\bin\$(Configuration)\ .\intermediate\$(Configuration)\$(ProjectName)\ true OnlyExplicitInline true ../../include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBFAAC_DLL_EXPORTS;DRM;_USE_MATH_DEFINES;%(PreprocessorDefinitions) true MultiThreadedDLL true Level3 true /MACHINE:I386 %(AdditionalOptions) true .\libfaac.def MachineX86 $(OutDir)libfaacdrm.lib Retrieving package version... "$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faac" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaac\win32_ver.h" Disabled ../../include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBFAAC_DLL_EXPORTS;DRM;_USE_MATH_DEFINES;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 true EditAndContinue /MACHINE:I386 %(AdditionalOptions) true .\libfaac.def true MachineX86 $(OutDir)libfaacdrm.lib Retrieving package version... "$(SolutionDir)..\..\utils\win32\ac2ver.exe" "faac" "$(SolutionDir)..\..\configure.ac" > "$(SolutionDir)..\..\libfaac\win32_ver.h" faac-1_30/project/msvc/libfaac_dll_drm.vcxproj.filters000066400000000000000000000105711355157314300232030ustar00rootroot00000000000000 {20c99963-1750-4885-ad2c-cd181cf772b6} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {34e89214-d9ae-4ebf-8bf8-6ae480b13a44} h;hpp;hxx;hm;inl {4cccac5e-3144-404c-b486-e4237c2d461c} Source Files Source Files Source Files Source Files Source Files Source Files Source Files kiss_fft kiss_fft Source Files Source Files Source Files Source Files Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files kiss_fft kiss_fft kiss_fft Header Files Header Files Header Files Header Files Header Files Header Files Header Files Source Files faac-1_30/project/msvc/unistd.h000066400000000000000000000001111355157314300165050ustar00rootroot00000000000000#pragma once #include #define W_OK 2 #define access _access faac-1_30/utils/000077500000000000000000000000001355157314300135575ustar00rootroot00000000000000faac-1_30/utils/win32/000077500000000000000000000000001355157314300145215ustar00rootroot00000000000000faac-1_30/utils/win32/ac2ver.c000066400000000000000000000041651355157314300160550ustar00rootroot00000000000000/* ** AC2VER - extract version number from AC_INIT macro (configure.ac) ** Copyright (C) 2017 LoRd_MuldeR ** ** This software is released under the CC0 1.0 Universal [CC0 1.0] licence! ** https://creativecommons.org/publicdomain/zero/1.0/legalcode **/ #define BUFF_SIZE 4096 #define _CRT_SECURE_NO_WARNINGS 1 #include #include #include #include static int clean_string(char *const str) { size_t i = 0, j = 0; while(str[i]) { if(isalnum(str[i]) || strchr("._-", str[i])) { if(i != j) { str[j] = str[i]; } ++j; } ++i; } str[j] = '\0'; return !!j; } static int parse_version(FILE *const input, const char *const format, char *const version) { char buffer[BUFF_SIZE]; while(!(feof(input) || ferror(input))) { const char *line = fgets(buffer, BUFF_SIZE, input); if(line) { while((*line) && (isspace(*line))) { ++line; /*skip space*/ } if(sscanf(line, format, version) == 1) { if(clean_string(version)) { return 1; /*found!*/ } } } } version[0] = '\0'; return 0; } static int get_version(const wchar_t *const lib_name, const wchar_t *const file_name) { char format[128], version[BUFF_SIZE]; FILE *const input = _wfopen(file_name, L"r"); if(!input) { fprintf(stderr, "Error: Failed to open input file!\n%S\n\n", file_name); return 0; } _snprintf(format, 128, "AC_INIT ( %S , %%s", lib_name); //printf("<%s>\n", format); if(parse_version(input, format, version)) { printf("#define PACKAGE_VERSION \"%s\"\n", version); fclose(input); return 1; } else { fprintf(stderr, "Error: Version string could not be found!\n\n"); fclose(input); return 0; } } int wmain(int argc, wchar_t* argv[]) { if((argc != 3) || (!argv[1][0]) || (!argv[2][0])) { wchar_t file_name[_MAX_FNAME], file_ext[_MAX_EXT]; _wsplitpath(argv[0], NULL, NULL, file_name, file_ext); fprintf(stderr, "AC2VER [%s]\n\n", __DATE__); fprintf(stderr, "Usage: %S%S \n\n", file_name, file_ext); return EXIT_FAILURE; } return get_version(argv[1], argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE; } faac-1_30/utils/win32/ac2ver.exe000066400000000000000000001670001355157314300164120ustar00rootroot00000000000000MZ@ !L!This program cannot be run in DOS mode. $8fEY5EY5EY5^H5YY5^I5,Y5L!p5FY5EY5Y5^}5UY5^M5DY5^~5DY5RichEY5PELis6Z  D!@@OW@H( 0.text `.rdata#$@@.data-@.rsrc @@.reloc 0@BU$t @3ʼnSW]ESGYSEhP} trPYtGuVuW uI338t6>PYu>Ph@YYt ;t>CG<>uu.]SYX3_3[ZŌ3@U츄@3ʼnE}E VWxf?pf>Sh@VYYuVh@n@P fWh@|hP|P|ntPh@a S 3 @h@ @PV S 33Ʌ[^|Q|Qjj0 hH@hT@@P |P|Phd@@P 3@M_3^; @uEUEu3]Ë@ ]ËUEu3]Ë@ ]ËU eWjY3}_uY9E tVYEIuuM;wEuEuu PUËUVuEPju h&@v^]ËUEVF uc.FHlHhN; h@t @HpuA,F;(@tF @Hpu$FF@puHpF  @F^]Uu MfE~EPju0 MH}tMapËU=LAuE X@A]juYY]ËUu ME~EPhu80 MH%}tMapËU=LAuE X@A%]ju~YY]ËUu MaE~EPju/ MH}tMapËU=LAuE X@A]juYY]ËUu ME~EPhu3/ MH%}tMapËU=LAuE X@A%]ju~YY]ø@áAVj^u;}ƣAjP1YY AujV5A1YY AujX^3ҹ@ A  @|j^3ҹ@W At;tu1 Bp@|_3^7=|At{25 A62YËUVu@;r"`@w+Q8N Y V@^]ËUE}P8E H Y]ËE P@]ËUE@;r=`@w` +P7Y]à P@]ËUME }` QZ7Y]à P@]̍B[Í$d$3D$ST$t :tτtQu WV ؋ ~333ƃu%t%uu^_[3ËB:t6t:t't:tt:tt^_B[ÍB^_[ÍB^_[ÍB^_[j h@v;3}3];;u  3{3u ;;t3f9>;t9E;u ɉ}f9;u jEPh@< PuVS6EE E;u YËUj@u u0 ]ËU SW3j3Y}]9]u:  uM Vu;t;u  PE;wMEPSuEPEBuud?;tMxE EPSL=YY^_[jh@9]]3;u9M t 0 339M ;t3u;;t9M tډuVtYeF @uoVKYttȃ Ax@A$u)tt Ax@@$t  e}t:M t2Nx AVLJYEu ;ue G}< uE E9ËuVYj h@8339u;uZ _j [PjYYuxPKYE PVu`P=EPPWtKE E{8* PjYYá@39@ËUQMS3VWU;} ;u9Uux9Utq9Uu9Uug9Ut`9Uu9U uV9U tO9U$uE9U(uE3@f9tH;wf>:u9;t}!jQjWJ3҃u9U(uE;t3f33ۋf;tTf/tf\t f.u~f;u;t,9Ut +9EPQju_J3҉} E;t3f8;tG;rC9Ut+9E vgPQju#JM39U$tE+9u(vEVSju$J+9Ut+9u v&VQjuI3ҋE$;t3f3_^[3ҋE ;t 9Uv3f0E;t 9Uv3f0E;t 9U v3f0E$;t 9U(v3f0;uj^0t9Uuj"Y닋UMɸ#QuM#QMu#ȋE QuPu u$]j h@53ۉ]3};;u?39] ;t܉}W8Y]G @uoWGYttȃ Ax@A$u)tt Ax@@$tPM9]u#WnGEPSu W:EWVGE E4uYËUVuWuA DF t8V<-VIVFP&IyFt PN)fYf _^]j h(@.4M3uuj F @t f E:4VYeV]u ]FE /F<-uqtm]tfF:s{{:{s,{*ЋσdzDGJu苝L{D2ȊЋDL<]cD@b+u.du t ƅs\t ؉l0\t؉lxt_XtZLxDžTt&HtdusDžLo.tt\SDYYj0[\tlH؉ltdd}sDžLxF@xGrtt\PCYY;c4cZt@3f@ƅ{l-u ƅY+u.du t ƅs\tx؉l(<sLxt]LptTPzYLou88<Kjj <8E0PYtk8<SYlTCЙH8f>D[GDd<%u8GuG\tGlD;uwPBYt%\tGD;u7tlu?%uNDxnuB4lt\P?YYt\l?YY0u PYlu*4u 8[ut% apt `p4[M_3^6-t"t t Ht3øøøøËVWh3FWP$;3ȋ~~~  ~@ F+ο@Ou@Nu_^ËU@3ʼnESWPv$@3@;rƅ t0;w+@P j Ra: Cujv vPWPjj D3SvWPWPWv SBDSvWPWPhv SB$3EtLtL @;rRDž3)ЍZ w LQ w L QA;rƋM_3[j hh@ @Gptltwhuj Yj )Yewhu;5(@t6tV,@u@tV+Y(@Gh5(@uV(@E뎋uj YËUS3SMH Au A4@8]tEMapE,@D;FG;v}>uЋuE}urlj{CijC C4@Zf1f0JuL@;v~0C@IuCC Ss3ȋ {95 ATM_^3[ jh@M}_huqE;CWh " Y؅Fwh#SuYYEuvh,@uFh=@tP Y^hS=(@Fp @j YeC0AC4AC 8A3E}fLCf E$A@3E=} L @@3E=}(@@5(@,@u(@=@tPJ Y(@SE0j Y%u @tS YeE:Ã=| AujVY| A3ËUSV5(@W}W֋tP֋tP֋tP֋tP֍_PE{$@t tPփ{t CtPփMu֋P_^[]ËUW}SV5,@W֋tP֋tP֋tP֋tP֍_PE{$@t tPփ{t CtPփMu֋P^[_]ËUSVu3W;to=(@th;t^9uZ;t9uPs AYY;t9uPR @YY: / YY;tD9u@-P +P +P =(@t9uP< YY~PE$@t;t 9uP Y9_tG;t 9uP} YMuVn Y_^[]ËUW} t;Et4V0;t(W8jYtV>Yu@tVsY^3_]j h@  @Fpt"~ltpluj Yj Ye5h@lVYYYEEj Yuj@<@V5p@@@u5@A@V5p@D@^ál@tP5HA@Ѓ l@p@tPH@ p@ jh@h@L@uF\(@f3G~~pƆCƆKCFh@j Yevh(@E>j Y}E Fluh@FlvlYE3Guj k Yj b YËVWX@5l@ЋuNhjTYYt:V5l@5DA@ЅtjVYYT@N VY3WP@_^ËVuj Y^jh@uF$tPYF,tPYF4tPYFWl@t3%>uN@ uNhF Ph@t,F N@Ch5 A`@3_[^ÃUVW3u9Yu'9PAvVx@;PAvuʋ_^]ËUVW3ju u5: u'9PAvVx@;PAvuË_^]ËUVW3u um:YYu,9E t'9PAvVx@;PAvu_^]ËUVW3uu u: u,9Et'9PAvVx@;PAvu_^]ËU}t-uj5 A|@uVX@P5Y^]jh@ 3ۉ]j|Y]j_};=A}T A9tE@ tPBYtE|( A Pt@ A4TY AGE Et j!YËUhp@L@th`@P\@tu]ËUuYu@jYjYËV+V.<VV<V;V9V9^ËUVu3utу;u r^]ËU= Ath A=Yt u AY<-h @h@YYuTVWhp@<@@Y;stЃ;r= A_^th Ag=Yt jjj A3]j h8@jYe3@9AAE|A} 5x A5@֋؉]Ѕth5t A֋}ԉ]܉}؃};rK9t;r>7֋5x A֋5t A9]u9Et]܉]ЉE؋}ԋ]E$@}0@sEtЃEE4@}8@sEtЃEE }u)AjYu}tjYËUjju ]ËUjju ]jjj jjjz ËU,uuYh̋USVuF Ȁ3ۀu@t9FW>+~,WPVkYP(C ;uF yF N _Ff^[]ËUVuu V5Y/V|YtF @tVPCYY3^]jhX@~3}}jBY}3u;5A A98t^@ tVPVQYY3BU AH t/9UuPJYtE9}utP/Yu E܉}F3uࡨ A4VZYYE}EtEjYjYËVW3A<@u@8h0h@t F$|3@_^Ã$@3St@V@W>t~t WW=&Y@|ܾ@_t ~uPӃ@|^[ËUE4Ÿ@@]j h@3G}39 AujhYYu4@9tmjvY;uF 3Pj XY]9u+hWh@uWlY ] >WQYE E|j )YËUEV4Ÿ@>uP#YujY6@^]ËUD A3SVu EUUUf> tat0rt#wth 3a 3ۃM M3AWf;y@St  tRHtCt- t!9EE @@EE ljE}utE nTtZtEHt0 tuE G}u;eE1}u% UEut3 ؃f}j _f9>tjVh@I f9>tf>=uuf9>tjh@VH u Ajh@VH u "jh@VH uf> t3f9>tChuE SuP@Gt3 E@MH M x8xxH_^[jh@533}jY]3u;5A A9t[@ uHuAFwFPY A4VYY A@ t PV7YYF둋}cj8xY A;tNh A Ph@ Au4sY A P@ A<}_ ;tg ___OE `Ë}j Yh0T@d5D$l$l$+SVW@1E3PeuEEEEdËMd Y__^[]Q̋US] Vs35@WEE{t N3 8N F3 8ѽE@fMUS[ EMt_I[LDEEtEx@GE؃u΀}t$t N3 8^N V3 :NE_^[]EɋM9csmu)=l At hl A3tUjRl AM UE 9X th@WӋE MH t N3 8ȼN V3 :踼EH*9S Oh@WASVWT$D$L$URPQQhPV@d5@3ĉD$d%D$0XL$,3p t;T$4t;v.4v\ H {uhCbFCtFd_^[ËL$At3D$H3ڻUhp pp> ]D$T$UL$)qqq( ]UVWS33333[_^]ËjE33333USVWjRhV@Q^_^[]Ul$RQt$ ]UQVu VE F YuN N /@t 3"S3ۨt^NF F F ^] u,: ;t .@;u u FYuVpFYF WF>HN+IN;~WPu 8 EM F yM tt Ax@@ tjSSQ E#ƒt%FM3GWEPu 7 E9}t N E%_[^A @tyt$Ix  QPvYYu ËUQC @VEt {uE >'} ~0EM E>u?*u˰?~} Ճ?uE^ËU@3ʼnES] Vu3W}uǹ u+t `p7 F @u^V} Yx@ttȃ AA$uttȃ A@$q3;g C39y B@Dž W @9} DžjugucDžW9~~=]VYt Dž5@GPPSP5@ЋtuPS5@YYguuPS5@YY;-uCSDž*snHHXDž'Dž2Qƅ0Dž t@tGGG@t3҉@t|sځu39} Dž9~ u!u t-RPWS>0؋9~N뽍E+Ftbt΀90tW0@?If90tu+(u @I8t@u+@t5t ƅ-t ƅ+ tƅ Dž++ u% O0tP2YYt.u%˰0Otヽtu~qPjEPP,<u69t.EPYYu#P]YY|2t) Ot߃t8Ytrt `pM_^3[ZÐ\@Z@Z@[@f[@q[@[@\@UVuu[F @t F F u V8YFvvVYPA FF uQVYt0VYt$WVtV< AdYY_x@@$^^N 3_@[3^]ËU}t'Vu F tVf f&fY^]ËUUS]VWuu9U u3_^[]Åt} u#j^0Ǽ݅u3fЋMu3fԋƒu+fft'Ou"+ fftOtKuu3fy3uM jPfDJXdf蔼j"YjUVuWV@YtP Au u u@DtjV@jM@YY;tVA@YP@u X@3V? AYD0t WY3_^]jh@0]u ˻ x; Ar迻 褻 Gҋ< AD0tS?YeD0t SYER ME EË]S;@YËUVuF ttvaf 3YFF^]ËUE8csmu*xu$@= t=!t="t=@u 3]hi@@3ËU3M; Ÿ@t @r3]Ëż@]ËU@3ʼnESVuWV3Y;ljvCYjeCYu =@6h@hAWB hAVSfA@uh@SVB t 3PPPPPVcB@Y=u Fd.=u Fd=u Fd=uFdvdjY~d`QY^`[_^]ËV5@W3uf=tGV?YtFfuSjGW|YYlAue5@5V?f>=Yxt"jWIYYtAVWP? uI4~f>u5@%@#p A3Y[_^5lA%lA3PPPPPе̋UQV3W} 9Ut ME1f8"u} 3Ʌj"Yt ffft;uf tf ut3fNe3f9 t u f99Ut ME13G3Bf8\tf8"u8u}t fx"u 339MMJt j\Yfuft$9Uu t tt tf끅t3f} 0E;t_^ËUQQSVWh AV33Sf A@ A5xA;tf9uEPS]3ɋ[]YY?sJMs?Y;r4PYt'EP V]EHYXAY5`A3_^[ËV@3;u3^f9tf9uf9uS+ƍXWS\Yu V@_[^SVW V@@W;stЃ;r_^ËV@@W;stЃ;r_^jhj@3Ʌ AËU@eeSWN@;t t У@eVEP@u3u@3T@3@3EP@E3E3;uO@u G 5@։5@^_[Ã%h A̋T$ L$ti3D$ur=d AtC<Wr1كt +шuʃtt uD$_ËD$UWVu M};v;r=d AtWV;^_uu<ur)$ps@Ǻr $r@$s@$s@r@r@r@#ъFGFGr$ps@I#ъFGr$ps@#ъr$ps@Igs@Ts@Ls@Ds@YtvV.Y[ 3_^]JX@PY2X@PYʋUM S3;vj3X;Es 3AMVW9]t u,YVuYYt;s+VjS _^[]jh@@xte3@ËeE{, hу@@ AËUE$ A( A, A0 A]ËUE @V9Ptk u ;rk M^;s9Pt3]5, A@j h@G3}}؋] KtjY+t"+t+tY+uC赼}؅uT$ A$ AUw\]YpQÃt2t!Ht舟+빾, A, A( A( A 0 A0 AEP@E3}9Euj9EtPHY3Et tuO`MԉG`u>OdMGdu, @M܋ @ @9M}Mk W\DErEuwdSUY]}؃}tjYSUYt tuEԉG`uEЉGd3ËUE8 A]ËUE< A]ËUE@ A]ËU5@ A@tuYt3@]3]ËUQSV5@W5x A5t A؉]֋;+GruS)؍GY;sH;s;rPu\YYuC;r>PuFYYt/P4@x Au=@׉Vףt AE3_^[ËVjj YYV@x At AujX^Ã&3^j h @heuYEE E`ËUuYH]̋UMMZf9t3]ËA<8PEu3ҹ f9H‹]̋UEH<ASVq3WDt} H ;r X;r B(;r3_^[]̋Ujh@@h0T@dPSVW@1E3PEdeEh@*tTE-@Ph@Pt:@$ЃEMd Y_^[]ËE3ҁ9‹ËeE3Md Y_^[]ËU'@3ʼnEE VuW34809}u3;uM83֚S AL8$$?tu'Mu ԚwD8 tjjjVVYD@l39H P4@3;`;t 8?P@4 3,9E#@?g $3 ǃx8tP4UM`8jEPKP Yt:4+M3@;jDSP C@jSDPk n3PPjMQjDQP C@@=j,PVEP$4@ @089,j,PjEP$E 4@,08<t<u!33Ƀ @D<t<uRD$Yf;DI8t)j XPD$Yf;D80E9@8T4D83ɋD8?D49M3+4H;Ms&CA u 0 @F@FrՋH+j(PVHP$4@C(8;;+4;El%?49MH@+4jH^;MsCΉ u0j [f @@fƁ@rH+j(PVHP$4@i(8;a+4;EGK4,9Mu,@+4jH^;Ms;,,΃ uj [f@@fƁ@r3VVhU QH++PPVh@;j(P+P5P$4@t (; X@D;\,+48;E ?Q(Qu448@t(D8 X@D8ulDt-j^9Du 0?DY1$D@t48u3$赔轔 8+0[M_3^Sjh`@]u联 f x; ArZ ? ҋ< AD0tS~YeD0tuu Sn E ME ETË]SYjh@]u蚓 x; Ar{ ڋ< ADtSYeDt1S=YP@u X@Ee}t!M ME E{Ë]SYËU4S3EV]܈]]E ]t ]E E]EP("YEuE@u9EtME+ùtCHt(Ht fIj^0MEt EuE@UEjY+t7+t*+t+t@u9UEEE E]E#¹W;3t(;t$;t=tT=u-ETEKEB=t4=t$;t)脑gj^0 _^[EEEEt TA#MxE@tMMMt } t M tM;u! ͐`E=@juuEPuuu ׉E;upM#;u+Et%ejuEuPuuu ׉E;u76 AD0 X@PTY(Eful@uD6 AD0 X@VYu@uՏ 렃uM@ uMu6Ѓ AYYMLЃ AD$ MeHMuEtpjS6 ;uT8tP6ejEP6q uf}uǙRP6 ;tjj6Q ;tE(@@}uE#u M EE#;tD=t)=@t"=t)=@t"=t=@uEM#;u EEE3E@}E#=@=tq;yE;nvv+[E3HHGEjjWW6 tWWW6 #ƒ;jEP6 ;vtj}uXEE;iWjWW6 JWWW6#;E%=u6Y$j^0u_=uWj6g ;E>WW6M Ej[+PD=P6E ;݃ AD$2M0 AD$M ʀ}u!Etȃ AD M#;u~Etxu@juEjPuE%Pu @;u4X@Pȃ AD 6XY6 AEUSSSSSjh@3}3u;;u聋j^0%Y39};t9}tE%@tʉ}uuu uEP\EEE;t誺3u9}t(9}t AD 6YËUjuuuuu !]ËU3SW9E]u蠊C} tVuM1yExuA+;Ar Zw Ar Zw MtDft?f;t8EPPEPPMt ftf;t+}^tMap_[ËU=LAVuy39Euu趉YcM t+Ar Zw Ar Zw Mt ftf;t+juu u^]ËU}u3]ËU MMtft f;u +]USVWUjjh@uD]_^[]ËL$At2D$H3vUhP(RP$R]D$T$SVWD$UPjh@d5@3PD$dD$(Xp t:|$,t;t$,v-4v L$ H |uhDID_뷋L$d _^[3d y@uQ R 9QuSQ@ SQ@L$ KCk UQPXY]Y[ËUQQE VuEEWVE Y;u螇 NjJuMQuP@E;uX@t P萇Yϋ AD0 EU_^jh@舶]܉]Eu5  Ëx; Ar 蕆ы< AL1tP1 YeD0tuuu uE܉U萆 蘆 ]܉]E E܋Uum YËU@hiYMAt I AI AAAAa]ËUEu 3]Åx; Ar 臅ދȃ AD@]ËUSVu 3W};u;v E;t3{E;tv|j^0 VuMtE9XfEf;v6;t;v WSV9 1*&8]tMap_^[;t&;w j"^0誄8]tE`pyE;t8]Jbz0BRz*DRl|$4FZhz@<@+@@i@`@@@P@HH:mm:ssdddd, MMMM dd, yyyyMM/dd/yyPMAMDecemberNovemberOctoberSeptemberAugustJulyJuneAprilMarchFebruaryJanuaryDecNovOctSepAugJulJunMayAprMarFebJanSaturdayFridayThursdayWednesdayTuesdayMondaySundaySatFriThuWedTueMonSunHH:mm:ssdddd, MMMM dd, yyyyMM/dd/yyPMAMDecemberNovemberOctoberSeptemberAugustJulyJuneAprilMarchFebruaryJanuaryDecNovOctSepAugJulJunMayAprMarFebJanSaturdayFridayThursdayWednesdayTuesdayMondaySundaySatFriThuWedTueMonSunKERNEL32.DLLFlsFreeFlsSetValueFlsGetValueFlsAlloc  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~CorExitProcessmscoree.dllccsUTF-8UTF-16LEUNICODE(null)(null)EEE50P( 8PX700WP `h````xpxxxxruntime error TLOSS error SING error DOMAIN error R6033 - Attempt to use MSIL code from this assembly during native code initialization This indicates a bug in your application. It is most likely the result of calling an MSIL-compiled (/clr) function from a native constructor or from DllMain. R6032 - not enough space for locale information R6031 - Attempt to initialize the CRT more than once. This indicates a bug in your application. R6030 - CRT not initialized R6028 - unable to initialize heap R6027 - not enough space for lowio initialization R6026 - not enough space for stdio initialization R6025 - pure virtual function call R6024 - not enough space for _onexit/atexit table R6019 - unable to open console device R6018 - unexpected heap error R6017 - unexpected multithread lock error R6016 - not enough space for thread data R6010 - abort() has been called R6009 - not enough space for environment R6008 - not enough space for arguments R6002 - floating point support not loaded X@@ @ `@@@`@@@H@@h@@@@ @!@x@yx@z\@T@4@Microsoft Visual C++ Runtime Library ...<program name unknown>Runtime Error! Program:   ((((( H h(((( H H  !"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~EEE00P('8PW700PP (`h`hhhxppwppGetProcessWindowStationGetUserObjectInformationWGetLastActivePopupGetActiveWindowMessageBoxWUSER32.DLLCONOUT$._-rError: Failed to open input file! %S AC_INIT ( %S , %%s#define PACKAGE_VERSION "%s" Error: Version string could not be found! Dec 17 2017AC2VER [%s] Usage: %S%S @@@@@V!@j!@8@<@'@@RA@aA@C@ C@I@L@N@M@O@S@Mi@@@ޅ@@ˈ@ވ@@@l@@w@@H@@pp *>Jbz0BRz*DRl|$4FZhzEnterCriticalSection9LeaveCriticalSectionGetCommandLineWHeapSetInformationTerminateProcessGetCurrentProcessUnhandledExceptionFilterSetUnhandledExceptionFilterIsDebuggerPresentrGetCPInfoInterlockedIncrementInterlockedDecrementhGetACP7GetOEMCP IsValidCodePageTlsAllocTlsGetValueTlsSetValueTlsFreeGetModuleHandleWsSetLastErrorGetCurrentThreadIdGetLastErrorEGetProcAddressoSetHandleCountdGetStdHandleInitializeCriticalSectionAndSpinCountGetFileTypecGetStartupInfoWDeleteCriticalSectionSleepHeapFreeExitProcessRtlUnwindRCloseHandle%WriteFileGetModuleFileNameWaFreeEnvironmentStringsWGetEnvironmentStringsWHeapCreateQueryPerformanceCounterGetTickCountGetCurrentProcessIdyGetSystemTimeAsFileTimegMultiByteToWideCharWideCharToMultiByte-LCMapStringWiGetStringTypeWHeapAllocHeapReAlloc?LoadLibraryWGetConsoleCPGetConsoleModeWFlushFileBuffersCreateFileWfSetFilePointerReadFileSetStdHandleIsProcessorFeaturePresentHeapSize$WriteConsoleWSSetEndOfFileJGetProcessHeapKERNEL32.dll A AN@D        ! 5A CPR S WY l m pr   )     abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@`y!@~ڣ @ڣ AϢ[@~QQ^ _j21~C@@@@@@|@t@l@d@X@L@D@8@4@0@,@(@$@ @@@@@ @@@@@@$@@@@@@@@@@@x@l@ d@\@T@L@D@<@4@$@@@@@@@@@@@@@@x@p@h@`@X@H@4@(@@@@@@@@@@@@@\@H@$@$@$@$@$@(@@P@@(@@@ @@@@@@@@@@@@.. @ A A A A A A A A A$@ A A A A A A A(@@@. е@е@0 HX Z PAPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPAD00 1?1S1i11112$2L2*3c3k3334$4445)555555566#6*696E6R6v66666677&7J7y7Q889Y:`::: ;;; >>>>>? 060C0P0\0h0n0000000#1(1/15111111111111112 222&2+212;2D2O2[2`2p2u2{2222223333344K4g4446666==0tx666<8M8888888889!9+9>9b9999Q:n::&;E;;;;;<<<->+????@`070>0J0P0\0b0k0q0z000000000000 101p1v1111112z222220363L3Q3Y3_3f3l3s3y3333333333333333334 444!4&4-4<4A4G4P4p4v44n5555 66%6l6v66666+7=7k777777 888X8a8m8888888939<9c9p9u9999999^:f:y:::::::::: ;;;.;4;E;~;;;;;;7>A>S>j>x>~>>>>>>>>?[????PX111 2o222223/3@3M3T3d3v3{333B45$5<5W55556889999^:m::=>`|'0j0002444455 5555668L8V8n88889999 :R:j:t:::::::;2;O;;;6=s=======s??????p00R0m0r0000000 11 1(141]1e1p11*2\2t2{2222222233 33333 3j3p3t3x3|33344444=4g44444444445 5555}5556L7777M88/99y::5; ?2?D?V?h???????? 0000B0T0f01111s2y22223:3R33 444$4)4.434C4r4x44445 5555#515555)686G6T6Z666667 77>7C7H7_7H8M8_8}888 9k9:.:;G;;==>>>@?_??d.0V0001P1Z1J3354H4g4y4444477.8U8u888889:;;;u<<<<=!=?={==->>>??1F1233?4N44455Q666677778)8A8a88889>9k9v99999 :I:n:{::::;Z;};;;;;;;;;;;;;;<<<<#<^>??8s0y00000112 2{2233?3k344P5V5[5a5r555H 11111(1,1@1D1>>>>>>>>>? ???$?,?4?8>D>00(8(9,9094989<9@9D9H9L9P9T9X9\9`9d9h9l9p9t9x9|999999999999999999999999999999::: ::::: :$:(:,:0:4:8:<:@:D:H:L:P:T:X:\:`:d:h:l:p:t:x:|::::::;;(;L;X;\;`;d;h;t;<<<<<<=== ===(=,=0=4=8=<=@=D=H=L=X=\=`=d=h=l=p=t=x=|==>>