diff options
| author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
|---|---|---|
| committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
| commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
| tree | 9b20069d5e62809ff434061ad730096836f916f2 /apps/codecs/libffmpegFLAC | |
| parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
| download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.bz2 rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.xz | |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'apps/codecs/libffmpegFLAC')
| -rw-r--r-- | apps/codecs/libffmpegFLAC/COPYING | 504 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/README | 19 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/README.rockbox | 46 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/SOURCES | 7 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/arm.S | 271 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/arm.h | 8 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/bitstream.h | 79 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/coldfire.S | 535 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/coldfire.h | 11 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/decoder.c | 627 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/decoder.h | 49 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/golomb.h | 110 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/libffmpegFLAC.make | 18 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/shndec.c | 481 | ||||
| -rw-r--r-- | apps/codecs/libffmpegFLAC/shndec.h | 52 |
15 files changed, 0 insertions, 2817 deletions
diff --git a/apps/codecs/libffmpegFLAC/COPYING b/apps/codecs/libffmpegFLAC/COPYING deleted file mode 100644 index 223ede7..0000000 --- a/apps/codecs/libffmpegFLAC/COPYING +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 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 Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - 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 Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -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 and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -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 other code 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. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - 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, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser 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 combine 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) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) 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. - - d) 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. - - e) 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 materials to be 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 with -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 Lesser 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. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - 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 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 - -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. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/apps/codecs/libffmpegFLAC/README b/apps/codecs/libffmpegFLAC/README deleted file mode 100644 index 9bc0f6e..0000000 --- a/apps/codecs/libffmpegFLAC/README +++ /dev/null @@ -1,19 +0,0 @@ -FFmpeg README -------------- - -1) Documentation ----------------- - -* Read the documentation in the doc/ directory. - -2) Licensing ------------- - -* Read the file COPYING. ffmpeg and the associated libraries EXCEPT - liba52 and libpostproc are licensed under the Lesser GNU General - Public License. - -* liba52 and libpostproc are distributed under the GNU General Public - License and their compilation and use is optional in ffmpeg. - -Fabrice Bellard.
\ No newline at end of file diff --git a/apps/codecs/libffmpegFLAC/README.rockbox b/apps/codecs/libffmpegFLAC/README.rockbox deleted file mode 100644 index 850cdfc..0000000 --- a/apps/codecs/libffmpegFLAC/README.rockbox +++ /dev/null @@ -1,46 +0,0 @@ -Library: libffmpegFLAC -Imported: 2005-10-26 by Dave Chapman - -This directory contains a FLAC decoder based on the flac.c (and a small -number of other files) from the ffmpeg project. - -LICENSING INFORMATION - -ffmpeg is licensed under the Lesser GNU General Public License and the -file flac.c is Copyright 2003 Alex Beregszaszi. - -IMPORT DETAILS - -The decoder is based on ffmpeg-cvs from 26 October 2005. - -The file libavcodec/flac.c was renamed to decoder.c and all ffmpeg -related code was removed. It was also heavily modified to remove -debugging information and unused experiemental code. - -It was also changed to provide output as 32-bit integers (with the -data left-shifted to 28 bit accuracy). The original flac.c provided -16-bit output. - -In order to minimise memory usage, a small number of hard-coded limits -are present in decoder.h - mainly limiting the supported blocksize -(number of samples in a frame) to 4608. This is the default value -used by the reference FLAC encoder at all standard compression -settings. - - -TESTING - -A test program is contained in the file main.c and this should compile -in any Unix-like environment using the command "make -f Makefile.test". - -Running "test file.flac" will decode the audio data to a WAV file -called "test.wav" in the current directory. This has been tested with -16-bit and 24-bit mono and stereo FLAC files. - -This can be used to test the accuracy of the decoder by comparing the -md5sum of the WAV file produced by this decoder with a WAV file -produced by the official libFLAC decoder. - -This test program could be extended to perform an internal md5sum -calculation and comparing that against the md5sum stored in the FLAC -file's header. diff --git a/apps/codecs/libffmpegFLAC/SOURCES b/apps/codecs/libffmpegFLAC/SOURCES deleted file mode 100644 index 63094b3..0000000 --- a/apps/codecs/libffmpegFLAC/SOURCES +++ /dev/null @@ -1,7 +0,0 @@ -decoder.c -shndec.c -#if defined(CPU_COLDFIRE) -coldfire.S -#elif defined(CPU_ARM) -arm.S -#endif diff --git a/apps/codecs/libffmpegFLAC/arm.S b/apps/codecs/libffmpegFLAC/arm.S deleted file mode 100644 index 8adca77..0000000 --- a/apps/codecs/libffmpegFLAC/arm.S +++ /dev/null @@ -1,271 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 by Thom Johansen - * - * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" - -/* The following is an assembler optimised version of the LPC filtering - routines needed for FLAC decoding. It is optimised for use with ARM - processors. - All LPC filtering up to order 9 is done in specially optimised unrolled - loops, while every order above this is handled by a slower default routine. - */ -#ifdef USE_IRAM - .section .icode,"ax",%progbits -#else - .text -#endif - .global lpc_decode_arm -lpc_decode_arm: - stmdb sp!, { r4-r11, lr } - ldr r4, [sp, #36] - /* r0 = blocksize, r1 = qlevel, r2 = pred_order - r3 = data, r4 = coeffs - */ - - /* the data pointer always lags behind history pointer by 'pred_order' - samples. since we have one loop for each order, we can hard code this - and free a register by not saving data pointer. - */ - sub r3, r3, r2, lsl #2 @ r3 = history - cmp r0, #0 @ no samples to process - beq .exit - cmp r2, #9 @ check if order is too high for unrolled loops - addls pc, pc, r2, lsl #2 @ jump to our unrolled decode loop if it exists -@ jumptable: - b .default @ order too high, go to default routine - b .exit @ zero order filter isn't possible, exit function - b .order1 - b .order2 - b .order3 - b .order4 - b .order5 - b .order6 - b .order7 - b .order8 - -@ last jump table entry coincides with target, so leave it out -.order9: - ldmia r4, { r5-r12, r14 } @ fetch coefs -.loop9: - ldr r4, [r3], #4 @ load first history sample - mul r2, r4, r14 @ multiply with last coef - ldr r4, [r3], #4 @ rinse and repeat while accumulating sum in r2 - mla r2, r4, r12, r2 - ldr r4, [r3], #4 - mla r2, r4, r11, r2 - ldr r4, [r3], #4 - mla r2, r4, r10, r2 - ldr r4, [r3], #4 - mla r2, r4, r9, r2 - ldr r4, [r3], #4 - mla r2, r4, r8, r2 - ldr r4, [r3], #4 - mla r2, r4, r7, r2 - ldr r4, [r3], #4 - mla r2, r4, r6, r2 - ldr r4, [r3], #4 - mla r2, r4, r5, r2 - ldr r4, [r3] @ r4 = residual - add r2, r4, r2, asr r1 @ shift sum by qlevel bits and add residual - str r2, [r3], #-8*4 @ save result and wrap history pointer back - subs r0, r0, #1 @ check if we're done - bne .loop9 @ nope, jump back - b .exit - -.order8: - ldmia r4, { r5-r12 } -.loop8: - @ we have more registers to spare here, so start block reading - ldmia r3!, { r4, r14 } - mul r2, r4, r12 - mla r2, r14, r11, r2 - ldmia r3!, { r4, r14 } - mla r2, r4, r10, r2 - mla r2, r14, r9, r2 - ldmia r3!, { r4, r14 } - mla r2, r4, r8, r2 - mla r2, r14, r7, r2 - ldmia r3!, { r4, r14 } - mla r2, r4, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-7*4 - subs r0, r0, #1 - bne .loop8 - b .exit - -.order7: - ldmia r4, { r5-r11 } -.loop7: - ldmia r3!, { r4, r12, r14 } - mul r2, r4, r11 - mla r2, r12, r10, r2 - mla r2, r14, r9, r2 - ldmia r3!, { r4, r12, r14 } - mla r2, r4, r8, r2 - mla r2, r12, r7, r2 - mla r2, r14, r6, r2 - ldr r4, [r3], #4 - mla r2, r4, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-6*4 - subs r0, r0, #1 - bne .loop7 - b .exit - -.order6: - ldmia r4, { r5-r10 } -.loop6: - ldmia r3!, { r4, r11-r12, r14 } - mul r2, r4, r10 - mla r2, r11, r9, r2 - mla r2, r12, r8, r2 - mla r2, r14, r7, r2 - ldmia r3!, { r4, r11 } - mla r2, r4, r6, r2 - mla r2, r11, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-5*4 - subs r0, r0, #1 - bne .loop6 - b .exit - -.order5: - ldmia r4, { r5-r9 } -.loop5: - ldmia r3!, { r4, r10-r12, r14 } - mul r2, r4, r9 - mla r2, r10, r8, r2 - mla r2, r11, r7, r2 - mla r2, r12, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-4*4 - subs r0, r0, #1 - bne .loop5 - b .exit - -.order4: - ldmia r4, { r5-r8 } -.loop4: - ldmia r3!, { r4, r11-r12, r14 } - mul r2, r4, r8 - mla r2, r11, r7, r2 - mla r2, r12, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-3*4 - subs r0, r0, #1 - bne .loop4 - b .exit - -.order3: - ldmia r4, { r5-r7 } -.loop3: - ldmia r3!, { r4, r12, r14 } - mul r2, r4, r7 - mla r2, r12, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-2*4 - subs r0, r0, #1 - bne .loop3 - b .exit - -.order2: - ldmia r4, { r5-r6 } -.loop2: - ldmia r3!, { r4, r14 } - mul r2, r4, r6 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-1*4 - subs r0, r0, #1 - bne .loop2 - b .exit - -.order1: - ldr r5, [r4] @ load the one coef we need - ldr r4, [r3], #4 @ load one history sample, r3 now points to residual -.loop1: - mul r2, r4, r5 @ multiply coef by history sample - ldr r4, [r3] @ load residual - add r4, r4, r2, asr r1 @ add result to residual - str r4, [r3], #4 @ place r3 at next residual, we already have - subs r0, r0, #1 @ the current sample in r4 for the next iteration - bne .loop1 - b .exit - -.default: - /* we do the filtering in an unrolled by 4 loop as far as we can, and then - do the rest by jump table. */ - add r5, r4, r2, lsl #2 @ need to start in the other end of coefs - mov r7, r2, lsr #2 @ r7 = coefs/4 - mov r14, #0 @ init accumulator -.dloop1: - ldmdb r5!, { r8-r11 } - ldmia r3!, { r6, r12 } - mla r14, r6, r11, r14 - mla r14, r12, r10, r14 - ldmia r3!, { r6, r12 } - mla r14, r6, r9, r14 - mla r14, r12, r8, r14 - subs r7, r7, #1 - bne .dloop1 - - and r7, r2, #3 @ get remaining samples to be filtered - add pc, pc, r7, lsl #2 @ jump into accumulator chain -@ jumptable: - b .dsave @ padding - b .dsave - b .oneleft - b .twoleft -@ implicit .threeleft - ldr r12, [r5, #-4]! - ldr r8, [r3], #4 - mla r14, r12, r8, r14 -.twoleft: - ldr r12, [r5, #-4]! - ldr r8, [r3], #4 - mla r14, r12, r8, r14 -.oneleft: - ldr r12, [r5, #-4]! - ldr r8, [r3], #4 - mla r14, r12, r8, r14 - -.dsave: - ldr r12, [r3] @ load residual - add r14, r12, r14, asr r1 @ shift sum by qlevel bits and add residual - str r14, [r3], #4 @ store result - sub r3, r3, r2, lsl #2 @ and wrap history pointer back to next first pos - subs r0, r0, #1 @ are we done? - bne .default @ no, prepare for next sample - -.exit: - ldmpc regs=r4-r11 - diff --git a/apps/codecs/libffmpegFLAC/arm.h b/apps/codecs/libffmpegFLAC/arm.h deleted file mode 100644 index 39080d7..0000000 --- a/apps/codecs/libffmpegFLAC/arm.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _FLAC_ARM_H -#define _FLAC_ARM_H - -#include "bitstream.h" - -void lpc_decode_arm(int blocksize, int qlevel, int pred_order, int32_t* data, int* coeffs); - -#endif diff --git a/apps/codecs/libffmpegFLAC/bitstream.h b/apps/codecs/libffmpegFLAC/bitstream.h deleted file mode 100644 index 5fc3460..0000000 --- a/apps/codecs/libffmpegFLAC/bitstream.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file bitstream.h - * bitstream api header. - */ - -#ifndef BITSTREAM_H -#define BITSTREAM_H - -#include <inttypes.h> -#include "ffmpeg_get_bits.h" - -#ifndef BUILD_STANDALONE - #include <config.h> - #include <system.h> -#else - #include <stdio.h> - #define IBSS_ATTR - #define ICONST_ATTR - #define ICODE_ATTR -#endif - -#if (CONFIG_CPU == MCF5250) || (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) -#define ICODE_ATTR_FLAC ICODE_ATTR -#define IBSS_ATTR_FLAC IBSS_ATTR -/* Enough IRAM to move additional data to it. */ -#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR -#define IBSS_ATTR_FLAC_XLARGE_IRAM - -#elif defined(CPU_S5L870X) -#define ICODE_ATTR_FLAC ICODE_ATTR -#define IBSS_ATTR_FLAC IBSS_ATTR -/* Enough IRAM to move even more additional data to it. */ -#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR -#define IBSS_ATTR_FLAC_XLARGE_IRAM IBSS_ATTR - -#else -#define ICODE_ATTR_FLAC ICODE_ATTR -#define IBSS_ATTR_FLAC IBSS_ATTR -/* Not enough IRAM available. */ -#define IBSS_ATTR_FLAC_LARGE_IRAM -#define IBSS_ATTR_FLAC_XLARGE_IRAM -#endif - -/* Endian conversion routines for standalone compilation */ -#ifdef BUILD_STANDALONE - #ifdef BUILD_BIGENDIAN - #define betoh32(x) (x) - #define letoh32(x) swap32(x) - #else - #define letoh32(x) (x) - #define betoh32(x) swap32(x) - #endif - - /* Taken from rockbox/firmware/export/system.h */ - - static inline unsigned short swap16(unsigned short value) - /* - result[15..8] = value[ 7..0]; - result[ 7..0] = value[15..8]; - */ - { - return (value >> 8) | (value << 8); - } - - static inline unsigned long swap32(unsigned long value) - /* - result[31..24] = value[ 7.. 0]; - result[23..16] = value[15.. 8]; - result[15.. 8] = value[23..16]; - result[ 7.. 0] = value[31..24]; - */ - { - unsigned long hi = swap16(value >> 16); - unsigned long lo = swap16(value & 0xffff); - return (lo << 16) | hi; - } -#endif - -#endif /* BITSTREAM_H */ diff --git a/apps/codecs/libffmpegFLAC/coldfire.S b/apps/codecs/libffmpegFLAC/coldfire.S deleted file mode 100644 index efbb907..0000000 --- a/apps/codecs/libffmpegFLAC/coldfire.S +++ /dev/null @@ -1,535 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 by Thom Johansen - * - * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* The following are assembler optimised version of the LPC filtering - routines needed for FLAC decoding. They is optimised for use with the - MCF5249 processor, or any other similar ColdFire core with the EMAC unit. - */ - -/* This routine deals with sample widths 16 and lower. All LPC filtering up to - order 10 is done in specially optimised unrolled loops, while every order - above this is handled by a slower default routine. - */ - .section .icode,"ax",@progbits - .global lpc_decode_emac - .align 2 -lpc_decode_emac: - lea.l (-44, %sp), %sp - movem.l %d2-%d7/%a2-%a6, (%sp) - movem.l (44+4, %sp), %d0-%d2/%a0-%a1 - /* d0 = blocksize, d1 = qlevel, d2 = pred_order - a0 = data, a1 = coeffs - */ - - /* the data pointer always lags behind history pointer by 'pred_order' - samples. since we have one loop for each order, we can hard code this - and free a register by not saving data pointer. - */ - move.l %d2, %d3 - neg.l %d3 - lea.l (%a0, %d3.l*4), %a0 | history - clr.l %d3 - move.l %d3, %macsr | we'll need integer mode for this - tst.l %d0 - jeq .exit | zero samples to process, exit - moveq.l #10, %d3 - cmp.l %d3, %d2 - jgt .default | order is over 10, jump to default case - jmp.l (2, %pc, %d2.l*4) | jump to loop corresponding to pred_order -| jumptable: - bra.w .exit | zero order filter isn't possible, exit function - bra.w .order1 - bra.w .order2 - bra.w .order3 - bra.w .order4 - bra.w .order5 - bra.w .order6 - bra.w .order7 - bra.w .order8 - bra.w .order9 - -| last jump table entry coincides with target, so leave it out -.order10: - movem.l (%a1), %d3-%d7/%a1-%a5 | load lpc coefs - move.l (%a0)+, %a6 | load first history sample -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (%a0)+, %a6, %acc0 - mac.l %a6, %d4, (%a0)+, %a6, %acc0 - mac.l %a6, %d3, (-9*4, %a0), %a6, %acc0 | load for the next iteration - movclr.l %acc0, %d2 | get sum - asr.l %d1, %d2 | shift sum by qlevel bits - add.l %d2, (%a0) | add residual and save - lea.l (-8*4, %a0), %a0 | point history back at second element - subq.l #1, %d0 | decrement sample count - jne 1b | are we done? - jra .exit - -.order9: - movem.l (%a1), %d4-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (%a0)+, %a6, %acc0 - mac.l %a6, %d4, (-8*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-7*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order8: - movem.l (%a1), %d5-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (-7*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-6*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order7: - movem.l (%a1), %d6-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (-6*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-5*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order6: - movem.l (%a1), %d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (-5*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-4*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order5: - movem.l (%a1), %a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (-4*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-3*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order4: - movem.l (%a1), %a2-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (-3*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #8, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order3: - movem.l (%a1), %a3-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (-2*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #4, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order2: - movem.l (%a1), %a4-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, %acc0 | data for next iteration is already loaded - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #1, %d0 - jne 1b - jra .exit - -.order1: - | no point in using mac here - move.l (%a1), %a5 -1: - move.l %a5, %d2 - muls.l (%a0)+, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #1, %d0 - jne 1b - jra .exit - -.default: - /* we do the filtering in an unrolled by 4 loop as far as we can, and then - do the rest by jump table. */ - lea.l (%a1, %d2.l*4), %a2 | need to start in the other end of coefs - move.l %a0, %a3 | working copy of history pointer - move.l %d2, %d3 - lsr.l #2, %d3 | coefs/4, num of iterations needed in next loop - move.l (%a3)+, %a5 | preload data for loop -1: - lea.l (-4*4, %a2), %a2 | move lpc coef pointer four samples backwards - movem.l (%a2), %d4-%d7 | load four coefs - mac.l %a5, %d7, (%a3)+, %a5, %acc0 - mac.l %a5, %d6, (%a3)+, %a5, %acc0 - mac.l %a5, %d5, (%a3)+, %a5, %acc0 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 - subq.l #1, %d3 | any more unrolled loop operations left? - jne 1b - - moveq.l #3, %d3 | mask 0x00000003 - and.l %d2, %d3 | get the remaining samples to be filtered - jmp.l (2, %pc, %d3*2) | then jump into mac.l chain -| jumptable: - bra.b 3f | none left - bra.b 2f | one left - bra.b 1f | two left -| three left - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -1: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -2: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -3: - movclr.l %acc0, %d3 | get result - asr.l %d1, %d3 | shift qlevel bits right - add.l %a5, %d3 | add residual, which is in a5 by now - move.l %d3, -(%a3) | save, a3 is also one past save location - addq.l #4, %a0 | increment history pointer - subq.l #1, %d0 | decrement sample count - jne .default | are we done? - jra .exit | if so, fall through to exit - - -/* This routine deals with sample widths 24 and lower. All LPC filtering up to - order 8 is done in specially optimised unrolled loops, while every order - above this is handled by a slower default routine. - */ - .global lpc_decode_emac_wide - .align 2 -lpc_decode_emac_wide: - lea.l (-44, %sp), %sp - movem.l %d2-%d7/%a2-%a6, (%sp) - movem.l (44+4, %sp), %d0-%d1/%d3/%a0-%a1 - /* d0 = blocksize, d1 = qlevel, d3 = pred_order - a0 = data, a1 = coeffs - */ - - /* the data pointer always lags behind history pointer by 'pred_order' - samples. since we have one loop for each order, we can hard code this - and free a register by not saving data pointer. - */ - move.l %d3, %d2 - neg.l %d2 - lea.l (%a0, %d2.l*4), %a0 | history - clr.l %d2 - move.l %d2, %macsr | we'll need integer mode for this - tst.l %d0 - jeq .exit | zero samples to process, exit - moveq.l #32, %d2 - sub.l %d1, %d2 | calculate shift amount for extension byte - moveq.l #8, %d4 - cmp.l %d4, %d3 - jgt .wdefault | order is over 8, jump to default case - jmp.l (2, %pc, %d3.l*4) | jump to loop corresponding to pred_order -| jumptable: - bra.w .exit | zero order filter isn't possible, exit function - bra.w .worder1 - bra.w .worder2 - bra.w .worder3 - bra.w .worder4 - bra.w .worder5 - bra.w .worder6 - bra.w .worder7 - -| last jump table entry coincides with target, so leave it out -.worder8: - movem.l (%a1), %d5-%d7/%a1-%a5 | load lpc coefs - move.l (%a0)+, %a6 | load first history sample -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (-7*4, %a0), %a6, %acc0 | load for the next iteration - move.l %accext01, %d4 | get top 8 bits of sum - movclr.l %acc0, %d3 | then botten 32 bits - lsr.l %d1, %d3 | shift bottom bits qlevel bits right - asl.l %d2, %d4 | shift top bits 32 - qlevel bits left - or.l %d4, %d3 | now combine results - add.l %d3, (%a0) | add residual and save - lea.l (-6*4, %a0), %a0 | point history back at second element - subq.l #1, %d0 | decrement sample count - jne 1b | are we done? - jra .exit - -.worder7: - movem.l (%a1), %d6-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (-6*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - lea.l (-5*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder6: - movem.l (%a1), %d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (-5*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - lea.l (-4*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder5: - movem.l (%a1), %a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (-4*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - lea.l (-3*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder4: - movem.l (%a1), %a2-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (-3*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - subq.l #8, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder3: - movem.l (%a1), %a3-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (-2*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - subq.l #4, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder2: - movem.l (%a1), %a4-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, %acc0 | data for next iteration is already loaded - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - subq.l #1, %d0 - jne 1b - jra .exit - -.worder1: - move.l (%a1), %a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %a6, %d3 | residual is already in a6 - move.l %d3, (%a0)+ - subq.l #1, %d0 - jne 1b - jra .exit - -.wdefault: - /* we do the filtering in an unrolled by 4 loop as far as we can, and then - do the rest by jump table. */ - lea.l (%a1, %d3.l*4), %a2 | need to start in the other end of coefs - move.l %a0, %a3 | working copy of history pointer - move.l %d3, %d4 - lsr.l #2, %d4 | coefs/4, num of iterations needed in next loop - move.l (%a3)+, %a5 | preload data for loop -1: - lea.l (-4*4, %a2), %a2 | move lpc coef pointer four samples backwards - movem.l (%a2), %d5-%d7/%a4 | load four coefs - mac.l %a5, %a4, (%a3)+, %a5, %acc0 - mac.l %a5, %d7, (%a3)+, %a5, %acc0 - mac.l %a5, %d6, (%a3)+, %a5, %acc0 - mac.l %a5, %d5, (%a3)+, %a5, %acc0 - subq.l #1, %d4 | any more unrolled loop operations left? - jne 1b - - moveq.l #3, %d4 | mask 0x00000003 - and.l %d3, %d4 | get the remaining samples to be filtered - jmp.l (2, %pc, %d4*2) | then jump into mac.l chain -| jumptable: - bra.b 3f | none left - bra.b 2f | one left - bra.b 1f | two left -| three left - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -1: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -2: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -3: - move.l %accext01, %d5 | get high 32 bits of result - movclr.l %acc0, %d4 | get low 32 bits of result - lsr.l %d1, %d4 | shift qlevel bits right - asl.l %d2, %d5 | shift 32 - qlevel bits left - or.l %d5, %d4 | combine top and low bits after shift - add.l %a5, %d4 | add residual, which is in a5 by now - move.l %d4, -(%a3) | save, a3 is also one past save location - addq.l #4, %a0 | increment history pointer - subq.l #1, %d0 | decrement sample count - jne .wdefault | are we done? - | if so, fall through to exit - -.exit: - movem.l (%sp), %d2-%d7/%a2-%a6 - lea.l (44, %sp), %sp - rts diff --git a/apps/codecs/libffmpegFLAC/coldfire.h b/apps/codecs/libffmpegFLAC/coldfire.h deleted file mode 100644 index d6f0996..0000000 --- a/apps/codecs/libffmpegFLAC/coldfire.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _FLAC_COLDFIRE_H -#define _FLAC_COLDFIRE_H - -#include "bitstream.h" - -void lpc_decode_emac(int blocksize, int qlevel, int pred_order, int32_t* data, - int* coeffs); -void lpc_decode_emac_wide(int blocksize, int qlevel, int pred_order, - int32_t* data, int* coeffs); - -#endif diff --git a/apps/codecs/libffmpegFLAC/decoder.c b/apps/codecs/libffmpegFLAC/decoder.c deleted file mode 100644 index 2e92c4b..0000000 --- a/apps/codecs/libffmpegFLAC/decoder.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * FLAC (Free Lossless Audio Codec) decoder - * Copyright (c) 2003 Alex Beregszaszi - * - * 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 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 - */ - -/** - * @file flac.c - * FLAC (Free Lossless Audio Codec) decoder - * @author Alex Beregszaszi - * - * For more information on the FLAC format, visit: - * http://flac.sourceforge.net/ - * - * This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed - * through, starting from the initial 'fLaC' signature; or by passing the - * 34-byte streaminfo structure through avctx->extradata[_size] followed - * by data starting with the 0xFFF8 marker. - */ - -#include <inttypes.h> -#include <stdbool.h> -#ifndef BUILD_STANDALONE -#include "codeclib.h" -#endif - -#include "bitstream.h" -#include "golomb.h" - -#include "decoder.h" - -#if defined(CPU_COLDFIRE) -#include "coldfire.h" -#elif defined(CPU_ARM) -#include "arm.h" -#endif - -static const int sample_rate_table[] ICONST_ATTR = -{ 0, 88200, 176400, 192000, - 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, - 0, 0, 0, 0 }; - -static const int sample_size_table[] ICONST_ATTR = -{ 0, 8, 12, 0, 16, 20, 24, 0 }; - -static const int blocksize_table[] ICONST_ATTR = { - 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0, -256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7 -}; - -static const uint8_t table_crc8[256] ICONST_ATTR = { - 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, - 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, - 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, - 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, - 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, - 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, - 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, - 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, - 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, - 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, - 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, - 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, - 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, - 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, - 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, - 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, - 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, - 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, - 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, - 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, - 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, - 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, - 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, - 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, - 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, - 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, - 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, - 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, - 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, - 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, - 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, - 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3 -}; - -static int64_t get_utf8(GetBitContext *gb) ICODE_ATTR_FLAC; -static int64_t get_utf8(GetBitContext *gb) -{ - uint64_t val; - int ones=0, bytes; - - while(get_bits1(gb)) - ones++; - - if (ones==0) bytes=0; - else if(ones==1) return -1; - else bytes= ones - 1; - - val= get_bits(gb, 7-ones); - while(bytes--){ - const int tmp = get_bits(gb, 8); - - if((tmp>>6) != 2) - return -2; - val<<=6; - val|= tmp&0x3F; - } - return val; -} - -static int get_crc8(const uint8_t *buf, int count) ICODE_ATTR_FLAC; -static int get_crc8(const uint8_t *buf, int count) -{ - int crc=0; - int i; - - for(i=0; i<count; i++){ - crc = table_crc8[crc ^ buf[i]]; - } - - return crc; -} - -static int decode_residuals(FLACContext *s, int32_t* decoded, int pred_order) ICODE_ATTR_FLAC; -static int decode_residuals(FLACContext *s, int32_t* decoded, int pred_order) -{ - int i, tmp, partition, method_type, rice_order; - int sample = 0, samples; - - method_type = get_bits(&s->gb, 2); - if (method_type > 1){ - //fprintf(stderr,"illegal residual coding method %d\n", method_type); - return -3; - } - - rice_order = get_bits(&s->gb, 4); - - samples= s->blocksize >> rice_order; - - sample= - i= pred_order; - for (partition = 0; partition < (1 << rice_order); partition++) - { - tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5); - if (tmp == (method_type == 0 ? 15 : 31)) - { - //fprintf(stderr,"fixed len partition\n"); - tmp = get_bits(&s->gb, 5); - for (; i < samples; i++, sample++) - decoded[sample] = get_sbits(&s->gb, tmp); - } - else - { - for (; i < samples; i++, sample++){ - decoded[sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); - } - } - i= 0; - } - - return 0; -} - -static int decode_subframe_fixed(FLACContext *s, int32_t* decoded, int pred_order) ICODE_ATTR_FLAC; -static int decode_subframe_fixed(FLACContext *s, int32_t* decoded, int pred_order) -{ - const int blocksize = s->blocksize; - int a, b, c, d, i; - - /* warm up samples */ - for (i = 0; i < pred_order; i++) - { - decoded[i] = get_sbits(&s->gb, s->curr_bps); - } - - if (decode_residuals(s, decoded, pred_order) < 0) - return -4; - - a = decoded[pred_order-1]; - b = a - decoded[pred_order-2]; - c = b - decoded[pred_order-2] + decoded[pred_order-3]; - d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4]; - - switch(pred_order) - { - case 0: - break; - case 1: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += decoded[i]; - break; - case 2: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += b += decoded[i]; - break; - case 3: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += b += c += decoded[i]; - break; - case 4: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += b += c += d += decoded[i]; - break; - default: - return -5; - } - - return 0; -} - -static int decode_subframe_lpc(FLACContext *s, int32_t* decoded, int pred_order) ICODE_ATTR_FLAC; -static int decode_subframe_lpc(FLACContext *s, int32_t* decoded, int pred_order) -{ - int sum, i, j; - int64_t wsum; - int coeff_prec, qlevel; - int coeffs[pred_order]; - - /* warm up samples */ - for (i = 0; i < pred_order; i++) - { - decoded[i] = get_sbits(&s->gb, s->curr_bps); - } - - coeff_prec = get_bits(&s->gb, 4) + 1; - if (coeff_prec == 16) - { - //fprintf(stderr,"invalid coeff precision\n"); - return -6; - } - qlevel = get_sbits(&s->gb, 5); - if (qlevel < 0) - { - //fprintf(stderr,"qlevel %d not supported, maybe buggy stream\n", qlevel); - return -7; - } - - for (i = 0; i < pred_order; i++) - { - coeffs[i] = get_sbits(&s->gb, coeff_prec); - } - - if (decode_residuals(s, decoded, pred_order) < 0) - return -8; - - if ((s->bps + coeff_prec + av_log2(pred_order)) <= 32) { - #if defined(CPU_COLDFIRE) - (void)sum; - lpc_decode_emac(s->blocksize - pred_order, qlevel, pred_order, - decoded + pred_order, coeffs); - #elif defined(CPU_ARM) - (void)sum; - lpc_decode_arm(s->blocksize - pred_order, qlevel, pred_order, - decoded + pred_order, coeffs); - #else - for (i = pred_order; i < s->blocksize; i++) - { - sum = 0; - for (j = 0; j < pred_order; j++) - sum += coeffs[j] * decoded[i-j-1]; - decoded[i] += sum >> qlevel; - } - #endif - } else { - #if defined(CPU_COLDFIRE) - (void)wsum; - (void)j; - lpc_decode_emac_wide(s->blocksize - pred_order, qlevel, pred_order, - decoded + pred_order, coeffs); - #else - for (i = pred_order; i < s->blocksize; i++) - { - wsum = 0; - for (j = 0; j < pred_order; j++) - wsum += (int64_t)coeffs[j] * (int64_t)decoded[i-j-1]; - decoded[i] += wsum >> qlevel; - } - #endif - } - - return 0; -} - -static inline int decode_subframe(FLACContext *s, int channel, int32_t* decoded) -{ - int type, wasted = 0; - int i, tmp; - - s->curr_bps = s->bps; - if(channel == 0){ - if(s->decorrelation == RIGHT_SIDE) - s->curr_bps++; - }else{ - if(s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE) - s->curr_bps++; - } - - if (get_bits1(&s->gb)) - { - //fprintf(stderr,"invalid subframe padding\n"); - return -9; - } - type = get_bits(&s->gb, 6); -// wasted = get_bits1(&s->gb); - -// if (wasted) -// { -// while (!get_bits1(&s->gb)) -// wasted++; -// if (wasted) -// wasted++; -// s->curr_bps -= wasted; -// } -#if 0 - wasted= 16 - av_log2(show_bits(&s->gb, 17)); - skip_bits(&s->gb, wasted+1); - s->curr_bps -= wasted; -#else - if (get_bits1(&s->gb)) - { - wasted = 1; - while (!get_bits1(&s->gb)) - wasted++; - s->curr_bps -= wasted; - //fprintf(stderr,"%d wasted bits\n", wasted); - } -#endif -//FIXME use av_log2 for types - if (type == 0) - { - //fprintf(stderr,"coding type: constant\n"); - tmp = get_sbits(&s->gb, s->curr_bps); - for (i = 0; i < s->blocksize; i++) - decoded[i] = tmp; - } - else if (type == 1) - { - //fprintf(stderr,"coding type: verbatim\n"); - for (i = 0; i < s->blocksize; i++) - decoded[i] = get_sbits(&s->gb, s->curr_bps); - } - else if ((type >= 8) && (type <= 12)) - { - //fprintf(stderr,"coding type: fixed\n"); - if (decode_subframe_fixed(s, decoded, type & ~0x8) < 0) - return -10; - } - else if (type >= 32) - { - //fprintf(stderr,"coding type: lpc\n"); - if (decode_subframe_lpc(s, decoded, (type & ~0x20)+1) < 0) - return -11; - } - else - { - //fprintf(stderr,"Unknown coding type: %d\n",type); - return -12; - } - - if (wasted) - { - int i; - for (i = 0; i < s->blocksize; i++) - decoded[i] <<= wasted; - } - - return 0; -} - -static int decode_frame(FLACContext *s, - void (*yield)(void)) ICODE_ATTR_FLAC; -static int decode_frame(FLACContext *s, - void (*yield)(void)) -{ - int blocksize_code, sample_rate_code, sample_size_code, assignment, crc8; - int decorrelation, bps, blocksize, samplerate; - int res, ch; - - blocksize_code = get_bits(&s->gb, 4); - - sample_rate_code = get_bits(&s->gb, 4); - - assignment = get_bits(&s->gb, 4); /* channel assignment */ - if (assignment < 8 && s->channels == assignment+1) - decorrelation = INDEPENDENT; - else if (assignment >=8 && assignment < 11 && s->channels == 2) - decorrelation = LEFT_SIDE + assignment - 8; - else - { - return -13; - } - - sample_size_code = get_bits(&s->gb, 3); - if(sample_size_code == 0) - bps= s->bps; - else if((sample_size_code != 3) && (sample_size_code != 7)) - bps = sample_size_table[sample_size_code]; - else - { - return -14; - } - - if (get_bits1(&s->gb)) - { - return -15; - } - - /* Get the samplenumber of the first sample in this block */ - s->samplenumber=get_utf8(&s->gb); - - /* samplenumber actually contains the frame number for streams - with a constant block size - so we multiply by blocksize to - get the actual sample number */ - if (s->min_blocksize == s->max_blocksize) { - s->samplenumber*=s->min_blocksize; - } - -#if 0 - if (/*((blocksize_code == 6) || (blocksize_code == 7)) &&*/ - (s->min_blocksize != s->max_blocksize)){ - }else{ - } -#endif - - if (blocksize_code == 0) - blocksize = s->min_blocksize; - else if (blocksize_code == 6) - blocksize = get_bits(&s->gb, 8)+1; - else if (blocksize_code == 7) - blocksize = get_bits(&s->gb, 16)+1; - else - blocksize = blocksize_table[blocksize_code]; - - if(blocksize > s->max_blocksize){ - return -16; - } - - if (sample_rate_code == 0){ - samplerate= s->samplerate; - }else if ((sample_rate_code < 12)) - samplerate = sample_rate_table[sample_rate_code]; - else if (sample_rate_code == 12) - samplerate = get_bits(&s->gb, 8) * 1000; - else if (sample_rate_code == 13) - samplerate = get_bits(&s->gb, 16); - else if (sample_rate_code == 14) - samplerate = get_bits(&s->gb, 16) * 10; - else{ - return -17; - } - - skip_bits(&s->gb, 8); - crc8= get_crc8(s->gb.buffer, get_bits_count(&s->gb)/8); - if(crc8){ - return -18; - } - - s->blocksize = blocksize; - s->samplerate = samplerate; - s->bps = bps; - s->decorrelation= decorrelation; - - for (ch=0; ch<s->channels; ++ch) { - yield(); - if ((res=decode_subframe(s, ch, s->decoded[ch])) < 0) - return res-100; - } - - yield(); - align_get_bits(&s->gb); - - /* frame footer */ - skip_bits(&s->gb, 16); /* data crc */ - - return 0; -} - -static int flac_downmix(FLACContext *s) ICODE_ATTR_FLAC; -static int flac_downmix(FLACContext *s) -{ - int32_t *FL, *FR, *FC, *SB, *RL, *RR; - int32_t *outL = s->decoded[0]; - int32_t *outR = s->decoded[1]; - int i, scale=FLAC_OUTPUT_DEPTH-s->bps; - - switch(s->channels) - { - case 3: /* 3.0 channel order: FL FR FC */ - FL = s->decoded[0]; - FR = s->decoded[1]; - FC = s->decoded[2]; - /* LF = 0.66 LF + 0.33 FC - LR = 0.66 LR + 0.33 FC */ - for (i=0; i<s->blocksize; ++i) { - int32_t a = *(FL)*2 + *(FC); - int32_t b = *(FR)*2 + *(FC); - *outL++ = ((a + (a<<2))>>4) << scale; /* 1/3 ~= 5>>4 */ - *outR++ = ((b + (b<<2))>>4) << scale; /* 1/3 ~= 5>>4 */ - FL++; FR++; FC++; - } - break; - case 4: /* 4.0 channel order: FL FR RL RR */ - FL = s->decoded[0]; - FR = s->decoded[1]; - RL = s->decoded[2]; - RR = s->decoded[3]; - /* LF = 0.50 LF + 0.50 RL + 0.00 RR - LR = 0.50 LR + 0.00 RL + 0.50 RR */ - for (i=0; i<s->blocksize; ++i) { - int32_t a = *(FL) + *(RL); - int32_t b = *(FR) + *(RR); - *outL++ = (a>>1) << scale; - *outR++ = (b>>1) << scale; - FL++; FR++; RL++; RR++; - } - break; - case 5: /* 5.0 channel order: FL FR FC RL RR */ - FL = s->decoded[0]; - FR = s->decoded[1]; - FC = s->decoded[2]; - RL = s->decoded[3]; - RR = s->decoded[4]; - /* LF = 0.40 LF + 0.20 FC + 0.40 RL + 0.00 RR - LR = 0.40 LR + 0.20 FC + 0.00 RL + 0.40 RR */ - for (i=0; i<s->blocksize; ++i) { - int32_t a = *(FL)*2 + *(FC) + *(RL)*2; - int32_t b = *(FR)*2 + *(FC) + *(RR)*2; - *outL++ = ((a + (a<<1))>>4) << scale; /* 3>>4 ~= 1/5 */ - *outR++ = ((b + (b<<1))>>4) << scale; /* 3>>4 ~= 1/5 */ - FL++; FR++; FC++; RL++; RR++; - } - break; - case 6: /* 5.1 channel order: FL FR FC SUB RL RR */ - FL = s->decoded[0]; - FR = s->decoded[1]; - FC = s->decoded[2]; - SB = s->decoded[3]; - RL = s->decoded[4]; - RR = s->decoded[5]; - /* LF = 0.33 LF + 0.16 SUB + 0.16 FC + 0.33 RL + 0.00 RR - LR = 0.33 LR + 0.16 SUB + 0.16 FC + 0.00 RL + 0.33 RR */ - for (i=0; i<s->blocksize; ++i) { - int32_t a = *(FL)*2 + *(SB) + *(FC) + *(RL)*2; - int32_t b = *(FR)*2 + *(SB) + *(FC) + *(RR)*2; - *outL++ = ((a + (a<<2))>>5) << scale; /* 5>>5 ~= 1/6 */ - *outR++ = ((b + (b<<2))>>5) << scale; /* 5>>5 ~= 1/6 */ - FL++; FR++; SB++; FC++; RL++; RR++; - } - break; - default: /* 1.0 and 2.0 do not need downmix, other formats unknown. */ - return -501; - break; - } - return 0; -} - -int flac_decode_frame(FLACContext *s, - uint8_t *buf, int buf_size, - void (*yield)(void)) -{ - int tmp; - int i; - int framesize; - int scale; - - init_get_bits(&s->gb, buf, buf_size*8); - - tmp = get_bits(&s->gb, 16); - if ((tmp & 0xFFFE) != 0xFFF8){ - return -41; - } - - if ((framesize=decode_frame(s,yield)) < 0){ - s->bitstream_size=0; - s->bitstream_index=0; - return framesize; - } - - yield(); - -#define DECORRELATE(left, right)\ - for (i = 0; i < s->blocksize; i++) {\ - int32_t a = s->decoded[0][i];\ - int32_t b = s->decoded[1][i];\ - s->decoded[0][i] = (left) << scale;\ - s->decoded[1][i] = (right) << scale;\ - }\ - - scale=FLAC_OUTPUT_DEPTH-s->bps; - switch(s->decorrelation) - { - case INDEPENDENT: - if (s->channels <= 2) { - DECORRELATE(a, b) /* Always decorrelate exactly the two supported channels. */ - } else { - if ((tmp=flac_downmix(s)) != 0) - return tmp; - } - break; - case LEFT_SIDE: - DECORRELATE(a, a-b) - break; - case RIGHT_SIDE: - DECORRELATE(a+b, b) - break; - case MID_SIDE: - DECORRELATE( (a-=b>>1) + b, a) - break; - } - - s->framesize = (get_bits_count(&s->gb)+7)>>3; - - return 0; -} diff --git a/apps/codecs/libffmpegFLAC/decoder.h b/apps/codecs/libffmpegFLAC/decoder.h deleted file mode 100644 index 677a21a..0000000 --- a/apps/codecs/libffmpegFLAC/decoder.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _FLAC_DECODER_H -#define _FLAC_DECODER_H - -#include "bitstream.h" - -#define MAX_CHANNELS 6 /* Maximum supported channels, only left/right will be played back */ -#define MAX_BLOCKSIZE 4608 /* Maxsize in samples of one uncompressed frame */ -#define MAX_FRAMESIZE 65536 /* Maxsize in bytes of one compressed frame */ - -#define FLAC_OUTPUT_DEPTH 29 /* Provide samples left-shifted to 28 bits+sign */ - -enum decorrelation_type { - INDEPENDENT, - LEFT_SIDE, - RIGHT_SIDE, - MID_SIDE, -}; - -typedef struct FLACContext { - GetBitContext gb; - - int min_blocksize, max_blocksize; - int min_framesize, max_framesize; - int samplerate, channels; - int blocksize/*, last_blocksize*/; - int bps, curr_bps; - unsigned long samplenumber; - unsigned long totalsamples; - enum decorrelation_type decorrelation; - - int filesize; - int length; - int bitrate; - int metadatalength; - - int bitstream_size; - int bitstream_index; - - int sample_skip; - int framesize; - - int32_t *decoded[MAX_CHANNELS]; -} FLACContext; - -int flac_decode_frame(FLACContext *s, - uint8_t *buf, int buf_size, - void (*yield)(void)) ICODE_ATTR_FLAC; - -#endif diff --git a/apps/codecs/libffmpegFLAC/golomb.h b/apps/codecs/libffmpegFLAC/golomb.h deleted file mode 100644 index 197b78e..0000000 --- a/apps/codecs/libffmpegFLAC/golomb.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * exp golomb vlc stuff - * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> - * Copyright (c) 2004 Alex Beregszaszi - * - * 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 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 <limits.h> -#include "codeclib.h" - -/** - * @file golomb.h - * @brief - * exp golomb vlc stuff - * @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi - */ - - -/** - * read unsigned golomb rice code (jpegls). - */ -static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len){ - unsigned int buf; - int log; - - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf=GET_CACHE(re, gb); - - log= av_log2(buf); - - if(log - k >= 32-MIN_CACHE_BITS+(MIN_CACHE_BITS==32) && 32-log < limit){ - buf >>= log - k; - buf += (30-log)<<k; - LAST_SKIP_BITS(re, gb, 32 + k - log); - CLOSE_READER(re, gb); - - return buf; - }else{ - int i; - for(i=0; SHOW_UBITS(re, gb, 1) == 0; i++){ - LAST_SKIP_BITS(re, gb, 1); - UPDATE_CACHE(re, gb); - } - SKIP_BITS(re, gb, 1); - - if(i < limit - 1){ - if(k){ - buf = SHOW_UBITS(re, gb, k); - LAST_SKIP_BITS(re, gb, k); - }else{ - buf=0; - } - - CLOSE_READER(re, gb); - return buf + (i<<k); - }else if(i == limit - 1){ - buf = SHOW_UBITS(re, gb, esc_len); - LAST_SKIP_BITS(re, gb, esc_len); - CLOSE_READER(re, gb); - - return buf + 1; - }else - return -1; - } -} - -/** - * read signed golomb rice code (flac). - */ -static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len){ - int v= get_ur_golomb_jpegls(gb, k, limit, esc_len); - return (v>>1) ^ -(v&1); -} - -/** - * read unsigned golomb rice code (shorten). - */ -#define get_ur_golomb_shorten(gb, k) get_ur_golomb_jpegls(gb, k, INT_MAX, 0) -/* -static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){ - return get_ur_golomb_jpegls(gb, k, INT_MAX, 0); -} -*/ - -/** - * read signed golomb rice code (shorten). - */ -static inline int get_sr_golomb_shorten(GetBitContext* gb, int k) -{ - int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0); - if (uvar & 1) - return ~(uvar >> 1); - else - return uvar >> 1; -} diff --git a/apps/codecs/libffmpegFLAC/libffmpegFLAC.make b/apps/codecs/libffmpegFLAC/libffmpegFLAC.make deleted file mode 100644 index 734f3d2..0000000 --- a/apps/codecs/libffmpegFLAC/libffmpegFLAC.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libffmpegFLAC -FFMPEGFLACLIB := $(CODECDIR)/libffmpegFLAC.a -FFMPEGFLACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libffmpegFLAC/SOURCES) -FFMPEGFLACLIB_OBJ := $(call c2obj, $(FFMPEGFLACLIB_SRC)) -OTHER_SRC += $(FFMPEGFLACLIB_SRC) - -$(FFMPEGFLACLIB): $(FFMPEGFLACLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libffmpegFLAC/shndec.c b/apps/codecs/libffmpegFLAC/shndec.c deleted file mode 100644 index 40e7211..0000000 --- a/apps/codecs/libffmpegFLAC/shndec.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Shorten decoder - * Copyright (c) 2005 Jeff Muizelaar - * - * 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 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 - */ - -/** - * @file shorten.c - * Shorten decoder - * @author Jeff Muizelaar - * - */ - -#include "bitstream.h" -#include "golomb.h" -#include "shndec.h" -#include "codeclib.h" - -#define ULONGSIZE 2 - -#define WAVE_FORMAT_PCM 0x0001 - -#define TYPESIZE 4 -#define CHANSIZE 0 -#define LPCQSIZE 2 -#define ENERGYSIZE 3 -#define BITSHIFTSIZE 2 - -#define TYPE_S16HL 3 /* signed 16 bit shorts: high-low */ -#define TYPE_S16LH 5 /* signed 16 bit shorts: low-high */ - -#define NWRAP 3 -#define NSKIPSIZE 1 - -#define LPCQUANT 5 -#define V2LPCQOFFSET (1 << LPCQUANT) - -#define FNSIZE 2 - -#define VERBATIM_CKSIZE_SIZE 5 -#define VERBATIM_BYTE_SIZE 8 -#define CANONICAL_HEADER_SIZE 44 - -#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) - -#define get_le16(gb) bswap_16(get_bits_long(gb, 16)) -#define get_le32(gb) bswap_32(get_bits_long(gb, 32)) - -/* converts fourcc string to int */ -static unsigned int ff_get_fourcc(const char *s){ - //assert( strlen(s)==4 ); - return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24); -} - -static unsigned int get_uint(ShortenContext *s, int k) -{ - if (s->version != 0) - k = get_ur_golomb_shorten(&s->gb, ULONGSIZE); - return get_ur_golomb_shorten(&s->gb, k); -} - -#if defined(CPU_COLDFIRE) -static inline void coldfire_lshift_samples(int n, int shift, int32_t *samples) -{ -/* - for (i = 0; i < n; i++) - samples[i] =<< shift; -*/ - asm volatile ( - "move.l %[n], %%d0 \n" /* d0 = loop counter */ - "asr.l #2, %%d0 \n" - "beq 1f \n" - "2:" /* main loop (unroll by 4) */ - "movem.l (%[x]), %%d4-%%d7 \n" - "asl.l %[s], %%d4 \n" - "asl.l %[s], %%d5 \n" - "asl.l %[s], %%d6 \n" - "asl.l %[s], %%d7 \n" - "movem.l %%d4-%%d7, (%[x]) \n" - "lea.l (16, %[x]), %[x] \n" - - "subq.l #1, %%d0 \n" - "bne 2b \n" - "1:" /* any loops left? */ - "and.l #3, %[n] \n" - "beq 4f \n" - "3:" /* remaining loops */ - "move.l (%[x]), %%d4 \n" - "asl.l %[s], %%d4 \n" - "move.l %%d4, (%[x])+ \n" - - "subq.l #1, %[n] \n" - "bne 3b \n" - "4:" /* exit */ - : [n] "+d" (n), - [x] "+a" (samples) - : [s] "d" (shift) - : "%d0", "%d4", "%d5", "%d6", "%d7", "cc", "memory" - ); -} -#endif - -static inline void fix_bitshift(ShortenContext *s, int32_t *samples) -{ - int i; - - /* Wrapped samples don't get bitshifted, so we'll do them during - the next iteration. */ - if (s->bitshift != 0) { -#if defined(CPU_COLDFIRE) - coldfire_lshift_samples(s->blocksize, s->bitshift, samples - s->nwrap); -#else - for (i = -s->nwrap; i < (s->blocksize - s->nwrap); i++) - samples[i] <<= s->bitshift; -#endif - } - - /* Also, when we have to remember to fix the wrapped samples when - the bitshift changes.*/ - if (s->bitshift != s->last_bitshift) { - if (s->last_bitshift != 0) - for (i = -s->nwrap; i < 0; i++) - samples[i] <<= s->last_bitshift; - - s->last_bitshift = s->bitshift; - } -} - -static inline void decode_subframe_lpc(ShortenContext *s, int32_t *decoded, - int residual_size, int pred_order) -{ - int sum, i, j; - int coeffs[MAX_PRED_ORDER]; - - for (i=0; i<pred_order; i++) { - coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT); - } - - for (i=0; i < s->blocksize; i++) { - sum = s->lpcqoffset; - for (j=0; j<pred_order; j++) - sum += coeffs[j] * decoded[i-j-1]; - - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> LPCQUANT); - } -} - -static inline int shorten_decode_frame(ShortenContext *s, int32_t *decoded, - int32_t *offset) -{ - int i; - int32_t sum; - - int cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); - switch (cmd) { - case FN_ZERO: - case FN_DIFF0: - case FN_DIFF1: - case FN_DIFF2: - case FN_DIFF3: - case FN_QLPC: - { - int residual_size = 0; - int32_t coffset; - if (cmd != FN_ZERO) { - residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); - /* this is a hack as version 0 differed in defintion of - get_sr_golomb_shorten */ - if (s->version == 0) - residual_size--; - } - - if (s->nmean == 0) { - coffset = offset[0]; - } else { - sum = (s->version < 2) ? 0 : s->nmean / 2; - for (i=0; i<s->nmean; i++) - sum += offset[i]; - - coffset = sum / s->nmean; - if (s->version >= 2) - coffset >>= FFMIN(1, s->bitshift); - } - - switch (cmd) { - case FN_ZERO: - for (i=0; i<s->blocksize; i++) - decoded[i] = 0; - break; - - case FN_DIFF0: - for (i=0; i<s->blocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - coffset; - break; - - case FN_DIFF1: - for (i=0; i<s->blocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - decoded[i - 1]; - break; - - case FN_DIFF2: - for (i=0; i<s->blocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - 2*decoded[i-1] - decoded[i-2]; - break; - - case FN_DIFF3: - for (i=0; i<s->blocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - 3*decoded[i-1] - 3*decoded[i-2] + decoded[i-3]; - break; - - case FN_QLPC: - { - int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); - for (i=0; i<pred_order; i++) - decoded[i - pred_order] -= coffset; - decode_subframe_lpc(s, decoded, residual_size, pred_order); - if (coffset != 0) { - for (i=0; i < s->blocksize; i++) - decoded[i] += coffset; - } - } - } - - if (s->nmean > 0) { - sum = (s->version < 2) ? 0 : s->blocksize / 2; - for (i=0; i<s->blocksize; i++) - sum += decoded[i]; - - for (i=1; i<s->nmean; i++) - offset[i-1] = offset[i]; - - if (s->version < 2) { - offset[s->nmean - 1] = sum / s->blocksize; - } else { - offset[s->nmean - 1] = - (sum / s->blocksize) << s->bitshift; - } - } - - fix_bitshift(s, decoded); - break; - } - - case FN_VERBATIM: - i = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - while (i--) - get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); - break; - - case FN_BITSHIFT: - s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); - break; - - case FN_BLOCKSIZE: - s->blocksize = get_uint(s, av_log2(s->blocksize)); - break; - - case FN_QUIT: - break; - - default: - return FN_ERROR; - break; - } - - return cmd; -} - -int shorten_decode_frames(ShortenContext *s, int *nsamples, - int32_t *decoded0, int32_t *decoded1, - int32_t *offset0, int32_t *offset1, - uint8_t *buf, int buf_size, - void (*yield)(void)) -{ - int32_t *decoded, *offset; - int cmd; - - *nsamples = 0; - - init_get_bits(&s->gb, buf, buf_size*8); - get_bits(&s->gb, s->bitindex); - - int n = 0; - while (n < NUM_DEC_LOOPS) { - int chan = n%2; - if (chan == 0) { - decoded = decoded0 + s->nwrap + *nsamples; - offset = offset0; - } else { - decoded = decoded1 + s->nwrap + *nsamples; - offset = offset1; - } - - yield(); - - cmd = shorten_decode_frame(s, decoded, offset); - - if (cmd == FN_VERBATIM || cmd == FN_BITSHIFT || cmd == FN_BLOCKSIZE) { - continue; - } else if (cmd == FN_QUIT || cmd == FN_ERROR) { - break; - } - - *nsamples += chan * s->blocksize; - n++; - } - - if (*nsamples) { - /* Wrap the samples for the next loop */ - int i; - for (i = 0; i < s->nwrap; i++) { - decoded0[i] = decoded0[*nsamples + i]; - decoded1[i] = decoded1[*nsamples + i]; - } - - /* Scale the samples for the pcmbuf */ - int scale = SHN_OUTPUT_DEPTH - s->bits_per_sample; -#if defined(CPU_COLDFIRE) - coldfire_lshift_samples(*nsamples, scale, decoded0 + s->nwrap); - coldfire_lshift_samples(*nsamples, scale, decoded1 + s->nwrap); -#else - for (i = 0; i < *nsamples; i++) { - decoded0[i + s->nwrap] <<= scale; - decoded1[i + s->nwrap] <<= scale; - } -#endif - } - - return cmd; -} - -static int decode_wave_header(ShortenContext *s, - uint8_t *header, - int header_size) -{ - GetBitContext hb; - int len; - - init_get_bits(&hb, header, header_size*8); - if (get_le32(&hb) != MKTAG('R','I','F','F')) { - return -8; - } - - int chunk_size = get_le32(&hb); - - if (get_le32(&hb) != MKTAG('W','A','V','E')) { - return -9; - } - - while (get_le32(&hb) != MKTAG('f','m','t',' ')) { - len = get_le32(&hb); - skip_bits(&hb, 8*len); - } - - len = get_le32(&hb); - if (len < 16) { - return -10; - } - - if (get_le16(&hb) != WAVE_FORMAT_PCM ) { - return -11; - } - - s->channels = get_le16(&hb); - if (s->channels > MAX_CHANNELS) { - return -3; - } - - s->sample_rate = get_le32(&hb); - - skip_bits(&hb, 32); - //s->bit_rate = 8*get_le32(&hb); - - int block_align = get_le16(&hb); - s->totalsamples = (chunk_size - 36) / block_align; - - s->bits_per_sample = get_le16(&hb); - if (s->bits_per_sample != 16) { - return -12; - } - - len -= 16; - if (len > 0) { - return len; - } - - return 0; -} - -int shorten_init(ShortenContext* s, uint8_t *buf, int buf_size) -{ - int i; - - s->blocksize = DEFAULT_BLOCK_SIZE; - s->channels = 1; - s->nmean = -1; - - init_get_bits(&s->gb, buf, buf_size*8); - get_bits(&s->gb, s->bitindex); - - /* shorten signature */ - if (get_bits_long(&s->gb, 32) != bswap_32(ff_get_fourcc("ajkg"))) { - return -1; - } - - s->version = get_bits(&s->gb, 8); - - int internal_ftype = get_uint(s, TYPESIZE); - if ((internal_ftype != TYPE_S16HL) && (internal_ftype != TYPE_S16LH)) { - return -2; - } - - s->channels = get_uint(s, CHANSIZE); - if (s->channels > MAX_CHANNELS) { - return -3; - } - - /* get blocksize if version > 0 */ - int maxnlpc = 0; - if (s->version > 0) { - s->blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); - maxnlpc = get_uint(s, LPCQSIZE); - s->nmean = get_uint(s, 0); - - int skip_bytes = get_uint(s, NSKIPSIZE); - for (i=0; i<skip_bytes; i++) { - skip_bits(&s->gb, 8); - } - } - - if (s->nmean > MAX_NMEAN) { - return -4; - } - - s->nwrap = FFMAX(NWRAP, maxnlpc); - if (s->nwrap > MAX_NWRAP) { - return -5; - } - - if (s->version > 1) - s->lpcqoffset = V2LPCQOFFSET; - - if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { - return -6; - } - - uint8_t header[MAX_HEADER_SIZE]; - int header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - if (header_size >= MAX_HEADER_SIZE || header_size < CANONICAL_HEADER_SIZE) { - return -7; - } - - for (i=0; i<header_size; i++) - header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); - - s->header_bits = s->gb.index; - - return decode_wave_header(s, header, header_size); -} diff --git a/apps/codecs/libffmpegFLAC/shndec.h b/apps/codecs/libffmpegFLAC/shndec.h deleted file mode 100644 index 068f4fa..0000000 --- a/apps/codecs/libffmpegFLAC/shndec.h +++ /dev/null @@ -1,52 +0,0 @@ -#include "bitstream.h" - -#define SHN_OUTPUT_DEPTH 29 /* 28 bits + sign */ - -#define MAX_CHANNELS 2 -#define MAX_PRED_ORDER 16 -#define MAX_NWRAP MAX_PRED_ORDER -#define MAX_NMEAN 4 - -/* NUM_DEC_LOOPS should be even number */ -#define NUM_DEC_LOOPS 26 -#define DEFAULT_BLOCK_SIZE 256 -#define MAX_HEADER_SIZE DEFAULT_BLOCK_SIZE*4 -#define MAX_BUFFER_SIZE 2*DEFAULT_BLOCK_SIZE*NUM_DEC_LOOPS -#define MAX_DECODE_SIZE ((DEFAULT_BLOCK_SIZE*NUM_DEC_LOOPS/2) + MAX_NWRAP) -#define MAX_OFFSET_SIZE MAX_NMEAN - -#define FN_DIFF0 0 -#define FN_DIFF1 1 -#define FN_DIFF2 2 -#define FN_DIFF3 3 -#define FN_QUIT 4 -#define FN_BLOCKSIZE 5 -#define FN_BITSHIFT 6 -#define FN_QLPC 7 -#define FN_ZERO 8 -#define FN_VERBATIM 9 -#define FN_ERROR 10 - -typedef struct ShortenContext { - GetBitContext gb; - int32_t lpcqoffset; - uint32_t totalsamples; - int header_bits; - int channels; - int sample_rate; - int bits_per_sample; - int version; - int bitshift; - int last_bitshift; - int nmean; - int nwrap; - int blocksize; - int bitindex; -} ShortenContext; - -int shorten_init(ShortenContext* s, uint8_t *buf, int buf_size); -int shorten_decode_frames(ShortenContext *s, int *nsamples, - int32_t *decoded0, int32_t *decoded1, - int32_t *offset0, int32_t *offset1, - uint8_t *buf, int buf_size, - void (*yield)(void)) ICODE_ATTR; |