pax_global_header 0000666 0000000 0000000 00000000064 13767656611 0014534 g ustar 00root root 0000000 0000000 52 comment=66699cd994f6c1b0fde3c04943a5e608227d2985
audiowmark-simple-detection/ 0000775 0000000 0000000 00000000000 13767656611 0016506 5 ustar 00root root 0000000 0000000 audiowmark-simple-detection/.dockerignore 0000664 0000000 0000000 00000000057 13767656611 0021164 0 ustar 00root root 0000000 0000000 .git
.gitignore
Dockerfile
.dockerignore
.idea
audiowmark-simple-detection/.gitignore 0000664 0000000 0000000 00000000210 13767656611 0020467 0 ustar 00root root 0000000 0000000 autom4te.cache/
build-aux/
m4/
aclocal.m4
configure
config.h
config.h.in
config.log
config.status
Makefile
Makefile.in
libtool
stamp-h1
audiowmark-simple-detection/COPYING 0000664 0000000 0000000 00000104515 13767656611 0017547 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU 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. But first, please read
.
audiowmark-simple-detection/Dockerfile 0000664 0000000 0000000 00000001062 13767656611 0020477 0 ustar 00root root 0000000 0000000 FROM gcc:latest
RUN apt-get update && apt-get install -y build-essential
RUN apt-get install -y libfftw3-dev
RUN apt-get install -y libsndfile1-dev
RUN apt-get install -y automake
RUN apt-get install -y autoconf
RUN apt-get install -y libtool
RUN apt-get install -y autoconf-archive
RUN apt-get install -y libgcrypt20-dev
RUN apt-get install -y libzita-resampler-dev
RUN apt-get install -y libmpg123-dev
ADD . /audiowmark
WORKDIR /audiowmark
RUN ./autogen.sh
RUN make
RUN make install
VOLUME ["/data"]
WORKDIR /data
ENTRYPOINT ["/usr/local/bin/audiowmark"]
audiowmark-simple-detection/Makefile.am 0000664 0000000 0000000 00000000113 13767656611 0020535 0 ustar 00root root 0000000 0000000 SUBDIRS = src
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = README.adoc Dockerfile
audiowmark-simple-detection/NEWS 0000664 0000000 0000000 00000002123 13767656611 0017203 0 ustar 00root root 0000000 0000000 Overview of Changes in audiowmark-0.5.0:
* support HTTP Live Streaming for audio/video streaming
* fix floating point wav input
* improve command line option handling (ArgParser)
* support seeking on internal watermark state
Overview of Changes in audiowmark-0.4.2:
* compile fixes for g++-9 and clang++-10
* add experimental support for short payload
Overview of Changes in audiowmark-0.4.1:
* initial public release
Overview of Changes in audiowmark-0.4.0:
* add initial video watermarking support (videowmark)
Overview of Changes in audiowmark-0.3.0:
* replace padding at start with a partial B block
* add algorithm for decoding the watermark from short clips
Overview of Changes in audiowmark-0.2.1:
* add limiter to avoid clipping during watermark generation
Overview of Changes in audiowmark-0.2.0:
* support input/output streams
* support raw streams
* some performance optimizations
* unified logging and --quiet option
* improved mp3 detection to avoid false positives
* split up watermarking source (wmadd/wmget/wmcommon)
Overview of Changes in audiowmark-0.1.0:
* initial release
audiowmark-simple-detection/README.adoc 0000664 0000000 0000000 00000046154 13767656611 0020305 0 ustar 00root root 0000000 0000000 = audiowmark - Audio Watermarking
== Description
`audiowmark` is an Open Source (GPL) solution for audio watermarking.
A sound file is read by the software, and a 128-bit message is stored in a
watermark in the output sound file. For human listeners, the files typically
sound the same.
However, the 128-bit message can be retrieved from the output sound file. Our
tests show, that even if the file is converted to mp3 or ogg (with bitrate 128
kbit/s or higher), the watermark usually can be retrieved without problems. The
process of retrieving the message does not need the original audio file (blind
decoding).
Internally, audiowmark is using the patchwork algorithm to hide the data in the
spectrum of the audio file. The signal is split into 1024 sample frames. For
each frame, some pseoudo-randomly selected amplitudes of the frequency bands of
a 1024-value FFTs are increased or decreased slightly, which can be detected
later. The algorithm used here is inspired by
Martin Steinebach: Digitale Wasserzeichen für Audiodaten.
Darmstadt University of Technology 2004, ISBN 3-8322-2507-2
== Open Source License
`audiowmark` is *open source* software available under the *GPLv3
or later* license.
Copyright (C) 2018-2020 Stefan Westerfeld
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
== Adding a Watermark
To add a watermark to the soundfile in.wav with a 128-bit message (which is
specified as hex-string):
[subs=+quotes]
....
*$ audiowmark add in.wav out.wav 0123456789abcdef0011223344556677*
Input: in.wav
Output: out.wav
Message: 0123456789abcdef0011223344556677
Strength: 10
Time: 3:59
Sample Rate: 48000
Channels: 2
Data Blocks: 4
....
The most important options for adding a watermark are:
--key ::
Use watermarking key from file (see <>).
--strength ::
Set the watermarking strength (see <>).
== Retrieving a Watermark
To get the 128-bit message from the watermarked file, use:
[subs=+quotes]
....
*$ audiowmark get out.wav*
pattern 0:05 0123456789abcdef0011223344556677 1.324 0.059 A
pattern 0:57 0123456789abcdef0011223344556677 1.413 0.112 B
pattern 0:57 0123456789abcdef0011223344556677 1.368 0.086 AB
pattern 1:49 0123456789abcdef0011223344556677 1.302 0.098 A
pattern 2:40 0123456789abcdef0011223344556677 1.361 0.093 B
pattern 2:40 0123456789abcdef0011223344556677 1.331 0.096 AB
pattern all 0123456789abcdef0011223344556677 1.350 0.054
....
The output of `audiowmark get` is designed to be machine readable. Each line
that starts with `pattern` contains one decoded message. The fields are
seperated by one or more space characters. The first field is a *timestamp*
indicating the position of the data block. The second field is the *decoded
message*. For most purposes this is all you need to know.
The software was designed under the assumption that you - the user - will be
able to decide whether a message is correct or not. To do this, on watermarking
song files, you could list each message you embedded in a database. During
retrieval, you should look up each pattern `audiowmark get` outputs in the
database. If the message is not found, then you should assume that a decoding
error occurred. In our example each pattern was decoded correctly, because
the watermark was not damaged at all, but if you for instance use lossy
compression (with a low bitrate), it may happen that only some of the decoded
patterns are correct. Or none, if the watermark was damaged too much.
The third field is the *sync score* (higher is better). The synchronization
algorithm tries to find valid data blocks in the audio file, that become
candidates for decoding.
The fourth field is the *decoding error* (lower is better). During message
decoding, we use convolutional codes for error correction, to make the
watermarking more robust.
The fifth field is the *block type*. There are two types of data blocks,
A blocks and B blocks. A single data block can be decoded alone, as it
contains a complete message. However, if during watermark detection an
A block followed by a B block was found, these two can be decoded
together (then this field will be AB), resulting in even higher error
correction capacity than one block alone would have.
To improve the error correction capacity even further, the `all` pattern
combines all data blocks that are available. The combined decoded
message will often be the most reliable result (meaning that even if all
other patterns were incorrect, this could still be right).
The most important options for getting a watermark are:
--key ::
Use watermarking key from file (see <>).
--strength ::
Set the watermarking strength (see <>).
[[key]]
== Watermark Key
Since the software is Open Source, a watermarking key should be used to ensure
that the message bits cannot be retrieved by somebody else (which would also
allow removing the watermark without loss of quality). The watermark key
controls all pseudo-random parameters of the algorithm. This means that
it determines which frequency bands are increased or decreased to store a
0 bit or a 1 bit. Without the key, it is impossible to decode the message
bits from the audio file alone.
Our watermarking key is a 128-bit AES key. A key can be generated using
audiowmark gen-key test.key
and can be used for the add/get commands as follows:
audiowmark add --key test.key in.wav out.wav 0123456789abcdef0011223344556677
audiowmark get --key test.key out.wav
[[strength]]
== Watermark Strength
The watermark strength parameter affects how much the watermarking algorithm
modifies the input signal. A stronger watermark is more audible, but also more
robust against modifications. The default strength is 10. A watermark with that
strength is recoverable after mp3/ogg encoding with 128kbit/s or higher. In our
informal listening tests, this setting also has a very good subjective quality.
A higher strength (for instance 15) would be helpful for instance if robustness
against multiple conversions or conversions to low bit rates (i.e. 64kbit/s) is
desired.
A lower strength (for instance 6) makes the watermark less audible, but also
less robust. Strengths below 5 are not recommended. To set the strength, the
same value has to be passed during both, generation and retrieving the
watermark. Fractional strengths (like 7.5) are possible.
audiowmark add --strength 15 in.wav out.wav 0123456789abcdef0011223344556677
audiowmark get --strength 15 out.wav
== Short Payload (experimental)
By default, the watermark will store a 128-bit message. In this mode, we
recommend using a 128bit hash (or HMAC) as payload. No error checking is
performed, the user needs to test patterns that the watermarker decodes to
ensure that they really are one of the expected patterns, not a decoding
error.
As an alternative, an experimental short payload option is available, for very
short payloads (12, 16 or 20 bits). It is enabled using the `--short `
command line option, for instance for 16 bits:
audiowmark add --short 16 in.wav out.wav abcd
audiowmark get --short 16 out.wav
Internally, a larger set of bits is sent to ensure that decoded short patterns
are really valid, so in this mode, error checking is performed after decoding,
and only valid patterns are reported.
Besides error checking, the advantage of a short payload is that fewer bits
need to be sent, so decoding will more likely to be successful on shorter
clips.
== Video Files
For video files, `videowmark` can be used to add a watermark to the audio track
of video files. To add a watermark, use
[subs=+quotes]
....
*$ videowmark add in.avi out.avi 0123456789abcdef0011223344556677*
Audio Codec: -c:a mp3 -ab 128000
Input: in.avi
Output: out.avi
Message: 0123456789abcdef0011223344556677
Strength: 10
Time: 3:53
Sample Rate: 44100
Channels: 2
Data Blocks: 4
....
To detect a watermark, use
[subs=+quotes]
....
*$ videowmark get out.avi*
pattern 0:05 0123456789abcdef0011223344556677 1.294 0.142 A
pattern 0:57 0123456789abcdef0011223344556677 1.191 0.144 B
pattern 0:57 0123456789abcdef0011223344556677 1.242 0.145 AB
pattern 1:49 0123456789abcdef0011223344556677 1.215 0.120 A
pattern 2:40 0123456789abcdef0011223344556677 1.079 0.128 B
pattern 2:40 0123456789abcdef0011223344556677 1.147 0.126 AB
pattern all 0123456789abcdef0011223344556677 1.195 0.104
....
The key and strength can be set using the command line options
--key ::
Use watermarking key from file (see <>).
--strength ::
Set the watermarking strength (see <>).
Videos can be watermarked on-the-fly using <>.
== Output as Stream
Usually, an input file is read, watermarked and an output file is written.
This means that it takes some time before the watermarked file can be used.
An alternative is to output the watermarked file as stream to stdout. One use
case is sending the watermarked file to a user via network while the
watermarker is still working on the rest of the file. Here is an example how to
watermark a wav file to stdout:
audiowmark add in.wav - 0123456789abcdef0011223344556677 | play -
In this case the file in.wav is read, watermarked, and the output is sent
to stdout. The "play -" can start playing the watermarked stream while the
rest of the file is being watermarked.
If - is used as output, the output is a valid .wav file, so the programs
running after `audiowmark` will be able to determine sample rate, number of
channels, bit depth, encoding and so on from the wav header.
Note that all input formats supported by audiowmark can be used in this way,
for instance flac/mp3:
audiowmark add in.flac - 0123456789abcdef0011223344556677 | play -
audiowmark add in.mp3 - 0123456789abcdef0011223344556677 | play -
== Input from Stream
Similar to the output, the `audiowmark` input can be a stream. In this case,
the input must be a valid .wav file. The watermarker will be able to
start watermarking the input stream before all data is available. An
example would be:
cat in.wav | audiowmark add - out.wav 0123456789abcdef0011223344556677
It is possible to do both, input from stream and output as stream.
cat in.wav | audiowmark add - - 0123456789abcdef0011223344556677 | play -
Streaming input is also supported for watermark detection.
cat in.wav | audiowmark get -
== Raw Streams
So far, all streams described here are essentially wav streams, which means
that the wav header allows `audiowmark` to determine sample rate, number of
channels, bit depth, encoding and so forth from the stream itself, and the a
wav header is written for the program after `audiowmark`, so that this can
figure out the parameters of the stream.
There are two cases where this is problematic. The first case is if the full
length of the stream is not known at the time processing starts. Then a wav
header cannot be used, as the wav file contains the length of the stream. The
second case is that the program before or after `audiowmark` doesn't support wav
headers.
For these two cases, raw streams are available. The idea is to set all
information that is needed like sample rate, number of channels,... manually.
Then, headerless data can be processed from stdin and/or sent to stdout.
--input-format raw::
--output-format raw::
--format raw::
These can be used to set the input format or output format to raw. The
last version sets both, input and output format to raw.
--raw-rate ::
This should be used to set the sample rate. The input sample rate and
the output sample rate will always be the same (no resampling is
done by the watermarker). There is no default for the sampling rate,
so this parameter must always be specified for raw streams.
--raw-input-bits ::
--raw-output-bits ::
--raw-bits ::
The options can be used to set the input number of bits, the output number
of bits or both. The number of bits can either be `16` or `24`. The default
number of bits is `16`.
--raw-input-endian ::
--raw-output-endian ::
--raw-endian ::
These options can be used to set the input/output endianness or both.
The parameter can either be `little` or `big`. The default
endianness is `little`.
--raw-input-encoding ::
--raw-output-encoding ::
--raw-encoding ::
These options can be used to set the input/output encoding or both.
The parameter can either be `signed` or `unsigned`. The
default encoding is `signed`.
--raw-channels ::
This can be used to set the number of channels. Note that the number
of input channels and the number of output channels must always be the
same. The watermarker has been designed and tested for stereo files,
so the number of channels should really be `2`. This is also the
default.
[[hls]]
== HTTP Live Streaming
=== Introduction for HLS
HTTP Live Streaming (HLS) is a protocol to deliver audio or video streams via
HTTP. One example for using HLS in practice would be: a user watches a video
in a web browser with a player like `hls.js`. The user is free to
play/pause/seek the video as he wants. `audiowmark` can watermark the audio
content while it is being transmitted to the user.
HLS splits the contents of each stream into small segments. For the watermarker
this means that if the user seeks to a position far ahead in the stream, the
server needs to start sending segments from where the new play position is, but
everything in between can be ignored.
Another important property of HLS is that it allows separate segments for the
video and audio stream of a video. Since we watermark only the audio track of a
video, the video segments can be sent as they are (and different users can get
the same video segments). What is watermarked are the audio segments only, so
here instead of sending the original audio segments to the user, the audio
segments are watermarked individually for each user, and then transmitted.
Everything necessary to watermark HLS audio segments is available within
`audiowmark`. The server side support which is necessary to send the right
watermarked segment to the right user is not included.
[[hls-requirements]]
=== HLS Requirements
HLS support requires some headers/libraries from ffmpeg:
* libavcodec
* libavformat
* libavutil
* libswresample
To enable these as dependencies and build `audiowmark` with HLS support, use the
`--with-ffmpeg` configure option:
[subs=+quotes]
....
*$ ./configure --with-ffmpeg*
....
In addition to the libraries, `audiowmark` also uses the two command line
programs from ffmpeg, so they need to be installed:
* ffmpeg
* ffprobe
=== Preparing HLS segments
The first step for preparing content for streaming with HLS would be splitting
a video into segments. For this documentation, we use a very simple example
using ffmpeg. No matter what the original codec was, at this point we force
transcoding to AAC with our target bit rate, because during delivery the stream
will be in AAC format.
[subs=+quotes]
....
*$ ffmpeg -i video.mp4 -f hls -master_pl_name replay.m3u8 -c:a aac -ab 192k \
-var_stream_map "a:0,agroup:aud v:0,agroup:aud" \
-hls_playlist_type vod -hls_list_size 0 -hls_time 10 vs%v/out.m3u8*
....
This splits the `video.mp4` file into an audio stream of segments in the `vs0`
directory and a video stream of segments in the `vs1` directory. Each segment
is approximately 10 seconds long, and a master playlist is written to
`replay.m3u8`.
Now we can add the relevant audio context to each audio ts segment. This is
necessary so that when the segment is watermarked in order to be transmitted to
the user, `audiowmark` will have enough context available before and after the
segment to create a watermark which sounds correct over segment boundaries.
[subs=+quotes]
....
*$ audiowmark hls-prepare vs0 vs0prep out.m3u8 video.mp4*
AAC Bitrate: 195641 (detected)
Segments: 18
Time: 2:53
....
This steps reads the audio playlist `vs0/out.m3u8` and writes all segments
contained in this audio playlist to a new directory `vs0prep` which
contains the audio segments prepared for watermarking.
The last argument in this command line is `video.mp4` again. All audio
that is watermarked is taken from this audio master. It could also be
supplied in `wav` format. This makes a difference if you use lossy
compression as target format (for instance AAC), but your original
video has an audio stream with higher quality (i.e. lossless).
=== Watermarking HLS segments
So with all preparations made, what would the server have to do to send a
watermarked version of the 6th audio segment `vs0prep/out5.ts`?
[subs=+quotes]
....
*$ audiowmark hls-add vs0prep/out5.ts send5.ts 0123456789abcdef0011223344556677*
Message: 0123456789abcdef0011223344556677
Strength: 10
Time: 0:15
Sample Rate: 44100
Channels: 2
Data Blocks: 0
AAC Bitrate: 195641
....
So instead of sending out5.ts (which has no watermark) to the user, we would
send send5.ts, which is watermarked.
In a real-world use case, it is likely that the server would supply the input
segment on stdin and send the output segment as written to stdout, like this
[subs=+quotes]
....
*$ [...] | audiowmark hls-add - - 0123456789abcdef0011223344556677 | [...]*
[...]
....
The usual parameters are supported in `audiowmark hls-add`, like
--key ::
Use watermarking key from file (see <>).
--strength ::
Set the watermarking strength (see <>).
The AAC bitrate for the output segment can be set using:
--bit-rate ::
Set the AAC bit-rate for the generated watermarked segment.
The rules for the AAC bit-rate of the newly encoded watermarked segment are:
* if the --bit-rate option is used during `hls-add`, this bit-rate will be used
* otherwise, if the `--bit-rate` option is used during `hls-prepare`, this bit-rate will be used
* otherwise, the bit-rate of the input material is detected during `hls-prepare`
== Dependencies
If you compile from source, `audiowmark` needs the following libraries:
* libfftw3
* libsndfile
* libgcrypt
* libzita-resampler
* libmpg123
If you want to build with HTTP Live Streaming support, see also
<>.
== Building fftw
`audiowmark` needs the single prevision variant of fftw3.
If you are building fftw3 from source, use the `--enable-float`
configure parameter to build it, e.g.::
cd ${FFTW3_SOURCE}
./configure --enable-float --enable-sse && \
make && \
sudo make install
or, when building from git
cd ${FFTW3_GIT}
./bootstrap.sh --enable-shared --enable-sse --enable-float && \
make && \
sudo make install
== Docker Build
You should be able to execute `audiowmark` via Docker.
Example that outputs the usage message:
docker build -t audiowmark .
docker run -v :/data -it audiowmark -h
audiowmark-simple-detection/autogen.sh 0000775 0000000 0000000 00000001373 13767656611 0020513 0 ustar 00root root 0000000 0000000 #!/bin/bash
if automake --version >/dev/null 2>&1; then
:
else
echo "You need to have automake installed to build this package"
DIE=1
fi
if autoconf --version >/dev/null 2>&1; then
:
else
echo "You need to have autoconf installed to build this package"
DIE=1
fi
if libtoolize --version >/dev/null 2>&1; then
:
elif glibtoolize --version >/dev/null 2>&1; then # macOS
:
else
echo "You need to have libtool installed to build this package"
DIE=1
fi
if pkg-config --version >/dev/null 2>&1; then
:
else
echo "You need to have pkg-config installed to build this package"
DIE=1
fi
# bail out as scheduled
test "0$DIE" -gt 0 && exit 1
echo "Running: autoreconf -i && ./configure $@"
autoreconf -f -i -Wno-portability && ./configure "$@"
audiowmark-simple-detection/configure.ac 0000664 0000000 0000000 00000005604 13767656611 0021001 0 ustar 00root root 0000000 0000000 AC_INIT([audiowmark], [0.5.0])
AC_CONFIG_SRCDIR([src/audiowmark.cc])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CXX
AC_PROG_LIBTOOL
dnl
dnl sndfile
dnl
AC_DEFUN([AC_SNDFILE_REQUIREMENTS],
[
PKG_CHECK_MODULES(SNDFILE, [sndfile])
AC_SUBST(SNDFILE_CFLAGS)
AC_SUBST(SNDFILE_LIBS)
])
dnl
dnl libmpg123
dnl
AC_DEFUN([AC_LIBMPG123_REQUIREMENTS],
[
PKG_CHECK_MODULES(LIBMPG123, [libmpg123])
AC_SUBST(LIBMPG123_CFLAGS)
AC_SUBST(LIBMPG123_LIBS)
])
dnl
dnl zita resampler
dnl
AC_DEFUN([AC_ZITA_REQUIREMENTS],
[
AC_CHECK_LIB(zita-resampler, _Z28zita_resampler_major_versionv,[],
[
AC_MSG_ERROR([You need to install libzita-resampler to build this package.])
]
)
])
dnl ffmpeg stuff
AC_DEFUN([AC_FFMPEG_REQUIREMENTS],
[
PKG_CHECK_MODULES(FFMPEG, libavcodec libavformat libavutil libswresample)
])
dnl FFTW3
AC_DEFUN([AC_FFTW_CHECK],
[
dnl this used to be optional, but is currently required
PKG_CHECK_MODULES(FFTW, [fftw3f])
SPECTMORPH_HAVE_FFTW=1
if test $SPECTMORPH_HAVE_FFTW -gt 0; then
fftw_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $FFTW_CFLAGS"
AC_MSG_CHECKING([whether FFTW is recent enough])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([
#include "fftw3.h"
int x = FFTW_WISDOM_ONLY;
])
],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
SPECTMORPH_HAVE_FFTW=0
])
fi
CFLAGS="$fftw_save_CFLAGS"
AC_DEFINE_UNQUOTED(SPECTMORPH_HAVE_FFTW, $SPECTMORPH_HAVE_FFTW, [Whether libfftw3 is available])
])
AC_SNDFILE_REQUIREMENTS
AC_LIBMPG123_REQUIREMENTS
AC_ZITA_REQUIREMENTS
AC_FFTW_CHECK
AM_PATH_LIBGCRYPT
dnl -------------------- ffmpeg is optional ----------------------------
AC_ARG_WITH([ffmpeg], [AS_HELP_STRING([--with-ffmpeg], [build against ffmpeg libraries])], [], [with_ffmpeg=no])
if test "x$with_ffmpeg" != "xno"; then
AC_FFMPEG_REQUIREMENTS
HAVE_FFMPEG=1
else
HAVE_FFMPEG=0
fi
AC_DEFINE_UNQUOTED(HAVE_FFMPEG, $HAVE_FFMPEG, [whether ffmpeg libs are available])
AM_CONDITIONAL([COND_WITH_FFMPEG], [test "x$with_ffmpeg" != "xno"])
dnl -------------------------------------------------------------------------
# need c++14 mode
AX_CXX_COMPILE_STDCXX_14(ext)
# use -Wall / -pthread if available
AC_LANG_PUSH([C++])
AX_CHECK_COMPILE_FLAG([-Wall], [CXXFLAGS="$CXXFLAGS -Wall"])
AX_CHECK_COMPILE_FLAG([-pthread], [CXXFLAGS="$CXXFLAGS -pthread"])
AC_LANG_POP([C++])
# Less cluttered build output
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
# Output summary message
echo
echo "---------------------------------------------------------------------------"
echo "$PACKAGE_NAME $PACKAGE_VERSION"
echo "---------------------------------------------------------------------------"
echo " * use ffmpeg libs: $with_ffmpeg (required for HLS)"
audiowmark-simple-detection/src/ 0000775 0000000 0000000 00000000000 13767656611 0017275 5 ustar 00root root 0000000 0000000 audiowmark-simple-detection/src/.gitignore 0000664 0000000 0000000 00000000212 13767656611 0021260 0 ustar 00root root 0000000 0000000 *.o
.deps/
.libs/
test/
audiowmark
testconvcode
testmp3
testrandom
teststream
testlimiter
testhls
testmpegts
testshortcode
testthreadpool
audiowmark-simple-detection/src/Makefile.am 0000664 0000000 0000000 00000003617 13767656611 0021340 0 ustar 00root root 0000000 0000000 bin_PROGRAMS = audiowmark
dist_bin_SCRIPTS = videowmark
COMMON_SRC = utils.hh utils.cc convcode.hh convcode.cc random.hh random.cc wavdata.cc wavdata.hh \
audiostream.cc audiostream.hh sfinputstream.cc sfinputstream.hh stdoutwavoutputstream.cc stdoutwavoutputstream.hh \
sfoutputstream.cc sfoutputstream.hh rawinputstream.cc rawinputstream.hh rawoutputstream.cc rawoutputstream.hh \
rawconverter.cc rawconverter.hh mp3inputstream.cc mp3inputstream.hh wmcommon.cc wmcommon.hh fft.cc fft.hh \
limiter.cc limiter.hh shortcode.cc shortcode.hh mpegts.cc mpegts.hh hls.cc hls.hh audiobuffer.hh \
wmget.cc wmadd.cc syncfinder.cc syncfinder.hh wmspeed.cc wmspeed.hh threadpool.cc threadpool.hh \
resample.cc resample.hh
COMMON_LIBS = $(SNDFILE_LIBS) $(FFTW_LIBS) $(LIBGCRYPT_LIBS) $(LIBMPG123_LIBS) $(FFMPEG_LIBS)
audiowmark_SOURCES = audiowmark.cc $(COMMON_SRC)
audiowmark_LDFLAGS = $(COMMON_LIBS)
noinst_PROGRAMS = testconvcode testrandom testmp3 teststream testlimiter testshortcode testmpegts testthreadpool
testconvcode_SOURCES = testconvcode.cc $(COMMON_SRC)
testconvcode_LDFLAGS = $(COMMON_LIBS)
testrandom_SOURCES = testrandom.cc $(COMMON_SRC)
testrandom_LDFLAGS = $(COMMON_LIBS)
testmp3_SOURCES = testmp3.cc $(COMMON_SRC)
testmp3_LDFLAGS = $(COMMON_LIBS)
teststream_SOURCES = teststream.cc $(COMMON_SRC)
teststream_LDFLAGS = $(COMMON_LIBS)
testlimiter_SOURCES = testlimiter.cc $(COMMON_SRC)
testlimiter_LDFLAGS = $(COMMON_LIBS)
testshortcode_SOURCES = testshortcode.cc $(COMMON_SRC)
testshortcode_LDFLAGS = $(COMMON_LIBS)
testmpegts_SOURCES = testmpegts.cc $(COMMON_SRC)
testmpegts_LDFLAGS = $(COMMON_LIBS)
testthreadpool_SOURCES = testthreadpool.cc $(COMMON_SRC)
testthreadpool_LDFLAGS = $(COMMON_LIBS)
if COND_WITH_FFMPEG
COMMON_SRC += hlsoutputstream.cc hlsoutputstream.hh
noinst_PROGRAMS += testhls
testhls_SOURCES = testhls.cc $(COMMON_SRC)
testhls_LDFLAGS = $(COMMON_LIBS)
endif
audiowmark-simple-detection/src/TODO 0000664 0000000 0000000 00000000266 13767656611 0017771 0 ustar 00root root 0000000 0000000 speed detection:
- remove pad start scaling
- test code
- document in README
possible improvements:
- dynamic bit strength
videowmark:
opus length ffprobe -show_format phil.mkv
audiowmark-simple-detection/src/audiobuffer.hh 0000664 0000000 0000000 00000002751 13767656611 0022116 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef AUDIOWMARK_AUDIO_BUFFER_HH
#define AUDIOWMARK_AUDIO_BUFFER_HH
#include
class AudioBuffer
{
const int n_channels = 0;
std::vector buffer;
public:
AudioBuffer (int n_channels) :
n_channels (n_channels)
{
}
void
write_frames (const std::vector& samples)
{
buffer.insert (buffer.end(), samples.begin(), samples.end());
}
std::vector
read_frames (size_t frames)
{
assert (frames * n_channels <= buffer.size());
const auto begin = buffer.begin();
const auto end = begin + frames * n_channels;
std::vector result (begin, end);
buffer.erase (begin, end);
return result;
}
size_t
can_read_frames() const
{
return buffer.size() / n_channels;
}
};
#endif /* AUDIOWMARK_AUDIO_BUFFER_HH */
audiowmark-simple-detection/src/audiostream.cc 0000664 0000000 0000000 00000005413 13767656611 0022124 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "audiostream.hh"
#include "wmcommon.hh"
#include "sfinputstream.hh"
#include "sfoutputstream.hh"
#include "mp3inputstream.hh"
#include "rawconverter.hh"
#include "rawoutputstream.hh"
#include "stdoutwavoutputstream.hh"
using std::string;
AudioStream::~AudioStream()
{
}
std::unique_ptr
AudioInputStream::create (const string& filename, Error& err)
{
std::unique_ptr in_stream;
if (Params::input_format == Format::AUTO)
{
SFInputStream *sistream = new SFInputStream();
in_stream.reset (sistream);
err = sistream->open (filename);
if (err && MP3InputStream::detect (filename))
{
MP3InputStream *mistream = new MP3InputStream();
in_stream.reset (mistream);
err = mistream->open (filename);
if (err)
return nullptr;
}
else if (err)
return nullptr;
}
else
{
RawInputStream *ristream = new RawInputStream();
in_stream.reset (ristream);
err = ristream->open (filename, Params::raw_input_format);
if (err)
return nullptr;
}
return in_stream;
}
std::unique_ptr
AudioOutputStream::create (const string& filename, int n_channels, int sample_rate, int bit_depth, size_t n_frames, Error& err)
{
std::unique_ptr out_stream;
if (Params::output_format == Format::RAW)
{
RawOutputStream *rostream = new RawOutputStream();
out_stream.reset (rostream);
err = rostream->open (filename, Params::raw_output_format);
if (err)
return nullptr;
}
else if (filename == "-")
{
StdoutWavOutputStream *swstream = new StdoutWavOutputStream();
out_stream.reset (swstream);
err = swstream->open (n_channels, sample_rate, bit_depth, n_frames);
if (err)
return nullptr;
}
else
{
SFOutputStream *sfostream = new SFOutputStream();
out_stream.reset (sfostream);
err = sfostream->open (filename, n_channels, sample_rate, bit_depth);
if (err)
return nullptr;
}
return out_stream;
}
audiowmark-simple-detection/src/audiostream.hh 0000664 0000000 0000000 00000003404 13767656611 0022134 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef AUDIOWMARK_AUDIO_STREAM_HH
#define AUDIOWMARK_AUDIO_STREAM_HH
#include
#include
#include "utils.hh"
class AudioStream
{
public:
virtual int bit_depth() const = 0;
virtual int sample_rate() const = 0;
virtual int n_channels() const = 0;
virtual ~AudioStream();
};
class AudioInputStream : public AudioStream
{
public:
static std::unique_ptr create (const std::string& filename, Error& err);
// for streams that do not know the number of frames in advance (i.e. raw input stream)
static constexpr size_t N_FRAMES_UNKNOWN = ~size_t (0);
virtual size_t n_frames() const = 0;
virtual Error read_frames (std::vector& samples, size_t count) = 0;
};
class AudioOutputStream : public AudioStream
{
public:
static std::unique_ptr create (const std::string& filename,
int n_channels, int sample_rate, int bit_depth, size_t n_frames, Error& err);
virtual Error write_frames (const std::vector& frames) = 0;
virtual Error close() = 0;
};
#endif /* AUDIOWMARK_AUDIO_STREAM_HH */
audiowmark-simple-detection/src/audiowmark.cc 0000664 0000000 0000000 00000046502 13767656611 0021756 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include "wavdata.hh"
#include "utils.hh"
#include "random.hh"
#include "wmcommon.hh"
#include "shortcode.hh"
#include "hls.hh"
#include
#include "config.h"
using std::string;
using std::vector;
using std::min;
using std::max;
void
print_usage()
{
printf ("usage: audiowmark [ ... ]\n");
printf ("\n");
printf ("Commands:\n");
printf (" * create a watermarked wav file with a message\n");
printf (" audiowmark add \n");
printf ("\n");
printf (" * retrieve message\n");
printf (" audiowmark get \n");
printf ("\n");
printf (" * compare watermark message with expected message\n");
printf (" audiowmark cmp \n");
printf ("\n");
printf (" * generate 128-bit watermarking key, to be used with --key option\n");
printf (" audiowmark gen-key \n");
printf ("\n");
printf ("Global options:\n");
printf (" --strength set watermark strength [%.6g]\n", Params::water_delta * 1000);
printf (" --linear disable non-linear bit storage\n");
printf (" --short enable short payload mode\n");
printf (" --key load watermarking key from file\n");
printf (" -q, --quiet disable information messages\n");
printf ("\n");
printf (" --input-format raw use raw stream as input\n");
printf (" --output-format raw use raw stream as output\n");
printf (" --format raw use raw stream as input and output\n");
printf ("\n");
printf ("The options to set the raw stream parameters (such as --raw-rate\n");
printf ("or --raw-channels) are documented in the README file.\n");
printf ("\n");
printf ("HLS command help can be displayed using --help-hls\n");
}
void
print_usage_hls()
{
printf ("usage: audiowmark [ ... ]\n");
printf ("\n");
printf ("Commands:\n");
printf (" * prepare HLS segments for streaming:\n");
printf (" audiowmark hls-prepare \n");
printf ("\n");
printf (" * watermark one HLS segment:\n");
printf (" audiowmark hls-add \n");
printf ("\n");
printf ("Global options:\n");
printf (" -q, --quiet disable information messages\n");
printf (" --bit-rate set AAC bitrate\n");
printf ("\n");
printf ("Watermarking options:\n");
printf (" --strength set watermark strength [%.6g]\n", Params::water_delta * 1000);
printf (" --short enable short payload mode\n");
printf (" --key load watermarking key from file\n");
}
Format
parse_format (const string& str)
{
if (str == "raw")
return Format::RAW;
if (str == "auto")
return Format::AUTO;
error ("audiowmark: unsupported format '%s'\n", str.c_str());
exit (1);
}
RawFormat::Endian
parse_endian (const string& str)
{
if (str == "little")
return RawFormat::Endian::LITTLE;
if (str == "big")
return RawFormat::Endian::BIG;
error ("audiowmark: unsupported endianness '%s'\n", str.c_str());
exit (1);
}
RawFormat::Encoding
parse_encoding (const string& str)
{
if (str == "signed")
return RawFormat::Encoding::SIGNED;
if (str == "unsigned")
return RawFormat::Encoding::UNSIGNED;
error ("audiowmark: unsupported encoding '%s'\n", str.c_str());
exit (1);
}
int
gentest (const string& infile, const string& outfile)
{
printf ("generating test sample from '%s' to '%s'\n", infile.c_str(), outfile.c_str());
WavData wav_data;
Error err = wav_data.load (infile);
if (err)
{
error ("audiowmark: error loading %s: %s\n", infile.c_str(), err.message());
return 1;
}
const vector& in_signal = wav_data.samples();
vector out_signal;
/* 2:45 of audio - this is approximately the minimal amount of audio data required
* for storing three separate watermarks with a 128-bit encoded message */
const size_t offset = 0 * wav_data.n_channels() * wav_data.sample_rate();
const size_t n_samples = 165 * wav_data.n_channels() * wav_data.sample_rate();
if (in_signal.size() < (offset + n_samples))
{
error ("audiowmark: input file %s too short\n", infile.c_str());
return 1;
}
for (size_t i = 0; i < n_samples; i++)
{
out_signal.push_back (in_signal[i + offset]);
}
WavData out_wav_data (out_signal, wav_data.n_channels(), wav_data.sample_rate(), wav_data.bit_depth());
err = out_wav_data.save (outfile);
if (err)
{
error ("audiowmark: error saving %s: %s\n", outfile.c_str(), err.message());
return 1;
}
return 0;
}
int
cut_start (const string& infile, const string& outfile, const string& start_str)
{
WavData wav_data;
Error err = wav_data.load (infile);
if (err)
{
error ("audiowmark: error loading %s: %s\n", infile.c_str(), err.message());
return 1;
}
size_t start = atoi (start_str.c_str());
const vector& in_signal = wav_data.samples();
vector out_signal;
for (size_t i = start * wav_data.n_channels(); i < in_signal.size(); i++)
out_signal.push_back (in_signal[i]);
WavData out_wav_data (out_signal, wav_data.n_channels(), wav_data.sample_rate(), wav_data.bit_depth());
err = out_wav_data.save (outfile);
if (err)
{
error ("audiowmark: error saving %s: %s\n", outfile.c_str(), err.message());
return 1;
}
return 0;
}
int
test_subtract (const string& infile1, const string& infile2, const string& outfile)
{
WavData in1_data;
Error err = in1_data.load (infile1);
if (err)
{
error ("audiowmark: error loading %s: %s\n", infile1.c_str(), err.message());
return 1;
}
WavData in2_data;
err = in2_data.load (infile2);
if (err)
{
error ("audiowmark: error loading %s: %s\n", infile2.c_str(), err.message());
return 1;
}
if (in1_data.n_values() != in2_data.n_values())
{
int64_t l1 = in1_data.n_values();
int64_t l2 = in2_data.n_values();
size_t delta = std::abs (l1 - l2);
warning ("audiowmark: size mismatch: %zd frames\n", delta / in1_data.n_channels());
warning (" - %s frames: %zd\n", infile1.c_str(), in1_data.n_values() / in1_data.n_channels());
warning (" - %s frames: %zd\n", infile2.c_str(), in2_data.n_values() / in2_data.n_channels());
}
assert (in1_data.n_channels() == in2_data.n_channels());
const auto& in1_signal = in1_data.samples();
const auto& in2_signal = in2_data.samples();
size_t len = std::min (in1_data.n_values(), in2_data.n_values());
vector out_signal;
for (size_t i = 0; i < len; i++)
out_signal.push_back (in1_signal[i] - in2_signal[i]);
WavData out_wav_data (out_signal, in1_data.n_channels(), in1_data.sample_rate(), in1_data.bit_depth());
err = out_wav_data.save (outfile);
if (err)
{
error ("audiowmark: error saving %s: %s\n", outfile.c_str(), err.message());
return 1;
}
return 0;
}
int
test_snr (const string& orig_file, const string& wm_file)
{
WavData orig_data;
Error err = orig_data.load (orig_file);
if (err)
{
error ("audiowmark: error loading %s: %s\n", orig_file.c_str(), err.message());
return 1;
}
WavData wm_data;
err = wm_data.load (wm_file);
if (err)
{
error ("audiowmark: error loading %s: %s\n", wm_file.c_str(), err.message());
return 1;
}
assert (orig_data.n_values() == wm_data.n_values());
assert (orig_data.n_channels() == orig_data.n_channels());
const auto& orig_signal = orig_data.samples();
const auto& wm_signal = wm_data.samples();
double snr_delta_power = 0;
double snr_signal_power = 0;
for (size_t i = 0; i < orig_signal.size(); i++)
{
const double orig = orig_signal[i]; // original sample
const double delta = orig_signal[i] - wm_signal[i]; // watermark
snr_delta_power += delta * delta;
snr_signal_power += orig * orig;
}
printf ("%f\n", 10 * log10 (snr_signal_power / snr_delta_power));
return 0;
}
int
test_clip (const string& in_file, const string& out_file, int seed, int time_seconds)
{
WavData in_data;
Error err = in_data.load (in_file);
if (err)
{
error ("audiowmark: error loading %s: %s\n", in_file.c_str(), err.message());
return 1;
}
bool done = false;
Random rng (seed, /* there is no stream for this test */ Random::Stream::data_up_down);
size_t start_point, end_point;
do
{
// this is unbiased only if 2 * block_size + time_seconds is smaller than overall file length
const size_t values_per_block = (mark_sync_frame_count() + mark_data_frame_count()) * Params::frame_size * in_data.n_channels();
start_point = 2 * values_per_block * rng.random_double();
start_point /= in_data.n_channels();
end_point = start_point + time_seconds * in_data.sample_rate();
if (end_point < in_data.n_values() / in_data.n_channels())
done = true;
}
while (!done);
//printf ("%.3f %.3f\n", start_point / double (in_data.sample_rate()), end_point / double (in_data.sample_rate()));
vector out_signal (in_data.samples().begin() + start_point * in_data.n_channels(),
in_data.samples().begin() + end_point * in_data.n_channels());
WavData out_wav_data (out_signal, in_data.n_channels(), in_data.sample_rate(), in_data.bit_depth());
err = out_wav_data.save (out_file);
if (err)
{
error ("audiowmark: error saving %s: %s\n", out_file.c_str(), err.message());
return 1;
}
return 0;
}
int
test_speed (int seed)
{
Random rng (seed, /* there is no stream for this test */ Random::Stream::data_up_down);
double low = 0.85;
double high = 1.15;
printf ("%.6f\n", low + (rng() / double (UINT64_MAX)) * (high - low));
return 0;
}
int
gen_key (const string& outfile)
{
FILE *f = fopen (outfile.c_str(), "w");
if (!f)
{
error ("audiowmark: error writing to file %s\n", outfile.c_str());
return 1;
}
fprintf (f, "# watermarking key for audiowmark\n\nkey %s\n", Random::gen_key().c_str());
fclose (f);
return 0;
}
class ArgParser
{
vector m_args;
bool
starts_with (const string& s, const string& start)
{
return s.substr (0, start.size()) == start;
}
public:
ArgParser (int argc, char **argv)
{
for (int i = 1; i < argc; i++)
m_args.push_back (argv[i]);
}
bool
parse_cmd (const string& cmd)
{
for (auto it = m_args.begin(); it != m_args.end(); it++)
{
if (!it->empty() && (*it)[0] != '-')
{
if (*it == cmd)
{
m_args.erase (it);
return true;
}
else /* first positional arg is not cmd */
{
return false;
}
}
}
return false;
}
bool
parse_opt (const string& option, string& out_s)
{
bool found_option = false;
auto it = m_args.begin();
while (it != m_args.end())
{
auto next_it = it + 1;
if (*it == option && next_it != m_args.end()) /* --option foo */
{
out_s = *next_it;
next_it = m_args.erase (it, it + 2);
found_option = true;
}
else if (starts_with (*it, (option + "="))) /* --option=foo */
{
out_s = it->substr (option.size() + 1);
next_it = m_args.erase (it);
found_option = true;
}
it = next_it;
}
return found_option;
}
bool
parse_opt (const string& option, int& out_i)
{
string out_s;
if (parse_opt (option, out_s))
{
out_i = atoi (out_s.c_str());
return true;
}
return false;
}
bool
parse_opt (const string& option, float& out_f)
{
string out_s;
if (parse_opt (option, out_s))
{
out_f = atof (out_s.c_str());
return true;
}
return false;
}
bool
parse_opt (const string& option)
{
for (auto it = m_args.begin(); it != m_args.end(); it++)
{
if (*it == option) /* --option */
{
m_args.erase (it);
return true;
}
}
return false;
}
bool
parse_args (size_t expected_count, vector& out_args)
{
if (m_args.size() == expected_count)
{
out_args = m_args;
return true;
}
return false;
}
};
void
parse_shared_options (ArgParser& ap)
{
int i;
float f;
string s;
if (ap.parse_opt ("--strength", f))
{
Params::water_delta = f / 1000;
}
if (ap.parse_opt ("--key", s))
{
Params::have_key++;
Random::load_global_key (s);
}
if (ap.parse_opt ("--test-key", i))
{
Params::have_key++;
Random::set_global_test_key (i);
}
if (ap.parse_opt ("--short", i))
{
Params::payload_size = i;
if (!short_code_init (Params::payload_size))
{
error ("audiowmark: unsupported short payload size %zd\n", Params::payload_size);
exit (1);
}
Params::payload_short = true;
}
ap.parse_opt ("--frames-per-bit", Params::frames_per_bit);
if (ap.parse_opt ("--linear"))
{
Params::mix = false;
}
if (Params::have_key > 1)
{
error ("audiowmark: watermark key can at most be set once (--key / --test-key option)\n");
exit (1);
}
}
void
parse_add_options (ArgParser& ap)
{
string s;
int i;
ap.parse_opt ("--set-input-label", Params::input_label);
ap.parse_opt ("--set-output-label", Params::output_label);
if (ap.parse_opt ("--snr"))
{
Params::snr = true;
}
if (ap.parse_opt ("--input-format", s))
{
Params::input_format = parse_format (s);
}
if (ap.parse_opt ("--output-format", s))
{
Params::output_format = parse_format (s);
}
if (ap.parse_opt ("--format", s))
{
Params::input_format = Params::output_format = parse_format (s);
}
if (ap.parse_opt ("--raw-input-bits", i))
{
Params::raw_input_format.set_bit_depth (i);
}
if (ap.parse_opt ("--raw-output-bits", i))
{
Params::raw_output_format.set_bit_depth (i);
}
if (ap.parse_opt ("--raw-bits", i))
{
Params::raw_input_format.set_bit_depth (i);
Params::raw_output_format.set_bit_depth (i);
}
if (ap.parse_opt ( "--raw-input-endian", s))
{
auto e = parse_endian (s);
Params::raw_input_format.set_endian (e);
}
if (ap.parse_opt ("--raw-output-endian", s))
{
auto e = parse_endian (s);
Params::raw_output_format.set_endian (e);
}
if (ap.parse_opt ("--raw-endian", s))
{
auto e = parse_endian (s);
Params::raw_input_format.set_endian (e);
Params::raw_output_format.set_endian (e);
}
if (ap.parse_opt ("--raw-input-encoding", s))
{
auto e = parse_encoding (s);
Params::raw_input_format.set_encoding (e);
}
if (ap.parse_opt ("--raw-output-encoding", s))
{
auto e = parse_encoding (s);
Params::raw_output_format.set_encoding (e);
}
if (ap.parse_opt ("--raw-encoding", s))
{
auto e = parse_encoding (s);
Params::raw_input_format.set_encoding (e);
Params::raw_output_format.set_encoding (e);
}
if (ap.parse_opt ("--raw-channels", i))
{
Params::raw_input_format.set_channels (i);
Params::raw_output_format.set_channels (i);
}
if (ap.parse_opt ("--raw-rate", i))
{
Params::raw_input_format.set_sample_rate (i);
Params::raw_output_format.set_sample_rate (i);
}
if (ap.parse_opt ("--test-no-limiter"))
{
Params::test_no_limiter = true;
}
}
void
parse_get_options (ArgParser& ap)
{
float f;
ap.parse_opt ("--test-cut", Params::test_cut);
ap.parse_opt ("--test-truncate", Params::test_truncate);
if (ap.parse_opt ("--hard"))
{
Params::hard = true;
}
if (ap.parse_opt ("--test-no-sync"))
{
Params::test_no_sync = true;
}
if (ap.parse_opt ("--detect-speed"))
{
Params::detect_speed = true;
}
if (ap.parse_opt ("--test-speed", f))
{
Params::test_speed = f;
}
}
int
main (int argc, char **argv)
{
ArgParser ap (argc, argv);
vector args;
if (ap.parse_opt ("--help") || ap.parse_opt ("-h"))
{
print_usage();
return 0;
}
if (ap.parse_opt ("--help-hls"))
{
print_usage_hls();
return 0;
}
if (ap.parse_opt ("--version") || ap.parse_opt ("-v"))
{
printf ("audiowmark %s\n", VERSION);
return 0;
}
if (ap.parse_opt ("--quiet") || ap.parse_opt ("-q"))
{
set_log_level (Log::WARNING);
}
if (ap.parse_cmd ("hls-add"))
{
parse_shared_options (ap);
ap.parse_opt ("--bit-rate", Params::hls_bit_rate);
if (ap.parse_args (3, args))
return hls_add (args[0], args[1], args[2]);
}
else if (ap.parse_cmd ("hls-prepare"))
{
ap.parse_opt ("--bit-rate", Params::hls_bit_rate);
if (ap.parse_args (4, args))
return hls_prepare (args[0], args[1], args[2], args[3]);
}
else if (ap.parse_cmd ("add"))
{
parse_shared_options (ap);
parse_add_options (ap);
if (ap.parse_args (3, args))
return add_watermark (args[0], args[1], args[2]);
}
else if (ap.parse_cmd ("get"))
{
parse_shared_options (ap);
parse_get_options (ap);
if (ap.parse_args (1, args))
return get_watermark (args[0], /* no ber */ "");
}
else if (ap.parse_cmd ("cmp"))
{
parse_shared_options (ap);
parse_get_options (ap);
if (ap.parse_args (2, args))
return get_watermark (args[0], args[1]);
}
else if (ap.parse_cmd ("gen-key"))
{
if (ap.parse_args (1, args))
return gen_key (args[0]);
}
else if (ap.parse_cmd ("gentest"))
{
if (ap.parse_args (2, args))
return gentest (args[0], args[1]);
}
else if (ap.parse_cmd ("cut-start"))
{
if (ap.parse_args (3, args))
return cut_start (args[0], args[1], args[2]);
}
else if (ap.parse_cmd ("test-subtract"))
{
if (ap.parse_args (3, args))
return test_subtract (args[0], args[1], args[2]);
}
else if (ap.parse_cmd ("test-snr"))
{
if (ap.parse_args (2, args))
return test_snr (args[0], args[1]);
}
else if (ap.parse_cmd ("test-clip"))
{
parse_shared_options (ap);
if (ap.parse_args (4, args))
return test_clip (args[0], args[1], atoi (args[2].c_str()), atoi (args[3].c_str()));
}
else if (ap.parse_cmd ("test-speed"))
{
parse_shared_options (ap);
if (ap.parse_args (1, args))
return test_speed (atoi (args[0].c_str()));
}
error ("audiowmark: error parsing commandline args (use audiowmark -h)\n");
return 1;
}
audiowmark-simple-detection/src/ber-double-mp3.sh 0000775 0000000 0000000 00000000200 13767656611 0022341 0 ustar 00root root 0000000 0000000 #/bin/bash
echo 512 $(ber-test.sh)
for quality in 256 196 128 96 64
do
echo $quality $(ber-test.sh double-mp3 $quality)
done
audiowmark-simple-detection/src/ber-mp3.sh 0000775 0000000 0000000 00000000171 13767656611 0021100 0 ustar 00root root 0000000 0000000 #/bin/bash
echo 512 $(ber-test.sh)
for quality in 256 196 128 96 64
do
echo $quality $(ber-test.sh mp3 $quality)
done
audiowmark-simple-detection/src/ber-ogg.sh 0000775 0000000 0000000 00000000171 13767656611 0021155 0 ustar 00root root 0000000 0000000 #/bin/bash
echo 512 $(ber-test.sh)
for quality in 256 196 128 96 64
do
echo $quality $(ber-test.sh ogg $quality)
done
audiowmark-simple-detection/src/ber-test.sh 0000775 0000000 0000000 00000012163 13767656611 0021364 0 ustar 00root root 0000000 0000000 #!/bin/bash
TRANSFORM=$1
if [ "x$AWM_TRUNCATE" != "x" ]; then
AWM_REPORT=truncv
fi
if [ "x$AWM_SET" == "x" ]; then
AWM_SET=small
fi
if [ "x$AWM_SEEDS" == "x" ]; then
AWM_SEEDS=0
fi
if [ "x$AWM_REPORT" == "x" ]; then
AWM_REPORT=fer
fi
if [ "x$AWM_FILE" == "x" ]; then
AWM_FILE=t
fi
if [ "x$AWM_MULTI_CLIP" == "x" ]; then
AWM_MULTI_CLIP=1
fi
if [ "x$AWM_PATTERN_BITS" == "x" ]; then
AWM_PATTERN_BITS=128
fi
{
if [ "x$AWM_SET" == "xsmall" ]; then
ls test/T*
elif [ "x$AWM_SET" == "xbig" ]; then
cat test_list
elif [ "x$AWM_SET" != "x" ] && [ -d "$AWM_SET" ] && [ -f "$AWM_SET/T001"*wav ]; then
ls $AWM_SET/T*
else
echo "bad AWM_SET $AWM_SET" >&2
exit 1
fi
} | while read i
do
for SEED in $AWM_SEEDS
do
echo in_file $i
if [ "x$AWM_RAND_PATTERN" != "x" ]; then
# random pattern, 128 bit
PATTERN=$(
for i in $(seq 16)
do
printf "%02x" $((RANDOM % 256))
done
)
else
# pseudo random pattern, 128 bit
PATTERN=4e1243bd22c66e76c2ba9eddc1f91394
fi
PATTERN=${PATTERN:0:$((AWM_PATTERN_BITS / 4))}
echo in_pattern $PATTERN
echo in_flags $AWM_PARAMS $AWM_PARAMS_ADD --test-key $SEED
audiowmark add "$i" ${AWM_FILE}.wav $PATTERN $AWM_PARAMS $AWM_PARAMS_ADD --test-key $SEED --quiet
CUT=0
if [ "x$AWM_ALWAYS_CUT" != x ]; then
CUT="$AWM_ALWAYS_CUT"
fi
if [ "x$AWM_RAND_CUT" != x ]; then
CUT=$((CUT + RANDOM))
fi
if [ "x$CUT" != x0 ]; then
audiowmark cut-start "${AWM_FILE}.wav" "${AWM_FILE}.wav" $CUT
TEST_CUT_ARGS="--test-cut $CUT"
echo in_cut $CUT
else
TEST_CUT_ARGS=""
fi
if [ "x$AWM_SPEED" != x ]; then
[ -z $SPEED_SEED ] && SPEED_SEED=0
SPEED=$(audiowmark test-speed $SPEED_SEED --test-key $SEED)
((SPEED_SEED++))
echo in_speed $SPEED
sox -D -V1 ${AWM_FILE}.wav ${AWM_FILE}.speed.wav speed $SPEED
mv ${AWM_FILE}.speed.wav ${AWM_FILE}.wav
TEST_SPEED_ARGS="--detect-speed --test-speed $SPEED"
else
TEST_SPEED_ARGS=""
fi
if [ "x$TRANSFORM" == "xmp3" ]; then
if [ "x$2" == "x" ]; then
echo "need mp3 bitrate" >&2
exit 1
fi
lame -b $2 ${AWM_FILE}.wav ${AWM_FILE}.mp3 --quiet
OUT_FILE=${AWM_FILE}.mp3
elif [ "x$TRANSFORM" == "xdouble-mp3" ]; then
if [ "x$2" == "x" ]; then
echo "need mp3 bitrate" >&2
exit 1
fi
# first mp3 step (fixed bitrate)
lame -b 128 ${AWM_FILE}.wav ${AWM_FILE}.mp3 --quiet
rm ${AWM_FILE}.wav
ffmpeg -i ${AWM_FILE}.mp3 ${AWM_FILE}.wav -v quiet -nostdin
# second mp3 step
lame -b $2 ${AWM_FILE}.wav ${AWM_FILE}.mp3 --quiet
OUT_FILE=${AWM_FILE}.mp3
elif [ "x$TRANSFORM" == "xogg" ]; then
if [ "x$2" == "x" ]; then
echo "need ogg bitrate" >&2
exit 1
fi
oggenc -b $2 ${AWM_FILE}.wav -o ${AWM_FILE}.ogg --quiet
OUT_FILE=${AWM_FILE}.ogg
elif [ "x$TRANSFORM" == "x" ]; then
OUT_FILE=${AWM_FILE}.wav
else
echo "unknown transform $TRANSFORM" >&2
exit 1
fi
echo
if [ "x${AWM_CLIP}" != "x" ]; then
for CLIP in $(seq $AWM_MULTI_CLIP)
do
audiowmark test-clip $OUT_FILE ${OUT_FILE}.clip.wav $((CLIP_SEED++)) $AWM_CLIP --test-key $SEED
audiowmark cmp ${OUT_FILE}.clip.wav $PATTERN $AWM_PARAMS --test-key $SEED $TEST_CUT_ARGS $TEST_SPEED_ARGS
rm ${OUT_FILE}.clip.wav
echo
done
elif [ "x$AWM_REPORT" == "xtruncv" ]; then
for TRUNC in $AWM_TRUNCATE
do
audiowmark cmp $OUT_FILE $PATTERN $AWM_PARAMS --test-key $SEED $TEST_CUT_ARGS $TEST_SPEED_ARGS --test-truncate $TRUNC | sed "s/^/$TRUNC /g"
echo
done
else
audiowmark cmp $OUT_FILE $PATTERN $AWM_PARAMS --test-key $SEED $TEST_CUT_ARGS $TEST_SPEED_ARGS
echo
fi
rm -f ${AWM_FILE}.wav $OUT_FILE # cleanup temp files
done
done | {
if [ "x$AWM_REPORT" == "xfer" ]; then
awk 'BEGIN { bad = n = 0 } $1 == "match_count" { if ($2 == 0) bad++; n++; } END { print bad, n, bad * 100.0 / n; }'
elif [ "x$AWM_REPORT" == "xferv" ]; then
awk 'BEGIN { bad = n = 0 } { print "###", $0; } $1 == "match_count" { if ($2 == 0) bad++; n++; } END { print bad, n, bad * 100.0 / n; }'
elif [ "x$AWM_REPORT" == "xsync" ]; then
awk 'BEGIN { bad = n = 0 } $1 == "sync_match" { bad += (3 - $2) / 3.0; n++; } END { print bad, n, bad * 100.0 / n; }'
elif [ "x$AWM_REPORT" == "xsyncv" ]; then
awk '{ print "###", $0; } $1 == "sync_match" { correct += $2; missing += 3 - $2; incorrect += $3-$2; print "correct:", correct, "missing:", missing, "incorrect:", incorrect; }'
elif [ "x$AWM_REPORT" == "xtruncv" ]; then
awk ' {
print "###", $0;
}
$2 == "match_count" {
if (!n[$1])
{
n[$1] = 0;
bad[$1] = 0;
}
if ($3 == 0)
bad[$1]++;
n[$1]++;
}
END {
for (trunc in n) {
print trunc, bad[trunc], n[trunc], bad[trunc] * 100.0 / n[trunc];
}
}'
else
echo "unknown report $AWM_REPORT" >&2
exit 1
fi
}
audiowmark-simple-detection/src/convcode.cc 0000664 0000000 0000000 00000015623 13767656611 0021413 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "utils.hh"
#include "convcode.hh"
#include
#include
#include
using std::vector;
using std::string;
using std::min;
int
parity (unsigned int v)
{
int p = 0;
while (v)
{
p ^= (v & 1);
v >>= 1;
}
return p;
}
constexpr auto ab_generators = std::array
{
066561, 075211, 071545, 054435, 063635, 052475,
063543, 075307, 052547, 045627, 067657, 051757
};
constexpr unsigned int ab_rate = ab_generators.size();
constexpr unsigned int order = 15;
/*
constexpr unsigned int order = 9;
constexpr auto generators = std::array { 0557, 0663, 0711 };
constexpr unsigned int order = 14;
constexpr auto generators = std::array { 021645, 035661, 037133 };
constexpr unsigned int order = 18;
constexpr auto generators = std::array { 0552137, 0614671, 0772233 };
*/
constexpr unsigned int state_count = (1 << order);
constexpr unsigned int state_mask = (1 << order) - 1;
size_t
conv_code_size (ConvBlockType block_type, size_t msg_size)
{
switch (block_type)
{
case ConvBlockType::a:
case ConvBlockType::b: return (msg_size + order) * ab_rate / 2;
case ConvBlockType::ab: return (msg_size + order) * ab_rate;
default: assert (false);
}
}
vector
get_block_type_generators (ConvBlockType block_type)
{
vector generators;
if (block_type == ConvBlockType::a)
{
for (unsigned int i = 0; i < ab_rate / 2; i++)
generators.push_back (ab_generators[i * 2]);
}
else if (block_type == ConvBlockType::b)
{
for (unsigned int i = 0; i < ab_rate / 2; i++)
generators.push_back (ab_generators[i * 2 + 1]);
}
else
{
assert (block_type == ConvBlockType::ab);
generators.assign (ab_generators.begin(), ab_generators.end());
}
return generators;
}
vector
conv_encode (ConvBlockType block_type, const vector& in_bits)
{
auto generators = get_block_type_generators (block_type);
vector out_vec;
vector vec = in_bits;
/* termination: bring encoder into all-zero state */
for (unsigned int i = 0; i < order; i++)
vec.push_back (0);
unsigned int reg = 0;
for (auto b : vec)
{
reg = (reg << 1) | b;
for (auto poly : generators)
{
int out_bit = parity (reg & poly);
out_vec.push_back (out_bit);
}
}
return out_vec;
}
/* decode using viterbi algorithm */
vector
conv_decode_soft (ConvBlockType block_type, const vector& coded_bits, float *error_out)
{
auto generators = get_block_type_generators (block_type);
unsigned int rate = generators.size();
vector decoded_bits;
assert (coded_bits.size() % rate == 0);
struct StateEntry
{
int last_state;
float delta;
int bit;
};
vector> error_count;
for (size_t i = 0; i < coded_bits.size() + rate; i += rate) /* 1 extra element */
error_count.emplace_back (state_count, StateEntry {0, -1, 0});
error_count[0][0].delta = 0; /* start state */
/* precompute state -> output bits table */
vector state2bits;
for (unsigned int state = 0; state < state_count; state++)
{
for (size_t p = 0; p < generators.size(); p++)
{
int out_bit = parity (state & generators[p]);
state2bits.push_back (out_bit);
}
}
for (size_t i = 0; i < coded_bits.size(); i += rate)
{
vector& old_table = error_count[i / rate];
vector& new_table = error_count[i / rate + 1];
for (unsigned int state = 0; state < state_count; state++)
{
/* this check enforces that we only consider states reachable from state=0 at time=0*/
if (old_table[state].delta >= 0)
{
for (int bit = 0; bit < 2; bit++)
{
int new_state = ((state << 1) | bit) & state_mask;
float delta = old_table[state].delta;
int sbit_pos = new_state * rate;
for (size_t p = 0; p < rate; p++)
{
const float cbit = coded_bits[i + p];
const float sbit = state2bits[sbit_pos + p];
/* decoding error weight for this bit; if input is only 0.0 and 1.0, this is the hamming distance */
delta += (cbit - sbit) * (cbit - sbit);
}
if (delta < new_table[new_state].delta || new_table[new_state].delta < 0) /* better match with this link? replace entry */
{
new_table[new_state].delta = delta;
new_table[new_state].last_state = state;
new_table[new_state].bit = bit;
}
}
}
}
}
unsigned int state = 0;
if (error_out)
*error_out = error_count.back()[state].delta / coded_bits.size();
for (size_t idx = error_count.size() - 1; idx > 0; idx--)
{
decoded_bits.push_back (error_count[idx][state].bit);
state = error_count[idx][state].last_state;
}
std::reverse (decoded_bits.begin(), decoded_bits.end());
/* remove termination */
assert (decoded_bits.size() >= order);
decoded_bits.resize (decoded_bits.size() - order);
return decoded_bits;
}
vector
conv_decode_hard (ConvBlockType block_type, const vector& coded_bits)
{
/* for the final application, we always want soft decoding, so we don't
* special case hard decoding here, so this will be a little slower than
* necessary
*/
vector soft_bits;
for (auto b : coded_bits)
soft_bits.push_back (b ? 1.0f : 0.0f);
return conv_decode_soft (block_type, soft_bits);
}
void
conv_print_table (ConvBlockType block_type)
{
vector bits (100);
bits[0] = 1;
vector out_bits = conv_encode (block_type, bits);
auto generators = get_block_type_generators (block_type);
unsigned int rate = generators.size();
for (unsigned int r = 0; r < rate; r++)
{
for (unsigned int i = 0; i < order; i++)
printf ("%s%d", i == 0 ? "" : " ", out_bits[i * rate + r]);
printf ("\n");
}
}
audiowmark-simple-detection/src/convcode.hh 0000664 0000000 0000000 00000002472 13767656611 0021423 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef AUDIOWMARK_CONV_CODE_HH
#define AUDIOWMARK_CONV_CODE_HH
#include
#include
enum class ConvBlockType { a, b, ab };
size_t conv_code_size (ConvBlockType block_type, size_t msg_size);
std::vector conv_encode (ConvBlockType block_type, const std::vector& in_bits);
std::vector conv_decode_hard (ConvBlockType block_type, const std::vector& coded_bits);
std::vector conv_decode_soft (ConvBlockType block_type, const std::vector& coded_bits, float *error_out = nullptr);
void conv_print_table (ConvBlockType block_type);
#endif /* AUDIOWMARK_CONV_CODE_HH */
audiowmark-simple-detection/src/delta2wav.sh 0000775 0000000 0000000 00000000304 13767656611 0021522 0 ustar 00root root 0000000 0000000 for delta in 0.080 0.050 0.030 0.020 0.015 0.010 0.005
do
audiowmark add "$1" --water-delta=$delta /tmp/w$delta.wav a9fcd54b25e7e863d72cd47c08af46e61
done
audiowmark scale "$1" /tmp/w.orig.wav
audiowmark-simple-detection/src/fer-test.sh 0000775 0000000 0000000 00000000514 13767656611 0021365 0 ustar 00root root 0000000 0000000 #!/bin/bash
SEEDS="$1"
MAX_SEED=$(($SEEDS - 1))
P="$2"
shift 2
echo "n seeds : $SEEDS"
echo "ber-test args : $@"
echo "params : $P"
for seed in $(seq 0 $MAX_SEED)
do
echo $(AWM_SEEDS=$seed AWM_PARAMS="$P" AWM_REPORT="fer" ber-test.sh "$@")
done | awk '{bad += $1; files += $2; print bad, files, bad * 100. / files }'
audiowmark-simple-detection/src/fft.cc 0000664 0000000 0000000 00000005304 13767656611 0020365 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "fft.hh"
#include
#include