start using submodules
This commit is contained in:
parent
979e2070d3
commit
37ae554f9f
60
flac/AUTHORS
60
flac/AUTHORS
|
|
@ -1,60 +0,0 @@
|
||||||
/* FLAC - Free Lossless Audio Codec
|
|
||||||
* Copyright (C) 2001-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* This file is part the FLAC project. FLAC is comprised of several
|
|
||||||
* components distributed under different licenses. The codec libraries
|
|
||||||
* are distributed under Xiph.Org's BSD-like license (see the file
|
|
||||||
* COPYING.Xiph in this distribution). All other programs, libraries, and
|
|
||||||
* plugins are distributed under the GPL (see COPYING.GPL). The documentation
|
|
||||||
* is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
|
|
||||||
* FLAC distribution contains at the top the terms under which it may be
|
|
||||||
* distributed.
|
|
||||||
*
|
|
||||||
* Since this particular file is relevant to all components of FLAC,
|
|
||||||
* it may be distributed under the Xiph.Org license, which is the least
|
|
||||||
* restrictive of those mentioned above. See the file COPYING.Xiph in this
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
This file lists major contributors to the FLAC project. This list is not
|
|
||||||
exhaustive. For an exhaustive list, run the command `git shortlog -s` on
|
|
||||||
the git repo or visit https://gitlab.xiph.org/xiph/flac/-/graphs/master
|
|
||||||
|
|
||||||
For a complete list of contributions, run the command `git log` on the
|
|
||||||
git repo, visit https://github.com/xiph/flac/commits or visit
|
|
||||||
https://gitlab.xiph.org/xiph/flac/commits
|
|
||||||
|
|
||||||
Original author: Josh Coalson <jcoalson@users.sourceforge.net>
|
|
||||||
Maintainer 2012-2020: Erik de Castro Lopo <erikd@mega-nerd.com>
|
|
||||||
Maintainer from 2022: Martijn van Beurden <mvanb1@gmail.com>
|
|
||||||
|
|
||||||
Website : https://www.xiph.org/flac/
|
|
||||||
|
|
||||||
Other major contributors and their contributions:
|
|
||||||
|
|
||||||
"lvqcl" <lvqcl@users.sourceforge.net>
|
|
||||||
* Visual Studio build system.
|
|
||||||
* Optimisations in the encoder and decoder.
|
|
||||||
|
|
||||||
"Janne Hyvärinen" <cse@sci.fi>
|
|
||||||
* Visual Studio build system.
|
|
||||||
* Unicode handling on Windows.
|
|
||||||
|
|
||||||
"Andrey Astafiev" <andrei@tvcell.ru>
|
|
||||||
* Russian translation of the HTML documentation
|
|
||||||
|
|
||||||
"Miroslav Lichvar" <lichvarm@phoenix.inf.upol.cz>
|
|
||||||
* IA-32 assembly versions of several libFLAC routines
|
|
||||||
|
|
||||||
"Brady Patterson" <bpat@users.sourceforge.net>
|
|
||||||
* AIFF file support, PPC assembly versions of libFLAC routines
|
|
||||||
|
|
||||||
"Daisuke Shimamura" <Daisuke_Shimamura@nifty.com>
|
|
||||||
* i18n support in the XMMS plugin
|
|
||||||
|
|
||||||
"X-Fixer" <x-fixer@narod.ru>
|
|
||||||
* Configuration system, tag editing, and file info in the Winamp2 plugin
|
|
||||||
|
|
||||||
"Matt Zimmerman" <mdz@debian.org>
|
|
||||||
* Libtool/autoconf/automake make system, flac man page
|
|
||||||
397
flac/COPYING.FDL
397
flac/COPYING.FDL
|
|
@ -1,397 +0,0 @@
|
||||||
GNU Free Documentation License
|
|
||||||
Version 1.2, November 2002
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
|
|
||||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
|
|
||||||
0. PREAMBLE
|
|
||||||
|
|
||||||
The purpose of this License is to make a manual, textbook, or other
|
|
||||||
functional and useful document "free" in the sense of freedom: to
|
|
||||||
assure everyone the effective freedom to copy and redistribute it,
|
|
||||||
with or without modifying it, either commercially or noncommercially.
|
|
||||||
Secondarily, this License preserves for the author and publisher a way
|
|
||||||
to get credit for their work, while not being considered responsible
|
|
||||||
for modifications made by others.
|
|
||||||
|
|
||||||
This License is a kind of "copyleft", which means that derivative
|
|
||||||
works of the document must themselves be free in the same sense. It
|
|
||||||
complements the GNU General Public License, which is a copyleft
|
|
||||||
license designed for free software.
|
|
||||||
|
|
||||||
We have designed this License in order to use it for manuals for free
|
|
||||||
software, because free software needs free documentation: a free
|
|
||||||
program should come with manuals providing the same freedoms that the
|
|
||||||
software does. But this License is not limited to software manuals;
|
|
||||||
it can be used for any textual work, regardless of subject matter or
|
|
||||||
whether it is published as a printed book. We recommend this License
|
|
||||||
principally for works whose purpose is instruction or reference.
|
|
||||||
|
|
||||||
|
|
||||||
1. APPLICABILITY AND DEFINITIONS
|
|
||||||
|
|
||||||
This License applies to any manual or other work, in any medium, that
|
|
||||||
contains a notice placed by the copyright holder saying it can be
|
|
||||||
distributed under the terms of this License. Such a notice grants a
|
|
||||||
world-wide, royalty-free license, unlimited in duration, to use that
|
|
||||||
work under the conditions stated herein. The "Document", below,
|
|
||||||
refers to any such manual or work. Any member of the public is a
|
|
||||||
licensee, and is addressed as "you". You accept the license if you
|
|
||||||
copy, modify or distribute the work in a way requiring permission
|
|
||||||
under copyright law.
|
|
||||||
|
|
||||||
A "Modified Version" of the Document means any work containing the
|
|
||||||
Document or a portion of it, either copied verbatim, or with
|
|
||||||
modifications and/or translated into another language.
|
|
||||||
|
|
||||||
A "Secondary Section" is a named appendix or a front-matter section of
|
|
||||||
the Document that deals exclusively with the relationship of the
|
|
||||||
publishers or authors of the Document to the Document's overall subject
|
|
||||||
(or to related matters) and contains nothing that could fall directly
|
|
||||||
within that overall subject. (Thus, if the Document is in part a
|
|
||||||
textbook of mathematics, a Secondary Section may not explain any
|
|
||||||
mathematics.) The relationship could be a matter of historical
|
|
||||||
connection with the subject or with related matters, or of legal,
|
|
||||||
commercial, philosophical, ethical or political position regarding
|
|
||||||
them.
|
|
||||||
|
|
||||||
The "Invariant Sections" are certain Secondary Sections whose titles
|
|
||||||
are designated, as being those of Invariant Sections, in the notice
|
|
||||||
that says that the Document is released under this License. If a
|
|
||||||
section does not fit the above definition of Secondary then it is not
|
|
||||||
allowed to be designated as Invariant. The Document may contain zero
|
|
||||||
Invariant Sections. If the Document does not identify any Invariant
|
|
||||||
Sections then there are none.
|
|
||||||
|
|
||||||
The "Cover Texts" are certain short passages of text that are listed,
|
|
||||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
|
||||||
the Document is released under this License. A Front-Cover Text may
|
|
||||||
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
|
||||||
|
|
||||||
A "Transparent" copy of the Document means a machine-readable copy,
|
|
||||||
represented in a format whose specification is available to the
|
|
||||||
general public, that is suitable for revising the document
|
|
||||||
straightforwardly with generic text editors or (for images composed of
|
|
||||||
pixels) generic paint programs or (for drawings) some widely available
|
|
||||||
drawing editor, and that is suitable for input to text formatters or
|
|
||||||
for automatic translation to a variety of formats suitable for input
|
|
||||||
to text formatters. A copy made in an otherwise Transparent file
|
|
||||||
format whose markup, or absence of markup, has been arranged to thwart
|
|
||||||
or discourage subsequent modification by readers is not Transparent.
|
|
||||||
An image format is not Transparent if used for any substantial amount
|
|
||||||
of text. A copy that is not "Transparent" is called "Opaque".
|
|
||||||
|
|
||||||
Examples of suitable formats for Transparent copies include plain
|
|
||||||
ASCII without markup, Texinfo input format, LaTeX input format, SGML
|
|
||||||
or XML using a publicly available DTD, and standard-conforming simple
|
|
||||||
HTML, PostScript or PDF designed for human modification. Examples of
|
|
||||||
transparent image formats include PNG, XCF and JPG. Opaque formats
|
|
||||||
include proprietary formats that can be read and edited only by
|
|
||||||
proprietary word processors, SGML or XML for which the DTD and/or
|
|
||||||
processing tools are not generally available, and the
|
|
||||||
machine-generated HTML, PostScript or PDF produced by some word
|
|
||||||
processors for output purposes only.
|
|
||||||
|
|
||||||
The "Title Page" means, for a printed book, the title page itself,
|
|
||||||
plus such following pages as are needed to hold, legibly, the material
|
|
||||||
this License requires to appear in the title page. For works in
|
|
||||||
formats which do not have any title page as such, "Title Page" means
|
|
||||||
the text near the most prominent appearance of the work's title,
|
|
||||||
preceding the beginning of the body of the text.
|
|
||||||
|
|
||||||
A section "Entitled XYZ" means a named subunit of the Document whose
|
|
||||||
title either is precisely XYZ or contains XYZ in parentheses following
|
|
||||||
text that translates XYZ in another language. (Here XYZ stands for a
|
|
||||||
specific section name mentioned below, such as "Acknowledgements",
|
|
||||||
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
|
|
||||||
of such a section when you modify the Document means that it remains a
|
|
||||||
section "Entitled XYZ" according to this definition.
|
|
||||||
|
|
||||||
The Document may include Warranty Disclaimers next to the notice which
|
|
||||||
states that this License applies to the Document. These Warranty
|
|
||||||
Disclaimers are considered to be included by reference in this
|
|
||||||
License, but only as regards disclaiming warranties: any other
|
|
||||||
implication that these Warranty Disclaimers may have is void and has
|
|
||||||
no effect on the meaning of this License.
|
|
||||||
|
|
||||||
|
|
||||||
2. VERBATIM COPYING
|
|
||||||
|
|
||||||
You may copy and distribute the Document in any medium, either
|
|
||||||
commercially or noncommercially, provided that this License, the
|
|
||||||
copyright notices, and the license notice saying this License applies
|
|
||||||
to the Document are reproduced in all copies, and that you add no other
|
|
||||||
conditions whatsoever to those of this License. You may not use
|
|
||||||
technical measures to obstruct or control the reading or further
|
|
||||||
copying of the copies you make or distribute. However, you may accept
|
|
||||||
compensation in exchange for copies. If you distribute a large enough
|
|
||||||
number of copies you must also follow the conditions in section 3.
|
|
||||||
|
|
||||||
You may also lend copies, under the same conditions stated above, and
|
|
||||||
you may publicly display copies.
|
|
||||||
|
|
||||||
|
|
||||||
3. COPYING IN QUANTITY
|
|
||||||
|
|
||||||
If you publish printed copies (or copies in media that commonly have
|
|
||||||
printed covers) of the Document, numbering more than 100, and the
|
|
||||||
Document's license notice requires Cover Texts, you must enclose the
|
|
||||||
copies in covers that carry, clearly and legibly, all these Cover
|
|
||||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
|
||||||
the back cover. Both covers must also clearly and legibly identify
|
|
||||||
you as the publisher of these copies. The front cover must present
|
|
||||||
the full title with all words of the title equally prominent and
|
|
||||||
visible. You may add other material on the covers in addition.
|
|
||||||
Copying with changes limited to the covers, as long as they preserve
|
|
||||||
the title of the Document and satisfy these conditions, can be treated
|
|
||||||
as verbatim copying in other respects.
|
|
||||||
|
|
||||||
If the required texts for either cover are too voluminous to fit
|
|
||||||
legibly, you should put the first ones listed (as many as fit
|
|
||||||
reasonably) on the actual cover, and continue the rest onto adjacent
|
|
||||||
pages.
|
|
||||||
|
|
||||||
If you publish or distribute Opaque copies of the Document numbering
|
|
||||||
more than 100, you must either include a machine-readable Transparent
|
|
||||||
copy along with each Opaque copy, or state in or with each Opaque copy
|
|
||||||
a computer-network location from which the general network-using
|
|
||||||
public has access to download using public-standard network protocols
|
|
||||||
a complete Transparent copy of the Document, free of added material.
|
|
||||||
If you use the latter option, you must take reasonably prudent steps,
|
|
||||||
when you begin distribution of Opaque copies in quantity, to ensure
|
|
||||||
that this Transparent copy will remain thus accessible at the stated
|
|
||||||
location until at least one year after the last time you distribute an
|
|
||||||
Opaque copy (directly or through your agents or retailers) of that
|
|
||||||
edition to the public.
|
|
||||||
|
|
||||||
It is requested, but not required, that you contact the authors of the
|
|
||||||
Document well before redistributing any large number of copies, to give
|
|
||||||
them a chance to provide you with an updated version of the Document.
|
|
||||||
|
|
||||||
|
|
||||||
4. MODIFICATIONS
|
|
||||||
|
|
||||||
You may copy and distribute a Modified Version of the Document under
|
|
||||||
the conditions of sections 2 and 3 above, provided that you release
|
|
||||||
the Modified Version under precisely this License, with the Modified
|
|
||||||
Version filling the role of the Document, thus licensing distribution
|
|
||||||
and modification of the Modified Version to whoever possesses a copy
|
|
||||||
of it. In addition, you must do these things in the Modified Version:
|
|
||||||
|
|
||||||
A. Use in the Title Page (and on the covers, if any) a title distinct
|
|
||||||
from that of the Document, and from those of previous versions
|
|
||||||
(which should, if there were any, be listed in the History section
|
|
||||||
of the Document). You may use the same title as a previous version
|
|
||||||
if the original publisher of that version gives permission.
|
|
||||||
B. List on the Title Page, as authors, one or more persons or entities
|
|
||||||
responsible for authorship of the modifications in the Modified
|
|
||||||
Version, together with at least five of the principal authors of the
|
|
||||||
Document (all of its principal authors, if it has fewer than five),
|
|
||||||
unless they release you from this requirement.
|
|
||||||
C. State on the Title page the name of the publisher of the
|
|
||||||
Modified Version, as the publisher.
|
|
||||||
D. Preserve all the copyright notices of the Document.
|
|
||||||
E. Add an appropriate copyright notice for your modifications
|
|
||||||
adjacent to the other copyright notices.
|
|
||||||
F. Include, immediately after the copyright notices, a license notice
|
|
||||||
giving the public permission to use the Modified Version under the
|
|
||||||
terms of this License, in the form shown in the Addendum below.
|
|
||||||
G. Preserve in that license notice the full lists of Invariant Sections
|
|
||||||
and required Cover Texts given in the Document's license notice.
|
|
||||||
H. Include an unaltered copy of this License.
|
|
||||||
I. Preserve the section Entitled "History", Preserve its Title, and add
|
|
||||||
to it an item stating at least the title, year, new authors, and
|
|
||||||
publisher of the Modified Version as given on the Title Page. If
|
|
||||||
there is no section Entitled "History" in the Document, create one
|
|
||||||
stating the title, year, authors, and publisher of the Document as
|
|
||||||
given on its Title Page, then add an item describing the Modified
|
|
||||||
Version as stated in the previous sentence.
|
|
||||||
J. Preserve the network location, if any, given in the Document for
|
|
||||||
public access to a Transparent copy of the Document, and likewise
|
|
||||||
the network locations given in the Document for previous versions
|
|
||||||
it was based on. These may be placed in the "History" section.
|
|
||||||
You may omit a network location for a work that was published at
|
|
||||||
least four years before the Document itself, or if the original
|
|
||||||
publisher of the version it refers to gives permission.
|
|
||||||
K. For any section Entitled "Acknowledgements" or "Dedications",
|
|
||||||
Preserve the Title of the section, and preserve in the section all
|
|
||||||
the substance and tone of each of the contributor acknowledgements
|
|
||||||
and/or dedications given therein.
|
|
||||||
L. Preserve all the Invariant Sections of the Document,
|
|
||||||
unaltered in their text and in their titles. Section numbers
|
|
||||||
or the equivalent are not considered part of the section titles.
|
|
||||||
M. Delete any section Entitled "Endorsements". Such a section
|
|
||||||
may not be included in the Modified Version.
|
|
||||||
N. Do not retitle any existing section to be Entitled "Endorsements"
|
|
||||||
or to conflict in title with any Invariant Section.
|
|
||||||
O. Preserve any Warranty Disclaimers.
|
|
||||||
|
|
||||||
If the Modified Version includes new front-matter sections or
|
|
||||||
appendices that qualify as Secondary Sections and contain no material
|
|
||||||
copied from the Document, you may at your option designate some or all
|
|
||||||
of these sections as invariant. To do this, add their titles to the
|
|
||||||
list of Invariant Sections in the Modified Version's license notice.
|
|
||||||
These titles must be distinct from any other section titles.
|
|
||||||
|
|
||||||
You may add a section Entitled "Endorsements", provided it contains
|
|
||||||
nothing but endorsements of your Modified Version by various
|
|
||||||
parties--for example, statements of peer review or that the text has
|
|
||||||
been approved by an organization as the authoritative definition of a
|
|
||||||
standard.
|
|
||||||
|
|
||||||
You may add a passage of up to five words as a Front-Cover Text, and a
|
|
||||||
passage of up to 25 words as a Back-Cover Text, to the end of the list
|
|
||||||
of Cover Texts in the Modified Version. Only one passage of
|
|
||||||
Front-Cover Text and one of Back-Cover Text may be added by (or
|
|
||||||
through arrangements made by) any one entity. If the Document already
|
|
||||||
includes a cover text for the same cover, previously added by you or
|
|
||||||
by arrangement made by the same entity you are acting on behalf of,
|
|
||||||
you may not add another; but you may replace the old one, on explicit
|
|
||||||
permission from the previous publisher that added the old one.
|
|
||||||
|
|
||||||
The author(s) and publisher(s) of the Document do not by this License
|
|
||||||
give permission to use their names for publicity for or to assert or
|
|
||||||
imply endorsement of any Modified Version.
|
|
||||||
|
|
||||||
|
|
||||||
5. COMBINING DOCUMENTS
|
|
||||||
|
|
||||||
You may combine the Document with other documents released under this
|
|
||||||
License, under the terms defined in section 4 above for modified
|
|
||||||
versions, provided that you include in the combination all of the
|
|
||||||
Invariant Sections of all of the original documents, unmodified, and
|
|
||||||
list them all as Invariant Sections of your combined work in its
|
|
||||||
license notice, and that you preserve all their Warranty Disclaimers.
|
|
||||||
|
|
||||||
The combined work need only contain one copy of this License, and
|
|
||||||
multiple identical Invariant Sections may be replaced with a single
|
|
||||||
copy. If there are multiple Invariant Sections with the same name but
|
|
||||||
different contents, make the title of each such section unique by
|
|
||||||
adding at the end of it, in parentheses, the name of the original
|
|
||||||
author or publisher of that section if known, or else a unique number.
|
|
||||||
Make the same adjustment to the section titles in the list of
|
|
||||||
Invariant Sections in the license notice of the combined work.
|
|
||||||
|
|
||||||
In the combination, you must combine any sections Entitled "History"
|
|
||||||
in the various original documents, forming one section Entitled
|
|
||||||
"History"; likewise combine any sections Entitled "Acknowledgements",
|
|
||||||
and any sections Entitled "Dedications". You must delete all sections
|
|
||||||
Entitled "Endorsements".
|
|
||||||
|
|
||||||
|
|
||||||
6. COLLECTIONS OF DOCUMENTS
|
|
||||||
|
|
||||||
You may make a collection consisting of the Document and other documents
|
|
||||||
released under this License, and replace the individual copies of this
|
|
||||||
License in the various documents with a single copy that is included in
|
|
||||||
the collection, provided that you follow the rules of this License for
|
|
||||||
verbatim copying of each of the documents in all other respects.
|
|
||||||
|
|
||||||
You may extract a single document from such a collection, and distribute
|
|
||||||
it individually under this License, provided you insert a copy of this
|
|
||||||
License into the extracted document, and follow this License in all
|
|
||||||
other respects regarding verbatim copying of that document.
|
|
||||||
|
|
||||||
|
|
||||||
7. AGGREGATION WITH INDEPENDENT WORKS
|
|
||||||
|
|
||||||
A compilation of the Document or its derivatives with other separate
|
|
||||||
and independent documents or works, in or on a volume of a storage or
|
|
||||||
distribution medium, is called an "aggregate" if the copyright
|
|
||||||
resulting from the compilation is not used to limit the legal rights
|
|
||||||
of the compilation's users beyond what the individual works permit.
|
|
||||||
When the Document is included in an aggregate, this License does not
|
|
||||||
apply to the other works in the aggregate which are not themselves
|
|
||||||
derivative works of the Document.
|
|
||||||
|
|
||||||
If the Cover Text requirement of section 3 is applicable to these
|
|
||||||
copies of the Document, then if the Document is less than one half of
|
|
||||||
the entire aggregate, the Document's Cover Texts may be placed on
|
|
||||||
covers that bracket the Document within the aggregate, or the
|
|
||||||
electronic equivalent of covers if the Document is in electronic form.
|
|
||||||
Otherwise they must appear on printed covers that bracket the whole
|
|
||||||
aggregate.
|
|
||||||
|
|
||||||
|
|
||||||
8. TRANSLATION
|
|
||||||
|
|
||||||
Translation is considered a kind of modification, so you may
|
|
||||||
distribute translations of the Document under the terms of section 4.
|
|
||||||
Replacing Invariant Sections with translations requires special
|
|
||||||
permission from their copyright holders, but you may include
|
|
||||||
translations of some or all Invariant Sections in addition to the
|
|
||||||
original versions of these Invariant Sections. You may include a
|
|
||||||
translation of this License, and all the license notices in the
|
|
||||||
Document, and any Warranty Disclaimers, provided that you also include
|
|
||||||
the original English version of this License and the original versions
|
|
||||||
of those notices and disclaimers. In case of a disagreement between
|
|
||||||
the translation and the original version of this License or a notice
|
|
||||||
or disclaimer, the original version will prevail.
|
|
||||||
|
|
||||||
If a section in the Document is Entitled "Acknowledgements",
|
|
||||||
"Dedications", or "History", the requirement (section 4) to Preserve
|
|
||||||
its Title (section 1) will typically require changing the actual
|
|
||||||
title.
|
|
||||||
|
|
||||||
|
|
||||||
9. TERMINATION
|
|
||||||
|
|
||||||
You may not copy, modify, sublicense, or distribute the Document except
|
|
||||||
as expressly provided for under this License. Any other attempt to
|
|
||||||
copy, modify, sublicense or distribute the Document 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.
|
|
||||||
|
|
||||||
|
|
||||||
10. FUTURE REVISIONS OF THIS LICENSE
|
|
||||||
|
|
||||||
The Free Software Foundation may publish new, revised versions
|
|
||||||
of the GNU Free Documentation 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. See
|
|
||||||
http://www.gnu.org/copyleft/.
|
|
||||||
|
|
||||||
Each version of the License is given a distinguishing version number.
|
|
||||||
If the Document specifies that a particular numbered version of this
|
|
||||||
License "or any later version" applies to it, you have the option of
|
|
||||||
following the terms and conditions either of that specified version or
|
|
||||||
of any later version that has been published (not as a draft) by the
|
|
||||||
Free Software Foundation. If the Document does not specify a version
|
|
||||||
number of this License, you may choose any version ever published (not
|
|
||||||
as a draft) by the Free Software Foundation.
|
|
||||||
|
|
||||||
|
|
||||||
ADDENDUM: How to use this License for your documents
|
|
||||||
|
|
||||||
To use this License in a document you have written, include a copy of
|
|
||||||
the License in the document and put the following copyright and
|
|
||||||
license notices just after the title page:
|
|
||||||
|
|
||||||
Copyright (c) YEAR YOUR NAME.
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
|
||||||
under the terms of the GNU Free Documentation License, Version 1.2
|
|
||||||
or any later version published by the Free Software Foundation;
|
|
||||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
|
||||||
A copy of the license is included in the section entitled "GNU
|
|
||||||
Free Documentation License".
|
|
||||||
|
|
||||||
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
|
||||||
replace the "with...Texts." line with this:
|
|
||||||
|
|
||||||
with the Invariant Sections being LIST THEIR TITLES, with the
|
|
||||||
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
|
|
||||||
|
|
||||||
If you have Invariant Sections without Cover Texts, or some other
|
|
||||||
combination of the three, merge those two alternatives to suit the
|
|
||||||
situation.
|
|
||||||
|
|
||||||
If your document contains nontrivial examples of program code, we
|
|
||||||
recommend releasing these examples in parallel under your choice of
|
|
||||||
free software license, such as the GNU General Public License,
|
|
||||||
to permit their use in free software.
|
|
||||||
339
flac/COPYING.GPL
339
flac/COPYING.GPL
|
|
@ -1,339 +0,0 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 2, June 1991
|
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
License is intended to guarantee your freedom to share and change free
|
|
||||||
software--to make sure the software is free for all its users. This
|
|
||||||
General Public License applies to most of the Free Software
|
|
||||||
Foundation's software and to any other program whose authors commit to
|
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
|
||||||
the GNU Lesser General Public License instead.) You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
this service if you wish), that you receive source code or can get it
|
|
||||||
if you want it, that you can change the software or use pieces of it
|
|
||||||
in new free programs; and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
|
||||||
These restrictions translate to certain responsibilities for you if you
|
|
||||||
distribute copies of the software, or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must give the recipients all the rights that
|
|
||||||
you have. You must make sure that they, too, receive or can get the
|
|
||||||
source code. And you must show them these terms so they know their
|
|
||||||
rights.
|
|
||||||
|
|
||||||
We protect your rights with two steps: (1) copyright the software, and
|
|
||||||
(2) offer you this license which gives you legal permission to copy,
|
|
||||||
distribute and/or modify the software.
|
|
||||||
|
|
||||||
Also, for each author's protection and ours, we want to make certain
|
|
||||||
that everyone understands that there is no warranty for this free
|
|
||||||
software. If the software is modified by someone else and passed on, we
|
|
||||||
want its recipients to know that what they have is not the original, so
|
|
||||||
that any problems introduced by others will not reflect on the original
|
|
||||||
authors' reputations.
|
|
||||||
|
|
||||||
Finally, any free program is threatened constantly by software
|
|
||||||
patents. We wish to avoid the danger that redistributors of a free
|
|
||||||
program will individually obtain patent licenses, in effect making the
|
|
||||||
program proprietary. To prevent this, we have made it clear that any
|
|
||||||
patent must be licensed for everyone's free use or not licensed at all.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
|
||||||
a notice placed by the copyright holder saying it may be distributed
|
|
||||||
under the terms of this General Public License. The "Program", below,
|
|
||||||
refers to any such program or work, and a "work based on the Program"
|
|
||||||
means either the Program or any derivative work under copyright law:
|
|
||||||
that is to say, a work containing the Program or a portion of it,
|
|
||||||
either verbatim or with modifications and/or translated into another
|
|
||||||
language. (Hereinafter, translation is included without limitation in
|
|
||||||
the term "modification".) Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running the Program is not restricted, and the output from the Program
|
|
||||||
is covered only if its contents constitute a work based on the
|
|
||||||
Program (independent of having been made by running the Program).
|
|
||||||
Whether that is true depends on what the Program does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Program's
|
|
||||||
source code as you receive it, in any medium, provided that you
|
|
||||||
conspicuously and appropriately publish on each copy an appropriate
|
|
||||||
copyright notice and disclaimer of warranty; keep intact all the
|
|
||||||
notices that refer to this License and to the absence of any warranty;
|
|
||||||
and give any other recipients of the Program a copy of this License
|
|
||||||
along with the Program.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy, and
|
|
||||||
you may at your option offer warranty protection in exchange for a fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Program or any portion
|
|
||||||
of it, thus forming a work based on the Program, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) You must cause the modified files to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
b) You must cause any work that you distribute or publish, that in
|
|
||||||
whole or in part contains or is derived from the Program or any
|
|
||||||
part thereof, to be licensed as a whole at no charge to all third
|
|
||||||
parties under the terms of this License.
|
|
||||||
|
|
||||||
c) If the modified program normally reads commands interactively
|
|
||||||
when run, you must cause it, when started running for such
|
|
||||||
interactive use in the most ordinary way, to print or display an
|
|
||||||
announcement including an appropriate copyright notice and a
|
|
||||||
notice that there is no warranty (or else, saying that you provide
|
|
||||||
a warranty) and that users may redistribute the program under
|
|
||||||
these conditions, and telling the user how to view a copy of this
|
|
||||||
License. (Exception: if the Program itself is interactive but
|
|
||||||
does not normally print such an announcement, your work based on
|
|
||||||
the Program is not required to print an announcement.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Program,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Program, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Program.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Program
|
|
||||||
with the Program (or with a work based on the Program) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may copy and distribute the Program (or a work based on it,
|
|
||||||
under Section 2) in object code or executable form under the terms of
|
|
||||||
Sections 1 and 2 above provided that you also do one of the following:
|
|
||||||
|
|
||||||
a) Accompany it with the complete corresponding machine-readable
|
|
||||||
source code, which must be distributed under the terms of Sections
|
|
||||||
1 and 2 above on a medium customarily used for software interchange; or,
|
|
||||||
|
|
||||||
b) Accompany it with a written offer, valid for at least three
|
|
||||||
years, to give any third party, for a charge no more than your
|
|
||||||
cost of physically performing source distribution, a complete
|
|
||||||
machine-readable copy of the corresponding source code, to be
|
|
||||||
distributed under the terms of Sections 1 and 2 above on a medium
|
|
||||||
customarily used for software interchange; or,
|
|
||||||
|
|
||||||
c) Accompany it with the information you received as to the offer
|
|
||||||
to distribute corresponding source code. (This alternative is
|
|
||||||
allowed only for noncommercial distribution and only if you
|
|
||||||
received the program in object code or executable form with such
|
|
||||||
an offer, in accord with Subsection b above.)
|
|
||||||
|
|
||||||
The source code for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For an executable work, complete source
|
|
||||||
code means all the source code for all modules it contains, plus any
|
|
||||||
associated interface definition files, plus the scripts used to
|
|
||||||
control compilation and installation of the executable. However, as a
|
|
||||||
special exception, the source code distributed need not include
|
|
||||||
anything that is normally distributed (in either source or binary
|
|
||||||
form) with the major components (compiler, kernel, and so on) of the
|
|
||||||
operating system on which the executable runs, unless that component
|
|
||||||
itself accompanies the executable.
|
|
||||||
|
|
||||||
If distribution of executable or object code is made by offering
|
|
||||||
access to copy from a designated place, then offering equivalent
|
|
||||||
access to copy the source code from the same place counts as
|
|
||||||
distribution of the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
|
||||||
except as expressly provided under this License. Any attempt
|
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
|
||||||
void, and will automatically terminate your rights under this License.
|
|
||||||
However, parties who have received copies, or rights, from you under
|
|
||||||
this License will not have their licenses terminated so long as such
|
|
||||||
parties remain in full compliance.
|
|
||||||
|
|
||||||
5. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Program or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Program (or any work based on the
|
|
||||||
Program), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Program or works based on it.
|
|
||||||
|
|
||||||
6. Each time you redistribute the Program (or any work based on the
|
|
||||||
Program), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute or modify the Program subject to
|
|
||||||
these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
this License.
|
|
||||||
|
|
||||||
7. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Program at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Program by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Program.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under
|
|
||||||
any particular circumstance, the balance of the section is intended to
|
|
||||||
apply and the section as a whole is intended to apply in other
|
|
||||||
circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system, which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Program under this License
|
|
||||||
may add an explicit geographical distribution limitation excluding
|
|
||||||
those countries, so that distribution is permitted only in or among
|
|
||||||
countries not thus excluded. In such case, this License incorporates
|
|
||||||
the limitation as if written in the body of this License.
|
|
||||||
|
|
||||||
9. The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
|
||||||
specifies a version number of this License which applies to it and "any
|
|
||||||
later version", you have the option of following the terms and conditions
|
|
||||||
either of that version or of any later version published by the Free
|
|
||||||
Software Foundation. If the Program does not specify a version number of
|
|
||||||
this License, you may choose any version ever published by the Free Software
|
|
||||||
Foundation.
|
|
||||||
|
|
||||||
10. If you wish to incorporate parts of the Program into other free
|
|
||||||
programs whose distribution conditions are different, write to the author
|
|
||||||
to ask for permission. For software which is copyrighted by the Free
|
|
||||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
||||||
make exceptions for this. Our decision will be guided by the two goals
|
|
||||||
of preserving the free status of all derivatives of our free software and
|
|
||||||
of promoting the sharing and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
||||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
||||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
||||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
||||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
||||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
||||||
REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
||||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
||||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
||||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
||||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program is interactive, make it output a short notice like this
|
|
||||||
when it starts in an interactive mode:
|
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) year name of author
|
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, the commands you use may
|
|
||||||
be called something other than `show w' and `show c'; they could even be
|
|
||||||
mouse-clicks or menu items--whatever suits your program.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
||||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1989
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
This General Public License does not permit incorporating your program into
|
|
||||||
proprietary programs. If your program is a subroutine library, you may
|
|
||||||
consider it more useful to permit linking proprietary applications with the
|
|
||||||
library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License.
|
|
||||||
|
|
@ -1,504 +0,0 @@
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
Version 2.1, February 1999
|
|
||||||
|
|
||||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
[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.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
Copyright (C) 2000-2009 Josh Coalson
|
|
||||||
Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
|
|
||||||
- Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
- Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
- Neither the name of the Xiph.Org Foundation nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
278
flac/README.md
278
flac/README.md
|
|
@ -1,278 +0,0 @@
|
||||||
<!---
|
|
||||||
/* FLAC - Free Lossless Audio Codec
|
|
||||||
* Copyright (C) 2001-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* This file is part the FLAC project. FLAC is comprised of several
|
|
||||||
* components distributed under different licenses. The codec libraries
|
|
||||||
* are distributed under Xiph.Org's BSD-like license (see the file
|
|
||||||
* COPYING.Xiph in this distribution). All other programs, libraries, and
|
|
||||||
* plugins are distributed under the LGPL or GPL (see COPYING.LGPL and
|
|
||||||
* COPYING.GPL). The documentation is distributed under the Gnu FDL (see
|
|
||||||
* COPYING.FDL). Each file in the FLAC distribution contains at the top the
|
|
||||||
* terms under which it may be distributed.
|
|
||||||
*
|
|
||||||
* Since this particular file is relevant to all components of FLAC,
|
|
||||||
* it may be distributed under the Xiph.Org license, which is the least
|
|
||||||
* restrictive of those mentioned above. See the file COPYING.Xiph in this
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
--->
|
|
||||||
|
|
||||||
# Free Lossless Audio Codec (FLAC)
|
|
||||||
|
|
||||||
FLAC is open source software that can reduce the amount of storage space
|
|
||||||
needed to store digital audio signals without needing to remove
|
|
||||||
information in doing so.
|
|
||||||
|
|
||||||
The files read and produced by this software are called FLAC files. As
|
|
||||||
these files (which follow the [FLAC format](https://xiph.org/flac/format.html))
|
|
||||||
can be read from and written to by other software as well, this software
|
|
||||||
is often referred to as the FLAC reference implementation.
|
|
||||||
|
|
||||||
FLAC has been developed by volunteers. If you want to help out, see
|
|
||||||
CONTRIBUTING.md for more information.
|
|
||||||
|
|
||||||
## Components
|
|
||||||
|
|
||||||
FLAC is comprised of
|
|
||||||
* libFLAC, a library which implements reference encoders and
|
|
||||||
decoders for native FLAC and Ogg FLAC, and a metadata interface
|
|
||||||
* libFLAC++, a C++ object wrapper library around libFLAC
|
|
||||||
* `flac`, a command-line program for encoding and decoding files
|
|
||||||
* `metaflac`, a command-line program for viewing and editing FLAC
|
|
||||||
metadata
|
|
||||||
* user and API documentation
|
|
||||||
|
|
||||||
The libraries (libFLAC, libFLAC++) are licensed under Xiph.org's
|
|
||||||
BSD-like license (see COPYING.Xiph). All other programs and plugins are
|
|
||||||
licensed under the GNU General Public License (see COPYING.GPL). The
|
|
||||||
documentation is licensed under the GNU Free Documentation License
|
|
||||||
(see COPYING.FDL).
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
For documentation of the `flac` and `metaflac` command line tools, see
|
|
||||||
the directory man, which contains the files flac.md and metaflac.md
|
|
||||||
|
|
||||||
The API documentation is in html and is generated by Doxygen. It can be
|
|
||||||
found in the directory doc/html/api. It is included in a release tarball
|
|
||||||
and must be build with Doxygen when the source is taken directly from
|
|
||||||
git.
|
|
||||||
|
|
||||||
The directory examples contains example source code on using libFLAC and
|
|
||||||
libFLAC++.
|
|
||||||
|
|
||||||
Documentation concerning the FLAC format itself (which can be used to
|
|
||||||
create software reading and writing FLAC software independent from
|
|
||||||
libFLAC) was included in previous releases, but can now be found on
|
|
||||||
https://datatracker.ietf.org/doc/draft-ietf-cellar-flac/ Additionally
|
|
||||||
a set of files for conformance testing called the FLAC decoder testbench
|
|
||||||
can be found at https://github.com/ietf-wg-cellar/flac-test-files
|
|
||||||
|
|
||||||
If you have questions about FLAC that this document does not answer,
|
|
||||||
please submit them at the following tracker so this document can be
|
|
||||||
improved:
|
|
||||||
|
|
||||||
https://github.com/xiph/flac/issues
|
|
||||||
|
|
||||||
## Building FLAC
|
|
||||||
|
|
||||||
All components of the FLAC project can be build with a variety of
|
|
||||||
compilers (including GCC, Clang, Visual Studio, Intel C++ Compiler) on
|
|
||||||
many architectures (inluding x86, x86_64, ARMv7, ARMv8 and PowerPC)
|
|
||||||
for many different operating systems.
|
|
||||||
|
|
||||||
To do this, FLAC provides two build systems: one using GNU's autotools
|
|
||||||
and one with CMake. Both differ slighly in configuration options, but
|
|
||||||
should be considered equivalent for most use cases.
|
|
||||||
|
|
||||||
FLAC used to provide files specifically for building with Visual Studio,
|
|
||||||
but these have been removed in favor of using CMake.
|
|
||||||
|
|
||||||
## Building with CMake
|
|
||||||
|
|
||||||
CMake is a cross-platform build system. FLAC can be built on Windows,
|
|
||||||
Linux, Mac OS X using CMake.
|
|
||||||
|
|
||||||
You can use either CMake's CLI or GUI. We recommend you to have a
|
|
||||||
separate build folder outside the repository in order to not spoil it
|
|
||||||
with generated files. It is possible however to do a so-called in-tree
|
|
||||||
build, in that case /path/to/flac-build in the following examples is
|
|
||||||
equal to /path/to/flac-source.
|
|
||||||
|
|
||||||
### CMake CLI
|
|
||||||
|
|
||||||
Go to your build folder and run something like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ cmake /path/to/flac-source
|
|
||||||
```
|
|
||||||
|
|
||||||
or e.g. in Windows shell
|
|
||||||
|
|
||||||
```
|
|
||||||
C:\path\to\flac-build> cmake \path\to\flac-source
|
|
||||||
```
|
|
||||||
|
|
||||||
(provided that cmake is in your %PATH% variable)
|
|
||||||
|
|
||||||
That will generate build scripts for the default build system (e.g.
|
|
||||||
Makefiles for UNIX). After that you start build with a command like
|
|
||||||
this:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ make
|
|
||||||
```
|
|
||||||
|
|
||||||
And afterwards you can run tests or install the built libraries and
|
|
||||||
headers
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ make test
|
|
||||||
/path/to/flac-build$ make install
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want use a build system other than default add -G flag to cmake,
|
|
||||||
e.g.:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ cmake /path/to/flac-source -GNinja
|
|
||||||
/path/to/flac-build$ ninja
|
|
||||||
```
|
|
||||||
|
|
||||||
or:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ cmake /path/to/flac-source -GXcode
|
|
||||||
```
|
|
||||||
|
|
||||||
Use cmake --help to see the list of available generators.
|
|
||||||
|
|
||||||
By default CMake will search for OGG. If CMake fails to find it you can
|
|
||||||
help CMake by specifying the exact path:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ cmake /path/to/flac-source -DOGG_ROOT=/path/to/ogg
|
|
||||||
```
|
|
||||||
|
|
||||||
If you would like CMake to build OGG alongside FLAC, you can place the
|
|
||||||
ogg sources directly in the flac source directory as a subdirectory with
|
|
||||||
the name ogg, for example:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-source/ogg
|
|
||||||
```
|
|
||||||
|
|
||||||
If you don't want to build flac with OGG support you can tell CMake not
|
|
||||||
to look for OGG:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ cmake /path/to/flac-source -DWITH_OGG=OFF
|
|
||||||
```
|
|
||||||
|
|
||||||
Other FLAC's options (e.g. building C++ lib or docs) can also be put to
|
|
||||||
cmake through -D flag. If you want to know what options are available,
|
|
||||||
use -LH:
|
|
||||||
|
|
||||||
```
|
|
||||||
/path/to/flac-build$ cmake /path/to/flac-source -LH
|
|
||||||
```
|
|
||||||
|
|
||||||
### CMake GUI (for Visual Studio)
|
|
||||||
It is likely that you would prefer to use the CMake GUI if you use
|
|
||||||
Visual Studio to build FLAC. It's in essence the same process as
|
|
||||||
building using CLI.
|
|
||||||
|
|
||||||
Open cmake-gui. In the window select a source directory (the
|
|
||||||
repository's root), a build directory (some other directory outside the
|
|
||||||
repository). Then press button "Configure". CMake will ask you which
|
|
||||||
build system you prefer. Choose that version of Visual Studio which you
|
|
||||||
have on your system, choose whether you want to build for Win32 or x64.
|
|
||||||
Press OK.
|
|
||||||
|
|
||||||
After CMake finishes you can change the configuration to your liking and
|
|
||||||
if you change anything, run Configure again. With the "Generate" button,
|
|
||||||
CMake creates Visual Studio files, which can be opened from Visual
|
|
||||||
Studio. With the button "Open Project" CMake will launch Visual Studio
|
|
||||||
and open the generated solution. You can use the project files as usual
|
|
||||||
but remember that they were generated by CMake. That means that your
|
|
||||||
changes (e.g. some additional compile flags) will be lost when you run
|
|
||||||
CMake next time.
|
|
||||||
|
|
||||||
CMake searches by default for OGG on your system and returns an error
|
|
||||||
if it cannot find it. If you want to build OGG alongside FLAC, you can
|
|
||||||
download the OGG sources and extract them in a subdirectory of the FLAC
|
|
||||||
source directory with the name ogg (i.e. /path/to/flac-source/ogg)
|
|
||||||
before running CMake. If you don't want to build FLAC with OGG support,
|
|
||||||
untick the box following WITH_OGG flag in the list of variables in
|
|
||||||
cmake-gui window and run "Configure" again.
|
|
||||||
|
|
||||||
If CMake fails to find MSVC compiler then running cmake-gui from MS
|
|
||||||
Developer comand prompt should help.
|
|
||||||
|
|
||||||
## Building with GNU autotools
|
|
||||||
|
|
||||||
FLAC uses autoconf and libtool for configuring and building. To
|
|
||||||
configure a build, open a commmand line/terminal and run `./configure`
|
|
||||||
You can provide options to this command, which are listed by running
|
|
||||||
`./configure --help`.
|
|
||||||
|
|
||||||
In case the configure script is not present (for example when building
|
|
||||||
from git and not from a release tarball), it can be generated by running
|
|
||||||
`./autogen.sh`. This may require a libtool development package though.
|
|
||||||
|
|
||||||
After configuration, build with `make`, verify the build with
|
|
||||||
`make check` and install with `make install`. Installation might require
|
|
||||||
administrator priviledged, i.e. `sudo make install`.
|
|
||||||
|
|
||||||
The 'make check' step is optional; omit it to skip all the tests, which
|
|
||||||
can take about an hour to complete. Even though it will stop with an
|
|
||||||
explicit message on any failure, it does print out a lot of stuff so you
|
|
||||||
might want to capture the output to a file if you're having a problem.
|
|
||||||
Also, don't run 'make check' as root because it confuses some of the
|
|
||||||
tests.
|
|
||||||
|
|
||||||
Summarizing:
|
|
||||||
|
|
||||||
```
|
|
||||||
./configure
|
|
||||||
make && make check
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Note to embedded developers
|
|
||||||
|
|
||||||
libFLAC has grown larger over time as more functionality has been
|
|
||||||
included, but much of it may be unnecessary for a particular embedded
|
|
||||||
implementation. Unused parts may be pruned by some simple editing of
|
|
||||||
configure.ac and src/libFLAC/Makefile.am; the following dependency
|
|
||||||
graph shows which modules may be pruned without breaking things
|
|
||||||
further down:
|
|
||||||
|
|
||||||
```
|
|
||||||
metadata.h
|
|
||||||
stream_decoder.h
|
|
||||||
format.h
|
|
||||||
|
|
||||||
stream_encoder.h
|
|
||||||
stream_decoder.h
|
|
||||||
format.h
|
|
||||||
|
|
||||||
stream_decoder.h
|
|
||||||
format.h
|
|
||||||
```
|
|
||||||
|
|
||||||
In other words, for pure decoding applications, both the stream encoder
|
|
||||||
and metadata editing interfaces can be safely removed. Note that this
|
|
||||||
is specific to building the libraries for embedded use. The command line
|
|
||||||
tools do not provide such compartmentalization, and require a complete
|
|
||||||
libFLAC build to function.
|
|
||||||
|
|
||||||
There is a section dedicated to embedded use in the libFLAC API
|
|
||||||
HTML documentation (see doc/html/api/index.html).
|
|
||||||
|
|
||||||
Also, there are several places in the libFLAC code with comments marked
|
|
||||||
with "OPT:" where a #define can be changed to enable code that might be
|
|
||||||
faster on a specific platform. Experimenting with these can yield
|
|
||||||
faster binaries.
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
local m = {}
|
|
||||||
|
|
||||||
local scriptdir = path.getabsolute(path.getdirectory(_SCRIPT))
|
|
||||||
local ogg = require("vendor/ogg/build-ogg")
|
|
||||||
function m.generateproject(liboutdir, intdir)
|
|
||||||
project"flac"
|
|
||||||
language"C" -- c++ will mangle names and sfml wont build
|
|
||||||
kind"staticLib"
|
|
||||||
targetdir (liboutdir)
|
|
||||||
objdir(intdir)
|
|
||||||
warnings"Off"
|
|
||||||
|
|
||||||
ogg.link()
|
|
||||||
|
|
||||||
defines
|
|
||||||
{
|
|
||||||
"FLAC__NO_DLL",
|
|
||||||
"CPU_IS_BIG_ENDIAN=0",
|
|
||||||
"FLAC__HAS_OGG=1",
|
|
||||||
"PACKAGE_VERSION=\"\"",
|
|
||||||
}
|
|
||||||
|
|
||||||
filter"system:linux"
|
|
||||||
defines
|
|
||||||
{
|
|
||||||
"HAVE_LROUND",--fix error in lpc.c <Static declaration of 'lround' follows non-static declaration>
|
|
||||||
"HAVE_STDINT_H", --fix error in alloc.h <# error>
|
|
||||||
}
|
|
||||||
|
|
||||||
includedirs
|
|
||||||
{
|
|
||||||
path.join(scriptdir, "include"),
|
|
||||||
path.join(scriptdir, "src/libFLAC/include"),
|
|
||||||
}
|
|
||||||
|
|
||||||
files
|
|
||||||
{
|
|
||||||
path.join(scriptdir, "src/libFLAC/**.c"),
|
|
||||||
}
|
|
||||||
|
|
||||||
removefiles
|
|
||||||
{
|
|
||||||
path.join(scriptdir, "src/libFLAC/deduplication/**"),
|
|
||||||
}
|
|
||||||
|
|
||||||
filter"system:windows"
|
|
||||||
files
|
|
||||||
{
|
|
||||||
path.join(scriptdir, "src/share/win_utf8_io/**.c"),
|
|
||||||
}
|
|
||||||
|
|
||||||
filter""
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function m.link()
|
|
||||||
externalincludedirs
|
|
||||||
{
|
|
||||||
path.join(scriptdir, "include"),
|
|
||||||
path.join(scriptdir, "src/libFLAC/include"),
|
|
||||||
path.join(scriptdir, "../ogg/include")
|
|
||||||
}
|
|
||||||
links {"flac", "ogg"}
|
|
||||||
end
|
|
||||||
|
|
||||||
return m
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
# libFLAC++ - Free Lossless Audio Codec library
|
|
||||||
# Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# - Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# - Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
|
||||||
# documentation and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
# contributors may be used to endorse or promote products derived from
|
|
||||||
# this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
flaccppincludedir = $(includedir)/FLAC++
|
|
||||||
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
|
|
||||||
flaccppinclude_HEADERS = \
|
|
||||||
all.h \
|
|
||||||
decoder.h \
|
|
||||||
encoder.h \
|
|
||||||
export.h \
|
|
||||||
metadata.h
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
/* libFLAC++ - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLACPP__ALL_H
|
|
||||||
#define FLACPP__ALL_H
|
|
||||||
|
|
||||||
#include "export.h"
|
|
||||||
|
|
||||||
#include "encoder.h"
|
|
||||||
#include "decoder.h"
|
|
||||||
#include "metadata.h"
|
|
||||||
|
|
||||||
/** \defgroup flacpp FLAC C++ API
|
|
||||||
*
|
|
||||||
* The FLAC C++ API is the interface to libFLAC++, a set of classes
|
|
||||||
* that encapsulate the encoders, decoders, and metadata interfaces
|
|
||||||
* in libFLAC.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,248 +0,0 @@
|
||||||
/* libFLAC++ - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLACPP__DECODER_H
|
|
||||||
#define FLACPP__DECODER_H
|
|
||||||
|
|
||||||
#include "export.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "FLAC/stream_decoder.h"
|
|
||||||
|
|
||||||
|
|
||||||
/** \file include/FLAC++/decoder.h
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module contains the classes which implement the various
|
|
||||||
* decoders.
|
|
||||||
*
|
|
||||||
* See the detailed documentation in the
|
|
||||||
* \link flacpp_decoder decoder \endlink module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup flacpp_decoder FLAC++/decoder.h: decoder classes
|
|
||||||
* \ingroup flacpp
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module describes the decoder layers provided by libFLAC++.
|
|
||||||
*
|
|
||||||
* The libFLAC++ decoder classes are object wrappers around their
|
|
||||||
* counterparts in libFLAC. All decoding layers available in
|
|
||||||
* libFLAC are also provided here. The interface is very similar;
|
|
||||||
* make sure to read the \link flac_decoder libFLAC decoder module \endlink.
|
|
||||||
*
|
|
||||||
* There are only two significant differences here. First, instead of
|
|
||||||
* passing in C function pointers for callbacks, you inherit from the
|
|
||||||
* decoder class and provide implementations for the callbacks in your
|
|
||||||
* derived class; because of this there is no need for a 'client_data'
|
|
||||||
* property.
|
|
||||||
*
|
|
||||||
* Second, there are two stream decoder classes. FLAC::Decoder::Stream
|
|
||||||
* is used for the same cases that FLAC__stream_decoder_init_stream() /
|
|
||||||
* FLAC__stream_decoder_init_ogg_stream() are used, and FLAC::Decoder::File
|
|
||||||
* is used for the same cases that
|
|
||||||
* FLAC__stream_decoder_init_FILE() and FLAC__stream_decoder_init_file() /
|
|
||||||
* FLAC__stream_decoder_init_ogg_FILE() and FLAC__stream_decoder_init_ogg_file()
|
|
||||||
* are used.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace FLAC {
|
|
||||||
namespace Decoder {
|
|
||||||
|
|
||||||
/** \ingroup flacpp_decoder
|
|
||||||
* \brief
|
|
||||||
* This class wraps the ::FLAC__StreamDecoder. If you are
|
|
||||||
* decoding from a file, FLAC::Decoder::File may be more
|
|
||||||
* convenient.
|
|
||||||
*
|
|
||||||
* The usage of this class is similar to FLAC__StreamDecoder,
|
|
||||||
* except instead of providing callbacks to
|
|
||||||
* FLAC__stream_decoder_init*_stream(), you will inherit from this
|
|
||||||
* class and override the virtual callback functions with your
|
|
||||||
* own implementations, then call init() or init_ogg(). The rest
|
|
||||||
* of the calls work the same as in the C layer.
|
|
||||||
*
|
|
||||||
* Only the read, write, and error callbacks are mandatory. The
|
|
||||||
* others are optional; this class provides default
|
|
||||||
* implementations that do nothing. In order for seeking to work
|
|
||||||
* you must override seek_callback(), tell_callback(),
|
|
||||||
* length_callback(), and eof_callback().
|
|
||||||
*/
|
|
||||||
class FLACPP_API Stream {
|
|
||||||
public:
|
|
||||||
/** This class is a wrapper around FLAC__StreamDecoderState.
|
|
||||||
*/
|
|
||||||
class FLACPP_API State {
|
|
||||||
public:
|
|
||||||
inline State(::FLAC__StreamDecoderState state): state_(state) { }
|
|
||||||
inline operator ::FLAC__StreamDecoderState() const { return state_; }
|
|
||||||
inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
|
|
||||||
inline const char *resolved_as_cstring(const Stream &decoder) const { return ::FLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); }
|
|
||||||
protected:
|
|
||||||
::FLAC__StreamDecoderState state_;
|
|
||||||
};
|
|
||||||
|
|
||||||
Stream();
|
|
||||||
virtual ~Stream();
|
|
||||||
|
|
||||||
//@{
|
|
||||||
/** Call after construction to check that the object was created
|
|
||||||
* successfully. If not, use get_state() to find out why not.
|
|
||||||
*/
|
|
||||||
virtual bool is_valid() const;
|
|
||||||
inline operator bool() const { return is_valid(); } ///< See is_valid()
|
|
||||||
//@}
|
|
||||||
|
|
||||||
virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_decoder_set_ogg_serial_number()
|
|
||||||
virtual bool set_md5_checking(bool value); ///< See FLAC__stream_decoder_set_md5_checking()
|
|
||||||
virtual bool set_metadata_respond(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_respond()
|
|
||||||
virtual bool set_metadata_respond_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_respond_application()
|
|
||||||
virtual bool set_metadata_respond_all(); ///< See FLAC__stream_decoder_set_metadata_respond_all()
|
|
||||||
virtual bool set_metadata_ignore(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_ignore()
|
|
||||||
virtual bool set_metadata_ignore_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_ignore_application()
|
|
||||||
virtual bool set_metadata_ignore_all(); ///< See FLAC__stream_decoder_set_metadata_ignore_all()
|
|
||||||
|
|
||||||
/* get_state() is not virtual since we want subclasses to be able to return their own state */
|
|
||||||
State get_state() const; ///< See FLAC__stream_decoder_get_state()
|
|
||||||
virtual bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking()
|
|
||||||
virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
|
|
||||||
virtual uint32_t get_channels() const; ///< See FLAC__stream_decoder_get_channels()
|
|
||||||
virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
|
|
||||||
virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
|
|
||||||
virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
|
|
||||||
virtual uint32_t get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize()
|
|
||||||
virtual bool get_decode_position(FLAC__uint64 *position) const; ///< See FLAC__stream_decoder_get_decode_position()
|
|
||||||
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init(); ///< Seek FLAC__stream_decoder_init_stream()
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init_ogg(); ///< Seek FLAC__stream_decoder_init_ogg_stream()
|
|
||||||
|
|
||||||
virtual bool finish(); ///< See FLAC__stream_decoder_finish()
|
|
||||||
|
|
||||||
virtual bool flush(); ///< See FLAC__stream_decoder_flush()
|
|
||||||
virtual bool reset(); ///< See FLAC__stream_decoder_reset()
|
|
||||||
|
|
||||||
virtual bool process_single(); ///< See FLAC__stream_decoder_process_single()
|
|
||||||
virtual bool process_until_end_of_metadata(); ///< See FLAC__stream_decoder_process_until_end_of_metadata()
|
|
||||||
virtual bool process_until_end_of_stream(); ///< See FLAC__stream_decoder_process_until_end_of_stream()
|
|
||||||
virtual bool skip_single_frame(); ///< See FLAC__stream_decoder_skip_single_frame()
|
|
||||||
|
|
||||||
virtual bool seek_absolute(FLAC__uint64 sample); ///< See FLAC__stream_decoder_seek_absolute()
|
|
||||||
protected:
|
|
||||||
/// see FLAC__StreamDecoderReadCallback
|
|
||||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) = 0;
|
|
||||||
|
|
||||||
/// see FLAC__StreamDecoderSeekCallback
|
|
||||||
virtual ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
|
|
||||||
|
|
||||||
/// see FLAC__StreamDecoderTellCallback
|
|
||||||
virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
|
|
||||||
|
|
||||||
/// see FLAC__StreamDecoderLengthCallback
|
|
||||||
virtual ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
|
|
||||||
|
|
||||||
/// see FLAC__StreamDecoderEofCallback
|
|
||||||
virtual bool eof_callback();
|
|
||||||
|
|
||||||
/// see FLAC__StreamDecoderWriteCallback
|
|
||||||
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
|
|
||||||
|
|
||||||
/// see FLAC__StreamDecoderMetadataCallback
|
|
||||||
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
|
||||||
|
|
||||||
/// see FLAC__StreamDecoderErrorCallback
|
|
||||||
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
|
|
||||||
|
|
||||||
#if (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
|
|
||||||
// lame hack: some compilers can't see a protected decoder_ from nested State::resolved_as_cstring()
|
|
||||||
friend State;
|
|
||||||
#endif
|
|
||||||
::FLAC__StreamDecoder *decoder_;
|
|
||||||
|
|
||||||
static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
|
||||||
static ::FLAC__StreamDecoderSeekStatus seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
|
||||||
static ::FLAC__StreamDecoderTellStatus tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
|
||||||
static ::FLAC__StreamDecoderLengthStatus length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
|
|
||||||
static FLAC__bool eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data);
|
|
||||||
static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
|
|
||||||
static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
|
|
||||||
static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
|
|
||||||
private:
|
|
||||||
// Private and undefined so you can't use them:
|
|
||||||
Stream(const Stream &);
|
|
||||||
void operator=(const Stream &);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** \ingroup flacpp_decoder
|
|
||||||
* \brief
|
|
||||||
* This class wraps the ::FLAC__StreamDecoder. If you are
|
|
||||||
* not decoding from a file, you may need to use
|
|
||||||
* FLAC::Decoder::Stream.
|
|
||||||
*
|
|
||||||
* The usage of this class is similar to FLAC__StreamDecoder,
|
|
||||||
* except instead of providing callbacks to
|
|
||||||
* FLAC__stream_decoder_init*_FILE() or
|
|
||||||
* FLAC__stream_decoder_init*_file(), you will inherit from this
|
|
||||||
* class and override the virtual callback functions with your
|
|
||||||
* own implementations, then call init() or init_off(). The rest
|
|
||||||
* of the calls work the same as in the C layer.
|
|
||||||
*
|
|
||||||
* Only the write, and error callbacks from FLAC::Decoder::Stream
|
|
||||||
* are mandatory. The others are optional; this class provides
|
|
||||||
* full working implementations for all other callbacks and
|
|
||||||
* supports seeking.
|
|
||||||
*/
|
|
||||||
class FLACPP_API File: public Stream {
|
|
||||||
public:
|
|
||||||
File();
|
|
||||||
virtual ~File();
|
|
||||||
|
|
||||||
using Stream::init;
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init(FILE *file); ///< See FLAC__stream_decoder_init_FILE()
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init(const char *filename); ///< See FLAC__stream_decoder_init_file()
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init(const std::string &filename); ///< See FLAC__stream_decoder_init_file()
|
|
||||||
using Stream::init_ogg;
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init_ogg(FILE *file); ///< See FLAC__stream_decoder_init_ogg_FILE()
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init_ogg(const char *filename); ///< See FLAC__stream_decoder_init_ogg_file()
|
|
||||||
virtual ::FLAC__StreamDecoderInitStatus init_ogg(const std::string &filename); ///< See FLAC__stream_decoder_init_ogg_file()
|
|
||||||
protected:
|
|
||||||
// this is a dummy implementation to satisfy the pure virtual in Stream that is actually supplied internally by the C layer
|
|
||||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
|
|
||||||
private:
|
|
||||||
// Private and undefined so you can't use them:
|
|
||||||
File(const File &);
|
|
||||||
void operator=(const File &);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,265 +0,0 @@
|
||||||
/* libFLAC++ - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLACPP__ENCODER_H
|
|
||||||
#define FLACPP__ENCODER_H
|
|
||||||
|
|
||||||
#include "export.h"
|
|
||||||
|
|
||||||
#include "FLAC/stream_encoder.h"
|
|
||||||
#include "decoder.h"
|
|
||||||
#include "metadata.h"
|
|
||||||
|
|
||||||
|
|
||||||
/** \file include/FLAC++/encoder.h
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module contains the classes which implement the various
|
|
||||||
* encoders.
|
|
||||||
*
|
|
||||||
* See the detailed documentation in the
|
|
||||||
* \link flacpp_encoder encoder \endlink module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup flacpp_encoder FLAC++/encoder.h: encoder classes
|
|
||||||
* \ingroup flacpp
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module describes the encoder layers provided by libFLAC++.
|
|
||||||
*
|
|
||||||
* The libFLAC++ encoder classes are object wrappers around their
|
|
||||||
* counterparts in libFLAC. All encoding layers available in
|
|
||||||
* libFLAC are also provided here. The interface is very similar;
|
|
||||||
* make sure to read the \link flac_encoder libFLAC encoder module \endlink.
|
|
||||||
*
|
|
||||||
* There are only two significant differences here. First, instead of
|
|
||||||
* passing in C function pointers for callbacks, you inherit from the
|
|
||||||
* encoder class and provide implementations for the callbacks in your
|
|
||||||
* derived class; because of this there is no need for a 'client_data'
|
|
||||||
* property.
|
|
||||||
*
|
|
||||||
* Second, there are two stream encoder classes. FLAC::Encoder::Stream
|
|
||||||
* is used for the same cases that FLAC__stream_encoder_init_stream() /
|
|
||||||
* FLAC__stream_encoder_init_ogg_stream() are used, and FLAC::Encoder::File
|
|
||||||
* is used for the same cases that
|
|
||||||
* FLAC__stream_encoder_init_FILE() and FLAC__stream_encoder_init_file() /
|
|
||||||
* FLAC__stream_encoder_init_ogg_FILE() and FLAC__stream_encoder_init_ogg_file()
|
|
||||||
* are used.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace FLAC {
|
|
||||||
namespace Encoder {
|
|
||||||
|
|
||||||
/** \ingroup flacpp_encoder
|
|
||||||
* \brief
|
|
||||||
* This class wraps the ::FLAC__StreamEncoder. If you are
|
|
||||||
* encoding to a file, FLAC::Encoder::File may be more
|
|
||||||
* convenient.
|
|
||||||
*
|
|
||||||
* The usage of this class is similar to FLAC__StreamEncoder,
|
|
||||||
* except instead of providing callbacks to
|
|
||||||
* FLAC__stream_encoder_init*_stream(), you will inherit from this
|
|
||||||
* class and override the virtual callback functions with your
|
|
||||||
* own implementations, then call init() or init_ogg(). The rest of
|
|
||||||
* the calls work the same as in the C layer.
|
|
||||||
*
|
|
||||||
* Only the write callback is mandatory. The others are
|
|
||||||
* optional; this class provides default implementations that do
|
|
||||||
* nothing. In order for some STREAMINFO and SEEKTABLE data to
|
|
||||||
* be written properly, you must override seek_callback() and
|
|
||||||
* tell_callback(); see FLAC__stream_encoder_init_stream() as to
|
|
||||||
* why.
|
|
||||||
*/
|
|
||||||
class FLACPP_API Stream {
|
|
||||||
public:
|
|
||||||
/** This class is a wrapper around FLAC__StreamEncoderState.
|
|
||||||
*/
|
|
||||||
class FLACPP_API State {
|
|
||||||
public:
|
|
||||||
inline State(::FLAC__StreamEncoderState state): state_(state) { }
|
|
||||||
inline operator ::FLAC__StreamEncoderState() const { return state_; }
|
|
||||||
inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
|
|
||||||
inline const char *resolved_as_cstring(const Stream &encoder) const { return ::FLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
|
|
||||||
protected:
|
|
||||||
::FLAC__StreamEncoderState state_;
|
|
||||||
};
|
|
||||||
|
|
||||||
Stream();
|
|
||||||
virtual ~Stream();
|
|
||||||
|
|
||||||
//@{
|
|
||||||
/** Call after construction to check that the object was created
|
|
||||||
* successfully. If not, use get_state() to find out why not.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual bool is_valid() const;
|
|
||||||
inline operator bool() const { return is_valid(); } ///< See is_valid()
|
|
||||||
//@}
|
|
||||||
|
|
||||||
virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_encoder_set_ogg_serial_number()
|
|
||||||
virtual bool set_verify(bool value); ///< See FLAC__stream_encoder_set_verify()
|
|
||||||
virtual bool set_streamable_subset(bool value); ///< See FLAC__stream_encoder_set_streamable_subset()
|
|
||||||
virtual bool set_channels(uint32_t value); ///< See FLAC__stream_encoder_set_channels()
|
|
||||||
virtual bool set_bits_per_sample(uint32_t value); ///< See FLAC__stream_encoder_set_bits_per_sample()
|
|
||||||
virtual bool set_sample_rate(uint32_t value); ///< See FLAC__stream_encoder_set_sample_rate()
|
|
||||||
virtual bool set_compression_level(uint32_t value); ///< See FLAC__stream_encoder_set_compression_level()
|
|
||||||
virtual bool set_blocksize(uint32_t value); ///< See FLAC__stream_encoder_set_blocksize()
|
|
||||||
virtual bool set_do_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_do_mid_side_stereo()
|
|
||||||
virtual bool set_loose_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_loose_mid_side_stereo()
|
|
||||||
virtual bool set_apodization(const char *specification); ///< See FLAC__stream_encoder_set_apodization()
|
|
||||||
virtual bool set_max_lpc_order(uint32_t value); ///< See FLAC__stream_encoder_set_max_lpc_order()
|
|
||||||
virtual bool set_qlp_coeff_precision(uint32_t value); ///< See FLAC__stream_encoder_set_qlp_coeff_precision()
|
|
||||||
virtual bool set_do_qlp_coeff_prec_search(bool value); ///< See FLAC__stream_encoder_set_do_qlp_coeff_prec_search()
|
|
||||||
virtual bool set_do_escape_coding(bool value); ///< See FLAC__stream_encoder_set_do_escape_coding()
|
|
||||||
virtual bool set_do_exhaustive_model_search(bool value); ///< See FLAC__stream_encoder_set_do_exhaustive_model_search()
|
|
||||||
virtual bool set_min_residual_partition_order(uint32_t value); ///< See FLAC__stream_encoder_set_min_residual_partition_order()
|
|
||||||
virtual bool set_max_residual_partition_order(uint32_t value); ///< See FLAC__stream_encoder_set_max_residual_partition_order()
|
|
||||||
virtual bool set_rice_parameter_search_dist(uint32_t value); ///< See FLAC__stream_encoder_set_rice_parameter_search_dist()
|
|
||||||
virtual bool set_total_samples_estimate(FLAC__uint64 value); ///< See FLAC__stream_encoder_set_total_samples_estimate()
|
|
||||||
virtual bool set_metadata(::FLAC__StreamMetadata **metadata, uint32_t num_blocks); ///< See FLAC__stream_encoder_set_metadata()
|
|
||||||
virtual bool set_metadata(FLAC::Metadata::Prototype **metadata, uint32_t num_blocks); ///< See FLAC__stream_encoder_set_metadata()
|
|
||||||
virtual bool set_limit_min_bitrate(bool value); ///< See FLAC__stream_encoder_set_limit_min_bitrate()
|
|
||||||
|
|
||||||
/* get_state() is not virtual since we want subclasses to be able to return their own state */
|
|
||||||
State get_state() const; ///< See FLAC__stream_encoder_get_state()
|
|
||||||
virtual Decoder::Stream::State get_verify_decoder_state() const; ///< See FLAC__stream_encoder_get_verify_decoder_state()
|
|
||||||
virtual void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got); ///< See FLAC__stream_encoder_get_verify_decoder_error_stats()
|
|
||||||
virtual bool get_verify() const; ///< See FLAC__stream_encoder_get_verify()
|
|
||||||
virtual bool get_streamable_subset() const; ///< See FLAC__stream_encoder_get_streamable_subset()
|
|
||||||
virtual bool get_do_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_do_mid_side_stereo()
|
|
||||||
virtual bool get_loose_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_loose_mid_side_stereo()
|
|
||||||
virtual uint32_t get_channels() const; ///< See FLAC__stream_encoder_get_channels()
|
|
||||||
virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_encoder_get_bits_per_sample()
|
|
||||||
virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_encoder_get_sample_rate()
|
|
||||||
virtual uint32_t get_blocksize() const; ///< See FLAC__stream_encoder_get_blocksize()
|
|
||||||
virtual uint32_t get_max_lpc_order() const; ///< See FLAC__stream_encoder_get_max_lpc_order()
|
|
||||||
virtual uint32_t get_qlp_coeff_precision() const; ///< See FLAC__stream_encoder_get_qlp_coeff_precision()
|
|
||||||
virtual bool get_do_qlp_coeff_prec_search() const; ///< See FLAC__stream_encoder_get_do_qlp_coeff_prec_search()
|
|
||||||
virtual bool get_do_escape_coding() const; ///< See FLAC__stream_encoder_get_do_escape_coding()
|
|
||||||
virtual bool get_do_exhaustive_model_search() const; ///< See FLAC__stream_encoder_get_do_exhaustive_model_search()
|
|
||||||
virtual uint32_t get_min_residual_partition_order() const; ///< See FLAC__stream_encoder_get_min_residual_partition_order()
|
|
||||||
virtual uint32_t get_max_residual_partition_order() const; ///< See FLAC__stream_encoder_get_max_residual_partition_order()
|
|
||||||
virtual uint32_t get_rice_parameter_search_dist() const; ///< See FLAC__stream_encoder_get_rice_parameter_search_dist()
|
|
||||||
virtual FLAC__uint64 get_total_samples_estimate() const; ///< See FLAC__stream_encoder_get_total_samples_estimate()
|
|
||||||
virtual bool get_limit_min_bitrate() const; ///< See FLAC__stream_encoder_get_limit_min_bitrate()
|
|
||||||
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init(); ///< See FLAC__stream_encoder_init_stream()
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init_ogg(); ///< See FLAC__stream_encoder_init_ogg_stream()
|
|
||||||
|
|
||||||
virtual bool finish(); ///< See FLAC__stream_encoder_finish()
|
|
||||||
|
|
||||||
virtual bool process(const FLAC__int32 * const buffer[], uint32_t samples); ///< See FLAC__stream_encoder_process()
|
|
||||||
virtual bool process_interleaved(const FLAC__int32 buffer[], uint32_t samples); ///< See FLAC__stream_encoder_process_interleaved()
|
|
||||||
protected:
|
|
||||||
/// See FLAC__StreamEncoderReadCallback
|
|
||||||
virtual ::FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
|
|
||||||
|
|
||||||
/// See FLAC__StreamEncoderWriteCallback
|
|
||||||
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame) = 0;
|
|
||||||
|
|
||||||
/// See FLAC__StreamEncoderSeekCallback
|
|
||||||
virtual ::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
|
|
||||||
|
|
||||||
/// See FLAC__StreamEncoderTellCallback
|
|
||||||
virtual ::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
|
|
||||||
|
|
||||||
/// See FLAC__StreamEncoderMetadataCallback
|
|
||||||
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
|
||||||
|
|
||||||
#if (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
|
|
||||||
// lame hack: some compilers can't see a protected encoder_ from nested State::resolved_as_cstring()
|
|
||||||
friend State;
|
|
||||||
#endif
|
|
||||||
::FLAC__StreamEncoder *encoder_;
|
|
||||||
|
|
||||||
static ::FLAC__StreamEncoderReadStatus read_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
|
||||||
static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data);
|
|
||||||
static ::FLAC__StreamEncoderSeekStatus seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
|
||||||
static ::FLAC__StreamEncoderTellStatus tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
|
||||||
static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
|
|
||||||
private:
|
|
||||||
// Private and undefined so you can't use them:
|
|
||||||
Stream(const Stream &);
|
|
||||||
void operator=(const Stream &);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** \ingroup flacpp_encoder
|
|
||||||
* \brief
|
|
||||||
* This class wraps the ::FLAC__StreamEncoder. If you are
|
|
||||||
* not encoding to a file, you may need to use
|
|
||||||
* FLAC::Encoder::Stream.
|
|
||||||
*
|
|
||||||
* The usage of this class is similar to FLAC__StreamEncoder,
|
|
||||||
* except instead of providing callbacks to
|
|
||||||
* FLAC__stream_encoder_init*_FILE() or
|
|
||||||
* FLAC__stream_encoder_init*_file(), you will inherit from this
|
|
||||||
* class and override the virtual callback functions with your
|
|
||||||
* own implementations, then call init() or init_ogg(). The rest
|
|
||||||
* of the calls work the same as in the C layer.
|
|
||||||
*
|
|
||||||
* There are no mandatory callbacks; all the callbacks from
|
|
||||||
* FLAC::Encoder::Stream are implemented here fully and support
|
|
||||||
* full post-encode STREAMINFO and SEEKTABLE updating. There is
|
|
||||||
* only an optional progress callback which you may override to
|
|
||||||
* get periodic reports on the progress of the encode.
|
|
||||||
*/
|
|
||||||
class FLACPP_API File: public Stream {
|
|
||||||
public:
|
|
||||||
File();
|
|
||||||
virtual ~File();
|
|
||||||
|
|
||||||
using Stream::init;
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init(FILE *file); ///< See FLAC__stream_encoder_init_FILE()
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init(const char *filename); ///< See FLAC__stream_encoder_init_file()
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init(const std::string &filename); ///< See FLAC__stream_encoder_init_file()
|
|
||||||
using Stream::init_ogg;
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init_ogg(FILE *file); ///< See FLAC__stream_encoder_init_ogg_FILE()
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init_ogg(const char *filename); ///< See FLAC__stream_encoder_init_ogg_file()
|
|
||||||
virtual ::FLAC__StreamEncoderInitStatus init_ogg(const std::string &filename); ///< See FLAC__stream_encoder_init_ogg_file()
|
|
||||||
protected:
|
|
||||||
/// See FLAC__StreamEncoderProgressCallback
|
|
||||||
virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate);
|
|
||||||
|
|
||||||
/// This is a dummy implementation to satisfy the pure virtual in Stream that is actually supplied internally by the C layer
|
|
||||||
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame);
|
|
||||||
private:
|
|
||||||
static void progress_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data);
|
|
||||||
|
|
||||||
// Private and undefined so you can't use them:
|
|
||||||
File(const Stream &);
|
|
||||||
void operator=(const Stream &);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
/* libFLAC++ - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLACPP__EXPORT_H
|
|
||||||
#define FLACPP__EXPORT_H
|
|
||||||
|
|
||||||
/** \file include/FLAC++/export.h
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module contains \#defines and symbols for exporting function
|
|
||||||
* calls, and providing version information and compiled-in features.
|
|
||||||
*
|
|
||||||
* See the \link flacpp_export export \endlink module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup flacpp_export FLAC++/export.h: export symbols
|
|
||||||
* \ingroup flacpp
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module contains \#defines and symbols for exporting function
|
|
||||||
* calls, and providing version information and compiled-in features.
|
|
||||||
*
|
|
||||||
* If you are compiling for Windows (with Visual Studio or MinGW for
|
|
||||||
* example) and will link to the static library (libFLAC++.lib) you
|
|
||||||
* should define FLAC__NO_DLL in your project to make sure the symbols
|
|
||||||
* are exported properly.
|
|
||||||
*
|
|
||||||
* \{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** This \#define is used internally in libFLAC and its headers to make
|
|
||||||
* sure the correct symbols are exported when working with shared
|
|
||||||
* libraries. On Windows, this \#define is set to __declspec(dllexport)
|
|
||||||
* when compiling libFLAC into a library and to __declspec(dllimport)
|
|
||||||
* when the headers are used to link to that DLL. On non-Windows systems
|
|
||||||
* it is used to set symbol visibility.
|
|
||||||
*
|
|
||||||
* Because of this, the define FLAC__NO_DLL must be defined when linking
|
|
||||||
* to libFLAC statically or linking will fail.
|
|
||||||
*/
|
|
||||||
/* This has grown quite complicated. FLAC__NO_DLL is used by MSVC sln
|
|
||||||
* files and CMake, which build either static or shared. autotools can
|
|
||||||
* build static, shared or **both**. Therefore, DLL_EXPORT, which is set
|
|
||||||
* by libtool, must override FLAC__NO_DLL on building shared components
|
|
||||||
*/
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
|
|
||||||
#define FLACPP_API
|
|
||||||
#else
|
|
||||||
#ifdef FLACPP_API_EXPORTS
|
|
||||||
#define FLACPP_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define FLACPP_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#elif defined(FLAC__USE_VISIBILITY_ATTR)
|
|
||||||
#define FLACPP_API __attribute__ ((visibility ("default")))
|
|
||||||
#else
|
|
||||||
#define FLACPP_API
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** These \#defines will mirror the libtool-based library version number, see
|
|
||||||
* http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
|
|
||||||
*/
|
|
||||||
#define FLACPP_API_VERSION_CURRENT 10
|
|
||||||
#define FLACPP_API_VERSION_REVISION 1 /**< see above */
|
|
||||||
#define FLACPP_API_VERSION_AGE 0 /**< see above */
|
|
||||||
|
|
||||||
/* \} */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,43 +0,0 @@
|
||||||
# libFLAC - Free Lossless Audio Codec library
|
|
||||||
# Copyright (C) 2000-2009 Josh Coalson
|
|
||||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# - Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# - Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
|
||||||
# documentation and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
# contributors may be used to endorse or promote products derived from
|
|
||||||
# this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
flaccincludedir = $(includedir)/FLAC
|
|
||||||
|
|
||||||
flaccinclude_HEADERS = \
|
|
||||||
all.h \
|
|
||||||
assert.h \
|
|
||||||
callback.h \
|
|
||||||
export.h \
|
|
||||||
format.h \
|
|
||||||
metadata.h \
|
|
||||||
ordinals.h \
|
|
||||||
stream_decoder.h \
|
|
||||||
stream_encoder.h
|
|
||||||
|
|
@ -1,450 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2000-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__ALL_H
|
|
||||||
#define FLAC__ALL_H
|
|
||||||
|
|
||||||
#include "export.h"
|
|
||||||
|
|
||||||
#include "assert.h"
|
|
||||||
#include "callback.h"
|
|
||||||
#include "format.h"
|
|
||||||
#include "metadata.h"
|
|
||||||
#include "ordinals.h"
|
|
||||||
#include "stream_decoder.h"
|
|
||||||
#include "stream_encoder.h"
|
|
||||||
|
|
||||||
/** \mainpage
|
|
||||||
*
|
|
||||||
* \section intro Introduction
|
|
||||||
*
|
|
||||||
* This is the documentation for the FLAC C and C++ APIs. It is
|
|
||||||
* highly interconnected; this introduction should give you a top
|
|
||||||
* level idea of the structure and how to find the information you
|
|
||||||
* need. As a prerequisite you should have at least a basic
|
|
||||||
* knowledge of the FLAC format, documented
|
|
||||||
* <A HREF="https://xiph.org/flac/format.html">here</A>.
|
|
||||||
*
|
|
||||||
* \section c_api FLAC C API
|
|
||||||
*
|
|
||||||
* The FLAC C API is the interface to libFLAC, a set of structures
|
|
||||||
* describing the components of FLAC streams, and functions for
|
|
||||||
* encoding and decoding streams, as well as manipulating FLAC
|
|
||||||
* metadata in files. The public include files will be installed
|
|
||||||
* in your include area (for example /usr/include/FLAC/...).
|
|
||||||
*
|
|
||||||
* By writing a little code and linking against libFLAC, it is
|
|
||||||
* relatively easy to add FLAC support to another program. The
|
|
||||||
* library is licensed under <A HREF="https://xiph.org/flac/license.html">Xiph's BSD license</A>.
|
|
||||||
* Complete source code of libFLAC as well as the command-line
|
|
||||||
* encoder and plugins is available and is a useful source of
|
|
||||||
* examples.
|
|
||||||
*
|
|
||||||
* Aside from encoders and decoders, libFLAC provides a powerful
|
|
||||||
* metadata interface for manipulating metadata in FLAC files. It
|
|
||||||
* allows the user to add, delete, and modify FLAC metadata blocks
|
|
||||||
* and it can automatically take advantage of PADDING blocks to avoid
|
|
||||||
* rewriting the entire FLAC file when changing the size of the
|
|
||||||
* metadata.
|
|
||||||
*
|
|
||||||
* libFLAC usually only requires the standard C library and C math
|
|
||||||
* library. In particular, threading is not used so there is no
|
|
||||||
* dependency on a thread library. However, libFLAC does not use
|
|
||||||
* global variables and should be thread-safe.
|
|
||||||
*
|
|
||||||
* libFLAC also supports encoding to and decoding from Ogg FLAC.
|
|
||||||
* However the metadata editing interfaces currently have limited
|
|
||||||
* read-only support for Ogg FLAC files.
|
|
||||||
*
|
|
||||||
* \section cpp_api FLAC C++ API
|
|
||||||
*
|
|
||||||
* The FLAC C++ API is a set of classes that encapsulate the
|
|
||||||
* structures and functions in libFLAC. They provide slightly more
|
|
||||||
* functionality with respect to metadata but are otherwise
|
|
||||||
* equivalent. For the most part, they share the same usage as
|
|
||||||
* their counterparts in libFLAC, and the FLAC C API documentation
|
|
||||||
* can be used as a supplement. The public include files
|
|
||||||
* for the C++ API will be installed in your include area (for
|
|
||||||
* example /usr/include/FLAC++/...).
|
|
||||||
*
|
|
||||||
* libFLAC++ is also licensed under
|
|
||||||
* <A HREF="https://xiph.org/flac/license.html">Xiph's BSD license</A>.
|
|
||||||
*
|
|
||||||
* \section getting_started Getting Started
|
|
||||||
*
|
|
||||||
* A good starting point for learning the API is to browse through
|
|
||||||
* the <A HREF="modules.html">modules</A>. Modules are logical
|
|
||||||
* groupings of related functions or classes, which correspond roughly
|
|
||||||
* to header files or sections of header files. Each module includes a
|
|
||||||
* detailed description of the general usage of its functions or
|
|
||||||
* classes.
|
|
||||||
*
|
|
||||||
* From there you can go on to look at the documentation of
|
|
||||||
* individual functions. You can see different views of the individual
|
|
||||||
* functions through the links in top bar across this page.
|
|
||||||
*
|
|
||||||
* If you prefer a more hands-on approach, you can jump right to some
|
|
||||||
* <A HREF="https://xiph.org/flac/documentation_example_code.html">example code</A>.
|
|
||||||
*
|
|
||||||
* \section porting_guide Porting Guide
|
|
||||||
*
|
|
||||||
* Starting with FLAC 1.1.3 a \link porting Porting Guide \endlink
|
|
||||||
* has been introduced which gives detailed instructions on how to
|
|
||||||
* port your code to newer versions of FLAC.
|
|
||||||
*
|
|
||||||
* \section embedded_developers Embedded Developers
|
|
||||||
*
|
|
||||||
* libFLAC has grown larger over time as more functionality has been
|
|
||||||
* included, but much of it may be unnecessary for a particular embedded
|
|
||||||
* implementation. Unused parts may be pruned by some simple editing of
|
|
||||||
* src/libFLAC/Makefile.am. In general, the decoders, encoders, and
|
|
||||||
* metadata interface are all independent from each other.
|
|
||||||
*
|
|
||||||
* It is easiest to just describe the dependencies:
|
|
||||||
*
|
|
||||||
* - All modules depend on the \link flac_format Format \endlink module.
|
|
||||||
* - The decoders and encoders depend on the bitbuffer.
|
|
||||||
* - The decoder is independent of the encoder. The encoder uses the
|
|
||||||
* decoder because of the verify feature, but this can be removed if
|
|
||||||
* not needed.
|
|
||||||
* - Parts of the metadata interface require the stream decoder (but not
|
|
||||||
* the encoder).
|
|
||||||
* - Ogg support is selectable through the compile time macro
|
|
||||||
* \c FLAC__HAS_OGG.
|
|
||||||
*
|
|
||||||
* For example, if your application only requires the stream decoder, no
|
|
||||||
* encoder, and no metadata interface, you can remove the stream encoder
|
|
||||||
* and the metadata interface, which will greatly reduce the size of the
|
|
||||||
* library.
|
|
||||||
*
|
|
||||||
* Also, there are several places in the libFLAC code with comments marked
|
|
||||||
* with "OPT:" where a \#define can be changed to enable code that might be
|
|
||||||
* faster on a specific platform. Experimenting with these can yield faster
|
|
||||||
* binaries.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup porting Porting Guide for New Versions
|
|
||||||
*
|
|
||||||
* This module describes differences in the library interfaces from
|
|
||||||
* version to version. It assists in the porting of code that uses
|
|
||||||
* the libraries to newer versions of FLAC.
|
|
||||||
*
|
|
||||||
* One simple facility for making porting easier that has been added
|
|
||||||
* in FLAC 1.1.3 is a set of \#defines in \c export.h of each
|
|
||||||
* library's includes (e.g. \c include/FLAC/export.h). The
|
|
||||||
* \#defines mirror the libraries'
|
|
||||||
* <A HREF="http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning">libtool version numbers</A>,
|
|
||||||
* e.g. in libFLAC there are \c FLAC_API_VERSION_CURRENT,
|
|
||||||
* \c FLAC_API_VERSION_REVISION, and \c FLAC_API_VERSION_AGE.
|
|
||||||
* These can be used to support multiple versions of an API during the
|
|
||||||
* transition phase, e.g.
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
|
|
||||||
* legacy code
|
|
||||||
* #else
|
|
||||||
* new code
|
|
||||||
* #endif
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* The source will work for multiple versions and the legacy code can
|
|
||||||
* easily be removed when the transition is complete.
|
|
||||||
*
|
|
||||||
* Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in
|
|
||||||
* include/FLAC/export.h), which can be used to determine whether or not
|
|
||||||
* the library has been compiled with support for Ogg FLAC. This is
|
|
||||||
* simpler than trying to call an Ogg init function and catching the
|
|
||||||
* error.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3
|
|
||||||
* \ingroup porting
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module describes porting from FLAC 1.1.2 to FLAC 1.1.3.
|
|
||||||
*
|
|
||||||
* The main change between the APIs in 1.1.2 and 1.1.3 is that they have
|
|
||||||
* been simplified. First, libOggFLAC has been merged into libFLAC and
|
|
||||||
* libOggFLAC++ has been merged into libFLAC++. Second, both the three
|
|
||||||
* decoding layers and three encoding layers have been merged into a
|
|
||||||
* single stream decoder and stream encoder. That is, the functionality
|
|
||||||
* of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged
|
|
||||||
* into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and
|
|
||||||
* FLAC__FileEncoder into FLAC__StreamEncoder. Only the
|
|
||||||
* FLAC__StreamDecoder and FLAC__StreamEncoder remain. What this means
|
|
||||||
* is there is now a single API that can be used to encode or decode
|
|
||||||
* streams to/from native FLAC or Ogg FLAC and the single API can work
|
|
||||||
* on both seekable and non-seekable streams.
|
|
||||||
*
|
|
||||||
* Instead of creating an encoder or decoder of a certain layer, now the
|
|
||||||
* client will always create a FLAC__StreamEncoder or
|
|
||||||
* FLAC__StreamDecoder. The old layers are now differentiated by the
|
|
||||||
* initialization function. For example, for the decoder,
|
|
||||||
* FLAC__stream_decoder_init() has been replaced by
|
|
||||||
* FLAC__stream_decoder_init_stream(). This init function takes
|
|
||||||
* callbacks for the I/O, and the seeking callbacks are optional. This
|
|
||||||
* allows the client to use the same object for seekable and
|
|
||||||
* non-seekable streams. For decoding a FLAC file directly, the client
|
|
||||||
* can use FLAC__stream_decoder_init_file() and pass just a filename
|
|
||||||
* and fewer callbacks; most of the other callbacks are supplied
|
|
||||||
* internally. For situations where fopen()ing by filename is not
|
|
||||||
* possible (e.g. Unicode filenames on Windows) the client can instead
|
|
||||||
* open the file itself and supply the FILE* to
|
|
||||||
* FLAC__stream_decoder_init_FILE(). The init functions now returns a
|
|
||||||
* FLAC__StreamDecoderInitStatus instead of FLAC__StreamDecoderState.
|
|
||||||
* Since the callbacks and client data are now passed to the init
|
|
||||||
* function, the FLAC__stream_decoder_set_*_callback() functions and
|
|
||||||
* FLAC__stream_decoder_set_client_data() are no longer needed. The
|
|
||||||
* rest of the calls to the decoder are the same as before.
|
|
||||||
*
|
|
||||||
* There are counterpart init functions for Ogg FLAC, e.g.
|
|
||||||
* FLAC__stream_decoder_init_ogg_stream(). All the rest of the calls
|
|
||||||
* and callbacks are the same as for native FLAC.
|
|
||||||
*
|
|
||||||
* As an example, in FLAC 1.1.2 a seekable stream decoder would have
|
|
||||||
* been set up like so:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* FLAC__SeekableStreamDecoder *decoder = FLAC__seekable_stream_decoder_new();
|
|
||||||
* if(decoder == NULL) do_something;
|
|
||||||
* FLAC__seekable_stream_decoder_set_md5_checking(decoder, true);
|
|
||||||
* [... other settings ...]
|
|
||||||
* FLAC__seekable_stream_decoder_set_read_callback(decoder, my_read_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_seek_callback(decoder, my_seek_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_tell_callback(decoder, my_tell_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_length_callback(decoder, my_length_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_eof_callback(decoder, my_eof_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_write_callback(decoder, my_write_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_metadata_callback(decoder, my_metadata_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_error_callback(decoder, my_error_callback);
|
|
||||||
* FLAC__seekable_stream_decoder_set_client_data(decoder, my_client_data);
|
|
||||||
* if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) do_something;
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* In FLAC 1.1.3 it is like this:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
|
|
||||||
* if(decoder == NULL) do_something;
|
|
||||||
* FLAC__stream_decoder_set_md5_checking(decoder, true);
|
|
||||||
* [... other settings ...]
|
|
||||||
* if(FLAC__stream_decoder_init_stream(
|
|
||||||
* decoder,
|
|
||||||
* my_read_callback,
|
|
||||||
* my_seek_callback, // or NULL
|
|
||||||
* my_tell_callback, // or NULL
|
|
||||||
* my_length_callback, // or NULL
|
|
||||||
* my_eof_callback, // or NULL
|
|
||||||
* my_write_callback,
|
|
||||||
* my_metadata_callback, // or NULL
|
|
||||||
* my_error_callback,
|
|
||||||
* my_client_data
|
|
||||||
* ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* or you could do;
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* [...]
|
|
||||||
* FILE *file = fopen("somefile.flac","rb");
|
|
||||||
* if(file == NULL) do_somthing;
|
|
||||||
* if(FLAC__stream_decoder_init_FILE(
|
|
||||||
* decoder,
|
|
||||||
* file,
|
|
||||||
* my_write_callback,
|
|
||||||
* my_metadata_callback, // or NULL
|
|
||||||
* my_error_callback,
|
|
||||||
* my_client_data
|
|
||||||
* ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* or just:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* [...]
|
|
||||||
* if(FLAC__stream_decoder_init_file(
|
|
||||||
* decoder,
|
|
||||||
* "somefile.flac",
|
|
||||||
* my_write_callback,
|
|
||||||
* my_metadata_callback, // or NULL
|
|
||||||
* my_error_callback,
|
|
||||||
* my_client_data
|
|
||||||
* ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* Another small change to the decoder is in how it handles unparseable
|
|
||||||
* streams. Before, when the decoder found an unparseable stream
|
|
||||||
* (reserved for when the decoder encounters a stream from a future
|
|
||||||
* encoder that it can't parse), it changed the state to
|
|
||||||
* \c FLAC__STREAM_DECODER_UNPARSEABLE_STREAM. Now the decoder instead
|
|
||||||
* drops sync and calls the error callback with a new error code
|
|
||||||
* \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM. This is
|
|
||||||
* more robust. If your error callback does not discriminate on the the
|
|
||||||
* error state, your code does not need to be changed.
|
|
||||||
*
|
|
||||||
* The encoder now has a new setting:
|
|
||||||
* FLAC__stream_encoder_set_apodization(). This is for setting the
|
|
||||||
* method used to window the data before LPC analysis. You only need to
|
|
||||||
* add a call to this function if the default is not suitable. There
|
|
||||||
* are also two new convenience functions that may be useful:
|
|
||||||
* FLAC__metadata_object_cuesheet_calculate_cddb_id() and
|
|
||||||
* FLAC__metadata_get_cuesheet().
|
|
||||||
*
|
|
||||||
* The \a bytes parameter to FLAC__StreamDecoderReadCallback,
|
|
||||||
* FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback
|
|
||||||
* is now \c size_t instead of \c uint32_t.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4
|
|
||||||
* \ingroup porting
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module describes porting from FLAC 1.1.3 to FLAC 1.1.4.
|
|
||||||
*
|
|
||||||
* There were no changes to any of the interfaces from 1.1.3 to 1.1.4.
|
|
||||||
* There was a slight change in the implementation of
|
|
||||||
* FLAC__stream_encoder_set_metadata(); the function now makes a copy
|
|
||||||
* of the \a metadata array of pointers so the client no longer needs
|
|
||||||
* to maintain it after the call. The objects themselves that are
|
|
||||||
* pointed to by the array are still not copied though and must be
|
|
||||||
* maintained until the call to FLAC__stream_encoder_finish().
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup porting_1_1_4_to_1_2_0 Porting from FLAC 1.1.4 to 1.2.0
|
|
||||||
* \ingroup porting
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module describes porting from FLAC 1.1.4 to FLAC 1.2.0.
|
|
||||||
*
|
|
||||||
* There were only very minor changes to the interfaces from 1.1.4 to 1.2.0.
|
|
||||||
* In libFLAC, \c FLAC__format_sample_rate_is_subset() was added.
|
|
||||||
* In libFLAC++, \c FLAC::Decoder::Stream::get_decode_position() was added.
|
|
||||||
*
|
|
||||||
* Finally, value of the constant \c FLAC__FRAME_HEADER_RESERVED_LEN
|
|
||||||
* has changed to reflect the conversion of one of the reserved bits
|
|
||||||
* into active use. It used to be \c 2 and now is \c 1. However the
|
|
||||||
* FLAC frame header length has not changed, so to skip the proper
|
|
||||||
* number of bits, use \c FLAC__FRAME_HEADER_RESERVED_LEN +
|
|
||||||
* \c FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup porting_1_3_4_to_1_4_0 Porting from FLAC 1.3.4 to 1.4.0
|
|
||||||
* \ingroup porting
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module describes porting from FLAC 1.3.4 to FLAC 1.4.0.
|
|
||||||
*
|
|
||||||
* \section porting_1_3_4_to_1_4_0_summary Summary
|
|
||||||
*
|
|
||||||
* Between FLAC 1.3.4 and FLAC 1.4.0, there have four breaking changes
|
|
||||||
* - the function get_client_data_from_decoder has been renamed to
|
|
||||||
* FLAC__get_decoder_client_data
|
|
||||||
* - some data types in the FLAC__Frame struct have changed
|
|
||||||
* - all functions resizing metadata blocks now return the object
|
|
||||||
* untouched if memory allocation fails, whereas previously the
|
|
||||||
* handling varied and was more or less undefined
|
|
||||||
* - all functions accepting a filename now take UTF-8 encoded filenames
|
|
||||||
* on Windows instead of filenames in the current codepage
|
|
||||||
*
|
|
||||||
* Furthermore, there have been the following additions
|
|
||||||
* - the functions FLAC__stream_encoder_set_limit_min_bitrate,
|
|
||||||
* FLAC__stream_encoder_get_limit_min_bitrate,
|
|
||||||
* FLAC::encoder::file::set_limit_min_bitrate() and
|
|
||||||
* FLAC::encoder::file::get_limit_min_bitrate() have been added
|
|
||||||
* - Added FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA to the
|
|
||||||
* FLAC__StreamDecoderErrorStatus enum
|
|
||||||
*
|
|
||||||
* \section porting_1_3_4_to_1_4_0_breaking Breaking changes
|
|
||||||
*
|
|
||||||
* The function \b get_client_data_from_decoder was added in FLAC 1.3.3
|
|
||||||
* but did not follow the API naming convention and was not properly
|
|
||||||
* exported. The function is now renamed and properly integrated as
|
|
||||||
* FLAC__stream_decoder_get_client_data
|
|
||||||
*
|
|
||||||
* To accomodate encoding and decoding 32-bit int PCM, some data types
|
|
||||||
* in the \b FLAC__frame struct were changed. Specifically, warmup
|
|
||||||
* in both the FLAC__Subframe_Fixed struc and the FLAC__Subframe_LPC
|
|
||||||
* struct is changed from FLAC__int32 to FLAC__int64. Also, value
|
|
||||||
* in the FLAC__Subframe_Constant is changed from FLAC__int32 to
|
|
||||||
* FLAC__int64. Finally, in FLAC__Subframe_Verbatim struct data is
|
|
||||||
* changes from a FLAC__int32 array to a union containing a FLAC__int32
|
|
||||||
* array and a FLAC__int64 array. Also, a new member is added,
|
|
||||||
* data_type, which clarifies whether the FLAC__int32 or FLAC__int64
|
|
||||||
* array is in use.
|
|
||||||
*
|
|
||||||
* Furthermore, the following functions now return the object untouched
|
|
||||||
* if memory allocation fails, whereas previously the handling varied
|
|
||||||
* and was more or less undefined
|
|
||||||
*
|
|
||||||
* - FLAC__metadata_object_seektable_resize_points
|
|
||||||
* - FLAC__metadata_object_vorbiscomment_resize_comments
|
|
||||||
* - FLAC__metadata_object_cuesheet_track_resize_indices
|
|
||||||
* - FLAC__metadata_object_cuesheet_resize_tracks
|
|
||||||
*
|
|
||||||
* The last breaking change is that all API functions taking a filename
|
|
||||||
* as an argument now, on Windows, must be supplied with that filename
|
|
||||||
* in the UTF-8 character encoding instead of using the current code
|
|
||||||
* page. libFLAC internally translates these UTF-8 encoded filenames to
|
|
||||||
* an appropriate representation to use with _wfopen. On all other
|
|
||||||
* systems, filename is passed to fopen without any translation, as it
|
|
||||||
* in libFLAC 1.3.4 and earlier.
|
|
||||||
*
|
|
||||||
* \section porting_1_3_4_to_1_4_0_additions Additions
|
|
||||||
*
|
|
||||||
* To aid in creating properly streamable FLAC files, a set of functions
|
|
||||||
* was added to make it possible to enfore a minimum bitrate to files
|
|
||||||
* created through libFLAC's stream_encoder.h interface. With this
|
|
||||||
* function enabled the resulting FLAC files have a minimum bitrate of
|
|
||||||
* 1bit/sample independent of the number of channels, i.e. 48kbit/s for
|
|
||||||
* 48kHz. This can be beneficial for streaming, as very low bitrates for
|
|
||||||
* silent sections compressed with 'constant' subframes can result in a
|
|
||||||
* bitrate of 1kbit/s, creating problems with clients that aren't aware
|
|
||||||
* of this possibility and buffer too much data.
|
|
||||||
*
|
|
||||||
* Finally, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA was added to
|
|
||||||
* the FLAC__StreamDecoderErrorStatus enum to signal that the decoder
|
|
||||||
* encountered unreadable metadata.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup flac FLAC C API
|
|
||||||
*
|
|
||||||
* The FLAC C API is the interface to libFLAC, a set of structures
|
|
||||||
* describing the components of FLAC streams, and functions for
|
|
||||||
* encoding and decoding streams, as well as manipulating FLAC
|
|
||||||
* metadata in files.
|
|
||||||
*
|
|
||||||
* You should start with the format components as all other modules
|
|
||||||
* are dependent on it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2001-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__ASSERT_H
|
|
||||||
#define FLAC__ASSERT_H
|
|
||||||
|
|
||||||
/* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */
|
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
||||||
#define FLAC__ASSERT(x) if(!(x)) __builtin_abort();
|
|
||||||
#define FLAC__ASSERT_DECLARATION(x) x
|
|
||||||
#else
|
|
||||||
#ifndef NDEBUG
|
|
||||||
#include <assert.h>
|
|
||||||
#define FLAC__ASSERT(x) assert(x)
|
|
||||||
#define FLAC__ASSERT_DECLARATION(x) x
|
|
||||||
#else
|
|
||||||
#define FLAC__ASSERT(x)
|
|
||||||
#define FLAC__ASSERT_DECLARATION(x)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,190 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2004-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__CALLBACK_H
|
|
||||||
#define FLAC__CALLBACK_H
|
|
||||||
|
|
||||||
#include "ordinals.h"
|
|
||||||
#include <stdlib.h> /* for size_t */
|
|
||||||
|
|
||||||
/** \file include/FLAC/callback.h
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module defines the structures for describing I/O callbacks
|
|
||||||
* to the other FLAC interfaces.
|
|
||||||
*
|
|
||||||
* See the detailed documentation for callbacks in the
|
|
||||||
* \link flac_callbacks callbacks \endlink module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup flac_callbacks FLAC/callback.h: I/O callback structures
|
|
||||||
* \ingroup flac
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module defines the structures for describing I/O callbacks
|
|
||||||
* to the other FLAC interfaces.
|
|
||||||
*
|
|
||||||
* The purpose of the I/O callback functions is to create a common way
|
|
||||||
* for the metadata interfaces to handle I/O.
|
|
||||||
*
|
|
||||||
* Originally the metadata interfaces required filenames as the way of
|
|
||||||
* specifying FLAC files to operate on. This is problematic in some
|
|
||||||
* environments so there is an additional option to specify a set of
|
|
||||||
* callbacks for doing I/O on the FLAC file, instead of the filename.
|
|
||||||
*
|
|
||||||
* In addition to the callbacks, a FLAC__IOHandle type is defined as an
|
|
||||||
* opaque structure for a data source.
|
|
||||||
*
|
|
||||||
* The callback function prototypes are similar (but not identical) to the
|
|
||||||
* stdio functions fread, fwrite, fseek, ftell, feof, and fclose. If you use
|
|
||||||
* stdio streams to implement the callbacks, you can pass fread, fwrite, and
|
|
||||||
* fclose anywhere a FLAC__IOCallback_Read, FLAC__IOCallback_Write, or
|
|
||||||
* FLAC__IOCallback_Close is required, and a FILE* anywhere a FLAC__IOHandle
|
|
||||||
* is required. \warning You generally CANNOT directly use fseek or ftell
|
|
||||||
* for FLAC__IOCallback_Seek or FLAC__IOCallback_Tell since on most systems
|
|
||||||
* these use 32-bit offsets and FLAC requires 64-bit offsets to deal with
|
|
||||||
* large files. You will have to find an equivalent function (e.g. ftello),
|
|
||||||
* or write a wrapper. The same is true for feof() since this is usually
|
|
||||||
* implemented as a macro, not as a function whose address can be taken.
|
|
||||||
*
|
|
||||||
* \{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** This is the opaque handle type used by the callbacks. Typically
|
|
||||||
* this is a \c FILE* or address of a file descriptor.
|
|
||||||
*/
|
|
||||||
typedef void* FLAC__IOHandle;
|
|
||||||
|
|
||||||
/** Signature for the read callback.
|
|
||||||
* The signature and semantics match POSIX fread() implementations
|
|
||||||
* and can generally be used interchangeably. Note that the global
|
|
||||||
* variable errno from errno.h is read by some libFLAC functions to
|
|
||||||
* detect read errors.
|
|
||||||
*
|
|
||||||
* \param ptr The address of the read buffer.
|
|
||||||
* \param size The size of the records to be read.
|
|
||||||
* \param nmemb The number of records to be read.
|
|
||||||
* \param handle The handle to the data source.
|
|
||||||
* \retval size_t
|
|
||||||
* The number of records read.
|
|
||||||
*/
|
|
||||||
typedef size_t (*FLAC__IOCallback_Read) (void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
|
|
||||||
|
|
||||||
/** Signature for the write callback.
|
|
||||||
* The signature and semantics match POSIX fwrite() implementations
|
|
||||||
* and can generally be used interchangeably.
|
|
||||||
*
|
|
||||||
* \param ptr The address of the write buffer.
|
|
||||||
* \param size The size of the records to be written.
|
|
||||||
* \param nmemb The number of records to be written.
|
|
||||||
* \param handle The handle to the data source.
|
|
||||||
* \retval size_t
|
|
||||||
* The number of records written.
|
|
||||||
*/
|
|
||||||
typedef size_t (*FLAC__IOCallback_Write) (const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
|
|
||||||
|
|
||||||
/** Signature for the seek callback.
|
|
||||||
* The signature and semantics mostly match POSIX fseek() WITH ONE IMPORTANT
|
|
||||||
* EXCEPTION: the offset is a 64-bit type whereas fseek() is generally 'long'
|
|
||||||
* and 32-bits wide.
|
|
||||||
*
|
|
||||||
* \param handle The handle to the data source.
|
|
||||||
* \param offset The new position, relative to \a whence
|
|
||||||
* \param whence \c SEEK_SET, \c SEEK_CUR, or \c SEEK_END
|
|
||||||
* \retval int
|
|
||||||
* \c 0 on success, \c -1 on error.
|
|
||||||
*/
|
|
||||||
typedef int (*FLAC__IOCallback_Seek) (FLAC__IOHandle handle, FLAC__int64 offset, int whence);
|
|
||||||
|
|
||||||
/** Signature for the tell callback.
|
|
||||||
* The signature and semantics mostly match POSIX ftell() WITH ONE IMPORTANT
|
|
||||||
* EXCEPTION: the offset is a 64-bit type whereas ftell() is generally 'long'
|
|
||||||
* and 32-bits wide.
|
|
||||||
*
|
|
||||||
* \param handle The handle to the data source.
|
|
||||||
* \retval FLAC__int64
|
|
||||||
* The current position on success, \c -1 on error.
|
|
||||||
*/
|
|
||||||
typedef FLAC__int64 (*FLAC__IOCallback_Tell) (FLAC__IOHandle handle);
|
|
||||||
|
|
||||||
/** Signature for the EOF callback.
|
|
||||||
* The signature and semantics mostly match POSIX feof() but WATCHOUT:
|
|
||||||
* on many systems, feof() is a macro, so in this case a wrapper function
|
|
||||||
* must be provided instead.
|
|
||||||
*
|
|
||||||
* \param handle The handle to the data source.
|
|
||||||
* \retval int
|
|
||||||
* \c 0 if not at end of file, nonzero if at end of file.
|
|
||||||
*/
|
|
||||||
typedef int (*FLAC__IOCallback_Eof) (FLAC__IOHandle handle);
|
|
||||||
|
|
||||||
/** Signature for the close callback.
|
|
||||||
* The signature and semantics match POSIX fclose() implementations
|
|
||||||
* and can generally be used interchangeably.
|
|
||||||
*
|
|
||||||
* \param handle The handle to the data source.
|
|
||||||
* \retval int
|
|
||||||
* \c 0 on success, \c EOF on error.
|
|
||||||
*/
|
|
||||||
typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle);
|
|
||||||
|
|
||||||
/** A structure for holding a set of callbacks.
|
|
||||||
* Each FLAC interface that requires a FLAC__IOCallbacks structure will
|
|
||||||
* describe which of the callbacks are required. The ones that are not
|
|
||||||
* required may be set to NULL.
|
|
||||||
*
|
|
||||||
* If the seek requirement for an interface is optional, you can signify that
|
|
||||||
* a data source is not seekable by setting the \a seek field to \c NULL.
|
|
||||||
*
|
|
||||||
* See the detailed documentation for callbacks in the
|
|
||||||
* \link flac_callbacks callbacks \endlink module.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
FLAC__IOCallback_Read read; /**< See FLAC__IOCallbacks */
|
|
||||||
FLAC__IOCallback_Write write; /**< See FLAC__IOCallbacks */
|
|
||||||
FLAC__IOCallback_Seek seek; /**< See FLAC__IOCallbacks */
|
|
||||||
FLAC__IOCallback_Tell tell; /**< See FLAC__IOCallbacks */
|
|
||||||
FLAC__IOCallback_Eof eof; /**< See FLAC__IOCallbacks */
|
|
||||||
FLAC__IOCallback_Close close; /**< See FLAC__IOCallbacks */
|
|
||||||
} FLAC__IOCallbacks;
|
|
||||||
|
|
||||||
/* \} */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,115 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2000-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__EXPORT_H
|
|
||||||
#define FLAC__EXPORT_H
|
|
||||||
|
|
||||||
/** \file include/FLAC/export.h
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module contains \#defines and symbols for exporting function
|
|
||||||
* calls, and providing version information and compiled-in features.
|
|
||||||
*
|
|
||||||
* See the \link flac_export export \endlink module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \defgroup flac_export FLAC/export.h: export symbols
|
|
||||||
* \ingroup flac
|
|
||||||
*
|
|
||||||
* \brief
|
|
||||||
* This module contains \#defines and symbols for exporting function
|
|
||||||
* calls, and providing version information and compiled-in features.
|
|
||||||
*
|
|
||||||
* If you are compiling for Windows (with Visual Studio or MinGW for
|
|
||||||
* example) and will link to the static library (libFLAC++.lib) you
|
|
||||||
* should define FLAC__NO_DLL in your project to make sure the symbols
|
|
||||||
* are exported properly.
|
|
||||||
*
|
|
||||||
* \{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** This \#define is used internally in libFLAC and its headers to make
|
|
||||||
* sure the correct symbols are exported when working with shared
|
|
||||||
* libraries. On Windows, this \#define is set to __declspec(dllexport)
|
|
||||||
* when compiling libFLAC into a library and to __declspec(dllimport)
|
|
||||||
* when the headers are used to link to that DLL. On non-Windows systems
|
|
||||||
* it is used to set symbol visibility.
|
|
||||||
*
|
|
||||||
* Because of this, the define FLAC__NO_DLL must be defined when linking
|
|
||||||
* to libFLAC statically or linking will fail.
|
|
||||||
*/
|
|
||||||
/* This has grown quite complicated. FLAC__NO_DLL is used by MSVC sln
|
|
||||||
* files and CMake, which build either static or shared. autotools can
|
|
||||||
* build static, shared or **both**. Therefore, DLL_EXPORT, which is set
|
|
||||||
* by libtool, must override FLAC__NO_DLL on building shared components
|
|
||||||
*/
|
|
||||||
#if defined(_WIN32)
|
|
||||||
|
|
||||||
#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
|
|
||||||
#define FLAC_API
|
|
||||||
#else
|
|
||||||
#ifdef FLAC_API_EXPORTS
|
|
||||||
#define FLAC_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define FLAC_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(FLAC__USE_VISIBILITY_ATTR)
|
|
||||||
#define FLAC_API __attribute__ ((visibility ("default")))
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define FLAC_API
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** These \#defines will mirror the libtool-based library version number, see
|
|
||||||
* http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
|
|
||||||
*/
|
|
||||||
#define FLAC_API_VERSION_CURRENT 13
|
|
||||||
#define FLAC_API_VERSION_REVISION 0 /**< see above */
|
|
||||||
#define FLAC_API_VERSION_AGE 1 /**< see above */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \c 1 if the library has been compiled with support for Ogg FLAC, else \c 0. */
|
|
||||||
extern FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* \} */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,55 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2000-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__ORDINALS_H
|
|
||||||
#define FLAC__ORDINALS_H
|
|
||||||
|
|
||||||
/* This of course assumes C99 headers */
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
typedef int8_t FLAC__int8;
|
|
||||||
typedef uint8_t FLAC__uint8;
|
|
||||||
|
|
||||||
typedef int16_t FLAC__int16;
|
|
||||||
typedef int32_t FLAC__int32;
|
|
||||||
typedef int64_t FLAC__int64;
|
|
||||||
typedef uint16_t FLAC__uint16;
|
|
||||||
typedef uint32_t FLAC__uint32;
|
|
||||||
typedef uint64_t FLAC__uint64;
|
|
||||||
|
|
||||||
typedef int FLAC__bool;
|
|
||||||
|
|
||||||
typedef FLAC__uint8 FLAC__byte;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,23 +0,0 @@
|
||||||
# FLAC - Free Lossless Audio Codec
|
|
||||||
# Copyright (C) 2001-2009 Josh Coalson
|
|
||||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
#
|
|
||||||
# This file is part the FLAC project. FLAC is comprised of several
|
|
||||||
# components distributed under different licenses. The codec libraries
|
|
||||||
# are distributed under Xiph.Org's BSD-like license (see the file
|
|
||||||
# COPYING.Xiph in this distribution). All other programs, libraries, and
|
|
||||||
# plugins are distributed under the GPL (see COPYING.GPL). The documentation
|
|
||||||
# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
|
|
||||||
# FLAC distribution contains at the top the terms under which it may be
|
|
||||||
# distributed.
|
|
||||||
#
|
|
||||||
# Since this particular file is relevant to all components of FLAC,
|
|
||||||
# it may be distributed under the Xiph.Org license, which is the least
|
|
||||||
# restrictive of those mentioned above. See the file COPYING.Xiph in this
|
|
||||||
# distribution.
|
|
||||||
|
|
||||||
if FLaC__WITH_CPPLIBS
|
|
||||||
CPPLIBS_DIRS = FLAC++
|
|
||||||
endif
|
|
||||||
|
|
||||||
SUBDIRS = FLAC $(CPPLIBS_DIRS) share test_libs_common
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
|
||||||
|
|
||||||
SUBDIRS = grabbag
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
alloc.h \
|
|
||||||
compat.h \
|
|
||||||
endswap.h \
|
|
||||||
getopt.h \
|
|
||||||
grabbag.h \
|
|
||||||
macros.h \
|
|
||||||
private.h \
|
|
||||||
replaygain_analysis.h \
|
|
||||||
replaygain_synthesis.h \
|
|
||||||
safe_str.h \
|
|
||||||
utf8.h \
|
|
||||||
win_utf8_io.h
|
|
||||||
|
|
@ -1,318 +0,0 @@
|
||||||
/* alloc - Convenience routines for safely allocating memory
|
|
||||||
* Copyright (C) 2007-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__SHARE__ALLOC_H
|
|
||||||
#define FLAC__SHARE__ALLOC_H
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* WATCHOUT: for c++ you may have to #define __STDC_LIMIT_MACROS 1 real early
|
|
||||||
* before #including this file, otherwise SIZE_MAX might not be defined
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <limits.h> /* for SIZE_MAX */
|
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
|
|
||||||
#endif
|
|
||||||
#include <stdlib.h> /* for size_t, malloc(), etc */
|
|
||||||
#include "share/compat.h"
|
|
||||||
|
|
||||||
#ifndef SIZE_MAX
|
|
||||||
# ifndef SIZE_T_MAX
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
# ifdef _WIN64
|
|
||||||
# define SIZE_T_MAX FLAC__U64L(0xffffffffffffffff)
|
|
||||||
# else
|
|
||||||
# define SIZE_T_MAX 0xffffffff
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# error
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# define SIZE_MAX SIZE_T_MAX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
||||||
extern int alloc_check_threshold, alloc_check_counter;
|
|
||||||
|
|
||||||
static inline int alloc_check() {
|
|
||||||
if(alloc_check_threshold == INT32_MAX)
|
|
||||||
return 0;
|
|
||||||
else if(alloc_check_counter++ == alloc_check_threshold)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* avoid malloc()ing 0 bytes, see:
|
|
||||||
* https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void *safe_malloc_(size_t size)
|
|
||||||
{
|
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
||||||
/* Fail if requested */
|
|
||||||
if(alloc_check())
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
/* malloc(0) is undefined; FLAC src convention is to always allocate */
|
|
||||||
if(!size)
|
|
||||||
size++;
|
|
||||||
return malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
||||||
static inline void *malloc_(size_t size)
|
|
||||||
{
|
|
||||||
/* Fail if requested */
|
|
||||||
if(alloc_check())
|
|
||||||
return NULL;
|
|
||||||
return malloc(size);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define malloc_ malloc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline void *safe_calloc_(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
||||||
/* Fail if requested */
|
|
||||||
if(alloc_check())
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
if(!nmemb || !size)
|
|
||||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
|
||||||
return calloc(nmemb, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@@@@ there's probably a better way to prevent overflows when allocating untrusted sums but this works for now */
|
|
||||||
|
|
||||||
static inline void *safe_malloc_add_2op_(size_t size1, size_t size2)
|
|
||||||
{
|
|
||||||
size2 += size1;
|
|
||||||
if(size2 < size1)
|
|
||||||
return 0;
|
|
||||||
return safe_malloc_(size2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_malloc_add_3op_(size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
size2 += size1;
|
|
||||||
if(size2 < size1)
|
|
||||||
return 0;
|
|
||||||
size3 += size2;
|
|
||||||
if(size3 < size2)
|
|
||||||
return 0;
|
|
||||||
return safe_malloc_(size3);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4)
|
|
||||||
{
|
|
||||||
size2 += size1;
|
|
||||||
if(size2 < size1)
|
|
||||||
return 0;
|
|
||||||
size3 += size2;
|
|
||||||
if(size3 < size2)
|
|
||||||
return 0;
|
|
||||||
size4 += size3;
|
|
||||||
if(size4 < size3)
|
|
||||||
return 0;
|
|
||||||
return safe_malloc_(size4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *safe_malloc_mul_2op_(size_t size1, size_t size2) ;
|
|
||||||
|
|
||||||
static inline void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
if(!size1 || !size2 || !size3)
|
|
||||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
|
||||||
if(size1 > SIZE_MAX / size2)
|
|
||||||
return 0;
|
|
||||||
size1 *= size2;
|
|
||||||
if(size1 > SIZE_MAX / size3)
|
|
||||||
return 0;
|
|
||||||
return malloc_(size1*size3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* size1*size2 + size3 */
|
|
||||||
static inline void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
if(!size1 || !size2)
|
|
||||||
return safe_malloc_(size3);
|
|
||||||
if(size1 > SIZE_MAX / size2)
|
|
||||||
return 0;
|
|
||||||
return safe_malloc_add_2op_(size1*size2, size3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* size1 * (size2 + size3) */
|
|
||||||
static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
if(!size1 || (!size2 && !size3))
|
|
||||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
|
||||||
size2 += size3;
|
|
||||||
if(size2 < size3)
|
|
||||||
return 0;
|
|
||||||
if(size1 > SIZE_MAX / size2)
|
|
||||||
return 0;
|
|
||||||
return malloc_(size1*size2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_realloc_(void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
void *oldptr;
|
|
||||||
void *newptr;
|
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
||||||
/* Fail if requested */
|
|
||||||
if(alloc_check() && size > 0) {
|
|
||||||
free(ptr);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
oldptr = ptr;
|
|
||||||
newptr = realloc(ptr, size);
|
|
||||||
if(size > 0 && newptr == 0)
|
|
||||||
free(oldptr);
|
|
||||||
return newptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
||||||
static inline void *realloc_(void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
/* Fail if requested */
|
|
||||||
if(alloc_check())
|
|
||||||
return NULL;
|
|
||||||
return realloc(ptr, size);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define realloc_ realloc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static inline void *safe_realloc_nofree_add_2op_(void *ptr, size_t size1, size_t size2)
|
|
||||||
{
|
|
||||||
size2 += size1;
|
|
||||||
if(size2 < size1)
|
|
||||||
return 0;
|
|
||||||
return realloc_(ptr, size2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
size2 += size1;
|
|
||||||
if(size2 < size1) {
|
|
||||||
free(ptr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
size3 += size2;
|
|
||||||
if(size3 < size2) {
|
|
||||||
free(ptr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return safe_realloc_(ptr, size3);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_realloc_nofree_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
size2 += size1;
|
|
||||||
if(size2 < size1)
|
|
||||||
return 0;
|
|
||||||
size3 += size2;
|
|
||||||
if(size3 < size2)
|
|
||||||
return 0;
|
|
||||||
return realloc_(ptr, size3);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_realloc_nofree_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4)
|
|
||||||
{
|
|
||||||
size2 += size1;
|
|
||||||
if(size2 < size1)
|
|
||||||
return 0;
|
|
||||||
size3 += size2;
|
|
||||||
if(size3 < size2)
|
|
||||||
return 0;
|
|
||||||
size4 += size3;
|
|
||||||
if(size4 < size3)
|
|
||||||
return 0;
|
|
||||||
return realloc_(ptr, size4);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
|
|
||||||
{
|
|
||||||
if(!size1 || !size2)
|
|
||||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
|
||||||
if(size1 > SIZE_MAX / size2) {
|
|
||||||
free(ptr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return safe_realloc_(ptr, size1*size2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *safe_realloc_nofree_mul_2op_(void *ptr, size_t size1, size_t size2)
|
|
||||||
{
|
|
||||||
if(!size1 || !size2)
|
|
||||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
|
||||||
if(size1 > SIZE_MAX / size2)
|
|
||||||
return 0;
|
|
||||||
return realloc_(ptr, size1*size2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* size1 * (size2 + size3) */
|
|
||||||
static inline void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
if(!size1 || (!size2 && !size3))
|
|
||||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
|
||||||
size2 += size3;
|
|
||||||
if(size2 < size3) {
|
|
||||||
free(ptr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return safe_realloc_mul_2op_(ptr, size1, size2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* size1 * (size2 + size3) */
|
|
||||||
static inline void *safe_realloc_nofree_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
|
|
||||||
{
|
|
||||||
if(!size1 || (!size2 && !size3))
|
|
||||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
|
||||||
size2 += size3;
|
|
||||||
if(size2 < size3)
|
|
||||||
return 0;
|
|
||||||
return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,240 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2012-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This is the preferred location of all CPP hackery to make $random_compiler
|
|
||||||
* work like something approaching a C99 (or maybe more accurately GNU99)
|
|
||||||
* compiler.
|
|
||||||
*
|
|
||||||
* It is assumed that this header will be included after "config.h".
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__SHARE__COMPAT_H
|
|
||||||
#define FLAC__SHARE__COMPAT_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#if defined _WIN32 && !defined __CYGWIN__
|
|
||||||
/* where MSVC puts unlink() */
|
|
||||||
# include <io.h>
|
|
||||||
#else
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
|
|
||||||
#include <sys/types.h> /* for off_t */
|
|
||||||
#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */
|
|
||||||
#define FLAC__OFF_T_MAX INT64_MAX
|
|
||||||
#if !defined __MINGW32__
|
|
||||||
#define fseeko _fseeki64
|
|
||||||
#define ftello _ftelli64
|
|
||||||
#else /* MinGW */
|
|
||||||
#if !defined(HAVE_FSEEKO)
|
|
||||||
#define fseeko fseeko64
|
|
||||||
#define ftello ftello64
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define FLAC__off_t off_t
|
|
||||||
#define FLAC__OFF_T_MAX OFF_T_MAX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_INTTYPES_H
|
|
||||||
#define __STDC_FORMAT_MACROS
|
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define strtoll _strtoi64
|
|
||||||
#define strtoull _strtoui64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__cplusplus)
|
|
||||||
#define inline __inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64)
|
|
||||||
/* MSVS generates VERY slow 32-bit code with __restrict */
|
|
||||||
#define flac_restrict __restrict
|
|
||||||
#elif defined __GNUC__
|
|
||||||
#define flac_restrict __restrict__
|
|
||||||
#else
|
|
||||||
#define flac_restrict
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FLAC__U64L(x) x##ULL
|
|
||||||
|
|
||||||
#if defined _MSC_VER || defined __MINGW32__
|
|
||||||
#define FLAC__STRCASECMP _stricmp
|
|
||||||
#define FLAC__STRNCASECMP _strnicmp
|
|
||||||
#elif defined __BORLANDC__
|
|
||||||
#define FLAC__STRCASECMP stricmp
|
|
||||||
#define FLAC__STRNCASECMP strnicmp
|
|
||||||
#else
|
|
||||||
#define FLAC__STRCASECMP strcasecmp
|
|
||||||
#define FLAC__STRNCASECMP strncasecmp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__
|
|
||||||
#include <io.h> /* for _setmode(), chmod() */
|
|
||||||
#include <fcntl.h> /* for _O_BINARY */
|
|
||||||
#else
|
|
||||||
#include <unistd.h> /* for chown(), unlink() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
|
|
||||||
#if defined __BORLANDC__
|
|
||||||
#include <utime.h> /* for utime() */
|
|
||||||
#else
|
|
||||||
#include <sys/utime.h> /* for utime() */
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
|
|
||||||
#include <fcntl.h>
|
|
||||||
#else
|
|
||||||
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
|
|
||||||
#include <utime.h> /* for utime() */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined _MSC_VER
|
|
||||||
# if _MSC_VER >= 1800
|
|
||||||
# include <inttypes.h>
|
|
||||||
# elif _MSC_VER >= 1600
|
|
||||||
/* Visual Studio 2010 has decent C99 support */
|
|
||||||
# include <stdint.h>
|
|
||||||
# define PRIu64 "llu"
|
|
||||||
# define PRId64 "lld"
|
|
||||||
# define PRIx64 "llx"
|
|
||||||
# else
|
|
||||||
# include <limits.h>
|
|
||||||
# ifndef UINT32_MAX
|
|
||||||
# define UINT32_MAX _UI32_MAX
|
|
||||||
# endif
|
|
||||||
# define PRIu64 "I64u"
|
|
||||||
# define PRId64 "I64d"
|
|
||||||
# define PRIx64 "I64x"
|
|
||||||
# endif
|
|
||||||
# if defined(_USING_V110_SDK71_) && !defined(_DLL)
|
|
||||||
# pragma message("WARNING: This compile will NOT FUNCTION PROPERLY on Windows XP. See comments in include/share/compat.h for details")
|
|
||||||
#define FLAC__USE_FILELENGTHI64
|
|
||||||
/*
|
|
||||||
*************************************************************************************
|
|
||||||
* V110_SDK71, in MSVC 2017 also known as v141_xp, is a platform toolset that is supposed
|
|
||||||
* to target Windows XP. It turns out however that certain functions provided silently fail
|
|
||||||
* on Windows XP only, which makes debugging challenging. This only occurs when building with
|
|
||||||
* /MT. This problem has been reported to Microsoft, but there hasn't been a fix for years. See
|
|
||||||
* https://web.archive.org/web/20170327195018/https://connect.microsoft.com/VisualStudio/feedback/details/1557168/wstat64-returns-1-on-xp-always
|
|
||||||
*
|
|
||||||
* It is known that this problem affects the functions _wstat64 (used by flac_stat i.e.
|
|
||||||
* stat64_utf8) and _fstat64 (i.e. flac_fstat) and therefore affects both libFLAC in
|
|
||||||
* several places as well as the flac and metaflac command line tools
|
|
||||||
*
|
|
||||||
* As the extent of this problem is unknown and Microsoft seems unwilling to fix it,
|
|
||||||
* users of libFLAC building with Visual Studio are encouraged to not use the /MT compile
|
|
||||||
* switch when explicitly targeting Windows XP. When use of /MT is deemed necessary with
|
|
||||||
* this toolset, be sure to check whether your application works properly on Windows XP.
|
|
||||||
* It is also possible to build for Windows XP with MinGW instead.
|
|
||||||
*************************************************************************************
|
|
||||||
*/
|
|
||||||
# endif
|
|
||||||
#endif /* defined _MSC_VER */
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */
|
|
||||||
|
|
||||||
#include "share/win_utf8_io.h"
|
|
||||||
#define flac_printf printf_utf8
|
|
||||||
#define flac_fprintf fprintf_utf8
|
|
||||||
#define flac_vfprintf vfprintf_utf8
|
|
||||||
#define flac_fopen fopen_utf8
|
|
||||||
#define flac_chmod chmod_utf8
|
|
||||||
#define flac_utime utime_utf8
|
|
||||||
#define flac_unlink unlink_utf8
|
|
||||||
#define flac_rename rename_utf8
|
|
||||||
#define flac_stat stat64_utf8
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define flac_printf printf
|
|
||||||
#define flac_fprintf fprintf
|
|
||||||
#define flac_vfprintf vfprintf
|
|
||||||
|
|
||||||
#define flac_fopen fopen
|
|
||||||
#define flac_chmod chmod
|
|
||||||
#define flac_unlink unlink
|
|
||||||
#define flac_rename rename
|
|
||||||
#define flac_stat stat
|
|
||||||
|
|
||||||
#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
|
|
||||||
#define flac_utime(a, b) utimensat (AT_FDCWD, a, *b, 0)
|
|
||||||
#else
|
|
||||||
#define flac_utime utime
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define flac_stat_s __stat64 /* stat struct */
|
|
||||||
#define flac_fstat _fstat64
|
|
||||||
#else
|
|
||||||
#define flac_stat_s stat /* stat struct */
|
|
||||||
#define flac_fstat fstat
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ANDROID
|
|
||||||
#include <limits.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef M_LN2
|
|
||||||
#define M_LN2 0.69314718055994530942
|
|
||||||
#endif
|
|
||||||
#ifndef M_PI
|
|
||||||
#define M_PI 3.14159265358979323846
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* FLAC needs to compile and work correctly on systems with a normal ISO C99
|
|
||||||
* snprintf as well as Microsoft Visual Studio which has an non-standards
|
|
||||||
* conformant snprint_s function.
|
|
||||||
*
|
|
||||||
* This function wraps the MS version to behave more like the ISO version.
|
|
||||||
*/
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
int flac_snprintf(char *str, size_t size, const char *fmt, ...);
|
|
||||||
int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* FLAC__SHARE__COMPAT_H */
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2012-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* It is assumed that this header will be included after "config.h". */
|
|
||||||
|
|
||||||
#ifdef HAVE_BSWAP32 /* GCC and Clang */
|
|
||||||
|
|
||||||
/* GCC prior to 4.8 didn't provide bswap16 on x86_64 */
|
|
||||||
#ifndef HAVE_BSWAP16
|
|
||||||
static inline unsigned short __builtin_bswap16(unsigned short a)
|
|
||||||
{
|
|
||||||
return (a<<8)|(a>>8);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ENDSWAP_16(x) (__builtin_bswap16 (x))
|
|
||||||
#define ENDSWAP_32(x) (__builtin_bswap32 (x))
|
|
||||||
#define ENDSWAP_64(x) (__builtin_bswap64 (x))
|
|
||||||
|
|
||||||
#elif defined _MSC_VER /* Windows */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define ENDSWAP_16(x) (_byteswap_ushort (x))
|
|
||||||
#define ENDSWAP_32(x) (_byteswap_ulong (x))
|
|
||||||
#define ENDSWAP_64(x) (_byteswap_uint64 (x))
|
|
||||||
|
|
||||||
#elif defined HAVE_BYTESWAP_H /* Linux */
|
|
||||||
|
|
||||||
#include <byteswap.h>
|
|
||||||
|
|
||||||
#define ENDSWAP_16(x) (bswap_16 (x))
|
|
||||||
#define ENDSWAP_32(x) (bswap_32 (x))
|
|
||||||
#define ENDSWAP_64(x) (bswap_64 (x))
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8))
|
|
||||||
#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24))
|
|
||||||
#define ENDSWAP_64(x) ((ENDSWAP_32(((x) >> 32) & 0xFFFFFFFF)) | (ENDSWAP_32((x) & 0xFFFFFFFF) << 32))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Host to little-endian byte swapping (for MD5 calculation) */
|
|
||||||
#if CPU_IS_BIG_ENDIAN
|
|
||||||
|
|
||||||
#define H2LE_16(x) ENDSWAP_16 (x)
|
|
||||||
#define H2LE_32(x) ENDSWAP_32 (x)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define H2LE_16(x) (x)
|
|
||||||
#define H2LE_32(x) (x)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
||||||
/*
|
|
||||||
NOTE:
|
|
||||||
I cannot get the vanilla getopt code to work (i.e. compile only what
|
|
||||||
is needed and not duplicate symbols found in the standard library)
|
|
||||||
on all the platforms that FLAC supports. In particular the gating
|
|
||||||
of code with the ELIDE_CODE #define is not accurate enough on systems
|
|
||||||
that are POSIX but not glibc. If someone has a patch that works on
|
|
||||||
GNU/Linux, Darwin, AND Solaris please submit it on the project page:
|
|
||||||
https://sourceforge.net/p/flac/patches/
|
|
||||||
|
|
||||||
In the meantime I have munged the global symbols and removed gates
|
|
||||||
around code, while at the same time trying to touch the original as
|
|
||||||
little as possible.
|
|
||||||
*/
|
|
||||||
/* Declarations for getopt.
|
|
||||||
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C 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.
|
|
||||||
|
|
||||||
The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not,
|
|
||||||
write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
#ifndef SHARE__GETOPT_H
|
|
||||||
#define SHARE__GETOPT_H
|
|
||||||
|
|
||||||
/*[JEC] was:#ifndef __need_getopt*/
|
|
||||||
/*[JEC] was:# define _GETOPT_H 1*/
|
|
||||||
/*[JEC] was:#endif*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For communication from `share__getopt' to the caller.
|
|
||||||
When `share__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 *share__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 `share__getopt'.
|
|
||||||
|
|
||||||
On entry to `share__getopt', zero means this is the first call; initialize.
|
|
||||||
|
|
||||||
When `share__getopt' returns -1, this is the index of the first of the
|
|
||||||
non-option elements that the caller should itself scan.
|
|
||||||
|
|
||||||
Otherwise, `share__optind' communicates from one call to the next
|
|
||||||
how much of ARGV has been scanned so far. */
|
|
||||||
|
|
||||||
extern int share__optind;
|
|
||||||
|
|
||||||
/* Callers store zero here to inhibit the error message `share__getopt' prints
|
|
||||||
for unrecognized options. */
|
|
||||||
|
|
||||||
extern int share__opterr;
|
|
||||||
|
|
||||||
/* Set to an option character which was unrecognized. */
|
|
||||||
|
|
||||||
extern int share__optopt;
|
|
||||||
|
|
||||||
/*[JEC] was:#ifndef __need_getopt */
|
|
||||||
/* Describe the long-named options requested by the application.
|
|
||||||
The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector
|
|
||||||
of `struct share__option' terminated by an element containing a name which is
|
|
||||||
zero.
|
|
||||||
|
|
||||||
The field `has_arg' is:
|
|
||||||
share__no_argument (or 0) if the option does not take an argument,
|
|
||||||
share__required_argument (or 1) if the option requires an argument,
|
|
||||||
share__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 `share__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, `share__getopt'
|
|
||||||
returns the contents of the `val' field. */
|
|
||||||
|
|
||||||
struct share__option
|
|
||||||
{
|
|
||||||
# if defined __STDC__ && __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 share__option'. */
|
|
||||||
|
|
||||||
# define share__no_argument 0
|
|
||||||
# define share__required_argument 1
|
|
||||||
# define share__optional_argument 2
|
|
||||||
/*[JEC] was:#endif*/ /* need getopt */
|
|
||||||
|
|
||||||
|
|
||||||
/* Get definitions and prototypes for functions to process the
|
|
||||||
arguments in ARGV (ARGC of them, minus the program name) for
|
|
||||||
options given in OPTS.
|
|
||||||
|
|
||||||
Return the option character from OPTS just read. Return -1 when
|
|
||||||
there are no more options. For unrecognized options, or options
|
|
||||||
missing arguments, `share__optopt' is set to the option letter, and '?' is
|
|
||||||
returned.
|
|
||||||
|
|
||||||
The OPTS string is a list of characters which are recognized option
|
|
||||||
letters, optionally followed by colons, specifying that that letter
|
|
||||||
takes an argument, to be placed in `share__optarg'.
|
|
||||||
|
|
||||||
If a letter in OPTS is followed by two colons, its argument is
|
|
||||||
optional. This behavior is specific to the GNU `share__getopt'.
|
|
||||||
|
|
||||||
The argument `--' causes premature termination of argument
|
|
||||||
scanning, explicitly telling `share__getopt' that there are no more
|
|
||||||
options.
|
|
||||||
|
|
||||||
If OPTS begins with `--', then non-option arguments are treated as
|
|
||||||
arguments to the option '\0'. This behavior is specific to the GNU
|
|
||||||
`share__getopt'. */
|
|
||||||
|
|
||||||
/*[JEC] was:#if defined __STDC__ && __STDC__*/
|
|
||||||
/*[JEC] was:# ifdef __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 share__getopt (int argc, char *const *argv, const char *shortopts);
|
|
||||||
/*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */
|
|
||||||
/*[JEC] was:extern int getopt ();*/
|
|
||||||
/*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */
|
|
||||||
|
|
||||||
/*[JEC] was:# ifndef __need_getopt*/
|
|
||||||
extern int share__getopt_long (int argc, char *const *argv, const char *shortopts,
|
|
||||||
const struct share__option *longopts, int *longind);
|
|
||||||
extern int share__getopt_long_only (int argc, char *const *argv,
|
|
||||||
const char *shortopts,
|
|
||||||
const struct share__option *longopts, int *longind);
|
|
||||||
|
|
||||||
/* Internal only. Users should not call this directly. */
|
|
||||||
extern int share___getopt_internal (int argc, char *const *argv,
|
|
||||||
const char *shortopts,
|
|
||||||
const struct share__option *longopts, int *longind,
|
|
||||||
int long_only);
|
|
||||||
/*[JEC] was:# endif*/
|
|
||||||
/*[JEC] was:#else*/ /* not __STDC__ */
|
|
||||||
/*[JEC] was:extern int getopt ();*/
|
|
||||||
/*[JEC] was:# ifndef __need_getopt*/
|
|
||||||
/*[JEC] was:extern int getopt_long ();*/
|
|
||||||
/*[JEC] was:extern int getopt_long_only ();*/
|
|
||||||
|
|
||||||
/*[JEC] was:extern int _getopt_internal ();*/
|
|
||||||
/*[JEC] was:# endif*/
|
|
||||||
/*[JEC] was:#endif*/ /* __STDC__ */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Make sure we later can get all the definitions and declarations. */
|
|
||||||
/*[JEC] was:#undef __need_getopt*/
|
|
||||||
|
|
||||||
#endif /* getopt.h */
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
/* grabbag - Convenience lib for various routines common to several tools
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SHARE__GRABBAG_H
|
|
||||||
#define SHARE__GRABBAG_H
|
|
||||||
|
|
||||||
/* These can't be included by themselves, only from within grabbag.h */
|
|
||||||
#include "grabbag/cuesheet.h"
|
|
||||||
#include "grabbag/file.h"
|
|
||||||
#include "grabbag/picture.h"
|
|
||||||
#include "grabbag/replaygain.h"
|
|
||||||
#include "grabbag/seektable.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
cuesheet.h \
|
|
||||||
file.h \
|
|
||||||
picture.h \
|
|
||||||
replaygain.h \
|
|
||||||
seektable.h
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/* grabbag - Convenience lib for various routines common to several tools
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
|
||||||
|
|
||||||
#ifndef GRABBAG__CUESHEET_H
|
|
||||||
#define GRABBAG__CUESHEET_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "FLAC/metadata.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t grabbag__cuesheet_msf_to_frame(uint32_t minutes, uint32_t seconds, uint32_t frames);
|
|
||||||
void grabbag__cuesheet_frame_to_msf(uint32_t frame, uint32_t *minutes, uint32_t *seconds, uint32_t *frames);
|
|
||||||
|
|
||||||
FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, uint32_t *last_line_read, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);
|
|
||||||
|
|
||||||
void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
/* grabbag - Convenience lib for various routines common to several tools
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Convenience routines for manipulating files */
|
|
||||||
|
|
||||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
|
||||||
|
|
||||||
#ifndef GRABAG__FILE_H
|
|
||||||
#define GRABAG__FILE_H
|
|
||||||
|
|
||||||
/* needed because of off_t */
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h> /* for off_t */
|
|
||||||
#include <stdio.h> /* for FILE */
|
|
||||||
#include "FLAC/ordinals.h"
|
|
||||||
#include "share/compat.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void grabbag__file_copy_metadata(const char *srcpath, const char *destpath);
|
|
||||||
FLAC__off_t grabbag__file_get_filesize(const char *srcpath);
|
|
||||||
const char *grabbag__file_get_basename(const char *srcpath);
|
|
||||||
|
|
||||||
/* read_only == false means "make file writable by user"
|
|
||||||
* read_only == true means "make file read-only for everyone"
|
|
||||||
*/
|
|
||||||
FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only);
|
|
||||||
|
|
||||||
/* returns true iff stat() succeeds for both files and they have the same device and inode. */
|
|
||||||
/* on windows, uses GetFileInformationByHandle() to compare */
|
|
||||||
FLAC__bool grabbag__file_are_same(const char *f1, const char *f2);
|
|
||||||
|
|
||||||
/* attempts to make writable before unlinking */
|
|
||||||
FLAC__bool grabbag__file_remove_file(const char *filename);
|
|
||||||
|
|
||||||
/* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */
|
|
||||||
FILE *grabbag__file_get_binary_stdin(void);
|
|
||||||
FILE *grabbag__file_get_binary_stdout(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
/* grabbag - Convenience lib for various routines common to several tools
|
|
||||||
* Copyright (C) 2006-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
|
||||||
|
|
||||||
#ifndef GRABBAG__PICTURE_H
|
|
||||||
#define GRABBAG__PICTURE_H
|
|
||||||
|
|
||||||
#include "FLAC/metadata.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* spec should be of the form "[TYPE]|MIME_TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE", e.g.
|
|
||||||
* "|image/jpeg|||cover.jpg"
|
|
||||||
* "4|image/jpeg||300x300x24|backcover.jpg"
|
|
||||||
* "|image/png|description|300x300x24/71|cover.png"
|
|
||||||
* "-->|image/gif||300x300x24/71|http://blah.blah.blah/cover.gif"
|
|
||||||
*
|
|
||||||
* empty type means default to FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER
|
|
||||||
* empty resolution spec means to get from the file (cannot get used with "-->" linked images)
|
|
||||||
* spec and error_message must not be NULL
|
|
||||||
*/
|
|
||||||
FLAC__StreamMetadata *grabbag__picture_parse_specification(const char *spec, const char **error_message);
|
|
||||||
|
|
||||||
typedef struct PictureResolution
|
|
||||||
{ uint32_t width, height, depth, colors ;
|
|
||||||
} PictureResolution ;
|
|
||||||
|
|
||||||
FLAC__StreamMetadata *grabbag__picture_from_specification(int type, const char *mime_type, const char * description,
|
|
||||||
const PictureResolution * res, const char * filepath, const char **error_message);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
/* grabbag - Convenience lib for various routines common to several tools
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This wraps the replaygain_analysis lib, which is LGPL. This wrapper
|
|
||||||
* allows analysis of different input resolutions by automatically
|
|
||||||
* scaling the input signal
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
|
||||||
|
|
||||||
#ifndef GRABBAG__REPLAYGAIN_H
|
|
||||||
#define GRABBAG__REPLAYGAIN_H
|
|
||||||
|
|
||||||
#include "FLAC/metadata.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern const uint32_t GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED;
|
|
||||||
|
|
||||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS; /* = "REPLAYGAIN_REFERENCE_LOUDNESS" */
|
|
||||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN; /* = "REPLAYGAIN_TRACK_GAIN" */
|
|
||||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK; /* = "REPLAYGAIN_TRACK_PEAK" */
|
|
||||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN; /* = "REPLAYGAIN_ALBUM_GAIN" */
|
|
||||||
extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK; /* = "REPLAYGAIN_ALBUM_PEAK" */
|
|
||||||
|
|
||||||
FLAC__bool grabbag__replaygain_is_valid_sample_frequency(uint32_t sample_frequency);
|
|
||||||
|
|
||||||
FLAC__bool grabbag__replaygain_init(uint32_t sample_frequency);
|
|
||||||
|
|
||||||
/* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */
|
|
||||||
FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, uint32_t bps, uint32_t samples);
|
|
||||||
|
|
||||||
void grabbag__replaygain_get_album(float *gain, float *peak);
|
|
||||||
void grabbag__replaygain_get_title(float *gain, float *peak);
|
|
||||||
|
|
||||||
/* These three functions return an error string on error, or NULL if successful */
|
|
||||||
const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak);
|
|
||||||
const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak);
|
|
||||||
const char *grabbag__replaygain_store_to_vorbiscomment_reference(FLAC__StreamMetadata *block);
|
|
||||||
const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak);
|
|
||||||
const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak);
|
|
||||||
const char *grabbag__replaygain_store_to_file(const char *filename, float album_gain, float album_peak, float title_gain, float title_peak, FLAC__bool preserve_modtime);
|
|
||||||
const char *grabbag__replaygain_store_to_file_reference(const char *filename, FLAC__bool preserve_modtime);
|
|
||||||
const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime);
|
|
||||||
const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime);
|
|
||||||
|
|
||||||
FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak);
|
|
||||||
double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/* grabbag - Convenience lib for various routines common to several tools
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Convenience routines for working with seek tables */
|
|
||||||
|
|
||||||
/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
|
|
||||||
|
|
||||||
#ifndef GRABAG__SEEKTABLE_H
|
|
||||||
#define GRABAG__SEEKTABLE_H
|
|
||||||
|
|
||||||
#include "FLAC/format.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, uint32_t sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2013-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
/* FLAC_CHECK_RETURN : Check the return value of the provided function and
|
|
||||||
* print an error message if it fails (ie returns a value < 0).
|
|
||||||
*
|
|
||||||
* Ideally, a library should not print anything, but this macro is only used
|
|
||||||
* for things that extremely unlikely to fail, like `chown` to a previoulsy
|
|
||||||
* saved `uid`.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define FLAC_CHECK_RETURN(x) \
|
|
||||||
{ if ((x) < 0) \
|
|
||||||
fprintf (stderr, "%s : %s\n", #x, strerror (errno)) ; \
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2013-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__SHARE__PRIVATE_H
|
|
||||||
#define FLAC__SHARE__PRIVATE_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unpublished debug routines from libFLAC. This should not be used from any
|
|
||||||
* client code other than code shipped with the FLAC sources.
|
|
||||||
*/
|
|
||||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_instruction_set(FLAC__StreamEncoder *encoder, int value);
|
|
||||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
|
||||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
|
||||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
|
||||||
/*
|
|
||||||
* The following two routines were intended as debug routines and are not
|
|
||||||
* in the public headers, but SHOULD NOT CHANGE! It is known they are used
|
|
||||||
* in some non-audio projects needing every last bit of performance.
|
|
||||||
* See https://github.com/xiph/flac/issues/547 for details. These projects
|
|
||||||
* provide their own prototypes, so changing the signature of these
|
|
||||||
* functions would break building.
|
|
||||||
*/
|
|
||||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
|
||||||
FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder);
|
|
||||||
|
|
||||||
#endif /* FLAC__SHARE__PRIVATE_H */
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* ReplayGainAnalysis - analyzes input samples and give the recommended dB change
|
|
||||||
* Copyright (C) 2001 David Robinson and Glen Sawyer
|
|
||||||
*
|
|
||||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* concept and filter values by David Robinson (David@Robinson.org)
|
|
||||||
* -- blame him if you think the idea is flawed
|
|
||||||
* coding by Glen Sawyer (glensawyer@hotmail.com) 442 N 700 E, Provo, UT 84606 USA
|
|
||||||
* -- blame him if you think this runs too slowly, or the coding is otherwise flawed
|
|
||||||
* minor cosmetic tweaks to integrate with FLAC by Josh Coalson
|
|
||||||
*
|
|
||||||
* For an explanation of the concepts and the basic algorithms involved, go to:
|
|
||||||
* http://www.replaygain.org/
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GAIN_ANALYSIS_H
|
|
||||||
#define GAIN_ANALYSIS_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#define GAIN_NOT_ENOUGH_SAMPLES -24601
|
|
||||||
#define GAIN_ANALYSIS_ERROR 0
|
|
||||||
#define GAIN_ANALYSIS_OK 1
|
|
||||||
|
|
||||||
#define INIT_GAIN_ANALYSIS_ERROR 0
|
|
||||||
#define INIT_GAIN_ANALYSIS_OK 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef float flac_float_t; /* Type used for filtering */
|
|
||||||
|
|
||||||
extern flac_float_t ReplayGainReferenceLoudness; /* in dB SPL, currently == 89.0 */
|
|
||||||
|
|
||||||
int InitGainAnalysis ( long samplefreq );
|
|
||||||
int ValidGainFrequency ( long samplefreq );
|
|
||||||
int AnalyzeSamples ( const flac_float_t* left_samples, const flac_float_t* right_samples, size_t num_samples, int num_channels );
|
|
||||||
flac_float_t GetTitleGain ( void );
|
|
||||||
flac_float_t GetAlbumGain ( void );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* GAIN_ANALYSIS_H */
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
/* replaygain_synthesis - Routines for applying ReplayGain to a signal
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
|
|
||||||
#define FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
|
|
||||||
|
|
||||||
#include <stdlib.h> /* for size_t */
|
|
||||||
#include "FLAC/format.h"
|
|
||||||
|
|
||||||
#define FLAC_SHARE__MAX_SUPPORTED_CHANNELS FLAC__MAX_CHANNELS
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
NOISE_SHAPING_NONE = 0,
|
|
||||||
NOISE_SHAPING_LOW = 1,
|
|
||||||
NOISE_SHAPING_MEDIUM = 2,
|
|
||||||
NOISE_SHAPING_HIGH = 3
|
|
||||||
} NoiseShaping;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const float* FilterCoeff;
|
|
||||||
FLAC__uint64 Mask;
|
|
||||||
double Add;
|
|
||||||
float Dither;
|
|
||||||
float ErrorHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; /* 16th order Noise shaping */
|
|
||||||
float DitherHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16];
|
|
||||||
int LastRandomNumber [FLAC_SHARE__MAX_SUPPORTED_CHANNELS];
|
|
||||||
unsigned LastHistoryIndex;
|
|
||||||
NoiseShaping ShapingType;
|
|
||||||
} DitherContext;
|
|
||||||
|
|
||||||
void FLAC__replaygain_synthesis__init_dither_context(DitherContext *dither, int bits, int shapingtype);
|
|
||||||
|
|
||||||
/* scale = (float) pow(10., (double)replaygain * 0.05); */
|
|
||||||
size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, const uint32_t source_bps, const uint32_t target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2013-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Safe string handling functions to replace things like strcpy, strncpy,
|
|
||||||
* strcat, strncat etc.
|
|
||||||
* All of these functions guarantee a correctly NUL terminated string but
|
|
||||||
* the string may be truncated if the destination buffer was too short.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__SHARE_SAFE_STR_H
|
|
||||||
#define FLAC__SHARE_SAFE_STR_H
|
|
||||||
|
|
||||||
static inline char *
|
|
||||||
safe_strncat(char *dest, const char *src, size_t dest_size)
|
|
||||||
{
|
|
||||||
char * ret;
|
|
||||||
|
|
||||||
if (dest_size < 1)
|
|
||||||
return dest;
|
|
||||||
|
|
||||||
/* Assume dist has space for a term character .. */
|
|
||||||
ret = strncat(dest, src, dest_size - strlen (dest));
|
|
||||||
/* .. but set it explicitly. */
|
|
||||||
dest [dest_size - 1] = 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline char *
|
|
||||||
safe_strncpy(char *dest, const char *src, size_t dest_size)
|
|
||||||
{
|
|
||||||
char * ret;
|
|
||||||
|
|
||||||
if (dest_size < 1)
|
|
||||||
return dest;
|
|
||||||
|
|
||||||
ret = strncpy(dest, src, dest_size - 1);
|
|
||||||
dest [dest_size - 1] = 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* FLAC__SHARE_SAFE_STR_H */
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
#ifndef SHARE__UTF8_H
|
|
||||||
#define SHARE__UTF8_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert a string between UTF-8 and the locale's charset.
|
|
||||||
* Invalid bytes are replaced by '#', and characters that are
|
|
||||||
* not available in the target encoding are replaced by '?'.
|
|
||||||
*
|
|
||||||
* If the locale's charset is not set explicitly then it is
|
|
||||||
* obtained using nl_langinfo(CODESET), where available, the
|
|
||||||
* environment variable CHARSET, or assumed to be US-ASCII.
|
|
||||||
*
|
|
||||||
* Return value of conversion functions:
|
|
||||||
*
|
|
||||||
* -1 : memory allocation failed
|
|
||||||
* 0 : data was converted exactly
|
|
||||||
* 1 : valid data was converted approximately (using '?')
|
|
||||||
* 2 : input was invalid (but still converted, using '#')
|
|
||||||
* 3 : unknown encoding (but still converted, using '?')
|
|
||||||
*/
|
|
||||||
|
|
||||||
int utf8_encode(const char *from, char **to);
|
|
||||||
int utf8_decode(const char *from, char **to);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2013-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#ifndef flac__win_utf8_io_h
|
|
||||||
#define flac__win_utf8_io_h
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/utime.h>
|
|
||||||
#include "FLAC/ordinals.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
size_t strlen_utf8(const char *str);
|
|
||||||
int win_get_console_width(void);
|
|
||||||
|
|
||||||
int get_utf8_argv(int *argc, char ***argv);
|
|
||||||
|
|
||||||
int printf_utf8(const char *format, ...);
|
|
||||||
int fprintf_utf8(FILE *stream, const char *format, ...);
|
|
||||||
int vfprintf_utf8(FILE *stream, const char *format, va_list argptr);
|
|
||||||
|
|
||||||
FILE* fopen_utf8(const char *filename, const char *mode);
|
|
||||||
int stat64_utf8(const char *path, struct __stat64 *buffer);
|
|
||||||
int chmod_utf8(const char *filename, int pmode);
|
|
||||||
int utime_utf8(const char *filename, struct utimbuf *times);
|
|
||||||
int unlink_utf8(const char *filename);
|
|
||||||
int rename_utf8(const char *oldname, const char *newname);
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /* extern "C" */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
file_utils_flac.h \
|
|
||||||
metadata_utils.h
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
/* test_libFLAC - Unit tester for libFLAC
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__TEST_LIBFLAC_FILE_UTILS_H
|
|
||||||
#define FLAC__TEST_LIBFLAC_FILE_UTILS_H
|
|
||||||
|
|
||||||
/* needed because of off_t */
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "FLAC/format.h"
|
|
||||||
#include <sys/types.h> /* for off_t */
|
|
||||||
#include "share/compat.h"
|
|
||||||
|
|
||||||
extern const long file_utils__ogg_serial_number;
|
|
||||||
|
|
||||||
FLAC__bool file_utils__generate_flacfile(FLAC__bool is_ogg, const char *output_filename, FLAC__off_t *output_filesize, uint32_t length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, uint32_t num_metadata);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
/* test_libFLAC - Unit tester for libFLAC
|
|
||||||
* Copyright (C) 2002-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLAC__TEST_LIBS_COMMON_METADATA_UTILS_H
|
|
||||||
#define FLAC__TEST_LIBS_COMMON_METADATA_UTILS_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are not tests, just utility functions used by the metadata tests
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "FLAC/format.h"
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_streaminfo(const FLAC__StreamMetadata_StreamInfo *block, const FLAC__StreamMetadata_StreamInfo *blockcopy);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_padding(const FLAC__StreamMetadata_Padding *block, const FLAC__StreamMetadata_Padding *blockcopy, uint32_t block_length);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_application(const FLAC__StreamMetadata_Application *block, const FLAC__StreamMetadata_Application *blockcopy, uint32_t block_length);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_seektable(const FLAC__StreamMetadata_SeekTable *block, const FLAC__StreamMetadata_SeekTable *blockcopy);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_vorbiscomment(const FLAC__StreamMetadata_VorbisComment *block, const FLAC__StreamMetadata_VorbisComment *blockcopy);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueSheet *block, const FLAC__StreamMetadata_CueSheet *blockcopy);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_picture(const FLAC__StreamMetadata_Picture *block, const FLAC__StreamMetadata_Picture *blockcopy);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block_data_unknown(const FLAC__StreamMetadata_Unknown *block, const FLAC__StreamMetadata_Unknown *blockcopy, uint32_t block_length);
|
|
||||||
|
|
||||||
FLAC__bool mutils__compare_block(const FLAC__StreamMetadata *block, const FLAC__StreamMetadata *blockcopy);
|
|
||||||
|
|
||||||
void mutils__init_metadata_blocks(
|
|
||||||
FLAC__StreamMetadata *streaminfo,
|
|
||||||
FLAC__StreamMetadata *padding,
|
|
||||||
FLAC__StreamMetadata *seektable,
|
|
||||||
FLAC__StreamMetadata *application1,
|
|
||||||
FLAC__StreamMetadata *application2,
|
|
||||||
FLAC__StreamMetadata *vorbiscomment,
|
|
||||||
FLAC__StreamMetadata *cuesheet,
|
|
||||||
FLAC__StreamMetadata *picture,
|
|
||||||
FLAC__StreamMetadata *unknown
|
|
||||||
);
|
|
||||||
|
|
||||||
void mutils__free_metadata_blocks(
|
|
||||||
FLAC__StreamMetadata *streaminfo,
|
|
||||||
FLAC__StreamMetadata *padding,
|
|
||||||
FLAC__StreamMetadata *seektable,
|
|
||||||
FLAC__StreamMetadata *application1,
|
|
||||||
FLAC__StreamMetadata *application2,
|
|
||||||
FLAC__StreamMetadata *vorbiscomment,
|
|
||||||
FLAC__StreamMetadata *cuesheet,
|
|
||||||
FLAC__StreamMetadata *picture,
|
|
||||||
FLAC__StreamMetadata *unknown
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
# FLAC - Free Lossless Audio Codec
|
|
||||||
# Copyright (C) 2006-2009 Josh Coalson
|
|
||||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
#
|
|
||||||
# This file is part the FLAC project. FLAC is comprised of several
|
|
||||||
# components distributed under different licenses. The codec libraries
|
|
||||||
# are distributed under Xiph.Org's BSD-like license (see the file
|
|
||||||
# COPYING.Xiph in this distribution). All other programs, libraries, and
|
|
||||||
# plugins are distributed under the GPL (see COPYING.GPL). The documentation
|
|
||||||
# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
|
|
||||||
# FLAC distribution contains at the top the terms under which it may be
|
|
||||||
# distributed.
|
|
||||||
#
|
|
||||||
# Since this particular file is relevant to all components of FLAC,
|
|
||||||
# it may be distributed under the Xiph.Org license, which is the least
|
|
||||||
# restrictive of those mentioned above. See the file COPYING.Xiph in this
|
|
||||||
# distribution.
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
add_cflags.m4 \
|
|
||||||
add_cxxflags.m4 \
|
|
||||||
bswap.m4 \
|
|
||||||
endian.m4 \
|
|
||||||
gcc_version.m4 \
|
|
||||||
ogg.m4 \
|
|
||||||
stack_protect.m4
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
dnl @synopsis XIPH_ADD_CFLAGS
|
|
||||||
dnl
|
|
||||||
dnl Add the given option to CFLAGS, if it doesn't break the compiler
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_ADD_CFLAGS],
|
|
||||||
[AC_MSG_CHECKING([if $CC accepts $1])
|
|
||||||
ac_add_cflags__old_cflags="$CFLAGS"
|
|
||||||
CFLAGS="$1"
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <stdio.h>
|
|
||||||
]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes)
|
|
||||||
CFLAGS="$ac_add_cflags__old_cflags $1"],[AC_MSG_RESULT(no)
|
|
||||||
CFLAGS="$ac_add_cflags__old_cflags"
|
|
||||||
])
|
|
||||||
])# XIPH_ADD_CFLAGS
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
dnl @synopsis XIPH_ADD_CXXFLAGS
|
|
||||||
dnl
|
|
||||||
dnl Add the given option to CXXFLAGS, if it doesn't break the compiler
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_ADD_CXXFLAGS],
|
|
||||||
[AC_MSG_CHECKING([if $CXX accepts $1])
|
|
||||||
AC_LANG_ASSERT([C++])
|
|
||||||
ac_add_cxxflags__old_cxxflags="$CXXFLAGS"
|
|
||||||
CXXFLAGS="$1"
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <cstdio>
|
|
||||||
]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes)
|
|
||||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags $1"],[AC_MSG_RESULT(no)
|
|
||||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
|
|
||||||
])
|
|
||||||
])# XIPH_ADD_CXXFLAGS
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
# ===========================================================================
|
|
||||||
# http://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html
|
|
||||||
# ===========================================================================
|
|
||||||
#
|
|
||||||
# SYNOPSIS
|
|
||||||
#
|
|
||||||
# AX_ADD_FORTIFY_SOURCE
|
|
||||||
#
|
|
||||||
# DESCRIPTION
|
|
||||||
#
|
|
||||||
# Check whether -D_FORTIFY_SOURCE=2 can be added to CPPFLAGS without macro
|
|
||||||
# redefinition warnings. Some distributions (such as Gentoo Linux) enable
|
|
||||||
# _FORTIFY_SOURCE globally in their compilers, leading to unnecessary
|
|
||||||
# warnings in the form of
|
|
||||||
#
|
|
||||||
# <command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
|
|
||||||
# <built-in>: note: this is the location of the previous definition
|
|
||||||
#
|
|
||||||
# which is a problem if -Werror is enabled. This macro checks whether
|
|
||||||
# _FORTIFY_SOURCE is already defined, and if not, adds -D_FORTIFY_SOURCE=2
|
|
||||||
# to CPPFLAGS.
|
|
||||||
#
|
|
||||||
# LICENSE
|
|
||||||
#
|
|
||||||
# Copyright (c) 2017 David Seifert <soap@gentoo.org>
|
|
||||||
#
|
|
||||||
# Copying and distribution of this file, with or without modification, are
|
|
||||||
# permitted in any medium without royalty provided the copyright notice
|
|
||||||
# and this notice are preserved. This file is offered as-is, without any
|
|
||||||
# warranty.
|
|
||||||
|
|
||||||
#serial 1
|
|
||||||
|
|
||||||
AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
|
|
||||||
AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CPPFLAGS])
|
|
||||||
AC_LINK_IFELSE([
|
|
||||||
AC_LANG_SOURCE(
|
|
||||||
[[
|
|
||||||
int main() {
|
|
||||||
#ifndef _FORTIFY_SOURCE
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
this_is_an_error;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
)], [
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
|
|
||||||
], [
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
# ===========================================================================
|
|
||||||
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
|
|
||||||
# ===========================================================================
|
|
||||||
#
|
|
||||||
# SYNOPSIS
|
|
||||||
#
|
|
||||||
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
|
|
||||||
#
|
|
||||||
# DESCRIPTION
|
|
||||||
#
|
|
||||||
# Check whether the given FLAG works with the current language's compiler
|
|
||||||
# or gives an error. (Warnings, however, are ignored)
|
|
||||||
#
|
|
||||||
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
|
||||||
# success/failure.
|
|
||||||
#
|
|
||||||
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
|
||||||
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
|
||||||
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
|
||||||
# force the compiler to issue an error when a bad flag is given.
|
|
||||||
#
|
|
||||||
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
|
|
||||||
#
|
|
||||||
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
|
|
||||||
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
|
|
||||||
#
|
|
||||||
# LICENSE
|
|
||||||
#
|
|
||||||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
|
||||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
|
||||||
#
|
|
||||||
# Copying and distribution of this file, with or without modification, are
|
|
||||||
# permitted in any medium without royalty provided the copyright notice
|
|
||||||
# and this notice are preserved. This file is offered as-is, without any
|
|
||||||
# warranty.
|
|
||||||
|
|
||||||
#serial 6
|
|
||||||
|
|
||||||
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
|
|
||||||
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
|
|
||||||
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
|
||||||
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
|
||||||
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
|
||||||
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
|
||||||
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
|
|
||||||
[AS_VAR_SET(CACHEVAR,[yes])],
|
|
||||||
[AS_VAR_SET(CACHEVAR,[no])])
|
|
||||||
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
|
||||||
AS_VAR_IF(CACHEVAR,yes,
|
|
||||||
[m4_default([$2], :)],
|
|
||||||
[m4_default([$3], :)])
|
|
||||||
AS_VAR_POPDEF([CACHEVAR])dnl
|
|
||||||
])dnl AX_CHECK_COMPILE_FLAGS
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
# ===========================================================================
|
|
||||||
# http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html
|
|
||||||
# ===========================================================================
|
|
||||||
#
|
|
||||||
# SYNOPSIS
|
|
||||||
#
|
|
||||||
# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE])
|
|
||||||
#
|
|
||||||
# DESCRIPTION
|
|
||||||
#
|
|
||||||
# Check for the presence of an --enable-debug option to configure, with
|
|
||||||
# the specified default value used when the option is not present. Return
|
|
||||||
# the value in the variable $ax_enable_debug.
|
|
||||||
#
|
|
||||||
# Specifying 'yes' adds '-g -O0' to the compilation flags for all
|
|
||||||
# languages. Specifying 'info' adds '-g' to the compilation flags.
|
|
||||||
# Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to
|
|
||||||
# the linking flags. Otherwise, nothing is added.
|
|
||||||
#
|
|
||||||
# Define the variables listed in the second argument if debug is enabled,
|
|
||||||
# defaulting to no variables. Defines the variables listed in the third
|
|
||||||
# argument if debug is disabled, defaulting to NDEBUG. All lists of
|
|
||||||
# variables should be space-separated.
|
|
||||||
#
|
|
||||||
# If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
|
|
||||||
# Should be invoked prior to any AC_PROG_* compiler checks.
|
|
||||||
#
|
|
||||||
# IS-RELEASE can be used to change the default to 'no' when making a
|
|
||||||
# release. Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it
|
|
||||||
# uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE
|
|
||||||
# macro, there is no need to pass this parameter.
|
|
||||||
#
|
|
||||||
# AX_IS_RELEASE([git-directory])
|
|
||||||
# AX_CHECK_ENABLE_DEBUG()
|
|
||||||
#
|
|
||||||
# LICENSE
|
|
||||||
#
|
|
||||||
# Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
|
|
||||||
# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
|
|
||||||
#
|
|
||||||
# Copying and distribution of this file, with or without modification, are
|
|
||||||
# permitted in any medium without royalty provided the copyright notice
|
|
||||||
# and this notice are preserved.
|
|
||||||
|
|
||||||
#serial 5
|
|
||||||
|
|
||||||
AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
|
|
||||||
AC_BEFORE([$0],[AC_PROG_CC])dnl
|
|
||||||
AC_BEFORE([$0],[AC_PROG_CXX])dnl
|
|
||||||
AC_BEFORE([$0],[AC_PROG_F77])dnl
|
|
||||||
AC_BEFORE([$0],[AC_PROG_FC])dnl
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether to enable debugging)
|
|
||||||
|
|
||||||
ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))
|
|
||||||
ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],,
|
|
||||||
[$ax_is_release],
|
|
||||||
[$4])))
|
|
||||||
|
|
||||||
# If this is a release, override the default.
|
|
||||||
AS_IF([test "$ax_enable_debug_is_release" = "yes"],
|
|
||||||
[ax_enable_debug_default="no"])
|
|
||||||
|
|
||||||
m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
|
|
||||||
m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(debug,
|
|
||||||
[AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])],
|
|
||||||
[],enable_debug=$ax_enable_debug_default)
|
|
||||||
|
|
||||||
# empty mean debug yes
|
|
||||||
AS_IF([test "x$enable_debug" = "x"],
|
|
||||||
[enable_debug="yes"])
|
|
||||||
|
|
||||||
# case of debug
|
|
||||||
AS_CASE([$enable_debug],
|
|
||||||
[yes],[
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
CFLAGS="${CFLAGS} -g -O0"
|
|
||||||
CXXFLAGS="${CXXFLAGS} -g -O0"
|
|
||||||
FFLAGS="${FFLAGS} -g -O0"
|
|
||||||
FCFLAGS="${FCFLAGS} -g -O0"
|
|
||||||
OBJCFLAGS="${OBJCFLAGS} -g -O0"
|
|
||||||
],
|
|
||||||
[info],[
|
|
||||||
AC_MSG_RESULT(info)
|
|
||||||
CFLAGS="${CFLAGS} -g"
|
|
||||||
CXXFLAGS="${CXXFLAGS} -g"
|
|
||||||
FFLAGS="${FFLAGS} -g"
|
|
||||||
FCFLAGS="${FCFLAGS} -g"
|
|
||||||
OBJCFLAGS="${OBJCFLAGS} -g"
|
|
||||||
],
|
|
||||||
[profile],[
|
|
||||||
AC_MSG_RESULT(profile)
|
|
||||||
CFLAGS="${CFLAGS} -g -pg"
|
|
||||||
CXXFLAGS="${CXXFLAGS} -g -pg"
|
|
||||||
FFLAGS="${FFLAGS} -g -pg"
|
|
||||||
FCFLAGS="${FCFLAGS} -g -pg"
|
|
||||||
OBJCFLAGS="${OBJCFLAGS} -g -pg"
|
|
||||||
LDFLAGS="${LDFLAGS} -pg"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
|
|
||||||
dnl by setting any unset environment flag variables
|
|
||||||
AS_IF([test "x${CFLAGS+set}" != "xset"],
|
|
||||||
[CFLAGS=""])
|
|
||||||
AS_IF([test "x${CXXFLAGS+set}" != "xset"],
|
|
||||||
[CXXFLAGS=""])
|
|
||||||
AS_IF([test "x${FFLAGS+set}" != "xset"],
|
|
||||||
[FFLAGS=""])
|
|
||||||
AS_IF([test "x${FCFLAGS+set}" != "xset"],
|
|
||||||
[FCFLAGS=""])
|
|
||||||
AS_IF([test "x${OBJCFLAGS+set}" != "xset"],
|
|
||||||
[OBJCFLAGS=""])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl Define various variables if debugging is disabled.
|
|
||||||
dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
|
|
||||||
AS_IF([test "x$enable_debug" = "xyes"],
|
|
||||||
[m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])],
|
|
||||||
[m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])])
|
|
||||||
ax_enable_debug=$enable_debug
|
|
||||||
])
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
dnl Copyright (C) 2012-2023 Xiph.Org Foundation
|
|
||||||
dnl
|
|
||||||
dnl Redistribution and use in source and binary forms, with or without
|
|
||||||
dnl modification, are permitted provided that the following conditions
|
|
||||||
dnl are met:
|
|
||||||
dnl
|
|
||||||
dnl - Redistributions of source code must retain the above copyright
|
|
||||||
dnl notice, this list of conditions and the following disclaimer.
|
|
||||||
dnl
|
|
||||||
dnl - Redistributions in binary form must reproduce the above copyright
|
|
||||||
dnl notice, this list of conditions and the following disclaimer in the
|
|
||||||
dnl documentation and/or other materials provided with the distribution.
|
|
||||||
dnl
|
|
||||||
dnl - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
dnl contributors may be used to endorse or promote products derived from
|
|
||||||
dnl this software without specific prior written permission.
|
|
||||||
dnl
|
|
||||||
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
dnl @synopsis XIPH_C_BSWAP32
|
|
||||||
dnl
|
|
||||||
dnl @author Erik de Castro Lopo <erikd@mega-nerd.com>
|
|
||||||
dnl
|
|
||||||
dnl Dtermine whether the compiler has the __builtin_bswap32() intrinsic which
|
|
||||||
dnl is likely to be present for most versions of GCC as well as Clang.
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_C_BSWAP32],
|
|
||||||
[AC_CACHE_CHECK(for bswap32 intrinsic,
|
|
||||||
ac_cv_c_bswap32,
|
|
||||||
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[return __builtin_bswap32 (0) ;]])],[ac_cv_c_bswap32=yes],[ac_cv_c_bswap32=no])
|
|
||||||
if test $ac_cv_c_bswap32 = yes; then
|
|
||||||
AC_DEFINE_UNQUOTED(HAVE_BSWAP32, [1], [Compiler has the __builtin_bswap32 intrinsic])
|
|
||||||
fi
|
|
||||||
)]
|
|
||||||
)# XIPH_C_BSWAP32
|
|
||||||
|
|
||||||
|
|
||||||
dnl @synopsis XIPH_C_BSWAP16
|
|
||||||
dnl
|
|
||||||
dnl @author Erik de Castro Lopo <erikd@mega-nerd.com>
|
|
||||||
dnl
|
|
||||||
dnl Dtermine whether the compiler has the __builtin_bswap16() intrinsic which
|
|
||||||
dnl is likely to be present for most versions of GCC as well as Clang.
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_C_BSWAP16],
|
|
||||||
[AC_CACHE_CHECK(for bswap16 intrinsic,
|
|
||||||
ac_cv_c_bswap16,
|
|
||||||
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[return __builtin_bswap16 (0) ;]])],[ac_cv_c_bswap16=yes],[ac_cv_c_bswap16=no])
|
|
||||||
if test $ac_cv_c_bswap16 = yes; then
|
|
||||||
AC_DEFINE_UNQUOTED(HAVE_BSWAP16, [1], [Compiler has the __builtin_bswap16 intrinsic])
|
|
||||||
fi
|
|
||||||
)]
|
|
||||||
)# XIPH_C_BSWAP16
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
#
|
|
||||||
# Check for supported __attribute__ features
|
|
||||||
#
|
|
||||||
# AC_C_ATTRIBUTE(FEATURE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
|
||||||
#
|
|
||||||
AC_DEFUN([AC_C_ATTRIBUTE],
|
|
||||||
[AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_c_attribute_$1])dnl
|
|
||||||
AC_CACHE_CHECK([for __attribute__ (($1))],
|
|
||||||
CACHEVAR,[
|
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
|
|
||||||
[[ void foo(void) __attribute__ (($1)); ]])],
|
|
||||||
[AS_VAR_SET(CACHEVAR, [yes])],
|
|
||||||
[AS_VAR_SET(CACHEVAR, [no])])])
|
|
||||||
AS_VAR_IF(CACHEVAR,yes,
|
|
||||||
[m4_default([$2], :)],
|
|
||||||
[m4_default([$3], :)])
|
|
||||||
AS_VAR_POPDEF([CACHEVAR])dnl
|
|
||||||
])dnl
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
dnl @synopsis XIPH_C_COMPILER_IS_CLANG
|
|
||||||
dnl
|
|
||||||
dnl Find out if a compiler claiming to be gcc really is gcc (clang lies).
|
|
||||||
dnl @version 1.0 Oct 31 2013
|
|
||||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
|
||||||
dnl
|
|
||||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
|
||||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
|
||||||
dnl and this permission notice appear in all copies. No representations are
|
|
||||||
dnl made about the suitability of this software for any purpose. It is
|
|
||||||
dnl provided "as is" without express or implied warranty.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_C_COMPILER_IS_CLANG],
|
|
||||||
[AC_CACHE_CHECK(whether we are using the CLANG C compiler,
|
|
||||||
xiph_cv_c_compiler_clang,
|
|
||||||
[ AC_LANG_ASSERT(C)
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <stdio.h>
|
|
||||||
]], [[
|
|
||||||
#ifndef __clang__
|
|
||||||
This is not clang!
|
|
||||||
#endif
|
|
||||||
]])],[xiph_cv_c_compiler_clang=yes],[xiph_cv_c_compiler_clang=no
|
|
||||||
])]
|
|
||||||
)]
|
|
||||||
)
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
# codeset.m4 serial 5 (gettext-0.18.2)
|
|
||||||
dnl Copyright (C) 2000-2002, 2006, 2008-2012 Free Software Foundation, Inc.
|
|
||||||
dnl This file is free software; the Free Software Foundation
|
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
|
||||||
dnl with or without modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
dnl From Bruno Haible.
|
|
||||||
|
|
||||||
AC_DEFUN([AM_LANGINFO_CODESET],
|
|
||||||
[
|
|
||||||
AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
|
|
||||||
[AC_LINK_IFELSE(
|
|
||||||
[AC_LANG_PROGRAM(
|
|
||||||
[[#include <langinfo.h>]],
|
|
||||||
[[char* cs = nl_langinfo(CODESET); return !cs;]])],
|
|
||||||
[am_cv_langinfo_codeset=yes],
|
|
||||||
[am_cv_langinfo_codeset=no])
|
|
||||||
])
|
|
||||||
if test $am_cv_langinfo_codeset = yes; then
|
|
||||||
AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
|
|
||||||
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
dnl Copyright (C) 2012-2023 Xiph.Org Foundation
|
|
||||||
dnl
|
|
||||||
dnl Redistribution and use in source and binary forms, with or without
|
|
||||||
dnl modification, are permitted provided that the following conditions
|
|
||||||
dnl are met:
|
|
||||||
dnl
|
|
||||||
dnl - Redistributions of source code must retain the above copyright
|
|
||||||
dnl notice, this list of conditions and the following disclaimer.
|
|
||||||
dnl
|
|
||||||
dnl - Redistributions in binary form must reproduce the above copyright
|
|
||||||
dnl notice, this list of conditions and the following disclaimer in the
|
|
||||||
dnl documentation and/or other materials provided with the distribution.
|
|
||||||
dnl
|
|
||||||
dnl - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
dnl contributors may be used to endorse or promote products derived from
|
|
||||||
dnl this software without specific prior written permission.
|
|
||||||
dnl
|
|
||||||
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
dnl @synopsis XIPH_C_FIND_ENDIAN
|
|
||||||
dnl
|
|
||||||
dnl Determine endian-ness of target processor.
|
|
||||||
dnl @version 1.1 Mar 03 2002
|
|
||||||
dnl @author Erik de Castro Lopo <erikd@mega-nerd.com>
|
|
||||||
dnl
|
|
||||||
dnl Majority written from scratch to replace the standard autoconf macro
|
|
||||||
dnl AC_C_BIGENDIAN. Only part remaining from the original is the invocation
|
|
||||||
dnl of the AC_RUN_IFELSE([AC_LANG_SOURCE([[]])],[],[],[]) macro.
|
|
||||||
dnl
|
|
||||||
dnl Find endian-ness in the following way:
|
|
||||||
dnl 1) Look in <endian.h>.
|
|
||||||
dnl 2) If 1) fails, look in <sys/types.h> and <sys/param.h>.
|
|
||||||
dnl 3) If 1) and 2) fails and not cross compiling run a test program.
|
|
||||||
dnl 4) If 1) and 2) fails and cross compiling then guess based on target.
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_C_FIND_ENDIAN],
|
|
||||||
[AC_CACHE_CHECK(processor byte ordering,
|
|
||||||
ac_cv_c_byte_order,
|
|
||||||
|
|
||||||
# Initialize to unknown
|
|
||||||
ac_cv_c_byte_order=unknown
|
|
||||||
|
|
||||||
if test x$ac_cv_header_endian_h = xyes ; then
|
|
||||||
|
|
||||||
# First try <endian.h> which should set BYTE_ORDER.
|
|
||||||
|
|
||||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <endian.h>
|
|
||||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
|
||||||
not big endian
|
|
||||||
#endif
|
|
||||||
]], [[return 0 ;]])],[ac_cv_c_byte_order=little
|
|
||||||
],[])]
|
|
||||||
|
|
||||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <endian.h>
|
|
||||||
#if BYTE_ORDER != BIG_ENDIAN
|
|
||||||
not big endian
|
|
||||||
#endif
|
|
||||||
]], [[return 0 ;]])],[ac_cv_c_byte_order=big
|
|
||||||
],[])]
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_c_byte_order = unknown ; then
|
|
||||||
|
|
||||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
|
|
||||||
bogus endian macros
|
|
||||||
#endif
|
|
||||||
]], [[return 0 ;]])],[_au_m4_changequote([,])AC_TRY_LINK([
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
|
||||||
not big endian
|
|
||||||
#endif
|
|
||||||
], return 0 ;,
|
|
||||||
ac_cv_c_byte_order=little
|
|
||||||
)
|
|
||||||
|
|
||||||
_au_m4_changequote([,])AC_TRY_LINK([
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
|
||||||
not big endian
|
|
||||||
#endif
|
|
||||||
], return 0 ;,
|
|
||||||
ac_cv_c_byte_order=little
|
|
||||||
)
|
|
||||||
|
|
||||||
],[])]
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_c_byte_order = unknown ; then
|
|
||||||
if test $cross_compiling = yes ; then
|
|
||||||
# This is the last resort. Try to guess the target processor endian-ness
|
|
||||||
# by looking at the target CPU type.
|
|
||||||
[
|
|
||||||
case "$target_cpu" in
|
|
||||||
alpha* | i?86* | mipsel* | ia64*)
|
|
||||||
ac_cv_c_byte_order=little
|
|
||||||
;;
|
|
||||||
|
|
||||||
m68* | mips* | powerpc* | hppa* | sparc*)
|
|
||||||
ac_cv_c_byte_order=big
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
]
|
|
||||||
else
|
|
||||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[[
|
|
||||||
int main (void)
|
|
||||||
{ /* Are we little or big endian? From Harbison&Steele. */
|
|
||||||
union
|
|
||||||
{ long l ;
|
|
||||||
char c [sizeof (long)] ;
|
|
||||||
} u ;
|
|
||||||
u.l = 1 ;
|
|
||||||
return (u.c [sizeof (long) - 1] == 1);
|
|
||||||
}
|
|
||||||
]]])],[],[ac_cv_c_byte_order=big],[])
|
|
||||||
|
|
||||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[[int main (void)
|
|
||||||
{ /* Are we little or big endian? From Harbison&Steele. */
|
|
||||||
union
|
|
||||||
{ long l ;
|
|
||||||
char c [sizeof (long)] ;
|
|
||||||
} u ;
|
|
||||||
u.l = 1 ;
|
|
||||||
return (u.c [0] == 1);
|
|
||||||
}]]])],[],[ac_cv_c_byte_order=little],[])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
if test $ac_cv_c_byte_order = big ; then
|
|
||||||
ac_cv_c_big_endian=1
|
|
||||||
ac_cv_c_little_endian=0
|
|
||||||
elif test $ac_cv_c_byte_order = little ; then
|
|
||||||
ac_cv_c_big_endian=0
|
|
||||||
ac_cv_c_little_endian=1
|
|
||||||
else
|
|
||||||
ac_cv_c_big_endian=0
|
|
||||||
ac_cv_c_little_endian=0
|
|
||||||
|
|
||||||
AC_MSG_WARN([[*****************************************************************]])
|
|
||||||
AC_MSG_WARN([[*** Not able to determine endian-ness of target processor. ]])
|
|
||||||
AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in ]])
|
|
||||||
AC_MSG_WARN([[*** config.h may need to be hand editied. ]])
|
|
||||||
AC_MSG_WARN([[*****************************************************************]])
|
|
||||||
fi
|
|
||||||
|
|
||||||
]
|
|
||||||
)# XIPH_C_FIND_ENDIAN
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
dnl @synopsis XIPH_GCC_VERSION
|
|
||||||
dnl
|
|
||||||
dnl Find the version of gcc.
|
|
||||||
dnl @version 1.0 Nov 05 2007
|
|
||||||
dnl @version 1.1 Mar 10 2013
|
|
||||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
|
||||||
dnl
|
|
||||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
|
||||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
|
||||||
dnl and this permission notice appear in all copies. No representations are
|
|
||||||
dnl made about the suitability of this software for any purpose. It is
|
|
||||||
dnl provided "as is" without express or implied warranty.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_GCC_VERSION],
|
|
||||||
[
|
|
||||||
if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for version of $CC])
|
|
||||||
GCC_VERSION=`$CC -dumpversion`
|
|
||||||
AC_MSG_RESULT($GCC_VERSION)
|
|
||||||
|
|
||||||
GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d. -f 1`
|
|
||||||
GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d. -f 2`
|
|
||||||
else
|
|
||||||
GCC_MAJOR_VERSION=0
|
|
||||||
GCC_MINOR_VERSION=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_SUBST(GCC_VERSION)
|
|
||||||
AC_SUBST(GCC_MAJOR_VERSION)
|
|
||||||
AC_SUBST(GCC_MINOR_VERSION)
|
|
||||||
|
|
||||||
])# XIPH_GCC_VERSION
|
|
||||||
268
flac/m4/iconv.m4
268
flac/m4/iconv.m4
|
|
@ -1,268 +0,0 @@
|
||||||
# iconv.m4 serial 18 (gettext-0.18.2)
|
|
||||||
dnl Copyright (C) 2000-2002, 2007-2012 Free Software Foundation, Inc.
|
|
||||||
dnl This file is free software; the Free Software Foundation
|
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
|
||||||
dnl with or without modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
dnl From Bruno Haible.
|
|
||||||
|
|
||||||
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
|
|
||||||
[
|
|
||||||
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
|
|
||||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
|
||||||
AC_REQUIRE([AC_LIB_RPATH])
|
|
||||||
|
|
||||||
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
|
||||||
dnl accordingly.
|
|
||||||
AC_LIB_LINKFLAGS_BODY([iconv])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_DEFUN([AM_ICONV_LINK],
|
|
||||||
[
|
|
||||||
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
|
|
||||||
dnl those with the standalone portable GNU libiconv installed).
|
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
||||||
|
|
||||||
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
|
||||||
dnl accordingly.
|
|
||||||
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
|
|
||||||
|
|
||||||
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
|
|
||||||
dnl because if the user has installed libiconv and not disabled its use
|
|
||||||
dnl via --without-libiconv-prefix, he wants to use it. The first
|
|
||||||
dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
|
|
||||||
am_save_CPPFLAGS="$CPPFLAGS"
|
|
||||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
|
|
||||||
am_cv_func_iconv="no, consider installing GNU libiconv"
|
|
||||||
am_cv_lib_iconv=no
|
|
||||||
AC_LINK_IFELSE(
|
|
||||||
[AC_LANG_PROGRAM(
|
|
||||||
[[
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <iconv.h>
|
|
||||||
]],
|
|
||||||
[[iconv_t cd = iconv_open("","");
|
|
||||||
iconv(cd,NULL,NULL,NULL,NULL);
|
|
||||||
iconv_close(cd);]])],
|
|
||||||
[am_cv_func_iconv=yes])
|
|
||||||
if test "$am_cv_func_iconv" != yes; then
|
|
||||||
am_save_LIBS="$LIBS"
|
|
||||||
LIBS="$LIBS $LIBICONV"
|
|
||||||
AC_LINK_IFELSE(
|
|
||||||
[AC_LANG_PROGRAM(
|
|
||||||
[[
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <iconv.h>
|
|
||||||
]],
|
|
||||||
[[iconv_t cd = iconv_open("","");
|
|
||||||
iconv(cd,NULL,NULL,NULL,NULL);
|
|
||||||
iconv_close(cd);]])],
|
|
||||||
[am_cv_lib_iconv=yes]
|
|
||||||
[am_cv_func_iconv=yes])
|
|
||||||
LIBS="$am_save_LIBS"
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
if test "$am_cv_func_iconv" = yes; then
|
|
||||||
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
|
|
||||||
dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
|
|
||||||
dnl Solaris 10.
|
|
||||||
am_save_LIBS="$LIBS"
|
|
||||||
if test $am_cv_lib_iconv = yes; then
|
|
||||||
LIBS="$LIBS $LIBICONV"
|
|
||||||
fi
|
|
||||||
AC_RUN_IFELSE(
|
|
||||||
[AC_LANG_SOURCE([[
|
|
||||||
#include <iconv.h>
|
|
||||||
#include <string.h>
|
|
||||||
int main ()
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
|
|
||||||
returns. */
|
|
||||||
{
|
|
||||||
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
|
|
||||||
if (cd_utf8_to_88591 != (iconv_t)(-1))
|
|
||||||
{
|
|
||||||
static const char input[] = "\342\202\254"; /* EURO SIGN */
|
|
||||||
char buf[10];
|
|
||||||
const char *inptr = input;
|
|
||||||
size_t inbytesleft = strlen (input);
|
|
||||||
char *outptr = buf;
|
|
||||||
size_t outbytesleft = sizeof (buf);
|
|
||||||
size_t res = iconv (cd_utf8_to_88591,
|
|
||||||
(char **) &inptr, &inbytesleft,
|
|
||||||
&outptr, &outbytesleft);
|
|
||||||
if (res == 0)
|
|
||||||
result |= 1;
|
|
||||||
iconv_close (cd_utf8_to_88591);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Test against Solaris 10 bug: Failures are not distinguishable from
|
|
||||||
successful returns. */
|
|
||||||
{
|
|
||||||
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
|
|
||||||
if (cd_ascii_to_88591 != (iconv_t)(-1))
|
|
||||||
{
|
|
||||||
static const char input[] = "\263";
|
|
||||||
char buf[10];
|
|
||||||
const char *inptr = input;
|
|
||||||
size_t inbytesleft = strlen (input);
|
|
||||||
char *outptr = buf;
|
|
||||||
size_t outbytesleft = sizeof (buf);
|
|
||||||
size_t res = iconv (cd_ascii_to_88591,
|
|
||||||
(char **) &inptr, &inbytesleft,
|
|
||||||
&outptr, &outbytesleft);
|
|
||||||
if (res == 0)
|
|
||||||
result |= 2;
|
|
||||||
iconv_close (cd_ascii_to_88591);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Test against AIX 6.1..7.1 bug: Buffer overrun. */
|
|
||||||
{
|
|
||||||
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
|
|
||||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
|
||||||
{
|
|
||||||
static const char input[] = "\304";
|
|
||||||
static char buf[2] = { (char)0xDE, (char)0xAD };
|
|
||||||
const char *inptr = input;
|
|
||||||
size_t inbytesleft = 1;
|
|
||||||
char *outptr = buf;
|
|
||||||
size_t outbytesleft = 1;
|
|
||||||
size_t res = iconv (cd_88591_to_utf8,
|
|
||||||
(char **) &inptr, &inbytesleft,
|
|
||||||
&outptr, &outbytesleft);
|
|
||||||
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
|
|
||||||
result |= 4;
|
|
||||||
iconv_close (cd_88591_to_utf8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if 0 /* This bug could be worked around by the caller. */
|
|
||||||
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
|
|
||||||
{
|
|
||||||
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
|
|
||||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
|
||||||
{
|
|
||||||
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
|
|
||||||
char buf[50];
|
|
||||||
const char *inptr = input;
|
|
||||||
size_t inbytesleft = strlen (input);
|
|
||||||
char *outptr = buf;
|
|
||||||
size_t outbytesleft = sizeof (buf);
|
|
||||||
size_t res = iconv (cd_88591_to_utf8,
|
|
||||||
(char **) &inptr, &inbytesleft,
|
|
||||||
&outptr, &outbytesleft);
|
|
||||||
if ((int)res > 0)
|
|
||||||
result |= 8;
|
|
||||||
iconv_close (cd_88591_to_utf8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
|
|
||||||
provided. */
|
|
||||||
if (/* Try standardized names. */
|
|
||||||
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
|
|
||||||
/* Try IRIX, OSF/1 names. */
|
|
||||||
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
|
|
||||||
/* Try AIX names. */
|
|
||||||
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
|
|
||||||
/* Try HP-UX names. */
|
|
||||||
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
|
|
||||||
result |= 16;
|
|
||||||
return result;
|
|
||||||
}]])],
|
|
||||||
[am_cv_func_iconv_works=yes],
|
|
||||||
[am_cv_func_iconv_works=no],
|
|
||||||
[
|
|
||||||
changequote(,)dnl
|
|
||||||
case "$host_os" in
|
|
||||||
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
|
|
||||||
*) am_cv_func_iconv_works="guessing yes" ;;
|
|
||||||
esac
|
|
||||||
changequote([,])dnl
|
|
||||||
])
|
|
||||||
LIBS="$am_save_LIBS"
|
|
||||||
])
|
|
||||||
case "$am_cv_func_iconv_works" in
|
|
||||||
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
|
|
||||||
*) am_func_iconv=yes ;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
am_func_iconv=no am_cv_lib_iconv=no
|
|
||||||
fi
|
|
||||||
if test "$am_func_iconv" = yes; then
|
|
||||||
AC_DEFINE([HAVE_ICONV], [1],
|
|
||||||
[Define if you have the iconv() function and it works.])
|
|
||||||
fi
|
|
||||||
if test "$am_cv_lib_iconv" = yes; then
|
|
||||||
AC_MSG_CHECKING([how to link with libiconv])
|
|
||||||
AC_MSG_RESULT([$LIBICONV])
|
|
||||||
else
|
|
||||||
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
|
|
||||||
dnl either.
|
|
||||||
CPPFLAGS="$am_save_CPPFLAGS"
|
|
||||||
LIBICONV=
|
|
||||||
LTLIBICONV=
|
|
||||||
fi
|
|
||||||
AC_SUBST([LIBICONV])
|
|
||||||
AC_SUBST([LTLIBICONV])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
|
|
||||||
dnl avoid warnings like
|
|
||||||
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
|
|
||||||
dnl This is tricky because of the way 'aclocal' is implemented:
|
|
||||||
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
|
|
||||||
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
|
|
||||||
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
|
|
||||||
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
|
|
||||||
dnl warnings.
|
|
||||||
m4_define([gl_iconv_AC_DEFUN],
|
|
||||||
m4_version_prereq([2.64],
|
|
||||||
[[AC_DEFUN_ONCE(
|
|
||||||
[$1], [$2])]],
|
|
||||||
[m4_ifdef([gl_00GNULIB],
|
|
||||||
[[AC_DEFUN_ONCE(
|
|
||||||
[$1], [$2])]],
|
|
||||||
[[AC_DEFUN(
|
|
||||||
[$1], [$2])]])]))
|
|
||||||
gl_iconv_AC_DEFUN([AM_ICONV],
|
|
||||||
[
|
|
||||||
AM_ICONV_LINK
|
|
||||||
if test "$am_cv_func_iconv" = yes; then
|
|
||||||
AC_MSG_CHECKING([for iconv declaration])
|
|
||||||
AC_CACHE_VAL([am_cv_proto_iconv], [
|
|
||||||
AC_COMPILE_IFELSE(
|
|
||||||
[AC_LANG_PROGRAM(
|
|
||||||
[[
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <iconv.h>
|
|
||||||
extern
|
|
||||||
#ifdef __cplusplus
|
|
||||||
"C"
|
|
||||||
#endif
|
|
||||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
|
|
||||||
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
|
|
||||||
#else
|
|
||||||
size_t iconv();
|
|
||||||
#endif
|
|
||||||
]],
|
|
||||||
[[]])],
|
|
||||||
[am_cv_proto_iconv_arg1=""],
|
|
||||||
[am_cv_proto_iconv_arg1="const"])
|
|
||||||
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
|
|
||||||
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
|
|
||||||
AC_MSG_RESULT([
|
|
||||||
$am_cv_proto_iconv])
|
|
||||||
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
|
|
||||||
[Define as const if the declaration of iconv() needs const.])
|
|
||||||
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
|
|
||||||
m4_ifdef([gl_ICONV_H_DEFAULTS],
|
|
||||||
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
|
|
||||||
if test -n "$am_cv_proto_iconv_arg1"; then
|
|
||||||
ICONV_CONST="const"
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
# lib-ld.m4 serial 6
|
|
||||||
dnl Copyright (C) 1996-2003, 2009-2012 Free Software Foundation, Inc.
|
|
||||||
dnl This file is free software; the Free Software Foundation
|
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
|
||||||
dnl with or without modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
dnl Subroutines of libtool.m4,
|
|
||||||
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
|
|
||||||
dnl collision with libtool.m4.
|
|
||||||
|
|
||||||
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
|
|
||||||
AC_DEFUN([AC_LIB_PROG_LD_GNU],
|
|
||||||
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
|
|
||||||
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
|
|
||||||
case `$LD -v 2>&1 </dev/null` in
|
|
||||||
*GNU* | *'with BFD'*)
|
|
||||||
acl_cv_prog_gnu_ld=yes
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
acl_cv_prog_gnu_ld=no
|
|
||||||
;;
|
|
||||||
esac])
|
|
||||||
with_gnu_ld=$acl_cv_prog_gnu_ld
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl From libtool-2.4. Sets the variable LD.
|
|
||||||
AC_DEFUN([AC_LIB_PROG_LD],
|
|
||||||
[AC_REQUIRE([AC_PROG_CC])dnl
|
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
|
||||||
|
|
||||||
AC_ARG_WITH([gnu-ld],
|
|
||||||
[AS_HELP_STRING([--with-gnu-ld],
|
|
||||||
[assume the C compiler uses GNU ld [default=no]])],
|
|
||||||
[test "$withval" = no || with_gnu_ld=yes],
|
|
||||||
[with_gnu_ld=no])dnl
|
|
||||||
|
|
||||||
# Prepare PATH_SEPARATOR.
|
|
||||||
# The user is always right.
|
|
||||||
if test "${PATH_SEPARATOR+set}" != set; then
|
|
||||||
# Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
|
|
||||||
# contains only /bin. Note that ksh looks also at the FPATH variable,
|
|
||||||
# so we have to set that as well for the test.
|
|
||||||
PATH_SEPARATOR=:
|
|
||||||
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|
|
||||||
&& { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|
|
||||||
|| PATH_SEPARATOR=';'
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_prog=ld
|
|
||||||
if test "$GCC" = yes; then
|
|
||||||
# Check if gcc -print-prog-name=ld gives a path.
|
|
||||||
AC_MSG_CHECKING([for ld used by $CC])
|
|
||||||
case $host in
|
|
||||||
*-*-mingw*)
|
|
||||||
# gcc leaves a trailing carriage return which upsets mingw
|
|
||||||
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
|
|
||||||
*)
|
|
||||||
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
|
|
||||||
esac
|
|
||||||
case $ac_prog in
|
|
||||||
# Accept absolute paths.
|
|
||||||
[[\\/]]* | ?:[[\\/]]*)
|
|
||||||
re_direlt='/[[^/]][[^/]]*/\.\./'
|
|
||||||
# Canonicalize the pathname of ld
|
|
||||||
ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
|
|
||||||
while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
|
|
||||||
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
|
|
||||||
done
|
|
||||||
test -z "$LD" && LD="$ac_prog"
|
|
||||||
;;
|
|
||||||
"")
|
|
||||||
# If it fails, then pretend we aren't using GCC.
|
|
||||||
ac_prog=ld
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# If it is relative, then search for the first ld in PATH.
|
|
||||||
with_gnu_ld=unknown
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif test "$with_gnu_ld" = yes; then
|
|
||||||
AC_MSG_CHECKING([for GNU ld])
|
|
||||||
else
|
|
||||||
AC_MSG_CHECKING([for non-GNU ld])
|
|
||||||
fi
|
|
||||||
AC_CACHE_VAL([acl_cv_path_LD],
|
|
||||||
[if test -z "$LD"; then
|
|
||||||
acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
|
|
||||||
for ac_dir in $PATH; do
|
|
||||||
IFS="$acl_save_ifs"
|
|
||||||
test -z "$ac_dir" && ac_dir=.
|
|
||||||
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
|
|
||||||
acl_cv_path_LD="$ac_dir/$ac_prog"
|
|
||||||
# Check to see if the program is GNU ld. I'd rather use --version,
|
|
||||||
# but apparently some variants of GNU ld only accept -v.
|
|
||||||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
|
||||||
case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
|
|
||||||
*GNU* | *'with BFD'*)
|
|
||||||
test "$with_gnu_ld" != no && break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
test "$with_gnu_ld" != yes && break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
IFS="$acl_save_ifs"
|
|
||||||
else
|
|
||||||
acl_cv_path_LD="$LD" # Let the user override the test with a path.
|
|
||||||
fi])
|
|
||||||
LD="$acl_cv_path_LD"
|
|
||||||
if test -n "$LD"; then
|
|
||||||
AC_MSG_RESULT([$LD])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
fi
|
|
||||||
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
|
|
||||||
AC_LIB_PROG_LD_GNU
|
|
||||||
])
|
|
||||||
|
|
@ -1,777 +0,0 @@
|
||||||
# lib-link.m4 serial 26 (gettext-0.18.2)
|
|
||||||
dnl Copyright (C) 2001-2012 Free Software Foundation, Inc.
|
|
||||||
dnl This file is free software; the Free Software Foundation
|
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
|
||||||
dnl with or without modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
dnl From Bruno Haible.
|
|
||||||
|
|
||||||
AC_PREREQ([2.54])
|
|
||||||
|
|
||||||
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
|
|
||||||
dnl the libraries corresponding to explicit and implicit dependencies.
|
|
||||||
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
|
|
||||||
dnl augments the CPPFLAGS variable.
|
|
||||||
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
|
|
||||||
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
|
|
||||||
AC_DEFUN([AC_LIB_LINKFLAGS],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
|
||||||
AC_REQUIRE([AC_LIB_RPATH])
|
|
||||||
pushdef([Name],[m4_translit([$1],[./+-], [____])])
|
|
||||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
|
||||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
|
||||||
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
|
|
||||||
AC_LIB_LINKFLAGS_BODY([$1], [$2])
|
|
||||||
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
|
|
||||||
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
|
|
||||||
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
|
|
||||||
ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
|
|
||||||
])
|
|
||||||
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
|
|
||||||
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
|
|
||||||
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
|
|
||||||
LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
|
|
||||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
|
|
||||||
AC_SUBST([LIB]NAME)
|
|
||||||
AC_SUBST([LTLIB]NAME)
|
|
||||||
AC_SUBST([LIB]NAME[_PREFIX])
|
|
||||||
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
|
|
||||||
dnl results of this search when this library appears as a dependency.
|
|
||||||
HAVE_LIB[]NAME=yes
|
|
||||||
popdef([NAME])
|
|
||||||
popdef([Name])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
|
|
||||||
dnl searches for libname and the libraries corresponding to explicit and
|
|
||||||
dnl implicit dependencies, together with the specified include files and
|
|
||||||
dnl the ability to compile and link the specified testcode. The missing-message
|
|
||||||
dnl defaults to 'no' and may contain additional hints for the user.
|
|
||||||
dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
|
|
||||||
dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
|
|
||||||
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
|
|
||||||
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
|
|
||||||
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
|
|
||||||
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
|
|
||||||
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
|
||||||
AC_REQUIRE([AC_LIB_RPATH])
|
|
||||||
pushdef([Name],[m4_translit([$1],[./+-], [____])])
|
|
||||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
|
||||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
|
||||||
|
|
||||||
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
|
|
||||||
dnl accordingly.
|
|
||||||
AC_LIB_LINKFLAGS_BODY([$1], [$2])
|
|
||||||
|
|
||||||
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
|
|
||||||
dnl because if the user has installed lib[]Name and not disabled its use
|
|
||||||
dnl via --without-lib[]Name-prefix, he wants to use it.
|
|
||||||
ac_save_CPPFLAGS="$CPPFLAGS"
|
|
||||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
|
|
||||||
ac_save_LIBS="$LIBS"
|
|
||||||
dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
|
|
||||||
dnl because these -l options might require -L options that are present in
|
|
||||||
dnl LIBS. -l options benefit only from the -L options listed before it.
|
|
||||||
dnl Otherwise, add it to the front of LIBS, because it may be a static
|
|
||||||
dnl library that depends on another static library that is present in LIBS.
|
|
||||||
dnl Static libraries benefit only from the static libraries listed after
|
|
||||||
dnl it.
|
|
||||||
case " $LIB[]NAME" in
|
|
||||||
*" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
|
|
||||||
*) LIBS="$LIB[]NAME $LIBS" ;;
|
|
||||||
esac
|
|
||||||
AC_LINK_IFELSE(
|
|
||||||
[AC_LANG_PROGRAM([[$3]], [[$4]])],
|
|
||||||
[ac_cv_lib[]Name=yes],
|
|
||||||
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
|
|
||||||
LIBS="$ac_save_LIBS"
|
|
||||||
])
|
|
||||||
if test "$ac_cv_lib[]Name" = yes; then
|
|
||||||
HAVE_LIB[]NAME=yes
|
|
||||||
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
|
|
||||||
AC_MSG_CHECKING([how to link with lib[]$1])
|
|
||||||
AC_MSG_RESULT([$LIB[]NAME])
|
|
||||||
else
|
|
||||||
HAVE_LIB[]NAME=no
|
|
||||||
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
|
|
||||||
dnl $INC[]NAME either.
|
|
||||||
CPPFLAGS="$ac_save_CPPFLAGS"
|
|
||||||
LIB[]NAME=
|
|
||||||
LTLIB[]NAME=
|
|
||||||
LIB[]NAME[]_PREFIX=
|
|
||||||
fi
|
|
||||||
AC_SUBST([HAVE_LIB]NAME)
|
|
||||||
AC_SUBST([LIB]NAME)
|
|
||||||
AC_SUBST([LTLIB]NAME)
|
|
||||||
AC_SUBST([LIB]NAME[_PREFIX])
|
|
||||||
popdef([NAME])
|
|
||||||
popdef([Name])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl Determine the platform dependent parameters needed to use rpath:
|
|
||||||
dnl acl_libext,
|
|
||||||
dnl acl_shlibext,
|
|
||||||
dnl acl_libname_spec,
|
|
||||||
dnl acl_library_names_spec,
|
|
||||||
dnl acl_hardcode_libdir_flag_spec,
|
|
||||||
dnl acl_hardcode_libdir_separator,
|
|
||||||
dnl acl_hardcode_direct,
|
|
||||||
dnl acl_hardcode_minus_L.
|
|
||||||
AC_DEFUN([AC_LIB_RPATH],
|
|
||||||
[
|
|
||||||
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
|
|
||||||
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
|
|
||||||
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
|
|
||||||
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
|
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
|
|
||||||
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
|
|
||||||
AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
|
|
||||||
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
|
|
||||||
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
|
|
||||||
. ./conftest.sh
|
|
||||||
rm -f ./conftest.sh
|
|
||||||
acl_cv_rpath=done
|
|
||||||
])
|
|
||||||
wl="$acl_cv_wl"
|
|
||||||
acl_libext="$acl_cv_libext"
|
|
||||||
acl_shlibext="$acl_cv_shlibext"
|
|
||||||
acl_libname_spec="$acl_cv_libname_spec"
|
|
||||||
acl_library_names_spec="$acl_cv_library_names_spec"
|
|
||||||
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
|
|
||||||
acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
|
|
||||||
acl_hardcode_direct="$acl_cv_hardcode_direct"
|
|
||||||
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
|
|
||||||
dnl Determine whether the user wants rpath handling at all.
|
|
||||||
AC_ARG_ENABLE([rpath],
|
|
||||||
[ --disable-rpath do not hardcode runtime library paths],
|
|
||||||
:, enable_rpath=yes)
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AC_LIB_FROMPACKAGE(name, package)
|
|
||||||
dnl declares that libname comes from the given package. The configure file
|
|
||||||
dnl will then not have a --with-libname-prefix option but a
|
|
||||||
dnl --with-package-prefix option. Several libraries can come from the same
|
|
||||||
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
|
|
||||||
dnl macro call that searches for libname.
|
|
||||||
AC_DEFUN([AC_LIB_FROMPACKAGE],
|
|
||||||
[
|
|
||||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
|
||||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
|
||||||
define([acl_frompackage_]NAME, [$2])
|
|
||||||
popdef([NAME])
|
|
||||||
pushdef([PACK],[$2])
|
|
||||||
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
|
|
||||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
|
||||||
define([acl_libsinpackage_]PACKUP,
|
|
||||||
m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
|
|
||||||
popdef([PACKUP])
|
|
||||||
popdef([PACK])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
|
|
||||||
dnl the libraries corresponding to explicit and implicit dependencies.
|
|
||||||
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
|
|
||||||
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
|
|
||||||
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
|
|
||||||
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
|
|
||||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
|
||||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
|
||||||
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
|
|
||||||
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
|
|
||||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
|
||||||
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
|
|
||||||
dnl Autoconf >= 2.61 supports dots in --with options.
|
|
||||||
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
|
|
||||||
dnl By default, look in $includedir and $libdir.
|
|
||||||
use_additional=yes
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([
|
|
||||||
eval additional_includedir=\"$includedir\"
|
|
||||||
eval additional_libdir=\"$libdir\"
|
|
||||||
])
|
|
||||||
AC_ARG_WITH(P_A_C_K[-prefix],
|
|
||||||
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
|
|
||||||
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
|
|
||||||
[
|
|
||||||
if test "X$withval" = "Xno"; then
|
|
||||||
use_additional=no
|
|
||||||
else
|
|
||||||
if test "X$withval" = "X"; then
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([
|
|
||||||
eval additional_includedir=\"$includedir\"
|
|
||||||
eval additional_libdir=\"$libdir\"
|
|
||||||
])
|
|
||||||
else
|
|
||||||
additional_includedir="$withval/include"
|
|
||||||
additional_libdir="$withval/$acl_libdirstem"
|
|
||||||
if test "$acl_libdirstem2" != "$acl_libdirstem" \
|
|
||||||
&& ! test -d "$withval/$acl_libdirstem"; then
|
|
||||||
additional_libdir="$withval/$acl_libdirstem2"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
dnl Search the library and its dependencies in $additional_libdir and
|
|
||||||
dnl $LDFLAGS. Using breadth-first-seach.
|
|
||||||
LIB[]NAME=
|
|
||||||
LTLIB[]NAME=
|
|
||||||
INC[]NAME=
|
|
||||||
LIB[]NAME[]_PREFIX=
|
|
||||||
dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
|
|
||||||
dnl computed. So it has to be reset here.
|
|
||||||
HAVE_LIB[]NAME=
|
|
||||||
rpathdirs=
|
|
||||||
ltrpathdirs=
|
|
||||||
names_already_handled=
|
|
||||||
names_next_round='$1 $2'
|
|
||||||
while test -n "$names_next_round"; do
|
|
||||||
names_this_round="$names_next_round"
|
|
||||||
names_next_round=
|
|
||||||
for name in $names_this_round; do
|
|
||||||
already_handled=
|
|
||||||
for n in $names_already_handled; do
|
|
||||||
if test "$n" = "$name"; then
|
|
||||||
already_handled=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$already_handled"; then
|
|
||||||
names_already_handled="$names_already_handled $name"
|
|
||||||
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
|
|
||||||
dnl or AC_LIB_HAVE_LINKFLAGS call.
|
|
||||||
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
|
|
||||||
eval value=\"\$HAVE_LIB$uppername\"
|
|
||||||
if test -n "$value"; then
|
|
||||||
if test "$value" = yes; then
|
|
||||||
eval value=\"\$LIB$uppername\"
|
|
||||||
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
|
|
||||||
eval value=\"\$LTLIB$uppername\"
|
|
||||||
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
|
|
||||||
else
|
|
||||||
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
|
|
||||||
dnl that this library doesn't exist. So just drop it.
|
|
||||||
:
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
|
|
||||||
dnl and the already constructed $LIBNAME/$LTLIBNAME.
|
|
||||||
found_dir=
|
|
||||||
found_la=
|
|
||||||
found_so=
|
|
||||||
found_a=
|
|
||||||
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
|
|
||||||
if test -n "$acl_shlibext"; then
|
|
||||||
shrext=".$acl_shlibext" # typically: shrext=.so
|
|
||||||
else
|
|
||||||
shrext=
|
|
||||||
fi
|
|
||||||
if test $use_additional = yes; then
|
|
||||||
dir="$additional_libdir"
|
|
||||||
dnl The same code as in the loop below:
|
|
||||||
dnl First look for a shared library.
|
|
||||||
if test -n "$acl_shlibext"; then
|
|
||||||
if test -f "$dir/$libname$shrext"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_so="$dir/$libname$shrext"
|
|
||||||
else
|
|
||||||
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
|
|
||||||
ver=`(cd "$dir" && \
|
|
||||||
for f in "$libname$shrext".*; do echo "$f"; done \
|
|
||||||
| sed -e "s,^$libname$shrext\\\\.,," \
|
|
||||||
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
|
|
||||||
| sed 1q ) 2>/dev/null`
|
|
||||||
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_so="$dir/$libname$shrext.$ver"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
eval library_names=\"$acl_library_names_spec\"
|
|
||||||
for f in $library_names; do
|
|
||||||
if test -f "$dir/$f"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_so="$dir/$f"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
dnl Then look for a static library.
|
|
||||||
if test "X$found_dir" = "X"; then
|
|
||||||
if test -f "$dir/$libname.$acl_libext"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_a="$dir/$libname.$acl_libext"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "X$found_dir" != "X"; then
|
|
||||||
if test -f "$dir/$libname.la"; then
|
|
||||||
found_la="$dir/$libname.la"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "X$found_dir" = "X"; then
|
|
||||||
for x in $LDFLAGS $LTLIB[]NAME; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
case "$x" in
|
|
||||||
-L*)
|
|
||||||
dir=`echo "X$x" | sed -e 's/^X-L//'`
|
|
||||||
dnl First look for a shared library.
|
|
||||||
if test -n "$acl_shlibext"; then
|
|
||||||
if test -f "$dir/$libname$shrext"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_so="$dir/$libname$shrext"
|
|
||||||
else
|
|
||||||
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
|
|
||||||
ver=`(cd "$dir" && \
|
|
||||||
for f in "$libname$shrext".*; do echo "$f"; done \
|
|
||||||
| sed -e "s,^$libname$shrext\\\\.,," \
|
|
||||||
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
|
|
||||||
| sed 1q ) 2>/dev/null`
|
|
||||||
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_so="$dir/$libname$shrext.$ver"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
eval library_names=\"$acl_library_names_spec\"
|
|
||||||
for f in $library_names; do
|
|
||||||
if test -f "$dir/$f"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_so="$dir/$f"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
dnl Then look for a static library.
|
|
||||||
if test "X$found_dir" = "X"; then
|
|
||||||
if test -f "$dir/$libname.$acl_libext"; then
|
|
||||||
found_dir="$dir"
|
|
||||||
found_a="$dir/$libname.$acl_libext"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "X$found_dir" != "X"; then
|
|
||||||
if test -f "$dir/$libname.la"; then
|
|
||||||
found_la="$dir/$libname.la"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if test "X$found_dir" != "X"; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if test "X$found_dir" != "X"; then
|
|
||||||
dnl Found the library.
|
|
||||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
|
|
||||||
if test "X$found_so" != "X"; then
|
|
||||||
dnl Linking with a shared library. We attempt to hardcode its
|
|
||||||
dnl directory into the executable's runpath, unless it's the
|
|
||||||
dnl standard /usr/lib.
|
|
||||||
if test "$enable_rpath" = no \
|
|
||||||
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
|
|
||||||
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
|
|
||||||
dnl No hardcoding is needed.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
|
||||||
else
|
|
||||||
dnl Use an explicit option to hardcode DIR into the resulting
|
|
||||||
dnl binary.
|
|
||||||
dnl Potentially add DIR to ltrpathdirs.
|
|
||||||
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
|
|
||||||
haveit=
|
|
||||||
for x in $ltrpathdirs; do
|
|
||||||
if test "X$x" = "X$found_dir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
ltrpathdirs="$ltrpathdirs $found_dir"
|
|
||||||
fi
|
|
||||||
dnl The hardcoding into $LIBNAME is system dependent.
|
|
||||||
if test "$acl_hardcode_direct" = yes; then
|
|
||||||
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
|
|
||||||
dnl resulting binary.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
|
||||||
else
|
|
||||||
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
|
|
||||||
dnl Use an explicit option to hardcode DIR into the resulting
|
|
||||||
dnl binary.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
|
||||||
dnl Potentially add DIR to rpathdirs.
|
|
||||||
dnl The rpathdirs will be appended to $LIBNAME at the end.
|
|
||||||
haveit=
|
|
||||||
for x in $rpathdirs; do
|
|
||||||
if test "X$x" = "X$found_dir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
rpathdirs="$rpathdirs $found_dir"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
dnl Rely on "-L$found_dir".
|
|
||||||
dnl But don't add it if it's already contained in the LDFLAGS
|
|
||||||
dnl or the already constructed $LIBNAME
|
|
||||||
haveit=
|
|
||||||
for x in $LDFLAGS $LIB[]NAME; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
if test "X$x" = "X-L$found_dir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
|
|
||||||
fi
|
|
||||||
if test "$acl_hardcode_minus_L" != no; then
|
|
||||||
dnl FIXME: Not sure whether we should use
|
|
||||||
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
|
|
||||||
dnl here.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
|
||||||
else
|
|
||||||
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
|
|
||||||
dnl here, because this doesn't fit in flags passed to the
|
|
||||||
dnl compiler. So give up. No hardcoding. This affects only
|
|
||||||
dnl very old systems.
|
|
||||||
dnl FIXME: Not sure whether we should use
|
|
||||||
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
|
|
||||||
dnl here.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if test "X$found_a" != "X"; then
|
|
||||||
dnl Linking with a static library.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
|
|
||||||
else
|
|
||||||
dnl We shouldn't come here, but anyway it's good to have a
|
|
||||||
dnl fallback.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
dnl Assume the include files are nearby.
|
|
||||||
additional_includedir=
|
|
||||||
case "$found_dir" in
|
|
||||||
*/$acl_libdirstem | */$acl_libdirstem/)
|
|
||||||
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
|
|
||||||
if test "$name" = '$1'; then
|
|
||||||
LIB[]NAME[]_PREFIX="$basedir"
|
|
||||||
fi
|
|
||||||
additional_includedir="$basedir/include"
|
|
||||||
;;
|
|
||||||
*/$acl_libdirstem2 | */$acl_libdirstem2/)
|
|
||||||
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
|
|
||||||
if test "$name" = '$1'; then
|
|
||||||
LIB[]NAME[]_PREFIX="$basedir"
|
|
||||||
fi
|
|
||||||
additional_includedir="$basedir/include"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if test "X$additional_includedir" != "X"; then
|
|
||||||
dnl Potentially add $additional_includedir to $INCNAME.
|
|
||||||
dnl But don't add it
|
|
||||||
dnl 1. if it's the standard /usr/include,
|
|
||||||
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
|
|
||||||
dnl 3. if it's already present in $CPPFLAGS or the already
|
|
||||||
dnl constructed $INCNAME,
|
|
||||||
dnl 4. if it doesn't exist as a directory.
|
|
||||||
if test "X$additional_includedir" != "X/usr/include"; then
|
|
||||||
haveit=
|
|
||||||
if test "X$additional_includedir" = "X/usr/local/include"; then
|
|
||||||
if test -n "$GCC"; then
|
|
||||||
case $host_os in
|
|
||||||
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
for x in $CPPFLAGS $INC[]NAME; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
if test "X$x" = "X-I$additional_includedir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
if test -d "$additional_includedir"; then
|
|
||||||
dnl Really add $additional_includedir to $INCNAME.
|
|
||||||
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
dnl Look for dependencies.
|
|
||||||
if test -n "$found_la"; then
|
|
||||||
dnl Read the .la file. It defines the variables
|
|
||||||
dnl dlname, library_names, old_library, dependency_libs, current,
|
|
||||||
dnl age, revision, installed, dlopen, dlpreopen, libdir.
|
|
||||||
save_libdir="$libdir"
|
|
||||||
case "$found_la" in
|
|
||||||
*/* | *\\*) . "$found_la" ;;
|
|
||||||
*) . "./$found_la" ;;
|
|
||||||
esac
|
|
||||||
libdir="$save_libdir"
|
|
||||||
dnl We use only dependency_libs.
|
|
||||||
for dep in $dependency_libs; do
|
|
||||||
case "$dep" in
|
|
||||||
-L*)
|
|
||||||
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
|
|
||||||
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
|
|
||||||
dnl But don't add it
|
|
||||||
dnl 1. if it's the standard /usr/lib,
|
|
||||||
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
|
|
||||||
dnl 3. if it's already present in $LDFLAGS or the already
|
|
||||||
dnl constructed $LIBNAME,
|
|
||||||
dnl 4. if it doesn't exist as a directory.
|
|
||||||
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
|
|
||||||
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
|
|
||||||
haveit=
|
|
||||||
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
|
|
||||||
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
|
|
||||||
if test -n "$GCC"; then
|
|
||||||
case $host_os in
|
|
||||||
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
haveit=
|
|
||||||
for x in $LDFLAGS $LIB[]NAME; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
if test "X$x" = "X-L$additional_libdir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
if test -d "$additional_libdir"; then
|
|
||||||
dnl Really add $additional_libdir to $LIBNAME.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
haveit=
|
|
||||||
for x in $LDFLAGS $LTLIB[]NAME; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
if test "X$x" = "X-L$additional_libdir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
if test -d "$additional_libdir"; then
|
|
||||||
dnl Really add $additional_libdir to $LTLIBNAME.
|
|
||||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-R*)
|
|
||||||
dir=`echo "X$dep" | sed -e 's/^X-R//'`
|
|
||||||
if test "$enable_rpath" != no; then
|
|
||||||
dnl Potentially add DIR to rpathdirs.
|
|
||||||
dnl The rpathdirs will be appended to $LIBNAME at the end.
|
|
||||||
haveit=
|
|
||||||
for x in $rpathdirs; do
|
|
||||||
if test "X$x" = "X$dir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
rpathdirs="$rpathdirs $dir"
|
|
||||||
fi
|
|
||||||
dnl Potentially add DIR to ltrpathdirs.
|
|
||||||
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
|
|
||||||
haveit=
|
|
||||||
for x in $ltrpathdirs; do
|
|
||||||
if test "X$x" = "X$dir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
ltrpathdirs="$ltrpathdirs $dir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-l*)
|
|
||||||
dnl Handle this in the next round.
|
|
||||||
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
|
|
||||||
;;
|
|
||||||
*.la)
|
|
||||||
dnl Handle this in the next round. Throw away the .la's
|
|
||||||
dnl directory; it is already contained in a preceding -L
|
|
||||||
dnl option.
|
|
||||||
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
dnl Most likely an immediate library name.
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
|
|
||||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
dnl Didn't find the library; assume it is in the system directories
|
|
||||||
dnl known to the linker and runtime loader. (All the system
|
|
||||||
dnl directories known to the linker should also be known to the
|
|
||||||
dnl runtime loader, otherwise the system is severely misconfigured.)
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
|
|
||||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
if test "X$rpathdirs" != "X"; then
|
|
||||||
if test -n "$acl_hardcode_libdir_separator"; then
|
|
||||||
dnl Weird platform: only the last -rpath option counts, the user must
|
|
||||||
dnl pass all path elements in one option. We can arrange that for a
|
|
||||||
dnl single library, but not when more than one $LIBNAMEs are used.
|
|
||||||
alldirs=
|
|
||||||
for found_dir in $rpathdirs; do
|
|
||||||
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
|
|
||||||
done
|
|
||||||
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
|
|
||||||
acl_save_libdir="$libdir"
|
|
||||||
libdir="$alldirs"
|
|
||||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
|
||||||
libdir="$acl_save_libdir"
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
|
|
||||||
else
|
|
||||||
dnl The -rpath options are cumulative.
|
|
||||||
for found_dir in $rpathdirs; do
|
|
||||||
acl_save_libdir="$libdir"
|
|
||||||
libdir="$found_dir"
|
|
||||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
|
||||||
libdir="$acl_save_libdir"
|
|
||||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "X$ltrpathdirs" != "X"; then
|
|
||||||
dnl When using libtool, the option that works for both libraries and
|
|
||||||
dnl executables is -R. The -R options are cumulative.
|
|
||||||
for found_dir in $ltrpathdirs; do
|
|
||||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
popdef([P_A_C_K])
|
|
||||||
popdef([PACKLIBS])
|
|
||||||
popdef([PACKUP])
|
|
||||||
popdef([PACK])
|
|
||||||
popdef([NAME])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
|
|
||||||
dnl unless already present in VAR.
|
|
||||||
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
|
|
||||||
dnl contains two or three consecutive elements that belong together.
|
|
||||||
AC_DEFUN([AC_LIB_APPENDTOVAR],
|
|
||||||
[
|
|
||||||
for element in [$2]; do
|
|
||||||
haveit=
|
|
||||||
for x in $[$1]; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
if test "X$x" = "X$element"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
[$1]="${[$1]}${[$1]:+ }$element"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl For those cases where a variable contains several -L and -l options
|
|
||||||
dnl referring to unknown libraries and directories, this macro determines the
|
|
||||||
dnl necessary additional linker options for the runtime path.
|
|
||||||
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
|
|
||||||
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
|
|
||||||
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
|
|
||||||
dnl otherwise linking without libtool is assumed.
|
|
||||||
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([AC_LIB_RPATH])
|
|
||||||
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
|
|
||||||
$1=
|
|
||||||
if test "$enable_rpath" != no; then
|
|
||||||
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
|
|
||||||
dnl Use an explicit option to hardcode directories into the resulting
|
|
||||||
dnl binary.
|
|
||||||
rpathdirs=
|
|
||||||
next=
|
|
||||||
for opt in $2; do
|
|
||||||
if test -n "$next"; then
|
|
||||||
dir="$next"
|
|
||||||
dnl No need to hardcode the standard /usr/lib.
|
|
||||||
if test "X$dir" != "X/usr/$acl_libdirstem" \
|
|
||||||
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
|
|
||||||
rpathdirs="$rpathdirs $dir"
|
|
||||||
fi
|
|
||||||
next=
|
|
||||||
else
|
|
||||||
case $opt in
|
|
||||||
-L) next=yes ;;
|
|
||||||
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
|
|
||||||
dnl No need to hardcode the standard /usr/lib.
|
|
||||||
if test "X$dir" != "X/usr/$acl_libdirstem" \
|
|
||||||
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
|
|
||||||
rpathdirs="$rpathdirs $dir"
|
|
||||||
fi
|
|
||||||
next= ;;
|
|
||||||
*) next= ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test "X$rpathdirs" != "X"; then
|
|
||||||
if test -n ""$3""; then
|
|
||||||
dnl libtool is used for linking. Use -R options.
|
|
||||||
for dir in $rpathdirs; do
|
|
||||||
$1="${$1}${$1:+ }-R$dir"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
dnl The linker is used for linking directly.
|
|
||||||
if test -n "$acl_hardcode_libdir_separator"; then
|
|
||||||
dnl Weird platform: only the last -rpath option counts, the user
|
|
||||||
dnl must pass all path elements in one option.
|
|
||||||
alldirs=
|
|
||||||
for dir in $rpathdirs; do
|
|
||||||
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
|
|
||||||
done
|
|
||||||
acl_save_libdir="$libdir"
|
|
||||||
libdir="$alldirs"
|
|
||||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
|
||||||
libdir="$acl_save_libdir"
|
|
||||||
$1="$flag"
|
|
||||||
else
|
|
||||||
dnl The -rpath options are cumulative.
|
|
||||||
for dir in $rpathdirs; do
|
|
||||||
acl_save_libdir="$libdir"
|
|
||||||
libdir="$dir"
|
|
||||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
|
||||||
libdir="$acl_save_libdir"
|
|
||||||
$1="${$1}${$1:+ }$flag"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
AC_SUBST([$1])
|
|
||||||
])
|
|
||||||
|
|
@ -1,224 +0,0 @@
|
||||||
# lib-prefix.m4 serial 7 (gettext-0.18)
|
|
||||||
dnl Copyright (C) 2001-2005, 2008-2012 Free Software Foundation, Inc.
|
|
||||||
dnl This file is free software; the Free Software Foundation
|
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
|
||||||
dnl with or without modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
dnl From Bruno Haible.
|
|
||||||
|
|
||||||
dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
|
|
||||||
dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
|
|
||||||
dnl require excessive bracketing.
|
|
||||||
ifdef([AS_HELP_STRING],
|
|
||||||
[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
|
|
||||||
[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
|
|
||||||
|
|
||||||
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
|
|
||||||
dnl to access previously installed libraries. The basic assumption is that
|
|
||||||
dnl a user will want packages to use other packages he previously installed
|
|
||||||
dnl with the same --prefix option.
|
|
||||||
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
|
|
||||||
dnl libraries, but is otherwise very convenient.
|
|
||||||
AC_DEFUN([AC_LIB_PREFIX],
|
|
||||||
[
|
|
||||||
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
|
|
||||||
AC_REQUIRE([AC_PROG_CC])
|
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
|
||||||
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
|
|
||||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
|
||||||
dnl By default, look in $includedir and $libdir.
|
|
||||||
use_additional=yes
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([
|
|
||||||
eval additional_includedir=\"$includedir\"
|
|
||||||
eval additional_libdir=\"$libdir\"
|
|
||||||
])
|
|
||||||
AC_LIB_ARG_WITH([lib-prefix],
|
|
||||||
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
|
|
||||||
--without-lib-prefix don't search for libraries in includedir and libdir],
|
|
||||||
[
|
|
||||||
if test "X$withval" = "Xno"; then
|
|
||||||
use_additional=no
|
|
||||||
else
|
|
||||||
if test "X$withval" = "X"; then
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([
|
|
||||||
eval additional_includedir=\"$includedir\"
|
|
||||||
eval additional_libdir=\"$libdir\"
|
|
||||||
])
|
|
||||||
else
|
|
||||||
additional_includedir="$withval/include"
|
|
||||||
additional_libdir="$withval/$acl_libdirstem"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
if test $use_additional = yes; then
|
|
||||||
dnl Potentially add $additional_includedir to $CPPFLAGS.
|
|
||||||
dnl But don't add it
|
|
||||||
dnl 1. if it's the standard /usr/include,
|
|
||||||
dnl 2. if it's already present in $CPPFLAGS,
|
|
||||||
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
|
|
||||||
dnl 4. if it doesn't exist as a directory.
|
|
||||||
if test "X$additional_includedir" != "X/usr/include"; then
|
|
||||||
haveit=
|
|
||||||
for x in $CPPFLAGS; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
if test "X$x" = "X-I$additional_includedir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
if test "X$additional_includedir" = "X/usr/local/include"; then
|
|
||||||
if test -n "$GCC"; then
|
|
||||||
case $host_os in
|
|
||||||
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
if test -d "$additional_includedir"; then
|
|
||||||
dnl Really add $additional_includedir to $CPPFLAGS.
|
|
||||||
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
dnl Potentially add $additional_libdir to $LDFLAGS.
|
|
||||||
dnl But don't add it
|
|
||||||
dnl 1. if it's the standard /usr/lib,
|
|
||||||
dnl 2. if it's already present in $LDFLAGS,
|
|
||||||
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
|
|
||||||
dnl 4. if it doesn't exist as a directory.
|
|
||||||
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
|
|
||||||
haveit=
|
|
||||||
for x in $LDFLAGS; do
|
|
||||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
|
||||||
if test "X$x" = "X-L$additional_libdir"; then
|
|
||||||
haveit=yes
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
|
|
||||||
if test -n "$GCC"; then
|
|
||||||
case $host_os in
|
|
||||||
linux*) haveit=yes;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test -z "$haveit"; then
|
|
||||||
if test -d "$additional_libdir"; then
|
|
||||||
dnl Really add $additional_libdir to $LDFLAGS.
|
|
||||||
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
|
|
||||||
dnl acl_final_exec_prefix, containing the values to which $prefix and
|
|
||||||
dnl $exec_prefix will expand at the end of the configure script.
|
|
||||||
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
|
|
||||||
[
|
|
||||||
dnl Unfortunately, prefix and exec_prefix get only finally determined
|
|
||||||
dnl at the end of configure.
|
|
||||||
if test "X$prefix" = "XNONE"; then
|
|
||||||
acl_final_prefix="$ac_default_prefix"
|
|
||||||
else
|
|
||||||
acl_final_prefix="$prefix"
|
|
||||||
fi
|
|
||||||
if test "X$exec_prefix" = "XNONE"; then
|
|
||||||
acl_final_exec_prefix='${prefix}'
|
|
||||||
else
|
|
||||||
acl_final_exec_prefix="$exec_prefix"
|
|
||||||
fi
|
|
||||||
acl_save_prefix="$prefix"
|
|
||||||
prefix="$acl_final_prefix"
|
|
||||||
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
|
|
||||||
prefix="$acl_save_prefix"
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
|
|
||||||
dnl variables prefix and exec_prefix bound to the values they will have
|
|
||||||
dnl at the end of the configure script.
|
|
||||||
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
|
|
||||||
[
|
|
||||||
acl_save_prefix="$prefix"
|
|
||||||
prefix="$acl_final_prefix"
|
|
||||||
acl_save_exec_prefix="$exec_prefix"
|
|
||||||
exec_prefix="$acl_final_exec_prefix"
|
|
||||||
$1
|
|
||||||
exec_prefix="$acl_save_exec_prefix"
|
|
||||||
prefix="$acl_save_prefix"
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AC_LIB_PREPARE_MULTILIB creates
|
|
||||||
dnl - a variable acl_libdirstem, containing the basename of the libdir, either
|
|
||||||
dnl "lib" or "lib64" or "lib/64",
|
|
||||||
dnl - a variable acl_libdirstem2, as a secondary possible value for
|
|
||||||
dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
|
|
||||||
dnl "lib/amd64".
|
|
||||||
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
|
|
||||||
[
|
|
||||||
dnl There is no formal standard regarding lib and lib64.
|
|
||||||
dnl On glibc systems, the current practice is that on a system supporting
|
|
||||||
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
|
|
||||||
dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
|
|
||||||
dnl the compiler's default mode by looking at the compiler's library search
|
|
||||||
dnl path. If at least one of its elements ends in /lib64 or points to a
|
|
||||||
dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
|
|
||||||
dnl Otherwise we use the default, namely "lib".
|
|
||||||
dnl On Solaris systems, the current practice is that on a system supporting
|
|
||||||
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
|
|
||||||
dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
|
|
||||||
dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
|
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
|
||||||
acl_libdirstem=lib
|
|
||||||
acl_libdirstem2=
|
|
||||||
case "$host_os" in
|
|
||||||
solaris*)
|
|
||||||
dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
|
|
||||||
dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
|
|
||||||
dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
|
|
||||||
dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
|
|
||||||
dnl symlink is missing, so we set acl_libdirstem2 too.
|
|
||||||
AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
|
|
||||||
[AC_EGREP_CPP([sixtyfour bits], [
|
|
||||||
#ifdef _LP64
|
|
||||||
sixtyfour bits
|
|
||||||
#endif
|
|
||||||
], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
|
|
||||||
])
|
|
||||||
if test $gl_cv_solaris_64bit = yes; then
|
|
||||||
acl_libdirstem=lib/64
|
|
||||||
case "$host_cpu" in
|
|
||||||
sparc*) acl_libdirstem2=lib/sparcv9 ;;
|
|
||||||
i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
|
|
||||||
if test -n "$searchpath"; then
|
|
||||||
acl_save_IFS="${IFS= }"; IFS=":"
|
|
||||||
for searchdir in $searchpath; do
|
|
||||||
if test -d "$searchdir"; then
|
|
||||||
case "$searchdir" in
|
|
||||||
*/lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
|
|
||||||
*/../ | */.. )
|
|
||||||
# Better ignore directories of this form. They are misleading.
|
|
||||||
;;
|
|
||||||
*) searchdir=`cd "$searchdir" && pwd`
|
|
||||||
case "$searchdir" in
|
|
||||||
*/lib64 ) acl_libdirstem=lib64 ;;
|
|
||||||
esac ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
IFS="$acl_save_IFS"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
|
|
||||||
])
|
|
||||||
114
flac/m4/ogg.m4
114
flac/m4/ogg.m4
|
|
@ -1,114 +0,0 @@
|
||||||
# Configure paths for libogg
|
|
||||||
# Jack Moffitt <jack@icecast.org> 10-21-2000
|
|
||||||
# Shamelessly stolen from Owen Taylor and Manish Singh
|
|
||||||
|
|
||||||
dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
|
||||||
dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
|
|
||||||
dnl
|
|
||||||
AC_DEFUN([XIPH_PATH_OGG],
|
|
||||||
[dnl
|
|
||||||
dnl Get the cflags and libraries
|
|
||||||
dnl
|
|
||||||
AC_ARG_WITH(ogg,AS_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="")
|
|
||||||
AC_ARG_WITH(ogg-libraries,AS_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="")
|
|
||||||
AC_ARG_WITH(ogg-includes,AS_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="")
|
|
||||||
AC_ARG_ENABLE(oggtest,AS_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes)
|
|
||||||
|
|
||||||
if test "x$ogg_libraries" != "x" ; then
|
|
||||||
OGG_LIBS="-L$ogg_libraries"
|
|
||||||
elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
|
|
||||||
OGG_LIBS=""
|
|
||||||
elif test "x$ogg_prefix" != "x" ; then
|
|
||||||
OGG_LIBS="-L$ogg_prefix/lib"
|
|
||||||
elif test "x$prefix" != "xNONE" ; then
|
|
||||||
OGG_LIBS="-L$prefix/lib"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "x$ogg_prefix" != "xno" ; then
|
|
||||||
OGG_LIBS="$OGG_LIBS -logg"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "x$ogg_includes" != "x" ; then
|
|
||||||
OGG_CFLAGS="-I$ogg_includes"
|
|
||||||
elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
|
|
||||||
OGG_CFLAGS=""
|
|
||||||
elif test "x$ogg_prefix" != "x" ; then
|
|
||||||
OGG_CFLAGS="-I$ogg_prefix/include"
|
|
||||||
elif test "x$prefix" != "xNONE"; then
|
|
||||||
OGG_CFLAGS="-I$prefix/include"
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(for Ogg)
|
|
||||||
if test "x$ogg_prefix" = "xno" ; then
|
|
||||||
no_ogg="disabled"
|
|
||||||
enable_oggtest="no"
|
|
||||||
else
|
|
||||||
no_ogg=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if test "x$enable_oggtest" = "xyes" ; then
|
|
||||||
ac_save_CFLAGS="$CFLAGS"
|
|
||||||
ac_save_LIBS="$LIBS"
|
|
||||||
CFLAGS="$CFLAGS $OGG_CFLAGS"
|
|
||||||
LIBS="$LIBS $OGG_LIBS"
|
|
||||||
dnl
|
|
||||||
dnl Now check if the installed Ogg is sufficiently new.
|
|
||||||
dnl
|
|
||||||
rm -f conf.oggtest
|
|
||||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ogg/ogg.h>
|
|
||||||
|
|
||||||
int main ()
|
|
||||||
{
|
|
||||||
system("touch conf.oggtest");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
]])],[],[no_ogg=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
|
||||||
CFLAGS="$ac_save_CFLAGS"
|
|
||||||
LIBS="$ac_save_LIBS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "x$no_ogg" = "xdisabled" ; then
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
ifelse([$2], , :, [$2])
|
|
||||||
elif test "x$no_ogg" = "x" ; then
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
ifelse([$1], , :, [$1])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
if test -f conf.oggtest ; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
echo "*** Could not run Ogg test program, checking why..."
|
|
||||||
CFLAGS="$CFLAGS $OGG_CFLAGS"
|
|
||||||
LIBS="$LIBS $OGG_LIBS"
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ogg/ogg.h>
|
|
||||||
]], [[ return 0; ]])],[ echo "*** The test program compiled, but did not run. This usually means"
|
|
||||||
echo "*** that the run-time linker is not finding Ogg or finding the wrong"
|
|
||||||
echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
|
|
||||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
|
||||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
|
||||||
echo "*** is required on your system"
|
|
||||||
echo "***"
|
|
||||||
echo "*** If you have an old version installed, it is best to remove it, although"
|
|
||||||
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],[ echo "*** The test program failed to compile or link. See the file config.log for the"
|
|
||||||
echo "*** exact error that occurred. This usually means Ogg was incorrectly installed"
|
|
||||||
echo "*** or that you have moved Ogg since it was installed." ])
|
|
||||||
CFLAGS="$ac_save_CFLAGS"
|
|
||||||
LIBS="$ac_save_LIBS"
|
|
||||||
fi
|
|
||||||
OGG_CFLAGS=""
|
|
||||||
OGG_LIBS=""
|
|
||||||
ifelse([$2], , :, [$2])
|
|
||||||
fi
|
|
||||||
AC_SUBST(OGG_CFLAGS)
|
|
||||||
AC_SUBST(OGG_LIBS)
|
|
||||||
rm -f conf.oggtest
|
|
||||||
])
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
dnl @synopsis XIPH_GCC_REALLY_IS_GCC
|
|
||||||
dnl
|
|
||||||
dnl Find out if a compiler claiming to be gcc really is gcc (clang lies).
|
|
||||||
dnl @version 1.0 Oct 31 2013
|
|
||||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
|
||||||
dnl
|
|
||||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
|
||||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
|
||||||
dnl and this permission notice appear in all copies. No representations are
|
|
||||||
dnl made about the suitability of this software for any purpose. It is
|
|
||||||
dnl provided "as is" without express or implied warranty.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
# If the configure script has already detected GNU GCC, then make sure it
|
|
||||||
# isn't CLANG masquerading as GCC.
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_GCC_REALLY_IS_GCC],
|
|
||||||
[ AC_LANG_ASSERT(C)
|
|
||||||
if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <stdio.h>
|
|
||||||
]], [[
|
|
||||||
#ifdef __clang__
|
|
||||||
This is clang!
|
|
||||||
#endif
|
|
||||||
]])],[ac_cv_c_compiler_gnu=yes],[ac_cv_c_compiler_gnu=no
|
|
||||||
])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
dnl Copyright (C) 2013-2023 Xiph.Org Foundation
|
|
||||||
dnl
|
|
||||||
dnl Redistribution and use in source and binary forms, with or without
|
|
||||||
dnl modification, are permitted provided that the following conditions
|
|
||||||
dnl are met:
|
|
||||||
dnl
|
|
||||||
dnl - Redistributions of source code must retain the above copyright
|
|
||||||
dnl notice, this list of conditions and the following disclaimer.
|
|
||||||
dnl
|
|
||||||
dnl - Redistributions in binary form must reproduce the above copyright
|
|
||||||
dnl notice, this list of conditions and the following disclaimer in the
|
|
||||||
dnl documentation and/or other materials provided with the distribution.
|
|
||||||
dnl
|
|
||||||
dnl - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
dnl contributors may be used to endorse or promote products derived from
|
|
||||||
dnl this software without specific prior written permission.
|
|
||||||
dnl
|
|
||||||
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
dnl We want to know if GCC stack protector works, for the C and for the C++
|
|
||||||
dnl compiler.
|
|
||||||
dnl
|
|
||||||
dnl Just checking if the compiler accepts the required CFLAGSs is not enough
|
|
||||||
dnl because we have seen at least one instance where this check was
|
|
||||||
dnl in-sufficient.
|
|
||||||
dnl
|
|
||||||
dnl Instead, try to compile and link a test program with the stack protector
|
|
||||||
dnl flags. If that works, we use it.
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_GCC_STACK_PROTECTOR],
|
|
||||||
[AC_LANG_ASSERT(C)
|
|
||||||
AC_MSG_CHECKING([if $CC supports stack smash protection])
|
|
||||||
xiph_stack_check_old_cflags="$CFLAGS"
|
|
||||||
SSP_FLAGS="-fstack-protector-strong"
|
|
||||||
CFLAGS=$SSP_FLAGS
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <stdio.h>
|
|
||||||
]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes)
|
|
||||||
CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS"],[AC_MSG_RESULT(no)
|
|
||||||
CFLAGS="$xiph_stack_check_old_cflags"
|
|
||||||
])
|
|
||||||
])# XIPH_GCC_STACK_PROTECTOR
|
|
||||||
|
|
||||||
AC_DEFUN([XIPH_GXX_STACK_PROTECTOR],
|
|
||||||
[AC_LANG_PUSH([C++])
|
|
||||||
AC_MSG_CHECKING([if $CXX supports stack smash protection])
|
|
||||||
xiph_stack_check_old_cxxflags="$CXXFLAGS"
|
|
||||||
SSP_FLAGS="-fstack-protector-strong"
|
|
||||||
CXXFLAGS=$SSP_FLAGS
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <cstdio>
|
|
||||||
]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes)
|
|
||||||
CXXFLAGS="$xiph_stack_check_old_cxxflags $SSP_FLAGS"],[AC_MSG_RESULT(no)
|
|
||||||
CXXFLAGS="$xiph_stack_check_old_cxxflags"
|
|
||||||
])
|
|
||||||
AC_LANG_POP([C++])
|
|
||||||
])# XIPH_GXX_STACK_PROTECTOR
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
# flac - Command-line FLAC encoder/decoder
|
|
||||||
# Copyright (C) 2000-2009 Josh Coalson
|
|
||||||
# Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
if FLaC__HAS_PANDOC
|
|
||||||
flac.1: flac.md
|
|
||||||
pandoc --standalone --to man $? > $@
|
|
||||||
|
|
||||||
metaflac.1: metaflac.md
|
|
||||||
pandoc --standalone --to man $? > $@
|
|
||||||
|
|
||||||
man_MANS = flac.1 metaflac.1
|
|
||||||
|
|
||||||
else
|
|
||||||
if FLaC__HAS_PREBUILT_MANPAGES
|
|
||||||
man_MANS = flac.1 metaflac.1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
EXTRA_DIST = flac.1 metaflac.1 flac.md metaflac.md
|
|
||||||
760
flac/man/flac.md
760
flac/man/flac.md
|
|
@ -1,760 +0,0 @@
|
||||||
% flac(1) Version 1.4.3 | Free Lossless Audio Codec conversion tool
|
|
||||||
|
|
||||||
# NAME
|
|
||||||
|
|
||||||
flac - Free Lossless Audio Codec
|
|
||||||
|
|
||||||
# SYNOPSIS
|
|
||||||
|
|
||||||
**flac** \[ *OPTIONS* \] \[ *infile.wav* \| *infile.rf64* \|
|
|
||||||
*infile.aiff* \| *infile.raw* \| *infile.flac* \| *infile.oga* \|
|
|
||||||
*infile.ogg* \| **-** *...* \]
|
|
||||||
|
|
||||||
**flac** \[ **-d** \| **\--decode** \| **-t** \| **\--test** \| **-a** \|
|
|
||||||
**\--analyze** \] \[ *OPTIONS* \] \[ *infile.flac* \| *infile.oga* \|
|
|
||||||
*infile.ogg* \| **-** *...* \]
|
|
||||||
|
|
||||||
# DESCRIPTION
|
|
||||||
|
|
||||||
**flac** is a command-line tool for encoding, decoding, testing and
|
|
||||||
analyzing FLAC streams.
|
|
||||||
|
|
||||||
# GENERAL USAGE
|
|
||||||
|
|
||||||
**flac** supports as input RIFF WAVE, Wave64, RF64, AIFF, FLAC or Ogg
|
|
||||||
FLAC format, or raw interleaved samples. The decoder currently can output
|
|
||||||
to RIFF WAVE, Wave64, RF64, or AIFF format, or raw interleaved samples.
|
|
||||||
flac only supports linear PCM samples (in other words, no A-LAW, uLAW,
|
|
||||||
etc.), and the input must be between 4 and 32 bits per sample.
|
|
||||||
|
|
||||||
flac assumes that files ending in ".wav" or that have the RIFF WAVE
|
|
||||||
header present are WAVE files, files ending in ".w64" or have the Wave64
|
|
||||||
header present are Wave64 files, files ending in ".rf64" or have the
|
|
||||||
RF64 header present are RF64 files, files ending in ".aif" or ".aiff" or
|
|
||||||
have the AIFF header present are AIFF files, files ending in ".flac"
|
|
||||||
or have the FLAC header present are FLAC files and files ending in ".oga"
|
|
||||||
or ".ogg" or have the Ogg FLAC header present are Ogg FLAC files.
|
|
||||||
|
|
||||||
Other than this, flac makes no assumptions about file extensions, though
|
|
||||||
the convention is that FLAC files have the extension ".flac"
|
|
||||||
(or ".fla" on ancient "8.3" file systems like FAT-16).
|
|
||||||
|
|
||||||
Before going into the full command-line description, a few other things
|
|
||||||
help to sort it out:
|
|
||||||
1. flac encodes by default, so you must use -d to decode
|
|
||||||
2. the options -0 .. -8 (or --fast and --best) that control the
|
|
||||||
compression level actually are just synonyms for different groups of
|
|
||||||
specific encoding options (described later) and you can get the same
|
|
||||||
effect by using the same options. When specific options are specified
|
|
||||||
they take priority over the compression level no matter the order
|
|
||||||
3. flac behaves similarly to gzip in the way it handles input and output
|
|
||||||
files
|
|
||||||
4. the order in which options are specified is generally not important
|
|
||||||
|
|
||||||
Skip to the examples below for examples of some common tasks.
|
|
||||||
|
|
||||||
flac will be invoked one of four ways, depending on whether you are
|
|
||||||
encoding, decoding, testing, or analyzing. Encoding is the default
|
|
||||||
invocation, but can be switch to decoding with **-d**, analysis with
|
|
||||||
**-a** or testing with **-t**. Depending on which way is chosen,
|
|
||||||
encoding, decoding, analysis or testing options can be used, see section
|
|
||||||
OPTIONS for details. General options can be used for all.
|
|
||||||
|
|
||||||
If only one inputfile is specified, it may be "-" for stdin. When stdin
|
|
||||||
is used as input, flac will write to stdout. Otherwise flac will perform
|
|
||||||
the desired operation on each input file to similarly named output files
|
|
||||||
(meaning for encoding, the extension will be replaced with ".flac", or
|
|
||||||
appended with ".flac" if the input file has no extension, and for
|
|
||||||
decoding, the extension will be ".wav" for WAVE output and ".raw" for raw
|
|
||||||
output). The original file is not deleted unless --delete-input-file is
|
|
||||||
specified.
|
|
||||||
|
|
||||||
If you are encoding/decoding from stdin to a file, you should use the -o
|
|
||||||
option like so:
|
|
||||||
|
|
||||||
flac [options] -o outputfile
|
|
||||||
flac -d [options] -o outputfile
|
|
||||||
|
|
||||||
which are better than:
|
|
||||||
|
|
||||||
flac [options] > outputfile
|
|
||||||
flac -d [options] > outputfile
|
|
||||||
|
|
||||||
since the former allows flac to seek backwards to write the STREAMINFO or
|
|
||||||
RIFF WAVE header contents when necessary.
|
|
||||||
|
|
||||||
Also, you can force output data to go to stdout using -c.
|
|
||||||
|
|
||||||
To encode or decode files that start with a dash, use -- to signal the
|
|
||||||
end of options, to keep the filenames themselves from being treated as
|
|
||||||
options:
|
|
||||||
|
|
||||||
flac -V -- -01-filename.wav
|
|
||||||
|
|
||||||
The encoding options affect the compression ratio and encoding speed. The
|
|
||||||
format options are used to tell flac the arrangement of samples if the
|
|
||||||
input file (or output file when decoding) is a raw file. If it is a RIFF
|
|
||||||
WAVE, Wave64, RF64, or AIFF file the format options are not needed since
|
|
||||||
they are read from the file's header.
|
|
||||||
|
|
||||||
In test mode, flac acts just like in decode mode, except no output file
|
|
||||||
is written. Both decode and test modes detect errors in the stream, but
|
|
||||||
they also detect when the MD5 signature of the decoded audio does not
|
|
||||||
match the stored MD5 signature, even when the bitstream is valid.
|
|
||||||
|
|
||||||
flac can also re-encode FLAC files. In other words, you can specify a
|
|
||||||
FLAC or Ogg FLAC file as an input to the encoder and it will decoder it
|
|
||||||
and re-encode it according to the options you specify. It will also
|
|
||||||
preserve all the metadata unless you override it with other options (e.g.
|
|
||||||
specifying new tags, seekpoints, cuesheet, padding, etc.).
|
|
||||||
|
|
||||||
flac has been tuned so that the default settings yield a good speed vs.
|
|
||||||
compression tradeoff for many kinds of input. However, if you are looking
|
|
||||||
to maximize the compression rate or speed, or want to use the full power
|
|
||||||
of FLAC's metadata system, see the page titled 'About the FLAC Format' on
|
|
||||||
the FLAC website.
|
|
||||||
|
|
||||||
# EXAMPLES
|
|
||||||
|
|
||||||
Some common **encoding** tasks using flac:
|
|
||||||
|
|
||||||
`flac abc.wav`
|
|
||||||
: Encode abc.wav to abc.flac using the default compression setting. abc.wav is not deleted.
|
|
||||||
|
|
||||||
`flac --delete-input-file abc.wav`
|
|
||||||
: Like above, except abc.wav is deleted if there were no errors.
|
|
||||||
|
|
||||||
`flac --delete-input-file -w abc.wav`
|
|
||||||
: Like above, except abc.wav is deleted if there were no errors or warnings.
|
|
||||||
|
|
||||||
`flac --best abc.wav`
|
|
||||||
: Encode abc.wav to abc.flac using the highest compression setting.
|
|
||||||
|
|
||||||
`flac --verify abc.wav`
|
|
||||||
: Encode abc.wav to abc.flac and internally decode abc.flac to make sure it matches abc.wav.
|
|
||||||
|
|
||||||
`flac -o my.flac abc.wav`
|
|
||||||
: Encode abc.wav to my.flac.
|
|
||||||
|
|
||||||
`flac -T "TITLE=Bohemian Rhapsody" -T "ARTIST=Queen" abc.wav`
|
|
||||||
: Encode abc.wav and add some tags at the same time to abc.flac.
|
|
||||||
|
|
||||||
`flac *.wav`
|
|
||||||
: Encode all .wav files in the current directory.
|
|
||||||
|
|
||||||
`flac abc.aiff`
|
|
||||||
: Encode abc.aiff to abc.flac.
|
|
||||||
|
|
||||||
`flac abc.rf64`
|
|
||||||
: Encode abc.rf64 to abc.flac.
|
|
||||||
|
|
||||||
`flac abc.w64`
|
|
||||||
: Encode abc.w64 to abc.flac.
|
|
||||||
|
|
||||||
`flac abc.flac --force`
|
|
||||||
: This one's a little tricky: notice that flac is in encode mode by
|
|
||||||
default (you have to specify -d to decode) so this command actually
|
|
||||||
recompresses abc.flac back to abc.flac. --force is needed to make
|
|
||||||
sure you really want to overwrite abc.flac with a new version. Why
|
|
||||||
would you want to do this? It allows you to recompress an existing
|
|
||||||
FLAC file with (usually) higher compression options or a newer
|
|
||||||
version of FLAC and preserve all the metadata like tags too.
|
|
||||||
|
|
||||||
Some common **decoding** tasks using flac:
|
|
||||||
|
|
||||||
`flac -d abc.flac`
|
|
||||||
: Decode abc.flac to abc.wav. abc.flac is not deleted. NOTE: Without
|
|
||||||
-d it means re-encode abc.flac to abc.flac (see above).
|
|
||||||
|
|
||||||
`flac -d --force-aiff-format abc.flac`
|
|
||||||
`flac -d -o abc.aiff abc.flac`
|
|
||||||
: Two different ways of decoding abc.flac to abc.aiff (AIFF format).
|
|
||||||
abc.flac is not deleted.
|
|
||||||
|
|
||||||
`flac -d --force-rf64-format abc.flac`
|
|
||||||
`flac -d -o abc.rf64 abc.flac`
|
|
||||||
: Two different ways of decoding abc.flac to abc.rf64 (RF64 format).
|
|
||||||
abc.flac is not deleted.
|
|
||||||
|
|
||||||
`flac -d --force-wave64-format abc.flac`
|
|
||||||
`flac -d -o abc.w64 abc.flac`
|
|
||||||
: Two different ways of decoding abc.flac to abc.w64 (Wave64 format).
|
|
||||||
abc.flac is not deleted.
|
|
||||||
|
|
||||||
`flac -d -F abc.flac`
|
|
||||||
: Decode abc.flac to abc.wav and don't abort if errors are found
|
|
||||||
(useful for recovering as much as possible from corrupted files).
|
|
||||||
|
|
||||||
|
|
||||||
# OPTIONS
|
|
||||||
|
|
||||||
A summary of options is included below. For a complete description, see
|
|
||||||
the HTML documentation.
|
|
||||||
|
|
||||||
## GENERAL OPTIONS
|
|
||||||
|
|
||||||
**-v, \--version**
|
|
||||||
: Show the flac version number
|
|
||||||
|
|
||||||
**-h, \--help**
|
|
||||||
: Show basic usage and a list of all options
|
|
||||||
|
|
||||||
**-H, \--explain**
|
|
||||||
: Show detailed explanation of usage and all options
|
|
||||||
|
|
||||||
**-d, \--decode**
|
|
||||||
: Decode (the default behavior is to encode)
|
|
||||||
|
|
||||||
**-t, \--test**
|
|
||||||
: Test a flac encoded file (same as -d except no decoded file is written)
|
|
||||||
|
|
||||||
**-a, \--analyze**
|
|
||||||
: Analyze a FLAC encoded file (same as -d except an analysis file is
|
|
||||||
written)
|
|
||||||
|
|
||||||
**-c, \--stdout**
|
|
||||||
: Write output to stdout
|
|
||||||
|
|
||||||
**-s, \--silent**
|
|
||||||
: Silent mode (do not write runtime encode/decode statistics to stderr)
|
|
||||||
|
|
||||||
**\--totally-silent**
|
|
||||||
: Do not print anything of any kind, including warnings or errors. The
|
|
||||||
exit code will be the only way to determine successful completion.
|
|
||||||
|
|
||||||
**\--no-utf8-convert**
|
|
||||||
: Do not convert tags from local charset to UTF-8. This is useful for
|
|
||||||
scripts, and setting tags in situations where the locale is wrong.
|
|
||||||
This option must appear before any tag options!
|
|
||||||
|
|
||||||
**-w, \--warnings-as-errors**
|
|
||||||
: Treat all warnings as errors (which cause flac to terminate with a
|
|
||||||
non-zero exit code).
|
|
||||||
|
|
||||||
**-f, \--force**
|
|
||||||
: Force overwriting of output files. By default, flac warns that the
|
|
||||||
output file already exists and continues to the next file.
|
|
||||||
|
|
||||||
**-o** *filename***, \--output-name=***filename*
|
|
||||||
: Force the output file name (usually flac just changes the extension).
|
|
||||||
May only be used when encoding a single file. May not be used in
|
|
||||||
conjunction with \--output-prefix.
|
|
||||||
|
|
||||||
**\--output-prefix=***string*
|
|
||||||
: Prefix each output file name with the given string. This can be
|
|
||||||
useful for encoding or decoding files to a different directory. Make
|
|
||||||
sure if your string is a path name that it ends with a trailing \`/'
|
|
||||||
(slash).
|
|
||||||
|
|
||||||
**\--delete-input-file**
|
|
||||||
: Automatically delete the input file after a successful encode or
|
|
||||||
decode. If there was an error (including a verify error) the input
|
|
||||||
file is left intact.
|
|
||||||
|
|
||||||
**\--preserve-modtime**
|
|
||||||
: Output files have their timestamps/permissions set to match those of
|
|
||||||
their inputs (this is default). Use \--no-preserve-modtime to make
|
|
||||||
output files have the current time and default permissions.
|
|
||||||
|
|
||||||
**\--keep-foreign-metadata**
|
|
||||||
: If encoding, save WAVE, RF64, or AIFF non-audio chunks in FLAC
|
|
||||||
metadata. If decoding, restore any saved non-audio chunks from FLAC
|
|
||||||
metadata when writing the decoded file. Foreign metadata cannot be
|
|
||||||
transcoded, e.g. WAVE chunks saved in a FLAC file cannot be restored
|
|
||||||
when decoding to AIFF. Input and output must be regular files (not
|
|
||||||
stdin or stdout). With this option, FLAC will pick the right output
|
|
||||||
format on decoding.
|
|
||||||
|
|
||||||
**\--keep-foreign-metadata-if-present**
|
|
||||||
: Like \--keep-foreign-metadata, but without throwing an error if
|
|
||||||
foreign metadata cannot be found or restored, instead printing a
|
|
||||||
warning.
|
|
||||||
|
|
||||||
**\--skip={***\#***\|***mm:ss.ss***}**
|
|
||||||
: Skip over the first number of samples of the input. This works for
|
|
||||||
both encoding and decoding, but not testing. The alternative form
|
|
||||||
mm:ss.ss can be used to specify minutes, seconds, and fractions of a
|
|
||||||
second.
|
|
||||||
|
|
||||||
**\--until={***\#***\|\[***+***\|***-***\]***mm:ss.ss***}**
|
|
||||||
: Stop at the given sample number for each input file. This works for
|
|
||||||
both encoding and decoding, but not testing. The given sample number
|
|
||||||
is not included in the decoded output. The alternative form mm:ss.ss
|
|
||||||
can be used to specify minutes, seconds, and fractions of a second.
|
|
||||||
If a \`+' (plus) sign is at the beginning, the \--until point is
|
|
||||||
relative to the \--skip point. If a \`-' (minus) sign is at the
|
|
||||||
beginning, the \--until point is relative to end of the audio.
|
|
||||||
|
|
||||||
**\--ogg**
|
|
||||||
: When encoding, generate Ogg FLAC output instead of native FLAC. Ogg
|
|
||||||
FLAC streams are FLAC streams wrapped in an Ogg transport layer. The
|
|
||||||
resulting file should have an '.oga' extension and will still be
|
|
||||||
decodable by flac. When decoding, force the input to be treated as
|
|
||||||
Ogg FLAC. This is useful when piping input from stdin or when the
|
|
||||||
filename does not end in '.oga' or '.ogg'.
|
|
||||||
|
|
||||||
**\--serial-number=***\#*
|
|
||||||
: When used with \--ogg, specifies the serial number to use for the
|
|
||||||
first Ogg FLAC stream, which is then incremented for each additional
|
|
||||||
stream. When encoding and no serial number is given, flac uses a
|
|
||||||
random number for the first stream, then increments it for each
|
|
||||||
additional stream. When decoding and no number is given, flac uses
|
|
||||||
the serial number of the first page.
|
|
||||||
|
|
||||||
## ANALYSIS OPTIONS
|
|
||||||
|
|
||||||
**\--residual-text**
|
|
||||||
: Includes the residual signal in the analysis file. This will make the
|
|
||||||
file very big, much larger than even the decoded file.
|
|
||||||
|
|
||||||
**\--residual-gnuplot**
|
|
||||||
: Generates a gnuplot file for every subframe; each file will contain
|
|
||||||
the residual distribution of the subframe. This will create a lot of
|
|
||||||
files.
|
|
||||||
|
|
||||||
## DECODING OPTIONS
|
|
||||||
|
|
||||||
**\--cue=\[***\#.#***\]\[-\[***\#.#***\]\]**
|
|
||||||
: Set the beginning and ending cuepoints to decode. The optional first
|
|
||||||
\#.# is the track and index point at which decoding will start; the
|
|
||||||
default is the beginning of the stream. The optional second \#.# is
|
|
||||||
the track and index point at which decoding will end; the default is
|
|
||||||
the end of the stream. If the cuepoint does not exist, the closest
|
|
||||||
one before it (for the start point) or after it (for the end point)
|
|
||||||
will be used. If those don't exist, the start of the stream (for the
|
|
||||||
start point) or end of the stream (for the end point) will be used.
|
|
||||||
The cuepoints are merely translated into sample numbers then used as
|
|
||||||
\--skip and \--until. A CD track can always be cued by, for example,
|
|
||||||
\--cue=9.1-10.1 for track 9, even if the CD has no 10th track.
|
|
||||||
|
|
||||||
**-F, \--decode-through-errors**
|
|
||||||
: By default flac stops decoding with an error and removes the
|
|
||||||
partially decoded file if it encounters a bitstream error. With -F,
|
|
||||||
errors are still printed but flac will continue decoding to
|
|
||||||
completion. Note that errors may cause the decoded audio to be
|
|
||||||
missing some samples or have silent sections.
|
|
||||||
|
|
||||||
**\--apply-replaygain-which-is-not-lossless\[=\<specification\>\]**
|
|
||||||
: Applies ReplayGain values while decoding. **WARNING: THIS IS NOT
|
|
||||||
LOSSLESS. DECODED AUDIO WILL NOT BE IDENTICAL TO THE ORIGINAL WITH
|
|
||||||
THIS OPTION.** This option is useful for example in transcoding
|
|
||||||
media servers, where the client does not support ReplayGain. For
|
|
||||||
details on the use of this option, see the section **ReplayGain
|
|
||||||
application specification**.
|
|
||||||
|
|
||||||
## ENCODING OPTIONS
|
|
||||||
|
|
||||||
**-V, \--verify**
|
|
||||||
: Verify a correct encoding by decoding the output in parallel and
|
|
||||||
comparing to the original
|
|
||||||
|
|
||||||
**\--lax**
|
|
||||||
: Allow encoder to generate non-Subset files. The resulting FLAC file
|
|
||||||
may not be streamable or might have trouble being played in all
|
|
||||||
players (especially hardware devices), so you should only use this
|
|
||||||
option in combination with custom encoding options meant for
|
|
||||||
archival.
|
|
||||||
|
|
||||||
**\--replay-gain**
|
|
||||||
: Calculate ReplayGain values and store them as FLAC tags, similar to
|
|
||||||
vorbisgain. Title gains/peaks will be computed for each input file,
|
|
||||||
and an album gain/peak will be computed for all files. All input
|
|
||||||
files must have the same resolution, sample rate, and number of
|
|
||||||
channels. Only mono and stereo files are allowed, and the sample
|
|
||||||
rate must be 8, 11.025, 12, 16, 18.9, 22.05, 24, 28, 32, 36, 37.8,
|
|
||||||
44.1, 48, 56, 64, 72, 75.6, 88.2, 96, 112, 128, 144, 151.2, 176.4,
|
|
||||||
192, 224, 256, 288, 302.4, 352.8, 384, 448, 512, 576, or 604.8 kHz.
|
|
||||||
Also note that this option may leave a few extra bytes in a PADDING
|
|
||||||
block as the exact size of the tags is not known until all files
|
|
||||||
are processed. Note that this option cannot be used when encoding
|
|
||||||
to standard output (stdout).
|
|
||||||
|
|
||||||
**\--cuesheet=***filename*
|
|
||||||
: Import the given cuesheet file and store it in a CUESHEET metadata
|
|
||||||
block. This option may only be used when encoding a single file. A
|
|
||||||
seekpoint will be added for each index point in the cuesheet to the
|
|
||||||
SEEKTABLE unless \--no-cued-seekpoints is specified.
|
|
||||||
|
|
||||||
**\--picture={***FILENAME***\|***SPECIFICATION***}**
|
|
||||||
: Import a picture and store it in a PICTURE metadata block. More than
|
|
||||||
one \--picture option can be specified. Either a filename for the
|
|
||||||
picture file or a more complete specification form can be used. The
|
|
||||||
SPECIFICATION is a string whose parts are separated by \| (pipe)
|
|
||||||
characters. Some parts may be left empty to invoke default values.
|
|
||||||
FILENAME is just shorthand for "\|\|\|\|FILENAME". For the format of
|
|
||||||
SPECIFICATION, see the section **picture specification**.
|
|
||||||
|
|
||||||
**\--ignore-chunk-sizes**
|
|
||||||
: When encoding to flac, ignore the file size headers in WAV and AIFF
|
|
||||||
files to attempt to work around problems with over-sized or malformed
|
|
||||||
files. WAV and AIFF files both have an unsigned 32 bit numbers in
|
|
||||||
the file header which specifes the length of audio data. Since this
|
|
||||||
number is unsigned 32 bits, that limits the size of a valid file to
|
|
||||||
being just over 4 Gigabytes. Files larger than this are mal-formed,
|
|
||||||
but should be read correctly using this option.
|
|
||||||
|
|
||||||
**-S {***\#***\|***X***\|***\#x***\|***\#s***}, \--seekpoint={***\#***\|***X***\|***\#x***\|***\#s***}**
|
|
||||||
: Include a point or points in a SEEKTABLE. Using \#, a seek point at
|
|
||||||
that sample number is added. Using X, a placeholder point is added at
|
|
||||||
the end of a the table. Using \#x, \# evenly spaced seek points will
|
|
||||||
be added, the first being at sample 0. Using \#s, a seekpoint will be
|
|
||||||
added every \# seconds (# does not have to be a whole number; it can
|
|
||||||
be, for example, 9.5, meaning a seekpoint every 9.5 seconds). You may
|
|
||||||
use many -S options; the resulting SEEKTABLE will be the unique-ified
|
|
||||||
union of all such values. With no -S options, flac defaults to
|
|
||||||
'-S 10s'. Use \--no-seektable for no SEEKTABLE. Note: '-S \#x' and
|
|
||||||
'-S \#s' will not work if the encoder can't determine the input size
|
|
||||||
before starting. Note: if you use '-S \#' and \# is \>= samples in
|
|
||||||
the input, there will be either no seek point entered (if the input
|
|
||||||
size is determinable before encoding starts) or a placeholder point
|
|
||||||
(if input size is not determinable).
|
|
||||||
|
|
||||||
**-P** *\#***, \--padding=***\#*
|
|
||||||
: Tell the encoder to write a PADDING metadata block of the given
|
|
||||||
length (in bytes) after the STREAMINFO block. This is useful if you
|
|
||||||
plan to tag the file later with an APPLICATION block; instead of
|
|
||||||
having to rewrite the entire file later just to insert your block,
|
|
||||||
you can write directly over the PADDING block. Note that the total
|
|
||||||
length of the PADDING block will be 4 bytes longer than the length
|
|
||||||
given because of the 4 metadata block header bytes. You can force no
|
|
||||||
PADDING block at all to be written with \--no-padding. The encoder
|
|
||||||
writes a PADDING block of 8192 bytes by default (or 65536 bytes if
|
|
||||||
the input audio stream is more that 20 minutes long).
|
|
||||||
|
|
||||||
**-T** *FIELD=VALUE***, \--tag=***FIELD=VALUE*
|
|
||||||
: Add a FLAC tag. The comment must adhere to the Vorbis comment spec;
|
|
||||||
i.e. the FIELD must contain only legal characters, terminated by an
|
|
||||||
'equals' sign. Make sure to quote the comment if necessary. This
|
|
||||||
option may appear more than once to add several comments. NOTE: all
|
|
||||||
tags will be added to all encoded files.
|
|
||||||
|
|
||||||
**\--tag-from-file=***FIELD=FILENAME*
|
|
||||||
: Like \--tag, except FILENAME is a file whose contents will be read
|
|
||||||
verbatim to set the tag value. The contents will be converted to
|
|
||||||
UTF-8 from the local charset. This can be used to store a cuesheet
|
|
||||||
in a tag (e.g. \--tag-from-file="CUESHEET=image.cue"). Do not try to
|
|
||||||
store binary data in tag fields! Use APPLICATION blocks for that.
|
|
||||||
|
|
||||||
**-b** *\#***, \--blocksize=***\#*
|
|
||||||
: Specify the blocksize in samples. The default is 1152 for -l 0,
|
|
||||||
else 4096. For subset streams this must be \<= 4608 if the samplerate
|
|
||||||
\<= 48kHz, for subset streams with higher samplerates it must be \<=
|
|
||||||
16384.
|
|
||||||
|
|
||||||
**-m, \--mid-side**
|
|
||||||
: Try mid-side coding for each frame (stereo input only)
|
|
||||||
|
|
||||||
**-M, \--adaptive-mid-side**
|
|
||||||
: Adaptive mid-side coding for all frames (stereo input only)
|
|
||||||
|
|
||||||
**-0..-8, \--compression-level-0..\--compression-level-8**
|
|
||||||
: Fastest compression..highest compression (default is -5). These are
|
|
||||||
synonyms for other options:
|
|
||||||
|
|
||||||
**-0, \--compression-level-0**
|
|
||||||
: Synonymous with -l 0 -b 1152 -r 3 \--no-mid-side
|
|
||||||
|
|
||||||
**-1, \--compression-level-1**
|
|
||||||
: Synonymous with -l 0 -b 1152 -M -r 3
|
|
||||||
|
|
||||||
**-2, \--compression-level-2**
|
|
||||||
: Synonymous with -l 0 -b 1152 -m -r 3
|
|
||||||
|
|
||||||
**-3, \--compression-level-3**
|
|
||||||
: Synonymous with -l 6 -b 4096 -r 4 \--no-mid-side
|
|
||||||
|
|
||||||
**-4, \--compression-level-4**
|
|
||||||
: Synonymous with -l 8 -b 4096 -M -r 4
|
|
||||||
|
|
||||||
**-5, \--compression-level-5**
|
|
||||||
: Synonymous with -l 8 -b 4096 -m -r 5
|
|
||||||
|
|
||||||
**-6, \--compression-level-6**
|
|
||||||
: Synonymous with -l 8 -b 4096 -m -r 6 -A subdivide_tukey(2)
|
|
||||||
|
|
||||||
**-7, \--compression-level-7**
|
|
||||||
: Synonymous with -l 12 -b 4096 -m -r 6 -A subdivide_tukey(2)
|
|
||||||
|
|
||||||
**-8, \--compression-level-8**
|
|
||||||
: Synonymous with -l 12 -b 4096 -m -r 6 -A subdivide_tukey(3)
|
|
||||||
|
|
||||||
**\--fast**
|
|
||||||
: Fastest compression. Currently synonymous with -0.
|
|
||||||
|
|
||||||
**\--best**
|
|
||||||
: Highest compression. Currently synonymous with -8.
|
|
||||||
|
|
||||||
**-e, \--exhaustive-model-search**
|
|
||||||
: Do exhaustive model search (expensive!)
|
|
||||||
|
|
||||||
**-A** *function***, \--apodization=***function*
|
|
||||||
: Window audio data with given the apodization function. See section
|
|
||||||
**Apodization functions** for details.
|
|
||||||
|
|
||||||
**-l** *\#***, \--max-lpc-order=***\#*
|
|
||||||
: Specifies the maximum LPC order. This number must be \<= 32. For
|
|
||||||
subset streams, it must be \<=12 if the sample rate is \<=48kHz. If
|
|
||||||
0, the encoder will not attempt generic linear prediction, and use
|
|
||||||
only fixed predictors. Using fixed predictors is faster but usually
|
|
||||||
results in files being 5-10% larger.
|
|
||||||
|
|
||||||
**-p, \--qlp-coeff-precision-search**
|
|
||||||
: Do exhaustive search of LP coefficient quantization (expensive!).
|
|
||||||
Overrides -q; does nothing if using -l 0
|
|
||||||
|
|
||||||
**-q** *\#***, \--qlp-coeff-precision=***\#*
|
|
||||||
: Precision of the quantized linear-predictor coefficients, 0 =\> let
|
|
||||||
encoder decide (min is 5, default is 0)
|
|
||||||
|
|
||||||
**-r \[***\#***,\]***\#***, \--rice-partition-order=\[***\#***,\]***\#*
|
|
||||||
: Set the \[min,\]max residual partition order (0..15). min defaults to
|
|
||||||
0 if unspecified. Default is -r 5.
|
|
||||||
|
|
||||||
## FORMAT OPTIONS
|
|
||||||
|
|
||||||
**\--endian={***big***\|***little***}**
|
|
||||||
: Set the byte order for samples
|
|
||||||
|
|
||||||
**\--channels=***\#*
|
|
||||||
: Set number of channels.
|
|
||||||
|
|
||||||
**\--bps=***\#*
|
|
||||||
: Set bits per sample.
|
|
||||||
|
|
||||||
**\--sample-rate=***\#*
|
|
||||||
: Set sample rate (in Hz).
|
|
||||||
|
|
||||||
**\--sign={***signed***\|***unsigned***}**
|
|
||||||
: Set the sign of samples.
|
|
||||||
|
|
||||||
**\--input-size=***\#*
|
|
||||||
: Specify the size of the raw input in bytes. If you are encoding raw
|
|
||||||
samples from stdin, you must set this option in order to be able to
|
|
||||||
use \--skip, \--until, \--cuesheet, or other options that need to
|
|
||||||
know the size of the input beforehand. If the size given is greater
|
|
||||||
than what is found in the input stream, the encoder will complain
|
|
||||||
about an unexpected end-of-file. If the size given is less, samples
|
|
||||||
will be truncated.
|
|
||||||
|
|
||||||
**\--force-raw-format**
|
|
||||||
: Force input (when encoding) or output (when decoding) to be treated
|
|
||||||
as raw samples (even if filename ends in *.wav*).
|
|
||||||
|
|
||||||
**\--force-aiff-format**
|
|
||||||
**\--force-rf64-format**
|
|
||||||
**\--force-wave64-format**
|
|
||||||
: Force the decoder to output AIFF/RF64/WAVE64 format respectively.
|
|
||||||
This option is not needed if the output filename (as set by -o)
|
|
||||||
ends with *.aif* or *.aiff*, *.rf64* and *.w64* respectively. Also,
|
|
||||||
this option has no effect when encoding since input is
|
|
||||||
auto-detected. When none of these options nor
|
|
||||||
--keep-foreign-metadata are given and no output filename is set,
|
|
||||||
the output format is WAV by default.
|
|
||||||
|
|
||||||
**\--force-legacy-wave-format**
|
|
||||||
**\--force-extensible-wave-format**
|
|
||||||
: Instruct the decoder to output a WAVE file with WAVE_FORMAT_PCM and
|
|
||||||
WAVE_FORMAT_EXTENSIBLE respectively. If none of these options nor
|
|
||||||
--keep-foreign-metadata are given, FLAC outputs WAVE_FORMAT_PCM
|
|
||||||
for mono or stereo with a bit depth of 8 or 16 bits, and
|
|
||||||
WAVE_FORMAT_EXTENSIBLE for all other audio formats.
|
|
||||||
|
|
||||||
**\--force-aiff-c-none-format**
|
|
||||||
**\--force-aiff-c-sowt-format**
|
|
||||||
: Instruct the decoder to output an AIFF-C file with format NONE and
|
|
||||||
sowt respectively.
|
|
||||||
|
|
||||||
## NEGATIVE OPTIONS
|
|
||||||
|
|
||||||
**\--no-adaptive-mid-side**
|
|
||||||
**\--no-cued-seekpoints**
|
|
||||||
**\--no-decode-through-errors**
|
|
||||||
**\--no-delete-input-file**
|
|
||||||
**\--no-preserve-modtime**
|
|
||||||
**\--no-keep-foreign-metadata**
|
|
||||||
**\--no-exhaustive-model-search**
|
|
||||||
**\--no-force**
|
|
||||||
**\--no-lax**
|
|
||||||
**\--no-mid-side**
|
|
||||||
**\--no-ogg**
|
|
||||||
**\--no-padding**
|
|
||||||
**\--no-qlp-coeff-prec-search**
|
|
||||||
**\--no-replay-gain**
|
|
||||||
**\--no-residual-gnuplot**
|
|
||||||
**\--no-residual-text**
|
|
||||||
**\--no-seektable**
|
|
||||||
**\--no-silent**
|
|
||||||
**\--no-verify**
|
|
||||||
**\--no-warnings-as-errors**
|
|
||||||
|
|
||||||
These flags can be used to invert the sense of the corresponding normal
|
|
||||||
option.
|
|
||||||
|
|
||||||
## ReplayGain application specification
|
|
||||||
The option \--apply-replaygain-which-is-not-lossless\[=\<specification\>\]**
|
|
||||||
applies ReplayGain values while decoding. **WARNING: THIS IS NOT
|
|
||||||
LOSSLESS. DECODED AUDIO WILL NOT BE IDENTICAL TO THE ORIGINAL WITH THIS
|
|
||||||
OPTION.** This option is useful for example in transcoding media servers,
|
|
||||||
where the client does not support ReplayGain.
|
|
||||||
|
|
||||||
The equals sign and \<specification\> is optional. If omitted, the
|
|
||||||
default specification is 0aLn1.
|
|
||||||
|
|
||||||
The \<specification\> is a shorthand notation for describing how to apply
|
|
||||||
ReplayGain. All components are optional but order is important. '\[\]'
|
|
||||||
means 'optional'. '\|' means 'or'. '{}' means required. The format is:
|
|
||||||
|
|
||||||
\[\<preamp\>\]\[a\|t\]\[l\|L\]\[n{0\|1\|2\|3}\]
|
|
||||||
|
|
||||||
In which the following parameters are used:
|
|
||||||
|
|
||||||
- **preamp**: A floating point number in dB. This is added to the
|
|
||||||
existing gain value.
|
|
||||||
|
|
||||||
- **a\|t**: Specify 'a' to use the album gain, or 't' to use the track
|
|
||||||
gain. If tags for the preferred kind (album/track) do not exist but
|
|
||||||
tags for the other (track/album) do, those will be used instead.
|
|
||||||
|
|
||||||
- **l\|L**: Specify 'l' to peak-limit the output, so that the
|
|
||||||
ReplayGain peak value is full-scale. Specify 'L' to use a 6dB hard
|
|
||||||
limiter that kicks in when the signal approaches full-scale.
|
|
||||||
|
|
||||||
- **n{0\|1\|2\|3}**: Specify the amount of noise shaping. ReplayGain
|
|
||||||
synthesis happens in floating point; the result is dithered before
|
|
||||||
converting back to integer. This quantization adds noise. Noise
|
|
||||||
shaping tries to move the noise where you won't hear it as much.
|
|
||||||
0 means no noise shaping, 1 means 'low', 2 means 'medium', 3 means
|
|
||||||
'high'.
|
|
||||||
|
|
||||||
For example, the default of 0aLn1 means 0dB preamp, use album gain, 6dB
|
|
||||||
hard limit, low noise shaping. \--apply-replaygain-which-is-not-lossless=3
|
|
||||||
means 3dB preamp, use album gain, no limiting, no noise shaping.
|
|
||||||
|
|
||||||
flac uses the ReplayGain tags for the calculation. If a stream does
|
|
||||||
not have the required tags or they can't be parsed, decoding will
|
|
||||||
continue with a warning, and no ReplayGain is applied to that stream.
|
|
||||||
|
|
||||||
## Picture specification
|
|
||||||
This described the specification used for the **\--picture** option.
|
|
||||||
\[TYPE\]\|\[MIME-TYPE\]\|\[DESCRIPTION\]\|\[WIDTHxHEIGHTxDEPTH\[/COLORS\]\]\|FILE
|
|
||||||
|
|
||||||
TYPE is optional; it is a number from one of:
|
|
||||||
|
|
||||||
0. Other
|
|
||||||
1. 32x32 pixels 'file icon' (PNG only)
|
|
||||||
2. Other file icon
|
|
||||||
3. Cover (front)
|
|
||||||
4. Cover (back)
|
|
||||||
5. Leaflet page
|
|
||||||
6. Media (e.g. label side of CD)
|
|
||||||
7. Lead artist/lead performer/soloist
|
|
||||||
8. Artist/performer
|
|
||||||
9. Conductor
|
|
||||||
10. Band/Orchestra
|
|
||||||
11. Composer
|
|
||||||
12. Lyricist/text writer
|
|
||||||
13. Recording Location
|
|
||||||
14. During recording
|
|
||||||
15. During performance
|
|
||||||
16. Movie/video screen capture
|
|
||||||
17. A bright coloured fish
|
|
||||||
18. Illustration
|
|
||||||
19. Band/artist logotype
|
|
||||||
20. Publisher/Studio logotype
|
|
||||||
|
|
||||||
The default is 3 (front cover). There may only be one picture each of
|
|
||||||
type 1 and 2 in a file.
|
|
||||||
|
|
||||||
MIME-TYPE is optional; if left blank, it will be detected from the file.
|
|
||||||
For best compatibility with players, use pictures with MIME type
|
|
||||||
image/jpeg or image/png. The MIME type can also be \--\> to mean that
|
|
||||||
FILE is actually a URL to an image, though this use is discouraged.
|
|
||||||
|
|
||||||
DESCRIPTION is optional; the default is an empty string.
|
|
||||||
|
|
||||||
The next part specifies the resolution and color information. If the
|
|
||||||
MIME-TYPE is image/jpeg, image/png, or image/gif, you can usually leave
|
|
||||||
this empty and they can be detected from the file. Otherwise, you must
|
|
||||||
specify the width in pixels, height in pixels, and color depth in
|
|
||||||
bits-per-pixel. If the image has indexed colors you should also specify
|
|
||||||
the number of colors used. When manually specified, it is not checked
|
|
||||||
against the file for accuracy.
|
|
||||||
|
|
||||||
FILE is the path to the picture file to be imported, or the URL if MIME
|
|
||||||
type is \--\>
|
|
||||||
|
|
||||||
For example, "\|image/jpeg\|\|\|../cover.jpg" will embed the JPEG file
|
|
||||||
at ../cover.jpg, defaulting to type 3 (front cover) and an empty
|
|
||||||
description. The resolution and color info will be retrieved from the
|
|
||||||
file itself.
|
|
||||||
|
|
||||||
The specification
|
|
||||||
"4\|\--\>\|CD\|320x300x24/173\|http://blah.blah/backcover.tiff" will
|
|
||||||
embed the given URL, with type 4 (back cover), description "CD", and a
|
|
||||||
manually specified resolution of 320x300, 24 bits-per-pixel, and 173
|
|
||||||
colors. The file at the URL will not be fetched; the URL itself is
|
|
||||||
stored in the PICTURE metadata block.
|
|
||||||
|
|
||||||
## Apodization functions
|
|
||||||
To improve LPC analysis, audio data is windowed . The window can be
|
|
||||||
selected with one or more **-A** options. Possible functions are:
|
|
||||||
bartlett, bartlett_hann, blackman, blackman_harris_4term_92db,
|
|
||||||
connes, flattop, gauss(STDDEV), hamming, hann, kaiser_bessel, nuttall,
|
|
||||||
rectangle, triangle, tukey(P), partial_tukey(n\[/ov\[/P\]\]),
|
|
||||||
punchout_tukey(n\[/ov\[/P\]\]), subdivide_tukey(n\[/P\]) welch.
|
|
||||||
|
|
||||||
- For gauss(STDDEV), STDDEV is the standard deviation (0\<STDDEV\<=0.5).
|
|
||||||
|
|
||||||
- For tukey(P), P specifies the fraction of the window that is tapered
|
|
||||||
(0\<=P\<=1; P=0 corresponds to "rectangle" and P=1 corresponds to
|
|
||||||
"hann").
|
|
||||||
|
|
||||||
- For partial_tukey(n) and punchout_tukey(n), n apodization functions are
|
|
||||||
added that span different parts of each block. Values of 2 to 6 seem to
|
|
||||||
yield sane results. If necessary, an overlap can be specified, as can be
|
|
||||||
the taper parameter, for example partial_tukey(2/0.2) or
|
|
||||||
partial_tukey(2/0.2/0.5). ov should be smaller than 1 and can be
|
|
||||||
negative. The use of this is that different parts of a block are ignored
|
|
||||||
as the might contain transients which are hard to predict anyway. The
|
|
||||||
encoder will try each different added apodization (each covering a
|
|
||||||
different part of the block) to see which resulting predictor results in
|
|
||||||
the smallest representation.
|
|
||||||
|
|
||||||
- subdivide_tukey(n) is a more efficient reimplementation of partial_tukey
|
|
||||||
and punchout_tukey taken together, recycling as much data as possible. It
|
|
||||||
combines all possible non-redundant partial_tukey(n) and punchout_tukey(n)
|
|
||||||
up to the n specified. Specifying subdivide_tukey(3) is equivalent to
|
|
||||||
specifying tukey, partial_tukey(2), partial_tukey(3) and punchout_tukey(3),
|
|
||||||
specifying subdivide_tukey(5) equivalently adds partial_tukey(4),
|
|
||||||
punchout_tukey(4), partial_tukey(5) and punchout_tukey(5). To be able to
|
|
||||||
reuse data as much as possible, the tukey taper is taken equal for all
|
|
||||||
windows, and the P specified is applied for the smallest used window.
|
|
||||||
In other words, subdivide_tukey(2/0.5) results in a taper equal to that
|
|
||||||
of tukey(0.25) and subdivide_tukey(5) in a taper equal to that of
|
|
||||||
tukey(0.1). The default P for subdivide_tukey when none is specified is
|
|
||||||
0.5.
|
|
||||||
|
|
||||||
Note that P, STDDEV and ov are locale specific, so a comma as
|
|
||||||
decimal separator might be required instead of a dot. Use scientific
|
|
||||||
notation for a locale-independent specification, for example
|
|
||||||
tukey(5e-1) instead of tukey(0.5) or tukey(0,5).
|
|
||||||
|
|
||||||
More than one -A option (up to 32) may be used. Any function that is
|
|
||||||
specified erroneously is silently dropped. The encoder chooses suitable
|
|
||||||
defaults in the absence of any -A options; any -A option specified
|
|
||||||
replaces the default(s).
|
|
||||||
|
|
||||||
When more than one function is specified, then for every subframe the
|
|
||||||
encoder will try each of them separately and choose the window that
|
|
||||||
results in the smallest compressed subframe. Multiple functions can
|
|
||||||
greatly increase the encoding time.
|
|
||||||
|
|
||||||
# SEE ALSO
|
|
||||||
|
|
||||||
**metaflac(1)**
|
|
||||||
|
|
||||||
# AUTHOR
|
|
||||||
|
|
||||||
This manual page was initially written by Matt Zimmerman
|
|
||||||
\<mdz@debian.org\> for the Debian GNU/Linux system (but may be used by
|
|
||||||
others). It has been kept up-to-date by the Xiph.org Foundation.
|
|
||||||
|
|
@ -1,299 +0,0 @@
|
||||||
% metaflac(1) Version 1.4.3 | Free Lossless Audio Codec metadata tool
|
|
||||||
|
|
||||||
# NAME
|
|
||||||
|
|
||||||
metaflac - program to list, add, remove, or edit metadata in one or more
|
|
||||||
FLAC files.
|
|
||||||
|
|
||||||
# SYNOPSIS
|
|
||||||
|
|
||||||
**metaflac** \[ *options* \] \[ *operations* \] *FLACfile ...*
|
|
||||||
|
|
||||||
# DESCRIPTION
|
|
||||||
|
|
||||||
Use **metaflac** to list, add, remove, or edit metadata in one or more
|
|
||||||
FLAC files. You may perform one major operation, or many shorthand
|
|
||||||
operations at a time.
|
|
||||||
|
|
||||||
# GENERAL USAGE
|
|
||||||
|
|
||||||
metaflac is the command-line .flac file metadata editor. You can use it
|
|
||||||
to list the contents of metadata blocks, edit, delete or insert blocks,
|
|
||||||
and manage padding.
|
|
||||||
|
|
||||||
metaflac takes a set of "options" (though some are not optional) and a
|
|
||||||
set of FLAC files to operate on. There are three kinds of "options":
|
|
||||||
|
|
||||||
- Major operations, which specify a mode of operation like listing
|
|
||||||
blocks, removing blocks, etc. These will have sub-operations describing
|
|
||||||
exactly what is to be done.
|
|
||||||
|
|
||||||
- Shorthand operations, which are convenient synonyms for major
|
|
||||||
operations. For example, there is a shorthand operation
|
|
||||||
--show-sample-rate that shows just the sample rate field from the
|
|
||||||
STREAMINFO metadata block.
|
|
||||||
|
|
||||||
- Global options, which affect all the operations.
|
|
||||||
|
|
||||||
All of these are described in the tables below. At least one shorthand
|
|
||||||
or major operation must be supplied. You can use multiple shorthand
|
|
||||||
operations to do more than one thing to a file or set of files. Most of
|
|
||||||
the common things to do to metadata have shorthand operations. As an
|
|
||||||
example, here is how to show the MD5 signatures for a set of three FLAC
|
|
||||||
files:
|
|
||||||
|
|
||||||
`metaflac --show-md5sum file1.flac file2.flac file3.flac`
|
|
||||||
|
|
||||||
Another example; this removes all DESCRIPTION and COMMENT tags in a set
|
|
||||||
of FLAC files, and uses the --preserve-modtime global option to keep the
|
|
||||||
FLAC file modification times the same (usually when files are edited the
|
|
||||||
modification time is set to the current time):
|
|
||||||
|
|
||||||
`metaflac --preserve-modtime --remove-tag=DESCRIPTION --remove-tag=COMMENT file1.flac file2.flac file3.flac`
|
|
||||||
|
|
||||||
# OPTIONS
|
|
||||||
|
|
||||||
**\--preserve-modtime**
|
|
||||||
: Preserve the original modification time in spite of edits.
|
|
||||||
|
|
||||||
**\--with-filename**
|
|
||||||
: Prefix each output line with the FLAC file name (the default if more
|
|
||||||
than one FLAC file is specified). This option has no effect for
|
|
||||||
options exporting to a file, like --export-tags-to.
|
|
||||||
|
|
||||||
**\--no-filename**
|
|
||||||
: Do not prefix each output line with the FLAC file name (the default
|
|
||||||
if only one FLAC file is specified).
|
|
||||||
|
|
||||||
**\--no-utf8-convert**
|
|
||||||
: Do not convert tags from UTF-8 to local charset, or vice versa. This
|
|
||||||
is useful for scripts, and setting tags in situations where the
|
|
||||||
locale is wrong.
|
|
||||||
|
|
||||||
**\--dont-use-padding**
|
|
||||||
: By default metaflac tries to use padding where possible to avoid
|
|
||||||
rewriting the entire file if the metadata size changes. Use this
|
|
||||||
option to tell metaflac to not take advantage of padding this way.
|
|
||||||
|
|
||||||
# SHORTHAND OPERATIONS
|
|
||||||
|
|
||||||
**\--show-md5sum**
|
|
||||||
: Show the MD5 signature from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-min-blocksize**
|
|
||||||
: Show the minimum block size from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-max-blocksize**
|
|
||||||
: Show the maximum block size from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-min-framesize**
|
|
||||||
: Show the minimum frame size from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-max-framesize**
|
|
||||||
: Show the maximum frame size from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-sample-rate**
|
|
||||||
: Show the sample rate from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-channels**
|
|
||||||
: Show the number of channels from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-bps**
|
|
||||||
: Show the \# of bits per sample from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-total-samples**
|
|
||||||
: Show the total \# of samples from the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--show-vendor-tag**
|
|
||||||
: Show the vendor string from the VORBIS_COMMENT block.
|
|
||||||
|
|
||||||
**\--show-tag=name**
|
|
||||||
: Show all tags where the field name matches 'name'.
|
|
||||||
|
|
||||||
**\--show-all-tags**
|
|
||||||
: Show all tags. This is an alias for --export-tags-to=-.
|
|
||||||
|
|
||||||
**\--remove-tag=name**
|
|
||||||
: Remove all tags whose field name is 'name'.
|
|
||||||
|
|
||||||
**\--remove-first-tag=name**
|
|
||||||
: Remove first tag whose field name is 'name'.
|
|
||||||
|
|
||||||
**\--remove-all-tags**
|
|
||||||
: Remove all tags, leaving only the vendor string.
|
|
||||||
|
|
||||||
**\--remove-all-tags-except=NAME1\[=NAME2\[=...\]\]**
|
|
||||||
: Remove all tags, except the vendor string and the tag names
|
|
||||||
specified. Tag names must be separated by an = character.
|
|
||||||
|
|
||||||
**\--set-tag=field**
|
|
||||||
: Add a tag. The field must comply with the Vorbis comment spec, of the
|
|
||||||
form "NAME=VALUE". If there is currently no tag block, one will be
|
|
||||||
created.
|
|
||||||
|
|
||||||
**\--set-tag-from-file=field**
|
|
||||||
: Like \--set-tag, except the VALUE is a filename whose contents will
|
|
||||||
be read verbatim to set the tag value. Unless \--no-utf8-convert is
|
|
||||||
specified, the contents will be converted to UTF-8 from the local
|
|
||||||
charset. This can be used to store a cuesheet in a tag (e.g.
|
|
||||||
\--set-tag-from-file="CUESHEET=image.cue"). Do not try to store
|
|
||||||
binary data in tag fields! Use APPLICATION blocks for that.
|
|
||||||
|
|
||||||
**\--import-tags-from=file**
|
|
||||||
: Import tags from a file. Use '-' for stdin. Each line should be of
|
|
||||||
the form NAME=VALUE. Multi-line comments are currently not supported.
|
|
||||||
Specify \--remove-all-tags and/or \--no-utf8-convert before
|
|
||||||
\--import-tags-from if necessary. If FILE is '-' (stdin), only one
|
|
||||||
FLAC file may be specified.
|
|
||||||
|
|
||||||
**\--export-tags-to=file**
|
|
||||||
: Export tags to a file. Use '-' for stdout. Each line will be of the
|
|
||||||
form NAME=VALUE. Specify \--no-utf8-convert if necessary.
|
|
||||||
|
|
||||||
**\--import-cuesheet-from=file**
|
|
||||||
: Import a cuesheet from a file. Use '-' for stdin. Only one FLAC file
|
|
||||||
may be specified. A seekpoint will be added for each index point in
|
|
||||||
the cuesheet to the SEEKTABLE unless \--no-cued-seekpoints is
|
|
||||||
specified.
|
|
||||||
|
|
||||||
**\--export-cuesheet-to=file**
|
|
||||||
: Export CUESHEET block to a cuesheet file, suitable for use by CD
|
|
||||||
authoring software. Use '-' for stdout. Only one FLAC file may be
|
|
||||||
specified on the command line.
|
|
||||||
|
|
||||||
**\--import-picture-from={***FILENAME***\|***SPECIFICATION***}**
|
|
||||||
: Import a picture and store it in a PICTURE metadata block. More than
|
|
||||||
one \--import-picture-from command can be specified. Either a filename
|
|
||||||
for the picture file or a more complete specification form can be
|
|
||||||
used. The SPECIFICATION is a string whose parts are separated by \|
|
|
||||||
(pipe) characters. Some parts may be left empty to invoke default
|
|
||||||
values. FILENAME is just shorthand for "\|\|\|\|FILENAME". For
|
|
||||||
details on the specification, see the section **Picture
|
|
||||||
specification** in the **flac(1)** man page.
|
|
||||||
|
|
||||||
**\--export-picture-to=file**
|
|
||||||
: Export PICTURE block to a file. Use '-' for stdout. Only one FLAC
|
|
||||||
file may be specified on the command line. The first PICTURE block
|
|
||||||
will be exported unless \--export-picture-to is preceded by a
|
|
||||||
\--block-number=# option to specify the exact metadata block to
|
|
||||||
extract. Note that the block number is the one shown by \--list.
|
|
||||||
|
|
||||||
**\--add-replay-gain**
|
|
||||||
: Calculates the title and album gains/peaks of the given FLAC files as
|
|
||||||
if all the files were part of one album, then stores them as FLAC
|
|
||||||
tags. The tags are the same as those used by vorbisgain. Existing
|
|
||||||
ReplayGain tags will be replaced. If only one FLAC file is given,
|
|
||||||
the album and title gains will be the same. Since this operation
|
|
||||||
requires two passes, it is always executed last, after all other
|
|
||||||
operations have been completed and written to disk. All FLAC files
|
|
||||||
specified must have the same resolution, sample rate, and number of
|
|
||||||
channels. Only mono and stereo files are allowed, and the sample
|
|
||||||
rate must be 8, 11.025, 12, 16, 18.9, 22.05, 24, 28, 32, 36, 37.8,
|
|
||||||
44.1, 48, 56, 64, 72, 75.6, 88.2, 96, 112, 128, 144, 151.2, 176.4,
|
|
||||||
192, 224, 256, 288, 302.4, 352.8, 384, 448, 512, 576, or 604.8 kHz.
|
|
||||||
|
|
||||||
**\--scan-replay-gain**
|
|
||||||
: Like \--add-replay-gain, but only analyzes the files rather than
|
|
||||||
writing them to the tags.
|
|
||||||
|
|
||||||
**\--remove-replay-gain**
|
|
||||||
: Removes the ReplayGain tags.
|
|
||||||
|
|
||||||
**\--add-seekpoint={***\#***\|***X***\|***\#x***\|***\#s***}**
|
|
||||||
: Add seek points to a SEEKTABLE block. Using \#, a seek point at that
|
|
||||||
sample number is added. Using X, a placeholder point is added at the
|
|
||||||
end of a the table. Using \#x, \# evenly spaced seek points will be
|
|
||||||
added, the first being at sample 0. Using \#s, a seekpoint will be
|
|
||||||
added every \# seconds (# does not have to be a whole number; it can
|
|
||||||
be, for example, 9.5, meaning a seekpoint every 9.5 seconds). If no
|
|
||||||
SEEKTABLE block exists, one will be created. If one already exists,
|
|
||||||
points will be added to the existing table, and any duplicates will
|
|
||||||
be turned into placeholder points. You may use many \--add-seekpoint
|
|
||||||
options; the resulting SEEKTABLE will be the unique-ified union of
|
|
||||||
all such values. Example: \--add-seekpoint=100x \--add-seekpoint=3.5s
|
|
||||||
will add 100 evenly spaced seekpoints and a seekpoint every 3.5
|
|
||||||
seconds.
|
|
||||||
|
|
||||||
**\--add-padding=length**
|
|
||||||
: Add a padding block of the given length (in bytes). The overall
|
|
||||||
length of the new block will be 4 + length; the extra 4 bytes is for
|
|
||||||
the metadata block header.
|
|
||||||
|
|
||||||
# MAJOR OPERATIONS
|
|
||||||
|
|
||||||
**\--list**
|
|
||||||
: List the contents of one or more metadata blocks to stdout. By
|
|
||||||
default, all metadata blocks are listed in text format. Use the
|
|
||||||
options **\--block-number**, **\--block-type** or
|
|
||||||
**\--except-block-type** to change this behavior.
|
|
||||||
|
|
||||||
**\--remove**
|
|
||||||
: Remove one or more metadata blocks from the metadata. Use the options
|
|
||||||
**\--block-number**, **\--block-type** or **\--except-block-type**
|
|
||||||
to specify which blocks should be removed. Note that if both
|
|
||||||
\--block-number and \--[except-]block-type are specified, the result
|
|
||||||
is the logical AND of both arguments. Unless \--dont-use-padding
|
|
||||||
is specified, the blocks will be replaced with padding. You may not
|
|
||||||
remove the STREAMINFO block.
|
|
||||||
|
|
||||||
**\--block-number=#\[,#\[...\]\]**
|
|
||||||
: An optional comma-separated list of block numbers to display. The
|
|
||||||
first block, the STREAMINFO block, is block 0.
|
|
||||||
|
|
||||||
**\--block-type=type\[,type\[...\]\]**
|
|
||||||
|
|
||||||
**\--except-block-type=type\[,type\[...\]\]**
|
|
||||||
: An optional comma-separated list of block types to be included or
|
|
||||||
ignored with this option. Use only one of \--block-type or
|
|
||||||
\--except-block-type. The valid block types are: STREAMINFO, PADDING,
|
|
||||||
APPLICATION, SEEKTABLE, VORBIS_COMMENT, PICTURE. You may narrow down
|
|
||||||
the types of APPLICATION blocks selected by appending APPLICATION
|
|
||||||
with a colon and the ID of the APPLICATION block in either ASCII
|
|
||||||
or hexadecimal representation. E.g. APPLICATION:abcd for the
|
|
||||||
APPLICATION block(s) whose textual representation of the 4-byte ID
|
|
||||||
is "abcd" or APPLICATION:0xXXXXXXXX for the APPLICATION block(s)
|
|
||||||
whose hexadecimal big- endian representation of the 4-byte ID
|
|
||||||
is "0xXXXXXXXX". For the example "abcd" above the hexadecimal
|
|
||||||
equivalalent is 0x61626364
|
|
||||||
|
|
||||||
**\--application-data-format=hexdump\|text**
|
|
||||||
: If the application block you are displaying contains binary data but
|
|
||||||
your \--data-format=text, you can display a hex dump of the
|
|
||||||
application data contents instead using
|
|
||||||
\--application-data-format=hexdump.
|
|
||||||
|
|
||||||
**\--data-format=binary\|binary-headerless\|text**
|
|
||||||
: For use with --list. By default a human-readable text
|
|
||||||
representation of the data is isplayed. You may specify
|
|
||||||
--data-format=binary to dump the raw binary form of each metadata
|
|
||||||
block. Specify --data-format=binary-headerless to omit output of
|
|
||||||
metadata block headers, including the id of APPLICATION metadata
|
|
||||||
blocks.
|
|
||||||
|
|
||||||
**\--append**
|
|
||||||
: Insert a metadata block from a file. This must be a binary block as
|
|
||||||
exported with --list --data-format=binary. The insertion point is
|
|
||||||
defined with --block-number=#. The new block will be added after the
|
|
||||||
given block number. This prevents the illegal insertion of a block
|
|
||||||
before the first STREAMINFO block. You may not --append another
|
|
||||||
STREAMINFO block. It is possible to copy a metadata block from one
|
|
||||||
file to another with this option. For example use
|
|
||||||
`metaflac --list --data-format=binary --block-number=6 file.flac > block`
|
|
||||||
to export the block, and then import it with
|
|
||||||
`metaflac --append anotherfile.flac < block`
|
|
||||||
|
|
||||||
**\--remove-all**
|
|
||||||
: Remove all metadata blocks (except the STREAMINFO block) from the
|
|
||||||
metadata. Unless \--dont-use-padding is specified, the blocks will be
|
|
||||||
replaced with padding.
|
|
||||||
|
|
||||||
**\--merge-padding**
|
|
||||||
: Merge adjacent PADDING blocks into single blocks.
|
|
||||||
|
|
||||||
**\--sort-padding**
|
|
||||||
: Move all PADDING blocks to the end of the metadata and merge them
|
|
||||||
into a single block.
|
|
||||||
|
|
||||||
# SEE ALSO
|
|
||||||
|
|
||||||
**flac(1)**
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
if(MSVC)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES rt)
|
|
||||||
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
|
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
add_definitions(-DFLAC__SYS_DARWIN)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(benchmark_residual benchmark_residual.c util.c)
|
|
||||||
target_include_directories(benchmark_residual PRIVATE
|
|
||||||
"$<TARGET_PROPERTY:FLAC,SOURCE_DIR>/include")
|
|
||||||
target_link_libraries(benchmark_residual
|
|
||||||
FLAC
|
|
||||||
$<$<BOOL:${HAVE_CLOCK_GETTIME}>:rt>)
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
# FLAC - Free Lossless Audio Codec
|
|
||||||
# Copyright (C) 2015-2023 Xiph.Org Foundation
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# - Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# - Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
|
||||||
# documentation and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
# contributors may be used to endorse or promote products derived from
|
|
||||||
# this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/libFLAC/include
|
|
||||||
|
|
||||||
noinst_HEADERS = util.h
|
|
||||||
|
|
||||||
noinst_PROGRAMS = benchmark_residual
|
|
||||||
|
|
||||||
benchmark_residual_SOURCES = benchmark_residual.c util.c
|
|
||||||
|
|
||||||
benchmark_residual_LDADD = @LIB_CLOCK_GETTIME@
|
|
||||||
|
|
||||||
EXTRA_DIST = CMakeLists.txt
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
||||||
/* libFLAC - Free Lossless Audio Codec library
|
|
||||||
* Copyright (C) 2000-2009 Josh Coalson
|
|
||||||
* Copyright (C) 2011-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "FLAC/ordinals.h"
|
|
||||||
#include "share/compat.h"
|
|
||||||
#include "private/bitmath.h"
|
|
||||||
#include "private/fixed.h"
|
|
||||||
#include "private/macros.h"
|
|
||||||
#include "FLAC/assert.h"
|
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
static void FLAC__fixed_compute_residual_shift(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[])
|
|
||||||
{
|
|
||||||
const int idata_len = (int) data_len;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
switch(order) {
|
|
||||||
case 0:
|
|
||||||
FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
|
|
||||||
memcpy(residual, data, sizeof(residual[0])*data_len);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - data[i-1];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - (data[i-1] << 1) + data[i-2];
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) - data[i-3];
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - ((data[i-1]+data[i-3])<<2) + ((data[i-2]<<2) + (data[i-2]<<1)) + data[i-4];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
FLAC__ASSERT(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void FLAC__fixed_compute_residual_mult(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[])
|
|
||||||
{
|
|
||||||
const int idata_len = (int)data_len;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
switch(order) {
|
|
||||||
case 0:
|
|
||||||
FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
|
|
||||||
memcpy(residual, data, sizeof(residual[0])*data_len);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - data[i-1];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - 2*data[i-1] + data[i-2];
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3];
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
for(i = 0; i < idata_len; i++)
|
|
||||||
residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
FLAC__ASSERT(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static FLAC__int32 data [200000] ;
|
|
||||||
static FLAC__int32 residual [200000] ;
|
|
||||||
|
|
||||||
static unsigned bench_order = 0 ;
|
|
||||||
|
|
||||||
static void
|
|
||||||
bench_shift (void)
|
|
||||||
{ FLAC__fixed_compute_residual_shift (data, ARRAY_LEN (data), bench_order, residual) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
bench_mult (void)
|
|
||||||
{ FLAC__fixed_compute_residual_mult (data, ARRAY_LEN (data), bench_order, residual) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{ bench_stats stats ;
|
|
||||||
|
|
||||||
puts ("") ;
|
|
||||||
|
|
||||||
for (bench_order = 2 ; bench_order <= 4 ; bench_order ++) {
|
|
||||||
memset (&stats, 0, sizeof (stats)) ;
|
|
||||||
stats.testfunc = bench_shift ;
|
|
||||||
stats.run_count = 100 ;
|
|
||||||
stats.loop_count = 10 ;
|
|
||||||
|
|
||||||
benchmark_stats (&stats) ;
|
|
||||||
printf ("shift order %u : %f %f %f %f\n", bench_order, stats.min_time, stats.median_time, stats.mean_time, stats.max_time) ;
|
|
||||||
|
|
||||||
memset (&stats, 0, sizeof (stats)) ;
|
|
||||||
stats.testfunc = bench_mult ;
|
|
||||||
stats.run_count = 100 ;
|
|
||||||
stats.loop_count = 10 ;
|
|
||||||
|
|
||||||
benchmark_stats (&stats) ;
|
|
||||||
printf ("mult order %u : %f %f %f %f\n\n", bench_order, stats.min_time, stats.median_time, stats.mean_time, stats.max_time) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0 ;
|
|
||||||
}
|
|
||||||
|
|
@ -1,205 +0,0 @@
|
||||||
/* FLAC - Free Lossless Audio Codec
|
|
||||||
* Copyright (C) 2015-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#if defined _WIN32
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
static double
|
|
||||||
counter_diff (const LARGE_INTEGER * start, const LARGE_INTEGER * end)
|
|
||||||
{
|
|
||||||
LARGE_INTEGER diff, freq;
|
|
||||||
|
|
||||||
QueryPerformanceFrequency(&freq);
|
|
||||||
diff.QuadPart = end->QuadPart - start->QuadPart;
|
|
||||||
|
|
||||||
return (double)diff.QuadPart/(double)freq.QuadPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
benchmark_function (void (*testfunc) (void), unsigned count)
|
|
||||||
{
|
|
||||||
LARGE_INTEGER start, end;
|
|
||||||
unsigned k;
|
|
||||||
|
|
||||||
QueryPerformanceCounter (&start) ;
|
|
||||||
|
|
||||||
for (k = 0 ; k < count ; k++)
|
|
||||||
testfunc();
|
|
||||||
|
|
||||||
QueryPerformanceCounter (&end) ;
|
|
||||||
|
|
||||||
return counter_diff (&start, &end) / count ;
|
|
||||||
} /* benchmark_function */
|
|
||||||
|
|
||||||
#elif defined FLAC__SYS_DARWIN
|
|
||||||
|
|
||||||
#include <mach/mach_time.h>
|
|
||||||
|
|
||||||
static double
|
|
||||||
counter_diff (const uint64_t * start, const uint64_t * end)
|
|
||||||
{
|
|
||||||
mach_timebase_info_data_t t_info;
|
|
||||||
mach_timebase_info(&t_info);
|
|
||||||
uint64_t duration = *end - *start;
|
|
||||||
|
|
||||||
return duration * ((double)t_info.numer/(double)t_info.denom);
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
benchmark_function (void (*testfunc) (void), unsigned count)
|
|
||||||
{
|
|
||||||
uint64_t start, end;
|
|
||||||
unsigned k;
|
|
||||||
|
|
||||||
start = mach_absolute_time();
|
|
||||||
|
|
||||||
for (k = 0 ; k < count ; k++)
|
|
||||||
testfunc();
|
|
||||||
|
|
||||||
end = mach_absolute_time();
|
|
||||||
|
|
||||||
return counter_diff (&start, &end) / count ;
|
|
||||||
} /* benchmark_function */
|
|
||||||
|
|
||||||
#elif defined HAVE_CLOCK_GETTIME
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
static double
|
|
||||||
timespec_diff (const struct timespec * start, const struct timespec * end)
|
|
||||||
{ struct timespec diff;
|
|
||||||
|
|
||||||
if (end->tv_nsec - start->tv_nsec < 0)
|
|
||||||
{ diff.tv_sec = end->tv_sec - start->tv_sec - 1 ;
|
|
||||||
diff.tv_nsec = 1000000000 + end->tv_nsec - start->tv_nsec ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ diff.tv_sec = end->tv_sec - start->tv_sec ;
|
|
||||||
diff.tv_nsec = end->tv_nsec-start->tv_nsec ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
return diff.tv_sec + 1e-9 * diff.tv_nsec ;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
benchmark_function (void (*testfunc) (void), unsigned count)
|
|
||||||
{ struct timespec start, end;
|
|
||||||
unsigned k ;
|
|
||||||
|
|
||||||
clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start) ;
|
|
||||||
|
|
||||||
for (k = 0 ; k < count ; k++)
|
|
||||||
testfunc () ;
|
|
||||||
|
|
||||||
clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &end) ;
|
|
||||||
|
|
||||||
return timespec_diff (&start, &end) / count ;
|
|
||||||
} /* benchmark_function */
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
static double
|
|
||||||
timeval_diff (const struct timeval * start, const struct timeval * end)
|
|
||||||
{ struct timeval diff;
|
|
||||||
|
|
||||||
if (end->tv_usec - start->tv_usec < 0)
|
|
||||||
{ diff.tv_sec = end->tv_sec - start->tv_sec - 1 ;
|
|
||||||
diff.tv_usec = 1000000 + end->tv_usec - start->tv_usec ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ diff.tv_sec = end->tv_sec - start->tv_sec ;
|
|
||||||
diff.tv_usec = end->tv_usec-start->tv_usec ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
return diff.tv_sec + 1e-6 * diff.tv_usec ;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
benchmark_function (void (*testfunc) (void), unsigned count)
|
|
||||||
{ struct timeval start, end;
|
|
||||||
unsigned k ;
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
|
|
||||||
for (k = 0 ; k < count ; k++)
|
|
||||||
testfunc () ;
|
|
||||||
|
|
||||||
gettimeofday(&end, NULL);
|
|
||||||
|
|
||||||
return timeval_diff (&start, &end) / count ;
|
|
||||||
} /* benchmark_function */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
|
||||||
double_cmp (const void * a, const void * b)
|
|
||||||
{ const double * pa = (double *) a ;
|
|
||||||
const double * pb = (double *) b ;
|
|
||||||
return pa [0] < pb [0] ;
|
|
||||||
} /* double_cmp */
|
|
||||||
|
|
||||||
void
|
|
||||||
benchmark_stats (bench_stats * stats)
|
|
||||||
{ double sum, times [stats->run_count] ;
|
|
||||||
unsigned k ;
|
|
||||||
|
|
||||||
for (k = 0 ; k < stats->run_count ; k++)
|
|
||||||
times [k] = benchmark_function (stats->testfunc, stats->loop_count) ;
|
|
||||||
|
|
||||||
qsort (times, stats->run_count, sizeof (times [0]), double_cmp) ;
|
|
||||||
|
|
||||||
sum = 0.0 ;
|
|
||||||
stats->min_time = stats->max_time = times [0] ;
|
|
||||||
for (k = 0 ; k < stats->run_count ; k++)
|
|
||||||
{ stats->min_time = stats->min_time < times [k] ? stats->min_time : times [k] ;
|
|
||||||
stats->max_time = stats->max_time > times [k] ? stats->max_time : times [k] ;
|
|
||||||
sum += times [k] ;
|
|
||||||
}
|
|
||||||
stats->mean_time = sum / stats->run_count ;
|
|
||||||
if (stats->run_count & 1)
|
|
||||||
stats->median_time = times [(stats->run_count + 1) / 2] ;
|
|
||||||
else
|
|
||||||
stats->median_time = 0.5 * (times [stats->run_count / 2] + times [(stats->run_count / 2) + 1]) ;
|
|
||||||
|
|
||||||
return ;
|
|
||||||
} /* benchmark_stats */
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/* FLAC - Free Lossless Audio Codec
|
|
||||||
* Copyright (C) 2015-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ARRAY_LEN(x) ((sizeof (x) / sizeof (x [0])))
|
|
||||||
|
|
||||||
typedef struct bench_stats
|
|
||||||
{ void (*testfunc) (void) ;
|
|
||||||
unsigned run_count ;
|
|
||||||
unsigned loop_count ;
|
|
||||||
double min_time, mean_time, median_time, max_time ;
|
|
||||||
} bench_stats ;
|
|
||||||
|
|
||||||
double benchmark_function (void (*testfunc) (void), unsigned count) ;
|
|
||||||
|
|
||||||
void benchmark_stats (bench_stats * stats) ;
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
# FLAC - Free Lossless Audio Codec
|
|
||||||
# Copyright (C) 2019-2023 Xiph.Org Foundation
|
|
||||||
#
|
|
||||||
# This file is part the FLAC project. FLAC is comprised of several
|
|
||||||
# components distributed under different licenses. The codec libraries
|
|
||||||
# are distributed under Xiph.Org's BSD-like license (see the file
|
|
||||||
# COPYING.Xiph in this distribution). All other programs, libraries, and
|
|
||||||
# plugins are distributed under the GPL (see COPYING.GPL). The documentation
|
|
||||||
# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
|
|
||||||
# FLAC distribution contains at the top the terms under which it may be
|
|
||||||
# distributed.
|
|
||||||
#
|
|
||||||
# Since this particular file is relevant to all components of FLAC,
|
|
||||||
# it may be distributed under the Xiph.Org license, which is the least
|
|
||||||
# restrictive of those mentioned above. See the file COPYING.Xiph in this
|
|
||||||
# distribution.
|
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/oss-fuzz
|
|
||||||
|
|
||||||
AM_CFLAGS = ${LIB_FUZZING_ENGINE}
|
|
||||||
AM_CXXFLAGS = -std=c++11 $(LIB_FUZZING_ENGINE)
|
|
||||||
LDADD = $(flac_libs)
|
|
||||||
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
fuzzer_encoder.dict \
|
|
||||||
common.h \
|
|
||||||
Readme.md \
|
|
||||||
fuzzing/datasource/datasource.hpp \
|
|
||||||
fuzzing/datasource/id.hpp \
|
|
||||||
fuzzing/exception.hpp \
|
|
||||||
fuzzing/memory.hpp \
|
|
||||||
fuzzing/types.hpp
|
|
||||||
|
|
||||||
noinst_PROGRAMS =
|
|
||||||
|
|
||||||
if USE_OSSFUZZERS
|
|
||||||
noinst_PROGRAMS += fuzzer_encoder fuzzer_encoder_v2 fuzzer_decoder fuzzer_seek fuzzer_metadata fuzzer_reencoder fuzzer_tool_flac fuzzer_tool_metaflac
|
|
||||||
endif
|
|
||||||
|
|
||||||
fuzzer_encoder_SOURCES = encoder.cc
|
|
||||||
fuzzer_encoder_v2_SOURCES = encoder_v2.cc
|
|
||||||
fuzzer_decoder_SOURCES = decoder.cc
|
|
||||||
fuzzer_seek_SOURCES = seek.cc
|
|
||||||
fuzzer_metadata_SOURCES = metadata.cc
|
|
||||||
fuzzer_reencoder_SOURCES = reencoder.cc
|
|
||||||
fuzzer_tool_flac_SOURCES = ${flac_SOURCES} empty.cc tool_flac.c # empty.cc is to force use of C++ linker, which is mandated by oss-fuzz
|
|
||||||
fuzzer_tool_flac_LDADD = \
|
|
||||||
$(top_builddir)/src/share/utf8/libutf8.la \
|
|
||||||
$(top_builddir)/src/share/grabbag/libgrabbag.la \
|
|
||||||
$(top_builddir)/src/share/getopt/libgetopt.la \
|
|
||||||
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
|
|
||||||
$(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \
|
|
||||||
$(top_builddir)/src/libFLAC/libFLAC.la \
|
|
||||||
@LTLIBICONV@ \
|
|
||||||
-lm
|
|
||||||
fuzzer_tool_metaflac_SOURCES = ${metaflac_SOURCES} empty.cc tool_metaflac.c # empty.cc is to force use of C++ linker, which is mandated by oss-fuzz
|
|
||||||
fuzzer_tool_metaflac_LDADD = \
|
|
||||||
$(top_builddir)/src/share/utf8/libutf8.la \
|
|
||||||
$(top_builddir)/src/share/grabbag/libgrabbag.la \
|
|
||||||
$(top_builddir)/src/share/getopt/libgetopt.la \
|
|
||||||
$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
|
|
||||||
$(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \
|
|
||||||
$(top_builddir)/src/libFLAC/libFLAC.la \
|
|
||||||
@LTLIBICONV@ \
|
|
||||||
-lm
|
|
||||||
|
|
||||||
flac_libs = \
|
|
||||||
$(top_builddir)/src/libFLAC/libFLAC-static.la \
|
|
||||||
$(top_builddir)/src/libFLAC++/libFLAC++-static.la \
|
|
||||||
@OGG_LIBS@ \
|
|
||||||
-lm
|
|
||||||
|
|
||||||
flac_SOURCES = \
|
|
||||||
${top_builddir}/src/flac/analyze.c \
|
|
||||||
${top_builddir}/src/flac/decode.c \
|
|
||||||
${top_builddir}/src/flac/encode.c \
|
|
||||||
${top_builddir}/src/flac/foreign_metadata.c \
|
|
||||||
${top_builddir}/src/flac/local_string_utils.c \
|
|
||||||
${top_builddir}/src/flac/utils.c \
|
|
||||||
${top_builddir}/src/flac/vorbiscomment.c \
|
|
||||||
${top_builddir}/src/flac/analyze.h \
|
|
||||||
${top_builddir}/src/flac/decode.h \
|
|
||||||
${top_builddir}/src/flac/encode.h \
|
|
||||||
${top_builddir}/src/flac/foreign_metadata.h \
|
|
||||||
${top_builddir}/src/flac/local_string_utils.h \
|
|
||||||
${top_builddir}/src/flac/utils.h \
|
|
||||||
${top_builddir}/src/flac/vorbiscomment.h
|
|
||||||
|
|
||||||
metaflac_SOURCES = \
|
|
||||||
${top_builddir}/src/metaflac/operations.c \
|
|
||||||
${top_builddir}/src/metaflac/operations_shorthand_cuesheet.c \
|
|
||||||
${top_builddir}/src/metaflac/operations_shorthand_picture.c \
|
|
||||||
${top_builddir}/src/metaflac/operations_shorthand_seektable.c \
|
|
||||||
${top_builddir}/src/metaflac/operations_shorthand_streaminfo.c \
|
|
||||||
${top_builddir}/src/metaflac/operations_shorthand_vorbiscomment.c \
|
|
||||||
${top_builddir}/src/metaflac/options.c \
|
|
||||||
${top_builddir}/src/metaflac/usage.c \
|
|
||||||
${top_builddir}/src/metaflac/utils.c \
|
|
||||||
${top_builddir}/src/metaflac/operations.h \
|
|
||||||
${top_builddir}/src/metaflac/operations_shorthand.h \
|
|
||||||
${top_builddir}/src/metaflac/options.h \
|
|
||||||
${top_builddir}/src/metaflac/usage.h \
|
|
||||||
${top_builddir}/src/metaflac/utils.h
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
Fuzzers fuzzer_decoder.cc and fuzzer_encoder.cc were taken from
|
|
||||||
|
|
||||||
https://github.com/guidovranken/flac-fuzzers
|
|
||||||
|
|
||||||
The header files in the directory fuzzing and below were taken from:
|
|
||||||
|
|
||||||
https://github.com/guidovranken/fuzzing-headers.git
|
|
||||||
|
|
||||||
Some minor modifications were made to make them build with the default C++
|
|
||||||
warning flags.
|
|
||||||
|
|
||||||
The code mentioned above, contributed by Guido Vranken, is licensed under
|
|
||||||
the MIT license. See the files themselves for details
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
extern int alloc_check_threshold, alloc_check_counter;
|
|
||||||
int alloc_check_threshold = INT32_MAX, alloc_check_counter = 0;
|
|
||||||
|
|
@ -1,408 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include <fuzzing/datasource/datasource.hpp>
|
|
||||||
#include <fuzzing/memory.hpp>
|
|
||||||
|
|
||||||
#include "FLAC++/decoder.h"
|
|
||||||
#include "FLAC++/metadata.h"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
template <> FLAC__MetadataType fuzzing::datasource::Base::Get<FLAC__MetadataType>(const uint64_t id) {
|
|
||||||
(void)id;
|
|
||||||
switch ( Get<uint8_t>() ) {
|
|
||||||
case 0:
|
|
||||||
return FLAC__METADATA_TYPE_STREAMINFO;
|
|
||||||
case 1:
|
|
||||||
return FLAC__METADATA_TYPE_PADDING;
|
|
||||||
case 2:
|
|
||||||
return FLAC__METADATA_TYPE_APPLICATION;
|
|
||||||
case 3:
|
|
||||||
return FLAC__METADATA_TYPE_SEEKTABLE;
|
|
||||||
case 4:
|
|
||||||
return FLAC__METADATA_TYPE_VORBIS_COMMENT;
|
|
||||||
case 5:
|
|
||||||
return FLAC__METADATA_TYPE_CUESHEET;
|
|
||||||
case 6:
|
|
||||||
return FLAC__METADATA_TYPE_PICTURE;
|
|
||||||
case 7:
|
|
||||||
return FLAC__METADATA_TYPE_UNDEFINED;
|
|
||||||
case 8:
|
|
||||||
return FLAC__MAX_METADATA_TYPE;
|
|
||||||
default:
|
|
||||||
return FLAC__METADATA_TYPE_STREAMINFO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace FLAC {
|
|
||||||
namespace Decoder {
|
|
||||||
class FuzzerStream : public Stream {
|
|
||||||
private:
|
|
||||||
fuzzing::datasource::Datasource& ds;
|
|
||||||
public:
|
|
||||||
FuzzerStream(fuzzing::datasource::Datasource& dsrc) :
|
|
||||||
Stream(), ds(dsrc) { }
|
|
||||||
|
|
||||||
::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) override {
|
|
||||||
try {
|
|
||||||
const size_t maxCopySize = *bytes;
|
|
||||||
|
|
||||||
if ( maxCopySize > 0 ) {
|
|
||||||
/* memset just to test if this overwrites anything, and triggers ASAN */
|
|
||||||
memset(buffer, 0, maxCopySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto data = ds.GetData(0);
|
|
||||||
const auto dataSize = data.size();
|
|
||||||
const auto copySize = std::min(maxCopySize, dataSize);
|
|
||||||
|
|
||||||
if ( copySize > 0 ) {
|
|
||||||
memcpy(buffer, data.data(), copySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
*bytes = copySize;
|
|
||||||
|
|
||||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
|
||||||
} catch ( ... ) {
|
|
||||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) override {
|
|
||||||
{
|
|
||||||
fuzzing::memory::memory_test(&(frame->header), sizeof(frame->header));
|
|
||||||
fuzzing::memory::memory_test(&(frame->footer), sizeof(frame->footer));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const auto numChannels = get_channels();
|
|
||||||
const size_t bytesPerChannel = frame->header.blocksize * sizeof(FLAC__int32);
|
|
||||||
for (size_t i = 0; i < numChannels; i++) {
|
|
||||||
fuzzing::memory::memory_test(buffer[i], bytesPerChannel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ( ds.Get<bool>() == true ) {
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
||||||
}
|
|
||||||
} catch ( ... ) { }
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void error_callback(::FLAC__StreamDecoderErrorStatus status) override {
|
|
||||||
fuzzing::memory::memory_test(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void metadata_callback(const ::FLAC__StreamMetadata *metadata) override {
|
|
||||||
Metadata::Prototype * cloned_object = nullptr;
|
|
||||||
fuzzing::memory::memory_test(metadata->type);
|
|
||||||
fuzzing::memory::memory_test(metadata->is_last);
|
|
||||||
fuzzing::memory::memory_test(metadata->length);
|
|
||||||
fuzzing::memory::memory_test(metadata->data);
|
|
||||||
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
|
|
||||||
cloned_object = new Metadata::StreamInfo(metadata);
|
|
||||||
else if (metadata->type == FLAC__METADATA_TYPE_PADDING)
|
|
||||||
cloned_object = new Metadata::Padding(metadata);
|
|
||||||
else if (metadata->type == FLAC__METADATA_TYPE_APPLICATION)
|
|
||||||
cloned_object = new Metadata::Application(metadata);
|
|
||||||
else if (metadata->type == FLAC__METADATA_TYPE_SEEKTABLE)
|
|
||||||
cloned_object = new Metadata::SeekTable(metadata);
|
|
||||||
else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
|
|
||||||
cloned_object = new Metadata::VorbisComment(metadata);
|
|
||||||
else if (metadata->type == FLAC__METADATA_TYPE_CUESHEET)
|
|
||||||
cloned_object = new Metadata::CueSheet(metadata);
|
|
||||||
else if (metadata->type == FLAC__METADATA_TYPE_PICTURE)
|
|
||||||
cloned_object = new Metadata::Picture(metadata);
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
if (0 != cloned_object && *cloned_object == *metadata && cloned_object->is_valid()) {
|
|
||||||
if (cloned_object->get_type() == FLAC__METADATA_TYPE_SEEKTABLE)
|
|
||||||
dynamic_cast<Metadata::SeekTable *>(cloned_object)->is_legal();
|
|
||||||
if (cloned_object->get_type() == FLAC__METADATA_TYPE_PICTURE)
|
|
||||||
dynamic_cast<Metadata::Picture *>(cloned_object)->is_legal(NULL);
|
|
||||||
if (cloned_object->get_type() == FLAC__METADATA_TYPE_CUESHEET)
|
|
||||||
dynamic_cast<Metadata::CueSheet *>(cloned_object)->is_legal(true,NULL);
|
|
||||||
}
|
|
||||||
delete cloned_object;
|
|
||||||
}
|
|
||||||
|
|
||||||
::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) override {
|
|
||||||
fuzzing::memory::memory_test(absolute_byte_offset);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ( ds.Get<bool>() == true ) {
|
|
||||||
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
|
||||||
} else {
|
|
||||||
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
} catch ( ... ) {
|
|
||||||
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) override {
|
|
||||||
fuzzing::memory::memory_test(*absolute_byte_offset);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ( ds.Get<bool>() == true ) {
|
|
||||||
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
|
||||||
} else {
|
|
||||||
return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
} catch ( ... ) {
|
|
||||||
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) override {
|
|
||||||
fuzzing::memory::memory_test(*stream_length);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ( ds.Get<bool>() == true ) {
|
|
||||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
|
|
||||||
} else {
|
|
||||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
} catch ( ... ) {
|
|
||||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
||||||
fuzzing::datasource::Datasource ds(data, size);
|
|
||||||
FLAC::Decoder::FuzzerStream decoder(ds);
|
|
||||||
bool use_ogg = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
use_ogg = false;
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_ogg_serial_number\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_ogg_serial_number(ds.Get<long>());
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_md5_checking\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_md5_checking(ds.Get<bool>());
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_metadata_respond\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_metadata_respond(ds.Get<::FLAC__MetadataType>());
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
const auto idVector = ds.GetData(0);
|
|
||||||
unsigned char id[4];
|
|
||||||
if ( idVector.size() >= sizeof(id) ) {
|
|
||||||
memcpy(id, idVector.data(), sizeof(id));
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_metadata_respond_application\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_metadata_respond_application(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_metadata_respond_all\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_metadata_respond_all();
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_metadata_ignore\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_metadata_ignore(ds.Get<::FLAC__MetadataType>());
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
const auto idVector = ds.GetData(0);
|
|
||||||
unsigned char id[4];
|
|
||||||
if ( idVector.size() >= sizeof(id) ) {
|
|
||||||
memcpy(id, idVector.data(), sizeof(id));
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_metadata_ignore_application\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_metadata_ignore_application(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("set_metadata_ignore_all\n");
|
|
||||||
#endif
|
|
||||||
decoder.set_metadata_ignore_all();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
::FLAC__StreamDecoderInitStatus ret;
|
|
||||||
if ( !use_ogg ) {
|
|
||||||
ret = decoder.init();
|
|
||||||
} else {
|
|
||||||
ret = decoder.init_ogg();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ret != FLAC__STREAM_DECODER_INIT_STATUS_OK ) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( ds.Get<bool>() ) {
|
|
||||||
switch ( ds.Get<uint8_t>() ) {
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("flush\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.flush();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("reset\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.reset();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("process_single\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.process_single();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("process_until_end_of_metadata\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.process_until_end_of_metadata();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("process_until_end_of_stream\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.process_until_end_of_stream();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("skip_single_frame\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.skip_single_frame();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("seek_absolute\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.seek_absolute(ds.Get<uint64_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("get_md5_checking\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.get_md5_checking();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("get_total_samples\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.get_total_samples();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("get_channels\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.get_channels();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("get_bits_per_sample\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.get_bits_per_sample();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("get_sample_rate\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.get_sample_rate();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
{
|
|
||||||
#ifdef FUZZER_DEBUG
|
|
||||||
printf("get_blocksize\n");
|
|
||||||
#endif
|
|
||||||
const bool res = decoder.get_blocksize();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch ( ... ) { }
|
|
||||||
|
|
||||||
end:
|
|
||||||
{
|
|
||||||
const bool res = decoder.finish();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,257 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include <fuzzing/datasource/datasource.hpp>
|
|
||||||
#include <fuzzing/memory.hpp>
|
|
||||||
|
|
||||||
#include "FLAC++/encoder.h"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
namespace FLAC {
|
|
||||||
namespace Encoder {
|
|
||||||
class FuzzerStream : public Stream {
|
|
||||||
private:
|
|
||||||
// fuzzing::datasource::Datasource& ds;
|
|
||||||
public:
|
|
||||||
FuzzerStream(fuzzing::datasource::Datasource&) :
|
|
||||||
Stream() { }
|
|
||||||
|
|
||||||
::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t /* samples */, uint32_t /* current_frame */) override {
|
|
||||||
fuzzing::memory::memory_test(buffer, bytes);
|
|
||||||
#if 0
|
|
||||||
try {
|
|
||||||
if ( ds.Get<bool>() == true ) {
|
|
||||||
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
|
|
||||||
}
|
|
||||||
} catch ( ... ) { }
|
|
||||||
#endif
|
|
||||||
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
||||||
fuzzing::datasource::Datasource ds(data, size);
|
|
||||||
FLAC::Encoder::FuzzerStream encoder(ds);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const int channels = ds.Get<uint8_t>();
|
|
||||||
const int bps = ds.Get<uint8_t>();
|
|
||||||
encoder.set_channels(channels);
|
|
||||||
encoder.set_bits_per_sample(bps);
|
|
||||||
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_streamable_subset(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_ogg_serial_number(ds.Get<long>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_verify(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_compression_level(ds.Get<uint8_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_do_exhaustive_model_search(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_do_mid_side_stereo(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_loose_mid_side_stereo(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const auto s = ds.Get<std::string>();
|
|
||||||
const bool res = encoder.set_apodization(s.data());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_max_lpc_order(ds.Get<uint8_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_qlp_coeff_precision(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_do_qlp_coeff_prec_search(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_do_escape_coding(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_min_residual_partition_order(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_max_residual_partition_order(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_rice_parameter_search_dist(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_total_samples_estimate(ds.Get<uint64_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_blocksize(ds.Get<uint16_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_limit_min_bitrate(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_sample_rate(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( size > 2 * 65535 * 4 ) {
|
|
||||||
/* With large inputs and expensive options enabled, the fuzzer can get *really* slow.
|
|
||||||
* Some combinations can make the fuzzer timeout (>60 seconds). However, while combining
|
|
||||||
* options makes the fuzzer slower, most options do not expose new code when combined.
|
|
||||||
* Therefore, combining slow options is disabled for large inputs. Any input containing
|
|
||||||
* more than 65536 * 2 samples of 32 bits each (max blocksize, stereo) is considered large
|
|
||||||
*/
|
|
||||||
encoder.set_do_qlp_coeff_prec_search(false);
|
|
||||||
encoder.set_do_exhaustive_model_search(false);
|
|
||||||
}
|
|
||||||
if ( size > 2 * 4096 * 4 + 250 ) {
|
|
||||||
/* With subdivide_tukey in the mix testing apodizations can get really expensive. Therefore
|
|
||||||
* this is disabled for inputs of more than one whole stereo block of 32-bit inputs plus a
|
|
||||||
* bit of overhead */
|
|
||||||
encoder.set_apodization("");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
::FLAC__StreamEncoderInitStatus ret;
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
ret = encoder.init();
|
|
||||||
} else {
|
|
||||||
ret = encoder.init_ogg();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK ) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* These sets must fail, because encoder is already initialized */
|
|
||||||
{
|
|
||||||
bool res = false;
|
|
||||||
res = res || encoder.set_streamable_subset(true);
|
|
||||||
res = res || encoder.set_ogg_serial_number(0);
|
|
||||||
res = res || encoder.set_verify(true);
|
|
||||||
res = res || encoder.set_compression_level(0);
|
|
||||||
res = res || encoder.set_do_exhaustive_model_search(true);
|
|
||||||
res = res || encoder.set_do_mid_side_stereo(true);
|
|
||||||
res = res || encoder.set_loose_mid_side_stereo(true);
|
|
||||||
res = res || encoder.set_apodization("test");
|
|
||||||
res = res || encoder.set_max_lpc_order(0);
|
|
||||||
res = res || encoder.set_qlp_coeff_precision(0);
|
|
||||||
res = res || encoder.set_do_qlp_coeff_prec_search(true);
|
|
||||||
res = res || encoder.set_do_escape_coding(true);
|
|
||||||
res = res || encoder.set_min_residual_partition_order(0);
|
|
||||||
res = res || encoder.set_max_residual_partition_order(0);
|
|
||||||
res = res || encoder.set_rice_parameter_search_dist(0);
|
|
||||||
res = res || encoder.set_total_samples_estimate(0);
|
|
||||||
res = res || encoder.set_channels(channels);
|
|
||||||
res = res || encoder.set_bits_per_sample(16);
|
|
||||||
res = res || encoder.set_limit_min_bitrate(true);
|
|
||||||
res = res || encoder.set_blocksize(3021);
|
|
||||||
res = res || encoder.set_sample_rate(44100);
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
if(res)
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
/* XORing values as otherwise compiler will optimize, apparently */
|
|
||||||
bool res = false;
|
|
||||||
res = res != encoder.get_streamable_subset();
|
|
||||||
res = res != encoder.get_verify();
|
|
||||||
res = res != encoder.get_do_exhaustive_model_search();
|
|
||||||
res = res != encoder.get_do_mid_side_stereo();
|
|
||||||
res = res != encoder.get_loose_mid_side_stereo();
|
|
||||||
res = res != encoder.get_max_lpc_order();
|
|
||||||
res = res != encoder.get_qlp_coeff_precision();
|
|
||||||
res = res != encoder.get_do_qlp_coeff_prec_search();
|
|
||||||
res = res != encoder.get_do_escape_coding();
|
|
||||||
res = res != encoder.get_min_residual_partition_order();
|
|
||||||
res = res != encoder.get_max_residual_partition_order();
|
|
||||||
res = res != encoder.get_rice_parameter_search_dist();
|
|
||||||
res = res != encoder.get_total_samples_estimate();
|
|
||||||
res = res != encoder.get_channels();
|
|
||||||
res = res != encoder.get_bits_per_sample();
|
|
||||||
res = res != encoder.get_limit_min_bitrate();
|
|
||||||
res = res != encoder.get_blocksize();
|
|
||||||
res = res != encoder.get_sample_rate();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
while ( ds.Get<bool>() ) {
|
|
||||||
{
|
|
||||||
auto dat = ds.GetVector<FLAC__int32>();
|
|
||||||
|
|
||||||
if( ds.Get<bool>() )
|
|
||||||
/* Mask */
|
|
||||||
for (size_t i = 0; i < dat.size(); i++)
|
|
||||||
/* If we get here, bps is 4 or larger, or init will have failed */
|
|
||||||
dat[i] = (int32_t)(((uint32_t)(dat[i]) << (32-bps)) >> (32-bps));
|
|
||||||
|
|
||||||
const uint32_t samples = dat.size() / channels;
|
|
||||||
if ( samples > 0 ) {
|
|
||||||
const int32_t* ptr = dat.data();
|
|
||||||
const bool res = encoder.process_interleaved(ptr, samples);
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch ( ... ) { }
|
|
||||||
|
|
||||||
end:
|
|
||||||
{
|
|
||||||
const bool res = encoder.finish();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,352 +0,0 @@
|
||||||
/* fuzzer_encoder_v2
|
|
||||||
* Copyright (C) 2022-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring> /* for memcpy */
|
|
||||||
#include "FLAC/stream_encoder.h"
|
|
||||||
#include "FLAC/metadata.h"
|
|
||||||
extern "C" {
|
|
||||||
#include "share/private.h"
|
|
||||||
}
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
/* This C++ fuzzer uses the FLAC and not FLAC++ because the latter lacks a few
|
|
||||||
* hidden functions like FLAC__stream_encoder_disable_constant_subframes. It
|
|
||||||
* is still processed by a C++ compiler because that's what oss-fuzz expects */
|
|
||||||
|
|
||||||
|
|
||||||
static FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data)
|
|
||||||
{
|
|
||||||
(void)encoder, (void)buffer, (void)bytes, (void)samples, (void)current_frame, (void)client_data;
|
|
||||||
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
||||||
{
|
|
||||||
FLAC__bool encoder_valid = true;
|
|
||||||
FLAC__StreamEncoder *encoder = 0;
|
|
||||||
FLAC__StreamEncoderState state;
|
|
||||||
FLAC__StreamMetadata *metadata[16] = {NULL};
|
|
||||||
unsigned num_metadata = 0;
|
|
||||||
FLAC__StreamMetadata_VorbisComment_Entry VorbisCommentField;
|
|
||||||
|
|
||||||
unsigned sample_rate, channels, bps;
|
|
||||||
uint64_t samples_estimate, samples_in_input;
|
|
||||||
unsigned compression_level, input_data_width, blocksize, max_lpc_order, qlp_coeff_precision, min_residual_partition_order, max_residual_partition_order, metadata_mask, instruction_set_disable_mask;
|
|
||||||
FLAC__bool ogg, write_to_file, interleaved;
|
|
||||||
|
|
||||||
FLAC__bool data_bools[24];
|
|
||||||
|
|
||||||
/* Set alloc threshold. This check was added later and no spare config
|
|
||||||
* bytes were left, so we're reusing the sample rate as that of little
|
|
||||||
* consequence to the encoder and decoder except reading the frame header */
|
|
||||||
|
|
||||||
if(size < 3)
|
|
||||||
return 0;
|
|
||||||
alloc_check_threshold = data[2];
|
|
||||||
alloc_check_counter = 0;
|
|
||||||
|
|
||||||
/* allocate the encoder */
|
|
||||||
if((encoder = FLAC__stream_encoder_new()) == NULL) {
|
|
||||||
fprintf(stderr, "ERROR: allocating encoder\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use first 20 byte for configuration */
|
|
||||||
if(size < 20){
|
|
||||||
FLAC__stream_encoder_delete(encoder);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First 3 byte for sample rate, 4th byte for channels, 5th byte for bps */
|
|
||||||
sample_rate = ((unsigned)data[0] << 16) + ((unsigned)data[1] << 8) + data[2];
|
|
||||||
channels = data[3];
|
|
||||||
bps = data[4];
|
|
||||||
|
|
||||||
/* Number of samples estimate, format accepts 36-bit max */
|
|
||||||
samples_estimate = ((uint64_t)data[5] << 32) + ((unsigned)data[6] << 24) + ((unsigned)data[7] << 16) + ((unsigned)data[8] << 8) + data[9];
|
|
||||||
|
|
||||||
compression_level = data[10]&0b1111;
|
|
||||||
input_data_width = 1 + (data[10]>>4)%4;
|
|
||||||
samples_in_input = (size-20)/input_data_width;
|
|
||||||
blocksize = ((unsigned)data[11] << 8) + (unsigned)data[12];
|
|
||||||
max_lpc_order = data[13];
|
|
||||||
qlp_coeff_precision = data[14];
|
|
||||||
min_residual_partition_order = data[15] & 0b1111;
|
|
||||||
max_residual_partition_order = data[15] & 0b11110000;
|
|
||||||
metadata_mask = data[16];
|
|
||||||
instruction_set_disable_mask = data[17];
|
|
||||||
|
|
||||||
/* Get array of bools from configuration */
|
|
||||||
for(int i = 0; i < 16; i++)
|
|
||||||
data_bools[i] = data[18+i/8] & (1 << (i % 8));
|
|
||||||
|
|
||||||
ogg = data_bools[0];
|
|
||||||
interleaved = data_bools[1];
|
|
||||||
write_to_file = data_bools[13];
|
|
||||||
|
|
||||||
/* Set input and process parameters */
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_verify(encoder, data_bools[2]);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_channels(encoder, channels);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_bits_per_sample(encoder, bps);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_sample_rate(encoder, sample_rate);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_total_samples_estimate(encoder, samples_estimate);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_disable_instruction_set(encoder, instruction_set_disable_mask);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_limit_min_bitrate(encoder, data_bools[15]);
|
|
||||||
|
|
||||||
/* Set compression related parameters */
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_compression_level(encoder, compression_level);
|
|
||||||
if(data_bools[3]){
|
|
||||||
/* Bias towards regular compression levels */
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_blocksize(encoder, blocksize);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_max_lpc_order(encoder, max_lpc_order);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_qlp_coeff_precision(encoder, qlp_coeff_precision);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_min_residual_partition_order(encoder, min_residual_partition_order);
|
|
||||||
|
|
||||||
/* With large inputs and expensive options enabled, the fuzzer can get *really* slow.
|
|
||||||
* Some combinations can make the fuzzer timeout (>60 seconds). However, while combining
|
|
||||||
* options makes the fuzzer slower, most options do not expose new code when combined.
|
|
||||||
* Therefore, combining slow options is disabled for large inputs. Any input containing
|
|
||||||
* more than 65536 * 2 samples (max blocksize, stereo) is considered large
|
|
||||||
*/
|
|
||||||
if(samples_in_input < (2*65536)) {
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_streamable_subset(encoder, data_bools[4]);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, data_bools[5]);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_do_escape_coding(encoder, data_bools[6]);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, data_bools[7]);
|
|
||||||
/* Combining model search, precision search and a high residual partition order is especially
|
|
||||||
* expensive, so limit that even further. This high partition order can only be set on
|
|
||||||
* large blocksize and with streamable subset disabled */
|
|
||||||
if(samples_in_input < (2 * 4609) || data_bools[4] || !data_bools[7] || !data_bools[5] || max_residual_partition_order < 9 || blocksize < 4609)
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_max_residual_partition_order(encoder, max_residual_partition_order);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(!data_bools[4])
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_streamable_subset(encoder, false);
|
|
||||||
else if(data_bools[6])
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_do_escape_coding(encoder, true);
|
|
||||||
else if(data_bools[7])
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, true);
|
|
||||||
else if(data_bools[5])
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, true);
|
|
||||||
}
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_do_mid_side_stereo(encoder, data_bools[8]);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, data_bools[9]);
|
|
||||||
|
|
||||||
encoder_valid &= FLAC__stream_encoder_disable_constant_subframes(encoder, data_bools[10]);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_disable_fixed_subframes(encoder, data_bools[11]);
|
|
||||||
encoder_valid &= FLAC__stream_encoder_disable_verbatim_subframes(encoder, data_bools[12]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Disable alloc check if requested */
|
|
||||||
if(encoder_valid && data_bools[14])
|
|
||||||
alloc_check_threshold = INT32_MAX;
|
|
||||||
|
|
||||||
/* add metadata */
|
|
||||||
if(encoder_valid && (metadata_mask & 1)) {
|
|
||||||
if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO)) == NULL)
|
|
||||||
encoder_valid = false;
|
|
||||||
else
|
|
||||||
num_metadata++;
|
|
||||||
}
|
|
||||||
if(encoder_valid && (metadata_mask & 2) && size > 21){
|
|
||||||
if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL)
|
|
||||||
encoder_valid = false;
|
|
||||||
else {
|
|
||||||
metadata[num_metadata++]->length = (((unsigned)data[20]) << 8) + (unsigned)(data[21]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(encoder_valid && (metadata_mask & 4) && size > 20){
|
|
||||||
FLAC__byte * application_data = (FLAC__byte *)malloc(size-20);
|
|
||||||
if(0 != application_data && ((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) == NULL))
|
|
||||||
encoder_valid = false;
|
|
||||||
else {
|
|
||||||
memcpy(application_data,data+20,size-20);
|
|
||||||
FLAC__metadata_object_application_set_data(metadata[num_metadata++], application_data, size-20, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(encoder_valid && (metadata_mask & 8) && size > 25){
|
|
||||||
if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE)) == NULL)
|
|
||||||
encoder_valid = false;
|
|
||||||
else {
|
|
||||||
unsigned seekpoint_spacing = ((unsigned)data[22] << 8) + data[23];
|
|
||||||
unsigned total_samples_for_seekpoints = ((unsigned)data[24] << 8) + data[25];
|
|
||||||
FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(metadata[num_metadata++], seekpoint_spacing, total_samples_for_seekpoints);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(encoder_valid && (metadata_mask & 16)){
|
|
||||||
if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) != NULL) {
|
|
||||||
bool vorbiscomment_valid = true;
|
|
||||||
/* Append a vorbis comment */
|
|
||||||
if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&VorbisCommentField, "COMMENTARY", "Nothing to 🤔 report"))
|
|
||||||
vorbiscomment_valid = false;
|
|
||||||
else {
|
|
||||||
if(FLAC__metadata_object_vorbiscomment_append_comment(metadata[num_metadata], VorbisCommentField, false)) {
|
|
||||||
|
|
||||||
/* Insert a vorbis comment at the first index */
|
|
||||||
if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&VorbisCommentField, "COMMENTARY", "Still nothing to report 🤔🤣"))
|
|
||||||
vorbiscomment_valid = false;
|
|
||||||
else
|
|
||||||
if(!FLAC__metadata_object_vorbiscomment_insert_comment(metadata[num_metadata], 0, VorbisCommentField, false)) {
|
|
||||||
free(VorbisCommentField.entry);
|
|
||||||
vorbiscomment_valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
free(VorbisCommentField.entry);
|
|
||||||
vorbiscomment_valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!vorbiscomment_valid) {
|
|
||||||
FLAC__metadata_object_delete(metadata[num_metadata]);
|
|
||||||
metadata[num_metadata] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
num_metadata++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(encoder_valid && (metadata_mask & 32)){
|
|
||||||
if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET)) != NULL) {
|
|
||||||
if(!FLAC__metadata_object_cuesheet_insert_blank_track(metadata[num_metadata],0)) {
|
|
||||||
FLAC__metadata_object_delete(metadata[num_metadata]);
|
|
||||||
metadata[num_metadata] = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(!FLAC__metadata_object_cuesheet_track_insert_blank_index(metadata[num_metadata],0,0)) {
|
|
||||||
FLAC__metadata_object_delete(metadata[num_metadata]);
|
|
||||||
metadata[num_metadata] = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
metadata[num_metadata]->data.cue_sheet.tracks[0].number = 1;
|
|
||||||
num_metadata++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(encoder_valid && (metadata_mask & 64)){
|
|
||||||
if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE)) != NULL) {
|
|
||||||
num_metadata++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(encoder_valid && (metadata_mask & 128)){
|
|
||||||
if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_UNDEFINED)) != NULL) {
|
|
||||||
metadata[num_metadata]->length = 24;
|
|
||||||
metadata[num_metadata]->data.unknown.data = (FLAC__byte *)calloc(24, 1);
|
|
||||||
num_metadata++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(num_metadata && encoder_valid)
|
|
||||||
encoder_valid = FLAC__stream_encoder_set_metadata(encoder, metadata, num_metadata);
|
|
||||||
|
|
||||||
/* initialize encoder */
|
|
||||||
if(encoder_valid) {
|
|
||||||
FLAC__StreamEncoderInitStatus init_status;
|
|
||||||
if(ogg)
|
|
||||||
if(write_to_file)
|
|
||||||
init_status = FLAC__stream_encoder_init_ogg_file(encoder, "/tmp/tmp.flac", NULL, NULL);
|
|
||||||
else
|
|
||||||
init_status = FLAC__stream_encoder_init_ogg_stream(encoder, NULL, write_callback, NULL, NULL, NULL, NULL);
|
|
||||||
else
|
|
||||||
if(write_to_file)
|
|
||||||
init_status = FLAC__stream_encoder_init_file(encoder, "/tmp/tmp.flac", NULL, NULL);
|
|
||||||
else
|
|
||||||
init_status = FLAC__stream_encoder_init_stream(encoder, write_callback, NULL, NULL, NULL, NULL);
|
|
||||||
if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
|
|
||||||
encoder_valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* send samples to encoder */
|
|
||||||
if(encoder_valid && size > (input_data_width*channels+26)) {
|
|
||||||
unsigned samples = (size - 26)/input_data_width/channels;
|
|
||||||
const uint8_t * pcm_data = data + 26;
|
|
||||||
int32_t * data_as_int32 = (int32_t *)malloc(4*samples*channels);
|
|
||||||
if(0 != data_as_int32){
|
|
||||||
for(unsigned i = 0; i < samples*channels; i++)
|
|
||||||
if(input_data_width == 1)
|
|
||||||
data_as_int32[i] = (int32_t)pcm_data[i] - 0x80;
|
|
||||||
else if(input_data_width == 2)
|
|
||||||
data_as_int32[i] = (((int32_t)pcm_data[i*2] << 8) + pcm_data[i*2+1]) - 0x8000;
|
|
||||||
else if(input_data_width == 3)
|
|
||||||
data_as_int32[i] = (((int32_t)pcm_data[i*3] << 16) + ((int32_t)pcm_data[i*3+1] << 8) + pcm_data[i*3+2]) - 0x800000;
|
|
||||||
else if(input_data_width == 4)
|
|
||||||
data_as_int32[i] = (((int64_t)pcm_data[i*4] << 24) + ((int32_t)pcm_data[i*4+1] << 16) + ((int32_t)pcm_data[i*4+2] << 8) + pcm_data[i*4+3]) - 0x80000000;
|
|
||||||
|
|
||||||
/* feed samples to encoder */
|
|
||||||
if(interleaved)
|
|
||||||
encoder_valid = FLAC__stream_encoder_process_interleaved(encoder, data_as_int32, samples);
|
|
||||||
else {
|
|
||||||
encoder_valid = FLAC__stream_encoder_process(encoder, (const int32_t*[]){data_as_int32,
|
|
||||||
data_as_int32+samples,
|
|
||||||
data_as_int32+samples*2,
|
|
||||||
data_as_int32+samples*3,
|
|
||||||
data_as_int32+samples*4, data_as_int32+samples*5, data_as_int32+samples*6, data_as_int32+samples*7}, samples);
|
|
||||||
}
|
|
||||||
free(data_as_int32);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
encoder_valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
state = FLAC__stream_encoder_get_state(encoder);
|
|
||||||
if(!(state == FLAC__STREAM_ENCODER_OK ||
|
|
||||||
state == FLAC__STREAM_ENCODER_UNINITIALIZED ||
|
|
||||||
state == FLAC__STREAM_ENCODER_CLIENT_ERROR ||
|
|
||||||
((state == FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR ||
|
|
||||||
state == FLAC__STREAM_ENCODER_FRAMING_ERROR ||
|
|
||||||
(state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR &&
|
|
||||||
FLAC__stream_encoder_get_verify_decoder_state(encoder) == FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR)) &&
|
|
||||||
alloc_check_threshold < INT32_MAX))) {
|
|
||||||
fprintf(stderr,"-----\nERROR: stream encoder returned %s\n-----\n",FLAC__stream_encoder_get_resolved_state_string(encoder));
|
|
||||||
if(state == FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA) {
|
|
||||||
uint32_t frame_number, channel, sample_number;
|
|
||||||
FLAC__int32 expected, got;
|
|
||||||
FLAC__stream_encoder_get_verify_decoder_error_stats(encoder, NULL, &frame_number, &channel, &sample_number, &expected, &got);
|
|
||||||
fprintf(stderr,"Frame number %d\nChannel %d\n Sample number %d\nExpected value %d\nGot %d\n", frame_number, channel, sample_number, expected, got);
|
|
||||||
}
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
FLAC__stream_encoder_finish(encoder);
|
|
||||||
|
|
||||||
/* now that encoding is finished, the metadata can be freed */
|
|
||||||
for(unsigned i = 0; i < 16; i++)
|
|
||||||
if(0 != metadata[i])
|
|
||||||
FLAC__metadata_object_delete(metadata[i]);
|
|
||||||
|
|
||||||
FLAC__stream_encoder_delete(encoder);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
flac_stream_marker="fLaC"
|
|
||||||
ogg_stream_marker="OggS"
|
|
||||||
flac_in_ogg_marker="\x7fFLAC"
|
|
||||||
|
|
||||||
synccode_fixed_blocksize="\xFF\xF8"
|
|
||||||
synccode_variable_blocksize="\xFF\xF9"
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
"bartlett"
|
|
||||||
"bartlett_hann"
|
|
||||||
"blackman"
|
|
||||||
"blackman_harris_4term_92db"
|
|
||||||
"connes"
|
|
||||||
"flattop"
|
|
||||||
"gauss()"
|
|
||||||
"hamming"
|
|
||||||
"hann"
|
|
||||||
"kaiser_bessel"
|
|
||||||
"nuttall"
|
|
||||||
"rectangle"
|
|
||||||
"triangle"
|
|
||||||
"tukey(0)"
|
|
||||||
"partial_tukey(0)"
|
|
||||||
"punchout_tukey(0)"
|
|
||||||
"subdivide_tukey(0)"
|
|
||||||
"welch"
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
flac_stream_marker="fLaC"
|
|
||||||
ogg_stream_marker="OggS"
|
|
||||||
flac_in_ogg_marker="\x7fFLAC"
|
|
||||||
|
|
||||||
synccode_fixed_blocksize="\xFF\xF8"
|
|
||||||
synccode_variable_blocksize="\xFF\xF9"
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
"--keep-foreign-metadata-if-present"
|
|
||||||
"--replay-gain"
|
|
||||||
"--apply-replaygain-which-is-not-lossless"
|
|
||||||
|
|
||||||
"--force-raw-format"
|
|
||||||
"--force-aiff-format"
|
|
||||||
"--force-rf64-format"
|
|
||||||
"--force-wave64-format"
|
|
||||||
"--force-aiff-c-sowt-format"
|
|
||||||
"--force-aiff-c-none-format"
|
|
||||||
"--force-legacy-wave-format"
|
|
||||||
"--force-extensible-wave-format"
|
|
||||||
|
|
||||||
"--endian=big"
|
|
||||||
"--sample-rate=1"
|
|
||||||
"--channels=1"
|
|
||||||
"--bps=32"
|
|
||||||
"--sign=unsigned"
|
|
||||||
|
|
||||||
|
|
@ -1,190 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <fuzzing/exception.hpp>
|
|
||||||
#include <fuzzing/types.hpp>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace fuzzing {
|
|
||||||
namespace datasource {
|
|
||||||
|
|
||||||
class Base
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
virtual std::vector<uint8_t> get(const size_t min, const size_t max, const uint64_t id = 0) = 0;
|
|
||||||
public:
|
|
||||||
Base(void) = default;
|
|
||||||
virtual ~Base(void) = default;
|
|
||||||
|
|
||||||
template<class T> T Get(const uint64_t id = 0);
|
|
||||||
uint16_t GetChoice(const uint64_t id = 0);
|
|
||||||
std::vector<uint8_t> GetData(const uint64_t id, const size_t min = 0, const size_t max = 0);
|
|
||||||
template <class T> std::vector<T> GetVector(const uint64_t id = 0);
|
|
||||||
|
|
||||||
class OutOfData : public fuzzing::exception::FlowException {
|
|
||||||
public:
|
|
||||||
OutOfData() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DeserializationFailure : public fuzzing::exception::FlowException {
|
|
||||||
public:
|
|
||||||
DeserializationFailure() = default;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
template<class T> T Base::Get(const uint64_t id)
|
|
||||||
{
|
|
||||||
T ret;
|
|
||||||
const auto v = get(sizeof(ret), sizeof(ret), id);
|
|
||||||
memcpy(&ret, v.data(), sizeof(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <> bool Base::Get<bool>(const uint64_t id)
|
|
||||||
{
|
|
||||||
uint8_t ret;
|
|
||||||
const auto v = get(sizeof(ret), sizeof(ret), id);
|
|
||||||
memcpy(&ret, v.data(), sizeof(ret));
|
|
||||||
return (ret % 2) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <> std::string Base::Get<std::string>(const uint64_t id)
|
|
||||||
{
|
|
||||||
auto data = GetData(id);
|
|
||||||
return std::string(data.data(), data.data() + data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <> std::vector<std::string> Base::Get<std::vector<std::string>>(const uint64_t id)
|
|
||||||
{
|
|
||||||
std::vector<std::string> ret;
|
|
||||||
while ( true ) {
|
|
||||||
auto data = GetData(id);
|
|
||||||
ret.push_back( std::string(data.data(), data.data() + data.size()) );
|
|
||||||
if ( Get<bool>(id) == false ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t Base::GetChoice(const uint64_t id)
|
|
||||||
{
|
|
||||||
return Get<uint16_t>(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint8_t> Base::GetData(const uint64_t id, const size_t min, const size_t max)
|
|
||||||
{
|
|
||||||
return get(min, max, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <> types::String<> Base::Get<types::String<>>(const uint64_t id) {
|
|
||||||
const auto data = GetData(id);
|
|
||||||
types::String<> ret(data.data(), data.size());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <> types::Data<> Base::Get<types::Data<>>(const uint64_t id) {
|
|
||||||
const auto data = GetData(id);
|
|
||||||
types::Data<> ret(data.data(), data.size());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
std::vector<T> Base::GetVector(const uint64_t id) {
|
|
||||||
std::vector<T> ret;
|
|
||||||
|
|
||||||
while ( Get<bool>(id) == true ) {
|
|
||||||
ret.push_back( Get<T>(id) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Datasource : public Base
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
const uint8_t* data;
|
|
||||||
const size_t size;
|
|
||||||
size_t idx;
|
|
||||||
size_t left;
|
|
||||||
std::vector<uint8_t> get(const size_t min, const size_t max, const uint64_t id = 0) override;
|
|
||||||
|
|
||||||
// Make copy constructor and assignment operator private.
|
|
||||||
Datasource(const Datasource &) : data(0), size(0), idx(0), left(0) {}
|
|
||||||
Datasource& operator=(const Datasource &) { return *this; }
|
|
||||||
public:
|
|
||||||
Datasource(const uint8_t* _data, const size_t _size);
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
Datasource::Datasource(const uint8_t* _data, const size_t _size) :
|
|
||||||
Base(), data(_data), size(_size), idx(0), left(size)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint8_t> Datasource::get(const size_t min, const size_t max, const uint64_t id) {
|
|
||||||
(void)id;
|
|
||||||
|
|
||||||
uint32_t getSize;
|
|
||||||
if ( left < sizeof(getSize) ) {
|
|
||||||
throw OutOfData();
|
|
||||||
}
|
|
||||||
memcpy(&getSize, data + idx, sizeof(getSize));
|
|
||||||
idx += sizeof(getSize);
|
|
||||||
left -= sizeof(getSize);
|
|
||||||
|
|
||||||
if ( getSize < min ) {
|
|
||||||
getSize = min;
|
|
||||||
}
|
|
||||||
if ( max && getSize > max ) {
|
|
||||||
getSize = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( left < getSize ) {
|
|
||||||
throw OutOfData();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint8_t> ret(getSize);
|
|
||||||
|
|
||||||
if ( getSize > 0 ) {
|
|
||||||
memcpy(ret.data(), data + idx, getSize);
|
|
||||||
}
|
|
||||||
idx += getSize;
|
|
||||||
left -= getSize;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* namespace datasource */
|
|
||||||
} /* namespace fuzzing */
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <utility>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace fuzzing {
|
|
||||||
namespace datasource {
|
|
||||||
|
|
||||||
/* From: https://gist.github.com/underscorediscovery/81308642d0325fd386237cfa3b44785c */
|
|
||||||
inline uint64_t hash_64_fnv1a(const void* key, const uint64_t len) {
|
|
||||||
|
|
||||||
const char* data = (char*)key;
|
|
||||||
uint64_t hash = 0xcbf29ce484222325;
|
|
||||||
uint64_t prime = 0x100000001b3;
|
|
||||||
|
|
||||||
for(uint64_t i = 0; i < len; ++i) {
|
|
||||||
uint8_t value = data[i];
|
|
||||||
hash = hash ^ value;
|
|
||||||
hash *= prime;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
|
|
||||||
} //hash_64_fnv1a
|
|
||||||
|
|
||||||
// FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit
|
|
||||||
// str should be a null terminated string literal, value should be left out
|
|
||||||
// e.g hash_32_fnv1a_const("example")
|
|
||||||
// code license: public domain or equivalent
|
|
||||||
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/
|
|
||||||
|
|
||||||
constexpr uint32_t val_32_const = 0x811c9dc5;
|
|
||||||
constexpr uint32_t prime_32_const = 0x1000193;
|
|
||||||
constexpr uint64_t val_64_const = 0xcbf29ce484222325;
|
|
||||||
constexpr uint64_t prime_64_const = 0x100000001b3;
|
|
||||||
|
|
||||||
|
|
||||||
inline constexpr uint64_t ID(const char* const str, const uint64_t value = val_64_const) noexcept {
|
|
||||||
auto ret = (str[0] == '\0') ? value : ID(&str[1], (value ^ uint64_t(str[0])) * prime_64_const);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr std::pair<const char*, uint64_t> IDPair(const char* const str, const uint64_t value = val_64_const) noexcept {
|
|
||||||
return {str, ID(str, value)};
|
|
||||||
}
|
|
||||||
|
|
||||||
using IDMap = std::map<const char*, uint64_t>;
|
|
||||||
|
|
||||||
} /* namespace datasource */
|
|
||||||
} /* namespace fuzzing */
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace fuzzing {
|
|
||||||
namespace exception {
|
|
||||||
|
|
||||||
class ExceptionBase : public std::exception {
|
|
||||||
public:
|
|
||||||
ExceptionBase(void) = default;
|
|
||||||
/* typeid(T).name */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Recoverable exception */
|
|
||||||
class FlowException : public ExceptionBase {
|
|
||||||
public:
|
|
||||||
FlowException(void) : ExceptionBase() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Error in this library, should never happen */
|
|
||||||
class LogicException : public ExceptionBase {
|
|
||||||
private:
|
|
||||||
std::string reason;
|
|
||||||
public:
|
|
||||||
LogicException(const std::string r) : ExceptionBase(), reason(r) { }
|
|
||||||
virtual const char* what(void) const throw() {
|
|
||||||
return reason.c_str();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Error in target application */
|
|
||||||
class TargetException : public ExceptionBase {
|
|
||||||
private:
|
|
||||||
std::string reason;
|
|
||||||
public:
|
|
||||||
TargetException(const std::string r) : ExceptionBase(), reason(r) { }
|
|
||||||
virtual const char* what(void) const throw() {
|
|
||||||
return reason.c_str();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} /* namespace exception */
|
|
||||||
} /* namespace fuzzing */
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#ifndef ASAN
|
|
||||||
#define ASAN 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MSAN
|
|
||||||
#define MSAN 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace fuzzing {
|
|
||||||
namespace memory {
|
|
||||||
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
#if ASAN == 1
|
|
||||||
extern "C" void *__asan_region_is_poisoned(const void *beg, size_t size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MSAN == 1
|
|
||||||
extern "C" void __msan_check_mem_is_initialized(const volatile void *x, size_t size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void memory_test_asan(const void* data, const size_t size)
|
|
||||||
{
|
|
||||||
(void)data;
|
|
||||||
(void)size;
|
|
||||||
|
|
||||||
#if ASAN == 1
|
|
||||||
if ( __asan_region_is_poisoned(data, size) != NULL ) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void memory_test_msan(const void* data, const size_t size)
|
|
||||||
{
|
|
||||||
(void)data;
|
|
||||||
(void)size;
|
|
||||||
|
|
||||||
#if MSAN == 1
|
|
||||||
__msan_check_mem_is_initialized(data, size);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void memory_test(const void* data, const size_t size)
|
|
||||||
{
|
|
||||||
memory_test_asan(data, size);
|
|
||||||
memory_test_msan(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void memory_test(const T& t)
|
|
||||||
{
|
|
||||||
(void)t;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
void memory_test(const std::string& s)
|
|
||||||
{
|
|
||||||
(void)s;
|
|
||||||
|
|
||||||
#if MSAN == 1
|
|
||||||
memory_test(s.data(), s.size());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* namespace memory */
|
|
||||||
} /* namespace fuzzing */
|
|
||||||
|
|
@ -1,158 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <fuzzing/memory.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace fuzzing {
|
|
||||||
namespace types {
|
|
||||||
|
|
||||||
template <typename CoreType, bool NullTerminated, bool UseMSAN = false>
|
|
||||||
class Container {
|
|
||||||
private:
|
|
||||||
CoreType* InvalidAddress = (CoreType*)0x12;
|
|
||||||
|
|
||||||
CoreType* _data = InvalidAddress;
|
|
||||||
size_t _size = 0;
|
|
||||||
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
void copy(const void* data, size_t size) {
|
|
||||||
if ( size > 0 ) {
|
|
||||||
std::memcpy(_data, data, size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void allocate(size_t size) {
|
|
||||||
if ( size > 0 ) {
|
|
||||||
_data = static_cast<CoreType*>(malloc(size * sizeof(CoreType)));
|
|
||||||
} else {
|
|
||||||
_data = InvalidAddress;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void allocate_and_copy(const void* data, size_t size) {
|
|
||||||
allocate(size);
|
|
||||||
copy(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void allocate_plus_1_and_copy(const void* data, size_t size) {
|
|
||||||
allocate(size+1);
|
|
||||||
copy(data, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void access_hook(void) const {
|
|
||||||
if ( UseMSAN == true ) {
|
|
||||||
memory::memory_test_msan(_data, _size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void free(void) {
|
|
||||||
access_hook();
|
|
||||||
|
|
||||||
if ( _data != InvalidAddress ) {
|
|
||||||
std::free(_data);
|
|
||||||
_data = InvalidAddress;
|
|
||||||
_size = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
CoreType* data(void) {
|
|
||||||
access_hook();
|
|
||||||
return _data;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size(void) const {
|
|
||||||
access_hook();
|
|
||||||
return _size;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Container(void)
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
= default
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
Container(const void* data, const size_t size)
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
{
|
|
||||||
if ( NullTerminated == false ) {
|
|
||||||
allocate_and_copy(data, size);
|
|
||||||
} else {
|
|
||||||
allocate_plus_1_and_copy(data, size);
|
|
||||||
_data[size] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
access_hook();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
Container(const T& t)
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
{
|
|
||||||
Container(t.data(), t.size());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
~Container(void)
|
|
||||||
#ifndef FUZZING_HEADERS_NO_IMPL
|
|
||||||
{
|
|
||||||
this->free();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The copy constructor was not originally explicitly supplied
|
|
||||||
// so it must have been incorrectly just copying the pointers.
|
|
||||||
Container(const Container &c) {
|
|
||||||
InvalidAddress = c.InvalidAddress;
|
|
||||||
allocate_and_copy(c._data, c._size);
|
|
||||||
}
|
|
||||||
|
|
||||||
Container& operator=(Container &c) {
|
|
||||||
InvalidAddress = c.InvalidAddress;
|
|
||||||
allocate_and_copy(c._data, c._size);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool UseMSAN = false> using String = Container<char, true, UseMSAN>;
|
|
||||||
template <bool UseMSAN = false> using Data = Container<uint8_t, false, UseMSAN>;
|
|
||||||
|
|
||||||
} /* namespace types */
|
|
||||||
} /* namespace fuzzing */
|
|
||||||
|
|
@ -1,526 +0,0 @@
|
||||||
/* fuzzer_metadata
|
|
||||||
* Copyright (C) 2022-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring> /* for memcpy */
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "FLAC++/metadata.h"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#define CONFIG_LENGTH 2
|
|
||||||
|
|
||||||
#define min(x,y) (x<y?x:y)
|
|
||||||
|
|
||||||
static void run_tests_with_level_0_interface(char filename[]);
|
|
||||||
static void run_tests_with_level_1_interface(char filename[], bool readonly, bool preservestats, const uint8_t *data, size_t size);
|
|
||||||
static void run_tests_with_level_2_interface(char filename[], bool ogg, bool use_padding, const uint8_t *data, size_t size);
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
||||||
{
|
|
||||||
uint8_t command_length;
|
|
||||||
char filename[] = "/tmp/tmpXXXXXX.flac";
|
|
||||||
FLAC__bool init_bools[4];
|
|
||||||
|
|
||||||
/* Use first byte for configuration, leave at least one byte of input */
|
|
||||||
if(size < 1 + CONFIG_LENGTH){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First 4 bits for configuration bools, next 4 for length of command section */
|
|
||||||
for(int i = 0; i < 4; i++)
|
|
||||||
init_bools[i] = data[i/8] & (1 << (i % 8));
|
|
||||||
|
|
||||||
command_length = data[0] >> 4;
|
|
||||||
|
|
||||||
if(0)//data[1] < 128) /* Use MSB as on/off */
|
|
||||||
alloc_check_threshold = data[1];
|
|
||||||
else
|
|
||||||
alloc_check_threshold = INT32_MAX;
|
|
||||||
alloc_check_counter = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/* Leave at least one byte as input */
|
|
||||||
if(command_length >= size - 1 - CONFIG_LENGTH)
|
|
||||||
command_length = size - 1 - CONFIG_LENGTH;
|
|
||||||
|
|
||||||
/* Dump input to file */
|
|
||||||
{
|
|
||||||
int file_to_fuzz = mkstemps(filename, 5);
|
|
||||||
|
|
||||||
if (file_to_fuzz < 0)
|
|
||||||
abort();
|
|
||||||
write(file_to_fuzz,data+CONFIG_LENGTH+command_length,size-CONFIG_LENGTH-command_length);
|
|
||||||
close(file_to_fuzz);
|
|
||||||
}
|
|
||||||
|
|
||||||
run_tests_with_level_0_interface(filename);
|
|
||||||
run_tests_with_level_1_interface(filename, init_bools[1], init_bools[2], data+CONFIG_LENGTH, command_length/2);
|
|
||||||
|
|
||||||
/* Dump input to file, to start fresh for level 2 */
|
|
||||||
if(!init_bools[1]){
|
|
||||||
FILE * file_to_fuzz = fopen(filename,"w");
|
|
||||||
fwrite(data+CONFIG_LENGTH+command_length,1,size-CONFIG_LENGTH-command_length,file_to_fuzz);
|
|
||||||
fclose(file_to_fuzz);
|
|
||||||
}
|
|
||||||
|
|
||||||
run_tests_with_level_2_interface(filename, init_bools[0], init_bools[3], data+command_length/2+CONFIG_LENGTH, command_length/2);
|
|
||||||
|
|
||||||
remove(filename);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void run_tests_with_level_0_interface(char filename[]) {
|
|
||||||
FLAC::Metadata::StreamInfo streaminfo;
|
|
||||||
FLAC::Metadata::VorbisComment vorbis_comment;
|
|
||||||
FLAC::Metadata::CueSheet cue_sheet;
|
|
||||||
FLAC::Metadata::Picture picture;
|
|
||||||
|
|
||||||
FLAC::Metadata::get_streaminfo(filename,streaminfo);
|
|
||||||
FLAC::Metadata::get_tags(filename,vorbis_comment);
|
|
||||||
FLAC::Metadata::get_cuesheet(filename,cue_sheet);
|
|
||||||
FLAC::Metadata::get_picture(filename,picture, (FLAC__StreamMetadata_Picture_Type)(1), NULL, NULL, -1, -1, -1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void run_tests_with_level_1_interface(char filename[], bool readonly, bool preservestats, const uint8_t *data, size_t size) {
|
|
||||||
FLAC::Metadata::SimpleIterator iterator;
|
|
||||||
FLAC::Metadata::Prototype *metadata_block = nullptr;
|
|
||||||
uint8_t id[4] = {0};
|
|
||||||
|
|
||||||
if(!iterator.is_valid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!iterator.init(filename,readonly,preservestats))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(size_t i = 0; i < size && iterator.status() == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; i++) {
|
|
||||||
switch(data[i] & 7) {
|
|
||||||
case 0:
|
|
||||||
iterator.get_block_type();
|
|
||||||
iterator.get_block_offset();
|
|
||||||
iterator.get_block_length();
|
|
||||||
iterator.get_application_id(id);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
iterator.next();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
iterator.prev();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
iterator.delete_block(data[i] & 8);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if(metadata_block != 0) {
|
|
||||||
delete metadata_block;
|
|
||||||
metadata_block = nullptr;
|
|
||||||
}
|
|
||||||
metadata_block = iterator.get_block();
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if(metadata_block != 0)
|
|
||||||
iterator.set_block(metadata_block,data[i] & 8);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if(metadata_block != 0)
|
|
||||||
iterator.insert_block_after(metadata_block, data[i] & 8);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
iterator.status();
|
|
||||||
iterator.is_last();
|
|
||||||
iterator.is_writable();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(metadata_block != 0) {
|
|
||||||
delete metadata_block;
|
|
||||||
metadata_block = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void run_tests_with_level_2_interface(char filename[], bool ogg, bool use_padding, const uint8_t *data, size_t size) {
|
|
||||||
FLAC::Metadata::Chain chain;
|
|
||||||
FLAC::Metadata::Iterator iterator;
|
|
||||||
FLAC::Metadata::Prototype *metadata_block_get = nullptr;
|
|
||||||
FLAC::Metadata::Prototype *metadata_block_transfer = nullptr;
|
|
||||||
FLAC::Metadata::Prototype *metadata_block_put = nullptr;
|
|
||||||
|
|
||||||
if(!chain.is_valid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!chain.read(filename, ogg))
|
|
||||||
return;
|
|
||||||
|
|
||||||
iterator.init(chain);
|
|
||||||
|
|
||||||
for(size_t i = 0; i < size; i++) {
|
|
||||||
switch(data[i] & 15) {
|
|
||||||
case 0:
|
|
||||||
iterator.get_block_type();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
iterator.next();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
iterator.prev();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
iterator.delete_block(data[i] & 16);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
metadata_block_get = iterator.get_block();
|
|
||||||
if(metadata_block_get != 0 && metadata_block_get->is_valid()) {
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
if(metadata_block_transfer != metadata_block_get) {
|
|
||||||
delete metadata_block_transfer;
|
|
||||||
metadata_block_transfer = nullptr;
|
|
||||||
metadata_block_transfer = FLAC::Metadata::clone(metadata_block_get);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
metadata_block_transfer = FLAC::Metadata::clone(metadata_block_get);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete metadata_block_get;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
metadata_block_put = FLAC::Metadata::clone(metadata_block_transfer);
|
|
||||||
if(metadata_block_put != 0 && metadata_block_put->is_valid()) {
|
|
||||||
if(!iterator.insert_block_before(metadata_block_put))
|
|
||||||
delete metadata_block_put;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(metadata_block_put != 0)
|
|
||||||
delete metadata_block_put;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
metadata_block_put = FLAC::Metadata::clone(metadata_block_transfer);
|
|
||||||
if(metadata_block_put != 0 && metadata_block_put->is_valid()) {
|
|
||||||
if(!iterator.insert_block_after(metadata_block_put))
|
|
||||||
delete metadata_block_put;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(metadata_block_put != 0)
|
|
||||||
delete metadata_block_put;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
metadata_block_put = FLAC::Metadata::clone(metadata_block_transfer);
|
|
||||||
if(metadata_block_put != 0 && metadata_block_put->is_valid()) {
|
|
||||||
if(!iterator.set_block(metadata_block_put))
|
|
||||||
delete metadata_block_put;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(metadata_block_put != 0)
|
|
||||||
delete metadata_block_put;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 8: /* Examine block */
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
switch(metadata_block_transfer->get_type()) {
|
|
||||||
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
|
||||||
{
|
|
||||||
uint32_t num_comments;
|
|
||||||
::FLAC__StreamMetadata_VorbisComment_Entry entry;
|
|
||||||
FLAC::Metadata::VorbisComment::Entry entry_cpp;
|
|
||||||
FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast<FLAC::Metadata::VorbisComment *>(metadata_block_transfer);
|
|
||||||
const ::FLAC__StreamMetadata * metadata_c = *metadata_block_transfer;
|
|
||||||
if(vorbiscomment == 0)
|
|
||||||
abort();
|
|
||||||
vorbiscomment->get_vendor_string();
|
|
||||||
num_comments = vorbiscomment->get_num_comments();
|
|
||||||
if(num_comments > 0) {
|
|
||||||
entry = metadata_c->data.vorbis_comment.comments[min(data[i]>>4,num_comments-1)];
|
|
||||||
if(entry.entry == 0)
|
|
||||||
abort();
|
|
||||||
if(vorbiscomment->get_comment(min(data[i]>>4,num_comments-1)).is_valid()) {
|
|
||||||
entry_cpp = vorbiscomment->get_comment(min(data[i]>>4,num_comments-1));
|
|
||||||
if(entry_cpp.is_valid() && entry_cpp.get_field() == 0)
|
|
||||||
abort();
|
|
||||||
vorbiscomment->find_entry_from(0,"TEST");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_CUESHEET:
|
|
||||||
{
|
|
||||||
uint32_t num_tracks, num_indices;
|
|
||||||
FLAC::Metadata::CueSheet * cuesheet = dynamic_cast<FLAC::Metadata::CueSheet *>(metadata_block_transfer);
|
|
||||||
if(cuesheet == 0 || !cuesheet->is_legal())
|
|
||||||
break;
|
|
||||||
cuesheet->is_legal(true); /* check CDDA subset */
|
|
||||||
cuesheet->calculate_cddb_id();
|
|
||||||
cuesheet->get_media_catalog_number();
|
|
||||||
cuesheet->get_lead_in();
|
|
||||||
cuesheet->get_is_cd();
|
|
||||||
num_tracks = cuesheet->get_num_tracks();
|
|
||||||
if(num_tracks > 0) {
|
|
||||||
FLAC::Metadata::CueSheet::Track track = cuesheet->get_track(min(data[i]>>4,num_tracks-1));
|
|
||||||
track.get_offset();
|
|
||||||
track.get_number();
|
|
||||||
track.get_isrc();
|
|
||||||
track.get_pre_emphasis();
|
|
||||||
num_indices = track.get_num_indices();
|
|
||||||
if(num_indices > 0) {
|
|
||||||
FLAC__StreamMetadata_CueSheet_Index index = track.get_index(min(data[i]>>4,num_indices-1));
|
|
||||||
(void)index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_PICTURE:
|
|
||||||
{
|
|
||||||
char * violation = nullptr;
|
|
||||||
FLAC::Metadata::Picture * picture = dynamic_cast<FLAC::Metadata::Picture *>(metadata_block_transfer);
|
|
||||||
if(picture == 0 || !picture->is_legal((const char **)&violation))
|
|
||||||
break;
|
|
||||||
picture->get_data();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 9: /* Replace or add in block */
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
switch(metadata_block_transfer->get_type()) {
|
|
||||||
case FLAC__METADATA_TYPE_SEEKTABLE:
|
|
||||||
{
|
|
||||||
uint32_t num_seekpoints;
|
|
||||||
FLAC__StreamMetadata_SeekPoint seekpoint;
|
|
||||||
FLAC::Metadata::SeekTable * seektable = dynamic_cast<FLAC::Metadata::SeekTable *>(metadata_block_transfer);
|
|
||||||
if(seektable == 0)
|
|
||||||
break;
|
|
||||||
if(seektable->is_valid() && seektable->is_legal()) {
|
|
||||||
num_seekpoints = seektable->get_num_points();
|
|
||||||
if(num_seekpoints > 0) {
|
|
||||||
seekpoint = seektable->get_point(min(data[i]>>5,num_seekpoints-1));
|
|
||||||
seektable->set_point(0,seekpoint);
|
|
||||||
seektable->insert_point(min(data[i]>>5,num_seekpoints-1),seekpoint);
|
|
||||||
}
|
|
||||||
seektable->template_append_placeholders(4);
|
|
||||||
seektable->template_append_point(111111);
|
|
||||||
seektable->template_append_points((FLAC__uint64[]){222222, 333333, 444444}, 3);
|
|
||||||
seektable->template_append_spaced_points(data[i]>>5, 1234567);
|
|
||||||
seektable->template_append_spaced_points_by_samples(data[i]>>5, 2468000);
|
|
||||||
seektable->template_sort(data[i] & 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
|
||||||
{
|
|
||||||
uint32_t num_comments;
|
|
||||||
FLAC::Metadata::VorbisComment::Entry entry;
|
|
||||||
FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast<FLAC::Metadata::VorbisComment *>(metadata_block_transfer);
|
|
||||||
if(vorbiscomment == 0)
|
|
||||||
break;
|
|
||||||
num_comments = vorbiscomment->get_num_comments();
|
|
||||||
if(num_comments > 0 && entry.is_valid()) {
|
|
||||||
if(vorbiscomment->get_comment(min(data[i]>>5,num_comments-1)).is_valid()) {
|
|
||||||
entry = vorbiscomment->get_comment(min(data[i]>>5,num_comments-1));
|
|
||||||
if(entry.is_valid()) {
|
|
||||||
vorbiscomment->replace_comment(entry,data[i] & 16);
|
|
||||||
vorbiscomment->set_comment(0,entry);
|
|
||||||
vorbiscomment->append_comment(entry);
|
|
||||||
vorbiscomment->insert_comment(0,entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_CUESHEET:
|
|
||||||
{
|
|
||||||
uint32_t num_tracks, num_indices;
|
|
||||||
FLAC::Metadata::CueSheet * cuesheet = dynamic_cast<FLAC::Metadata::CueSheet *>(metadata_block_transfer);
|
|
||||||
if(cuesheet == 0 || !cuesheet->is_legal())
|
|
||||||
break;
|
|
||||||
num_tracks = cuesheet->get_num_tracks();
|
|
||||||
if(num_tracks > 0) {
|
|
||||||
FLAC::Metadata::CueSheet::Track track = cuesheet->get_track(min(data[i]>>4,num_tracks-1));
|
|
||||||
num_indices = track.get_num_indices();
|
|
||||||
if(num_indices > 0) {
|
|
||||||
FLAC__StreamMetadata_CueSheet_Index index = track.get_index(min(data[i]>>4,num_indices-1));
|
|
||||||
track.set_index(0,index);
|
|
||||||
cuesheet->insert_index(0,0,index);
|
|
||||||
cuesheet->insert_blank_index(0,0);
|
|
||||||
}
|
|
||||||
cuesheet->insert_blank_track(0);
|
|
||||||
cuesheet->insert_track(0,track);
|
|
||||||
cuesheet->resize_indices(min(data[i]>>4,num_tracks-1),data[i]>>4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_PICTURE:
|
|
||||||
{
|
|
||||||
FLAC::Metadata::Picture * picture = dynamic_cast<FLAC::Metadata::Picture *>(metadata_block_transfer);
|
|
||||||
const char testtext[] = "TEST";
|
|
||||||
if(picture == 0 || !picture->is_legal(NULL))
|
|
||||||
break;
|
|
||||||
picture->set_description((FLAC__byte *)&testtext);
|
|
||||||
picture->set_mime_type((const char *)&testtext);
|
|
||||||
picture->set_data((FLAC__byte *)&testtext,4);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 10: /* Delete from block */
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
switch(metadata_block_transfer->get_type()) {
|
|
||||||
case FLAC__METADATA_TYPE_SEEKTABLE:
|
|
||||||
{
|
|
||||||
uint32_t num_seekpoints;
|
|
||||||
FLAC::Metadata::SeekTable * seektable = dynamic_cast<FLAC::Metadata::SeekTable *>(metadata_block_transfer);
|
|
||||||
if(seektable == 0)
|
|
||||||
break;
|
|
||||||
if(seektable->is_valid() && seektable->is_legal()) {
|
|
||||||
num_seekpoints = seektable->get_num_points();
|
|
||||||
if(num_seekpoints > 0)
|
|
||||||
seektable->delete_point(min(data[i]>>4,num_seekpoints-1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
|
||||||
{
|
|
||||||
uint32_t num_comments;
|
|
||||||
FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast<FLAC::Metadata::VorbisComment *>(metadata_block_transfer);
|
|
||||||
if(vorbiscomment == 0)
|
|
||||||
break;
|
|
||||||
num_comments = vorbiscomment->get_num_comments();
|
|
||||||
if(num_comments > 0)
|
|
||||||
vorbiscomment->delete_comment(min(data[i]>>4,num_comments-1));
|
|
||||||
vorbiscomment->remove_entry_matching("TEST");
|
|
||||||
vorbiscomment->remove_entries_matching("TEST");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_CUESHEET:
|
|
||||||
{
|
|
||||||
uint32_t num_tracks;
|
|
||||||
FLAC::Metadata::CueSheet * cuesheet = dynamic_cast<FLAC::Metadata::CueSheet *>(metadata_block_transfer);
|
|
||||||
if(cuesheet == 0 || !cuesheet->is_legal())
|
|
||||||
break;
|
|
||||||
num_tracks = cuesheet->get_num_tracks();
|
|
||||||
if(num_tracks > 0) {
|
|
||||||
FLAC::Metadata::CueSheet::Track track = cuesheet->get_track(min(data[i]>>4,num_tracks-1));
|
|
||||||
if(track.get_num_indices() > 0)
|
|
||||||
cuesheet->delete_index(min(data[i]>>4,num_tracks-1),0);
|
|
||||||
cuesheet->delete_track(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 11: /* Resize block */
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
switch(metadata_block_transfer->get_type()) {
|
|
||||||
case FLAC__METADATA_TYPE_PADDING:
|
|
||||||
{
|
|
||||||
FLAC::Metadata::Padding * padding = dynamic_cast<FLAC::Metadata::Padding *>(metadata_block_transfer);
|
|
||||||
if(padding == 0)
|
|
||||||
break;
|
|
||||||
padding->set_length(data[i]>>4);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_SEEKTABLE:
|
|
||||||
{
|
|
||||||
FLAC::Metadata::SeekTable * seektable = dynamic_cast<FLAC::Metadata::SeekTable *>(metadata_block_transfer);
|
|
||||||
if(seektable == 0)
|
|
||||||
break;
|
|
||||||
seektable->resize_points(data[i]>>4);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
|
||||||
{
|
|
||||||
FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast<FLAC::Metadata::VorbisComment *>(metadata_block_transfer);
|
|
||||||
if(vorbiscomment == 0)
|
|
||||||
break;
|
|
||||||
vorbiscomment->resize_comments(data[i]>>4);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FLAC__METADATA_TYPE_CUESHEET:
|
|
||||||
{
|
|
||||||
uint32_t num_tracks;
|
|
||||||
FLAC::Metadata::CueSheet * cuesheet = dynamic_cast<FLAC::Metadata::CueSheet *>(metadata_block_transfer);
|
|
||||||
if(cuesheet == 0 || !cuesheet->is_legal())
|
|
||||||
break;
|
|
||||||
num_tracks = cuesheet->get_num_tracks();
|
|
||||||
if(num_tracks > 0) {
|
|
||||||
cuesheet->resize_indices(min(data[i]>>4,num_tracks-1),data[i]>>4);
|
|
||||||
}
|
|
||||||
cuesheet->resize_tracks(data[i]<<4);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 12: /* Prototype functions */
|
|
||||||
if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) {
|
|
||||||
const ::FLAC__StreamMetadata * metadata_compare = *metadata_block_transfer;
|
|
||||||
metadata_block_transfer->get_is_last();
|
|
||||||
metadata_block_transfer->get_length();
|
|
||||||
metadata_block_transfer->set_is_last(data[i] & 16);
|
|
||||||
FLAC__metadata_object_is_equal(metadata_compare, metadata_compare);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(metadata_block_transfer != 0) {
|
|
||||||
delete metadata_block_transfer;
|
|
||||||
metadata_block_transfer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
chain.status();
|
|
||||||
chain.sort_padding();
|
|
||||||
chain.merge_padding();
|
|
||||||
|
|
||||||
chain.check_if_tempfile_needed(!use_padding);
|
|
||||||
chain.write(use_padding);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,304 +0,0 @@
|
||||||
/* Copyright 2019 Guido Vranken
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include <fuzzing/datasource/datasource.hpp>
|
|
||||||
#include <fuzzing/memory.hpp>
|
|
||||||
|
|
||||||
#include "FLAC++/encoder.h"
|
|
||||||
#include "FLAC++/decoder.h"
|
|
||||||
#include "FLAC++/metadata.h"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#define MAX_NUM_METADATA_BLOCKS 2048
|
|
||||||
|
|
||||||
namespace FLAC {
|
|
||||||
namespace Encoder {
|
|
||||||
class FuzzerStream : public Stream {
|
|
||||||
private:
|
|
||||||
// fuzzing::datasource::Datasource& ds;
|
|
||||||
public:
|
|
||||||
FuzzerStream(fuzzing::datasource::Datasource&) :
|
|
||||||
Stream() { }
|
|
||||||
|
|
||||||
::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t /* samples */, uint32_t /* current_frame */) override {
|
|
||||||
fuzzing::memory::memory_test(buffer, bytes);
|
|
||||||
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
namespace Decoder {
|
|
||||||
class FuzzerDecoder : public Stream {
|
|
||||||
private:
|
|
||||||
fuzzing::datasource::Datasource& ds;
|
|
||||||
FLAC::Encoder::FuzzerStream& encoder;
|
|
||||||
public:
|
|
||||||
FuzzerDecoder(fuzzing::datasource::Datasource& dsrc, FLAC::Encoder::FuzzerStream& encoder_arg) :
|
|
||||||
Stream(), ds(dsrc), encoder(encoder_arg) { }
|
|
||||||
|
|
||||||
::FLAC__StreamMetadata * metadata_blocks[MAX_NUM_METADATA_BLOCKS] = {0};
|
|
||||||
int num_metadata_blocks = 0;
|
|
||||||
|
|
||||||
void metadata_callback(const ::FLAC__StreamMetadata *metadata) override {
|
|
||||||
if(num_metadata_blocks < MAX_NUM_METADATA_BLOCKS)
|
|
||||||
if((metadata_blocks[num_metadata_blocks] = FLAC__metadata_object_clone(metadata)) != NULL)
|
|
||||||
num_metadata_blocks++;
|
|
||||||
}
|
|
||||||
|
|
||||||
::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) override {
|
|
||||||
try {
|
|
||||||
const size_t maxCopySize = *bytes;
|
|
||||||
|
|
||||||
if ( maxCopySize > 0 ) {
|
|
||||||
/* memset just to test if this overwrites anything, and triggers ASAN */
|
|
||||||
memset(buffer, 0, maxCopySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto data = ds.GetData(0);
|
|
||||||
const auto dataSize = data.size();
|
|
||||||
const auto copySize = std::min(maxCopySize, dataSize);
|
|
||||||
|
|
||||||
if ( copySize > 0 ) {
|
|
||||||
memcpy(buffer, data.data(), copySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
*bytes = copySize;
|
|
||||||
|
|
||||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
|
||||||
} catch ( ... ) {
|
|
||||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) override {
|
|
||||||
{
|
|
||||||
fuzzing::memory::memory_test(&(frame->header), sizeof(frame->header));
|
|
||||||
fuzzing::memory::memory_test(&(frame->footer), sizeof(frame->footer));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const auto numChannels = get_channels();
|
|
||||||
const size_t bytesPerChannel = frame->header.blocksize * sizeof(FLAC__int32);
|
|
||||||
for (size_t i = 0; i < numChannels; i++) {
|
|
||||||
fuzzing::memory::memory_test(buffer[i], bytesPerChannel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Data is checked, now pass it towards encoder */
|
|
||||||
if(encoder.get_state() == FLAC__STREAM_ENCODER_OK) {
|
|
||||||
if(encoder.get_channels() != get_channels())
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
||||||
if(encoder.get_bits_per_sample() != get_bits_per_sample())
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
||||||
encoder.process(buffer, frame->header.blocksize);
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
||||||
}
|
|
||||||
void error_callback(::FLAC__StreamDecoderErrorStatus status) override {
|
|
||||||
fuzzing::memory::memory_test(status);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
||||||
fuzzing::datasource::Datasource ds(data, size);
|
|
||||||
FLAC::Encoder::FuzzerStream encoder(ds);
|
|
||||||
FLAC::Decoder::FuzzerDecoder decoder(ds, encoder);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const int channels = ds.Get<uint8_t>();
|
|
||||||
const int bps = ds.Get<uint8_t>();
|
|
||||||
encoder.set_channels(channels);
|
|
||||||
encoder.set_bits_per_sample(bps);
|
|
||||||
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_streamable_subset(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_ogg_serial_number(ds.Get<long>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_verify(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_compression_level(ds.Get<uint8_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_do_mid_side_stereo(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_loose_mid_side_stereo(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_max_lpc_order(ds.Get<uint8_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_qlp_coeff_precision(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_do_escape_coding(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_min_residual_partition_order(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_max_residual_partition_order(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_total_samples_estimate(ds.Get<uint64_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_blocksize(ds.Get<uint16_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_limit_min_bitrate(ds.Get<bool>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = encoder.set_sample_rate(ds.Get<uint32_t>());
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
decoder.set_metadata_respond_all();
|
|
||||||
|
|
||||||
{
|
|
||||||
::FLAC__StreamDecoderInitStatus ret;
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
ret = decoder.init();
|
|
||||||
} else {
|
|
||||||
ret = decoder.init_ogg();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ret != FLAC__STREAM_DECODER_INIT_STATUS_OK ) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
decoder.process_until_end_of_metadata();
|
|
||||||
if(decoder.num_metadata_blocks > 0)
|
|
||||||
encoder.set_metadata(decoder.metadata_blocks, decoder.num_metadata_blocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
::FLAC__StreamEncoderInitStatus ret;
|
|
||||||
if ( ds.Get<bool>() ) {
|
|
||||||
ret = encoder.init();
|
|
||||||
} else {
|
|
||||||
ret = encoder.init_ogg();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK ) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* These sets must fail, because encoder is already initialized */
|
|
||||||
{
|
|
||||||
bool res = false;
|
|
||||||
res = res || encoder.set_streamable_subset(true);
|
|
||||||
res = res || encoder.set_ogg_serial_number(0);
|
|
||||||
res = res || encoder.set_verify(true);
|
|
||||||
res = res || encoder.set_compression_level(0);
|
|
||||||
res = res || encoder.set_do_exhaustive_model_search(true);
|
|
||||||
res = res || encoder.set_do_mid_side_stereo(true);
|
|
||||||
res = res || encoder.set_loose_mid_side_stereo(true);
|
|
||||||
res = res || encoder.set_apodization("test");
|
|
||||||
res = res || encoder.set_max_lpc_order(0);
|
|
||||||
res = res || encoder.set_qlp_coeff_precision(0);
|
|
||||||
res = res || encoder.set_do_qlp_coeff_prec_search(true);
|
|
||||||
res = res || encoder.set_do_escape_coding(true);
|
|
||||||
res = res || encoder.set_min_residual_partition_order(0);
|
|
||||||
res = res || encoder.set_max_residual_partition_order(0);
|
|
||||||
res = res || encoder.set_rice_parameter_search_dist(0);
|
|
||||||
res = res || encoder.set_total_samples_estimate(0);
|
|
||||||
res = res || encoder.set_channels(channels);
|
|
||||||
res = res || encoder.set_bits_per_sample(16);
|
|
||||||
res = res || encoder.set_limit_min_bitrate(true);
|
|
||||||
res = res || encoder.set_blocksize(3021);
|
|
||||||
res = res || encoder.set_sample_rate(44100);
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
if(res)
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
/* XORing values as otherwise compiler will optimize, apparently */
|
|
||||||
bool res = false;
|
|
||||||
res = res != encoder.get_streamable_subset();
|
|
||||||
res = res != encoder.get_verify();
|
|
||||||
res = res != encoder.get_do_exhaustive_model_search();
|
|
||||||
res = res != encoder.get_do_mid_side_stereo();
|
|
||||||
res = res != encoder.get_loose_mid_side_stereo();
|
|
||||||
res = res != encoder.get_max_lpc_order();
|
|
||||||
res = res != encoder.get_qlp_coeff_precision();
|
|
||||||
res = res != encoder.get_do_qlp_coeff_prec_search();
|
|
||||||
res = res != encoder.get_do_escape_coding();
|
|
||||||
res = res != encoder.get_min_residual_partition_order();
|
|
||||||
res = res != encoder.get_max_residual_partition_order();
|
|
||||||
res = res != encoder.get_rice_parameter_search_dist();
|
|
||||||
res = res != encoder.get_total_samples_estimate();
|
|
||||||
res = res != encoder.get_channels();
|
|
||||||
res = res != encoder.get_bits_per_sample();
|
|
||||||
res = res != encoder.get_limit_min_bitrate();
|
|
||||||
res = res != encoder.get_blocksize();
|
|
||||||
res = res != encoder.get_sample_rate();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
decoder.process_until_end_of_stream();
|
|
||||||
|
|
||||||
} catch ( ... ) { }
|
|
||||||
|
|
||||||
end:
|
|
||||||
{
|
|
||||||
const bool res = encoder.finish();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const bool res = decoder.finish();
|
|
||||||
fuzzing::memory::memory_test(res);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < decoder.num_metadata_blocks; i++)
|
|
||||||
FLAC__metadata_object_delete(decoder.metadata_blocks[i]);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,195 +0,0 @@
|
||||||
/* fuzzer_seek
|
|
||||||
* Copyright (C) 2022-2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring> /* for memcpy */
|
|
||||||
#include "FLAC/stream_decoder.h"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
int write_abort_check_counter = -1;
|
|
||||||
|
|
||||||
#if 0 /* set to 1 to debug */
|
|
||||||
#define FPRINTF_DEBUG_ONLY(...) fprintf(__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define FPRINTF_DEBUG_ONLY(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CONFIG_LENGTH 2
|
|
||||||
|
|
||||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
|
|
||||||
{
|
|
||||||
(void)decoder, (void)frame, (void)buffer, (void)client_data;
|
|
||||||
if(write_abort_check_counter > 0) {
|
|
||||||
write_abort_check_counter--;
|
|
||||||
if(write_abort_check_counter == 0)
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
||||||
} else if(write_abort_check_counter == 0)
|
|
||||||
/* This must not happen: write callback called after abort is returned */
|
|
||||||
abort();
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus error, void *client_data)
|
|
||||||
{
|
|
||||||
(void)decoder, (void)error, (void)client_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
||||||
{
|
|
||||||
FLAC__bool decoder_valid = true;
|
|
||||||
FLAC__StreamDecoder *decoder;
|
|
||||||
uint8_t command_length;
|
|
||||||
FLAC__bool init_bools[16], ogg;
|
|
||||||
|
|
||||||
if(size > 2 && data[1] < 128) /* Use MSB as on/off */
|
|
||||||
alloc_check_threshold = data[1];
|
|
||||||
else
|
|
||||||
alloc_check_threshold = INT32_MAX;
|
|
||||||
alloc_check_counter = 0;
|
|
||||||
|
|
||||||
write_abort_check_counter = -1;
|
|
||||||
|
|
||||||
/* allocate the decoder */
|
|
||||||
if((decoder = FLAC__stream_decoder_new()) == NULL) {
|
|
||||||
fprintf(stderr, "ERROR: allocating decoder\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use first byte for configuration, leave at least one byte of input */
|
|
||||||
if(size < 1 + CONFIG_LENGTH){
|
|
||||||
FLAC__stream_decoder_delete(decoder);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First 4 bits for configuration bools, next 4 for length of command section */
|
|
||||||
for(int i = 0; i < 4; i++)
|
|
||||||
init_bools[i] = data[i/8] & (1 << (i % 8));
|
|
||||||
|
|
||||||
command_length = data[0] >> 4;
|
|
||||||
|
|
||||||
/* Leave at least one byte as input */
|
|
||||||
if(command_length >= size - 1 - CONFIG_LENGTH)
|
|
||||||
command_length = size - 1 - CONFIG_LENGTH;
|
|
||||||
|
|
||||||
/* Dump decoder input to file */
|
|
||||||
{
|
|
||||||
FILE * file_to_decode = fopen("/tmp/tmp.flac","w");
|
|
||||||
fwrite(data+CONFIG_LENGTH+command_length,1,size-CONFIG_LENGTH-command_length,file_to_decode);
|
|
||||||
fclose(file_to_decode);
|
|
||||||
}
|
|
||||||
|
|
||||||
ogg = init_bools[0];
|
|
||||||
|
|
||||||
FLAC__stream_decoder_set_md5_checking(decoder,init_bools[1]);
|
|
||||||
if(init_bools[2])
|
|
||||||
FLAC__stream_decoder_set_metadata_respond_all(decoder);
|
|
||||||
if(init_bools[3])
|
|
||||||
FLAC__stream_decoder_set_metadata_ignore_all(decoder);
|
|
||||||
|
|
||||||
/* initialize decoder */
|
|
||||||
if(decoder_valid) {
|
|
||||||
FLAC__StreamDecoderInitStatus init_status;
|
|
||||||
if(ogg)
|
|
||||||
init_status = FLAC__stream_decoder_init_ogg_file(decoder, "/tmp/tmp.flac", write_callback, NULL, error_callback, NULL);
|
|
||||||
else
|
|
||||||
init_status = FLAC__stream_decoder_init_file(decoder, "/tmp/tmp.flac", write_callback, NULL, error_callback, NULL);
|
|
||||||
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
|
|
||||||
decoder_valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run commands */
|
|
||||||
for(uint8_t i = 0; decoder_valid && (i < command_length); i++){
|
|
||||||
const uint8_t * command = data+CONFIG_LENGTH+i;
|
|
||||||
uint8_t shift = 1u << (command[0] >> 3);
|
|
||||||
FLAC__uint64 seekpos;
|
|
||||||
|
|
||||||
switch(command[0] & 15){
|
|
||||||
case 0:
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"end_of_stream\n");
|
|
||||||
decoder_valid = FLAC__stream_decoder_process_until_end_of_stream(decoder);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"end_of_metadata\n");
|
|
||||||
decoder_valid = FLAC__stream_decoder_process_until_end_of_metadata(decoder);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"single\n");
|
|
||||||
decoder_valid = FLAC__stream_decoder_process_single(decoder);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"skip_single\n");
|
|
||||||
decoder_valid = FLAC__stream_decoder_skip_single_frame(decoder);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"reset\n");
|
|
||||||
decoder_valid = FLAC__stream_decoder_reset(decoder);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"flush\n");
|
|
||||||
decoder_valid = FLAC__stream_decoder_flush(decoder);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
case 14:
|
|
||||||
shift = 1u << (command[0] >> 3);
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"seek short %hhu\n",shift);
|
|
||||||
decoder_valid = FLAC__stream_decoder_seek_absolute(decoder,shift);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
if(i+8 >= command_length) /* Not enough data available to do this */
|
|
||||||
break;
|
|
||||||
seekpos = ((FLAC__uint64)command[1] << 56) +
|
|
||||||
((FLAC__uint64)command[2] << 48) +
|
|
||||||
((FLAC__uint64)command[3] << 40) +
|
|
||||||
((FLAC__uint64)command[4] << 32) +
|
|
||||||
((FLAC__uint64)command[5] << 24) +
|
|
||||||
((FLAC__uint64)command[6] << 16) +
|
|
||||||
((FLAC__uint64)command[7] << 8) +
|
|
||||||
command[8];
|
|
||||||
i+=8;
|
|
||||||
FPRINTF_DEBUG_ONLY(stderr,"seek long %lu\n",seekpos);
|
|
||||||
decoder_valid = FLAC__stream_decoder_seek_absolute(decoder,seekpos);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
/* Set abort on write callback */
|
|
||||||
write_abort_check_counter = (command[0] >> 4) + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FLAC__stream_decoder_finish(decoder);
|
|
||||||
|
|
||||||
FLAC__stream_decoder_delete(decoder);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
/* fuzzer_tool_flac
|
|
||||||
* Copyright (C) 2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h> /* for memcpy */
|
|
||||||
#define FUZZ_TOOL_FLAC
|
|
||||||
#define fprintf(...)
|
|
||||||
#define printf(...)
|
|
||||||
#include "../src/flac/main.c"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
||||||
{
|
|
||||||
size_t size_left = size;
|
|
||||||
size_t arglen;
|
|
||||||
char * argv[67];
|
|
||||||
char exename[] = "flac";
|
|
||||||
char filename[] = "/tmp/fuzzXXXXXX";
|
|
||||||
int numarg = 0, maxarg;
|
|
||||||
int file_to_fuzz;
|
|
||||||
int tmp_stdout, tmp_stdin;
|
|
||||||
fpos_t pos_stdout;
|
|
||||||
bool use_stdin = false;
|
|
||||||
|
|
||||||
/* reset global vars */
|
|
||||||
flac__utils_verbosity_ = 0;
|
|
||||||
share__opterr = 0;
|
|
||||||
share__optind = 0;
|
|
||||||
|
|
||||||
if(size < 2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
maxarg = data[0] & 63;
|
|
||||||
use_stdin = data[0] & 64;
|
|
||||||
size_left--;
|
|
||||||
|
|
||||||
argv[0] = exename;
|
|
||||||
numarg++;
|
|
||||||
|
|
||||||
/* Check whether input is zero delimited */
|
|
||||||
while((arglen = strnlen((char *)data+(size-size_left),size_left)) < size_left && numarg < maxarg) {
|
|
||||||
argv[numarg++] = (char *)data+(size-size_left);
|
|
||||||
size_left -= arglen + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
file_to_fuzz = mkstemp(filename);
|
|
||||||
|
|
||||||
if (file_to_fuzz < 0)
|
|
||||||
abort();
|
|
||||||
write(file_to_fuzz,data+(size-size_left),size_left);
|
|
||||||
close(file_to_fuzz);
|
|
||||||
|
|
||||||
/* redirect stdout */
|
|
||||||
fflush(stdout);
|
|
||||||
fgetpos(stdout,&pos_stdout);
|
|
||||||
tmp_stdout = dup(fileno(stdout));
|
|
||||||
freopen("/dev/null","w",stdout);
|
|
||||||
|
|
||||||
/* redirect stdin */
|
|
||||||
tmp_stdin = dup(fileno(stdin));
|
|
||||||
|
|
||||||
if(use_stdin)
|
|
||||||
freopen(filename,"r",stdin);
|
|
||||||
else {
|
|
||||||
freopen("/dev/null","r",stdin);
|
|
||||||
argv[numarg++] = filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
main_to_fuzz(numarg,argv);
|
|
||||||
|
|
||||||
/* restore stdout */
|
|
||||||
fflush(stdout);
|
|
||||||
dup2(tmp_stdout, fileno(stdout));
|
|
||||||
close(tmp_stdout);
|
|
||||||
clearerr(stdout);
|
|
||||||
fsetpos(stdout,&pos_stdout);
|
|
||||||
|
|
||||||
/* restore stdin */
|
|
||||||
dup2(tmp_stdin, fileno(stdin));
|
|
||||||
close(tmp_stdin);
|
|
||||||
clearerr(stdin);
|
|
||||||
|
|
||||||
unlink(filename);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,136 +0,0 @@
|
||||||
/* fuzzer_tool_flac
|
|
||||||
* Copyright (C) 2023 Xiph.Org Foundation
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h> /* for memcpy */
|
|
||||||
#define FUZZ_TOOL_METAFLAC
|
|
||||||
#define fprintf(...)
|
|
||||||
#define printf(...)
|
|
||||||
#include "../src/metaflac/main.c"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
||||||
{
|
|
||||||
size_t size_left = size;
|
|
||||||
size_t arglen;
|
|
||||||
char * argv[64];
|
|
||||||
char exename[] = "metaflac";
|
|
||||||
char filename[] = "/tmp/fuzzXXXXXX";
|
|
||||||
char filename_stdin[] = "/tmp/fuzzXXXXXX";
|
|
||||||
int numarg = 0, maxarg;
|
|
||||||
int file_to_fuzz;
|
|
||||||
int tmp_stdout, tmp_stdin;
|
|
||||||
fpos_t pos_stdout;
|
|
||||||
bool use_stdin = false;
|
|
||||||
|
|
||||||
share__opterr = 0;
|
|
||||||
share__optind = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if(size < 2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
maxarg = data[0] & 15;
|
|
||||||
use_stdin = data[0] & 16;
|
|
||||||
size_left--;
|
|
||||||
|
|
||||||
argv[0] = exename;
|
|
||||||
numarg++;
|
|
||||||
|
|
||||||
/* Check whether input is zero delimited */
|
|
||||||
while((arglen = strnlen((char *)data+(size-size_left),size_left)) < size_left && numarg < maxarg) {
|
|
||||||
argv[numarg++] = (char *)data+(size-size_left);
|
|
||||||
size_left -= arglen + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create file to feed directly */
|
|
||||||
file_to_fuzz = mkstemp(filename);
|
|
||||||
if (file_to_fuzz < 0)
|
|
||||||
abort();
|
|
||||||
if(use_stdin) {
|
|
||||||
write(file_to_fuzz,data+(size-size_left),size_left/2);
|
|
||||||
size_left -= size_left/2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
write(file_to_fuzz,data+(size-size_left),size_left);
|
|
||||||
close(file_to_fuzz);
|
|
||||||
|
|
||||||
argv[numarg++] = filename;
|
|
||||||
|
|
||||||
/* Create file to feed to stdin */
|
|
||||||
if(use_stdin) {
|
|
||||||
file_to_fuzz = mkstemp(filename_stdin);
|
|
||||||
if (file_to_fuzz < 0)
|
|
||||||
abort();
|
|
||||||
write(file_to_fuzz,data+(size-size_left),size_left);
|
|
||||||
close(file_to_fuzz);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* redirect stdout */
|
|
||||||
fflush(stdout);
|
|
||||||
fgetpos(stdout,&pos_stdout);
|
|
||||||
tmp_stdout = dup(fileno(stdout));
|
|
||||||
freopen("/dev/null","w",stdout);
|
|
||||||
|
|
||||||
/* redirect stdin */
|
|
||||||
tmp_stdin = dup(fileno(stdin));
|
|
||||||
if(use_stdin)
|
|
||||||
freopen(filename_stdin,"r",stdin);
|
|
||||||
else {
|
|
||||||
freopen("/dev/null","r",stdin);
|
|
||||||
argv[numarg++] = filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
main_to_fuzz(numarg,argv);
|
|
||||||
|
|
||||||
/* restore stdout */
|
|
||||||
fflush(stdout);
|
|
||||||
dup2(tmp_stdout, fileno(stdout));
|
|
||||||
close(tmp_stdout);
|
|
||||||
clearerr(stdout);
|
|
||||||
fsetpos(stdout,&pos_stdout);
|
|
||||||
|
|
||||||
/* restore stdin */
|
|
||||||
dup2(tmp_stdin, fileno(stdin));
|
|
||||||
close(tmp_stdin);
|
|
||||||
clearerr(stdin);
|
|
||||||
|
|
||||||
unlink(filename);
|
|
||||||
|
|
||||||
if(use_stdin)
|
|
||||||
unlink(filename_stdin);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue