Update WiFi SoftAP password to love, update touch pin mappings, and remove unused decoders to resolve compile crash.
This commit is contained in:
674
LICENSE.txt
Normal file
674
LICENSE.txt
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
13
README.md
13
README.md
@@ -17,12 +17,7 @@ The application reads PNG images and compressed MP3 / uncompressed WAV audio fil
|
||||
* *Triple Click:* Previous photo/audio pair.
|
||||
* *Quadruple Click:* Cycle volume through levels 4, 8, 12, 16, and 20 (on a 0-21 scale).
|
||||
* *Long Press (>1.5s):* Toggle Autoplay slideshow mode.
|
||||
* **WS2812 RGB LED Status Feedback:** Utilizes the onboard RGB LED to output real-time visual feedback:
|
||||
* 🔵 **Solid Blue:** Idle, waiting for manual trigger.
|
||||
* 🟢 **Pulsing Green:** Audio is playing.
|
||||
* 🟣 **Pulsing Purple:** Autoplay/Slideshow mode is active.
|
||||
* ⚪ **White Flashing:** Confirms a volume change has been triggered.
|
||||
* 🔴 **Blinking Red:** Error state (microSD card failed to initialize, or no media files were found).
|
||||
* **Visual Status Indicators:** Disabled on this Touch board version to prevent SCLK (GPIO 38) line contention.
|
||||
|
||||
---
|
||||
|
||||
@@ -31,7 +26,7 @@ The application reads PNG images and compressed MP3 / uncompressed WAV audio fil
|
||||
To upload new files to your photo frame over WiFi:
|
||||
1. Connect your phone, tablet, or computer to the WiFi network hosted by the board:
|
||||
* **SSID:** `love`
|
||||
* **Password:** `password`
|
||||
* **Password:** `love`
|
||||
2. Open your browser and navigate to: **`http://192.168.4.1`**
|
||||
3. Choose a file (`.png`, `.mp3`, or `.wav`) and click **Upload to Frame**.
|
||||
4. The file will be saved directly to the microSD card. The board will automatically re-scan the card, and the new files will be indexed and ready to play!
|
||||
@@ -40,7 +35,7 @@ To upload new files to your photo frame over WiFi:
|
||||
|
||||
## 🔌 Hardware Connections (External I2S DAC)
|
||||
|
||||
Because the Waveshare ESP32-S3-LCD-1.47 does not have built-in audio amplification or a speaker, you must connect an external **I2S DAC/Amplifier** (e.g., MAX98357A or PCM5102) to the exposed headers.
|
||||
Because the Waveshare ESP32-S3-Touch-LCD-1.47 does not have built-in audio amplification or a speaker, you must connect an external **I2S DAC/Amplifier** (e.g., MAX98357A or PCM5102) to the exposed headers.
|
||||
|
||||
Configure the pin connections as follows:
|
||||
|
||||
@@ -52,7 +47,7 @@ Configure the pin connections as follows:
|
||||
| **3V3 / VBUS (5V)** | VCC | Power Supply |
|
||||
| **GND** | GND | Ground Reference |
|
||||
|
||||
*Note: The physical **BOOT button** is permanently connected to **GPIO 9** and acts as the input control.*
|
||||
*Note: The physical **BOOT button** is permanently connected to **GPIO 0** and acts as the input control.*
|
||||
|
||||
---
|
||||
|
||||
|
||||
BIN
arduino-cli.exe
Normal file
BIN
arduino-cli.exe
Normal file
Binary file not shown.
@@ -16,12 +16,12 @@ char audioI2SVers[] = "\
|
||||
*****************************************************************************************************************************************************/
|
||||
|
||||
#include "Audio.h"
|
||||
#include "aac_decoder/aac_decoder.h"
|
||||
#include "flac_decoder/flac_decoder.h"
|
||||
// #include "aac_decoder/aac_decoder.h"
|
||||
// #include "flac_decoder/flac_decoder.h"
|
||||
#include "mp3_decoder/mp3_decoder.h"
|
||||
#include "opus_decoder/opus_decoder.h"
|
||||
// #include "opus_decoder/opus_decoder.h"
|
||||
#include "psram_unique_ptr.hpp"
|
||||
#include "vorbis_decoder/vorbis_decoder.h"
|
||||
// #include "vorbis_decoder/vorbis_decoder.h"
|
||||
#include "wav_decoder/wav_decoder.h"
|
||||
|
||||
// constants
|
||||
@@ -376,10 +376,10 @@ void Audio::destroy_decoder() {
|
||||
std::unique_ptr<Decoder> Audio::createDecoder(const std::string& type) {
|
||||
destroy_decoder();
|
||||
if (type == "MP3") return std::make_unique<MP3Decoder>(*this);
|
||||
if (type == "FLAC") return std::make_unique<FlacDecoder>(*this);
|
||||
if (type == "OPUS") return std::make_unique<OpusDecoder>(*this);
|
||||
if (type == "AAC") return std::make_unique<AACDecoder>(*this);
|
||||
if (type == "VORBIS") return std::make_unique<VorbisDecoder>(*this);
|
||||
// if (type == "FLAC") return std::make_unique<FlacDecoder>(*this);
|
||||
// if (type == "OPUS") return std::make_unique<OpusDecoder>(*this);
|
||||
// if (type == "AAC") return std::make_unique<AACDecoder>(*this);
|
||||
// if (type == "VORBIS") return std::make_unique<VorbisDecoder>(*this);
|
||||
if (type == "WAV") return std::make_unique<WavDecoder>(*this);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -5555,29 +5555,6 @@ uint32_t Audio::decodeError(int8_t res, uint8_t* data, int32_t bytesDecoded) {
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t Audio::decodeContinue(int8_t res, uint8_t* data, int32_t bytesDecoded, int32_t* bytesLeft) {
|
||||
// if(m_codec == CODEC_MP3){ if(res == MAD_ERROR_CONTINUE) return bytesDecoded;} // nothing to play, mybe eof
|
||||
if (m_codec == CODEC_AAC) {
|
||||
if (res == AACDecoder::AAC_ID3_HDR) {
|
||||
uint32_t size = ((data[6 + bytesDecoded] & 0x7F) << 21) | ((data[7 + bytesDecoded] & 0x7F) << 14) | ((data[8 + bytesDecoded] & 0x7F) << 7) | (data[9 + bytesDecoded] & 0x7F);
|
||||
size += 10; // skip payload
|
||||
return bytesDecoded + size;
|
||||
if (bytesDecoded > *bytesLeft) AUDIO_LOG_ERROR("AAC input data too small bytesDecoded {} > bytesLeft {}", bytesDecoded, *bytesLeft);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_codec == CODEC_FLAC) {
|
||||
if (res == FlacDecoder::FLAC_PARSE_OGG_DONE) return bytesDecoded;
|
||||
if (res == FlacDecoder::FLAC_DECODE_FRAMES_LOOP) return bytesDecoded;
|
||||
} // nothing to play
|
||||
if (m_codec == CODEC_OPUS) {
|
||||
if (res == OpusDecoder::OPUS_PARSE_OGG_DONE) return bytesDecoded;
|
||||
if (res == OpusDecoder::OPUS_END) return bytesDecoded;
|
||||
} // nothing to play
|
||||
if (m_codec == CODEC_VORBIS) {
|
||||
if (res == VorbisDecoder::VORBIS_PARSE_OGG_DONE) return bytesDecoded;
|
||||
if (res == VorbisDecoder::VORBIS_COMMENT_DONE) return bytesDecoded;
|
||||
if (res == VorbisDecoder::VORBIS_COMMENT_NEED_MORE) return bytesDecoded;
|
||||
} // nothing to play
|
||||
if (m_codec == CODEC_MP3) {
|
||||
if (res == MP3Decoder::MP3_NEXT_FRAME) return bytesDecoded;
|
||||
}
|
||||
@@ -5812,8 +5789,8 @@ bool Audio::i2s_config() {
|
||||
m_i2s_chan_cfg.dma_desc_num = settings.DMA_DESC_NUM; // number of DMA buffer
|
||||
m_i2s_chan_cfg.dma_frame_num = settings.DMA_FRAME_NUM; // I2S frame number in one DMA buffer.
|
||||
m_i2s_chan_cfg.auto_clear = true; // i2s will always send zero automatically if no data to send
|
||||
m_i2s_chan_cfg.allow_pd = false;
|
||||
m_i2s_chan_cfg.intr_priority = 2;
|
||||
// m_i2s_chan_cfg.allow_pd = false;
|
||||
// m_i2s_chan_cfg.intr_priority = 2;
|
||||
result = i2s_new_channel(&m_i2s_chan_cfg, &m_i2s_tx_handle, NULL);
|
||||
if (result != ESP_OK) { // ESP_ERR_INVALID_ARG?
|
||||
AUDIO_LOG_ERROR("I2S channel: invalid argument");
|
||||
@@ -6694,9 +6671,9 @@ void Audio::IIR_filter(int32_t* sample) {
|
||||
float s[2];
|
||||
s[LEFTCHANNEL] = (float)(s32[LEFTCHANNEL] * m_audio_items.pre_gain);
|
||||
s[RIGHTCHANNEL] = (float)(s32[RIGHTCHANNEL] * m_audio_items.pre_gain);
|
||||
dsps_biquad_sf32(s, s, 1, m_audio_items.coeffs[0], m_audio_items.state_biquad[0]);
|
||||
dsps_biquad_sf32(s, s, 1, m_audio_items.coeffs[1], m_audio_items.state_biquad[1]);
|
||||
dsps_biquad_sf32(s, s, 1, m_audio_items.coeffs[2], m_audio_items.state_biquad[2]);
|
||||
dsps_biquad_f32(s, s, 1, m_audio_items.coeffs[0], m_audio_items.state_biquad[0]);
|
||||
dsps_biquad_f32(s, s, 1, m_audio_items.coeffs[1], m_audio_items.state_biquad[1]);
|
||||
dsps_biquad_f32(s, s, 1, m_audio_items.coeffs[2], m_audio_items.state_biquad[2]);
|
||||
s32[LEFTCHANNEL] = (int32_t)std::clamp(s[LEFTCHANNEL], -2147483648.0f, 2147483647.0f);
|
||||
s32[RIGHTCHANNEL] = (int32_t)std::clamp(s[RIGHTCHANNEL], -2147483648.0f, 2147483647.0f);
|
||||
return;
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
/*
|
||||
* aac_decoder.cpp
|
||||
* faad2 - ESP32 adaptation
|
||||
* Created on: 12.09.2023
|
||||
* Updated on: 26.06.2026
|
||||
*/
|
||||
|
||||
#include "aac_decoder.h"
|
||||
#include "Arduino.h"
|
||||
#include "libfaad/neaacdec.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
AACDecoder::AACDecoder(Audio& audioRef) : Decoder(audioRef), audio(audioRef), m_neaacdec(std::make_unique<NeaacDecoder>()) {}
|
||||
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
bool AACDecoder::init() {
|
||||
m_hAac = m_neaacdec->NeAACDecOpen();
|
||||
m_conf = m_neaacdec->NeAACDecGetCurrentConfiguration(m_hAac);
|
||||
m_out16.alloc_array(4608 * 2, "m_out16");
|
||||
|
||||
if (m_hAac && m_out16.valid()) m_f_decoderIsInit = true;
|
||||
m_f_firstCall = false;
|
||||
m_f_setRaWBlockParams = false;
|
||||
return m_f_decoderIsInit;
|
||||
}
|
||||
void AACDecoder::clear() {
|
||||
m_out16.clear();
|
||||
return; // nothing todo
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
void AACDecoder::reset() {
|
||||
m_neaacdec->NeAACDecClose(m_hAac);
|
||||
m_hAac = NULL;
|
||||
m_f_decoderIsInit = false;
|
||||
m_f_firstCall = false;
|
||||
m_out16.reset();
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
bool AACDecoder::isValid() {
|
||||
return m_f_decoderIsInit;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t AACDecoder::findSyncWord(uint8_t* buf, int32_t nBytes) {
|
||||
const int MIN_ADTS_HEADER_SIZE = 7;
|
||||
if (buf == nullptr || nBytes < MIN_ADTS_HEADER_SIZE) { return -1; }
|
||||
|
||||
auto validate = [MIN_ADTS_HEADER_SIZE](const uint8_t* buf, int32_t bytesAvailable) -> bool { // check the ADTS header for validity
|
||||
if (bytesAvailable < MIN_ADTS_HEADER_SIZE) { return false; }
|
||||
|
||||
// Layer (bits 14-15) must be 00
|
||||
if ((buf[1] & 0x06) != 0x00) { return false; }
|
||||
|
||||
// Sampling Frequency Index (Bits 18-21) cannot be invalid
|
||||
uint8_t sampling_frequency_index = (buf[2] & 0x3C) >> 2;
|
||||
if (sampling_frequency_index > 12) { return false; }
|
||||
|
||||
// Frame length (bits 30-42) must be at least the header size
|
||||
int frame_length = ((buf[3] & 0x03) << 11) | (buf[4] << 3) | ((buf[5] & 0xE0) >> 5);
|
||||
if (frame_length < MIN_ADTS_HEADER_SIZE) { return false; }
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/* find byte-aligned syncword (12 bits = 0xFFF) */
|
||||
for (int32_t i = 0; i <= nBytes - MIN_ADTS_HEADER_SIZE; i++) {
|
||||
if ((buf[i + 0] & SYNCWORDH) == SYNCWORDH && (buf[i + 1] & SYNCWORDL) == SYNCWORDL) {
|
||||
int32_t bytesAvailable = nBytes - i;
|
||||
if (!validate(&buf[i], bytesAvailable)) { continue; }
|
||||
|
||||
int frame_length = ((buf[i + 3] & 0x03) << 11) | (buf[i + 4] << 3) | ((buf[i + 5] & 0xE0) >> 5);
|
||||
if (i + frame_length + 1 >= nBytes) {
|
||||
return -1; // Puffergrenze überschritten, kein gültiger Header
|
||||
}
|
||||
/* find a second byte-aligned syncword (12 bits = 0xFFF) */
|
||||
if ((buf[i + frame_length + 0] & SYNCWORDH) == SYNCWORDH && (buf[i + frame_length + 1] & SYNCWORDL) == SYNCWORDL) { return i; }
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint8_t AACDecoder::getChannels() {
|
||||
return m_aacChannels;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t AACDecoder::getSampleRate() {
|
||||
return m_aacSamplerate;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t AACDecoder::getOutputSamples() {
|
||||
return m_validSamples;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint8_t AACDecoder::getBitsPerSample() {
|
||||
return 16;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t AACDecoder::getBitRate() {
|
||||
uint32_t br = getBitsPerSample() * getChannels() * getSampleRate();
|
||||
return (br / m_compressionRatio);
|
||||
;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t AACDecoder::getAudioDataStart() {
|
||||
return 0; // nothing todo
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t AACDecoder::getAudioFileDuration() {
|
||||
return 0; // nothing todo
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const char* AACDecoder::getStreamTitle() {
|
||||
return nullptr; // nothing todo
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const char* AACDecoder::whoIsIt() {
|
||||
return "AAC";
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
error_info_t AACDecoder::getErrorMessage(int8_t err) {
|
||||
return m_neaacdec->NeAACDecGetErrorMessage(abs(err));
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t AACDecoder::decode(uint8_t* inbuf, int32_t* bytesLeft, int32_t* outbuf) {
|
||||
|
||||
uint8_t* ob = (uint8_t*)m_out16.get();
|
||||
if (m_f_firstCall == false) {
|
||||
if (m_f_setRaWBlockParams) { // set raw AAC values, e.g. for M4A config.
|
||||
m_f_setRaWBlockParams = false;
|
||||
m_conf->defSampleRate = m_aacSamplerate;
|
||||
m_conf->outputFormat = FAAD_FMT_16BIT;
|
||||
m_conf->useOldADTSFormat = 1;
|
||||
m_conf->defObjectType = 2;
|
||||
int8_t ret = m_neaacdec->NeAACDecSetConfiguration(m_hAac, m_conf);
|
||||
(void)ret;
|
||||
|
||||
uint8_t specificInfo[2];
|
||||
createAudioSpecificConfig(specificInfo, m_aacProfile, m_neaacdec->get_sr_index(m_aacSamplerate), m_aacChannels);
|
||||
int8_t err = m_neaacdec->NeAACDecInit2(m_hAac, specificInfo, 2, &m_aacSamplerate, &m_aacChannels);
|
||||
(void)err;
|
||||
} else {
|
||||
m_neaacdec->NeAACDecSetConfiguration(m_hAac, m_conf);
|
||||
int8_t err = m_neaacdec->NeAACDecInit(m_hAac, inbuf, *bytesLeft, &m_aacSamplerate, &m_aacChannels);
|
||||
(void)err;
|
||||
}
|
||||
m_f_firstCall = true;
|
||||
}
|
||||
|
||||
m_neaacdec->NeAACDecDecode2(m_hAac, &m_frameInfo, inbuf, *bytesLeft, (void**)&ob, 2048 * 2 * sizeof(int16_t));
|
||||
*bytesLeft -= m_frameInfo.bytesconsumed;
|
||||
m_validSamples = m_frameInfo.samples;
|
||||
int8_t err = 0 - m_frameInfo.error;
|
||||
m_compressionRatio = (float)m_frameInfo.samples * 2 / m_frameInfo.bytesconsumed;
|
||||
if (err < 0) {
|
||||
if (err == -100) return AAC_ID3_HDR; // ID3 header found
|
||||
else{
|
||||
if(getErrorMessage(abs(err)).level == AAC_ERROR) AAC_LOG_ERROR("{}", getErrorMessage(abs(err)).text);
|
||||
if(getErrorMessage(abs(err)).level == AAC_WARN) AAC_LOG_WARN("{}", getErrorMessage(abs(err)).text);
|
||||
if(getErrorMessage(abs(err)).level == AAC_INFO) AAC_LOG_INFO("{}", getErrorMessage(abs(err)).text);
|
||||
if(getErrorMessage(abs(err)).level == AAC_DEBUG) AAC_LOG_DEBUG("{}", getErrorMessage(abs(err)).text);
|
||||
if(getErrorMessage(abs(err)).level == AAC_VERBOSE) AAC_LOG_VERBOSE("{}", getErrorMessage(abs(err)).text);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (m_aacChannels == 1) {
|
||||
for (int i = 0; i < m_validSamples; i++) {
|
||||
outbuf[i * 2] = m_out16[i] << 16;
|
||||
outbuf[i * 2 + 1] = m_out16[i] << 16;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_aacChannels == 2) {
|
||||
for (int i = 0; i < m_validSamples * 2; i++) { outbuf[i] = m_out16[i] << 16; }
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
void AACDecoder::setRawBlockParams(uint8_t channels, uint32_t sampleRate, uint8_t dummy1, uint32_t profile, uint32_t dummy2) {
|
||||
m_f_setRaWBlockParams = true;
|
||||
m_aacChannels = channels; // 1: Mono, 2: Stereo
|
||||
m_aacSamplerate = sampleRate; // 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
|
||||
m_aacProfile = profile; // 1: AAC Main, 2: AAC LC (Low Complexity), 3: AAC SSR (Scalable Sample Rate), 4: AAC LTP (Long Term Prediction)
|
||||
return;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
std::vector<uint32_t> AACDecoder::getMetadataBlockPicture() {
|
||||
std::vector<uint32_t> a;
|
||||
return a;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const char* AACDecoder::arg1() { // AAC format
|
||||
m_arg1.assign("AAC HeaderFormat: ");
|
||||
if (m_frameInfo.header_type == 0)
|
||||
m_arg1.append("RAW");
|
||||
else if (m_frameInfo.header_type == 1)
|
||||
m_arg1.append("ADIF"); /* single ADIF header at the beginning of the file */
|
||||
else if (m_frameInfo.header_type == 2)
|
||||
m_arg1.append("ADTS"); /* ADTS header at the beginning of each frame */
|
||||
else
|
||||
m_arg1.append("unknown");
|
||||
return m_arg1.c_get();
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const char* AACDecoder::arg2() {
|
||||
if (m_frameInfo.sbr == 1) return "upsampled SBR";
|
||||
if (m_frameInfo.sbr == 2) return "downsampled SBR";
|
||||
if (m_frameInfo.sbr == 3) return "no SBR used, but file is upsampled by a factor 2";
|
||||
return "without SBR";
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t AACDecoder::val1() { // Parametric Stereo
|
||||
return m_frameInfo.isPS;
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t AACDecoder::val2() { // Spectral Band Replication
|
||||
return m_frameInfo.sbr; // NO_SBR 0 /* no SBR used in this file */
|
||||
// SBR_UPSAMPLED 1 /* upsampled SBR used */
|
||||
// SBR_DOWNSAMPLED 2 /* downsampled SBR used */
|
||||
// NO_SBR_UPSAMPLED 3 /* no SBR used, but file is upsampled by a factor 2 anyway */
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
void AACDecoder::createAudioSpecificConfig(uint8_t* config, uint8_t audioObjectType, uint8_t samplingFrequencyIndex, uint8_t channelConfiguration) {
|
||||
config[0] = (audioObjectType << 3) | (samplingFrequencyIndex >> 1);
|
||||
config[1] = (samplingFrequencyIndex << 7) | (channelConfiguration << 3);
|
||||
}
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
// extern uint8_t NeaacDecoder::get_sr_index(const uint32_t samplerate);
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* aac_decoder.h
|
||||
* faad2 - ESP32 adaptation
|
||||
* Created on: 12.09.2023
|
||||
* Updated on: 13.06.2026
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Audio.h"
|
||||
#include "libfaad/aac_settings.h"
|
||||
#include "libfaad/aac_structs.h"
|
||||
#include "libfaad/aac_defines.h"
|
||||
#include "libfaad/aac_tables.h"
|
||||
#include "libfaad/neaacdec.h"
|
||||
|
||||
#pragma GCC diagnostic warning "-Wunused-function"
|
||||
|
||||
class AACDecoder : public Decoder {
|
||||
|
||||
public:
|
||||
enum : int8_t {
|
||||
AAC_ID3_HDR = 100,
|
||||
AAC_NONE = 0,
|
||||
AAC_ERR = -1,
|
||||
};
|
||||
|
||||
AACDecoder(Audio& audioRef);
|
||||
~AACDecoder() { reset(); }
|
||||
bool init() override;
|
||||
void clear() override;
|
||||
void reset() override;
|
||||
bool isValid() override;
|
||||
int32_t findSyncWord(uint8_t* buf, int32_t nBytes) override;
|
||||
uint8_t getChannels() override;
|
||||
uint32_t getSampleRate() override;
|
||||
uint32_t getOutputSamples();
|
||||
uint8_t getBitsPerSample() override;
|
||||
uint32_t getBitRate() override;
|
||||
uint32_t getAudioDataStart() override;
|
||||
uint32_t getAudioFileDuration() override;
|
||||
const char* getStreamTitle() override;
|
||||
const char* whoIsIt() override;
|
||||
int32_t decode(uint8_t* inbuf, int32_t* bytesLeft, int32_t* outbuf) override;
|
||||
void setRawBlockParams(uint8_t channels, uint32_t sampleRate, uint8_t BPS, uint32_t tsis, uint32_t AuDaLength) override;
|
||||
std::vector<uint32_t> getMetadataBlockPicture() override;
|
||||
const char* arg1() override;
|
||||
const char* arg2() override;
|
||||
virtual int32_t val1() override; // Paramertric Stereo
|
||||
virtual int32_t val2() override; // SBR
|
||||
|
||||
private:
|
||||
Audio& audio;
|
||||
ps_ptr<char> m_arg1;
|
||||
ps_ptr<int16_t> m_out16;
|
||||
void createAudioSpecificConfig(uint8_t* config, uint8_t audioObjectType, uint8_t samplingFrequencyIndex, uint8_t channelConfiguration);
|
||||
error_info_t getErrorMessage(int8_t err);
|
||||
|
||||
NeAACDecHandle m_hAac;
|
||||
NeAACDecFrameInfo m_frameInfo;
|
||||
NeAACDecConfigurationPtr m_conf;
|
||||
const uint8_t SYNCWORDH = 0xff; /* 12-bit syncword */
|
||||
const uint8_t SYNCWORDL = 0xf0;
|
||||
bool m_f_decoderIsInit = false;
|
||||
bool m_f_firstCall = false;
|
||||
bool m_f_setRaWBlockParams = false;
|
||||
uint32_t m_aacSamplerate = 0;
|
||||
uint8_t m_aacChannels = 0;
|
||||
uint8_t m_aacProfile = 0;
|
||||
uint16_t m_validSamples = 0;
|
||||
float m_compressionRatio = 1;
|
||||
std::unique_ptr<NeaacDecoder> m_neaacdec;
|
||||
|
||||
struct AudioSpecificConfig {
|
||||
uint8_t audioObjectType;
|
||||
uint8_t samplingFrequencyIndex;
|
||||
uint8_t channelConfiguration;
|
||||
};
|
||||
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
};
|
||||
@@ -1,450 +0,0 @@
|
||||
#pragma once
|
||||
#include "Arduino.h"
|
||||
#include "../../Audio.h"
|
||||
#include "aac_settings.h"
|
||||
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
/* defines if an object type can be decoded by this library or not */
|
||||
__unused static uint8_t ObjectTypesTable[32] = {
|
||||
0, /* 0 NULL */
|
||||
#ifdef MAIN_DEC
|
||||
1, /* 1 AAC Main */
|
||||
#else
|
||||
0, /* 1 AAC Main */
|
||||
#endif
|
||||
1, /* 2 AAC LC */
|
||||
#ifdef SSR_DEC
|
||||
1, /* 3 AAC SSR */
|
||||
#else
|
||||
0, /* 3 AAC SSR */
|
||||
#endif
|
||||
#ifdef LTP_DEC
|
||||
1, /* 4 AAC LTP */
|
||||
#else
|
||||
0, /* 4 AAC LTP */
|
||||
#endif
|
||||
#ifdef SBR_DEC
|
||||
1, /* 5 SBR */
|
||||
#else
|
||||
0, /* 5 SBR */
|
||||
#endif
|
||||
0, /* 6 AAC Scalable */
|
||||
0, /* 7 TwinVQ */
|
||||
0, /* 8 CELP */
|
||||
0, /* 9 HVXC */
|
||||
0, /* 10 Reserved */
|
||||
0, /* 11 Reserved */
|
||||
0, /* 12 TTSI */
|
||||
0, /* 13 Main synthetic */
|
||||
0, /* 14 Wavetable synthesis */
|
||||
0, /* 15 General MIDI */
|
||||
0, /* 16 Algorithmic Synthesis and Audio FX */
|
||||
/* MPEG-4 Version 2 */
|
||||
#ifdef ERROR_RESILIENCE
|
||||
1, /* 17 ER AAC LC */
|
||||
0, /* 18 (Reserved) */
|
||||
#ifdef LTP_DEC
|
||||
1, /* 19 ER AAC LTP */
|
||||
#else
|
||||
0, /* 19 ER AAC LTP */
|
||||
#endif
|
||||
0, /* 20 ER AAC scalable */
|
||||
0, /* 21 ER TwinVQ */
|
||||
0, /* 22 ER BSAC */
|
||||
#ifdef LD_DEC
|
||||
1, /* 23 ER AAC LD */
|
||||
#else
|
||||
0, /* 23 ER AAC LD */
|
||||
#endif
|
||||
0, /* 24 ER CELP */
|
||||
0, /* 25 ER HVXC */
|
||||
0, /* 26 ER HILN */
|
||||
0, /* 27 ER Parametric */
|
||||
#else /* No ER defined */
|
||||
0, /* 17 ER AAC LC */
|
||||
0, /* 18 (Reserved) */
|
||||
0, /* 19 ER AAC LTP */
|
||||
0, /* 20 ER AAC scalable */
|
||||
0, /* 21 ER TwinVQ */
|
||||
0, /* 22 ER BSAC */
|
||||
0, /* 23 ER AAC LD */
|
||||
0, /* 24 ER CELP */
|
||||
0, /* 25 ER HVXC */
|
||||
0, /* 26 ER HILN */
|
||||
0, /* 27 ER Parametric */
|
||||
#endif
|
||||
0, /* 28 (Reserved) */
|
||||
#ifdef PS_DEC
|
||||
1, /* 29 AAC LC + SBR + PS */
|
||||
#else
|
||||
0, /* 29 AAC LC + SBR + PS */
|
||||
#endif
|
||||
0, /* 30 (Reserved) */
|
||||
0 /* 31 (Reserved) */
|
||||
};
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
#define ZERO_HCB 0
|
||||
#define FIRST_PAIR_HCB 5
|
||||
#define ESC_HCB 11
|
||||
#define QUAD_LEN 4
|
||||
#define PAIR_LEN 2
|
||||
#define NOISE_HCB 13
|
||||
#define INTENSITY_HCB2 14
|
||||
#define INTENSITY_HCB 15
|
||||
#define DRC_REF_LEVEL 20 * 4 /* -20 dB */
|
||||
#define DRM_PARAMETRIC_STEREO 0
|
||||
#define DRM_NUM_SA_BANDS 8
|
||||
#define DRM_NUM_PAN_BANDS 20
|
||||
#define NUM_OF_LINKS 3
|
||||
#define NUM_OF_QMF_CHANNELS 64
|
||||
#define NUM_OF_SUBSAMPLES 30
|
||||
#define MAX_SA_BAND 46
|
||||
#define MAX_PAN_BAND 64
|
||||
#define MAX_DELAY 5
|
||||
#define EXTENSION_ID_PS 2
|
||||
#define MAX_PS_ENVELOPES 5
|
||||
#define NO_ALLPASS_LINKS 3
|
||||
#define BYTE_NUMBIT 8
|
||||
#define BYTE_NUMBIT_LD 3
|
||||
#define bit2byte(a) ((a + 7) >> BYTE_NUMBIT_LD)
|
||||
#define NUM_ERROR_MESSAGES 34
|
||||
#define ESC_VAL 7
|
||||
#define SSR_BANDS 4
|
||||
#define PQFTAPS 96
|
||||
|
||||
#ifdef DRM
|
||||
#define DECAY_CUTOFF 3
|
||||
#define DECAY_SLOPE 0.05f
|
||||
/* type definitaions */
|
||||
typedef const int8_t (*drm_ps_huff_tab)[2];
|
||||
#endif
|
||||
|
||||
#define FLOAT_SCALE (1.0f / (1 << 15))
|
||||
#define DM_MUL REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))
|
||||
#define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2)
|
||||
#define NUM_CB 6
|
||||
#define NUM_CB_ER 22
|
||||
#define MAX_CB 32
|
||||
#define VCB11_FIRST 16
|
||||
#define VCB11_LAST 31
|
||||
#define TNS_MAX_ORDER 20
|
||||
#define MAIN 1
|
||||
#define LC 2
|
||||
#define SSR 3
|
||||
#define LTP 4
|
||||
#define HE_AAC 5
|
||||
#define LD 23
|
||||
#define ER_LC 17
|
||||
#define ER_LTP 19
|
||||
#define DRM_ER_LC 27 /* special object type for DRM */
|
||||
/* header types */
|
||||
#define RAW 0
|
||||
#define ADIF 1
|
||||
#define ADTS 2
|
||||
#define LATM 3
|
||||
/* SBR signalling */
|
||||
#define NO_SBR 0
|
||||
#define SBR_UPSAMPLED 1
|
||||
#define SBR_DOWNSAMPLED 2
|
||||
#define NO_SBR_UPSAMPLED 3
|
||||
/* DRM channel definitions */
|
||||
#define DRMCH_MONO 1
|
||||
#define DRMCH_STEREO 2
|
||||
#define DRMCH_SBR_MONO 3
|
||||
#define DRMCH_SBR_STEREO 4
|
||||
#define DRMCH_SBR_PS_STEREO 5
|
||||
/* First object type that has ER */
|
||||
#define ER_OBJECT_START 17
|
||||
/* Bitstream */
|
||||
#define LEN_SE_ID 3
|
||||
#define LEN_TAG 4
|
||||
#define LEN_BYTE 8
|
||||
#define EXT_FIL 0
|
||||
#define EXT_FILL_DATA 1
|
||||
#define EXT_DATA_ELEMENT 2
|
||||
#define EXT_DYNAMIC_RANGE 11
|
||||
#define ANC_DATA 0
|
||||
/* Syntax elements */
|
||||
#define ID_SCE 0x0
|
||||
#define ID_CPE 0x1
|
||||
#define ID_CCE 0x2
|
||||
#define ID_LFE 0x3
|
||||
#define ID_DSE 0x4
|
||||
#define ID_PCE 0x5
|
||||
#define ID_FIL 0x6
|
||||
#define ID_END 0x7
|
||||
#define INVALID_ELEMENT_ID 255
|
||||
#define ONLY_LONG_SEQUENCE 0x0
|
||||
#define LONG_START_SEQUENCE 0x1
|
||||
#define EIGHT_SHORT_SEQUENCE 0x2
|
||||
#define LONG_STOP_SEQUENCE 0x3
|
||||
#define ZERO_HCB 0
|
||||
#define FIRST_PAIR_HCB 5
|
||||
#define ESC_HCB 11
|
||||
#define QUAD_LEN 4
|
||||
#define PAIR_LEN 2
|
||||
#define NOISE_HCB 13
|
||||
#define INTENSITY_HCB2 14
|
||||
#define INTENSITY_HCB 15
|
||||
#define INVALID_SBR_ELEMENT 255
|
||||
#define T_HFGEN 8
|
||||
#define T_HFADJ 2
|
||||
#define EXT_SBR_DATA 13
|
||||
#define EXT_SBR_DATA_CRC 14
|
||||
#define FIXFIX 0
|
||||
#define FIXVAR 1
|
||||
#define VARFIX 2
|
||||
#define VARVAR 3
|
||||
#define LO_RES 0
|
||||
#define HI_RES 1
|
||||
#define NO_TIME_SLOTS_960 15
|
||||
#define NO_TIME_SLOTS 16
|
||||
#define RATE 2
|
||||
#define NOISE_FLOOR_OFFSET 6
|
||||
|
||||
#ifdef PS_DEC
|
||||
#define NEGATE_IPD_MASK (0x1000)
|
||||
#define DECAY_SLOPE FRAC_CONST(0.05)
|
||||
#define COEF_SQRT2 COEF_CONST(1.4142135623731)
|
||||
#endif // PS_DEC
|
||||
|
||||
#define MAX_NTSRHFG 40 /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */
|
||||
#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
|
||||
#define MAX_M 49 /* MAX_M: maximum value for M */
|
||||
#define MAX_L_E 5 /* MAX_L_E: maximum value for L_E */
|
||||
|
||||
#ifdef SBR_DEC
|
||||
#ifdef FIXED_POINT
|
||||
#define _EPS (1) /* smallest number available in fixed point */
|
||||
#else
|
||||
#define _EPS (1e-12)
|
||||
#endif
|
||||
#endif // SBR_DEC
|
||||
|
||||
#ifdef FIXED_POINT /* int32_t */
|
||||
#define LOG2_MIN_INF REAL_CONST(-10000)
|
||||
#define COEF_BITS 28
|
||||
#define COEF_PRECISION (1 << COEF_BITS)
|
||||
#define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR
|
||||
#define REAL_PRECISION (1 << REAL_BITS)
|
||||
/* FRAC is the fractional only part of the fixed point number [0.0..1.0) */
|
||||
#define FRAC_SIZE 32 /* frac is a 32 bit integer */
|
||||
#define FRAC_BITS 31
|
||||
#define FRAC_PRECISION ((uint32_t)(1 << FRAC_BITS))
|
||||
#define FRAC_MAX 0x7FFFFFFF
|
||||
typedef int32_t real_t;
|
||||
#define REAL_CONST(A) (((A) >= 0) ? ((real_t)((A) * (REAL_PRECISION) + 0.5)) : ((real_t)((A) * (REAL_PRECISION) - 0.5)))
|
||||
#define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A) * (COEF_PRECISION) + 0.5)) : ((real_t)((A) * (COEF_PRECISION) - 0.5)))
|
||||
#define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : (((A) >= 0) ? ((real_t)((A) * (FRAC_PRECISION) + 0.5)) : ((real_t)((A) * (FRAC_PRECISION) - 0.5))))
|
||||
// #define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))
|
||||
#define Q2_BITS 22
|
||||
#define Q2_PRECISION (1 << Q2_BITS)
|
||||
#define Q2_CONST(A) (((A) >= 0) ? ((real_t)((A) * (Q2_PRECISION) + 0.5)) : ((real_t)((A) * (Q2_PRECISION) - 0.5)))
|
||||
/* multiply with real shift */
|
||||
#define MUL_R(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (REAL_BITS - 1))) >> REAL_BITS)
|
||||
/* multiply with coef shift */
|
||||
#define MUL_C(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (COEF_BITS - 1))) >> COEF_BITS)
|
||||
/* multiply with fractional shift */
|
||||
#define _MulHigh(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (FRAC_SIZE - 1))) >> FRAC_SIZE)
|
||||
#define MUL_F(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (FRAC_BITS - 1))) >> FRAC_BITS)
|
||||
#define MUL_Q2(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (Q2_BITS - 1))) >> Q2_BITS)
|
||||
#define MUL_SHIFT6(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (6 - 1))) >> 6)
|
||||
#define MUL_SHIFT23(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (23 - 1))) >> 23)
|
||||
#define DIV_R(A, B) (((int64_t)A << REAL_BITS) / B)
|
||||
#define DIV_C(A, B) (((int64_t)A << COEF_BITS) / B)
|
||||
/* Complex multiplication */
|
||||
static inline void ComplexMult(real_t* y1, real_t* y2, real_t x1, real_t x2, real_t c1, real_t c2) { // FIXED POINT
|
||||
*y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2)) << (FRAC_SIZE - FRAC_BITS);
|
||||
*y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2)) << (FRAC_SIZE - FRAC_BITS);
|
||||
}
|
||||
// static inline void ComplexMult(int32_t* y1, int32_t* y2, int32_t x1, int32_t x2, int32_t c1, int32_t c2) { // only XTENSA chips
|
||||
// asm volatile (
|
||||
// // y1 = (x1 * c1) + (x2 * c2)
|
||||
// "mulsh a2, %2, %4\n" // a2 = x1 * c1 (Low 32 bits)
|
||||
// "mulsh a3, %3, %5\n" // a3 = x2 * c2 (Low 32 bits)
|
||||
// "add a2, a2, a3\n" // a2 = (x1 * c1) + (x2 * c2)
|
||||
// "slli a2, a2, 1\n" // a2 = a2 >> 31 (Fixed-Point scaling)
|
||||
// "s32i a2, %0 \n" // Store result in *y1
|
||||
// // y2 = (x2 * c1) - (x1 * c2)
|
||||
// "mulsh a2, %3, %4\n" // a2 = x2 * c1 (Low 32 bits)
|
||||
// "mulsh a3, %2, %5\n" // a3 = x1 * c2 (Low 32 bits)
|
||||
// "sub a2, a2, a3\n" // a2 = (x2 * c1) - (x1 * c2)
|
||||
// "slli a2, a2, 1\n" // a2 = a2 >> 31 (Fixed-Point scaling)
|
||||
// "s32i a2, %1 \n" // Store result in *y2
|
||||
// : "=m" (*y1), "=m" (*y2) // Output
|
||||
// : "r" (x1), "r" (x2), "r" (c1), "r" (c2) // Input
|
||||
// : "a2", "a3" // Clobbers
|
||||
// );
|
||||
// }
|
||||
|
||||
#define DIV(A, B) (((int64_t)A << REAL_BITS) / B)
|
||||
#define step(shift) \
|
||||
if ((0x40000000l >> shift) + root <= value) { \
|
||||
value -= (0x40000000l >> shift) + root; \
|
||||
root = (root >> 1) | (0x40000000l >> shift); \
|
||||
} else { \
|
||||
root = root >> 1; \
|
||||
}
|
||||
|
||||
real_t const pow2_table[] = {COEF_CONST(1.0), COEF_CONST(1.18920711500272), COEF_CONST(1.41421356237310), COEF_CONST(1.68179283050743)};
|
||||
#endif // FIXED_POINT
|
||||
#ifndef FIXED_POINT
|
||||
#ifdef MAIN_DEC
|
||||
#define ALPHA REAL_CONST(0.90625)
|
||||
#define A REAL_CONST(0.953125)
|
||||
#endif
|
||||
#define IQ_TABLE_SIZE 8192
|
||||
#define DIV_R(A, B) ((A) / (B))
|
||||
#define DIV_C(A, B) ((A) / (B))
|
||||
#ifdef USE_DOUBLE_PRECISION /* double */
|
||||
typedef double real_t;
|
||||
#include <math.h>
|
||||
#define MUL_R(A, B) ((A) * (B))
|
||||
#define MUL_C(A, B) ((A) * (B))
|
||||
#define MUL_F(A, B) ((A) * (B))
|
||||
#define REAL_CONST(A) ((real_t)(A))
|
||||
#define COEF_CONST(A) ((real_t)(A))
|
||||
#define Q2_CONST(A) ((real_t)(A))
|
||||
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */
|
||||
/* Complex multiplication */
|
||||
static void ComplexMult(real_t* y1, real_t* y2, real_t x1, real_t x2, real_t c1, real_t c2) {
|
||||
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
|
||||
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
|
||||
}
|
||||
#else /* Normal floating point operation */
|
||||
typedef float real_t;
|
||||
#define MUL_R(A, B) ((A) * (B))
|
||||
#define MUL_C(A, B) ((A) * (B))
|
||||
#define MUL_F(A, B) ((A) * (B))
|
||||
#define REAL_CONST(A) ((real_t)(A))
|
||||
#define COEF_CONST(A) ((real_t)(A))
|
||||
#define Q2_CONST(A) ((real_t)(A))
|
||||
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */
|
||||
/* Complex multiplication */
|
||||
__unused static void ComplexMult(real_t* y1, real_t* y2, real_t x1, real_t x2, real_t c1, real_t c2) {
|
||||
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
|
||||
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
|
||||
}
|
||||
|
||||
#endif /* USE_DOUBLE_PRECISION */
|
||||
#endif // FIXED_POINT
|
||||
|
||||
#ifdef SBR_LOW_POWER
|
||||
#define qmf_t real_t
|
||||
#define QMF_RE(A) (A)
|
||||
#define QMF_IM(A)
|
||||
#else
|
||||
#define qmf_t complex_t
|
||||
#define QMF_RE(A) RE(A)
|
||||
#define QMF_IM(A) IM(A)
|
||||
#endif
|
||||
typedef real_t complex_t[2];
|
||||
#define RE(A) A[0]
|
||||
#define IM(A) A[1]
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#if !defined(max) && !defined(__cplusplus)
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#if !defined(min) && !defined(__cplusplus)
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef FAAD2_VERSION
|
||||
#define FAAD2_VERSION "unknown"
|
||||
#endif
|
||||
/* object types for AAC */
|
||||
#define MAIN 1
|
||||
#define LC 2
|
||||
#define SSR 3
|
||||
#define LTP 4
|
||||
#define HE_AAC 5
|
||||
#define ER_LC 17
|
||||
#define ER_LTP 19
|
||||
#define LD 23
|
||||
#define DRM_ER_LC 27 /* special object type for DRM */
|
||||
/* header types */
|
||||
#define RAW 0
|
||||
#define ADIF 1
|
||||
#define ADTS 2
|
||||
#define LATM 3
|
||||
/* SBR signalling */
|
||||
#define NO_SBR 0
|
||||
#define SBR_UPSAMPLED 1
|
||||
#define SBR_DOWNSAMPLED 2
|
||||
#define NO_SBR_UPSAMPLED 3
|
||||
/* library output formats */
|
||||
#define FAAD_FMT_16BIT 1
|
||||
#define FAAD_FMT_24BIT 2
|
||||
#define FAAD_FMT_32BIT 3
|
||||
#define FAAD_FMT_FLOAT 4
|
||||
#define FAAD_FMT_FIXED FAAD_FMT_FLOAT
|
||||
#define FAAD_FMT_DOUBLE 5
|
||||
/* Capabilities */
|
||||
#define LC_DEC_CAP (1 << 0) /* Can decode LC */
|
||||
#define MAIN_DEC_CAP (1 << 1) /* Can decode MAIN */
|
||||
#define LTP_DEC_CAP (1 << 2) /* Can decode LTP */
|
||||
#define LD_DEC_CAP (1 << 3) /* Can decode LD */
|
||||
#define ERROR_RESILIENCE_CAP (1 << 4) /* Can decode ER */
|
||||
#define FIXED_POINT_CAP (1 << 5) /* Fixed point */
|
||||
/* Channel definitions */
|
||||
#define FRONT_CHANNEL_CENTER (1)
|
||||
#define FRONT_CHANNEL_LEFT (2)
|
||||
#define FRONT_CHANNEL_RIGHT (3)
|
||||
#define SIDE_CHANNEL_LEFT (4)
|
||||
#define SIDE_CHANNEL_RIGHT (5)
|
||||
#define BACK_CHANNEL_LEFT (6)
|
||||
#define BACK_CHANNEL_RIGHT (7)
|
||||
#define BACK_CHANNEL_CENTER (8)
|
||||
#define LFE_CHANNEL (9)
|
||||
#define UNKNOWN_CHANNEL (0)
|
||||
/* DRM channel definitions */
|
||||
#define DRMCH_MONO 1
|
||||
#define DRMCH_STEREO 2
|
||||
#define DRMCH_SBR_MONO 3
|
||||
#define DRMCH_SBR_STEREO 4
|
||||
#define DRMCH_SBR_PS_STEREO 5
|
||||
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
|
||||
so at least so much bytes per channel should be available in this stream */
|
||||
#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
|
||||
|
||||
#define MAX_CHANNELS 64
|
||||
#define MAX_SYNTAX_ELEMENTS 48
|
||||
#define MAX_WINDOW_GROUPS 8
|
||||
#define MAX_SFB 51
|
||||
#define MAX_LTP_SFB 40
|
||||
#define MAX_LTP_SFB_S 8
|
||||
#define MAX_ASC_BYTES 64
|
||||
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
#ifndef FIXED_POINT
|
||||
#ifndef HAS_LRINTF
|
||||
#define CLIP(sample, max, min) \
|
||||
if (sample >= 0.0f) { \
|
||||
sample += 0.5f; \
|
||||
if (sample >= max) sample = max; \
|
||||
} else { \
|
||||
sample += -0.5f; \
|
||||
if (sample <= min) sample = min; \
|
||||
}
|
||||
#else
|
||||
#define CLIP(sample, max, min) \
|
||||
if (sample >= 0.0f) { \
|
||||
if (sample >= max) sample = max; \
|
||||
} else { \
|
||||
if (sample <= min) sample = min; \
|
||||
}
|
||||
#endif
|
||||
#define CONV(a, b) ((a << 1) | (b & 0x1))
|
||||
#endif
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
// Macro for comfortable calls
|
||||
#define AAC_LOG_ERROR(fmt, ...) Audio::AUDIO_LOG_IMPL(1, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define AAC_LOG_WARN(fmt, ...) Audio::AUDIO_LOG_IMPL(2, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define AAC_LOG_INFO(fmt, ...) Audio::AUDIO_LOG_IMPL(3, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define AAC_LOG_DEBUG(fmt, ...) Audio::AUDIO_LOG_IMPL(4, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define AAC_LOG_VERBOSE(fmt, ...) Audio::AUDIO_LOG_IMPL(5, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
@@ -1,90 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/* ----------------------COMPILE TIME DEFINITIONS ---------------- */
|
||||
#define PREFER_POINTERS // Use if target platform has address generators with autoincrement
|
||||
// #define BIG_IQ_TABLE
|
||||
// #define USE_DOUBLE_PRECISION // use double precision
|
||||
// #define FIXED_POINT // use fixed point reals, undefs MAIN_DEC and SSR_DEC
|
||||
// #define ERROR_RESILIENCE 2
|
||||
// #define MAIN_DEC // Allow decoding of MAIN profile AAC
|
||||
// #define SSR_DEC // Allow decoding of SSR profile AAC
|
||||
#define LTP_DEC // Allow decoding of LTP (Long Term Prediction) profile AAC
|
||||
#define LD_DEC // Allow decoding of LD (Low Delay) profile AAC
|
||||
// #define DRM_SUPPORT // Allow decoding of Digital Radio Mondiale (DRM)
|
||||
#if (defined CONFIG_IDF_TARGET_ESP32S3 || defined CONFIG_IDF_TARGET_ESP32P4)
|
||||
#define SBR_DEC // Allow decoding of SBR (Spectral Band Replication) profile AAC
|
||||
#define PS_DEC // Allow decoding of PS (Parametric Stereo) profile AAC
|
||||
#endif
|
||||
// #define SBR_LOW_POWER
|
||||
#define ALLOW_SMALL_FRAMELENGTH
|
||||
// #define LC_ONLY_DECODER // if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC)
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
#ifdef DRM_SUPPORT // Allow decoding of Digital Radio Mondiale (DRM)
|
||||
#define DRM
|
||||
#define DRM_PS
|
||||
#undef PS_DEC
|
||||
#endif
|
||||
#ifdef LD_DEC /* LD can't do without LTP */
|
||||
#ifndef ERROR_RESILIENCE
|
||||
#define ERROR_RESILIENCE
|
||||
#endif
|
||||
#ifndef LTP_DEC
|
||||
#define LTP_DEC
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LC_ONLY_DECODER
|
||||
#undef LD_DEC
|
||||
#undef LTP_DEC
|
||||
#undef MAIN_DEC
|
||||
#undef SSR_DEC
|
||||
#undef DRM
|
||||
#undef DRM_PS
|
||||
#undef ALLOW_SMALL_FRAMELENGTH
|
||||
#undef ERROR_RESILIENCE
|
||||
#endif
|
||||
#ifdef SBR_LOW_POWER
|
||||
#undef PS_DEC
|
||||
#endif
|
||||
#ifdef FIXED_POINT /* No MAIN decoding */
|
||||
#ifdef MAIN_DEC
|
||||
#undef MAIN_DEC
|
||||
#endif
|
||||
#endif // FIXED_POINT
|
||||
#ifdef DRM
|
||||
#ifndef ALLOW_SMALL_FRAMELENGTH
|
||||
#define ALLOW_SMALL_FRAMELENGTH
|
||||
#endif
|
||||
#undef LD_DEC
|
||||
#undef LTP_DEC
|
||||
#undef MAIN_DEC
|
||||
#undef SSR_DEC
|
||||
#endif
|
||||
/* END COMPILE TIME DEFINITIONS */
|
||||
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define ARCH_IS_BIG_ENDIAN
|
||||
#endif
|
||||
/* FIXED_POINT doesn't work with MAIN and SSR yet */
|
||||
#ifdef FIXED_POINT
|
||||
#undef MAIN_DEC
|
||||
#undef SSR_DEC
|
||||
#endif
|
||||
#if defined(FIXED_POINT)
|
||||
#elif defined(USE_DOUBLE_PRECISION)
|
||||
#else /* Normal floating point operation */
|
||||
#ifdef HAVE_LRINTF
|
||||
#define HAS_LRINTF
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC9X 1
|
||||
#define __USE_ISOC99 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef HAS_LRINTF
|
||||
/* standard cast */
|
||||
// #define int32_t(f) ((int32_t)(f))
|
||||
#endif
|
||||
@@ -1,672 +0,0 @@
|
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
**
|
||||
** Any non-GPL usage of this software or parts of this software is strictly
|
||||
** forbidden.
|
||||
**
|
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2
|
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
|
||||
**
|
||||
** Commercial non-GPL licensing of this software is possible.
|
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
|
||||
**
|
||||
** $Id: structs.h,v 1.49 2009/01/26 23:51:15 menno Exp $
|
||||
**/
|
||||
#pragma once
|
||||
#include "Arduino.h"
|
||||
#include "aac_defines.h"
|
||||
#include "aac_settings.h"
|
||||
|
||||
typedef void* NeAACDecHandle;
|
||||
typedef struct mp4AudioSpecificConfig {
|
||||
/* Audio Specific Info */
|
||||
unsigned char objectTypeIndex;
|
||||
unsigned char samplingFrequencyIndex;
|
||||
uint32_t samplingFrequency;
|
||||
unsigned char channelsConfiguration;
|
||||
/* GA Specific Info */
|
||||
unsigned char frameLengthFlag;
|
||||
unsigned char dependsOnCoreCoder;
|
||||
unsigned short coreCoderDelay;
|
||||
unsigned char extensionFlag;
|
||||
unsigned char aacSectionDataResilienceFlag;
|
||||
unsigned char aacScalefactorDataResilienceFlag;
|
||||
unsigned char aacSpectralDataResilienceFlag;
|
||||
unsigned char epConfig;
|
||||
char sbr_present_flag;
|
||||
char forceUpSampling;
|
||||
char downSampledSBR;
|
||||
} mp4AudioSpecificConfig;
|
||||
typedef struct NeAACDecFrameInfo {
|
||||
uint32_t bytesconsumed;
|
||||
uint32_t samples;
|
||||
unsigned char channels;
|
||||
unsigned char error;
|
||||
uint32_t samplerate;
|
||||
/* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
|
||||
unsigned char sbr;
|
||||
/* MPEG-4 ObjectType */
|
||||
unsigned char object_type;
|
||||
/* AAC header type; MP4 will be signalled as RAW also */
|
||||
unsigned char header_type;
|
||||
/* multichannel configuration */
|
||||
unsigned char num_front_channels;
|
||||
unsigned char num_side_channels;
|
||||
unsigned char num_back_channels;
|
||||
unsigned char num_lfe_channels;
|
||||
unsigned char channel_position[64];
|
||||
/* PS: 0: off, 1: on */
|
||||
unsigned char ps;
|
||||
uint8_t isPS;
|
||||
} NeAACDecFrameInfo;
|
||||
|
||||
/* used to save the prediction state */
|
||||
typedef struct {
|
||||
uint16_t n;
|
||||
uint16_t ifac[15];
|
||||
complex_t* work;
|
||||
complex_t* tab;
|
||||
} cfft_info;
|
||||
typedef struct {
|
||||
int16_t r[2];
|
||||
int16_t COR[2];
|
||||
int16_t VAR[2];
|
||||
} pred_state;
|
||||
typedef struct {
|
||||
uint16_t N;
|
||||
cfft_info* cfft;
|
||||
complex_t* sincos;
|
||||
int64_t cycles;
|
||||
int64_t fft_cycles;
|
||||
} mdct_info;
|
||||
typedef struct {
|
||||
const real_t* long_window[2];
|
||||
const real_t* short_window[2];
|
||||
const real_t* ld_window[2];
|
||||
int64_t cycles;
|
||||
} fb_info;
|
||||
typedef struct {
|
||||
uint8_t present;
|
||||
uint8_t num_bands;
|
||||
uint8_t pce_instance_tag;
|
||||
uint8_t excluded_chns_present;
|
||||
uint8_t band_top[17];
|
||||
uint8_t prog_ref_level;
|
||||
uint8_t dyn_rng_sgn[17];
|
||||
uint8_t dyn_rng_ctl[17];
|
||||
uint8_t exclude_mask[MAX_CHANNELS];
|
||||
uint8_t additional_excluded_chns[MAX_CHANNELS];
|
||||
real_t ctrl1;
|
||||
real_t ctrl2;
|
||||
} drc_info;
|
||||
typedef struct {
|
||||
uint8_t element_instance_tag;
|
||||
uint8_t object_type;
|
||||
uint8_t sf_index;
|
||||
uint8_t num_front_channel_elements;
|
||||
uint8_t num_side_channel_elements;
|
||||
uint8_t num_back_channel_elements;
|
||||
uint8_t num_lfe_channel_elements;
|
||||
uint8_t num_assoc_data_elements;
|
||||
uint8_t num_valid_cc_elements;
|
||||
uint8_t mono_mixdown_present;
|
||||
uint8_t mono_mixdown_element_number;
|
||||
uint8_t stereo_mixdown_present;
|
||||
uint8_t stereo_mixdown_element_number;
|
||||
uint8_t matrix_mixdown_idx_present;
|
||||
uint8_t pseudo_surround_enable;
|
||||
uint8_t matrix_mixdown_idx;
|
||||
uint8_t front_element_is_cpe[16];
|
||||
uint8_t front_element_tag_select[16];
|
||||
uint8_t side_element_is_cpe[16];
|
||||
uint8_t side_element_tag_select[16];
|
||||
uint8_t back_element_is_cpe[16];
|
||||
uint8_t back_element_tag_select[16];
|
||||
uint8_t lfe_element_tag_select[16];
|
||||
uint8_t assoc_data_element_tag_select[16];
|
||||
uint8_t cc_element_is_ind_sw[16];
|
||||
uint8_t valid_cc_element_tag_select[16];
|
||||
uint8_t channels;
|
||||
uint8_t comment_field_bytes;
|
||||
uint8_t comment_field_data[257];
|
||||
uint8_t num_front_channels; /* extra added values */
|
||||
uint8_t num_side_channels;
|
||||
uint8_t num_back_channels;
|
||||
uint8_t num_lfe_channels;
|
||||
uint8_t sce_channel[16];
|
||||
uint8_t cpe_channel[16];
|
||||
} program_config;
|
||||
typedef struct {
|
||||
uint16_t syncword;
|
||||
uint8_t id;
|
||||
uint8_t layer;
|
||||
uint8_t protection_absent;
|
||||
uint8_t profile;
|
||||
uint8_t sf_index;
|
||||
uint8_t private_bit;
|
||||
uint8_t channel_configuration;
|
||||
uint8_t original;
|
||||
uint8_t home;
|
||||
uint8_t emphasis;
|
||||
uint8_t copyright_identification_bit;
|
||||
uint8_t copyright_identification_start;
|
||||
uint16_t aac_frame_length;
|
||||
uint16_t adts_buffer_fullness;
|
||||
uint8_t no_raw_data_blocks_in_frame;
|
||||
uint16_t crc_check;
|
||||
uint8_t old_format; /* control param */
|
||||
} adts_header;
|
||||
typedef struct {
|
||||
uint8_t copyright_id_present;
|
||||
int8_t copyright_id[10];
|
||||
uint8_t original_copy;
|
||||
uint8_t home;
|
||||
uint8_t bitstream_type;
|
||||
uint32_t bitrate;
|
||||
uint8_t num_program_config_elements;
|
||||
uint32_t adif_buffer_fullness;
|
||||
/* maximum of 16 PCEs */
|
||||
program_config pce[16];
|
||||
} adif_header;
|
||||
typedef struct {
|
||||
uint8_t last_band;
|
||||
uint8_t data_present;
|
||||
uint16_t lag;
|
||||
uint8_t lag_update;
|
||||
uint8_t coef;
|
||||
uint8_t long_used[MAX_SFB];
|
||||
uint8_t short_used[8];
|
||||
uint8_t short_lag_present[8];
|
||||
uint8_t short_lag[8];
|
||||
} ltp_info;
|
||||
typedef struct {
|
||||
uint8_t limit;
|
||||
uint8_t predictor_reset;
|
||||
uint8_t predictor_reset_group_number;
|
||||
uint8_t prediction_used[MAX_SFB];
|
||||
} pred_info;
|
||||
typedef struct {
|
||||
uint8_t number_pulse;
|
||||
uint8_t pulse_start_sfb;
|
||||
uint8_t pulse_offset[4];
|
||||
uint8_t pulse_amp[4];
|
||||
} pulse_info;
|
||||
typedef struct {
|
||||
uint8_t n_filt[8];
|
||||
uint8_t coef_res[8];
|
||||
uint8_t length[8][4];
|
||||
uint8_t order[8][4];
|
||||
uint8_t direction[8][4];
|
||||
uint8_t coef_compress[8][4];
|
||||
uint8_t coef[8][4][32];
|
||||
} tns_info;
|
||||
typedef struct {
|
||||
uint8_t max_band;
|
||||
uint8_t adjust_num[4][8];
|
||||
uint8_t alevcode[4][8][8];
|
||||
uint8_t aloccode[4][8][8];
|
||||
} ssr_info;
|
||||
typedef struct {
|
||||
uint8_t max_sfb;
|
||||
uint8_t num_swb;
|
||||
uint8_t num_window_groups;
|
||||
uint8_t num_windows;
|
||||
uint8_t window_sequence;
|
||||
uint8_t window_group_length[8];
|
||||
uint8_t window_shape;
|
||||
uint8_t scale_factor_grouping;
|
||||
uint16_t sect_sfb_offset[8][15 * 8];
|
||||
uint16_t swb_offset[52];
|
||||
uint16_t swb_offset_max;
|
||||
uint8_t sect_cb[8][15 * 8];
|
||||
uint16_t sect_start[8][15 * 8];
|
||||
uint16_t sect_end[8][15 * 8];
|
||||
uint8_t sfb_cb[8][8 * 15];
|
||||
uint8_t num_sec[8]; /* number of sections in a group */
|
||||
uint8_t global_gain;
|
||||
int16_t scale_factors[8][51]; /* [0..255] */
|
||||
uint8_t ms_mask_present;
|
||||
uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
|
||||
uint8_t noise_used;
|
||||
uint8_t is_used;
|
||||
uint8_t pulse_data_present;
|
||||
uint8_t tns_data_present;
|
||||
uint8_t gain_control_data_present;
|
||||
uint8_t predictor_data_present;
|
||||
pulse_info pul;
|
||||
tns_info tns;
|
||||
pred_info pred;
|
||||
ltp_info ltp;
|
||||
ltp_info ltp2;
|
||||
ssr_info ssr;
|
||||
uint16_t length_of_reordered_spectral_data; /* ER HCR data */
|
||||
uint8_t length_of_longest_codeword;
|
||||
uint8_t sf_concealment; /* ER RLVC data */
|
||||
uint8_t rev_global_gain;
|
||||
uint16_t length_of_rvlc_sf;
|
||||
uint16_t dpcm_noise_nrg;
|
||||
uint8_t sf_escapes_present;
|
||||
uint8_t length_of_rvlc_escapes;
|
||||
uint16_t dpcm_noise_last_position;
|
||||
} ic_stream; /* individual channel stream */
|
||||
typedef struct {
|
||||
uint8_t channel;
|
||||
int16_t paired_channel;
|
||||
uint8_t element_instance_tag;
|
||||
uint8_t common_window;
|
||||
ic_stream ics1;
|
||||
ic_stream ics2;
|
||||
} element; /* syntax element (SCE, CPE, LFE) */
|
||||
typedef struct {
|
||||
int inited;
|
||||
int version, versionA;
|
||||
int framelen_type;
|
||||
int useSameStreamMux;
|
||||
int allStreamsSameTimeFraming;
|
||||
int numSubFrames;
|
||||
int numPrograms;
|
||||
int numLayers;
|
||||
int otherDataPresent;
|
||||
uint32_t otherDataLenBits;
|
||||
uint32_t frameLength;
|
||||
uint8_t ASC[MAX_ASC_BYTES];
|
||||
uint32_t ASCbits;
|
||||
} latm_header;
|
||||
typedef struct NeAACDecConfiguration {
|
||||
unsigned char defObjectType;
|
||||
unsigned long defSampleRate;
|
||||
unsigned char outputFormat;
|
||||
unsigned char downMatrix;
|
||||
unsigned char useOldADTSFormat;
|
||||
unsigned char dontUpSampleImplicitSBR;
|
||||
} NeAACDecConfiguration, *NeAACDecConfigurationPtr;
|
||||
typedef struct {
|
||||
uint8_t drm_ps_data_available;
|
||||
uint8_t bs_enable_sa;
|
||||
uint8_t bs_enable_pan;
|
||||
uint8_t bs_sa_dt_flag;
|
||||
uint8_t bs_pan_dt_flag;
|
||||
uint8_t g_last_had_sa;
|
||||
uint8_t g_last_had_pan;
|
||||
int8_t bs_sa_data[DRM_NUM_SA_BANDS];
|
||||
int8_t bs_pan_data[DRM_NUM_PAN_BANDS];
|
||||
int8_t g_sa_index[DRM_NUM_SA_BANDS];
|
||||
int8_t g_pan_index[DRM_NUM_PAN_BANDS];
|
||||
int8_t g_prev_sa_index[DRM_NUM_SA_BANDS];
|
||||
int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS];
|
||||
int8_t sa_decode_error;
|
||||
int8_t pan_decode_error;
|
||||
int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS];
|
||||
int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS];
|
||||
qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND];
|
||||
complex_t d_buff[2][MAX_SA_BAND];
|
||||
complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND];
|
||||
uint8_t delay_buf_index_ser[NUM_OF_LINKS];
|
||||
real_t prev_nrg[MAX_SA_BAND];
|
||||
real_t prev_peakdiff[MAX_SA_BAND];
|
||||
real_t peakdecay_fast[MAX_SA_BAND];
|
||||
} drm_ps_info;
|
||||
typedef struct {
|
||||
/* bitstream parameters */
|
||||
uint8_t enable_iid;
|
||||
uint8_t enable_icc;
|
||||
uint8_t enable_ext;
|
||||
uint8_t iid_mode;
|
||||
uint8_t icc_mode;
|
||||
uint8_t nr_iid_par;
|
||||
uint8_t nr_ipdopd_par;
|
||||
uint8_t nr_icc_par;
|
||||
uint8_t frame_class;
|
||||
uint8_t num_env;
|
||||
uint8_t border_position[MAX_PS_ENVELOPES + 1];
|
||||
uint8_t iid_dt[MAX_PS_ENVELOPES];
|
||||
uint8_t icc_dt[MAX_PS_ENVELOPES];
|
||||
uint8_t enable_ipdopd;
|
||||
uint8_t ipd_mode;
|
||||
uint8_t ipd_dt[MAX_PS_ENVELOPES];
|
||||
uint8_t opd_dt[MAX_PS_ENVELOPES];
|
||||
/* indices */
|
||||
int8_t iid_index_prev[34];
|
||||
int8_t icc_index_prev[34];
|
||||
int8_t ipd_index_prev[17];
|
||||
int8_t opd_index_prev[17];
|
||||
int8_t iid_index[MAX_PS_ENVELOPES][34];
|
||||
int8_t icc_index[MAX_PS_ENVELOPES][34];
|
||||
int8_t ipd_index[MAX_PS_ENVELOPES][17];
|
||||
int8_t opd_index[MAX_PS_ENVELOPES][17];
|
||||
int8_t ipd_index_1[17];
|
||||
int8_t opd_index_1[17];
|
||||
int8_t ipd_index_2[17];
|
||||
int8_t opd_index_2[17];
|
||||
/* ps data was correctly read */
|
||||
uint8_t ps_data_available;
|
||||
/* a header has been read */
|
||||
uint8_t header_read;
|
||||
/* hybrid filterbank parameters */
|
||||
void* hyb;
|
||||
uint8_t use34hybrid_bands;
|
||||
uint8_t numTimeSlotsRate;
|
||||
/**/
|
||||
uint8_t num_groups;
|
||||
uint8_t num_hybrid_groups;
|
||||
uint8_t nr_par_bands;
|
||||
uint8_t nr_allpass_bands;
|
||||
uint8_t decay_cutoff;
|
||||
uint8_t* group_border;
|
||||
uint16_t* map_group2bk;
|
||||
/* filter delay handling */
|
||||
uint8_t saved_delay;
|
||||
uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS];
|
||||
uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS];
|
||||
uint8_t delay_D[64];
|
||||
uint8_t delay_buf_index_delay[64];
|
||||
complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */
|
||||
complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */
|
||||
complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */
|
||||
complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */
|
||||
/* transients */
|
||||
real_t alpha_decay;
|
||||
real_t alpha_smooth;
|
||||
real_t P_PeakDecayNrg[34];
|
||||
real_t P_prev[34];
|
||||
real_t P_SmoothPeakDecayDiffNrg_prev[34];
|
||||
/* mixing and phase */
|
||||
complex_t h11_prev[50];
|
||||
complex_t h12_prev[50];
|
||||
complex_t h21_prev[50];
|
||||
complex_t h22_prev[50];
|
||||
uint8_t phase_hist;
|
||||
complex_t ipd_prev[20][2];
|
||||
complex_t opd_prev[20][2];
|
||||
} ps_info;
|
||||
typedef struct {
|
||||
real_t* x;
|
||||
int16_t x_index;
|
||||
uint8_t channels;
|
||||
} qmfa_info;
|
||||
typedef struct {
|
||||
real_t* v;
|
||||
int16_t v_index;
|
||||
uint8_t channels;
|
||||
} qmfs_info;
|
||||
typedef struct {
|
||||
uint32_t sample_rate;
|
||||
uint32_t maxAACLine;
|
||||
uint8_t rate;
|
||||
uint8_t just_seeked;
|
||||
uint8_t ret;
|
||||
uint8_t amp_res[2];
|
||||
uint8_t k0;
|
||||
uint8_t kx;
|
||||
uint8_t M;
|
||||
uint8_t N_master;
|
||||
uint8_t N_high;
|
||||
uint8_t N_low;
|
||||
uint8_t N_Q;
|
||||
uint8_t N_L[4];
|
||||
uint8_t n[2];
|
||||
uint8_t f_master[64];
|
||||
uint8_t f_table_res[2][64];
|
||||
uint8_t f_table_noise[64];
|
||||
uint8_t f_table_lim[4][64];
|
||||
uint8_t f_group[5][64];
|
||||
uint8_t N_G[5];
|
||||
uint8_t table_map_k_to_g[64];
|
||||
uint8_t abs_bord_lead[2];
|
||||
uint8_t abs_bord_trail[2];
|
||||
uint8_t n_rel_lead[2];
|
||||
uint8_t n_rel_trail[2];
|
||||
uint8_t L_E[2];
|
||||
uint8_t L_E_prev[2];
|
||||
uint8_t L_Q[2];
|
||||
uint8_t t_E[2][MAX_L_E + 1];
|
||||
uint8_t t_Q[2][3];
|
||||
uint8_t f[2][MAX_L_E + 1];
|
||||
uint8_t f_prev[2];
|
||||
real_t* G_temp_prev[2][5];
|
||||
real_t* Q_temp_prev[2][5];
|
||||
int8_t GQ_ringbuf_index[2];
|
||||
int16_t E[2][64][MAX_L_E];
|
||||
int16_t E_prev[2][64];
|
||||
real_t E_orig[2][64][MAX_L_E];
|
||||
real_t E_curr[2][64][MAX_L_E];
|
||||
int32_t Q[2][64][2];
|
||||
real_t Q_div[2][64][2];
|
||||
real_t Q_div2[2][64][2];
|
||||
int32_t Q_prev[2][64];
|
||||
int8_t l_A[2];
|
||||
int8_t l_A_prev[2];
|
||||
uint8_t bs_invf_mode[2][MAX_L_E];
|
||||
uint8_t bs_invf_mode_prev[2][MAX_L_E];
|
||||
real_t bwArray[2][64];
|
||||
real_t bwArray_prev[2][64];
|
||||
uint8_t noPatches;
|
||||
uint8_t patchNoSubbands[64];
|
||||
uint8_t patchStartSubband[64];
|
||||
uint8_t bs_add_harmonic[2][64];
|
||||
uint8_t bs_add_harmonic_prev[2][64];
|
||||
uint16_t index_noise_prev[2];
|
||||
uint8_t psi_is_prev[2];
|
||||
uint8_t bs_start_freq_prev;
|
||||
uint8_t bs_stop_freq_prev;
|
||||
uint8_t bs_xover_band_prev;
|
||||
uint8_t bs_freq_scale_prev;
|
||||
uint8_t bs_alter_scale_prev;
|
||||
uint8_t bs_noise_bands_prev;
|
||||
int8_t prevEnvIsShort[2];
|
||||
int8_t kx_prev;
|
||||
uint8_t bsco;
|
||||
uint8_t bsco_prev;
|
||||
uint8_t M_prev;
|
||||
uint16_t frame_len;
|
||||
uint8_t Reset;
|
||||
uint32_t frame;
|
||||
uint32_t header_count;
|
||||
uint8_t id_aac;
|
||||
qmfa_info* qmfa[2];
|
||||
qmfs_info* qmfs[2];
|
||||
qmf_t Xsbr[2][MAX_NTSRHFG][64];
|
||||
uint8_t Is_DRM_SBR;
|
||||
drm_ps_info* drm_ps;
|
||||
uint8_t numTimeSlotsRate;
|
||||
uint8_t numTimeSlots;
|
||||
uint8_t tHFGen;
|
||||
uint8_t tHFAdj;
|
||||
ps_info* ps;
|
||||
uint8_t ps_used;
|
||||
uint8_t psResetFlag;
|
||||
/* to get it compiling */
|
||||
/* we'll see during the coding of all the tools, whether
|
||||
these are all used or not.
|
||||
*/
|
||||
uint8_t bs_header_flag;
|
||||
uint8_t bs_crc_flag;
|
||||
uint16_t bs_sbr_crc_bits;
|
||||
uint8_t bs_protocol_version;
|
||||
uint8_t bs_amp_res;
|
||||
uint8_t bs_start_freq;
|
||||
uint8_t bs_stop_freq;
|
||||
uint8_t bs_xover_band;
|
||||
uint8_t bs_freq_scale;
|
||||
uint8_t bs_alter_scale;
|
||||
uint8_t bs_noise_bands;
|
||||
uint8_t bs_limiter_bands;
|
||||
uint8_t bs_limiter_gains;
|
||||
uint8_t bs_interpol_freq;
|
||||
uint8_t bs_smoothing_mode;
|
||||
uint8_t bs_samplerate_mode;
|
||||
uint8_t bs_add_harmonic_flag[2];
|
||||
uint8_t bs_add_harmonic_flag_prev[2];
|
||||
uint8_t bs_extended_data;
|
||||
uint8_t bs_extension_id;
|
||||
uint8_t bs_extension_data;
|
||||
uint8_t bs_coupling;
|
||||
uint8_t bs_frame_class[2];
|
||||
uint8_t bs_rel_bord[2][9];
|
||||
uint8_t bs_rel_bord_0[2][9];
|
||||
uint8_t bs_rel_bord_1[2][9];
|
||||
uint8_t bs_pointer[2];
|
||||
uint8_t bs_abs_bord_0[2];
|
||||
uint8_t bs_abs_bord_1[2];
|
||||
uint8_t bs_num_rel_0[2];
|
||||
uint8_t bs_num_rel_1[2];
|
||||
uint8_t bs_df_env[2][9];
|
||||
uint8_t bs_df_noise[2][3];
|
||||
} sbr_info;
|
||||
typedef struct {
|
||||
uint8_t adts_header_present;
|
||||
uint8_t adif_header_present;
|
||||
uint8_t latm_header_present;
|
||||
uint8_t sf_index;
|
||||
uint8_t object_type;
|
||||
uint8_t channelConfiguration;
|
||||
uint8_t aacSectionDataResilienceFlag;
|
||||
uint8_t aacScalefactorDataResilienceFlag;
|
||||
uint8_t aacSpectralDataResilienceFlag;
|
||||
uint16_t frameLength;
|
||||
uint8_t postSeekResetFlag;
|
||||
uint32_t frame;
|
||||
uint8_t downMatrix;
|
||||
uint8_t upMatrix;
|
||||
uint8_t first_syn_ele;
|
||||
uint8_t has_lfe;
|
||||
uint8_t fr_channels; /* number of channels in current frame */
|
||||
uint8_t fr_ch_ele; /* number of elements in current frame */
|
||||
uint8_t element_output_channels[MAX_SYNTAX_ELEMENTS]; /* element_output_channels: determines the number of channels the element will output */
|
||||
uint8_t element_alloced[MAX_SYNTAX_ELEMENTS]; /* element_alloced:determines whether the data needed for the element is allocated or not*/
|
||||
uint8_t alloced_channels; /* alloced_channels: determines the number of channels where output data is allocated for*/
|
||||
void* sample_buffer; /* output data buffer */
|
||||
uint8_t window_shape_prev[MAX_CHANNELS];
|
||||
uint16_t ltp_lag[MAX_CHANNELS];
|
||||
fb_info* fb;
|
||||
drc_info* drc;
|
||||
real_t* time_out[MAX_CHANNELS];
|
||||
real_t* fb_intermed[MAX_CHANNELS];
|
||||
int8_t sbr_present_flag;
|
||||
int8_t forceUpSampling;
|
||||
int8_t downSampledSBR;
|
||||
uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS]; /* determines whether SBR data is allocated for the gives element */
|
||||
sbr_info* sbr[MAX_SYNTAX_ELEMENTS];
|
||||
uint8_t ps_used[MAX_SYNTAX_ELEMENTS];
|
||||
uint8_t ps_used_global;
|
||||
real_t* ssr_overlap[MAX_CHANNELS];
|
||||
real_t* prev_fmd[MAX_CHANNELS];
|
||||
real_t ipqf_buffer[MAX_CHANNELS][4][96 / 4];
|
||||
pred_state* pred_stat[MAX_CHANNELS];
|
||||
int16_t* lt_pred_stat[MAX_CHANNELS];
|
||||
uint8_t error_state;
|
||||
uint32_t __r1; /* RNG states */
|
||||
uint32_t __r2;
|
||||
uint8_t pce_set; /* Program Config Element */
|
||||
program_config pce;
|
||||
uint8_t element_id[MAX_CHANNELS];
|
||||
uint8_t internal_channel[MAX_CHANNELS];
|
||||
NeAACDecConfiguration config; /* Configuration data */
|
||||
int64_t cycles;
|
||||
int64_t spectral_cycles;
|
||||
int64_t output_cycles;
|
||||
int64_t scalefac_cycles;
|
||||
int64_t requant_cycles;
|
||||
latm_header latm_config;
|
||||
const uint8_t* cmes;
|
||||
uint8_t isPS;
|
||||
} NeAACDecStruct;
|
||||
/* 1st step table */
|
||||
typedef struct {
|
||||
uint8_t offset;
|
||||
uint8_t extra_bits;
|
||||
} hcb;
|
||||
/* 2nd step table with quadruple data */
|
||||
typedef struct {
|
||||
uint8_t bits;
|
||||
int8_t x;
|
||||
int8_t y;
|
||||
} hcb_2_pair;
|
||||
typedef struct {
|
||||
uint8_t bits;
|
||||
int8_t x;
|
||||
int8_t y;
|
||||
int8_t v;
|
||||
int8_t w;
|
||||
} hcb_2_quad;
|
||||
/* binary search table */
|
||||
typedef struct {
|
||||
uint8_t is_leaf;
|
||||
int8_t data[4];
|
||||
} hcb_bin_quad;
|
||||
typedef struct {
|
||||
uint8_t is_leaf;
|
||||
int8_t data[2];
|
||||
} hcb_bin_pair;
|
||||
typedef struct _bitfile {
|
||||
/* bit input */
|
||||
uint32_t bufa;
|
||||
uint32_t bufb;
|
||||
uint32_t bits_left;
|
||||
uint32_t buffer_size; /* size of the buffer in bytes */
|
||||
uint32_t bytes_left;
|
||||
uint8_t error;
|
||||
uint32_t* tail;
|
||||
uint32_t* start;
|
||||
const void* buffer;
|
||||
} bitfile;
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
typedef struct {
|
||||
/* bit input */
|
||||
uint32_t bufa;
|
||||
uint32_t bufb;
|
||||
int8_t len;
|
||||
} bits_t;
|
||||
typedef struct {
|
||||
uint8_t cb;
|
||||
uint8_t decoded;
|
||||
uint16_t sp_offset;
|
||||
bits_t bits;
|
||||
} codeword_t;
|
||||
typedef struct {
|
||||
int8_t index;
|
||||
uint8_t len;
|
||||
uint32_t cw;
|
||||
} rvlc_huff_table;
|
||||
// ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
/* type definitions */
|
||||
typedef struct {
|
||||
uint8_t frame_len;
|
||||
uint8_t resolution20[3];
|
||||
uint8_t resolution34[5];
|
||||
qmf_t* work;
|
||||
qmf_t** buffer;
|
||||
qmf_t** temp;
|
||||
} hyb_info;
|
||||
|
||||
typedef struct {
|
||||
real_t G_lim_boost[MAX_L_E][MAX_M];
|
||||
real_t Q_M_lim_boost[MAX_L_E][MAX_M];
|
||||
real_t S_M_boost[MAX_L_E][MAX_M];
|
||||
} sbr_hfadj_info;
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
typedef struct {
|
||||
complex_t r01;
|
||||
complex_t r02;
|
||||
complex_t r11;
|
||||
complex_t r12;
|
||||
complex_t r22;
|
||||
real_t det;
|
||||
} acorr_coef;
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
typedef const int8_t (*ps_huff_tab)[2];
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,425 +0,0 @@
|
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
**
|
||||
** Any non-GPL usage of this software or parts of this software is strictly forbidden.
|
||||
**
|
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
|
||||
**
|
||||
** Commercial non-GPL licensing of this software is possible.
|
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
|
||||
**/
|
||||
|
||||
// ESP32 Version 29.07.2024
|
||||
// updated: 18.06.2026
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "aac_structs.h"
|
||||
#include "aac_tables.h"
|
||||
#include "aac_defines.h"
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
class NeaacDecoder {
|
||||
public:
|
||||
NeaacDecoder() { m_initFlag = 0; }
|
||||
~NeaacDecoder() = default;
|
||||
NeAACDecHandle NeAACDecOpen(void);
|
||||
NeAACDecConfigurationPtr NeAACDecGetCurrentConfiguration(NeAACDecHandle hpDecoder);
|
||||
void NeAACDecClose(NeAACDecHandle hpDecoder);
|
||||
uint8_t NeAACDecSetConfiguration(NeAACDecHandle hpDecoder, NeAACDecConfigurationPtr config);
|
||||
char NeAACDecInit2(NeAACDecHandle hpDecoder, uint8_t* pBuffer, uint32_t SizeOfDecoderSpecificInfo, uint32_t* samplerate, uint8_t* channels);
|
||||
long NeAACDecInit(NeAACDecHandle hpDecoder, uint8_t* buffer, uint32_t buffer_size, uint32_t* samplerate, uint8_t* channels);
|
||||
void* NeAACDecDecode2(NeAACDecHandle hpDecoder, NeAACDecFrameInfo* hInfo, uint8_t* buffer, uint32_t buffer_size, void** sample_buffer, uint32_t sample_buffer_size);
|
||||
error_info_t NeAACDecGetErrorMessage(const uint8_t errcode);
|
||||
uint8_t get_sr_index(const uint32_t samplerate);
|
||||
|
||||
private:
|
||||
uint32_t __r1 __attribute__((unused)) = 1;
|
||||
uint32_t __r2 __attribute__((unused)) = 1;
|
||||
|
||||
ps_ptr<mdct_info> m_mdct256;
|
||||
ps_ptr<mdct_info> m_mdct1024;
|
||||
ps_ptr<mdct_info> m_mdct2048;
|
||||
ps_ptr<cfft_info> m_ccft256;
|
||||
ps_ptr<cfft_info> m_ccft1024;
|
||||
ps_ptr<cfft_info> m_ccft2048;
|
||||
ps_ptr<complex_t> m_work256;
|
||||
ps_ptr<complex_t> m_work1024;
|
||||
ps_ptr<complex_t> m_work2048;
|
||||
ps_ptr<real_t> m_G_temp_prev[48][2][5];
|
||||
ps_ptr<real_t> m_Q_temp_prev[48][2][5];
|
||||
ps_ptr<adif_header> m_adif;
|
||||
ps_ptr<adts_header> m_adts;
|
||||
ps_ptr<bitfile> m_ld;
|
||||
ps_ptr<uint8_t> m_sample_buffer;
|
||||
|
||||
uint32_t ne_rng(uint32_t* __r1, uint32_t* __r2);
|
||||
uint32_t wl_min_lzc(uint32_t x);
|
||||
uint8_t m_initFlag = 0;
|
||||
#ifdef FIXED_POINT
|
||||
int32_t log2_int(uint32_t val);
|
||||
int32_t log2_fix(uint32_t val);
|
||||
int32_t pow2_int(real_t val);
|
||||
real_t pow2_fix(real_t val);
|
||||
#endif
|
||||
template <typename freeType> void faad_free(freeType** b);
|
||||
|
||||
void* faad_calloc(size_t len, size_t size);
|
||||
uint32_t ones32(uint32_t x);
|
||||
uint32_t floor_log2(uint32_t x);
|
||||
int NeAACDecGetVersion(const char** faad_id_string, const char** faad_copyright_string);
|
||||
uint32_t NeAACDecGetCapabilities(void);
|
||||
void NeAACDecPostSeekReset(NeAACDecHandle hpDecoder, long frame);
|
||||
void* NeAACDecDecode(NeAACDecHandle hpDecoder, NeAACDecFrameInfo* hInfo, uint8_t* buffer, uint32_t buffer_size);
|
||||
void cfftf1pos(uint16_t n, complex_t* c, complex_t* ch, const uint16_t* ifac, const complex_t* wa, const int8_t isign);
|
||||
void cfftf1neg(uint16_t n, complex_t* c, complex_t* ch, const uint16_t* ifac, const complex_t* wa, const int8_t isign);
|
||||
#ifdef FIXED_POINT
|
||||
real_t get_sample(real_t** input, uint8_t channel, uint16_t sample, uint8_t down_matrix, uint8_t up_matrix, uint8_t* internal_channel);
|
||||
#endif
|
||||
#ifndef FIXED_POINT
|
||||
real_t get_sample(real_t** input, uint8_t channel, uint16_t sample, uint8_t down_matrix, uint8_t* internal_channel);
|
||||
void to_PCM_16bit(NeAACDecStruct* hDecoder, real_t** input, uint8_t channels, uint16_t frame_len, int16_t** sample_buffer);
|
||||
void to_PCM_24bit(NeAACDecStruct* hDecoder, real_t** input, uint8_t channels, uint16_t frame_len, int32_t** sample_buffer);
|
||||
void to_PCM_32bit(NeAACDecStruct* hDecoder, real_t** input, uint8_t channels, uint16_t frame_len, int32_t** sample_buffer);
|
||||
void to_PCM_float(NeAACDecStruct* hDecoder, real_t** input, uint8_t channels, uint16_t frame_len, float** sample_buffer);
|
||||
void to_PCM_double(NeAACDecStruct* hDecoder, real_t** input, uint8_t channels, uint16_t frame_len, double** sample_buffer);
|
||||
#endif
|
||||
void imdct_ssr(fb_info* fb, real_t* in_data, real_t* out_data, uint16_t len);
|
||||
void gc_setcoef_eff_pqfsyn(int mm, int kk, real_t* p_proto, real_t*** ppp_q0, real_t*** ppp_t0, real_t*** ppp_t1);
|
||||
real_t calc_Q_div(sbr_info* sbr, uint8_t ch, uint8_t m, uint8_t l);
|
||||
real_t calc_Q_div2(sbr_info* sbr, uint8_t ch, uint8_t m, uint8_t l);
|
||||
#ifdef MAIN_DEC
|
||||
void flt_round(float* pf);
|
||||
int16_t quant_pred(float x);
|
||||
float inv_quant_pred(int16_t q);
|
||||
void ic_predict(pred_state* state, real_t input, real_t* output, uint8_t pred);
|
||||
void reset_pred_state(pred_state* state);
|
||||
#endif
|
||||
void imdct_long(fb_info* fb, real_t* in_data, real_t* out_data, uint16_t len);
|
||||
void mdct_init(fb_info* fb, real_t* in_data, real_t* out_data, uint16_t len);
|
||||
uint32_t rewrev_word(uint32_t v, const uint8_t len);
|
||||
void rewrev_lword(uint32_t* hi, uint32_t* lo, const uint8_t len);
|
||||
void rewrev_bits(bits_t* bits);
|
||||
void concat_bits(bits_t* b, bits_t* a);
|
||||
uint8_t is_good_cb(uint8_t this_CB, uint8_t this_sec_CB);
|
||||
void read_segment(bits_t* segment, uint8_t segwidth, bitfile* ld);
|
||||
void fill_in_codeword(codeword_t* codeword, uint16_t index, uint16_t sp, uint8_t cb);
|
||||
void fft_dif(real_t* Real, real_t* Imag);
|
||||
real_t iquant(int16_t q, const real_t* tab, uint8_t* error);
|
||||
uint8_t allocate_single_channel(NeAACDecStruct* hDecoder, uint8_t channel, uint8_t output_channels);
|
||||
uint8_t allocate_channel_pair(NeAACDecStruct* hDecoder, uint8_t channel, uint8_t paired_channel);
|
||||
uint8_t decode_scale_factors(ic_stream* ics, bitfile* ld);
|
||||
uint32_t latm_get_value(bitfile* ld);
|
||||
uint32_t latmParsePayload(latm_header* latm, bitfile* ld);
|
||||
uint32_t latmAudioMuxElement(latm_header* latm, bitfile* ld);
|
||||
char NeAACDecAudioSpecificConfig(uint8_t* pBuffer, uint32_t buffer_size, mp4AudioSpecificConfig* mp4ASC);
|
||||
void hybrid_free(hyb_info* hyb);
|
||||
void channel_filter4(hyb_info* hyb, uint8_t frame_len, const real_t* filter, qmf_t* buffer, qmf_t** X_hybrid);
|
||||
void DCT3_6_unscaled(real_t* y, real_t* x);
|
||||
void channel_filter12(hyb_info* hyb, uint8_t frame_len, const real_t* filter, qmf_t* buffer, qmf_t** X_hybrid);
|
||||
real_t magnitude_c(complex_t c);
|
||||
uint8_t sbr_process_channel(sbr_info* sbr, real_t* channel_buf, qmf_t X[MAX_NTSR][64], uint8_t ch, uint8_t dont_process, const uint8_t downSampledSBR);
|
||||
real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1);
|
||||
void sbr_reset(sbr_info* sbr);
|
||||
int8_t sbr_log2(const int8_t val);
|
||||
real_t find_log2_E(sbr_info* sbr, uint8_t k, uint8_t l, uint8_t ch);
|
||||
real_t find_log2_Q(sbr_info* sbr, uint8_t k, uint8_t l, uint8_t ch);
|
||||
real_t find_log2_Qplus1(sbr_info* sbr, uint8_t k, uint8_t l, uint8_t ch);
|
||||
void auto_correlation(sbr_info* sbr, acorr_coef* ac, qmf_t buffer[MAX_NTSRHFG][64], uint8_t bd, uint8_t len);
|
||||
real_t mapNewBw(uint8_t invf_mode, uint8_t invf_mode_prev);
|
||||
uint8_t max_pred_sfb(const uint8_t sr_index);
|
||||
uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, const uint8_t is_short);
|
||||
uint32_t get_sample_rate(const uint8_t sr_index);
|
||||
int8_t can_decode_ot(const uint8_t object_type);
|
||||
void* faad_malloc(size_t size);
|
||||
drc_info* drc_init(real_t cut, real_t boost);
|
||||
void drc_end(drc_info* drc);
|
||||
void drc_decode(drc_info* drc, real_t* spec);
|
||||
sbr_info* sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint32_t sample_rate, uint8_t downSampledSBR, uint8_t IsDRM);
|
||||
void sbrDecodeEnd(sbr_info* sbr, uint8_t i);
|
||||
void sbrReset(sbr_info* sbr, uint8_t i);
|
||||
uint8_t sbrDecodeCoupleFrame(sbr_info* sbr, real_t* left_chan, real_t* right_chan, const uint8_t just_seeked, const uint8_t downSampledSBR);
|
||||
uint8_t sbrDecodeSingleFrame(sbr_info* sbr, real_t* channel, const uint8_t just_seeked, const uint8_t downSampledSBR);
|
||||
uint16_t ps_data(ps_info* ps, bitfile* ld, uint8_t* header);
|
||||
ps_info* ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate);
|
||||
void ps_free(ps_info* ps);
|
||||
uint8_t ps_decode(ps_info* ps, qmf_t X_left[38][64], qmf_t X_right[38][64]);
|
||||
void faad_initbits(bitfile* ld, const void* buffer, const uint32_t buffer_size);
|
||||
void faad_endbits(bitfile* ld);
|
||||
void faad_initbits_rev(bitfile* ld, void* buffer, uint32_t bits_in_buffer);
|
||||
uint8_t faad_byte_align(bitfile* ld);
|
||||
uint32_t faad_get_processed_bits(bitfile* ld);
|
||||
void faad_flushbits_ex(bitfile* ld, uint32_t bits);
|
||||
void faad_rewindbits(bitfile* ld);
|
||||
void faad_resetbits(bitfile* ld, int bits);
|
||||
uint8_t* faad_getbitbuffer(bitfile* ld, uint32_t bits);
|
||||
void* faad_origbitbuffer(bitfile* ld);
|
||||
uint32_t faad_origbitbuffer_size(bitfile* ld);
|
||||
uint8_t faad_get1bit(bitfile* ld);
|
||||
uint32_t faad_getbits(bitfile* ld, uint32_t n);
|
||||
uint32_t faad_showbits_rev(bitfile* ld, uint32_t bits);
|
||||
void faad_flushbits_rev(bitfile* ld, uint32_t bits);
|
||||
uint32_t getdword(void* mem);
|
||||
uint32_t getdword_n(void* mem, int n);
|
||||
void faad_flushbits(bitfile* ld, uint32_t bits);
|
||||
uint32_t faad_showbits(bitfile* ld, uint32_t bits);
|
||||
uint32_t showbits_hcr(bits_t* ld, uint8_t bits);
|
||||
uint32_t faad_getbits_rev(bitfile* ld, uint32_t n);
|
||||
int8_t get1bit_hcr(bits_t* ld, uint8_t* result);
|
||||
int8_t flushbits_hcr(bits_t* ld, uint8_t bits);
|
||||
int8_t getbits_hcr(bits_t* ld, uint8_t n, uint32_t* result);
|
||||
void cfftf(uint16_t mdct_len, complex_t* c);
|
||||
void cfftb(uint16_t mdct_len, complex_t* c);
|
||||
void cffti(uint16_t mdct_len, uint16_t n);
|
||||
void* aac_frame_decode(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, uint8_t* buffer, uint32_t buffer_size, void** sample_buffer2, uint32_t sample_buffer_size);
|
||||
void create_channel_config(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo);
|
||||
void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa);
|
||||
void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa);
|
||||
void passf3(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const int8_t isign);
|
||||
void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const complex_t* wa3);
|
||||
void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const complex_t* wa3);
|
||||
void passf5(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const complex_t* wa3, const complex_t* wa4, const int8_t isign);
|
||||
void cffti1(uint16_t n, complex_t* wa, uint16_t* ifac);
|
||||
fb_info* filter_bank_init(uint16_t frame_len);
|
||||
void filter_bank_end(fb_info* fb);
|
||||
void filter_bank_ltp(fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* in_data, real_t* out_mdct, uint8_t object_type, uint16_t frame_len);
|
||||
void ifilter_bank(fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* freq_in, real_t* time_out, real_t* overlap, uint8_t object_type,
|
||||
uint16_t frame_len);
|
||||
void ms_decode(ic_stream* ics, ic_stream* icsr, real_t* l_spec, real_t* r_spec, uint16_t frame_len);
|
||||
void is_decode(ic_stream* ics, ic_stream* icsr, real_t* l_spec, real_t* r_spec, uint16_t frame_len);
|
||||
int8_t is_intensity(ic_stream* ics, uint8_t group, uint8_t sfb);
|
||||
uint8_t is_noise(ic_stream* ics, uint8_t group, uint8_t sfb);
|
||||
real_t fp_sqrt(real_t value);
|
||||
void pns_decode(ic_stream* ics_left, ic_stream* ics_right, real_t* spec_left, real_t* spec_right, uint16_t frame_len, uint8_t channel_pair, uint8_t object_type,
|
||||
/* RNG states */ uint32_t* __r1, uint32_t* __r2);
|
||||
int8_t invert_intensity(ic_stream* ics, uint8_t group, uint8_t sfb);
|
||||
void* output_to_PCM(NeAACDecStruct* hDecoder, real_t** input, void* samplebuffer, uint8_t channels, uint16_t frame_len, uint8_t format);
|
||||
uint8_t pulse_decode(ic_stream* ics, int16_t* spec_coef, uint16_t framelen);
|
||||
void gen_rand_vector(real_t* spec, int16_t scale_factor, uint16_t size, uint8_t sub, uint32_t* __r1, uint32_t* __r2);
|
||||
void huffman_sign_bits(bitfile* ld, int16_t* sp, uint8_t len);
|
||||
uint8_t huffman_getescape(bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_2step_quad(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_2step_pair(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_binary_quad(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_binary_pair(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
int16_t huffman_codebook(uint8_t i);
|
||||
void vcb11_check_LAV(uint8_t cb, int16_t* sp);
|
||||
uint16_t drm_ps_data(drm_ps_info* ps, bitfile* ld);
|
||||
drm_ps_info* drm_ps_init(void);
|
||||
void drm_ps_free(drm_ps_info* ps);
|
||||
uint8_t drm_ps_decode(drm_ps_info* ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]);
|
||||
int8_t huffman_scale_factor(bitfile* ld);
|
||||
uint8_t huffman_spectral_data(uint8_t cb, bitfile* ld, int16_t* sp);
|
||||
int8_t huffman_spectral_data_2(uint8_t cb, bits_t* ld, int16_t* sp);
|
||||
int8_t AudioSpecificConfig2(uint8_t* pBuffer, uint32_t buffer_size, mp4AudioSpecificConfig* mp4ASC, program_config* pce, uint8_t short_form);
|
||||
int8_t AudioSpecificConfigFromBitfile(bitfile* ld, mp4AudioSpecificConfig* mp4ASC, program_config* pce, uint32_t bsize, uint8_t short_form);
|
||||
void pns_reset_pred_state(ic_stream* ics, pred_state* state);
|
||||
void reset_all_predictors(pred_state* state, uint16_t frame_len);
|
||||
void ic_prediction(ic_stream* ics, real_t* spec, pred_state* state, uint16_t frame_len, uint8_t sf_index);
|
||||
uint8_t quant_to_spec(NeAACDecStruct* hDecoder, ic_stream* ics, int16_t* quant_data, real_t* spec_data, uint16_t frame_len);
|
||||
uint8_t window_grouping_info(NeAACDecStruct* hDecoder, ic_stream* ics);
|
||||
uint8_t reconstruct_channel_pair(NeAACDecStruct* hDecoder, ic_stream* ics1, ic_stream* ics2, element* cpe, int16_t* spec_data1, int16_t* spec_data2);
|
||||
uint8_t reconstruct_single_channel(NeAACDecStruct* hDecoder, ic_stream* ics, element* sce, int16_t* spec_data);
|
||||
void tns_decode_frame(ic_stream* ics, tns_info* tns, uint8_t sr_index, uint8_t object_type, real_t* spec, uint16_t frame_len);
|
||||
void tns_encode_frame(ic_stream* ics, tns_info* tns, uint8_t sr_index, uint8_t object_type, real_t* spec, uint16_t frame_len);
|
||||
uint8_t is_ltp_ot(uint8_t object_type);
|
||||
void lt_prediction(ic_stream* ics, ltp_info* ltp, real_t* spec, int16_t* lt_pred_stat, fb_info* fb, uint8_t win_shape, uint8_t win_shape_prev, uint8_t sr_index, uint8_t object_type,
|
||||
uint16_t frame_len);
|
||||
void lt_update_state(int16_t* lt_pred_stat, real_t* time, real_t* overlap, uint16_t frame_len, uint8_t object_type);
|
||||
void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress, uint8_t* coef, real_t* a);
|
||||
void tns_ar_filter(real_t* spectrum, uint16_t size, int8_t inc, real_t* lpc, uint8_t order);
|
||||
void tns_ma_filter(real_t* spectrum, uint16_t size, int8_t inc, real_t* lpc, uint8_t order);
|
||||
uint8_t faad_check_CRC(bitfile* ld, uint16_t len);
|
||||
/* static function declarations */
|
||||
void decode_sce_lfe(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, uint8_t id_syn_ele);
|
||||
void decode_cpe(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, uint8_t id_syn_ele);
|
||||
uint8_t single_lfe_channel_element(NeAACDecStruct* hDecoder, bitfile* ld, uint8_t channel, uint8_t* tag);
|
||||
uint8_t channel_pair_element(NeAACDecStruct* hDecoder, bitfile* ld, uint8_t channel, uint8_t* tag);
|
||||
#ifdef COUPLING_DEC
|
||||
uint8_t coupling_channel_element(NeAACDecStruct* hDecoder, bitfile* ld);
|
||||
#endif
|
||||
uint16_t data_stream_element(NeAACDecStruct* hDecoder, bitfile* ld);
|
||||
uint8_t program_config_element(program_config* pce, bitfile* ld);
|
||||
uint8_t fill_element(NeAACDecStruct* hDecoder, bitfile* ld, drc_info* drc, uint8_t sbr_ele);
|
||||
uint8_t individual_channel_stream(NeAACDecStruct* hDecoder, element* ele, bitfile* ld, ic_stream* ics, uint8_t scal_flag, int16_t* spec_data);
|
||||
uint8_t ics_info(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld, uint8_t common_window);
|
||||
uint8_t section_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld);
|
||||
uint8_t scale_factor_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld);
|
||||
#ifdef SSR_DEC
|
||||
void gain_control_data(bitfile* ld, ic_stream* ics);
|
||||
#endif
|
||||
uint8_t spectral_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld, int16_t* spectral_data);
|
||||
uint16_t extension_payload(bitfile* ld, drc_info* drc, uint16_t count);
|
||||
uint8_t pulse_data(ic_stream* ics, pulse_info* pul, bitfile* ld);
|
||||
void tns_data(ic_stream* ics, tns_info* tns, bitfile* ld);
|
||||
#ifdef LTP_DEC
|
||||
uint8_t ltp_data(NeAACDecStruct* hDecoder, ic_stream* ics, ltp_info* ltp, bitfile* ld);
|
||||
#endif
|
||||
uint8_t adts_fixed_header(adts_header* adts, bitfile* ld);
|
||||
void adts_variable_header(adts_header* adts, bitfile* ld);
|
||||
void adts_error_check(adts_header* adts, bitfile* ld);
|
||||
uint8_t dynamic_range_info(bitfile* ld, drc_info* drc);
|
||||
uint8_t excluded_channels(bitfile* ld, drc_info* drc);
|
||||
uint8_t side_info(NeAACDecStruct* hDecoder, element* ele, bitfile* ld, ic_stream* ics, uint8_t scal_flag);
|
||||
int8_t GASpecificConfig(bitfile* ld, mp4AudioSpecificConfig* mp4ASC, program_config* pce);
|
||||
uint8_t adts_frame(adts_header* adts, bitfile* ld);
|
||||
void get_adif_header(adif_header* adif, bitfile* ld);
|
||||
void raw_data_block(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, program_config* pce, drc_info* drc);
|
||||
uint8_t reordered_spectral_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld, int16_t* spectral_data);
|
||||
#ifdef DRM
|
||||
int8_t DRM_aac_scalable_main_header(NeAACDecStruct* hDecoder, ic_stream* ics1, ic_stream* ics2, bitfile* ld, uint8_t this_layer_stereo);
|
||||
#endif
|
||||
void dct4_kernel(real_t* in_real, real_t* in_imag, real_t* out_real, real_t* out_imag);
|
||||
void DCT3_32_unscaled(real_t* y, real_t* x);
|
||||
void DCT4_32(real_t* y, real_t* x);
|
||||
void DST4_32(real_t* y, real_t* x);
|
||||
void DCT2_32_unscaled(real_t* y, real_t* x);
|
||||
void DCT4_16(real_t* y, real_t* x);
|
||||
void DCT2_16_unscaled(real_t* y, real_t* x);
|
||||
uint8_t rvlc_scale_factor_data(ic_stream* ics, bitfile* ld);
|
||||
uint8_t rvlc_decode_scale_factors(ic_stream* ics, bitfile* ld);
|
||||
uint8_t sbr_extension_data(bitfile* ld, sbr_info* sbr, uint16_t cnt, uint8_t resetFlag);
|
||||
int8_t rvlc_huffman_sf(bitfile* ld_sf, bitfile* ld_esc, int8_t direction);
|
||||
int8_t rvlc_huffman_esc(bitfile* ld_esc, int8_t direction);
|
||||
uint8_t rvlc_decode_sf_forward(ic_stream* ics, bitfile* ld_sf, bitfile* ld_esc, uint8_t* intensity_used);
|
||||
#ifdef DRM
|
||||
void DRM_aac_scalable_main_element(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, program_config* pce, drc_info* drc);
|
||||
#endif
|
||||
uint32_t faad_latm_frame(latm_header* latm, bitfile* ld);
|
||||
#ifdef SSR_DEC
|
||||
void ssr_decode(ssr_info* ssr, fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* freq_in, real_t* time_out, real_t* overlap,
|
||||
real_t ipqf_buffer[SSR_BANDS][96 / 4], real_t* prev_fmd, uint16_t frame_len);
|
||||
void ssr_gain_control(ssr_info* ssr, real_t* data, real_t* output, real_t* overlap, real_t* prev_fmd, uint8_t band, uint8_t window_sequence, uint16_t frame_len);
|
||||
void ssr_gc_function(ssr_info* ssr, real_t* prev_fmd, real_t* gc_function, uint8_t window_sequence, uint16_t frame_len);
|
||||
#endif
|
||||
void extract_envelope_data(sbr_info* sbr, uint8_t ch);
|
||||
void extract_noise_floor_data(sbr_info* sbr, uint8_t ch);
|
||||
#ifndef FIXED_POINT
|
||||
void envelope_noise_dequantisation(sbr_info* sbr, uint8_t ch);
|
||||
void unmap_envelope_noise(sbr_info* sbr);
|
||||
#endif
|
||||
void ssr_ipqf(ssr_info* ssr, real_t* in_data, real_t* out_data, real_t buffer[SSR_BANDS][96 / 4], uint16_t frame_len, uint8_t bands);
|
||||
void faad_mdct_init(uint16_t mdct_len, uint16_t N);
|
||||
void faad_mdct_end(uint16_t mdct_len);
|
||||
void faad_imdct(uint16_t mdct_idx, real_t* X_in, real_t* X_out);
|
||||
void faad_mdct(uint16_t mdct_len, real_t* X_in, real_t* X_out);
|
||||
#if (defined(PS_DEC) || defined(DRM_PS))
|
||||
uint8_t sbrDecodeSingleFramePS(sbr_info* sbr, real_t* left_channel, real_t* right_channel, const uint8_t just_seeked, const uint8_t downSampledSBR);
|
||||
#endif
|
||||
// void unmap_envelope_noise(sbr_info* sbr);
|
||||
int16_t real_to_int16(real_t sig_in);
|
||||
uint8_t sbr_save_prev_data(sbr_info* sbr, uint8_t ch);
|
||||
void sbr_save_matrix(sbr_info* sbr, uint8_t ch);
|
||||
fb_info* ssr_filter_bank_init(uint16_t frame_len);
|
||||
void ssr_filter_bank_end(fb_info* fb);
|
||||
void ssr_ifilter_bank(fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* freq_in, real_t* time_out, uint16_t frame_len);
|
||||
int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1);
|
||||
void sbr_header(bitfile* ld, sbr_info* sbr);
|
||||
uint8_t calc_sbr_tables(sbr_info* sbr, uint8_t start_freq, uint8_t stop_freq, uint8_t samplerate_mode, uint8_t freq_scale, uint8_t alter_scale, uint8_t xover_band);
|
||||
uint8_t sbr_data(bitfile* ld, sbr_info* sbr);
|
||||
uint16_t sbr_extension(bitfile* ld, sbr_info* sbr, uint8_t bs_extension_id, uint16_t num_bits_left);
|
||||
uint8_t sbr_single_channel_element(bitfile* ld, sbr_info* sbr);
|
||||
uint8_t sbr_channel_pair_element(bitfile* ld, sbr_info* sbr);
|
||||
uint8_t sbr_grid(bitfile* ld, sbr_info* sbr, uint8_t ch);
|
||||
void sbr_dtdf(bitfile* ld, sbr_info* sbr, uint8_t ch);
|
||||
void invf_mode(bitfile* ld, sbr_info* sbr, uint8_t ch);
|
||||
void sinusoidal_coding(bitfile* ld, sbr_info* sbr, uint8_t ch);
|
||||
uint8_t hf_adjustment(sbr_info* sbr, qmf_t Xsbr[MAX_NTSRHFG][64], real_t* deg, uint8_t ch);
|
||||
uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, uint32_t sample_rate);
|
||||
uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, uint8_t k0);
|
||||
uint8_t master_frequency_table_fs0(sbr_info* sbr, uint8_t k0, uint8_t k2, uint8_t bs_alter_scale);
|
||||
uint8_t master_frequency_table(sbr_info* sbr, uint8_t k0, uint8_t k2, uint8_t bs_freq_scale, uint8_t bs_alter_scale);
|
||||
uint8_t derived_frequency_table(sbr_info* sbr, uint8_t bs_xover_band, uint8_t k2);
|
||||
void limiter_frequency_table(sbr_info* sbr);
|
||||
#ifdef SBR_DEC
|
||||
#ifdef SBR_LOW_POWER
|
||||
void calc_prediction_coef_lp(sbr_info* sbr, qmf_t Xlow[MAX_NTSRHFG][64], complex_t* alpha_0, complex_t* alpha_1, real_t* rxx);
|
||||
void calc_aliasing_degree(sbr_info* sbr, real_t* rxx, real_t* deg);
|
||||
#else // SBR_LOW_POWER
|
||||
void calc_prediction_coef(sbr_info* sbr, qmf_t Xlow[MAX_NTSRHFG][64], complex_t* alpha_0, complex_t* alpha_1, uint8_t k);
|
||||
#endif // SBR_LOW_POWER
|
||||
void calc_chirp_factors(sbr_info* sbr, uint8_t ch);
|
||||
void patch_construction(sbr_info* sbr);
|
||||
#endif // SBR_DEC
|
||||
#ifdef SBR_DEC
|
||||
uint8_t estimate_current_envelope(sbr_info* sbr, sbr_hfadj_info* adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
|
||||
void calculate_gain(sbr_info* sbr, sbr_hfadj_info* adj, uint8_t ch);
|
||||
#ifdef SBR_LOW_POWER
|
||||
void calc_gain_groups(sbr_info* sbr, sbr_hfadj_info* adj, real_t* deg, uint8_t ch);
|
||||
void aliasing_reduction(sbr_info* sbr, sbr_hfadj_info* adj, real_t* deg, uint8_t ch);
|
||||
#endif // SBR_LOW_POWER
|
||||
void hf_assembly(sbr_info* sbr, sbr_hfadj_info* adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
|
||||
#endif // SBR_DEC
|
||||
uint8_t get_S_mapped(sbr_info* sbr, uint8_t ch, uint8_t l, uint8_t current_band);
|
||||
qmfa_info* qmfa_init(uint8_t channels);
|
||||
void qmfa_end(qmfa_info* qmfa);
|
||||
qmfs_info* qmfs_init(uint8_t channels);
|
||||
void qmfs_end(qmfs_info* qmfs);
|
||||
void sbr_qmf_analysis_32(sbr_info* sbr, qmfa_info* qmfa, const real_t* input, qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx);
|
||||
void sbr_qmf_synthesis_32(sbr_info* sbr, qmfs_info* qmfs, qmf_t X[MAX_NTSRHFG][64], real_t* output);
|
||||
void sbr_qmf_synthesis_64(sbr_info* sbr, qmfs_info* qmfs, qmf_t X[MAX_NTSRHFG][64], real_t* output);
|
||||
uint8_t envelope_time_border_vector(sbr_info* sbr, uint8_t ch);
|
||||
void noise_floor_time_border_vector(sbr_info* sbr, uint8_t ch);
|
||||
void hf_generation(sbr_info* sbr, qmf_t Xlow[MAX_NTSRHFG][64], qmf_t Xhigh[MAX_NTSRHFG][64], real_t* deg, uint8_t ch);
|
||||
void sbr_envelope(bitfile* ld, sbr_info* sbr, uint8_t ch);
|
||||
void sbr_noise(bitfile* ld, sbr_info* sbr, uint8_t ch);
|
||||
uint8_t middleBorder(sbr_info* sbr, uint8_t ch);
|
||||
#ifdef SSR_DEC
|
||||
// void ssr_ipqf(ssr_info* ssr, real_t* in_data, real_t* out_data, real_t buffer[SSR_BANDS][96 / 4], uint16_t frame_len, uint8_t bands);
|
||||
void gc_set_protopqf(real_t* p_proto);
|
||||
#endif
|
||||
#ifdef PS_DEC
|
||||
hyb_info* hybrid_init(uint8_t numTimeSlotsRate);
|
||||
void channel_filter2(hyb_info* hyb, uint8_t frame_len, const real_t* filter, qmf_t* buffer, qmf_t** X_hybrid);
|
||||
void inline DCT3_4_unscaled(real_t* y, real_t* x);
|
||||
void channel_filter8(hyb_info* hyb, uint8_t frame_len, const real_t* filter, qmf_t* buffer, qmf_t** X_hybrid);
|
||||
void hybrid_analysis(hyb_info* hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], uint8_t use34, uint8_t numTimeSlotsRate);
|
||||
void hybrid_synthesis(hyb_info* hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], uint8_t use34, uint8_t numTimeSlotsRate);
|
||||
int8_t delta_clip(int8_t i, int8_t min, int8_t max);
|
||||
void delta_decode(uint8_t enable, int8_t* index, int8_t* index_prev, uint8_t dt_flag, uint8_t nr_par, uint8_t stride, int8_t min_index, int8_t max_index);
|
||||
void delta_modulo_decode(uint8_t enable, int8_t* index, int8_t* index_prev, uint8_t dt_flag, uint8_t nr_par, uint8_t stride, int8_t and_modulo);
|
||||
void map20indexto34(int8_t* index, uint8_t bins);
|
||||
#ifdef PS_LOW_POWER
|
||||
void map34indexto20(int8_t* index, uint8_t bins);
|
||||
#endif
|
||||
void ps_data_decode(ps_info* ps);
|
||||
void ps_decorrelate(ps_info* ps, qmf_t X_left[38][64], qmf_t X_right[38][64], qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]);
|
||||
void ps_mix_phase(ps_info* ps, qmf_t X_left[38][64], qmf_t X_right[38][64], qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]);
|
||||
#endif // PS_DEC
|
||||
#ifdef PS_DEC
|
||||
uint16_t ps_extension(ps_info* ps, bitfile* ld, const uint8_t ps_extension_id, const uint16_t num_bits_left);
|
||||
void huff_data(bitfile* ld, const uint8_t dt, const uint8_t nr_par, ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t* par);
|
||||
int8_t ps_huff_dec(bitfile* ld, ps_huff_tab t_huff);
|
||||
#endif // PS_DEC
|
||||
typedef const int8_t (*sbr_huff_tab)[2];
|
||||
int16_t sbr_huff_dec(bitfile* ld, sbr_huff_tab t_huff);
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
// Macro for comfortable calls
|
||||
// #define AAC_LOG_ERROR(fmt, ...) Audio::AUDIO_LOG_IMPL(1, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
// #define AAC_LOG_WARN(fmt, ...) Audio::AUDIO_LOG_IMPL(2, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
// #define AAC_LOG_INFO(fmt, ...) Audio::AUDIO_LOG_IMPL(3, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
// #define AAC_LOG_DEBUG(fmt, ...) Audio::AUDIO_LOG_IMPL(4, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
// #define AAC_LOG_VERBOSE(fmt, ...) Audio::AUDIO_LOG_IMPL(5, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,258 +0,0 @@
|
||||
/*
|
||||
* flac_decoder.h
|
||||
*
|
||||
* Created on: Jul 03,2020
|
||||
* Updated on: Apr 25,2025
|
||||
*
|
||||
* Author: wolle
|
||||
*
|
||||
* Restrictions:
|
||||
* blocksize must not exceed 24576 bytes
|
||||
* bits per sample must be 8, 16, 24 or 32
|
||||
* num Channels must be 1 or 2
|
||||
*
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#pragma GCC optimize("Ofast")
|
||||
|
||||
#include "../Audio.h"
|
||||
|
||||
#define ANSI_ESC_RESET "\033[0m"
|
||||
#define ANSI_ESC_BLACK "\033[30m"
|
||||
#define ANSI_ESC_RED "\033[31m"
|
||||
#define ANSI_ESC_GREEN "\033[32m"
|
||||
#define ANSI_ESC_YELLOW "\033[33m"
|
||||
#define ANSI_ESC_BLUE "\033[34m"
|
||||
#define ANSI_ESC_MAGENTA "\033[35m"
|
||||
#define ANSI_ESC_CYAN "\033[36m"
|
||||
#define ANSI_ESC_WHITE "\033[37m"
|
||||
|
||||
class FlacDecoder : public Decoder {
|
||||
|
||||
public:
|
||||
FlacDecoder(Audio& audioRef) : Decoder(audioRef), audio(audioRef) {}
|
||||
~FlacDecoder() { reset(); }
|
||||
bool init() override;
|
||||
void clear() override;
|
||||
void reset() override;
|
||||
bool isValid() override;
|
||||
int32_t findSyncWord(uint8_t* buf, int32_t nBytes) override;
|
||||
uint8_t getChannels() override;
|
||||
uint32_t getSampleRate() override;
|
||||
uint32_t getOutputSamples();
|
||||
uint8_t getBitsPerSample() override;
|
||||
uint32_t getBitRate() override;
|
||||
uint32_t getAudioDataStart() override;
|
||||
uint32_t getAudioFileDuration() override;
|
||||
const char* getStreamTitle() override;
|
||||
const char* whoIsIt() override;
|
||||
int32_t decode(uint8_t* inbuf, int32_t* bytesLeft, int32_t* outbuf) override;
|
||||
void setRawBlockParams(uint8_t channels, uint32_t sampleRate, uint8_t BPS, uint32_t tsis, uint32_t AuDaLength) override;
|
||||
std::vector<uint32_t> getMetadataBlockPicture() override;
|
||||
const char* arg1() override;
|
||||
const char* arg2() override;
|
||||
virtual int32_t val1() override;
|
||||
virtual int32_t val2() override;
|
||||
|
||||
enum : int8_t {
|
||||
FLAC_PARSE_OGG_DONE = 100,
|
||||
FLAC_DECODE_FRAMES_LOOP = 100,
|
||||
FLAC_OGG_SYNC_FOUND = +2,
|
||||
GIVE_NEXT_LOOP = +1,
|
||||
FLAC_NONE = 0,
|
||||
FLAC_ERR = -1,
|
||||
FLAC_STOP = -100,
|
||||
};
|
||||
|
||||
private:
|
||||
Audio& audio;
|
||||
#define FLAC_MAX_CHANNELS 2
|
||||
#define FLAC_MAX_BLOCKSIZE 24576 // 24 * 1024
|
||||
#define FLAC_MAX_OUTBUFFSIZE 4096 * 2
|
||||
|
||||
enum : uint8_t { FLACDECODER_INIT, FLACDECODER_READ_IN, FLACDECODER_WRITE_OUT };
|
||||
enum : uint8_t { DECODE_FRAME, DECODE_SUBFRAMES, OUT_SAMPLES };
|
||||
|
||||
typedef struct FLACMetadataBlock_t {
|
||||
// METADATA_BLOCK_STREAMINFO
|
||||
uint16_t minblocksize; // The minimum block size (in samples) used in the stream.
|
||||
//----------------------------------------------------------------------------------------
|
||||
// The maximum block size (in samples) used in the stream.
|
||||
uint16_t maxblocksize; // (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
|
||||
//----------------------------------------------------------------------------------------
|
||||
// The minimum frame size (in bytes) used in the stream.
|
||||
uint32_t minframesize; // May be 0 to imply the value is not known.
|
||||
//----------------------------------------------------------------------------------------
|
||||
// The maximum frame size (in bytes) used in the stream.
|
||||
uint32_t maxframesize; // May be 0 to imply the value is not known.
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Sample rate in Hz. Though 20 bits are available,
|
||||
// the maximum sample rate is limited by the structure of frame headers to 655350Hz.
|
||||
uint32_t sampleRate; // Also, a value of 0 is invalid.
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Number of channels FLAC supports from 1 to 8 channels
|
||||
uint8_t numChannels; // 000 : 1 channel .... 111 : 8 channels
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Sample size in bits:
|
||||
// 000 : get from STREAMINFO metadata block
|
||||
// 001 : 8 bits per sample
|
||||
// 010 : 12 bits per sample
|
||||
// 011 : reserved
|
||||
// 100 : 16 bits per sample
|
||||
// 101 : 20 bits per sample
|
||||
// 110 : 24 bits per sample
|
||||
uint8_t bitsPerSample; // 111 : reserved
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Total samples in stream. 'Samples' means inter-channel sample,
|
||||
// i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number
|
||||
uint64_t totalSamples; // of channels. A value of zero here means the number of total samples is unknown.
|
||||
//----------------------------------------------------------------------------------------
|
||||
uint32_t audioDataLength; // is not the filelength, is only the length of the audio datablock in bytes
|
||||
} FLACMetadataBlock_t;
|
||||
|
||||
typedef struct FLACFrameHeader_t {
|
||||
// 0 : fixed-blocksize stream; frame header encodes the frame number
|
||||
uint8_t blockingStrategy; // 1 : variable-blocksize stream; frame header encodes the sample number
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Block size in inter-channel samples:
|
||||
// 0000 : reserved
|
||||
// 0001 : 192 samples
|
||||
// 0010-0101 : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
|
||||
// 0110 : get 8 bit (blocksize-1) from end of header
|
||||
// 0111 : get 16 bit (blocksize-1) from end of header
|
||||
uint8_t blockSizeCode; // 1000-1111 : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
|
||||
//----------------------------------------------------------------------------------------
|
||||
// 0000 : get from STREAMINFO metadata block
|
||||
// 0001 : 88.2kHz
|
||||
// 0010 : 176.4kHz
|
||||
// 0011 : 192kHz
|
||||
// 0100 : 8kHz
|
||||
// 0101 : 16kHz
|
||||
// 0110 : 22.05kHz
|
||||
// 0111 : 24kHz
|
||||
// 1000 : 32kHz
|
||||
// 1001 : 44.1kHz
|
||||
// 1010 : 48kHz
|
||||
// 1011 : 96kHz
|
||||
// 1100 : get 8 bit sample rate (in kHz) from end of header
|
||||
// 1101 : get 16 bit sample rate (in Hz) from end of header
|
||||
// 1110 : get 16 bit sample rate (in tens of Hz) from end of header
|
||||
uint8_t sampleRateCode; // 1111 : invalid, to prevent sync-fooling string of 1s
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Channel assignment
|
||||
// 0000 1 channel: mono
|
||||
// 0001 2 channels: left, right
|
||||
// 0010 3 channels
|
||||
// 0011 4 channels
|
||||
// 0100 5 channels
|
||||
// 0101 6 channels
|
||||
// 0110 7 channels
|
||||
// 0111 8 channels
|
||||
// 1000 : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
|
||||
// 1001 : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
|
||||
// 1010 : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
|
||||
uint8_t chanAsgn; // 1011-1111 : reserved
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Sample size in bits:
|
||||
// 000 : get from STREAMINFO metadata block
|
||||
// 001 : 8 bits per sample
|
||||
// 010 : 12 bits per sample
|
||||
// 011 : reserved
|
||||
// 100 : 16 bits per sample
|
||||
// 101 : 20 bits per sample
|
||||
// 110 : 24 bits per sample
|
||||
uint8_t sampleSizeCode; // 111 : reserved
|
||||
//----------------------------------------------------------------------------------------
|
||||
uint32_t totalSamples; // totalSamplesInStream
|
||||
//----------------------------------------------------------------------------------------
|
||||
uint32_t bitrate; // bitrate
|
||||
} FLACFrameHeader_t;
|
||||
|
||||
const std::deque<std::deque<int>> FIXED_PREDICTION_COEFFICIENTS = {
|
||||
{}, // {}
|
||||
{1}, // {1}
|
||||
{2, -1}, // {2, -1}
|
||||
{3, -3, 1}, // {3, -3, 1}
|
||||
{4, -6, 4, -1} // {4, -6, 4, -1}
|
||||
};
|
||||
|
||||
// std::deque<int> coefs;
|
||||
|
||||
ps_ptr<FLACFrameHeader_t> FLACFrameHeader;
|
||||
ps_ptr<FLACMetadataBlock_t> FLACMetadataBlock;
|
||||
|
||||
std::vector<uint32_t> m_flacSegmTableVec;
|
||||
std::vector<int32_t> coefs;
|
||||
std::vector<uint32_t> m_flacBlockPicItem;
|
||||
|
||||
uint64_t m_flac_bitBuffer = 0;
|
||||
uint32_t m_flacBitrate = 0;
|
||||
uint32_t m_flacBlockPicLenUntilFrameEnd = 0;
|
||||
uint32_t m_flacCurrentFilePos = 0;
|
||||
uint32_t m_flacBlockPicPos = 0;
|
||||
uint32_t m_flacBlockPicLen = 0;
|
||||
uint32_t m_segmLength = 0;
|
||||
uint32_t m_flacAudioDataStart = 0;
|
||||
int32_t m_flacRemainBlockPicLen = 0;
|
||||
uint32_t m_segmLenTmp = 0;
|
||||
uint16_t m_numOfOutSamples = 0;
|
||||
uint16_t m_flacValidSamples = 0;
|
||||
uint16_t m_rIndex = 0;
|
||||
uint16_t m_offset = 0;
|
||||
uint8_t m_flacStatus = 0;
|
||||
uint8_t* m_flacInptr;
|
||||
float m_flacCompressionRatio = 0;
|
||||
uint8_t m_flacBitBufferLen = 0;
|
||||
bool m_f_flacParseOgg = false;
|
||||
bool m_f_bitReaderError = false;
|
||||
uint8_t m_flac_pageSegments = 0;
|
||||
ps_ptr<char> m_flacStreamTitle = {};
|
||||
ps_ptr<char> m_flacVendorString = {};
|
||||
bool m_f_flacNewStreamtitle = false;
|
||||
bool m_f_flacFirstCall = true;
|
||||
bool m_f_oggWrapper = false;
|
||||
bool m_f_lastMetaDataBlock = false;
|
||||
bool m_f_flacNewMetadataBlockPicture = false;
|
||||
bool m_valid = false;
|
||||
bool m_continued_page = false;
|
||||
bool m_f_first_flac_frame = false;
|
||||
uint8_t m_flacPageNr = 0;
|
||||
ps_ptr<int64_t> m_samplesBuffer[2];
|
||||
uint16_t m_maxBlocksize = FLAC_MAX_BLOCKSIZE;
|
||||
int32_t m_nBytes = 0;
|
||||
|
||||
boolean FLACFindMagicWord(unsigned char* buf, int32_t nBytes);
|
||||
int32_t parseOGG(uint8_t* inbuf, int32_t* bytesLeft);
|
||||
int32_t parseFlacFirstPacket(uint8_t* inbuf, int16_t nBytes);
|
||||
int32_t parseMetaDataBlockHeader(uint8_t* inbuf, int16_t nBytes);
|
||||
void setDefaults();
|
||||
void decoderReset();
|
||||
int8_t decodeNative(uint8_t* inbuf, int32_t* bytesLeft, int32_t* outbuf);
|
||||
int8_t decodeFrame(uint8_t* inbuf, int32_t* bytesLeft);
|
||||
uint64_t getTotoalSamplesInStream();
|
||||
uint32_t readUint(uint8_t nBits, int32_t* bytesLeft);
|
||||
void alignToByte();
|
||||
int8_t decodeSubframes(int32_t* bytesLeft);
|
||||
int8_t decodeSubframe(uint8_t sampleDepth, uint8_t ch, int32_t* bytesLeft);
|
||||
int8_t decodeFixedPredictionSubframe(uint8_t predOrder, uint8_t sampleDepth, uint8_t ch, int32_t* bytesLeft);
|
||||
int8_t decodeLinearPredictiveCodingSubframe(int32_t lpcOrder, int32_t sampleDepth, uint8_t ch, int32_t* bytesLeft);
|
||||
int8_t decodeResiduals(uint8_t warmup, uint8_t ch, int32_t* bytesLeft);
|
||||
void restoreLinearPrediction(uint8_t ch, uint8_t shift);
|
||||
int32_t specialIndexOf(uint8_t* base, const char* str, int32_t baselen, bool exact = false);
|
||||
|
||||
inline int32_t readSignedInt(int32_t nBits, int32_t* bytesLeft) {
|
||||
int32_t temp = readUint(nBits, bytesLeft) << (32 - nBits);
|
||||
temp = temp >> (32 - nBits); // The C++ compiler uses the sign bit to fill vacated bit positions
|
||||
return temp;
|
||||
}
|
||||
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
// Macro for comfortable calls
|
||||
#define FLAC_LOG_ERROR(fmt, ...) Audio::AUDIO_LOG_IMPL(1, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define FLAC_LOG_WARN(fmt, ...) Audio::AUDIO_LOG_IMPL(2, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define FLAC_LOG_INFO(fmt, ...) Audio::AUDIO_LOG_IMPL(3, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define FLAC_LOG_DEBUG(fmt, ...) Audio::AUDIO_LOG_IMPL(4, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define FLAC_LOG_VERBOSE(fmt, ...) Audio::AUDIO_LOG_IMPL(5, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,230 +0,0 @@
|
||||
/* Copyright (c) 2007-2008 CSIRO
|
||||
Copyright (c) 2007-2009 Xiph.Org Foundation
|
||||
Copyright (c) 2008 Gregory Maxwell
|
||||
Written by Jean-Marc Valin and Gregory Maxwell */
|
||||
/**
|
||||
@file celt.h
|
||||
@brief Contains all the functions for encoding and decoding audio
|
||||
*/
|
||||
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../psram_unique_ptr.hpp"
|
||||
#include "Arduino.h"
|
||||
#include "celt_defines.h"
|
||||
#include "celt_structs.h"
|
||||
#include "celt_tables.h"
|
||||
#include "range_decoder.h"
|
||||
|
||||
extern const int16_t eband5ms[22];
|
||||
extern const uint8_t band_allocation[231];
|
||||
extern const uint32_t CELT_PVQ_U_DATA[];
|
||||
extern const int16_t mdct_twiddles960[];
|
||||
extern const int16_t window120[];
|
||||
extern const int16_t logN400[];
|
||||
extern const int16_t cache_index50[];
|
||||
extern const uint8_t cache_bits50[];
|
||||
extern const uint8_t cache_caps50[];
|
||||
extern const kiss_twiddle_cpx fft_twiddles48000_960[];
|
||||
extern const int16_t fft_bitrev480[];
|
||||
extern const int16_t fft_bitrev240[];
|
||||
extern const int16_t fft_bitrev12[];
|
||||
extern const int16_t fft_bitrev60[];
|
||||
extern const uint8_t LOG2_FRAC_TABLE[];
|
||||
extern const uint8_t e_prob_mode[];
|
||||
extern const uint8_t small_energy_icdf[];
|
||||
extern const int8_t tf_select_table[4][8];
|
||||
extern const int32_t ordery_table[];
|
||||
extern const int32_t second_check[];
|
||||
extern const uint8_t trim_icd[];
|
||||
extern const uint8_t spread_icd[];
|
||||
extern const uint8_t tapset_icdf[];
|
||||
extern const uint32_t row_idx[];
|
||||
|
||||
class CeltDecoder {
|
||||
public:
|
||||
CeltDecoder(RangeDecoder& rangeDecoder) : rd(rangeDecoder) {}
|
||||
~CeltDecoder() { reset(); }
|
||||
bool init();
|
||||
void clear();
|
||||
void reset();
|
||||
int32_t celt_decoder_init(int32_t channels);
|
||||
int32_t celt_decoder_ctl(int32_t request, ...);
|
||||
int32_t celt_decode_with_ec(int16_t* pcm, int32_t frame_size);
|
||||
int16_t SAT16(int32_t x);
|
||||
|
||||
private:
|
||||
RangeDecoder& rd; // Referenz auf RangeDecoder
|
||||
|
||||
|
||||
const kiss_fft_state fft_state48000_960_0 = {
|
||||
480, /* nfft */
|
||||
17476, /* scale */
|
||||
8, /* scale_shift */
|
||||
-1, /* shift */
|
||||
{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0}, /* factors */
|
||||
fft_bitrev480, /* bitrev */
|
||||
fft_twiddles48000_960, /* bitrev */
|
||||
};
|
||||
|
||||
const kiss_fft_state fft_state48000_960_1 = {
|
||||
240, /* nfft */
|
||||
17476, /* scale */
|
||||
7, /* scale_shift */
|
||||
1, /* shift */
|
||||
{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0}, /* factors */
|
||||
fft_bitrev240, /* bitrev */
|
||||
fft_twiddles48000_960, /* bitrev */
|
||||
};
|
||||
|
||||
const kiss_fft_state fft_state48000_960_2 = {
|
||||
120, /* nfft */
|
||||
17476, /* scale */
|
||||
6, /* scale_shift */
|
||||
2, /* shift */
|
||||
{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0}, /* factors */
|
||||
fft_bitrev120, /* bitrev */
|
||||
fft_twiddles48000_960, /* bitrev */
|
||||
};
|
||||
const kiss_fft_state fft_state48000_960_3 = {
|
||||
60, /* nfft */
|
||||
17476, /* scale */
|
||||
5, /* scale_shift */
|
||||
3, /* shift */
|
||||
{5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* factors */
|
||||
fft_bitrev60, /* bitrev */
|
||||
fft_twiddles48000_960, /* bitrev */
|
||||
};
|
||||
|
||||
const CELTMode_t m_CELTMode = {
|
||||
48000, /* Fs */
|
||||
120, /* overlap */
|
||||
21, /* nbEBands */
|
||||
21, /* effEBands */
|
||||
{27853, 0, 4096, 8192}, /* preemph */
|
||||
3, /* maxLM */
|
||||
8, /* nbShortMdcts */
|
||||
120, /* shortMdctSize */
|
||||
11, /* nbAllocVectors */
|
||||
};
|
||||
|
||||
const mdct_lookup_t m_mdct_lookup = {
|
||||
1920,
|
||||
3,
|
||||
{
|
||||
&fft_state48000_960_0,
|
||||
&fft_state48000_960_1,
|
||||
&fft_state48000_960_2,
|
||||
&fft_state48000_960_3,
|
||||
},
|
||||
mdct_twiddles960, /* mdct */
|
||||
};
|
||||
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
CELTDecoder_t m_celtDec; // unique pointer
|
||||
ps_ptr<int32_t> m_decode_mem;
|
||||
band_ctx_t m_band_ctx;
|
||||
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
int32_t celt_inner_prod_c(const int16_t* x, const int16_t* y, int32_t N);
|
||||
int32_t celt_rcp(int32_t x);
|
||||
uint32_t celt_pvq_u_row(uint32_t row, uint32_t data);
|
||||
void exp_rotation1(int16_t* X, int32_t len, int32_t stride, int16_t c, int16_t s);
|
||||
void exp_rotation(int16_t* X, int32_t len, int32_t dir, int32_t stride, int32_t K, int32_t spread);
|
||||
void normalise_residual(int32_t* iy, int16_t* X, int32_t N, int32_t Ryy, int16_t gain);
|
||||
uint32_t extract_collapse_mask(int32_t* iy, int32_t N, int32_t B);
|
||||
uint32_t alg_unquant(int16_t* X, int32_t N, int32_t K, int32_t spread, int32_t B, int16_t gain);
|
||||
void renormalise_vector(int16_t* X, int32_t N, int16_t gain);
|
||||
int32_t resampling_factor(int32_t rate);
|
||||
void comb_filter_const_c(int32_t* y, int32_t* x, int32_t T, int32_t N, int16_t g10, int16_t g11, int16_t g12);
|
||||
void comb_filter(int32_t* y, int32_t* x, int32_t T0, int32_t T1, int32_t N, int16_t g0, int16_t g1, int32_t tapset0, int32_t tapset1);
|
||||
void init_caps(int32_t* cap, int32_t LM, int32_t C);
|
||||
uint32_t celt_lcg_rand(uint32_t seed);
|
||||
int16_t bitexact_cos(int16_t x);
|
||||
int32_t bitexact_log2tan(int32_t isin, int32_t icos);
|
||||
void denormalise_bands(const int16_t* X, int32_t* freq, const int16_t* bandLogE, int32_t start, int32_t end, int32_t M, int32_t downsample, int32_t silence);
|
||||
void anti_collapse(int16_t* X_, uint8_t* collapse_masks, int32_t LM, int32_t C, int32_t size, int32_t start, int32_t end, const int16_t* logE, const int16_t* prev1logE, const int16_t* prev2logE,
|
||||
const int32_t* pulses, uint32_t seed);
|
||||
void compute_channel_weights(int32_t Ex, int32_t Ey, int16_t w[2]);
|
||||
void stereo_split(int16_t* X, int16_t* Y, int32_t N);
|
||||
void stereo_merge(int16_t* X, int16_t* Y, int16_t mid, int32_t N);
|
||||
void deinterleave_hadamard(int16_t* X, int32_t N0, int32_t stride, int32_t hadamard);
|
||||
void interleave_hadamard(int16_t* X, int32_t N0, int32_t stride, int32_t hadamard);
|
||||
void haar1(int16_t* X, int32_t N0, int32_t stride);
|
||||
int32_t compute_qn(int32_t N, int32_t b, int32_t offset, int32_t pulse_cap, int32_t stereo);
|
||||
void compute_theta(struct split_ctx* sctx, int16_t* X, int16_t* Y, int32_t N, int32_t* b, int32_t B, int32_t __B0, int32_t LM, int32_t stereo, int32_t* fill);
|
||||
uint32_t quant_band_n1(int16_t* X, int16_t* Y, int32_t b, int16_t* lowband_out);
|
||||
uint32_t quant_partition(int16_t* X, int32_t N, int32_t b, int32_t B, int16_t* lowband, int32_t LM, int16_t gain, int32_t fill);
|
||||
uint32_t quant_band(int16_t* X, int32_t N, int32_t b, int32_t B, int16_t* lowband, int32_t LM, int16_t* lowband_out, int16_t gain, int16_t* lowband_scratch, int32_t fill);
|
||||
uint32_t quant_band_stereo(int16_t* X, int16_t* Y, int32_t N, int32_t b, int32_t B, int16_t* lowband, int32_t LM, int16_t* lowband_out, int16_t* lowband_scratch, int32_t fill);
|
||||
void special_hybrid_folding(int16_t* norm, int16_t* norm2, int32_t start, int32_t M, int32_t dual_stereo);
|
||||
void quant_all_bands(int32_t start, int32_t end, int16_t* X_, int16_t* Y_, uint8_t* collapse_masks, const int32_t* bandE, int32_t* pulses, int32_t shortBlocks, int32_t spread, int32_t dual_stereo,
|
||||
int32_t intensity, int32_t* tf_res, int32_t total_bits, int32_t balance, int32_t LM, int32_t codedBands, uint32_t* seed, int32_t complexity, int32_t disable_inv);
|
||||
int32_t celt_decoder_get_size(int32_t channels);
|
||||
void deemphasis_stereo_simple(int32_t* in[], int16_t* pcm, int32_t N, const int16_t coef0, int32_t* mem);
|
||||
void deemphasis(int32_t* in[], int16_t* pcm, int32_t N, int32_t C, int32_t downsample, const int16_t* coef, int32_t* mem, int32_t accum);
|
||||
void celt_synthesis(int16_t* X, int32_t* out_syn[], int16_t* oldBandE, int32_t start, int32_t effEnd, int32_t C, int32_t CC, int32_t isTransient, int32_t LM, int32_t downsample, int32_t silence);
|
||||
void tf_decode(int32_t start, int32_t end, int32_t isTransient, int32_t* tf_res, int32_t LM);
|
||||
int32_t cwrsi(int32_t _n, int32_t _k, uint32_t _i, int32_t* _y);
|
||||
int32_t decode_pulses(int32_t* _y, int32_t _n, int32_t _k);
|
||||
void kf_bfly2(kiss_fft_cpx* Fout, int32_t m, int32_t N);
|
||||
void kf_bfly4(kiss_fft_cpx* Fout, const size_t fstride, const kiss_fft_state* st, int32_t m, int32_t N, int32_t mm);
|
||||
void kf_bfly3(kiss_fft_cpx* Fout, const size_t fstride, const kiss_fft_state* st, int32_t m, int32_t N, int32_t mm);
|
||||
void kf_bfly5(kiss_fft_cpx* Fout, const size_t fstride, const kiss_fft_state* st, int32_t m, int32_t N, int32_t mm);
|
||||
void opus_fft_impl(const kiss_fft_state* st, kiss_fft_cpx* fout);
|
||||
uint32_t isqrt32(uint32_t _val);
|
||||
int16_t celt_rsqrt_norm(int32_t x);
|
||||
int32_t celt_sqrt(int32_t x);
|
||||
int16_t celt_cos_norm(int32_t x);
|
||||
void clt_mdct_backward(int32_t* in, int32_t* out, int32_t overlap, int32_t shift, int32_t stride);
|
||||
int32_t interp_bits2pulses(int32_t start, int32_t end, int32_t skip_start, const int32_t* bits1, const int32_t* bits2, const int32_t* thresh, const int32_t* cap, int32_t total, int32_t* _balance,
|
||||
int32_t skip_rsv, int32_t* intensity, int32_t intensity_rsv, int32_t* dual_stereo, int32_t dual_stereo_rsv, int32_t* bits, int32_t* ebits, int32_t* fine_priority,
|
||||
int32_t C, int32_t LM, int32_t encode, int32_t prev, int32_t signalBandwidth);
|
||||
int32_t clt_compute_allocation(int32_t start, int32_t end, const int32_t* offsets, const int32_t* cap, int32_t alloc_trim, int32_t* intensity, int32_t* dual_stereo, int32_t total,
|
||||
int32_t* balance, int32_t* pulses, int32_t* ebits, int32_t* fine_priority, int32_t C, int32_t LM, int32_t encode, int32_t prev, int32_t signalBandwidth);
|
||||
void unquant_coarse_energy(int32_t start, int32_t end, int16_t* oldEBands, int32_t intra, int32_t C, int32_t LM);
|
||||
void unquant_fine_energy(int32_t start, int32_t end, int16_t* oldEBands, int32_t* fine_quant, int32_t C);
|
||||
void unquant_energy_finalise(int32_t start, int32_t end, int16_t* oldEBands, int32_t* fine_quant, int32_t* fine_priority, int32_t bits_left, int32_t C);
|
||||
uint32_t celt_udiv(uint32_t n, uint32_t d);
|
||||
int32_t celt_sudiv(int32_t n, int32_t d);
|
||||
int16_t sig2word16(int32_t x);
|
||||
int16_t celt_atan01(int16_t x);
|
||||
int16_t celt_atan2p(int16_t y, int16_t x);
|
||||
int32_t celt_maxabs16(const int16_t* x, int32_t len);
|
||||
int32_t celt_maxabs32(const int32_t* x, int32_t len);
|
||||
int16_t celt_ilog2(int32_t x);
|
||||
int16_t celt_zlog2(int32_t x);
|
||||
int32_t celt_exp2_frac(int16_t x);
|
||||
int32_t celt_exp2(int16_t x);
|
||||
void dual_inner_prod_c(const int16_t* x, const int16_t* y01, const int16_t* y02, int32_t N, int32_t* xy1, int32_t* xy2);
|
||||
int32_t get_pulses(int32_t i);
|
||||
int32_t bits2pulses(int32_t band, int32_t LM, int32_t bits);
|
||||
int32_t pulses2bits(int32_t band, int32_t LM, int32_t pulses);
|
||||
int16_t celt_log2(int32_t x);
|
||||
int16_t _celt_cos_pi_2(int16_t x);
|
||||
};
|
||||
@@ -1,153 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define OPUS_OK 0
|
||||
#define OPUS_BAD_ARG -1
|
||||
#define OPUS_BUFFER_TOO_SMALL -2
|
||||
#define OPUS_INTERNAL_ERROR -3
|
||||
#define OPUS_INVALID_PACKET -4
|
||||
#define OPUS_UNIMPLEMENTED -5
|
||||
#define OPUS_INVALID_STATE -6
|
||||
#define OPUS_ALLOC_FAIL -7
|
||||
#define OPUS_GET_LOOKAHEAD_REQUEST 4027
|
||||
#define OPUS_RESET_STATE 4028
|
||||
#define OPUS_GET_PITCH_REQUEST 4033
|
||||
#define OPUS_GET_FINAL_RANGE_REQUEST 4031
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047
|
||||
#define LEAK_BANDS 19
|
||||
#define MAXFACTORS 8
|
||||
#define CELT_CLZ0s ((int32_t)sizeof(uint32_t) * CHAR_BIT)
|
||||
#define CELT_CLZ(_x) (__builtin_clz(_x))
|
||||
#define CELT_ILOG(_x) (CELT_CLZ0s - CELT_CLZ(_x))
|
||||
#define DECODER_RESET_START rng
|
||||
#define TOTAL_MODES 1
|
||||
#define BITRES 3
|
||||
#define SPREAD_NONE (0)
|
||||
#define SPREAD_LIGHT (1)
|
||||
#define SPREAD_NORMAL (2)
|
||||
#define SPREAD_AGGRESSIVE (3)
|
||||
#define opus_likely(x) (__builtin_expect(!!(x), 1))
|
||||
#define opus_unlikely(x) (__builtin_expect(!!(x), 0))
|
||||
#define assert2(cond, message)
|
||||
#define TWID_MAX 32767
|
||||
#define TRIG_UPSCALE 1
|
||||
#define LPC_ORDER 24
|
||||
#define S_MUL(a, b) MULT16_32_Q15(b, a)
|
||||
#define C_MUL(m, a, b) \
|
||||
do { \
|
||||
(m).r = SUB32_ovflw(S_MUL((a).r, (b).r), S_MUL((a).i, (b).i)); \
|
||||
(m).i = ADD32_ovflw(S_MUL((a).r, (b).i), S_MUL((a).i, (b).r)); \
|
||||
} while (0)
|
||||
#define C_MULBYSCALAR(c, s) \
|
||||
do { \
|
||||
(c).r = S_MUL((c).r, s); \
|
||||
(c).i = S_MUL((c).i, s); \
|
||||
} while (0)
|
||||
#define DIVSCALAR(x, k) (x) = S_MUL(x, (TWID_MAX - ((k) >> 1)) / (k) + 1)
|
||||
#define C_ADD(res, a, b) \
|
||||
do { \
|
||||
(res).r = ADD32_ovflw((a).r, (b).r); \
|
||||
(res).i = ADD32_ovflw((a).i, (b).i); \
|
||||
} while (0)
|
||||
#define C_SUB(res, a, b) \
|
||||
do { \
|
||||
(res).r = SUB32_ovflw((a).r, (b).r); \
|
||||
(res).i = SUB32_ovflw((a).i, (b).i); \
|
||||
} while (0)
|
||||
#define C_ADDTO(res, a) \
|
||||
do { \
|
||||
(res).r = ADD32_ovflw((res).r, (a).r); \
|
||||
(res).i = ADD32_ovflw((res).i, (a).i); \
|
||||
} while (0)
|
||||
#define HALF_OF(x) ((x) >> 1)
|
||||
#define COMBFILTER_MINPERIOD 15
|
||||
#define comb_filter_const(y, x, T, N, g10, g11, g12) (comb_filter_const_c(y, x, T, N, g10, g11, g12))
|
||||
#define SIG_SAT (300000000)
|
||||
#define NORM_SCALING 16384
|
||||
#define DB_SHIFT 10
|
||||
#define EPSILON 1
|
||||
#define VERY_SMALL 0
|
||||
#define VERY_LARGE16 ((int16_t)32767)
|
||||
#define Q15_ONE ((int16_t)32767)
|
||||
#define SCALEIN(a) (a)
|
||||
#define SCALEOUT(a) (a)
|
||||
#define MULT16_16SU(a, b) ((int32_t)(int16_t)(a) * (int32_t)(uint16_t)(b)) /** Multiply a 16-bit signed value by a 16-bit uint32_t value. The result is a 32-bit signed value */
|
||||
#define MULT16_32_P16(a, b) ((int32_t)PSHR((int64_t)((int16_t)(a)) * (b), 16)) /** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */
|
||||
#define MULT16_32_Q15(a, b) ((int32_t)SHR((int64_t)((int16_t)(a)) * (b), 15)) /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */
|
||||
#define MULT32_32_Q31(a, b) ((int32_t)SHR((int64_t)(a) * (int64_t)(b), 31)) /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */
|
||||
#define QCONST16(x, bits) ((int16_t)(0.5L + (x) * (((int32_t)1) << (bits)))) /** Compile-time conversion of float constant to 16-bit value */
|
||||
#define QCONST32(x, bits) ((int32_t)(0.5L + (x) * (((int32_t)1) << (bits)))) /** Compile-time conversion of float constant to 32-bit value */
|
||||
#define NEG16(x) (-(x)) /** Negate a 16-bit value */
|
||||
#define NEG32(x) (-(x)) /** Negate a 32-bit value */
|
||||
#define EXTRACT16(x) ((int16_t)(x)) /** Change a 32-bit value into a 16-bit value. The value is assumed to fit in 16-bit, otherwise the result is undefined */
|
||||
#define EXTEND32(x) ((int32_t)(x)) /** Change a 16-bit value into a 32-bit value */
|
||||
#define SHR16(a, shift) ((a) >> (shift)) /** Arithmetic shift-right of a 16-bit value */
|
||||
#define SHL16(a, shift) ((int16_t)((uint16_t)(a) << (shift))) /** Arithmetic shift-left of a 16-bit value */
|
||||
#define SHR32(a, shift) ((a) >> (shift)) /** Arithmetic shift-right of a 32-bit value */
|
||||
#define SHL32(a, shift) ((int32_t)((uint32_t)(a) << (shift))) /** Arithmetic shift-left of a 32-bit value */
|
||||
#define PSHR32(a, shift) (SHR32((a) + ((EXTEND32(1) << ((shift)) >> 1)), shift)) /** 32-bit arithmetic shift right with rounding-to-nearest instead of rounding down */
|
||||
#define VSHR32(a, shift) (((shift) > 0) ? SHR32(a, shift) : SHL32(a, -(shift))) /** 32-bit arithmetic shift right where the argument can be negative */
|
||||
#define SHR(a, shift) ((a) >> (shift)) /** "RAW" macros, should not be used outside of this header file */
|
||||
#define SHL(a, shift) SHL32(a, shift)
|
||||
#define PSHR(a, shift) (SHR((a) + ((EXTEND32(1) << ((shift)) >> 1)), shift))
|
||||
#define SATURATE(x, a) (((x) > (a) ? (a) : (x) < -(a) ? -(a) : (x)))
|
||||
#define SATURATE16(x) (EXTRACT16((x) > 32767 ? 32767 : (x) < -32768 ? -32768 : (x)))
|
||||
#define ROUND16(x, a) (EXTRACT16(PSHR32((x), (a)))) /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */
|
||||
#define SROUND16(x, a) EXTRACT16(SATURATE(PSHR32(x, a), 32767)); /** Shift by a and round-to-neareast 32-bit value. Result is a saturated 16-bit value */
|
||||
#define HALF16(x) (SHR16(x, 1)) /** Divide by two */
|
||||
#define HALF32(x) (SHR32(x, 1))
|
||||
#define ADD16(a, b) ((int16_t)((int16_t)(a) + (int16_t)(b))) /** Add two 16-bit values */
|
||||
#define SUB16(a, b) ((int16_t)(a) - (int16_t)(b)) /** Subtract two 16-bit values */
|
||||
#define ADD32(a, b) ((int32_t)(a) + (int32_t)(b)) /** Add two 32-bit values */
|
||||
#define SUB32(a, b) ((int32_t)(a) - (int32_t)(b)) /** Subtract two 32-bit values */
|
||||
#define ADD32_ovflw(a, b) ((int32_t)((uint32_t)(a) + (uint32_t)(b))) /** Add two 32-bit values, ignore any overflows */
|
||||
#define SUB32_ovflw(a, b) ((int32_t)((uint32_t)(a) - (uint32_t)(b))) /** Subtract two 32-bit values, ignore any overflows */
|
||||
#define NEG32_ovflw(a) ((int32_t)(0 - (uint32_t)(a))) /* Avoid MSVC warning C4146: unary minus operator applied to uint32_t type, Negate 32-bit value, ignore any overflows */
|
||||
#define MULT16_16_16(a, b) ((((int16_t)(a)) * ((int16_t)(b))))
|
||||
#define MULT16_16(a, b) (((int32_t)(int16_t)(a)) * ((int32_t)(int16_t)(b))) /** 16x16 multiplication where the result fits in 32 bits */
|
||||
#define MAC16_16(c, a, b) (ADD32((c), MULT16_16((a), (b)))) /** 16x16 multiply-add where the result fits in 32 bits */
|
||||
#define MULT16_16_Q11_32(a, b) (SHR(MULT16_16((a), (b)), 11))
|
||||
#define MULT16_16_Q11(a, b) (SHR(MULT16_16((a), (b)), 11))
|
||||
#define MULT16_16_Q13(a, b) (SHR(MULT16_16((a), (b)), 13))
|
||||
#define MULT16_16_Q14(a, b) (SHR(MULT16_16((a), (b)), 14))
|
||||
#define MULT16_16_Q15(a, b) (SHR(MULT16_16((a), (b)), 15))
|
||||
#define MULT16_16_P13(a, b) (SHR(ADD32(4096, MULT16_16((a), (b))), 13))
|
||||
#define MULT16_16_P14(a, b) (SHR(ADD32(8192, MULT16_16((a), (b))), 14))
|
||||
#define MULT16_16_P15(a, b) (SHR(ADD32(16384, MULT16_16((a), (b))), 15))
|
||||
#define DIV32_16(a, b) ((int16_t)(((int32_t)(a)) / ((int16_t)(b)))) /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */
|
||||
#define DIV32(a, b) (((int32_t)(a)) / ((int32_t)(b))) /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */
|
||||
#define celt_div(a, b) MULT32_32_Q31((int32_t)(a), celt_rcp(b))
|
||||
#define MAX_PERIOD 1024
|
||||
#define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n) * sizeof(*(dst)) + 0 * ((dst) - (src))))
|
||||
#define OPUS_CLEAR(dst, n) (memset((dst), 0, (n) * sizeof(*(dst))))
|
||||
#define ALLOC_STEPS 6
|
||||
#define celt_inner_prod(x, y, N) (celt_inner_prod_c(x, y, N))
|
||||
#define dual_inner_prod(x, y01, y02, N, xy1, xy2) (dual_inner_prod_c(x, y01, y02, N, xy1, xy2))
|
||||
#define FRAC_MUL16(a, b) ((16384 + ((int32_t)(int16_t)(a) * (int16_t)(b))) >> 15) /* Multiplies two 16-bit fractional values. Bit-exactness of this macro is important */
|
||||
#define VARDECL(type, var)
|
||||
#define ALLOC(var, size, type) type var[size]
|
||||
#define FINE_OFFSET 21
|
||||
#define QTHETA_OFFSET 4
|
||||
#define QTHETA_OFFSET_TWOPHASE 16
|
||||
#define MAX_FINE_BITS 8
|
||||
#define MAX_PSEUDO 40
|
||||
#define LOG_MAX_PSEUDO 6
|
||||
#define ALLOC_NONE 1
|
||||
#define OPUS_FPRINTF (void)
|
||||
#define DECODE_BUFFER_SIZE 2048
|
||||
#define CELT_PVQ_U(_n, _k) (celt_pvq_u_row(min(_n, _k), max(_n, _k)))
|
||||
#define CELT_PVQ_V(_n, _k) (CELT_PVQ_U(_n, _k) + CELT_PVQ_U(_n, (_k) + 1))
|
||||
#define CELT_GET_AND_CLEAR_ERROR_REQUEST 10007
|
||||
#define CELT_SET_CHANNELS_REQUEST 10008
|
||||
#define CELT_SET_START_BAND_REQUEST 10010
|
||||
#define CELT_SET_END_BAND_REQUEST 10012
|
||||
#define CELT_GET_MODE_REQUEST 10015
|
||||
#define CELT_SET_SIGNALLING_REQUEST 10016
|
||||
#define CELT_SET_TONALITY_REQUEST 10018
|
||||
#define CELT_SET_TONALITY_SLOPE_REQUEST 10020
|
||||
#define CELT_SET_ANALYSIS_REQUEST 10022
|
||||
#define OPUS_SET_LFE_REQUEST 10024
|
||||
#define OPUS_SET_ENERGY_MASK_REQUEST 10026
|
||||
#define CELT_SET_SILK_INFO_REQUEST 10028
|
||||
#define PLC_PITCH_LAG_MAX 720
|
||||
#define PLC_PITCH_LAG_MIN 100
|
||||
@@ -1,98 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint-gcc.h>
|
||||
#include "celt_defines.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t r;
|
||||
int32_t i;
|
||||
} kiss_fft_cpx;
|
||||
|
||||
typedef struct {
|
||||
int16_t r;
|
||||
int16_t i;
|
||||
} kiss_twiddle_cpx;
|
||||
|
||||
typedef struct kiss_fft_state {
|
||||
int32_t nfft;
|
||||
int16_t scale;
|
||||
int32_t scale_shift;
|
||||
int32_t shift;
|
||||
int16_t factors[2 * MAXFACTORS];
|
||||
const int16_t* bitrev;
|
||||
const kiss_twiddle_cpx* twiddles;
|
||||
} kiss_fft_state;
|
||||
|
||||
typedef struct {
|
||||
int32_t n;
|
||||
int32_t maxshift;
|
||||
const kiss_fft_state* kfft[4];
|
||||
const int16_t* trig;
|
||||
} mdct_lookup_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t size;
|
||||
const int16_t* index;
|
||||
const uint8_t* bits;
|
||||
const uint8_t* caps;
|
||||
} PulseCache;
|
||||
|
||||
typedef struct _CELTMode {
|
||||
int32_t Fs;
|
||||
int32_t overlap;
|
||||
int32_t nbEBands;
|
||||
int32_t effEBands;
|
||||
int16_t preemph[4];
|
||||
int32_t maxLM;
|
||||
int32_t nbShortMdcts;
|
||||
int32_t shortMdctSize;
|
||||
int32_t nbAllocVectors; /**< Number of lines in the matrix below */
|
||||
} CELTMode_t;
|
||||
|
||||
typedef struct _band_ctx {
|
||||
int32_t resynth;
|
||||
const CELTMode_t* m;
|
||||
int32_t i;
|
||||
int32_t intensity;
|
||||
int32_t spread;
|
||||
int32_t tf_change;
|
||||
int32_t remaining_bits;
|
||||
const int32_t* bandE;
|
||||
uint32_t seed;
|
||||
int32_t theta_round;
|
||||
int32_t disable_inv;
|
||||
int32_t avoid_split_noise;
|
||||
} band_ctx_t;
|
||||
|
||||
struct split_ctx {
|
||||
int32_t inv;
|
||||
int32_t imid;
|
||||
int32_t iside;
|
||||
int32_t delta;
|
||||
int32_t itheta;
|
||||
int32_t qalloc;
|
||||
};
|
||||
|
||||
typedef struct _CELTDecoder {
|
||||
int32_t overlap;
|
||||
int32_t channels;
|
||||
int32_t stream_channels;
|
||||
int32_t downsample;
|
||||
int32_t start, end;
|
||||
int32_t signalling;
|
||||
int32_t disable_inv;
|
||||
uint32_t rng;
|
||||
int32_t error;
|
||||
int32_t last_pitch_index;
|
||||
int32_t loss_count;
|
||||
int32_t skip_plc;
|
||||
int32_t postfilter_period;
|
||||
int32_t postfilter_period_old;
|
||||
int16_t postfilter_gain;
|
||||
int16_t postfilter_gain_old;
|
||||
int32_t postfilter_tapset;
|
||||
int32_t postfilter_tapset_old;
|
||||
int32_t preemph_memD[2];
|
||||
} CELTDecoder_t;
|
||||
|
||||
|
||||
@@ -1,359 +0,0 @@
|
||||
#pragma once // celt_tables
|
||||
|
||||
#include "celt_structs.h"
|
||||
#include <stdint-gcc.h>
|
||||
|
||||
static const int16_t eband5ms[22] = {
|
||||
/*0 200 400 600 800 1k 1.2 1.4 1.6 2k 2.4 2.8 3.2 4k 4.8 5.6 6.8 8k 9.6 12k 15.6 */
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 78, 100};
|
||||
|
||||
static const uint8_t band_allocation[231] = {
|
||||
/*0 200 400 600 800 1k 1.2 1.4 1.6 2k 2.4 2.8 3.2 4k 4.8 5.6 6.8 8k 9.6 12k 15.6 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 80, 75, 69, 63, 56, 49, 40, 34, 29, 20, 18, 10, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 110, 100, 90, 84, 78, 71, 65, 58, 51, 45, 39, 32, 26, 20, 12, 0, 0, 0, 0, 0, 0, 118, 110, 103, 93, 86, 80, 75, 70, 65, 59, 53, 47, 40, 31, 23,
|
||||
15, 4, 0, 0, 0, 0, 126, 119, 112, 104, 95, 89, 83, 78, 72, 66, 60, 54, 47, 39, 32, 25, 17, 12, 1, 0, 0, 134, 127, 120, 114, 103, 97, 91, 85, 78, 72, 66, 60,
|
||||
54, 47, 41, 35, 29, 23, 16, 10, 1, 144, 137, 130, 124, 113, 107, 101, 95, 88, 82, 76, 70, 64, 57, 51, 45, 39, 33, 26, 15, 1, 152, 145, 138, 132, 123, 117, 111, 105, 98,
|
||||
92, 86, 80, 74, 67, 61, 55, 49, 43, 36, 20, 1, 162, 155, 148, 142, 133, 127, 121, 115, 108, 102, 96, 90, 84, 77, 71, 65, 59, 53, 46, 30, 1, 172, 165, 158, 152, 143, 137,
|
||||
131, 125, 118, 112, 106, 100, 94, 87, 81, 75, 69, 63, 56, 45, 20, 200, 200, 200, 200, 200, 200, 200, 200, 198, 193, 188, 183, 178, 173, 168, 163, 158, 153, 148, 129, 104,
|
||||
};
|
||||
|
||||
/*For each V(N,K) supported, we will access element U(min(N,K+1),max(N,K+1)). Thus, the number of entries in row I is
|
||||
the larger of the maximum number of pulses we will ever allocate for a given N=I (K=128, or however many fit in
|
||||
32 bits, whichever is smaller), plus one, and the maximum N for which K=I-1 pulses fit in 32 bits.
|
||||
The largest band size in an Opus Custom mode is 208. Otherwise, we can limit things to the set of N which can be
|
||||
achieved by splitting a band from a
|
||||
standard Opus mode: 176, 144, 96, 88, 72, 64, 48,44, 36, 32, 24, 22, 18, 16, 8, 4, 2).*/
|
||||
|
||||
static const uint32_t CELT_PVQ_U_DATA[1272] = {
|
||||
/*N=0, K=0...176:*/
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*N=1, K=1...176:*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
/*N=2, K=2...176:*/
|
||||
3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101,
|
||||
103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179,
|
||||
181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257,
|
||||
259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 333, 335,
|
||||
337, 339, 341, 343, 345, 347, 349, 351,
|
||||
/*N=3, K=3...176:*/
|
||||
13, 25, 41, 61, 85, 113, 145, 181, 221, 265, 313, 365, 421, 481, 545, 613, 685, 761, 841, 925, 1013, 1105, 1201, 1301, 1405, 1513, 1625, 1741, 1861, 1985, 2113, 2245, 2381, 2521, 2665, 2813, 2965,
|
||||
3121, 3281, 3445, 3613, 3785, 3961, 4141, 4325, 4513, 4705, 4901, 5101, 5305, 5513, 5725, 5941, 6161, 6385, 6613, 6845, 7081, 7321, 7565, 7813, 8065, 8321, 8581, 8845, 9113, 9385, 9661, 9941,
|
||||
10225, 10513, 10805, 11101, 11401, 11705, 12013, 12325, 12641, 12961, 13285, 13613, 13945, 14281, 14621, 14965, 15313, 15665, 16021, 16381, 16745, 17113, 17485, 17861, 18241, 18625, 19013, 19405,
|
||||
19801, 20201, 20605, 21013, 21425, 21841, 22261, 22685, 23113, 23545, 23981, 24421, 24865, 25313, 25765, 26221, 26681, 27145, 27613, 28085, 28561, 29041, 29525, 30013, 30505, 31001, 31501, 32005,
|
||||
32513, 33025, 33541, 34061, 34585, 35113, 35645, 36181, 36721, 37265, 37813, 38365, 38921, 39481, 40045, 40613, 41185, 41761, 42341, 42925, 43513, 44105, 44701, 45301, 45905, 46513, 47125, 47741,
|
||||
48361, 48985, 49613, 50245, 50881, 51521, 52165, 52813, 53465, 54121, 54781, 55445, 56113, 56785, 57461, 58141, 58825, 59513, 60205, 60901, 61601,
|
||||
/*N=4, K=4...176:*/
|
||||
63, 129, 231, 377, 575, 833, 1159, 1561, 2047, 2625, 3303, 4089, 4991, 6017, 7175, 8473, 9919, 11521, 13287, 15225, 17343, 19649, 22151, 24857, 27775, 30913, 34279, 37881, 41727, 45825, 50183,
|
||||
54809, 59711, 64897, 70375, 76153, 82239, 88641, 95367, 102425, 109823, 117569, 125671, 134137, 142975, 152193, 161799, 171801, 182207, 193025, 204263, 215929, 228031, 240577, 253575, 267033,
|
||||
280959, 295361, 310247, 325625, 341503, 357889, 374791, 392217, 410175, 428673, 447719, 467321, 487487, 508225, 529543, 551449, 573951, 597057, 620775, 645113, 670079, 695681, 721927, 748825,
|
||||
776383, 804609, 833511, 863097, 893375, 924353, 956039, 988441, 1021567, 1055425, 1090023, 1125369, 1161471, 1198337, 1235975, 1274393, 1313599, 1353601, 1394407, 1436025, 1478463, 1521729,
|
||||
1565831, 1610777, 1656575, 1703233, 1750759, 1799161, 1848447, 1898625, 1949703, 2001689, 2054591, 2108417, 2163175, 2218873, 2275519, 2333121, 2391687, 2451225, 2511743, 2573249, 2635751,
|
||||
2699257, 2763775, 2829313, 2895879, 2963481, 3032127, 3101825, 3172583, 3244409, 3317311, 3391297, 3466375, 3542553, 3619839, 3698241, 3777767, 3858425, 3940223, 4023169, 4107271, 4192537,
|
||||
4278975, 4366593, 4455399, 4545401, 4636607, 4729025, 4822663, 4917529, 5013631, 5110977, 5209575, 5309433, 5410559, 5512961, 5616647, 5721625, 5827903, 5935489, 6044391, 6154617, 6266175,
|
||||
6379073, 6493319, 6608921, 6725887, 6844225, 6963943, 7085049, 7207551,
|
||||
/*N=5, K=5...176:*/
|
||||
321, 681, 1289, 2241, 3649, 5641, 8361, 11969, 16641, 22569, 29961, 39041, 50049, 63241, 78889, 97281, 118721, 143529, 172041, 204609, 241601, 283401, 330409, 383041, 441729, 506921, 579081,
|
||||
658689, 746241, 842249, 947241, 1061761, 1186369, 1321641, 1468169, 1626561, 1797441, 1981449, 2179241, 2391489, 2618881, 2862121, 3121929, 3399041, 3694209, 4008201, 4341801, 4695809, 5071041,
|
||||
5468329, 5888521, 6332481, 6801089, 7295241, 7815849, 8363841, 8940161, 9545769, 10181641, 10848769, 11548161, 12280841, 13047849, 13850241, 14689089, 15565481, 16480521, 17435329, 18431041,
|
||||
19468809, 20549801, 21675201, 22846209, 24064041, 25329929, 26645121, 28010881, 29428489, 30899241, 32424449, 34005441, 35643561, 37340169, 39096641, 40914369, 42794761, 44739241, 46749249,
|
||||
48826241, 50971689, 53187081, 55473921, 57833729, 60268041, 62778409, 65366401, 68033601, 70781609, 73612041, 76526529, 79526721, 82614281, 85790889, 89058241, 92418049, 95872041, 99421961,
|
||||
103069569, 106816641, 110664969, 114616361, 118672641, 122835649, 127107241, 131489289, 135983681, 140592321, 145317129, 150160041, 155123009, 160208001, 165417001, 170752009, 176215041,
|
||||
181808129, 187533321, 193392681, 199388289, 205522241, 211796649, 218213641, 224775361, 231483969, 238341641, 245350569, 252512961, 259831041, 267307049, 274943241, 282741889, 290705281,
|
||||
298835721, 307135529, 315607041, 324252609, 333074601, 342075401, 351257409, 360623041, 370174729, 379914921, 389846081, 399970689, 410291241, 420810249, 431530241, 442453761, 453583369,
|
||||
464921641, 476471169, 488234561, 500214441, 512413449, 524834241, 537479489, 550351881, 563454121, 576788929, 590359041, 604167209, 618216201, 632508801,
|
||||
/*N=6, K=6...96:*/
|
||||
1683, 3653, 7183, 13073, 22363, 36365, 56695, 85305, 124515, 177045, 246047, 335137, 448427, 590557, 766727, 982729, 1244979, 1560549, 1937199, 2383409, 2908411, 3522221, 4235671, 5060441,
|
||||
6009091, 7095093, 8332863, 9737793, 11326283, 13115773, 15124775, 17372905, 19880915, 22670725, 25765455, 29189457, 32968347, 37129037, 41699767, 46710137, 52191139, 58175189, 64696159, 71789409,
|
||||
79491819, 87841821, 96879431, 106646281, 117185651, 128542501, 140763503, 153897073, 167993403, 183104493, 199284183, 216588185, 235074115, 254801525, 275831935, 298228865, 322057867, 347386557,
|
||||
374284647, 402823977, 433078547, 465124549, 499040399, 534906769, 572806619, 612825229, 655050231, 699571641, 746481891, 795875861, 847850911, 902506913, 959946283, 1020274013, 1083597703,
|
||||
1150027593, 1219676595, 1292660325, 1369097135, 1449108145, 1532817275, 1620351277, 1711839767, 1807415257, 1907213187, 2011371957, 2120032959,
|
||||
/*N=7, K=7...54*/
|
||||
8989, 19825, 40081, 75517, 134245, 227305, 369305, 579125, 880685, 1303777, 1884961, 2668525, 3707509, 5064793, 6814249, 9041957, 11847485, 15345233, 19665841, 24957661, 31388293, 39146185,
|
||||
48442297, 59511829, 72616013, 88043969, 106114625, 127178701, 151620757, 179861305, 212358985, 249612805, 292164445, 340600625, 395555537, 457713341, 527810725, 606639529, 695049433, 793950709,
|
||||
904317037, 1027188385, 1163673953, 1314955181, 1482288821, 1667010073, 1870535785, 2094367717,
|
||||
/*N=8, K=8...37*/
|
||||
48639, 108545, 224143, 433905, 795455, 1392065, 2340495, 3800305, 5984767, 9173505, 13726991, 20103025, 28875327, 40754369, 56610575, 77500017, 104692735, 139703809, 184327311, 240673265,
|
||||
311207743, 398796225, 506750351, 638878193, 799538175, 993696769, 1226990095, 1505789553, 1837271615, 2229491905U,
|
||||
/*N=9, K=9...28:*/
|
||||
265729, 598417, 1256465, 2485825, 4673345, 8405905, 14546705, 24331777, 39490049, 62390545, 96220561, 145198913, 214828609, 312193553, 446304145, 628496897, 872893441, 1196924561, 1621925137,
|
||||
2173806145U,
|
||||
/*N=10, K=10...24:*/
|
||||
1462563, 3317445, 7059735, 14218905, 27298155, 50250765, 89129247, 152951073, 254831667, 413442773, 654862247, 1014889769, 1541911931, 2300409629U, 3375210671U,
|
||||
/*N=11, K=11...19:*/
|
||||
8097453, 18474633, 39753273, 81270333, 158819253, 298199265, 540279585, 948062325, 1616336765,
|
||||
/*N=12, K=12...18:*/
|
||||
45046719, 103274625, 224298231, 464387817, 921406335, 1759885185, 3248227095U,
|
||||
/*N=13, K=13...16:*/
|
||||
251595969, 579168825, 1267854873, 2653649025U,
|
||||
/*N=14, K=14:*/
|
||||
1409933619};
|
||||
|
||||
static const int16_t mdct_twiddles960[1800] = {
|
||||
32767, 32767, 32767, 32766, 32765, 32763, 32761, 32759, 32756, 32753, 32750, 32746, 32742, 32738, 32733, 32728, 32722, 32717, 32710, 32704, 32697, 32690, 32682, 32674,
|
||||
32666, 32657, 32648, 32639, 32629, 32619, 32609, 32598, 32587, 32576, 32564, 32552, 32539, 32526, 32513, 32500, 32486, 32472, 32457, 32442, 32427, 32411, 32395, 32379,
|
||||
32362, 32345, 32328, 32310, 32292, 32274, 32255, 32236, 32217, 32197, 32177, 32157, 32136, 32115, 32093, 32071, 32049, 32027, 32004, 31981, 31957, 31933, 31909, 31884,
|
||||
31859, 31834, 31809, 31783, 31756, 31730, 31703, 31676, 31648, 31620, 31592, 31563, 31534, 31505, 31475, 31445, 31415, 31384, 31353, 31322, 31290, 31258, 31226, 31193,
|
||||
31160, 31127, 31093, 31059, 31025, 30990, 30955, 30920, 30884, 30848, 30812, 30775, 30738, 30701, 30663, 30625, 30587, 30548, 30509, 30470, 30430, 30390, 30350, 30309,
|
||||
30269, 30227, 30186, 30144, 30102, 30059, 30016, 29973, 29930, 29886, 29842, 29797, 29752, 29707, 29662, 29616, 29570, 29524, 29477, 29430, 29383, 29335, 29287, 29239,
|
||||
29190, 29142, 29092, 29043, 28993, 28943, 28892, 28842, 28791, 28739, 28688, 28636, 28583, 28531, 28478, 28425, 28371, 28317, 28263, 28209, 28154, 28099, 28044, 27988,
|
||||
27932, 27876, 27820, 27763, 27706, 27648, 27591, 27533, 27474, 27416, 27357, 27298, 27238, 27178, 27118, 27058, 26997, 26936, 26875, 26814, 26752, 26690, 26628, 26565,
|
||||
26502, 26439, 26375, 26312, 26247, 26183, 26119, 26054, 25988, 25923, 25857, 25791, 25725, 25658, 25592, 25524, 25457, 25389, 25322, 25253, 25185, 25116, 25047, 24978,
|
||||
24908, 24838, 24768, 24698, 24627, 24557, 24485, 24414, 24342, 24270, 24198, 24126, 24053, 23980, 23907, 23834, 23760, 23686, 23612, 23537, 23462, 23387, 23312, 23237,
|
||||
23161, 23085, 23009, 22932, 22856, 22779, 22701, 22624, 22546, 22468, 22390, 22312, 22233, 22154, 22075, 21996, 21916, 21836, 21756, 21676, 21595, 21515, 21434, 21352,
|
||||
21271, 21189, 21107, 21025, 20943, 20860, 20777, 20694, 20611, 20528, 20444, 20360, 20276, 20192, 20107, 20022, 19937, 19852, 19767, 19681, 19595, 19509, 19423, 19336,
|
||||
19250, 19163, 19076, 18988, 18901, 18813, 18725, 18637, 18549, 18460, 18372, 18283, 18194, 18104, 18015, 17925, 17835, 17745, 17655, 17565, 17474, 17383, 17292, 17201,
|
||||
17110, 17018, 16927, 16835, 16743, 16650, 16558, 16465, 16372, 16279, 16186, 16093, 15999, 15906, 15812, 15718, 15624, 15529, 15435, 15340, 15245, 15150, 15055, 14960,
|
||||
14864, 14769, 14673, 14577, 14481, 14385, 14288, 14192, 14095, 13998, 13901, 13804, 13706, 13609, 13511, 13414, 13316, 13218, 13119, 13021, 12923, 12824, 12725, 12626,
|
||||
12527, 12428, 12329, 12230, 12130, 12030, 11930, 11831, 11730, 11630, 11530, 11430, 11329, 11228, 11128, 11027, 10926, 10824, 10723, 10622, 10520, 10419, 10317, 10215,
|
||||
10113, 10011, 9909, 9807, 9704, 9602, 9499, 9397, 9294, 9191, 9088, 8985, 8882, 8778, 8675, 8572, 8468, 8364, 8261, 8157, 8053, 7949, 7845, 7741,
|
||||
7637, 7532, 7428, 7323, 7219, 7114, 7009, 6905, 6800, 6695, 6590, 6485, 6380, 6274, 6169, 6064, 5958, 5853, 5747, 5642, 5536, 5430, 5325, 5219,
|
||||
5113, 5007, 4901, 4795, 4689, 4583, 4476, 4370, 4264, 4157, 4051, 3945, 3838, 3732, 3625, 3518, 3412, 3305, 3198, 3092, 2985, 2878, 2771, 2664,
|
||||
2558, 2451, 2344, 2237, 2130, 2023, 1916, 1809, 1702, 1594, 1487, 1380, 1273, 1166, 1059, 952, 844, 737, 630, 523, 416, 308, 201, 94,
|
||||
-13, -121, -228, -335, -442, -550, -657, -764, -871, -978, -1086, -1193, -1300, -1407, -1514, -1621, -1728, -1835, -1942, -2049, -2157, -2263, -2370, -2477,
|
||||
-2584, -2691, -2798, -2905, -3012, -3118, -3225, -3332, -3439, -3545, -3652, -3758, -3865, -3971, -4078, -4184, -4290, -4397, -4503, -4609, -4715, -4821, -4927, -5033,
|
||||
-5139, -5245, -5351, -5457, -5562, -5668, -5774, -5879, -5985, -6090, -6195, -6301, -6406, -6511, -6616, -6721, -6826, -6931, -7036, -7140, -7245, -7349, -7454, -7558,
|
||||
-7663, -7767, -7871, -7975, -8079, -8183, -8287, -8390, -8494, -8597, -8701, -8804, -8907, -9011, -9114, -9217, -9319, -9422, -9525, -9627, -9730, -9832, -9934, -10037,
|
||||
-10139, -10241, -10342, -10444, -10546, -10647, -10748, -10850, -10951, -11052, -11153, -11253, -11354, -11455, -11555, -11655, -11756, -11856, -11955, -12055, -12155, -12254, -12354, -12453,
|
||||
-12552, -12651, -12750, -12849, -12947, -13046, -13144, -13242, -13340, -13438, -13536, -13633, -13731, -13828, -13925, -14022, -14119, -14216, -14312, -14409, -14505, -14601, -14697, -14793,
|
||||
-14888, -14984, -15079, -15174, -15269, -15364, -15459, -15553, -15647, -15741, -15835, -15929, -16023, -16116, -16210, -16303, -16396, -16488, -16581, -16673, -16766, -16858, -16949, -17041,
|
||||
-17133, -17224, -17315, -17406, -17497, -17587, -17678, -17768, -17858, -17948, -18037, -18127, -18216, -18305, -18394, -18483, -18571, -18659, -18747, -18835, -18923, -19010, -19098, -19185,
|
||||
-19271, -19358, -19444, -19531, -19617, -19702, -19788, -19873, -19959, -20043, -20128, -20213, -20297, -20381, -20465, -20549, -20632, -20715, -20798, -20881, -20963, -21046, -21128, -21210,
|
||||
-21291, -21373, -21454, -21535, -21616, -21696, -21776, -21856, -21936, -22016, -22095, -22174, -22253, -22331, -22410, -22488, -22566, -22643, -22721, -22798, -22875, -22951, -23028, -23104,
|
||||
-23180, -23256, -23331, -23406, -23481, -23556, -23630, -23704, -23778, -23852, -23925, -23998, -24071, -24144, -24216, -24288, -24360, -24432, -24503, -24574, -24645, -24716, -24786, -24856,
|
||||
-24926, -24995, -25064, -25133, -25202, -25270, -25339, -25406, -25474, -25541, -25608, -25675, -25742, -25808, -25874, -25939, -26005, -26070, -26135, -26199, -26264, -26327, -26391, -26455,
|
||||
-26518, -26581, -26643, -26705, -26767, -26829, -26891, -26952, -27013, -27073, -27133, -27193, -27253, -27312, -27372, -27430, -27489, -27547, -27605, -27663, -27720, -27777, -27834, -27890,
|
||||
-27946, -28002, -28058, -28113, -28168, -28223, -28277, -28331, -28385, -28438, -28491, -28544, -28596, -28649, -28701, -28752, -28803, -28854, -28905, -28955, -29006, -29055, -29105, -29154,
|
||||
-29203, -29251, -29299, -29347, -29395, -29442, -29489, -29535, -29582, -29628, -29673, -29719, -29764, -29808, -29853, -29897, -29941, -29984, -30027, -30070, -30112, -30154, -30196, -30238,
|
||||
-30279, -30320, -30360, -30400, -30440, -30480, -30519, -30558, -30596, -30635, -30672, -30710, -30747, -30784, -30821, -30857, -30893, -30929, -30964, -30999, -31033, -31068, -31102, -31135,
|
||||
-31168, -31201, -31234, -31266, -31298, -31330, -31361, -31392, -31422, -31453, -31483, -31512, -31541, -31570, -31599, -31627, -31655, -31682, -31710, -31737, -31763, -31789, -31815, -31841,
|
||||
-31866, -31891, -31915, -31939, -31963, -31986, -32010, -32032, -32055, -32077, -32099, -32120, -32141, -32162, -32182, -32202, -32222, -32241, -32260, -32279, -32297, -32315, -32333, -32350,
|
||||
-32367, -32383, -32399, -32415, -32431, -32446, -32461, -32475, -32489, -32503, -32517, -32530, -32542, -32555, -32567, -32579, -32590, -32601, -32612, -32622, -32632, -32641, -32651, -32659,
|
||||
-32668, -32676, -32684, -32692, -32699, -32706, -32712, -32718, -32724, -32729, -32734, -32739, -32743, -32747, -32751, -32754, -32757, -32760, -32762, -32764, -32765, -32767, -32767, -32767,
|
||||
32767, 32767, 32765, 32761, 32756, 32750, 32742, 32732, 32722, 32710, 32696, 32681, 32665, 32647, 32628, 32608, 32586, 32562, 32538, 32512, 32484, 32455, 32425, 32393,
|
||||
32360, 32326, 32290, 32253, 32214, 32174, 32133, 32090, 32046, 32001, 31954, 31906, 31856, 31805, 31753, 31700, 31645, 31588, 31530, 31471, 31411, 31349, 31286, 31222,
|
||||
31156, 31089, 31020, 30951, 30880, 30807, 30733, 30658, 30582, 30504, 30425, 30345, 30263, 30181, 30096, 30011, 29924, 29836, 29747, 29656, 29564, 29471, 29377, 29281,
|
||||
29184, 29086, 28987, 28886, 28784, 28681, 28577, 28471, 28365, 28257, 28147, 28037, 27925, 27812, 27698, 27583, 27467, 27349, 27231, 27111, 26990, 26868, 26744, 26620,
|
||||
26494, 26367, 26239, 26110, 25980, 25849, 25717, 25583, 25449, 25313, 25176, 25038, 24900, 24760, 24619, 24477, 24333, 24189, 24044, 23898, 23751, 23602, 23453, 23303,
|
||||
23152, 22999, 22846, 22692, 22537, 22380, 22223, 22065, 21906, 21746, 21585, 21423, 21261, 21097, 20933, 20767, 20601, 20434, 20265, 20096, 19927, 19756, 19584, 19412,
|
||||
19239, 19065, 18890, 18714, 18538, 18361, 18183, 18004, 17824, 17644, 17463, 17281, 17098, 16915, 16731, 16546, 16361, 16175, 15988, 15800, 15612, 15423, 15234, 15043,
|
||||
14852, 14661, 14469, 14276, 14083, 13889, 13694, 13499, 13303, 13107, 12910, 12713, 12515, 12317, 12118, 11918, 11718, 11517, 11316, 11115, 10913, 10710, 10508, 10304,
|
||||
10100, 9896, 9691, 9486, 9281, 9075, 8869, 8662, 8455, 8248, 8040, 7832, 7623, 7415, 7206, 6996, 6787, 6577, 6366, 6156, 5945, 5734, 5523, 5311,
|
||||
5100, 4888, 4675, 4463, 4251, 4038, 3825, 3612, 3399, 3185, 2972, 2758, 2544, 2330, 2116, 1902, 1688, 1474, 1260, 1045, 831, 617, 402, 188,
|
||||
-27, -241, -456, -670, -885, -1099, -1313, -1528, -1742, -1956, -2170, -2384, -2598, -2811, -3025, -3239, -3452, -3665, -3878, -4091, -4304, -4516, -4728, -4941,
|
||||
-5153, -5364, -5576, -5787, -5998, -6209, -6419, -6629, -6839, -7049, -7258, -7467, -7676, -7884, -8092, -8300, -8507, -8714, -8920, -9127, -9332, -9538, -9743, -9947,
|
||||
-10151, -10355, -10558, -10761, -10963, -11165, -11367, -11568, -11768, -11968, -12167, -12366, -12565, -12762, -12960, -13156, -13352, -13548, -13743, -13937, -14131, -14324, -14517, -14709,
|
||||
-14900, -15091, -15281, -15470, -15659, -15847, -16035, -16221, -16407, -16593, -16777, -16961, -17144, -17326, -17508, -17689, -17869, -18049, -18227, -18405, -18582, -18758, -18934, -19108,
|
||||
-19282, -19455, -19627, -19799, -19969, -20139, -20308, -20475, -20642, -20809, -20974, -21138, -21301, -21464, -21626, -21786, -21946, -22105, -22263, -22420, -22575, -22730, -22884, -23037,
|
||||
-23189, -23340, -23490, -23640, -23788, -23935, -24080, -24225, -24369, -24512, -24654, -24795, -24934, -25073, -25211, -25347, -25482, -25617, -25750, -25882, -26013, -26143, -26272, -26399,
|
||||
-26526, -26651, -26775, -26898, -27020, -27141, -27260, -27379, -27496, -27612, -27727, -27841, -27953, -28065, -28175, -28284, -28391, -28498, -28603, -28707, -28810, -28911, -29012, -29111,
|
||||
-29209, -29305, -29401, -29495, -29587, -29679, -29769, -29858, -29946, -30032, -30118, -30201, -30284, -30365, -30445, -30524, -30601, -30677, -30752, -30825, -30897, -30968, -31038, -31106,
|
||||
-31172, -31238, -31302, -31365, -31426, -31486, -31545, -31602, -31658, -31713, -31766, -31818, -31869, -31918, -31966, -32012, -32058, -32101, -32144, -32185, -32224, -32262, -32299, -32335,
|
||||
-32369, -32401, -32433, -32463, -32491, -32518, -32544, -32568, -32591, -32613, -32633, -32652, -32669, -32685, -32700, -32713, -32724, -32735, -32744, -32751, -32757, -32762, -32766, -32767,
|
||||
32767, 32764, 32755, 32741, 32720, 32694, 32663, 32626, 32583, 32535, 32481, 32421, 32356, 32286, 32209, 32128, 32041, 31948, 31850, 31747, 31638, 31523, 31403, 31278,
|
||||
31148, 31012, 30871, 30724, 30572, 30415, 30253, 30086, 29913, 29736, 29553, 29365, 29172, 28974, 28771, 28564, 28351, 28134, 27911, 27684, 27452, 27216, 26975, 26729,
|
||||
26478, 26223, 25964, 25700, 25432, 25159, 24882, 24601, 24315, 24026, 23732, 23434, 23133, 22827, 22517, 22204, 21886, 21565, 21240, 20912, 20580, 20244, 19905, 19563,
|
||||
19217, 18868, 18516, 18160, 17802, 17440, 17075, 16708, 16338, 15964, 15588, 15210, 14829, 14445, 14059, 13670, 13279, 12886, 12490, 12093, 11693, 11291, 10888, 10482,
|
||||
10075, 9666, 9255, 8843, 8429, 8014, 7597, 7180, 6760, 6340, 5919, 5496, 5073, 4649, 4224, 3798, 3372, 2945, 2517, 2090, 1661, 1233, 804, 375,
|
||||
-54, -483, -911, -1340, -1768, -2197, -2624, -3052, -3479, -3905, -4330, -4755, -5179, -5602, -6024, -6445, -6865, -7284, -7702, -8118, -8533, -8946, -9358, -9768,
|
||||
-10177, -10584, -10989, -11392, -11793, -12192, -12589, -12984, -13377, -13767, -14155, -14541, -14924, -15305, -15683, -16058, -16430, -16800, -17167, -17531, -17892, -18249, -18604, -18956,
|
||||
-19304, -19649, -19990, -20329, -20663, -20994, -21322, -21646, -21966, -22282, -22595, -22904, -23208, -23509, -23806, -24099, -24387, -24672, -24952, -25228, -25499, -25766, -26029, -26288,
|
||||
-26541, -26791, -27035, -27275, -27511, -27741, -27967, -28188, -28405, -28616, -28823, -29024, -29221, -29412, -29599, -29780, -29957, -30128, -30294, -30455, -30611, -30761, -30906, -31046,
|
||||
-31181, -31310, -31434, -31552, -31665, -31773, -31875, -31972, -32063, -32149, -32229, -32304, -32373, -32437, -32495, -32547, -32594, -32635, -32671, -32701, -32726, -32745, -32758, -32766,
|
||||
32767, 32754, 32717, 32658, 32577, 32473, 32348, 32200, 32029, 31837, 31624, 31388, 31131, 30853, 30553, 30232, 29891, 29530, 29148, 28746, 28324, 27883, 27423, 26944,
|
||||
26447, 25931, 25398, 24847, 24279, 23695, 23095, 22478, 21846, 21199, 20538, 19863, 19174, 18472, 17757, 17030, 16291, 15541, 14781, 14010, 13230, 12441, 11643, 10837,
|
||||
10024, 9204, 8377, 7545, 6708, 5866, 5020, 4171, 3319, 2464, 1608, 751, -107, -965, -1822, -2678, -3532, -4383, -5232, -6077, -6918, -7754, -8585, -9409,
|
||||
-10228, -11039, -11843, -12639, -13426, -14204, -14972, -15730, -16477, -17213, -17937, -18648, -19347, -20033, -20705, -21363, -22006, -22634, -23246, -23843, -24423, -24986, -25533, -26062,
|
||||
-26573, -27066, -27540, -27995, -28431, -28848, -29245, -29622, -29979, -30315, -30630, -30924, -31197, -31449, -31679, -31887, -32074, -32239, -32381, -32501, -32600, -32675, -32729, -32759,
|
||||
};
|
||||
|
||||
static const int16_t window120[120] = {
|
||||
2, 20, 55, 108, 178, 266, 372, 494, 635, 792, 966, 1157, 1365, 1590, 1831, 2089, 2362, 2651, 2956, 3276, 3611, 3961, 4325, 4703,
|
||||
5094, 5499, 5916, 6346, 6788, 7241, 7705, 8179, 8663, 9156, 9657, 10167, 10684, 11207, 11736, 12271, 12810, 13353, 13899, 14447, 14997, 15547, 16098, 16648,
|
||||
17197, 17744, 18287, 18827, 19363, 19893, 20418, 20936, 21447, 21950, 22445, 22931, 23407, 23874, 24330, 24774, 25208, 25629, 26039, 26435, 26819, 27190, 27548, 27893,
|
||||
28224, 28541, 28845, 29135, 29411, 29674, 29924, 30160, 30384, 30594, 30792, 30977, 31151, 31313, 31463, 31602, 31731, 31849, 31958, 32057, 32148, 32229, 32303, 32370,
|
||||
32429, 32481, 32528, 32568, 32604, 32634, 32661, 32683, 32701, 32717, 32729, 32740, 32748, 32754, 32758, 32762, 32764, 32766, 32767, 32767, 32767, 32767, 32767, 32767,
|
||||
};
|
||||
|
||||
static const int16_t logN400[21] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36,
|
||||
};
|
||||
|
||||
static const int16_t cache_index50[105] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 123, 123,
|
||||
123, 164, 164, 240, 266, 283, 295, 41, 41, 41, 41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, 318, 328, 336, 123, 123, 123, 123, 123, 123, 123,
|
||||
123, 240, 240, 240, 240, 305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, 240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387,
|
||||
};
|
||||
static const uint8_t cache_bits50[392] = {
|
||||
40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 40, 15, 23, 28, 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, 51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62,
|
||||
63, 63, 65, 66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, 64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, 94, 96, 98,
|
||||
101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, 124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, 97, 100, 102, 105, 107, 111, 115, 118, 121,
|
||||
124, 126, 129, 131, 135, 139, 142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149,
|
||||
153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, 229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, 166, 174, 182, 189, 195, 201,
|
||||
207, 217, 227, 235, 243, 251, 17, 35, 63, 86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, 25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161,
|
||||
168, 174, 180, 185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, 74, 103, 128,
|
||||
151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, 163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, 228, 241, 253, 9, 44, 81, 113, 142, 168,
|
||||
192, 214, 235, 255, 7, 49, 90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, 87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57,
|
||||
106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, 224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, 182, 234,
|
||||
};
|
||||
static const uint8_t cache_caps50[168] = {
|
||||
224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, 178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, 240, 240, 240, 207,
|
||||
207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, 160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, 138, 64, 38, 240, 240, 240, 240, 240,
|
||||
240, 240, 240, 207, 207, 207, 207, 204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, 185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172,
|
||||
138, 65, 39, 207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, 188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193,
|
||||
193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, 204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, 140, 66, 40,
|
||||
};
|
||||
|
||||
static const kiss_twiddle_cpx fft_twiddles48000_960[480] = {
|
||||
{32767, 0}, {32766, -429}, {32757, -858}, {32743, -1287}, {32724, -1715}, {32698, -2143}, {32667, -2570}, {32631, -2998}, {32588, -3425}, {32541, -3851},
|
||||
{32488, -4277}, {32429, -4701}, {32364, -5125}, {32295, -5548}, {32219, -5971}, {32138, -6393}, {32051, -6813}, {31960, -7231}, {31863, -7650}, {31760, -8067},
|
||||
{31652, -8481}, {31539, -8895}, {31419, -9306}, {31294, -9716}, {31165, -10126}, {31030, -10532}, {30889, -10937}, {30743, -11340}, {30592, -11741}, {30436, -12141},
|
||||
{30274, -12540}, {30107, -12935}, {29936, -13328}, {29758, -13718}, {29577, -14107}, {29390, -14493}, {29197, -14875}, {29000, -15257}, {28797, -15635}, {28590, -16010},
|
||||
{28379, -16384}, {28162, -16753}, {27940, -17119}, {27714, -17484}, {27482, -17845}, {27246, -18205}, {27006, -18560}, {26760, -18911}, {26510, -19260}, {26257, -19606},
|
||||
{25997, -19947}, {25734, -20286}, {25466, -20621}, {25194, -20952}, {24918, -21281}, {24637, -21605}, {24353, -21926}, {24063, -22242}, {23770, -22555}, {23473, -22865},
|
||||
{23171, -23171}, {22866, -23472}, {22557, -23769}, {22244, -24063}, {21927, -24352}, {21606, -24636}, {21282, -24917}, {20954, -25194}, {20622, -25465}, {20288, -25733},
|
||||
{19949, -25997}, {19607, -26255}, {19261, -26509}, {18914, -26760}, {18561, -27004}, {18205, -27246}, {17846, -27481}, {17485, -27713}, {17122, -27940}, {16755, -28162},
|
||||
{16385, -28378}, {16012, -28590}, {15636, -28797}, {15258, -28999}, {14878, -29197}, {14494, -29389}, {14108, -29576}, {13720, -29757}, {13329, -29934}, {12937, -30107},
|
||||
{12540, -30274}, {12142, -30435}, {11744, -30592}, {11342, -30743}, {10939, -30889}, {10534, -31030}, {10127, -31164}, {9718, -31294}, {9307, -31418}, {8895, -31537},
|
||||
{8482, -31652}, {8067, -31759}, {7650, -31862}, {7233, -31960}, {6815, -32051}, {6393, -32138}, {5973, -32219}, {5549, -32294}, {5127, -32364}, {4703, -32429},
|
||||
{4278, -32487}, {3852, -32541}, {3426, -32588}, {2999, -32630}, {2572, -32667}, {2144, -32698}, {1716, -32724}, {1287, -32742}, {860, -32757}, {430, -32766},
|
||||
{0, -32767}, {-429, -32766}, {-858, -32757}, {-1287, -32743}, {-1715, -32724}, {-2143, -32698}, {-2570, -32667}, {-2998, -32631}, {-3425, -32588}, {-3851, -32541},
|
||||
{-4277, -32488}, {-4701, -32429}, {-5125, -32364}, {-5548, -32295}, {-5971, -32219}, {-6393, -32138}, {-6813, -32051}, {-7231, -31960}, {-7650, -31863}, {-8067, -31760},
|
||||
{-8481, -31652}, {-8895, -31539}, {-9306, -31419}, {-9716, -31294}, {-10126, -31165}, {-10532, -31030}, {-10937, -30889}, {-11340, -30743}, {-11741, -30592}, {-12141, -30436},
|
||||
{-12540, -30274}, {-12935, -30107}, {-13328, -29936}, {-13718, -29758}, {-14107, -29577}, {-14493, -29390}, {-14875, -29197}, {-15257, -29000}, {-15635, -28797}, {-16010, -28590},
|
||||
{-16384, -28379}, {-16753, -28162}, {-17119, -27940}, {-17484, -27714}, {-17845, -27482}, {-18205, -27246}, {-18560, -27006}, {-18911, -26760}, {-19260, -26510}, {-19606, -26257},
|
||||
{-19947, -25997}, {-20286, -25734}, {-20621, -25466}, {-20952, -25194}, {-21281, -24918}, {-21605, -24637}, {-21926, -24353}, {-22242, -24063}, {-22555, -23770}, {-22865, -23473},
|
||||
{-23171, -23171}, {-23472, -22866}, {-23769, -22557}, {-24063, -22244}, {-24352, -21927}, {-24636, -21606}, {-24917, -21282}, {-25194, -20954}, {-25465, -20622}, {-25733, -20288},
|
||||
{-25997, -19949}, {-26255, -19607}, {-26509, -19261}, {-26760, -18914}, {-27004, -18561}, {-27246, -18205}, {-27481, -17846}, {-27713, -17485}, {-27940, -17122}, {-28162, -16755},
|
||||
{-28378, -16385}, {-28590, -16012}, {-28797, -15636}, {-28999, -15258}, {-29197, -14878}, {-29389, -14494}, {-29576, -14108}, {-29757, -13720}, {-29934, -13329}, {-30107, -12937},
|
||||
{-30274, -12540}, {-30435, -12142}, {-30592, -11744}, {-30743, -11342}, {-30889, -10939}, {-31030, -10534}, {-31164, -10127}, {-31294, -9718}, {-31418, -9307}, {-31537, -8895},
|
||||
{-31652, -8482}, {-31759, -8067}, {-31862, -7650}, {-31960, -7233}, {-32051, -6815}, {-32138, -6393}, {-32219, -5973}, {-32294, -5549}, {-32364, -5127}, {-32429, -4703},
|
||||
{-32487, -4278}, {-32541, -3852}, {-32588, -3426}, {-32630, -2999}, {-32667, -2572}, {-32698, -2144}, {-32724, -1716}, {-32742, -1287}, {-32757, -860}, {-32766, -430},
|
||||
{-32767, 0}, {-32766, 429}, {-32757, 858}, {-32743, 1287}, {-32724, 1715}, {-32698, 2143}, {-32667, 2570}, {-32631, 2998}, {-32588, 3425}, {-32541, 3851},
|
||||
{-32488, 4277}, {-32429, 4701}, {-32364, 5125}, {-32295, 5548}, {-32219, 5971}, {-32138, 6393}, {-32051, 6813}, {-31960, 7231}, {-31863, 7650}, {-31760, 8067},
|
||||
{-31652, 8481}, {-31539, 8895}, {-31419, 9306}, {-31294, 9716}, {-31165, 10126}, {-31030, 10532}, {-30889, 10937}, {-30743, 11340}, {-30592, 11741}, {-30436, 12141},
|
||||
{-30274, 12540}, {-30107, 12935}, {-29936, 13328}, {-29758, 13718}, {-29577, 14107}, {-29390, 14493}, {-29197, 14875}, {-29000, 15257}, {-28797, 15635}, {-28590, 16010},
|
||||
{-28379, 16384}, {-28162, 16753}, {-27940, 17119}, {-27714, 17484}, {-27482, 17845}, {-27246, 18205}, {-27006, 18560}, {-26760, 18911}, {-26510, 19260}, {-26257, 19606},
|
||||
{-25997, 19947}, {-25734, 20286}, {-25466, 20621}, {-25194, 20952}, {-24918, 21281}, {-24637, 21605}, {-24353, 21926}, {-24063, 22242}, {-23770, 22555}, {-23473, 22865},
|
||||
{-23171, 23171}, {-22866, 23472}, {-22557, 23769}, {-22244, 24063}, {-21927, 24352}, {-21606, 24636}, {-21282, 24917}, {-20954, 25194}, {-20622, 25465}, {-20288, 25733},
|
||||
{-19949, 25997}, {-19607, 26255}, {-19261, 26509}, {-18914, 26760}, {-18561, 27004}, {-18205, 27246}, {-17846, 27481}, {-17485, 27713}, {-17122, 27940}, {-16755, 28162},
|
||||
{-16385, 28378}, {-16012, 28590}, {-15636, 28797}, {-15258, 28999}, {-14878, 29197}, {-14494, 29389}, {-14108, 29576}, {-13720, 29757}, {-13329, 29934}, {-12937, 30107},
|
||||
{-12540, 30274}, {-12142, 30435}, {-11744, 30592}, {-11342, 30743}, {-10939, 30889}, {-10534, 31030}, {-10127, 31164}, {-9718, 31294}, {-9307, 31418}, {-8895, 31537},
|
||||
{-8482, 31652}, {-8067, 31759}, {-7650, 31862}, {-7233, 31960}, {-6815, 32051}, {-6393, 32138}, {-5973, 32219}, {-5549, 32294}, {-5127, 32364}, {-4703, 32429},
|
||||
{-4278, 32487}, {-3852, 32541}, {-3426, 32588}, {-2999, 32630}, {-2572, 32667}, {-2144, 32698}, {-1716, 32724}, {-1287, 32742}, {-860, 32757}, {-430, 32766},
|
||||
{0, 32767}, {429, 32766}, {858, 32757}, {1287, 32743}, {1715, 32724}, {2143, 32698}, {2570, 32667}, {2998, 32631}, {3425, 32588}, {3851, 32541},
|
||||
{4277, 32488}, {4701, 32429}, {5125, 32364}, {5548, 32295}, {5971, 32219}, {6393, 32138}, {6813, 32051}, {7231, 31960}, {7650, 31863}, {8067, 31760},
|
||||
{8481, 31652}, {8895, 31539}, {9306, 31419}, {9716, 31294}, {10126, 31165}, {10532, 31030}, {10937, 30889}, {11340, 30743}, {11741, 30592}, {12141, 30436},
|
||||
{12540, 30274}, {12935, 30107}, {13328, 29936}, {13718, 29758}, {14107, 29577}, {14493, 29390}, {14875, 29197}, {15257, 29000}, {15635, 28797}, {16010, 28590},
|
||||
{16384, 28379}, {16753, 28162}, {17119, 27940}, {17484, 27714}, {17845, 27482}, {18205, 27246}, {18560, 27006}, {18911, 26760}, {19260, 26510}, {19606, 26257},
|
||||
{19947, 25997}, {20286, 25734}, {20621, 25466}, {20952, 25194}, {21281, 24918}, {21605, 24637}, {21926, 24353}, {22242, 24063}, {22555, 23770}, {22865, 23473},
|
||||
{23171, 23171}, {23472, 22866}, {23769, 22557}, {24063, 22244}, {24352, 21927}, {24636, 21606}, {24917, 21282}, {25194, 20954}, {25465, 20622}, {25733, 20288},
|
||||
{25997, 19949}, {26255, 19607}, {26509, 19261}, {26760, 18914}, {27004, 18561}, {27246, 18205}, {27481, 17846}, {27713, 17485}, {27940, 17122}, {28162, 16755},
|
||||
{28378, 16385}, {28590, 16012}, {28797, 15636}, {28999, 15258}, {29197, 14878}, {29389, 14494}, {29576, 14108}, {29757, 13720}, {29934, 13329}, {30107, 12937},
|
||||
{30274, 12540}, {30435, 12142}, {30592, 11744}, {30743, 11342}, {30889, 10939}, {31030, 10534}, {31164, 10127}, {31294, 9718}, {31418, 9307}, {31537, 8895},
|
||||
{31652, 8482}, {31759, 8067}, {31862, 7650}, {31960, 7233}, {32051, 6815}, {32138, 6393}, {32219, 5973}, {32294, 5549}, {32364, 5127}, {32429, 4703},
|
||||
{32487, 4278}, {32541, 3852}, {32588, 3426}, {32630, 2999}, {32667, 2572}, {32698, 2144}, {32724, 1716}, {32742, 1287}, {32757, 860}, {32766, 430},
|
||||
};
|
||||
|
||||
static const int16_t fft_bitrev480[480] = {
|
||||
0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, 16, 112, 208, 304, 400, 48, 144, 240, 336, 432,
|
||||
80, 176, 272, 368, 464, 24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, 4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, 12, 108, 204, 300, 396,
|
||||
44, 140, 236, 332, 428, 76, 172, 268, 364, 460, 20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, 28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476,
|
||||
1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, 9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, 17, 113, 209, 305, 401, 49, 145, 241, 337, 433,
|
||||
81, 177, 273, 369, 465, 25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, 5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, 13, 109, 205, 301, 397,
|
||||
45, 141, 237, 333, 429, 77, 173, 269, 365, 461, 21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, 29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477,
|
||||
2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, 10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, 18, 114, 210, 306, 402, 50, 146, 242, 338, 434,
|
||||
82, 178, 274, 370, 466, 26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, 6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, 14, 110, 206, 302, 398,
|
||||
46, 142, 238, 334, 430, 78, 174, 270, 366, 462, 22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, 30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478,
|
||||
3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, 11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, 19, 115, 211, 307, 403, 51, 147, 243, 339, 435,
|
||||
83, 179, 275, 371, 467, 27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, 7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, 15, 111, 207, 303, 399,
|
||||
47, 143, 239, 335, 431, 79, 175, 271, 367, 463, 23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, 31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479,
|
||||
};
|
||||
|
||||
static const int16_t fft_bitrev240[240] = {
|
||||
0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, 8, 56, 104, 152, 200, 24, 72, 120, 168, 216,
|
||||
40, 88, 136, 184, 232, 12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, 1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, 5, 53, 101, 149, 197,
|
||||
21, 69, 117, 165, 213, 37, 85, 133, 181, 229, 9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, 13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237,
|
||||
2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, 6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, 10, 58, 106, 154, 202, 26, 74, 122, 170, 218,
|
||||
42, 90, 138, 186, 234, 14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, 3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, 7, 55, 103, 151, 199,
|
||||
23, 71, 119, 167, 215, 39, 87, 135, 183, 231, 11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, 15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239,
|
||||
};
|
||||
|
||||
static const int16_t fft_bitrev120[120] = {
|
||||
0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, 1, 25, 49, 73, 97, 9, 33, 57, 81, 105,
|
||||
17, 41, 65, 89, 113, 5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, 2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, 6, 30, 54, 78, 102,
|
||||
14, 38, 62, 86, 110, 22, 46, 70, 94, 118, 3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, 7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119,
|
||||
};
|
||||
|
||||
static const int16_t fft_bitrev60[60] = {
|
||||
0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, 1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57,
|
||||
2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, 3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59,
|
||||
};
|
||||
|
||||
static const uint8_t LOG2_FRAC_TABLE[24] = {0, 8, 13, 16, 19, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 32, 33, 34, 34, 35, 36, 36, 37, 37};
|
||||
|
||||
/* Mean energy in each band quantized in Q4 */
|
||||
static const signed char eMeans[25] = {103, 100, 92, 85, 81, 77, 72, 70, 78, 75, 73, 71, 78, 74, 69, 72, 70, 74, 76, 71, 60, 60, 60, 60, 60};
|
||||
|
||||
/* prediction coefficients: 0.9, 0.8, 0.65, 0.5 */
|
||||
static const int16_t pred_coef[4] = {29440, 26112, 21248, 16384};
|
||||
static const int16_t beta_coef[4] = {30147, 22282, 12124, 6554};
|
||||
static const int16_t beta_intra = 4915;
|
||||
|
||||
/*Parameters of the Laplace-like probability models used for the coarse energy. There is one pair of parameters for
|
||||
each frame size, prediction type (inter/intra), and band number. The first number of each pair is the probability
|
||||
of 0, and the second is the decay rate, both in Q8 precision.*/
|
||||
static const uint8_t e_prob_model[4][2][42] = {
|
||||
/*120 sample frames.*/
|
||||
{/*Inter*/
|
||||
{72, 127, 65, 129, 66, 128, 65, 128, 64, 128, 62, 128, 64, 128, 64, 128, 92, 78, 92, 79, 92, 78, 90, 79, 116, 41, 115, 40, 114, 40, 132, 26, 132, 26, 145, 17, 161, 12, 176, 10, 177, 11},
|
||||
/*Intra*/
|
||||
{24, 179, 48, 138, 54, 135, 54, 132, 53, 134, 56, 133, 55, 132, 55, 132, 61, 114, 70, 96, 74, 88, 75, 88, 87, 74, 89, 66, 91, 67, 100, 59, 108, 50, 120, 40, 122, 37, 97, 43, 78, 50}},
|
||||
/*240 sample frames.*/
|
||||
{/*Inter*/
|
||||
{83, 78, 84, 81, 88, 75, 86, 74, 87, 71, 90, 73, 93, 74, 93, 74, 109, 40, 114, 36, 117, 34, 117, 34, 143, 17, 145, 18, 146, 19, 162, 12, 165, 10, 178, 7, 189, 6, 190, 8, 177, 9},
|
||||
/*Intra*/
|
||||
{23, 178, 54, 115, 63, 102, 66, 98, 69, 99, 74, 89, 71, 91, 73, 91, 78, 89, 86, 80, 92, 66, 93, 64, 102, 59, 103, 60, 104, 60, 117, 52, 123, 44, 138, 35, 133, 31, 97, 38, 77, 45}},
|
||||
/*480 sample frames.*/
|
||||
{/*Inter*/
|
||||
{61, 90, 93, 60, 105, 42, 107, 41, 110, 45, 116, 38, 113, 38, 112, 38, 124, 26, 132, 27, 136, 19, 140, 20, 155, 14, 159, 16, 158, 18, 170, 13, 177, 10, 187, 8, 192, 6, 175, 9, 159, 10},
|
||||
/*Intra*/
|
||||
{21, 178, 59, 110, 71, 86, 75, 85, 84, 83, 91, 66, 88, 73, 87, 72, 92, 75, 98, 72, 105, 58, 107, 54, 115, 52, 114, 55, 112, 56, 129, 51, 132, 40, 150, 33, 140, 29, 98, 35, 77, 42}},
|
||||
/*960 sample frames.*/
|
||||
{/*Inter*/
|
||||
{42, 121, 96, 66, 108, 43, 111, 40, 117, 44, 123, 32, 120, 36, 119, 33, 127, 33, 134, 34, 139, 21, 147, 23, 152, 20, 158, 25, 154, 26, 166, 21, 173, 16, 184, 13, 184, 10, 150, 13, 139, 15},
|
||||
/*Intra*/
|
||||
{22, 178, 63, 114, 74, 82, 84, 83, 92, 82, 103, 62, 96, 72, 96, 67, 101, 73, 107, 72, 113, 55, 118, 52, 125, 52, 118, 52, 117, 55, 135, 49, 137, 39, 157, 32, 145, 29, 97, 33, 77, 40}}};
|
||||
|
||||
static const uint8_t small_energy_icdf[3] = {2, 1, 0};
|
||||
|
||||
/* TF change table. Positive values mean better frequency resolution (longer effective window), whereas negative values mean better time resolution (shorter effective window).
|
||||
The second index is computed as: 4*isTransient + 2*tf_select + per_band_flag */
|
||||
static const int8_t tf_select_table[4][8] = {
|
||||
/*isTransient=0 isTransient=1 */
|
||||
{0, -1, 0, -1, 0, -1, 0, -1}, /* 2.5 ms */
|
||||
{0, -1, 0, -2, 1, 0, 1, -1}, /* 5 ms */
|
||||
{0, -2, 0, -3, 2, 0, 1, -1}, /* 10 ms */
|
||||
{0, -2, 0, -3, 3, 0, 1, -1}, /* 20 ms */
|
||||
};
|
||||
|
||||
/* Indexing table for converting from natural Hadamard to ordery Hadamarangedec-> This is essentially a bit-reversed Gray,
|
||||
on top of which we've added an inversion of the order because we want the DC at the end rather than the beginning.
|
||||
The lines are for N=2, 4, 8, 16 */
|
||||
static const int32_t ordery_table[30] = {
|
||||
1, 0, 3, 0, 2, 1, 7, 0, 4, 3, 6, 1, 5, 2, 15, 0, 8, 7, 12, 3, 11, 4, 14, 1, 9, 6, 13, 2, 10, 5,
|
||||
};
|
||||
|
||||
static const int32_t second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2};
|
||||
|
||||
static const uint8_t trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0};
|
||||
/* Probs: NONE: 21.875%, LIGHT: 6.25%, NORMAL: 65.625%, AGGRESSIVE: 6.25% */
|
||||
static const uint8_t spread_icdf[4] = {25, 23, 2, 0};
|
||||
|
||||
static const uint8_t tapset_icdf[3] = {2, 1, 0};
|
||||
|
||||
static const uint32_t row_idx[15] = {0, 176, 351, 525, 698, 870, 1041, 1131, 1178, 1207, 1226, 1240, 1248, 1254, 1257};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,228 +0,0 @@
|
||||
// based on Xiph.Org Foundation celt decoder
|
||||
#pragma once
|
||||
|
||||
#include "../Audio.h"
|
||||
#include "../psram_unique_ptr.hpp"
|
||||
#include "celt.h"
|
||||
#include "range_decoder.h"
|
||||
#include "silk.h"
|
||||
#include <vector>
|
||||
|
||||
#define ANSI_ESC_RESET "\033[0m"
|
||||
#define ANSI_ESC_BLACK "\033[30m"
|
||||
#define ANSI_ESC_RED "\033[31m"
|
||||
#define ANSI_ESC_GREEN "\033[32m"
|
||||
#define ANSI_ESC_YELLOW "\033[33m"
|
||||
#define ANSI_ESC_BLUE "\033[34m"
|
||||
#define ANSI_ESC_MAGENTA "\033[35m"
|
||||
#define ANSI_ESC_CYAN "\033[36m"
|
||||
#define ANSI_ESC_WHITE "\033[37m"
|
||||
|
||||
class OpusDecoder : public Decoder {
|
||||
|
||||
public:
|
||||
OpusDecoder(Audio& audioRef)
|
||||
: Decoder(audioRef), rangedec(std::make_unique<RangeDecoder>()), silkdec(std::make_unique<SilkDecoder>(*rangedec)), celtdec(std::make_unique<CeltDecoder>(*rangedec)), audio(audioRef) {}
|
||||
~OpusDecoder() { reset(); }
|
||||
bool init() override;
|
||||
void clear() override;
|
||||
void reset() override;
|
||||
bool isValid() override;
|
||||
int32_t findSyncWord(uint8_t* buf, int32_t nBytes) override;
|
||||
uint8_t getChannels() override;
|
||||
uint32_t getSampleRate() override;
|
||||
uint32_t getOutputSamples();
|
||||
uint8_t getBitsPerSample() override;
|
||||
uint32_t getBitRate() override;
|
||||
uint32_t getAudioDataStart() override;
|
||||
uint32_t getAudioFileDuration() override;
|
||||
const char* getStreamTitle() override;
|
||||
const char* whoIsIt() override;
|
||||
int32_t decode(uint8_t* inbuf, int32_t* bytesLeft, int32_t* outbuf) override;
|
||||
void setRawBlockParams(uint8_t channels, uint32_t sampleRate, uint8_t BPS, uint32_t tsis, uint32_t AuDaLength) override;
|
||||
std::vector<uint32_t> getMetadataBlockPicture() override;
|
||||
const char* arg1() override;
|
||||
const char* arg2() override;
|
||||
virtual int32_t val1() override;
|
||||
virtual int32_t val2() override;
|
||||
|
||||
std::unique_ptr<RangeDecoder> rangedec;
|
||||
std::unique_ptr<SilkDecoder> silkdec;
|
||||
std::unique_ptr<CeltDecoder> celtdec;
|
||||
|
||||
enum : int8_t { OPUS_END = 120, OPUS_CONTINUE = 10, OPUS_PARSE_OGG_DONE = 100, OPUS_NONE = 0, OPUS_ERR = -1 };
|
||||
|
||||
private:
|
||||
Audio& audio;
|
||||
typedef struct _ofp2 {
|
||||
uint16_t firstFrameLength{};
|
||||
uint16_t secondFrameLength{};
|
||||
|
||||
void reset() {
|
||||
*this = _ofp2{}; // sauber neu initialisieren
|
||||
}
|
||||
} ofp2_t;
|
||||
|
||||
typedef struct _ofp3 { // opus_FramePacking_Code
|
||||
bool firstCall{};
|
||||
bool v{}; // VBR indicator
|
||||
bool p{}; // padding exists
|
||||
int16_t fs{}; // frame size
|
||||
uint8_t M{}; // nr of frames
|
||||
int32_t spf{}; // samples per frame
|
||||
int32_t paddingLength{};
|
||||
uint16_t c1fs{};
|
||||
uint16_t vfs[48]{}; // variable frame size
|
||||
uint32_t idx{};
|
||||
|
||||
void reset() {
|
||||
*this = _ofp3{}; // sauber neu initialisieren
|
||||
}
|
||||
} ofp3_t;
|
||||
|
||||
typedef struct _odp3 {
|
||||
int8_t configNr{};
|
||||
uint16_t samplesPerFrame{};
|
||||
|
||||
void reset() {
|
||||
// Default-initialize alles neu (inklusive Array)
|
||||
*this = _odp3{};
|
||||
}
|
||||
|
||||
} odp3_t;
|
||||
|
||||
#define CELT_SET_END_BAND_REQUEST 10012
|
||||
#define CELT_SET_CHANNELS_REQUEST 10008
|
||||
#define CELT_SET_START_BAND_REQUEST 10010
|
||||
#define CELT_SET_SIGNALLING_REQUEST 10016
|
||||
#define CELT_GET_AND_CLEAR_ERROR_REQUEST 10007
|
||||
#define CELT_GET_MODE_REQUEST 10015
|
||||
|
||||
enum { OPUS_BANDWIDTH_NARROWBAND = 1101, OPUS_BANDWIDTH_MEDIUMBAND = 1102, OPUS_BANDWIDTH_WIDEBAND = 1103, OPUS_BANDWIDTH_SUPERWIDEBAND = 1104, OPUS_BANDWIDTH_FULLBAND = 1105 };
|
||||
enum ParseResult { OPUS_COMMENT_INVALID = -1, OPUS_COMMENT_NEED_MORE = 1, OPUS_COMMENT_DONE = 2 };
|
||||
|
||||
uint8_t m_opusChannels = 0;
|
||||
uint8_t m_opusCountCode = 0;
|
||||
uint8_t m_opusPageNr = 0;
|
||||
uint8_t m_frameCount = 0;
|
||||
uint8_t m_opusSegmentTableSize = 0;
|
||||
uint16_t m_mode = 0;
|
||||
uint16_t m_opusOggHeaderSize = 0;
|
||||
uint16_t m_bandWidth = 0;
|
||||
uint16_t m_internalSampleRate = 0;
|
||||
uint16_t m_endband = 0;
|
||||
uint32_t m_opusSamplerate = 0;
|
||||
uint32_t m_opusSegmentLength = 0;
|
||||
uint32_t m_opusCurrentFilePos = 0;
|
||||
uint32_t m_opusAudioDataStart = 0;
|
||||
uint32_t m_opusBlockPicPos = 0;
|
||||
uint32_t m_opusBlockLen = 0;
|
||||
bool m_f_opusParseOgg = false;
|
||||
bool m_f_newSteamTitle = false; // streamTitle
|
||||
bool m_f_opusNewMetadataBlockPicture = false; // new metadata block picture
|
||||
bool m_f_opusStereoFlag = false;
|
||||
bool m_f_continuedPage = false;
|
||||
bool m_f_firstPage = false;
|
||||
bool m_f_lastPage = false;
|
||||
bool m_f_nextChunk = false;
|
||||
bool m_isValid = false;
|
||||
int8_t m_opusError = 0;
|
||||
int16_t m_opusSegmentTableRdPtr = -1;
|
||||
int16_t m_prev_mode = 0;
|
||||
int32_t m_opusValidSamples = 0;
|
||||
int32_t m_opusBlockPicLen = 0;
|
||||
int32_t m_blockPicLenUntilFrameEnd = 0;
|
||||
int32_t m_opusRemainBlockPicLen = 0;
|
||||
int32_t m_opusCommentBlockSize = 0;
|
||||
float m_opusCompressionRatio = 0;
|
||||
ps_ptr<int16_t> m_out16;
|
||||
|
||||
struct picture_segment_t {
|
||||
uint32_t start_page_index{};
|
||||
uint32_t start_offset{};
|
||||
uint32_t end_page_index{};
|
||||
uint32_t end_offset{};
|
||||
bool in_progress{};
|
||||
};
|
||||
|
||||
typedef struct _comment {
|
||||
uint32_t pointer{};
|
||||
uint32_t list_length{};
|
||||
bool oob{}; // out of bounds (block overflow)
|
||||
uint32_t save_len{};
|
||||
uint32_t comment_size{};
|
||||
uint32_t start_pos{}; // comment start file position
|
||||
uint32_t end_pos{}; // comment end file position
|
||||
uint8_t length_bytes[4]{}; // 🆕 Addition for split 4-byte length fields
|
||||
uint8_t partial_length{}; // how many of the 4 bytes have already been read
|
||||
uint32_t bytes_available{};
|
||||
|
||||
ps_ptr<char> stream_title{};
|
||||
ps_ptr<char> comment_content{};
|
||||
std::vector<uint32_t> item_vec;
|
||||
std::vector<uint32_t> pic_vec;
|
||||
|
||||
void reset() { *this = _comment{}; }
|
||||
} comment_t;
|
||||
comment_t m_comment;
|
||||
|
||||
ps_ptr<uint16_t> m_opusSegmentTable;
|
||||
|
||||
ofp2_t m_ofp2; // used in opus_FramePacking_Code2
|
||||
ofp3_t m_ofp3; // used in opus_FramePacking_Code3
|
||||
odp3_t m_odp3; // used in opusDecodePage3
|
||||
|
||||
std::vector<uint32_t> m_opusBlockPicItem;
|
||||
|
||||
void OPUSsetDefaults();
|
||||
int32_t opusDecodePage0(uint8_t* inbuf, int32_t* bytesLeft, uint32_t segmentLength);
|
||||
int32_t opusDecodePage3(uint8_t* inbuf, int32_t* bytesLeft, uint32_t segmentLength, int16_t* outbuf);
|
||||
int8_t opus_FramePacking_Code0(uint8_t* inbuf, int32_t* bytesLeft, int16_t* outbuf, int32_t packetLen, uint16_t samplesPerFrame);
|
||||
int8_t opus_FramePacking_Code1(uint8_t* inbuf, int32_t* bytesLeft, int16_t* outbuf, int32_t packetLen, uint16_t samplesPerFrame, uint8_t* frameCount);
|
||||
int8_t opus_FramePacking_Code2(uint8_t* inbuf, int32_t* bytesLeft, int16_t* outbuf, int32_t packetLen, uint16_t samplesPerFrame, uint8_t* frameCount);
|
||||
int8_t opus_FramePacking_Code3(uint8_t* inbuf, int32_t* bytesLeft, int16_t* outbuf, int32_t packetLen, uint16_t samplesPerFrame, uint8_t* frameCount);
|
||||
int32_t parseOGG(uint8_t* inbuf, int32_t* bytesLeft);
|
||||
int32_t parseOpusHead(uint8_t* inbuf, int32_t nBytes);
|
||||
int32_t parseOpusComment(uint8_t* inbuf, int32_t nBytes, uint32_t current_file_pos);
|
||||
int8_t parseOpusTOC(uint8_t TOC_Byte);
|
||||
int32_t opus_packet_get_samples_per_frame(const uint8_t* data, int32_t Fs);
|
||||
int32_t opus_decode_frame(uint8_t* inbuf, int16_t* outbuf, int32_t packetLen, uint16_t samplesPerFrame);
|
||||
|
||||
// some helper functions
|
||||
int32_t OPUS_specialIndexOf(uint8_t* base, const char* str, int32_t baselen, bool exact = false);
|
||||
int32_t OPUS_specialIndexOf_icase(uint8_t* base, const char* str, int32_t baselen, bool exact = false);
|
||||
uint32_t little_endian(uint8_t* data);
|
||||
enum { MODE_NONE = 0, MODE_SILK_ONLY = 1000, MODE_HYBRID = 1001, MODE_CELT_ONLY = 1002 };
|
||||
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
// Macro for comfortable calls
|
||||
#define OPUS_LOG_ERROR(fmt, ...) Audio::AUDIO_LOG_IMPL(1, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define OPUS_LOG_WARN(fmt, ...) Audio::AUDIO_LOG_IMPL(2, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define OPUS_LOG_INFO(fmt, ...) Audio::AUDIO_LOG_IMPL(3, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define OPUS_LOG_DEBUG(fmt, ...) Audio::AUDIO_LOG_IMPL(4, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define OPUS_LOG_VERBOSE(fmt, ...) Audio::AUDIO_LOG_IMPL(5, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
// Macro for time measuring
|
||||
// PROFILE_START(decodeNative);
|
||||
// ret = decodeNative(inbuf, bytesLeft, outbuf);
|
||||
// PROFILE_END_N(decodeNative, 1000);
|
||||
|
||||
#define PROFILE_START(name) \
|
||||
static uint64_t _prof_##name##_start = 0; \
|
||||
_prof_##name##_start = esp_timer_get_time()
|
||||
|
||||
#define PROFILE_END_N(name, N) \
|
||||
do { \
|
||||
static uint64_t _prof_##name##_sum = 0; \
|
||||
static uint32_t _prof_##name##_count = 0; \
|
||||
uint64_t _prof_##name##_elapsed = esp_timer_get_time() - _prof_##name##_start; \
|
||||
_prof_##name##_sum += _prof_##name##_elapsed; \
|
||||
_prof_##name##_count++; \
|
||||
if (_prof_##name##_count >= (N)) { \
|
||||
printf("%-20s avg: %.2f µs over %u runs\n", #name, (double)_prof_##name##_sum / _prof_##name##_count, _prof_##name##_count); \
|
||||
_prof_##name##_sum = 0; \
|
||||
_prof_##name##_count = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
@@ -1,223 +0,0 @@
|
||||
#include "range_decoder.h"
|
||||
|
||||
RangeDecoder::RangeDecoder() : m_buf(nullptr) {}
|
||||
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
/* This is a faster version of ec_tell_frac() that takes advantage of the low (1/8 bit) resolution to use just a linear function followed by a lookup to determine the exact transition thresholds. */
|
||||
uint32_t RangeDecoder::tell_frac() {
|
||||
const uint32_t correction[8] = {35733, 38967, 42495, 46340, 50535, 55109, 60097, 65535};
|
||||
uint32_t nbits;
|
||||
uint32_t r;
|
||||
int32_t l;
|
||||
uint32_t b;
|
||||
nbits = m_nbits_total << EC_BITRES;
|
||||
l = EC_ILOG(m_rng);
|
||||
r = m_rng >> (l - 16);
|
||||
b = (r >> 12) - 8;
|
||||
b += r > correction[b];
|
||||
l = (l << 3) + b;
|
||||
return nbits - l;
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t RangeDecoder::read_byte() { return m_offs < m_storage ? m_buf[m_offs++] : 0; }
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t RangeDecoder::read_byte_from_end() {
|
||||
return m_end_offs < m_storage ? m_buf[m_storage - ++(m_end_offs)] : 0;
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
/*Normalizes the contents of val and rng so that rng lies entirely in the high-order symbol.*/
|
||||
void RangeDecoder::dec_normalize() {
|
||||
/*If the range is too small, rescale it and input some bits.*/
|
||||
while (m_rng <= EC_CODE_BOT) {
|
||||
int32_t sym;
|
||||
m_nbits_total += EC_SYM_BITS;
|
||||
m_rng <<= EC_SYM_BITS;
|
||||
/*Use up the remaining bits from our last symbol.*/
|
||||
sym = m_rem;
|
||||
/*Read the next value from the input.*/
|
||||
m_rem = read_byte();
|
||||
/*Take the rest of the bits we need from this new symbol.*/
|
||||
sym = (sym << EC_SYM_BITS | m_rem) >> (EC_SYM_BITS - EC_CODE_EXTRA);
|
||||
/*And subtract them from val, capped to be less than EC_CODE_TOP.*/
|
||||
m_val = ((m_val << EC_SYM_BITS) + (EC_SYM_MAX & ~sym)) & ((EC_CODE_TOP) - 1);
|
||||
}
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
void RangeDecoder::dec_init(uint8_t *_buf, uint32_t _storage) {
|
||||
|
||||
m_buf = _buf;
|
||||
m_storage = _storage;
|
||||
m_end_offs = 0;
|
||||
m_end_window = 0;
|
||||
m_nend_bits = 0;
|
||||
m_nbits_total = EC_CODE_BITS + 1 - ((EC_CODE_BITS - EC_CODE_EXTRA) / EC_SYM_BITS) * EC_SYM_BITS;
|
||||
m_offs = 0;
|
||||
m_rng = 1U << EC_CODE_EXTRA;
|
||||
m_rem = read_byte();
|
||||
m_val = m_rng - 1 - (m_rem >> (EC_SYM_BITS - EC_CODE_EXTRA));
|
||||
m_error = 0;
|
||||
/*Normalize the interval.*/
|
||||
dec_normalize();
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t RangeDecoder::decode(uint32_t _ft) {
|
||||
uint32_t s;
|
||||
m_ext = m_rng / _ft;
|
||||
s = (uint32_t)(m_val / m_ext);
|
||||
return _ft - EC_MINI(s + 1, _ft);
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t RangeDecoder::decode_bin(uint32_t _bits) {
|
||||
uint32_t s;
|
||||
m_ext = m_rng >> _bits;
|
||||
s = (uint32_t)(m_val / m_ext);
|
||||
return (1U << _bits) - EC_MINI(s + 1U, 1U << _bits);
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
void RangeDecoder::dec_update(uint32_t _fl, uint32_t _fh, uint32_t _ft) {
|
||||
uint32_t s;
|
||||
s = m_ext * (_ft - _fh);
|
||||
m_val -= s;
|
||||
|
||||
if(_fl > 0){
|
||||
m_rng = m_ext * (_fh - _fl);
|
||||
}
|
||||
else{
|
||||
m_rng = m_rng - s;
|
||||
}
|
||||
dec_normalize();
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
/*The probability of having a "one" is 1/(1<<_logp).*/
|
||||
int32_t RangeDecoder::dec_bit_logp( uint32_t _logp) {
|
||||
uint32_t r;
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
int32_t ret;
|
||||
r = m_rng;
|
||||
d = m_val;
|
||||
s = r >> _logp;
|
||||
ret = d < s;
|
||||
if (!ret) m_val = d - s;
|
||||
m_rng = ret ? s : r - s;
|
||||
dec_normalize();
|
||||
return ret;
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t RangeDecoder::dec_icdf(const uint8_t *_icdf, uint32_t _ftb) {
|
||||
uint32_t r;
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
uint32_t t;
|
||||
int32_t ret;
|
||||
s = m_rng;
|
||||
d = m_val;
|
||||
r = s >> _ftb;
|
||||
ret = -1;
|
||||
do {
|
||||
t = s;
|
||||
s = r * _icdf[++ret];
|
||||
} while (d < s);
|
||||
m_val = d - s;
|
||||
m_rng = t - s;
|
||||
dec_normalize();
|
||||
return ret;
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t RangeDecoder::dec_uint(uint32_t _ft) {
|
||||
uint32_t ft;
|
||||
uint32_t s;
|
||||
int32_t ftb;
|
||||
/*In order to optimize EC_ILOG(), it is undefined for the value 0.*/
|
||||
assert(_ft > 1);
|
||||
_ft--;
|
||||
ftb = EC_ILOG(_ft);
|
||||
if (ftb > EC_UINT_BITS) {
|
||||
uint32_t t;
|
||||
ftb -= EC_UINT_BITS;
|
||||
ft = (uint32_t)(_ft >> ftb) + 1;
|
||||
s = decode(ft);
|
||||
dec_update(s, s + 1, ft);
|
||||
t = (uint32_t)s << ftb | dec_bits(ftb);
|
||||
if (t <= _ft) return t;
|
||||
m_error = 1;
|
||||
return _ft;
|
||||
} else {
|
||||
_ft++;
|
||||
s = decode((uint32_t)_ft);
|
||||
dec_update(s, s + 1, (uint32_t)_ft);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
uint32_t RangeDecoder::dec_bits(uint32_t _bits) {
|
||||
uint32_t window;
|
||||
int32_t available;
|
||||
uint32_t ret;
|
||||
window = m_end_window;
|
||||
available = m_nend_bits;
|
||||
if ((uint32_t)available < _bits) {
|
||||
do {
|
||||
window |= (uint32_t)read_byte_from_end() << available;
|
||||
available += EC_SYM_BITS;
|
||||
} while (available <= EC_WINDOW_SIZE - EC_SYM_BITS);
|
||||
}
|
||||
ret = (uint32_t)window & (((uint32_t)1 << _bits) - 1U);
|
||||
window >>= _bits;
|
||||
available -= _bits;
|
||||
m_end_window = window;
|
||||
m_nend_bits = available;
|
||||
m_nbits_total += _bits;
|
||||
return ret;
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t RangeDecoder::tell(){return m_nbits_total-EC_ILOG(m_rng);}
|
||||
void RangeDecoder::add_nbits_total(int32_t nbits_total){m_nbits_total += nbits_total;}
|
||||
uint32_t RangeDecoder::get_storage(){return m_storage;}
|
||||
int32_t RangeDecoder::get_error(){return m_error;}
|
||||
uint32_t RangeDecoder::get_rng(){return m_rng;}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
/* When called, decay is positive and at most 11456. */
|
||||
uint32_t RangeDecoder::laplace_get_freq1(uint32_t fs0, int32_t decay) {
|
||||
uint32_t ft;
|
||||
ft = 32768 - LAPLACE_MINP * (2 * LAPLACE_NMIN) - fs0;
|
||||
return ft * (int32_t)(16384 - decay) >> 15;
|
||||
}
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
int32_t RangeDecoder::laplace_decode(uint32_t fs, int32_t decay) {
|
||||
int32_t val = 0;
|
||||
uint32_t fl;
|
||||
uint32_t fm;
|
||||
fm = decode_bin(15);
|
||||
fl = 0;
|
||||
if (fm >= fs) {
|
||||
val++;
|
||||
fl = fs;
|
||||
fs = laplace_get_freq1(fs, decay) + LAPLACE_MINP;
|
||||
/* Search the decaying part of the PDF.*/
|
||||
while (fs > LAPLACE_MINP && fm >= fl + 2 * fs) {
|
||||
fs *= 2;
|
||||
fl += fs;
|
||||
fs = ((fs - 2 * LAPLACE_MINP) * (int32_t)decay) >> 15;
|
||||
fs += LAPLACE_MINP;
|
||||
val++;
|
||||
}
|
||||
/* Everything beyond that has probability LAPLACE_MINP. */
|
||||
if (fs <= LAPLACE_MINP) {
|
||||
int32_t di;
|
||||
di = (fm - fl) >> (LAPLACE_LOG_MINP + 1);
|
||||
val += di;
|
||||
fl += 2 * di * LAPLACE_MINP;
|
||||
}
|
||||
if (fm < fl + fs)
|
||||
val = -val;
|
||||
else
|
||||
fl += fs;
|
||||
}
|
||||
assert(fl < 32768);
|
||||
assert(fs > 0);
|
||||
assert(fl <= fm);
|
||||
assert(fm < min((uint32_t)(fl + fs), (uint32_t)32768));
|
||||
dec_update(fl, min((uint32_t)(fl + fs), (uint32_t)32768), (uint32_t)32768);
|
||||
return val;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
class RangeDecoder {
|
||||
public:
|
||||
RangeDecoder();
|
||||
~RangeDecoder(){}
|
||||
void dec_init(uint8_t *_buf, uint32_t _storage);
|
||||
uint32_t get_storage();
|
||||
uint32_t dec_bits(uint32_t _bits);
|
||||
uint32_t dec_uint(uint32_t _ft);
|
||||
uint32_t decode(uint32_t _ft);
|
||||
uint32_t decode_bin(uint32_t _bits);
|
||||
void dec_update(uint32_t _fl, uint32_t _fh, uint32_t _ft);
|
||||
int32_t dec_bit_logp( uint32_t _logp);
|
||||
uint32_t tell_frac();
|
||||
int32_t dec_icdf(const uint8_t *_icdf, uint32_t _ftb);
|
||||
int32_t tell();
|
||||
void add_nbits_total(int32_t nbits_total);
|
||||
int32_t get_error();
|
||||
uint32_t get_rng();
|
||||
int32_t laplace_decode(uint32_t fs, int32_t decay);
|
||||
|
||||
private:
|
||||
#define EC_WINDOW_SIZE ((int32_t)sizeof(uint32_t)*CHAR_BIT)
|
||||
#define EC_UINT_BITS (8)
|
||||
#define EC_MINI(_a,_b) ((_a)+(((_b)-(_a))&-((_b)<(_a))))
|
||||
#define EC_CLZ0s ((int32_t)sizeof(uint32_t)*CHAR_BIT)
|
||||
#define EC_CLZ(_x) (__builtin_clz(_x))
|
||||
#define EC_ILOG(_x) (EC_CLZ0s-EC_CLZ(_x))
|
||||
#define EC_BITRES 3
|
||||
|
||||
#define EC_SYM_BITS 8
|
||||
#define EC_CODE_BITS 32
|
||||
#define EC_SYM_MAX ((1U << EC_SYM_BITS) - 1)
|
||||
#define EC_CODE_TOP 1U << (EC_CODE_BITS - 1)
|
||||
#define EC_CODE_BOT EC_CODE_TOP >> EC_SYM_BITS
|
||||
#define EC_CODE_EXTRA ((EC_CODE_BITS-2) % EC_SYM_BITS + 1)
|
||||
|
||||
#define LAPLACE_LOG_MINP (0)
|
||||
#define LAPLACE_MINP (1<<LAPLACE_LOG_MINP)
|
||||
#define LAPLACE_NMIN (16)
|
||||
|
||||
uint8_t* m_buf = nullptr; /*Buffered input/output */
|
||||
uint32_t m_storage = 0; /*The size of the buffer.*/
|
||||
uint32_t m_end_offs = 0; /*The offset at which the last byte containing raw bits was read/written.*/
|
||||
uint32_t m_end_window = 0; /*Bits that will be read from/written at the end.*/
|
||||
int32_t m_nend_bits = 0; /*Number of valid bits in end_window.*/
|
||||
int32_t m_nbits_total = 0;
|
||||
uint32_t m_offs = 0; /*The offset at which the next range coder byte will be read/written.*/
|
||||
uint32_t m_rng = 0; /*The number of values in the current range.*/
|
||||
uint32_t m_val = 0;
|
||||
uint32_t m_ext = 0;
|
||||
int32_t m_rem = 0; /*A buffered input/output symbol, awaiting carry propagation.*/
|
||||
int32_t m_error = 0; /*Nonzero if an error occurred.*/
|
||||
|
||||
|
||||
int32_t read_byte();
|
||||
int32_t read_byte_from_end();
|
||||
void dec_normalize();
|
||||
uint32_t laplace_get_freq1(uint32_t fs0, int32_t decay);
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,312 +0,0 @@
|
||||
/***********************************************************************
|
||||
Copyright (c) 2006-2011, Skype Limited. All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
***********************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "../psram_unique_ptr.hpp"
|
||||
#include "opus_decoder.h"
|
||||
#include "silk_defines.h"
|
||||
#include "silk_tables.h"
|
||||
#include "silk_structs.h"
|
||||
#include "range_decoder.h"
|
||||
|
||||
extern const int16_t silk_LSFCosTab_FIX_Q12[LSF_COS_TAB_SZ_FIX + 1];
|
||||
extern const int16_t silk_stereo_pred_quant_Q13[STEREO_QUANT_TAB_SIZE];
|
||||
extern const uint8_t silk_stereo_pred_joint_iCDF[25];
|
||||
extern const uint8_t silk_stereo_only_code_mid_iCDF[2];
|
||||
extern const uint8_t silk_LBRR_flags_2_iCDF[3];
|
||||
extern const uint8_t silk_LBRR_flags_3_iCDF[7];
|
||||
extern const uint8_t* const silk_LBRR_flags_iCDF_ptr[2];
|
||||
extern const uint8_t silk_lsb_iCDF[2];
|
||||
extern const uint8_t silk_LTPscale_iCDF[3];
|
||||
extern const uint8_t silk_type_offset_VAD_iCDF[4];
|
||||
extern const uint8_t silk_type_offset_no_VAD_iCDF[2];
|
||||
extern const uint8_t silk_NLSF_interpolation_factor_iCDF[5];
|
||||
extern const int16_t silk_Quantization_Offsets_Q10[2][2];
|
||||
extern const int16_t silk_LTPScales_table_Q14[3];
|
||||
extern const uint8_t silk_uniform3_iCDF[3];
|
||||
extern const uint8_t silk_uniform4_iCDF[4];
|
||||
extern const uint8_t silk_uniform5_iCDF[5];
|
||||
extern const uint8_t silk_uniform6_iCDF[6];
|
||||
extern const uint8_t silk_uniform8_iCDF[8];
|
||||
extern const uint8_t silk_NLSF_EXT_iCDF[7];
|
||||
extern const int32_t silk_Transition_LP_B_Q28[TRANSITION_INT_NUM][TRANSITION_NB];
|
||||
extern const int32_t silk_Transition_LP_A_Q28[TRANSITION_INT_NUM][TRANSITION_NA];
|
||||
extern const uint8_t silk_max_pulses_table[4];
|
||||
extern const uint8_t silk_pulses_per_block_iCDF[10][18];
|
||||
extern const uint8_t silk_rate_levels_iCDF[2][9];
|
||||
extern const uint8_t silk_rate_levels_BITS_Q5[2][9];
|
||||
extern const uint8_t silk_shell_code_table0[152];
|
||||
extern const uint8_t silk_shell_code_table1[152];
|
||||
extern const uint8_t silk_shell_code_table2[152];
|
||||
extern const uint8_t silk_shell_code_table3[152];
|
||||
extern const uint8_t silk_shell_code_table_offsets[17];
|
||||
extern const uint8_t silk_sign_iCDF[42];
|
||||
extern const uint8_t silk_NLSF_CB1_NB_MB_Q8[320];
|
||||
extern const int16_t silk_NLSF_CB1_Wght_Q9[320];
|
||||
extern const uint8_t silk_NLSF_CB1_iCDF_NB_MB[64];
|
||||
extern const uint8_t silk_NLSF_CB2_SELECT_NB_MB[160];
|
||||
extern const uint8_t silk_NLSF_CB2_iCDF_NB_MB[72];
|
||||
extern const uint8_t silk_NLSF_CB2_BITS_NB_MB_Q5[72];
|
||||
extern const uint8_t silk_NLSF_PRED_NB_MB_Q8[18];
|
||||
extern const int16_t silk_NLSF_DELTA_MIN_NB_MB_Q15[11];
|
||||
extern const uint8_t silk_gain_iCDF[3][N_LEVELS_QGAIN / 8];
|
||||
extern const uint8_t silk_delta_gain_iCDF[MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1];
|
||||
extern const uint8_t silk_pitch_lag_iCDF[2 * (PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS)];
|
||||
extern const uint8_t silk_pitch_delta_iCDF[21];
|
||||
extern const uint8_t silk_pitch_contour_iCDF[34];
|
||||
extern const uint8_t silk_pitch_contour_NB_iCDF[11];
|
||||
extern const uint8_t silk_pitch_contour_10_ms_iCDF[12];
|
||||
extern const uint8_t silk_pitch_contour_10_ms_NB_iCDF[3];
|
||||
extern const uint8_t silk_LTP_per_index_iCDF[3];
|
||||
extern const uint8_t silk_LTP_gain_iCDF_0[8];
|
||||
extern const uint8_t silk_LTP_gain_iCDF_1[16];
|
||||
extern const uint8_t silk_LTP_gain_iCDF_2[32];
|
||||
extern const uint8_t silk_LTP_gain_BITS_Q5_0[8];
|
||||
extern const uint8_t silk_LTP_gain_BITS_Q5_1[16];
|
||||
extern const uint8_t silk_LTP_gain_BITS_Q5_2[32];
|
||||
extern const uint8_t* const silk_LTP_gain_iCDF_ptrs[NB_LTP_CBKS];
|
||||
extern const uint8_t* const silk_LTP_gain_BITS_Q5_ptrs[NB_LTP_CBKS];
|
||||
extern const int8_t silk_LTP_gain_vq_0[8][5];
|
||||
extern const int8_t silk_LTP_gain_vq_1[16][5];
|
||||
extern const int8_t silk_LTP_gain_vq_2[32][5];
|
||||
extern const uint8_t silk_NLSF_CB1_WB_Q8[512];
|
||||
extern const int16_t silk_NLSF_CB1_WB_Wght_Q9[512];
|
||||
extern const uint8_t silk_NLSF_CB1_iCDF_WB[64];
|
||||
extern const uint8_t silk_NLSF_CB2_SELECT_WB[256];
|
||||
extern const uint8_t silk_NLSF_CB2_iCDF_WB[72];
|
||||
extern const uint8_t silk_NLSF_CB2_BITS_WB_Q5[72];
|
||||
extern const uint8_t silk_NLSF_PRED_WB_Q8[30];
|
||||
extern const int16_t silk_NLSF_DELTA_MIN_WB_Q15[17];
|
||||
extern const int8_t silk_CB_lags_stage2_10_ms[PE_MAX_NB_SUBFR >> 1][PE_NB_CBKS_STAGE2_10MS];
|
||||
extern const int8_t silk_CB_lags_stage3_10_ms[PE_MAX_NB_SUBFR >> 1][PE_NB_CBKS_STAGE3_10MS];
|
||||
extern const int8_t silk_CB_lags_stage3_10_ms[PE_MAX_NB_SUBFR >> 1][PE_NB_CBKS_STAGE3_10MS];
|
||||
extern const int8_t silk_Lag_range_stage3_10_ms[PE_MAX_NB_SUBFR >> 1][2];
|
||||
extern const int8_t silk_CB_lags_stage2[PE_MAX_NB_SUBFR][PE_NB_CBKS_STAGE2_EXT];
|
||||
extern const int8_t silk_CB_lags_stage3[PE_MAX_NB_SUBFR][PE_NB_CBKS_STAGE3_MAX];
|
||||
extern const int8_t silk_Lag_range_stage3[SILK_PE_MAX_COMPLEX + 1][PE_MAX_NB_SUBFR][2];
|
||||
extern const int8_t delay_matrix_enc[5][3];
|
||||
extern const int8_t delay_matrix_dec[3][5];
|
||||
extern const int16_t silk_Resampler_3_4_COEFS[2 + 3 * RESAMPLER_DOWN_ORDER_FIR0 / 2];
|
||||
extern const int16_t silk_Resampler_2_3_COEFS[2 + 2 * RESAMPLER_DOWN_ORDER_FIR0 / 2];
|
||||
extern const int16_t silk_Resampler_1_2_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR1 / 2];
|
||||
extern const int16_t silk_Resampler_1_3_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR2 / 2];
|
||||
extern const int16_t silk_Resampler_1_4_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR2 / 2];
|
||||
extern const int16_t silk_Resampler_1_6_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR2 / 2];
|
||||
extern const int16_t silk_Resampler_2_3_COEFS_LQ[2 + 2 * 2];
|
||||
extern const int16_t silk_resampler_frac_FIR_12[12][RESAMPLER_ORDER_FIR_12 / 2];
|
||||
extern const int16_t HARM_ATT_Q15[NB_ATT];
|
||||
extern const int16_t PLC_RAND_ATTENUATE_V_Q15[NB_ATT];
|
||||
extern const int16_t PLC_RAND_ATTENUATE_UV_Q15[NB_ATT];
|
||||
extern const int16_t silk_resampler_down2_0;
|
||||
extern const int16_t silk_resampler_down2_1;
|
||||
extern const int16_t silk_resampler_up2_hq_0[3];
|
||||
extern const int16_t silk_resampler_up2_hq_1[3];
|
||||
extern const int32_t sigm_LUT_slope_Q10[6];
|
||||
extern const int32_t sigm_LUT_pos_Q15[6];
|
||||
extern const int32_t sigm_LUT_neg_Q15[6];
|
||||
extern const int8_t silk_nb_cbk_searchs_stage3[SILK_PE_MAX_COMPLEX + 1];
|
||||
|
||||
|
||||
class SilkDecoder{
|
||||
public:
|
||||
SilkDecoder(RangeDecoder& rangeDecoder) : rd(rangeDecoder) {}
|
||||
~SilkDecoder() {reset();}
|
||||
bool init();
|
||||
void clear();
|
||||
void reset();
|
||||
int32_t silk_InitDecoder();
|
||||
void setChannelsAPI(uint8_t nChannelsAPI);
|
||||
void setChannelsInternal(uint8_t nChannelsInternal);
|
||||
void setAPIsampleRate(uint32_t API_sampleRate);
|
||||
void silk_setRawParams(uint8_t channels, uint8_t API_channels, uint8_t payloadSize_ms, uint32_t internalSampleRate, uint32_t API_samleRate);
|
||||
int32_t silk_Decode(int32_t lostFlag, int32_t newPacketFlag, int16_t *samplesOut, int32_t *nSamplesOut);
|
||||
|
||||
private:
|
||||
RangeDecoder& rd; // Referenz auf RangeDecoder
|
||||
|
||||
ps_ptr<silk_resampler_state_struct_t> m_resampler_state;
|
||||
ps_ptr<silk_decoder_state_t> m_channel_state;
|
||||
ps_ptr<silk_decoder_t> m_silk_decoder;
|
||||
ps_ptr<silk_decoder_control_t> m_silk_decoder_control;
|
||||
ps_ptr<silk_DecControlStruct_t> m_silk_DecControlStruct;
|
||||
|
||||
uint8_t m_channelsInternal = 0;
|
||||
uint8_t m_payloadSize_ms = 0;
|
||||
uint8_t m_API_channels = 0;
|
||||
uint32_t m_silk_internalSampleRate = 0;
|
||||
uint32_t m_API_sampleRate = 0;
|
||||
uint32_t m_prevPitchLag = 0;
|
||||
|
||||
/* Coefficients for 2-band filter bank based on first-order allpass filters */
|
||||
int16_t A_fb1_20 = 5394 << 1;
|
||||
int16_t A_fb1_21 = -24290; /* (int16_t)(20623 << 1) */
|
||||
|
||||
const silk_NLSF_CB_struct_t silk_NLSF_CB_WB = {
|
||||
32,
|
||||
16,
|
||||
SILK_FIX_CONST(0.15, 16),
|
||||
SILK_FIX_CONST(1.0 / 0.15, 6),
|
||||
silk_NLSF_CB1_WB_Q8,
|
||||
silk_NLSF_CB1_WB_Wght_Q9,
|
||||
silk_NLSF_CB1_iCDF_WB,
|
||||
silk_NLSF_PRED_WB_Q8,
|
||||
silk_NLSF_CB2_SELECT_WB,
|
||||
silk_NLSF_CB2_iCDF_WB,
|
||||
silk_NLSF_CB2_BITS_WB_Q5,
|
||||
silk_NLSF_DELTA_MIN_WB_Q15,
|
||||
};
|
||||
|
||||
const int8_t* const silk_LTP_vq_ptrs_Q7[NB_LTP_CBKS] = {(int8_t*)&silk_LTP_gain_vq_0[0][0], (int8_t*)&silk_LTP_gain_vq_1[0][0], (int8_t*)&silk_LTP_gain_vq_2[0][0]};
|
||||
|
||||
/* Maximum frequency-dependent response of the pitch taps above,
|
||||
computed as max(abs(freqz(taps))) */
|
||||
const uint8_t silk_LTP_gain_vq_0_gain[8] = {46, 2, 90, 87, 93, 91, 82, 98};
|
||||
|
||||
const uint8_t silk_LTP_gain_vq_1_gain[16] = {109, 120, 118, 12, 113, 115, 117, 119, 99, 59, 87, 111, 63, 111, 112, 80};
|
||||
|
||||
const uint8_t silk_LTP_gain_vq_2_gain[32] = {126, 124, 125, 124, 129, 121, 126, 23, 132, 127, 127, 127, 126, 127, 122, 133,
|
||||
130, 134, 101, 118, 119, 145, 126, 86, 124, 120, 123, 119, 170, 173, 107, 109};
|
||||
|
||||
const uint8_t* const silk_LTP_vq_gain_ptrs_Q7[NB_LTP_CBKS] = {&silk_LTP_gain_vq_0_gain[0], &silk_LTP_gain_vq_1_gain[0], &silk_LTP_gain_vq_2_gain[0]};
|
||||
|
||||
const int8_t silk_LTP_vq_sizes[NB_LTP_CBKS] = {8, 16, 32};
|
||||
|
||||
const silk_NLSF_CB_struct_t silk_NLSF_CB_NB_MB = {
|
||||
32,
|
||||
10,
|
||||
SILK_FIX_CONST(0.18, 16),
|
||||
SILK_FIX_CONST(1.0 / 0.18, 6),
|
||||
silk_NLSF_CB1_NB_MB_Q8,
|
||||
silk_NLSF_CB1_Wght_Q9,
|
||||
silk_NLSF_CB1_iCDF_NB_MB,
|
||||
silk_NLSF_PRED_NB_MB_Q8,
|
||||
silk_NLSF_CB2_SELECT_NB_MB,
|
||||
silk_NLSF_CB2_iCDF_NB_MB,
|
||||
silk_NLSF_CB2_BITS_NB_MB_Q5,
|
||||
silk_NLSF_DELTA_MIN_NB_MB_Q15,
|
||||
};
|
||||
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
void silk_ana_filt_bank_1(const int16_t *in, int32_t *S, int16_t *outL, int16_t *outH, const int32_t N);
|
||||
void silk_biquad_alt_stride1(const int16_t *in, const int32_t *B_Q28, const int32_t *A_Q28, int32_t *S,int16_t *out, const int32_t len);
|
||||
void silk_biquad_alt_stride2_c(const int16_t *in, const int32_t *B_Q28, const int32_t *A_Q28, int32_t *S, int16_t *out, const int32_t len);
|
||||
void silk_bwexpander_32(int32_t *ar, const int32_t d, int32_t chirp_Q16);
|
||||
void silk_bwexpander(int16_t *ar, const int32_t d, int32_t chirp_Q16);
|
||||
void silk_stereo_decode_pred(int32_t pred_Q13[]);
|
||||
void silk_stereo_decode_mid_only(int32_t *decode_only_mid);
|
||||
void silk_PLC_Reset(uint8_t n);
|
||||
void silk_PLC(uint8_t n, int16_t frame[], int32_t lost);
|
||||
void silk_PLC_glue_frames(uint8_t, int16_t frame[], int32_t length);
|
||||
void silk_LP_interpolate_filter_taps(int32_t B_Q28[TRANSITION_NB], int32_t A_Q28[TRANSITION_NA], const int32_t ind, const int32_t fac_Q16);
|
||||
void silk_LP_variable_cutoff(silk_LP_state_t *psLP, int16_t *frame, const int32_t frame_length);
|
||||
void silk_NLSF_unpack(int16_t ec_ix[], uint8_t pred_Q8[], const silk_NLSF_CB_struct_t *psNLSF_CB, const int32_t CB1_index);
|
||||
void silk_NLSF_decode(int16_t *pNLSF_Q15, int8_t *NLSFIndices, const silk_NLSF_CB_struct_t *psNLSF_CB);
|
||||
int32_t silk_decoder_set_fs(uint8_t n, int32_t fs_kHz, int32_t fs_API_Hz);
|
||||
int32_t combine_and_check(int32_t* pulses_comb, const int32_t* pulses_in, int32_t max_pulses, int32_t len);
|
||||
void silk_decode_indices(uint8_t n, int32_t FrameIndex, int32_t decode_LBRR, int32_t condCoding);
|
||||
void silk_decode_parameters(uint8_t n, int32_t condCoding);
|
||||
void silk_decode_core(uint8_t n, int16_t xq[], const int16_t pulses[MAX_FRAME_LENGTH]);
|
||||
void silk_decode_pulses(int16_t pulses[], const int32_t signalType, const int32_t quantOffsetType, const int32_t frame_length);
|
||||
int32_t silk_init_decoder(uint8_t n);
|
||||
int32_t silk_NLSF_del_dec_quant(int8_t indices[], const int16_t x_Q10[], const int16_t w_Q5[], const uint8_t pred_coef_Q8[], const int16_t ec_ix[], const uint8_t ec_rates_Q5[],
|
||||
const int32_t quant_step_size_Q16, const int16_t inv_quant_step_size_Q6, const int32_t mu_Q20, const int16_t order);
|
||||
void silk_NLSF_VQ(int32_t err_Q26[], const int16_t in_Q15[], const uint8_t pCB_Q8[], const int16_t pWght_Q9[], const int32_t K, const int32_t LPC_order);
|
||||
int32_t silk_VAD_Init(silk_VAD_state_t *psSilk_VAD);
|
||||
void silk_stereo_MS_to_LR(stereo_dec_state_t *state, int16_t x1[], int16_t x2[], const int32_t pred_Q13[], int32_t fs_kHz, int32_t frame_length);
|
||||
int32_t silk_stereo_find_predictor(int32_t *ratio_Q14, const int16_t x[], const int16_t y[], int32_t mid_res_amp_Q0[], int32_t length, int32_t smooth_coef_Q16);
|
||||
void silk_stereo_quant_pred(int32_t pred_Q13[], int8_t ix[2][3]);
|
||||
void silk_decode_signs(int16_t pulses[], int32_t length, const int32_t signalType, const int32_t quantOffsetType, const int32_t sum_pulses[MAX_NB_SHELL_BLOCKS]);
|
||||
void silk_shell_decoder(int16_t *pulses0, const int32_t pulses4);
|
||||
void silk_gains_quant(int8_t ind[MAX_NB_SUBFR], int32_t gain_Q16[MAX_NB_SUBFR], int8_t *prev_ind, const int32_t conditional, const int32_t nb_subfr);
|
||||
void silk_gains_dequant(int32_t gain_Q16[MAX_NB_SUBFR], const int8_t ind[MAX_NB_SUBFR], int8_t *prev_ind, const int32_t conditional, const int32_t nb_subfr);
|
||||
int32_t silk_gains_ID(const int8_t ind[MAX_NB_SUBFR], const int32_t nb_subfr);
|
||||
void silk_interpolate(int16_t xi[MAX_LPC_ORDER], const int16_t x0[MAX_LPC_ORDER], const int16_t x1[MAX_LPC_ORDER], const int32_t ifact_Q2, const int32_t d);
|
||||
void silk_quant_LTP_gains(int16_t B_Q14[MAX_NB_SUBFR * LTP_ORDER], int8_t cbk_index[MAX_NB_SUBFR], int8_t *periodicity_index, int32_t *sum_gain_dB_Q7, int32_t *pred_gain_dB_Q7,
|
||||
const int32_t XX_Q17[MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER], const int32_t xX_Q17[MAX_NB_SUBFR * LTP_ORDER], const int32_t subfr_len, const int32_t nb_subfr);
|
||||
void decode_split(int16_t *p_child1, int16_t *p_child2, const int32_t p, const uint8_t *shell_table);
|
||||
void silk_VQ_WMat_EC_c(int8_t *ind, int32_t *res_nrg_Q15, int32_t *rate_dist_Q8, int32_t *gain_Q7, const int32_t *XX_Q17, const int32_t *xX_Q17, const int8_t *cb_Q7, const uint8_t *cb_gain_Q7,
|
||||
const uint8_t *cl_Q5, const int32_t subfr_len, const int32_t max_gain_Q7, const int32_t L);
|
||||
void silk_CNG_Reset(uint8_t n);
|
||||
void silk_CNG(uint8_t n, int16_t frame[], int32_t length);
|
||||
int32_t silk_Get_Decoder_Size(int32_t *decSizeBytes);
|
||||
void silk_NLSF2A_find_poly(int32_t *out, const int32_t *cLSF, int32_t dd);
|
||||
void silk_NLSF2A(int16_t *a_Q12, const int16_t *NLSF, const int32_t d);
|
||||
void silk_CNG_exc(int32_t exc_Q14[], int32_t exc_buf_Q14[], int32_t length, int32_t *rand_seed);
|
||||
int32_t silk_decode_frame(uint8_t n, int16_t pOut[], int32_t *pN, int32_t lostFlag, int32_t condCoding);
|
||||
void silk_decode_pitch(int16_t lagIndex, int8_t contourIndex, int32_t pitch_lags[], const int32_t Fs_kHz, const int32_t nb_subfr);
|
||||
int32_t silk_inner_prod_aligned_scale(const int16_t *const inVec1, const int16_t *const inVec2, const int32_t scale, const int32_t len);
|
||||
int32_t silk_lin2log(const int32_t inLin);
|
||||
int32_t silk_log2lin(const int32_t inLog_Q7);
|
||||
void silk_LPC_analysis_filter(int16_t *out, const int16_t *in, const int16_t *B, const int32_t len, const int32_t d);
|
||||
void silk_LPC_fit(int16_t *a_QOUT, int32_t *a_QIN, const int32_t QOUT, const int32_t QIN, const int32_t d);
|
||||
int32_t LPC_inverse_pred_gain_QA_c(int32_t A_QA[SILK_MAX_ORDER_LPC], const int32_t order);
|
||||
int32_t silk_LPC_inverse_pred_gain_c(const int16_t *A_Q12, const int32_t order);
|
||||
void silk_NLSF_residual_dequant(int16_t x_Q10[], const int8_t indices[], const uint8_t pred_coef_Q8[], const int32_t quant_step_size_Q16, const int16_t order);
|
||||
void silk_NLSF_stabilize(int16_t *NLSF_Q15, const int16_t *NDeltaMin_Q15, const int32_t L);
|
||||
void silk_NLSF_VQ_weights_laroia(int16_t *pNLSFW_Q_OUT, const int16_t *pNLSF_Q15, const int32_t D);
|
||||
void silk_PLC_update(uint8_t n);
|
||||
void silk_PLC_energy(int32_t *energy1, int32_t *shift1, int32_t *energy2, int32_t *shift2, const int32_t *exc_Q14, const int32_t *prevGain_Q10, int subfr_length, int nb_subfr);
|
||||
void silk_PLC_conceal(uint8_t n, int16_t frame[]);
|
||||
void silk_resampler_down2(int32_t *S, int16_t *out, const int16_t *in, int32_t inLen);
|
||||
void silk_resampler_private_AR2(int32_t S[], int32_t out_Q8[], const int16_t in[], const int16_t A_Q14[], int32_t len);
|
||||
int16_t *silk_resampler_private_down_FIR_INTERPOL(int16_t *out, int32_t *buf, const int16_t *FIR_Coefs, int32_t FIR_Order, int32_t FIR_Fracs, int32_t max_index_Q16, int32_t index_increment_Q16);
|
||||
void silk_resampler_private_down_FIR(void *SS, int16_t out[], const int16_t in[], int32_t inLen);
|
||||
int16_t *silk_resampler_private_IIR_FIR_INTERPOL(int16_t *out, int16_t *buf, int32_t max_index_Q16, int32_t index_increment_Q16);
|
||||
void silk_resampler_private_IIR_FIR(void *SS, int16_t out[], const int16_t in[], int32_t inLen);
|
||||
void silk_resampler_private_up2_HQ(int32_t *S, int16_t *out, const int16_t *in, int32_t len);
|
||||
void silk_resampler_private_up2_HQ_wrapper(void *SS, int16_t *out, const int16_t *in, int32_t len);
|
||||
int32_t silk_resampler_init(uint8_t n, int32_t Fs_Hz_in, int32_t Fs_Hz_out, int32_t forEnc);
|
||||
int32_t silk_resampler(uint8_t n, int16_t out[], const int16_t in[], int32_t inLen);
|
||||
int32_t silk_sigm_Q15(int32_t in_Q5);
|
||||
void silk_insertion_sort_increasing(int32_t *a, int32_t *idx, const int32_t L, const int32_t K);
|
||||
void silk_insertion_sort_decreasing_int16(int16_t *a, int32_t *idx, const int32_t L, const int32_t K);
|
||||
void silk_insertion_sort_increasing_all_values_int16(int16_t *a, const int32_t L);
|
||||
void silk_sum_sqr_shift(int32_t *energy, int32_t *shift, const int16_t *x, int32_t len);
|
||||
void combine_pulses(int32_t *out, const int32_t *in, const int32_t len);
|
||||
int32_t silk_INVERSE32_varQ(const int32_t b32, const int32_t Qres);
|
||||
int32_t silk_DIV32_varQ(const int32_t a32, const int32_t b32, const int32_t Qres);
|
||||
int32_t silk_SQRT_APPROX(int32_t x);
|
||||
void silk_CLZ_FRAC(int32_t in, int32_t *lz, int32_t *frac_Q7);
|
||||
uint32_t silk_getPrevPitchLag();
|
||||
int32_t silk_ROR32(int32_t a32, int32_t rot);
|
||||
int32_t silk_CLZ64(int64_t in);
|
||||
int32_t silk_min_int(int32_t a, int32_t b);
|
||||
int16_t silk_min_16(int16_t a, int16_t b);
|
||||
int32_t silk_min_32(int32_t a, int32_t b);
|
||||
int64_t silk_min_64(int64_t a, int64_t b);
|
||||
|
||||
/* silk_min() versions with typecast in the function call */
|
||||
int32_t silk_max_int(int32_t a, int32_t b);
|
||||
int16_t silk_max_16(int16_t a, int16_t b);
|
||||
int32_t silk_max_32(int32_t a, int32_t b);
|
||||
int64_t silk_max_64(int64_t a, int64_t b);
|
||||
int32_t silk_noise_shape_quantizer_short_prediction_c(const int32_t *buf32, const int16_t *coef16, int32_t order);
|
||||
int32_t silk_NSQ_noise_shape_feedback_loop_c(const int32_t *data0, int32_t *data1, const int16_t *coef, int32_t order);
|
||||
int32_t silk_CLZ16(int16_t in16);
|
||||
int32_t silk_CLZ32(int32_t in32);
|
||||
};
|
||||
@@ -1,336 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define SILK_MAX_FRAMES_PER_PACKET 3
|
||||
/* Decoder API flags */
|
||||
#define FLAG_DECODE_NORMAL 0
|
||||
#define FLAG_PACKET_LOST 1
|
||||
#define FLAG_DECODE_LBRR 2
|
||||
#define SILK_ALLOC_NONE 1
|
||||
/* Number of binary divisions, when not in low complexity mode */
|
||||
#define BIN_DIV_STEPS_A2NLSF_FIX 3 /* must be no higher than 16 - log2( LSF_COS_TAB_SZ_FIX ) */
|
||||
#define MAX_ITERATIONS_A2NLSF_FIX 16
|
||||
|
||||
/* Fixed point macros */
|
||||
#define silk_MUL(a32, b32) ((a32) * (b32)) /* (a32 * b32) output have to be 32bit int */
|
||||
#define silk_MUL_uint(a32, b32) silk_MUL(a32, b32) /* (a32 * b32) output have to be 32bit uint */
|
||||
#define silk_MLA(a32, b32, c32) silk_ADD32((a32),((b32) * (c32))) /* a32 + (b32 * c32) output have to be 32bit int */
|
||||
#define silk_MLA_uint(a32, b32, c32) silk_MLA(a32, b32, c32) /* a32 + (b32 * c32) output have to be 32bit uint */
|
||||
#define silk_SMULTT(a32, b32) (((a32) >> 16) * ((b32) >> 16)) /* ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int */
|
||||
#define silk_SMLATT(a32, b32, c32) silk_ADD32((a32),((b32) >> 16) * ((c32) >> 16)) /* a32 + ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int */
|
||||
#define silk_SMLALBB(a64, b16, c16) silk_ADD64((a64),(int64_t)((int32_t)(b16) * (int32_t)(c16)))
|
||||
#define silk_SMULL(a32, b32) ((int64_t)(a32) * /*(int64_t)*/(b32)) /* (a32 * b32) */
|
||||
#define silk_ADD32_ovflw(a, b) ((int32_t)((uint32_t)(a) + (uint32_t)(b))) /* Adds two signed 32-bit values in a way that can overflow, while not relying on undefined behaviour (just standard two's complement implementation-specific behaviour) */
|
||||
#define silk_SUB32_ovflw(a, b) ((int32_t)((uint32_t)(a) - (uint32_t)(b))) /* Subtractss two signed 32-bit values in a way that can overflow, while not relying on undefined behaviour (just standard two's complement implementation-specific behaviour) */
|
||||
#define silk_MLA_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (uint32_t)(b32) * (uint32_t)(c32)) /* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */
|
||||
#define silk_SMLABB_ovflw(a32, b32, c32) (silk_ADD32_ovflw((a32) , ((int32_t)((int16_t)(b32))) * (int32_t)((int16_t)(c32))))
|
||||
#define silk_DIV32_16(a32, b16) ((int32_t)((a32) / (b16)))
|
||||
#define silk_DIV32(a32, b32) ((int32_t)((a32) / (b32)))
|
||||
#define silk_ADD16(a, b) ((a) + (b)) /* These macros enables checking for overflow in silk_API_Debug.h*/
|
||||
#define silk_ADD32(a, b) ((a) + (b))
|
||||
#define silk_ADD64(a, b) ((a) + (b))
|
||||
#define silk_SUB16(a, b) ((a) - (b))
|
||||
#define silk_SUB32(a, b) ((a) - (b))
|
||||
#define silk_SUB64(a, b) ((a) - (b))
|
||||
#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : ((a) < silk_int8_MIN ? silk_int8_MIN : (a)))
|
||||
#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : ((a) < silk_int16_MIN ? silk_int16_MIN : (a)))
|
||||
#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : ((a) < silk_int32_MIN ? silk_int32_MIN : (a)))
|
||||
#define silk_CHECK_FIT8(a) (a)
|
||||
#define silk_CHECK_FIT16(a) (a)
|
||||
#define silk_CHECK_FIT32(a) (a)
|
||||
#define silk_ADD_SAT16(a, b) (int16_t)silk_SAT16( silk_ADD32( (int32_t)(a), (b) ) )
|
||||
#define silk_ADD_SAT64(a, b) ((((a) + (b)) & 0x8000000000000000LL) == 0 ? \
|
||||
((((a) & (b)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a)+(b)) : ((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a)+(b)) )
|
||||
#define silk_SUB_SAT16(a, b) (int16_t)silk_SAT16( silk_SUB32( (int32_t)(a), (b) ) )
|
||||
#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \
|
||||
(( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : ((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) )
|
||||
#define silk_POS_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : (a)) /* Saturation for positive input values */
|
||||
#define silk_ADD_POS_SAT8(a, b) ((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b))) /* Add with saturation for positive input values */
|
||||
#define silk_ADD_POS_SAT16(a, b) ((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b)))
|
||||
#define silk_ADD_POS_SAT32(a, b) ((((uint32_t)(a)+(uint32_t)(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)))
|
||||
#define silk_LSHIFT8(a, shift) ((int32_t8)((uint8_t)(a)<<(shift))) /* shift >= 0, shift < 8 */
|
||||
#define silk_LSHIFT16(a, shift) ((int16_t)((uint16_t)(a)<<(shift))) /* shift >= 0, shift < 16 */
|
||||
#define silk_LSHIFT32(a, shift) ((int32_t)((uint32_t)(a)<<(shift))) /* shift >= 0, shift < 32 */
|
||||
#define silk_LSHIFT64(a, shift) ((int64_t)((uint64_t)(a)<<(shift))) /* shift >= 0, shift < 64 */
|
||||
#define silk_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */
|
||||
#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */
|
||||
#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */
|
||||
#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */
|
||||
#define silk_RSHIFT64(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 64 */
|
||||
#define silk_RSHIFT(a, shift) silk_RSHIFT32(a, shift) /* shift >= 0, shift < 32 */
|
||||
#define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (shift) ))
|
||||
#define silk_LSHIFT_ovflw(a, shift) ((int32_t)((uint32_t)(a) << (shift))) /* shift >= 0, allowed to overflow */
|
||||
#define silk_LSHIFT_uint(a, shift) ((a) << (shift)) /* shift >= 0 */
|
||||
#define silk_RSHIFT_uint(a, shift) ((a) >> (shift)) /* shift >= 0 */
|
||||
#define silk_ADD_LSHIFT(a, b, shift) ((a) + silk_LSHIFT((b), (shift))) /* shift >= 0 */
|
||||
#define silk_ADD_LSHIFT32(a, b, shift) silk_ADD32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */
|
||||
#define silk_ADD_LSHIFT_uint(a, b, shift) ((a) + silk_LSHIFT_uint((b), (shift))) /* shift >= 0 */
|
||||
#define silk_ADD_RSHIFT(a, b, shift) ((a) + silk_RSHIFT((b), (shift))) /* shift >= 0 */
|
||||
#define silk_ADD_RSHIFT32(a, b, shift) silk_ADD32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */
|
||||
#define silk_ADD_RSHIFT_uint(a, b, shift) ((a) + silk_RSHIFT_uint((b), (shift))) /* shift >= 0 */
|
||||
#define silk_SUB_LSHIFT32(a, b, shift) silk_SUB32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */
|
||||
#define silk_SUB_RSHIFT32(a, b, shift) silk_SUB32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */
|
||||
#define silk_RSHIFT_ROUND(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) /* Requires that shift > 0 */
|
||||
#define silk_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
|
||||
#define silk_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(silk_abs(a)) + (32-silk_CLZ32(silk_abs(b))))) ) /* Number of rightshift required to fit the multiplication */
|
||||
#define silk_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(silk_abs(a)) + (16-silk_CLZ16(silk_abs(b))))) )
|
||||
#define silk_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define silk_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN_QGAIN_DB 2 /* dB level of lowest gain quantization level */
|
||||
#define MAX_QGAIN_DB 88 /* dB level of highest gain quantization level */
|
||||
#define N_LEVELS_QGAIN 64 /* Number of gain quantization levels */
|
||||
#define MAX_DELTA_GAIN_QUANT 36 /* Max increase in gain quantization index */
|
||||
#define MIN_DELTA_GAIN_QUANT -4 /* Max decrease in gain quantization index */
|
||||
#define OFFSET_VL_Q10 32 /* Quantization offsets (multiples of 4) */
|
||||
#define OFFSET_VH_Q10 100
|
||||
#define OFFSET_UVL_Q10 100
|
||||
#define OFFSET_UVH_Q10 240
|
||||
#define QUANT_LEVEL_ADJUST_Q10 80
|
||||
#define MAX_LPC_STABILIZE_ITERATIONS 16 /* Maximum numbers of iterations used to stabilize an LPC vector */
|
||||
#define MAX_PREDICTION_POWER_GAIN 1e4f
|
||||
#define MAX_PREDICTION_POWER_GAIN_AFTER_RESET 1e2f
|
||||
#define MAX_LPC_ORDER 16
|
||||
#define MIN_LPC_ORDER 10
|
||||
#define LTP_ORDER 5 /* Find Pred Coef defines */
|
||||
#define NB_LTP_CBKS 3 /* LTP quantization settings */
|
||||
#define USE_HARM_SHAPING 1 /* Flag to use harmonic noise shaping */
|
||||
#define MAX_SHAPE_LPC_ORDER 24 /* Max LPC order of noise shaping filters */
|
||||
#define HARM_SHAPE_FIR_TAPS 3
|
||||
#define MAX_DEL_DEC_STATES 4 /* Maximum number of delayed decision states */
|
||||
#define LTP_BUF_LENGTH 512
|
||||
#define LTP_MASK ( LTP_BUF_LENGTH - 1 )
|
||||
#define DECISION_DELAY 40
|
||||
#define MAX_NB_SUBFR 4 /* Maximum number of subframes */
|
||||
#define ENCODER_NUM_CHANNELS 2 /* Max number of encoder channels (1/2) */
|
||||
#define DECODER_NUM_CHANNELS 2 /* Number of decoder channels (1/2) */
|
||||
#define MAX_FRAMES_PER_PACKET 3
|
||||
#define MIN_TARGET_RATE_BPS 5000 /* Limits on bitrate */
|
||||
#define MAX_TARGET_RATE_BPS 80000
|
||||
#define LBRR_NB_MIN_RATE_BPS 12000 /* LBRR thresholds */
|
||||
#define LBRR_MB_MIN_RATE_BPS 14000
|
||||
#define LBRR_WB_MIN_RATE_BPS 16000
|
||||
#define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */
|
||||
#define MAX_CONSECUTIVE_DTX 20 /* eq 400 ms */
|
||||
#define DTX_ACTIVITY_THRESHOLD 0.1f
|
||||
#define VAD_NO_DECISION -1 /* VAD decision */
|
||||
#define VAD_NO_ACTIVITY 0
|
||||
#define VAD_ACTIVITY 1
|
||||
#define MAX_FS_KHZ 16 /* Maximum sampling frequency */
|
||||
#define MAX_API_FS_KHZ 48
|
||||
#define TYPE_NO_VOICE_ACTIVITY 0 /* Signal types */
|
||||
#define TYPE_UNVOICED 1
|
||||
#define TYPE_VOICED 2
|
||||
#define CODE_INDEPENDENTLY 0 /* Conditional coding types */
|
||||
#define CODE_INDEPENDENTLY_NO_LTP_SCALING 1
|
||||
#define CODE_CONDITIONALLY 2
|
||||
#define STEREO_QUANT_TAB_SIZE 16 /* Settings for stereo processing */
|
||||
#define STEREO_QUANT_SUB_STEPS 5
|
||||
#define STEREO_INTERP_LEN_MS 8 /* must be even */
|
||||
#define STEREO_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */
|
||||
#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */
|
||||
#define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */
|
||||
#define LTP_MEM_LENGTH_MS 20 /* Number of samples per frame */
|
||||
#define SUB_FRAME_LENGTH_MS 5
|
||||
#define MAX_SUB_FRAME_LENGTH ( SUB_FRAME_LENGTH_MS * MAX_FS_KHZ )
|
||||
#define MAX_FRAME_LENGTH_MS ( SUB_FRAME_LENGTH_MS * MAX_NB_SUBFR )
|
||||
#define MAX_FRAME_LENGTH ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ )
|
||||
#define LA_PITCH_MS 2 /* Milliseconds of lookahead for pitch analysis */
|
||||
#define LA_PITCH_MAX ( LA_PITCH_MS * MAX_FS_KHZ )
|
||||
#define MAX_FIND_PITCH_LPC_ORDER 16 /* Order of LPC used in find pitch */
|
||||
#define FIND_PITCH_LPC_WIN_MS ( 20 + (LA_PITCH_MS << 1) )/* Length of LPC window used in find pitch */
|
||||
#define FIND_PITCH_LPC_WIN_MS_2_SF ( 10 + (LA_PITCH_MS << 1) )
|
||||
#define FIND_PITCH_LPC_WIN_MAX ( FIND_PITCH_LPC_WIN_MS * MAX_FS_KHZ )
|
||||
#define LA_SHAPE_MS 5 /* Milliseconds of lookahead for noise shape analysis */
|
||||
#define LA_SHAPE_MAX ( LA_SHAPE_MS * MAX_FS_KHZ )
|
||||
#define SHAPE_LPC_WIN_MAX ( 15 * MAX_FS_KHZ )/* Max lenof LPCwindow in noise shape analysis */
|
||||
#define SHELL_CODEC_FRAME_LENGTH 16 /* Number of subframes for excitation entropy coding */
|
||||
#define LOG2_SHELL_CODEC_FRAME_LENGTH 4
|
||||
#define MAX_NB_SHELL_BLOCKS ( MAX_FRAME_LENGTH / SHELL_CODEC_FRAME_LENGTH )
|
||||
#define N_RATE_LEVELS 10 /* Number of rate levels, for entropy coding of excitation */
|
||||
#define SILK_MAX_PULSES 16 /* Maximum sum of pulses per shell coding frame */
|
||||
#define MAX_MATRIX_SIZE MAX_LPC_ORDER /* Max of LPC Order and LTP order */
|
||||
#define NSQ_LPC_BUF_LENGTH MAX_LPC_ORDER
|
||||
#define VAD_N_BANDS 4
|
||||
#define VAD_INTERNAL_SUBFRAMES_LOG2 2
|
||||
#define VAD_INTERNAL_SUBFRAMES ( 1 << VAD_INTERNAL_SUBFRAMES_LOG2 )
|
||||
#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 1024 /* Must be < 4096 */
|
||||
#define VAD_NOISE_LEVELS_BIAS 50
|
||||
#define VAD_NEGATIVE_OFFSET_Q5 128 /* sigmoid is 0 at -128 */
|
||||
#define VAD_SNR_FACTOR_Q16 45000
|
||||
#define VAD_SNR_SMOOTH_COEF_Q18 4096 /* smoothing for SNR measurement */
|
||||
#define LSF_COS_TAB_SZ_FIX 128/* Sizeof piecewise linear cos approximation table for the LSFs */
|
||||
#define BWE_COEF 0.99
|
||||
#define V_PITCH_GAIN_START_MIN_Q14 11469
|
||||
#define V_PITCH_GAIN_START_MAX_Q14 15565
|
||||
#define MAX_PITCH_LAG_MS 18
|
||||
#define RAND_BUF_SIZE 128
|
||||
#define RAND_BUF_MASK ( RAND_BUF_SIZE - 1)
|
||||
#define LOG2_INV_LPC_GAIN_HIGH_THRES 3
|
||||
#define LOG2_INV_LPC_GAIN_LOW_THRES 8
|
||||
#define PITCH_DRIFT_FAC_Q16 655
|
||||
#define BITRESERVOIR_DECAY_TIME_MS 500 /* Decay time for bitreservoir */
|
||||
#define FIND_PITCH_WHITE_NOISE_FRACTION 1e-3f /* Level of noise floor for whitening filter LPC analysis */
|
||||
#define FIND_PITCH_BANDWIDTH_EXPANSION 0.99f /* Bandwidth expansion for whitening filter in pitch analysis */
|
||||
#define FIND_LPC_COND_FAC 1e-5f /* LPC analysis regularization */
|
||||
#define MAX_SUM_LOG_GAIN_DB 250.0f /* Max cumulative LTP gain */
|
||||
#define LTP_CORR_INV_MAX 0.03f /* LTP analysis defines */
|
||||
#define VARIABLE_HP_SMTH_COEF1 0.1f
|
||||
#define VARIABLE_HP_SMTH_COEF2 0.015f
|
||||
#define VARIABLE_HP_MAX_DELTA_FREQ 0.4f
|
||||
#define VARIABLE_HP_MIN_CUTOFF_HZ 60 /* Min and max cut-off frequency values (-3 dB points) */
|
||||
#define VARIABLE_HP_MAX_CUTOFF_HZ 100
|
||||
#define SPEECH_ACTIVITY_DTX_THRES 0.05f /* VAD threshold */
|
||||
#define LBRR_SPEECH_ACTIVITY_THRES 0.3f /* Speech Activity LBRR enable threshold */
|
||||
#define BG_SNR_DECR_dB 2.0f /* reduction in coding SNR during low speech activity */
|
||||
#define HARM_SNR_INCR_dB 2.0f /* factor for reducing quantization noise during voiced speech */
|
||||
#define SPARSE_SNR_INCR_dB 2.0f /* factor for reducing quant. noise for unvoiced sparse signals */
|
||||
#define ENERGY_VARIATION_THRESHOLD_QNT_OFFSET 0.6f
|
||||
#define WARPING_MULTIPLIER 0.015f /* warping control */
|
||||
#define SHAPE_WHITE_NOISE_FRACTION 3e-5f /* fraction added to first autocorrelation value */
|
||||
#define BANDWIDTH_EXPANSION 0.94f /* noise shaping filter chirp factor */
|
||||
#define HARMONIC_SHAPING 0.3f /* harmonic noise shaping */
|
||||
#define HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING 0.2f /* extra harmonic noise shaping for high bitr. or noisy input */
|
||||
#define HP_NOISE_COEF 0.25f /* parameter for shaping noise towards higher frequencies */
|
||||
#define HARM_HP_NOISE_COEF 0.35f
|
||||
#define INPUT_TILT 0.05f
|
||||
#define HIGH_RATE_INPUT_TILT 0.1f /* for extra high-pass tilt to the input signal at high rates */
|
||||
#define LOW_FREQ_SHAPING 4.0f /* parameter for reducing noise at the very low frequencies */
|
||||
#define LOW_QUALITY_LOW_FREQ_SHAPING_DECR 0.5f
|
||||
#define SUBFR_SMTH_COEF 0.4f
|
||||
#define LAMBDA_OFFSET 1.2f /* param. defining the R/D tradeoff in the residual quantizer */
|
||||
#define LAMBDA_SPEECH_ACT -0.2f
|
||||
#define LAMBDA_DELAYED_DECISIONS -0.05f
|
||||
#define LAMBDA_INPUT_QUALITY -0.1f
|
||||
#define LAMBDA_CODING_QUALITY -0.2f
|
||||
#define LAMBDA_QUANT_OFFSET 0.8f
|
||||
#define REDUCE_BITRATE_10_MS_BPS 2200 /* Compensation in bitrate calculations for 10 ms modes */
|
||||
#define MAX_BANDWIDTH_SWITCH_DELAY_MS 5000 /* Maximum time before allowing a bandwidth transition */
|
||||
#define silk_int64_MAX ((int64_t)0x7FFFFFFFFFFFFFFFLL) /* 2^63 - 1 */
|
||||
#define silk_int64_MIN ((int64_t)0x8000000000000000LL) /* -2^63 */
|
||||
#define silk_int32_MAX 0x7FFFFFFF /* 2^31 - 1 = 2147483647 */
|
||||
#define silk_int32_MIN ((int32_t)0x80000000) /* -2^31 = -2147483648 */
|
||||
#define silk_int16_MAX 0x7FFF /* 2^15 - 1 = 32767 */
|
||||
#define silk_int16_MIN ((int16_t)0x8000) /* -2^15 = -32768 */
|
||||
#define silk_int8_MAX 0x7F /* 2^7 - 1 = 127 */
|
||||
#define silk_int8_MIN ((int8_t)0x80) /* -2^7 = -128 */
|
||||
#define silk_uint8_MAX 0xFF /* 2^8 - 1 = 255 */
|
||||
#define silk_TRUE 1
|
||||
#define silk_FALSE 0
|
||||
#define silk_enc_map(a) ( silk_RSHIFT( (a), 15 ) + 1 )
|
||||
#define silk_dec_map(a) ( silk_LSHIFT( (a), 1 ) - 1 )
|
||||
#define SILK_FIX_CONST(C, Q) ((int32_t)((C) * ((int64_t)1 << (Q)) + 0.5L)) /* Macro to convert floating-point constants to fixed-point */
|
||||
#define TIC(TAG_NAME) /* define macros as empty strings */
|
||||
#define TOC(TAG_NAME)
|
||||
#define silk_TimerSave(FILE_NAME)
|
||||
#define NLSF_W_Q 2 /* NLSF quantizer */
|
||||
#define NLSF_VQ_MAX_VECTORS 32
|
||||
#define NLSF_QUANT_MAX_AMPLITUDE 4
|
||||
#define NLSF_QUANT_MAX_AMPLITUDE_EXT 10
|
||||
#define NLSF_QUANT_LEVEL_ADJ 0.1
|
||||
#define NLSF_QUANT_DEL_DEC_STATES_LOG2 2
|
||||
#define NLSF_QUANT_DEL_DEC_STATES ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 )
|
||||
#define TRANSITION_TIME_MS 5120 /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/
|
||||
#define TRANSITION_NB 3 /* Hardcoded in tables */
|
||||
#define TRANSITION_NA 2 /* Hardcoded in tables */
|
||||
#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */
|
||||
#define TRANSITION_FRAMES ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS )
|
||||
#define TRANSITION_INT_STEPS ( TRANSITION_FRAMES / ( TRANSITION_INT_NUM - 1 ) )
|
||||
#define BWE_AFTER_LOSS_Q16 63570 /* BWE factors to apply after packet loss */
|
||||
#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */
|
||||
#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */
|
||||
#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */
|
||||
#define PE_MAX_FS_KHZ 16 /* Maximum sampling frequency used */
|
||||
#define PE_MAX_NB_SUBFR 4
|
||||
#define PE_SUBFR_LENGTH_MS 5 /* 5 ms */
|
||||
#define PE_LTP_MEM_LENGTH_MS ( 4 * PE_SUBFR_LENGTH_MS )
|
||||
#define PE_MAX_FRAME_LENGTH_MS ( PE_LTP_MEM_LENGTH_MS + PE_MAX_NB_SUBFR * PE_SUBFR_LENGTH_MS )
|
||||
#define PE_MAX_FRAME_LENGTH ( PE_MAX_FRAME_LENGTH_MS * PE_MAX_FS_KHZ )
|
||||
#define PE_MAX_FRAME_LENGTH_ST_1 ( PE_MAX_FRAME_LENGTH >> 2 )
|
||||
#define PE_MAX_FRAME_LENGTH_ST_2 ( PE_MAX_FRAME_LENGTH >> 1 )
|
||||
#define PE_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */
|
||||
#define PE_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */
|
||||
#define PE_MAX_LAG ( PE_MAX_LAG_MS * PE_MAX_FS_KHZ )
|
||||
#define PE_MIN_LAG ( PE_MIN_LAG_MS * PE_MAX_FS_KHZ )
|
||||
#define PE_D_SRCH_LENGTH 24
|
||||
#define PE_NB_STAGE3_LAGS 5
|
||||
#define PE_NB_CBKS_STAGE2 3
|
||||
#define PE_NB_CBKS_STAGE2_EXT 11
|
||||
#define PE_NB_CBKS_STAGE3_MAX 34
|
||||
#define PE_NB_CBKS_STAGE3_MID 24
|
||||
#define PE_NB_CBKS_STAGE3_MIN 16
|
||||
#define PE_NB_CBKS_STAGE3_10MS 12
|
||||
#define PE_NB_CBKS_STAGE2_10MS 3
|
||||
#define PE_SHORTLAG_BIAS 0.2f /* for logarithmic weighting */
|
||||
#define PE_PREVLAG_BIAS 0.2f /* for logarithmic weighting */
|
||||
#define PE_FLATCONTOUR_BIAS 0.05f
|
||||
#define SILK_PE_MIN_COMPLEX 0
|
||||
#define SILK_PE_MID_COMPLEX 1
|
||||
#define SILK_PE_MAX_COMPLEX 2
|
||||
#define USE_CELT_FIR 0
|
||||
#define MAX_LOOPS 20
|
||||
#define NB_ATT 2
|
||||
#define ORDER_FIR 4
|
||||
#define RESAMPLER_DOWN_ORDER_FIR0 18
|
||||
#define RESAMPLER_DOWN_ORDER_FIR1 24
|
||||
#define RESAMPLER_DOWN_ORDER_FIR2 36
|
||||
#define RESAMPLER_ORDER_FIR_12 8
|
||||
#define SILK_MAX_ORDER_LPC 24 /* max order of the LPC analysis in schur() and k2a() */
|
||||
#define SILK_RESAMPLER_MAX_FIR_ORDER 36
|
||||
#define SILK_RESAMPLER_MAX_IIR_ORDER 6
|
||||
#define A_LIMIT SILK_FIX_CONST( 0.99975, 24 )
|
||||
#define MUL32_FRAC_Q(a32, b32, Q) ((int32_t)(silk_RSHIFT_ROUND64(silk_SMULL(a32, b32), Q)))
|
||||
#define RESAMPLER_MAX_BATCH_SIZE_MS 10 /* Number of input samples to process in the inner loop */
|
||||
#define RESAMPLER_MAX_FS_KHZ 48
|
||||
#define RESAMPLER_MAX_BATCH_SIZE_IN ( RESAMPLER_MAX_BATCH_SIZE_MS * RESAMPLER_MAX_FS_KHZ )
|
||||
#define rateID(R) ( ( ( ((R)>>12) - ((R)>16000) ) >> ((R)>24000) ) - 1 ) /* Simple way to make [8000, 12000, 16000, 24000, 48000] to [0, 1, 2, 3, 4] */
|
||||
#define USE_silk_resampler_copy (0)
|
||||
#define USE_silk_resampler_private_up2_HQ_wrapper (1)
|
||||
#define USE_silk_resampler_private_IIR_FIR (2)
|
||||
#define USE_silk_resampler_private_down_FIR (3)
|
||||
#define SILK_NO_ERROR 0
|
||||
#define silk_encoder_state_Fxx silk_encoder_state_FIX
|
||||
#define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FIX
|
||||
#define silk_encode_frame_Fxx silk_encode_frame_FIX
|
||||
#define silk_LIMIT(a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
|
||||
#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ))
|
||||
#define silk_LIMIT_int silk_LIMIT
|
||||
#define silk_LIMIT_16 silk_LIMIT
|
||||
#define silk_LIMIT_32 silk_LIMIT
|
||||
#define silk_abs(a) (((a) > 0) ? (a) : -(a))
|
||||
#define silk_abs_int(a) (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1)))
|
||||
#define silk_abs_int32(a) (((a) ^ ((a) >> 31)) - ((a) >> 31))
|
||||
#define silk_abs_int64(a) (((a) > 0) ? (a) : -(a))
|
||||
#define OFFSET ((MIN_QGAIN_DB * 128) / 6 + 16 * 128)
|
||||
#define SCALE_Q16 ((65536 * (N_LEVELS_QGAIN - 1)) / (((MAX_QGAIN_DB - MIN_QGAIN_DB) * 128) / 6))
|
||||
#define INV_SCALE_Q16 ((65536 * (((MAX_QGAIN_DB - MIN_QGAIN_DB) * 128) / 6)) / (N_LEVELS_QGAIN - 1))
|
||||
#define silk_SMULWB(a32, b32) ((int32_t)(((a32) * (int64_t)((int16_t)(b32))) >> 16)) /* (a32 * (int32_t)((int16_t)(b32))) >> 16 output have to be 32bit int */
|
||||
#define silk_SMLAWB(a32, b32, c32) ((int32_t)((a32) + (((b32) * (int64_t)((int16_t)(c32))) >> 16))) /* a32 + (b32 * (int32_t)((int16_t)(c32))) >> 16 output have to be 32bit int */
|
||||
#define silk_SMULWT(a32, b32) ((int32_t)(((a32) * (int64_t)((b32) >> 16)) >> 16)) /* (a32 * (b32 >> 16)) >> 16 */
|
||||
#define silk_SMLAWT(a32, b32, c32) ((int32_t)((a32) + (((b32) * ((int64_t)(c32) >> 16)) >> 16)))/* a32 + (b32 * (c32 >> 16)) >> 16 */
|
||||
#define silk_SMULBB(a32, b32) ((int32_t)((int16_t)(a32)) * (int32_t)((int16_t)(b32))) /* (int32_t)((int16_t)(a3))) * (int32_t)((int16_t)(b32)) output have to be 32bit int */
|
||||
#define silk_SMLABB(a32, b32, c32) ((a32) + ((int32_t)((int16_t)(b32))) * (int32_t)((int16_t)(c32))) /* a32 + (int32_t)((int16_t)(b32)) * (int32_t)((int16_t)(c32)) output have to be 32bit int */
|
||||
#define silk_SMULBT(a32, b32) ((int32_t)((int16_t)(a32)) * ((b32) >> 16)) /* (int32_t)((int16_t)(a32)) * (b32 >> 16) */
|
||||
#define silk_SMLABT(a32, b32, c32) ((a32) + ((int32_t)((int16_t)(b32))) * ((c32) >> 16)) /* a32 + (int32_t)((int16_t)(b32)) * (c32 >> 16) */
|
||||
#define silk_SMLAL(a64, b32, c32) (silk_ADD64((a64), ((int64_t)(b32) * (int64_t)(c32)))) /* a64 + (b32 * c32) */
|
||||
#define silk_SMULWW(a32, b32) ((int32_t)(((int64_t)(a32) * (b32)) >> 16)) /* (a32 * b32) >> 16 */
|
||||
#define silk_SMLAWW(a32, b32, c32) ((int32_t)((a32) + (((int64_t)(b32) * (c32)) >> 16))) /* a32 + ((b32 * c32) >> 16) */
|
||||
#define silk_ADD_SAT32(a, b) ((((uint32_t)(a) + (uint32_t)(b)) & 0x80000000) == 0 ? \
|
||||
((((a) & (b)) & 0x80000000) != 0 ? silk_int32_MIN : (a)+(b)) : ((((a) | (b)) & 0x80000000) == 0 ? silk_int32_MAX : (a)+(b)) )
|
||||
#define silk_SUB_SAT32(a, b) ((((uint32_t)(a)-(uint32_t)(b)) & 0x80000000) == 0 ? \
|
||||
(( (a) & ((b)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a)-(b)) : ((((a)^0x80000000) & (b) & 0x80000000) ? silk_int32_MAX : (a)-(b)) )
|
||||
#define EC_CLZ0 ((int)sizeof(unsigned)*CHAR_BIT)
|
||||
#define EC_CLZ(_x) (__builtin_clz(_x))
|
||||
#define EC_ILOGs(_x) (EC_CLZ0-EC_CLZ(_x))
|
||||
#define matrix_ptr(Matrix_base_adr, row, column, N) (*((Matrix_base_adr) + ((row) * (N) + (column)))) /* Row based */
|
||||
#define matrix_adr(Matrix_base_adr, row, column, N) ((Matrix_base_adr) + ((row) * (N) + (column)))
|
||||
#define silk_VQ_WMat_EC(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, subfr_len, max_gain_Q7, L) (silk_VQ_WMat_EC_c(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, subfr_len, max_gain_Q7, L))
|
||||
#define silk_noise_shape_quantizer_short_prediction(in, coef, coefRev, order) (silk_noise_shape_quantizer_short_prediction_c(in, coef, order))
|
||||
#define silk_SMMUL(a32, b32) (int32_t) silk_RSHIFT64(silk_SMULL((a32), (b32)), 32)
|
||||
#define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D) (silk_burg_modified_c(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D))
|
||||
#define silk_inner_prod16_aligned_64(inVec1, inVec2, len) (silk_inner_prod16_aligned_64_c(inVec1, inVec2, len))
|
||||
#define silk_biquad_alt_stride2(in, B_Q28, A_Q28, S, out, len) (silk_biquad_alt_stride2_c(in, B_Q28, A_Q28, S, out, len))
|
||||
#define silk_LPC_inverse_pred_gain(A_Q12, order) (silk_LPC_inverse_pred_gain_c(A_Q12, order))
|
||||
#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ))
|
||||
#define RAND_MULTIPLIER 196314165
|
||||
#define RAND_INCREMENT 907633515
|
||||
#define silk_RAND(seed) (silk_MLA_ovflw((RAND_INCREMENT), (seed), (RAND_MULTIPLIER)))
|
||||
#define silk_NSQ_noise_shape_feedback_loop(data0, data1, coef, order) (silk_NSQ_noise_shape_feedback_loop_c(data0, data1, coef, order))
|
||||
@@ -1,191 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "silk_defines.h"
|
||||
|
||||
typedef struct {
|
||||
int8_t GainsIndices[MAX_NB_SUBFR];
|
||||
int8_t LTPIndex[MAX_NB_SUBFR];
|
||||
int8_t NLSFIndices[MAX_LPC_ORDER + 1];
|
||||
int16_t lagIndex;
|
||||
int8_t contourIndex;
|
||||
int8_t signalType;
|
||||
int8_t quantOffsetType;
|
||||
int8_t NLSFInterpCoef_Q2;
|
||||
int8_t PERIndex;
|
||||
int8_t LTP_scaleIndex;
|
||||
int8_t Seed;
|
||||
} sideInfoIndices_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t AnaState[2]; /* Analysis filterbank state: 0-8 kHz */
|
||||
int32_t AnaState1[2]; /* Analysis filterbank state: 0-4 kHz */
|
||||
int32_t AnaState2[2]; /* Analysis filterbank state: 0-2 kHz */
|
||||
int32_t XnrgSubfr[VAD_N_BANDS]; /* Subframe energies */
|
||||
int32_t NrgRatioSmth_Q8[VAD_N_BANDS]; /* Smoothed energy level in each band */
|
||||
int16_t HPstate; /* State of differentiator in the lowest band */
|
||||
int32_t NL[VAD_N_BANDS]; /* Noise energy level in each band */
|
||||
int32_t inv_NL[VAD_N_BANDS]; /* Inverse noise energy level in each band */
|
||||
int32_t NoiseLevelBias[VAD_N_BANDS]; /* Noise level estimator bias/offset */
|
||||
int32_t counter; /* Frame counter used in the initial phase */
|
||||
} silk_VAD_state_t;
|
||||
|
||||
typedef struct { /* Variable cut-off low-pass filter state */
|
||||
int32_t In_LP_State[2]; /* Low pass filter state */
|
||||
int32_t transition_frame_no; /* Counter which is mapped to a cut-off frequency */
|
||||
int32_t mode; /* Operating mode, <0: switch down, >0: switch up; 0: do nothing */
|
||||
int32_t saved_fs_kHz; /* If non-zero, holds the last sampling rate before a bandwidth switching reset. */
|
||||
} silk_LP_state_t;
|
||||
|
||||
typedef struct { /* Structure containing NLSF codebook */
|
||||
const int16_t nVectors;
|
||||
const int16_t order;
|
||||
const int16_t quantStepSize_Q16;
|
||||
const int16_t invQuantStepSize_Q6;
|
||||
const uint8_t* CB1_NLSF_Q8;
|
||||
const int16_t* CB1_Wght_Q9;
|
||||
const uint8_t* CB1_iCDF;
|
||||
const uint8_t* pred_Q8;
|
||||
const uint8_t* ec_sel;
|
||||
const uint8_t* ec_iCDF;
|
||||
const uint8_t* ec_Rates_Q5;
|
||||
const int16_t* deltaMin_Q15;
|
||||
} silk_NLSF_CB_struct_t;
|
||||
|
||||
typedef struct _silk_resampler_state_struct {
|
||||
int32_t sIIR[SILK_RESAMPLER_MAX_IIR_ORDER]; /* this must be the first element of this struct */
|
||||
union {
|
||||
int32_t i32[SILK_RESAMPLER_MAX_FIR_ORDER];
|
||||
int16_t i16[SILK_RESAMPLER_MAX_FIR_ORDER];
|
||||
} sFIR;
|
||||
int16_t delayBuf[48];
|
||||
int32_t resampler_function;
|
||||
int32_t batchSize;
|
||||
int32_t invRatio_Q16;
|
||||
int32_t FIR_Order;
|
||||
int32_t FIR_Fracs;
|
||||
int32_t Fs_in_kHz;
|
||||
int32_t Fs_out_kHz;
|
||||
int32_t inputDelay;
|
||||
const int16_t* Coefs;
|
||||
} silk_resampler_state_struct_t;
|
||||
|
||||
typedef struct {
|
||||
int16_t pred_prev_Q13[2];
|
||||
int16_t sMid[2];
|
||||
int16_t sSide[2];
|
||||
} stereo_dec_state_t;
|
||||
|
||||
/* Struct for Packet Loss Concealment */
|
||||
typedef struct {
|
||||
int32_t pitchL_Q8; /* Pitch lag to use for voiced concealment */
|
||||
int16_t LTPCoef_Q14[LTP_ORDER]; /* LTP coeficients to use for voiced concealment */
|
||||
int16_t prevLPC_Q12[MAX_LPC_ORDER];
|
||||
int32_t last_frame_lost; /* Was previous frame lost */
|
||||
int32_t rand_seed; /* Seed for unvoiced signal generation */
|
||||
int16_t randScale_Q14; /* Scaling of unvoiced random signal */
|
||||
int32_t conc_energy;
|
||||
int32_t conc_energy_shift;
|
||||
int16_t prevLTP_scale_Q14;
|
||||
int32_t prevGain_Q16[2];
|
||||
int32_t fs_kHz;
|
||||
int32_t nb_subfr;
|
||||
int32_t subfr_length;
|
||||
} silk_PLC_struct_t;
|
||||
|
||||
/* Struct for CNG */
|
||||
typedef struct {
|
||||
int32_t CNG_exc_buf_Q14[MAX_FRAME_LENGTH];
|
||||
int16_t CNG_smth_NLSF_Q15[MAX_LPC_ORDER];
|
||||
int32_t CNG_synth_state[MAX_LPC_ORDER];
|
||||
int32_t CNG_smth_Gain_Q16;
|
||||
int32_t rand_seed;
|
||||
int32_t fs_kHz;
|
||||
} silk_CNG_struct_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t prev_gain_Q16;
|
||||
int32_t exc_Q14[MAX_FRAME_LENGTH];
|
||||
int32_t sLPC_Q14_buf[MAX_LPC_ORDER];
|
||||
int16_t outBuf[MAX_FRAME_LENGTH + 2 * MAX_SUB_FRAME_LENGTH]; /* Buffer for output signal */
|
||||
int32_t lagPrev; /* Previous Lag */
|
||||
int8_t LastGainIndex; /* Previous gain index */
|
||||
int32_t fs_kHz; /* Sampling frequency in kHz */
|
||||
int32_t fs_API_hz; /* API sample frequency (Hz) */
|
||||
int32_t nb_subfr; /* Number of 5 ms subframes in a frame */
|
||||
int32_t frame_length; /* Frame length (samples) */
|
||||
int32_t subfr_length; /* Subframe length (samples) */
|
||||
int32_t ltp_mem_length; /* Length of LTP memory */
|
||||
int32_t LPC_order; /* LPC order */
|
||||
int16_t prevNLSF_Q15[MAX_LPC_ORDER]; /* Used to interpolate LSFs */
|
||||
int32_t first_frame_after_reset; /* Flag for deactivating NLSF interpolation */
|
||||
const uint8_t* pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */
|
||||
const uint8_t* pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */
|
||||
/* For buffering payload in case of more frames per packet */
|
||||
int32_t nFramesDecoded;
|
||||
int32_t nFramesPerPacket;
|
||||
/* Specifically for entropy coding */
|
||||
int32_t ec_prevSignalType;
|
||||
int16_t ec_prevLagIndex;
|
||||
int32_t VAD_flags[MAX_FRAMES_PER_PACKET];
|
||||
int32_t LBRR_flag;
|
||||
int32_t LBRR_flags[MAX_FRAMES_PER_PACKET];
|
||||
const silk_NLSF_CB_struct_t* psNLSF_CB; /* Pointer to NLSF codebook */
|
||||
sideInfoIndices_t indices; /* Quantization indices */
|
||||
silk_CNG_struct_t sCNG; /* CNG state */
|
||||
int32_t lossCnt; /* Stuff used for PLC */
|
||||
int32_t prevSignalType;
|
||||
silk_PLC_struct_t sPLC;
|
||||
} silk_decoder_state_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t pitchL[MAX_NB_SUBFR]; /* Prediction and coding parameters */
|
||||
int32_t Gains_Q16[MAX_NB_SUBFR];
|
||||
int16_t PredCoef_Q12[2][MAX_LPC_ORDER]; /* Holds interpolated and final coefficients, 4-byte aligned */
|
||||
int16_t LTPCoef_Q14[LTP_ORDER * MAX_NB_SUBFR];
|
||||
int32_t LTP_scale_Q14;
|
||||
} silk_decoder_control_t;
|
||||
|
||||
/* Decoder Super Struct */
|
||||
typedef struct {
|
||||
stereo_dec_state_t sStereo;
|
||||
int32_t nChannelsAPI;
|
||||
int32_t nChannelsInternal;
|
||||
int32_t prev_decode_only_middle;
|
||||
} silk_decoder_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t sLPC_Q14[MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH];
|
||||
int32_t RandState[DECISION_DELAY];
|
||||
int32_t Q_Q10[DECISION_DELAY];
|
||||
int32_t Xq_Q14[DECISION_DELAY];
|
||||
int32_t Pred_Q15[DECISION_DELAY];
|
||||
int32_t Shape_Q14[DECISION_DELAY];
|
||||
int32_t sAR2_Q14[MAX_SHAPE_LPC_ORDER];
|
||||
int32_t LF_AR_Q14;
|
||||
int32_t Diff_Q14;
|
||||
int32_t Seed;
|
||||
int32_t SeedInit;
|
||||
int32_t RD_Q10;
|
||||
} NSQ_del_dec_struct;
|
||||
|
||||
typedef struct {
|
||||
int32_t Q_Q10;
|
||||
int32_t RD_Q10;
|
||||
int32_t xq_Q14;
|
||||
int32_t LF_AR_Q14;
|
||||
int32_t Diff_Q14;
|
||||
int32_t sLTP_shp_Q14;
|
||||
int32_t LPC_exc_Q14;
|
||||
} NSQ_sample_struct;
|
||||
|
||||
typedef NSQ_sample_struct NSQ_sample_pair[2];
|
||||
|
||||
typedef struct {
|
||||
int32_t nChannelsAPI; /* I: Number of channels; 1/2 */
|
||||
int32_t nChannelsInternal; /* I: Number of channels; 1/2 */
|
||||
int32_t API_sampleRate; /* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
|
||||
int32_t internalSampleRate; /* I: Internal sampling rate used, in Hertz; 8000/12000/16000 */
|
||||
int32_t payloadSize_ms; /* I: Number of samples per packet in milliseconds; 10/20/40/60 */
|
||||
int32_t prevPitchLag; /* O: Pitch lag of previous frame (0 if unvoiced), measured in samples at 48 kHz */
|
||||
} silk_DecControlStruct_t;
|
||||
@@ -1,360 +0,0 @@
|
||||
#pragma once
|
||||
#include "silk.h"
|
||||
#include "silk_defines.h"
|
||||
|
||||
/* Cosine approximation table for LSF conversion */
|
||||
/* Q12 values (even) */
|
||||
static const int16_t silk_LSFCosTab_FIX_Q12[LSF_COS_TAB_SZ_FIX + 1] = {
|
||||
8192, 8190, 8182, 8170, 8152, 8130, 8104, 8072, 8034, 7994, 7946, 7896, 7840, 7778, 7714, 7644, 7568, 7490, 7406, 7318, 7226, 7128, 7026, 6922, 6812, 6698,
|
||||
6580, 6458, 6332, 6204, 6070, 5934, 5792, 5648, 5502, 5352, 5198, 5040, 4880, 4718, 4552, 4382, 4212, 4038, 3862, 3684, 3502, 3320, 3136, 2948, 2760, 2570,
|
||||
2378, 2186, 1990, 1794, 1598, 1400, 1202, 1002, 802, 602, 402, 202, 0, -202, -402, -602, -802, -1002, -1202, -1400, -1598, -1794, -1990, -2186, -2378, -2570,
|
||||
-2760, -2948, -3136, -3320, -3502, -3684, -3862, -4038, -4212, -4382, -4552, -4718, -4880, -5040, -5198, -5352, -5502, -5648, -5792, -5934, -6070, -6204, -6332, -6458, -6580, -6698,
|
||||
-6812, -6922, -7026, -7128, -7226, -7318, -7406, -7490, -7568, -7644, -7714, -7778, -7840, -7896, -7946, -7994, -8034, -8072, -8104, -8130, -8152, -8170, -8182, -8190, -8192};
|
||||
|
||||
/* Tables for stereo predictor coding */
|
||||
static const int16_t silk_stereo_pred_quant_Q13[STEREO_QUANT_TAB_SIZE] = {-13732, -10050, -8266, -7526, -6500, -5000, -2950, -820, 820, 2950, 5000, 6500, 7526, 8266, 10050, 13732};
|
||||
static const uint8_t silk_stereo_pred_joint_iCDF[25] = {249, 247, 246, 245, 244, 234, 210, 202, 201, 200, 197, 174, 82, 59, 56, 55, 54, 46, 22, 12, 11, 10, 9, 7, 0};
|
||||
static const uint8_t silk_stereo_only_code_mid_iCDF[2] = {64, 0};
|
||||
|
||||
/* Tables for LBRR flags */
|
||||
static const uint8_t silk_LBRR_flags_2_iCDF[3] = {203, 150, 0};
|
||||
static const uint8_t silk_LBRR_flags_3_iCDF[7] = {215, 195, 166, 125, 110, 82, 0};
|
||||
static const uint8_t* const silk_LBRR_flags_iCDF_ptr[2] = {silk_LBRR_flags_2_iCDF, silk_LBRR_flags_3_iCDF};
|
||||
|
||||
/* Table for LSB coding */
|
||||
static const uint8_t silk_lsb_iCDF[2] = {120, 0};
|
||||
|
||||
/* Tables for LTPScale */
|
||||
static const uint8_t silk_LTPscale_iCDF[3] = {128, 64, 0};
|
||||
|
||||
/* Tables for signal type and offset coding */
|
||||
static const uint8_t silk_type_offset_VAD_iCDF[4] = {232, 158, 10, 0};
|
||||
static const uint8_t silk_type_offset_no_VAD_iCDF[2] = {230, 0};
|
||||
|
||||
/* Tables for NLSF interpolation factor */
|
||||
static const uint8_t silk_NLSF_interpolation_factor_iCDF[5] = {243, 221, 192, 181, 0};
|
||||
|
||||
/* Quantization offsets */
|
||||
static const int16_t silk_Quantization_Offsets_Q10[2][2] = {{OFFSET_UVL_Q10, OFFSET_UVH_Q10}, {OFFSET_VL_Q10, OFFSET_VH_Q10}};
|
||||
|
||||
/* Table for LTPScale */
|
||||
static const int16_t silk_LTPScales_table_Q14[3] = {15565, 12288, 8192};
|
||||
|
||||
/* Uniform entropy tables */
|
||||
static const uint8_t silk_uniform3_iCDF[3] = {171, 85, 0};
|
||||
static const uint8_t silk_uniform4_iCDF[4] = {192, 128, 64, 0};
|
||||
static const uint8_t silk_uniform5_iCDF[5] = {205, 154, 102, 51, 0};
|
||||
static const uint8_t silk_uniform6_iCDF[6] = {213, 171, 128, 85, 43, 0};
|
||||
static const uint8_t silk_uniform8_iCDF[8] = {224, 192, 160, 128, 96, 64, 32, 0};
|
||||
|
||||
static const uint8_t silk_NLSF_EXT_iCDF[7] = {100, 40, 16, 7, 3, 1, 0};
|
||||
|
||||
/* Elliptic/Cauer filters designed with 0.1 dB passband ripple,
|
||||
80 dB minimum stopband attenuation, and
|
||||
[0.95 : 0.15 : 0.35] normalized cut off frequencies. */
|
||||
|
||||
/* Interpolation points for filter coefficients used in the bandwidth transition smoother */
|
||||
static const int32_t silk_Transition_LP_B_Q28[TRANSITION_INT_NUM][TRANSITION_NB] = {{250767114, 501534038, 250767114},
|
||||
{209867381, 419732057, 209867381},
|
||||
{170987846, 341967853, 170987846},
|
||||
{131531482, 263046905, 131531482},
|
||||
{89306658, 178584282, 89306658}};
|
||||
|
||||
/* Interpolation points for filter coefficients used in the bandwidth transition smoother */
|
||||
static const int32_t silk_Transition_LP_A_Q28[TRANSITION_INT_NUM][TRANSITION_NA] = {{506393414, 239854379},
|
||||
{411067935, 169683996},
|
||||
{306733530, 116694253},
|
||||
{185807084, 77959395},
|
||||
{35497197, 57401098}};
|
||||
|
||||
static const uint8_t silk_max_pulses_table[4] = {8, 10, 12, 16};
|
||||
|
||||
static const uint8_t silk_pulses_per_block_iCDF[10][18] = {{125, 51, 26, 18, 15, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
|
||||
{198, 105, 45, 22, 15, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
|
||||
{213, 162, 116, 83, 59, 43, 32, 24, 18, 15, 12, 9, 7, 6, 5, 3, 2, 0},
|
||||
{239, 187, 116, 59, 28, 16, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
|
||||
{250, 229, 188, 135, 86, 51, 30, 19, 13, 10, 8, 6, 5, 4, 3, 2, 1, 0},
|
||||
{249, 235, 213, 185, 156, 128, 103, 83, 66, 53, 42, 33, 26, 21, 17, 13, 10, 0},
|
||||
{254, 249, 235, 206, 164, 118, 77, 46, 27, 16, 10, 7, 5, 4, 3, 2, 1, 0},
|
||||
{255, 253, 249, 239, 220, 191, 156, 119, 85, 57, 37, 23, 15, 10, 6, 4, 2, 0},
|
||||
{255, 253, 251, 246, 237, 223, 203, 179, 152, 124, 98, 75, 55, 40, 29, 21, 15, 0},
|
||||
{255, 254, 253, 247, 220, 162, 106, 67, 42, 28, 18, 12, 9, 6, 4, 3, 2, 0}};
|
||||
|
||||
static const uint8_t silk_rate_levels_iCDF[2][9] = {{241, 190, 178, 132, 87, 74, 41, 14, 0}, {223, 193, 157, 140, 106, 57, 39, 18, 0}};
|
||||
|
||||
static const uint8_t silk_rate_levels_BITS_Q5[2][9] = {{131, 74, 141, 79, 80, 138, 95, 104, 134}, {95, 99, 91, 125, 93, 76, 123, 115, 123}};
|
||||
|
||||
static const uint8_t silk_shell_code_table0[152] = {
|
||||
128, 0, 214, 42, 0, 235, 128, 21, 0, 244, 184, 72, 11, 0, 248, 214, 128, 42, 7, 0, 248, 225, 170, 80, 25, 5, 0, 251, 236, 198, 126, 54, 18, 3, 0, 250, 238, 211,
|
||||
159, 82, 35, 15, 5, 0, 250, 231, 203, 168, 128, 88, 53, 25, 6, 0, 252, 238, 216, 185, 148, 108, 71, 40, 18, 4, 0, 253, 243, 225, 199, 166, 128, 90, 57, 31, 13, 3,
|
||||
0, 254, 246, 233, 212, 183, 147, 109, 73, 44, 23, 10, 2, 0, 255, 250, 240, 223, 198, 166, 128, 90, 58, 33, 16, 6, 1, 0, 255, 251, 244, 231, 210, 181, 146, 110, 75, 46,
|
||||
25, 12, 5, 1, 0, 255, 253, 248, 238, 221, 196, 164, 128, 92, 60, 35, 18, 8, 3, 1, 0, 255, 253, 249, 242, 229, 208, 180, 146, 110, 76, 48, 27, 14, 7, 3, 1, 0};
|
||||
|
||||
static const uint8_t silk_shell_code_table1[152] = {
|
||||
129, 0, 207, 50, 0, 236, 129, 20, 0, 245, 185, 72, 10, 0, 249, 213, 129, 42, 6, 0, 250, 226, 169, 87, 27, 4, 0, 251, 233, 194, 130, 62, 20, 4, 0, 250, 236, 207,
|
||||
160, 99, 47, 17, 3, 0, 255, 240, 217, 182, 131, 81, 41, 11, 1, 0, 255, 254, 233, 201, 159, 107, 61, 20, 2, 1, 0, 255, 249, 233, 206, 170, 128, 86, 50, 23, 7, 1,
|
||||
0, 255, 250, 238, 217, 186, 148, 108, 70, 39, 18, 6, 1, 0, 255, 252, 243, 226, 200, 166, 128, 90, 56, 30, 13, 4, 1, 0, 255, 252, 245, 231, 209, 180, 146, 110, 76, 47,
|
||||
25, 11, 4, 1, 0, 255, 253, 248, 237, 219, 194, 163, 128, 93, 62, 37, 19, 8, 3, 1, 0, 255, 254, 250, 241, 226, 205, 177, 145, 111, 79, 51, 30, 15, 6, 2, 1, 0};
|
||||
|
||||
static const uint8_t silk_shell_code_table2[152] = {
|
||||
129, 0, 203, 54, 0, 234, 129, 23, 0, 245, 184, 73, 10, 0, 250, 215, 129, 41, 5, 0, 252, 232, 173, 86, 24, 3, 0, 253, 240, 200, 129, 56, 15, 2, 0, 253, 244, 217,
|
||||
164, 94, 38, 10, 1, 0, 253, 245, 226, 189, 132, 71, 27, 7, 1, 0, 253, 246, 231, 203, 159, 105, 56, 23, 6, 1, 0, 255, 248, 235, 213, 179, 133, 85, 47, 19, 5, 1,
|
||||
0, 255, 254, 243, 221, 194, 159, 117, 70, 37, 12, 2, 1, 0, 255, 254, 248, 234, 208, 171, 128, 85, 48, 22, 8, 2, 1, 0, 255, 254, 250, 240, 220, 189, 149, 107, 67, 36,
|
||||
16, 6, 2, 1, 0, 255, 254, 251, 243, 227, 201, 166, 128, 90, 55, 29, 13, 5, 2, 1, 0, 255, 254, 252, 246, 234, 213, 183, 147, 109, 73, 43, 22, 10, 4, 2, 1, 0};
|
||||
|
||||
static const uint8_t silk_shell_code_table3[152] = {
|
||||
130, 0, 200, 58, 0, 231, 130, 26, 0, 244, 184, 76, 12, 0, 249, 214, 130, 43, 6, 0, 252, 232, 173, 87, 24, 3, 0, 253, 241, 203, 131, 56, 14, 2, 0, 254, 246, 221,
|
||||
167, 94, 35, 8, 1, 0, 254, 249, 232, 193, 130, 65, 23, 5, 1, 0, 255, 251, 239, 211, 162, 99, 45, 15, 4, 1, 0, 255, 251, 243, 223, 186, 131, 74, 33, 11, 3, 1,
|
||||
0, 255, 252, 245, 230, 202, 158, 105, 57, 24, 8, 2, 1, 0, 255, 253, 247, 235, 214, 179, 132, 84, 44, 19, 7, 2, 1, 0, 255, 254, 250, 240, 223, 196, 159, 112, 69, 36,
|
||||
15, 6, 2, 1, 0, 255, 254, 253, 245, 231, 209, 176, 136, 93, 55, 27, 11, 3, 2, 1, 0, 255, 254, 253, 252, 239, 221, 194, 158, 117, 76, 42, 18, 4, 3, 2, 1, 0};
|
||||
|
||||
static const uint8_t silk_shell_code_table_offsets[17] = {0, 0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104, 119, 135};
|
||||
|
||||
static const uint8_t silk_sign_iCDF[42] = {254, 49, 67, 77, 82, 93, 99, 198, 11, 18, 24, 31, 36, 45, 255, 46, 66, 78, 87, 94, 104,
|
||||
208, 14, 21, 32, 42, 51, 66, 255, 94, 104, 109, 112, 115, 118, 248, 53, 69, 80, 88, 95, 102};
|
||||
|
||||
static const uint8_t silk_NLSF_CB1_NB_MB_Q8[320] = {
|
||||
12, 35, 60, 83, 108, 132, 157, 180, 206, 228, 15, 32, 55, 77, 101, 125, 151, 175, 201, 225, 19, 42, 66, 89, 114, 137, 162, 184, 209, 230, 12, 25, 50, 72, 97, 120, 147, 172, 200, 223,
|
||||
26, 44, 69, 90, 114, 135, 159, 180, 205, 225, 13, 22, 53, 80, 106, 130, 156, 180, 205, 228, 15, 25, 44, 64, 90, 115, 142, 168, 196, 222, 19, 24, 62, 82, 100, 120, 145, 168, 190, 214,
|
||||
22, 31, 50, 79, 103, 120, 151, 170, 203, 227, 21, 29, 45, 65, 106, 124, 150, 171, 196, 224, 30, 49, 75, 97, 121, 142, 165, 186, 209, 229, 19, 25, 52, 70, 93, 116, 143, 166, 192, 219,
|
||||
26, 34, 62, 75, 97, 118, 145, 167, 194, 217, 25, 33, 56, 70, 91, 113, 143, 165, 196, 223, 21, 34, 51, 72, 97, 117, 145, 171, 196, 222, 20, 29, 50, 67, 90, 117, 144, 168, 197, 221,
|
||||
22, 31, 48, 66, 95, 117, 146, 168, 196, 222, 24, 33, 51, 77, 116, 134, 158, 180, 200, 224, 21, 28, 70, 87, 106, 124, 149, 170, 194, 217, 26, 33, 53, 64, 83, 117, 152, 173, 204, 225,
|
||||
27, 34, 65, 95, 108, 129, 155, 174, 210, 225, 20, 26, 72, 99, 113, 131, 154, 176, 200, 219, 34, 43, 61, 78, 93, 114, 155, 177, 205, 229, 23, 29, 54, 97, 124, 138, 163, 179, 209, 229,
|
||||
30, 38, 56, 89, 118, 129, 158, 178, 200, 231, 21, 29, 49, 63, 85, 111, 142, 163, 193, 222, 27, 48, 77, 103, 133, 158, 179, 196, 215, 232, 29, 47, 74, 99, 124, 151, 176, 198, 220, 237,
|
||||
33, 42, 61, 76, 93, 121, 155, 174, 207, 225, 29, 53, 87, 112, 136, 154, 170, 188, 208, 227, 24, 30, 52, 84, 131, 150, 166, 186, 203, 229, 37, 48, 64, 84, 104, 118, 156, 177, 201, 230};
|
||||
|
||||
static const int16_t silk_NLSF_CB1_Wght_Q9[320] = {
|
||||
2897, 2314, 2314, 2314, 2287, 2287, 2314, 2300, 2327, 2287, 2888, 2580, 2394, 2367, 2314, 2274, 2274, 2274, 2274, 2194, 2487, 2340, 2340, 2314, 2314, 2314, 2340, 2340, 2367, 2354, 3216, 2766,
|
||||
2340, 2340, 2314, 2274, 2221, 2207, 2261, 2194, 2460, 2474, 2367, 2394, 2394, 2394, 2394, 2367, 2407, 2314, 3479, 3056, 2127, 2207, 2274, 2274, 2274, 2287, 2314, 2261, 3282, 3141, 2580, 2394,
|
||||
2247, 2221, 2207, 2194, 2194, 2114, 4096, 3845, 2221, 2620, 2620, 2407, 2314, 2394, 2367, 2074, 3178, 3244, 2367, 2221, 2553, 2434, 2340, 2314, 2167, 2221, 3338, 3488, 2726, 2194, 2261, 2460,
|
||||
2354, 2367, 2207, 2101, 2354, 2420, 2327, 2367, 2394, 2420, 2420, 2420, 2460, 2367, 3779, 3629, 2434, 2527, 2367, 2274, 2274, 2300, 2207, 2048, 3254, 3225, 2713, 2846, 2447, 2327, 2300, 2300,
|
||||
2274, 2127, 3263, 3300, 2753, 2806, 2447, 2261, 2261, 2247, 2127, 2101, 2873, 2981, 2633, 2367, 2407, 2354, 2194, 2247, 2247, 2114, 3225, 3197, 2633, 2580, 2274, 2181, 2247, 2221, 2221, 2141,
|
||||
3178, 3310, 2740, 2407, 2274, 2274, 2274, 2287, 2194, 2114, 3141, 3272, 2460, 2061, 2287, 2500, 2367, 2487, 2434, 2181, 3507, 3282, 2314, 2700, 2647, 2474, 2367, 2394, 2340, 2127, 3423, 3535,
|
||||
3038, 3056, 2300, 1950, 2221, 2274, 2274, 2274, 3404, 3366, 2087, 2687, 2873, 2354, 2420, 2274, 2474, 2540, 3760, 3488, 1950, 2660, 2897, 2527, 2394, 2367, 2460, 2261, 3028, 3272, 2740, 2888,
|
||||
2740, 2154, 2127, 2287, 2234, 2247, 3695, 3657, 2025, 1969, 2660, 2700, 2580, 2500, 2327, 2367, 3207, 3413, 2354, 2074, 2888, 2888, 2340, 2487, 2247, 2167, 3338, 3366, 2846, 2780, 2327, 2154,
|
||||
2274, 2287, 2114, 2061, 2327, 2300, 2181, 2167, 2181, 2367, 2633, 2700, 2700, 2553, 2407, 2434, 2221, 2261, 2221, 2221, 2340, 2420, 2607, 2700, 3038, 3244, 2806, 2888, 2474, 2074, 2300, 2314,
|
||||
2354, 2380, 2221, 2154, 2127, 2287, 2500, 2793, 2793, 2620, 2580, 2367, 3676, 3713, 2234, 1838, 2181, 2753, 2726, 2673, 2513, 2207, 2793, 3160, 2726, 2553, 2846, 2513, 2181, 2394, 2221, 2181};
|
||||
|
||||
static const uint8_t silk_NLSF_CB1_iCDF_NB_MB[64] = {212, 178, 148, 129, 108, 96, 85, 82, 79, 77, 61, 59, 57, 56, 51, 49, 48, 45, 42, 41, 40, 38, 36, 34, 31, 30, 21, 12, 10, 3, 1, 0,
|
||||
255, 245, 244, 236, 233, 225, 217, 203, 190, 176, 175, 161, 149, 136, 125, 114, 102, 91, 81, 71, 60, 52, 43, 35, 28, 20, 19, 18, 12, 11, 5, 0};
|
||||
|
||||
static const uint8_t silk_NLSF_CB2_SELECT_NB_MB[160] = {16, 0, 0, 0, 0, 99, 66, 36, 36, 34, 36, 34, 34, 34, 34, 83, 69, 36, 52, 34, 116, 102, 70, 68, 68, 176, 102,
|
||||
68, 68, 34, 65, 85, 68, 84, 36, 116, 141, 152, 139, 170, 132, 187, 184, 216, 137, 132, 249, 168, 185, 139, 104, 102, 100, 68,
|
||||
68, 178, 218, 185, 185, 170, 244, 216, 187, 187, 170, 244, 187, 187, 219, 138, 103, 155, 184, 185, 137, 116, 183, 155, 152, 136, 132,
|
||||
217, 184, 184, 170, 164, 217, 171, 155, 139, 244, 169, 184, 185, 170, 164, 216, 223, 218, 138, 214, 143, 188, 218, 168, 244, 141, 136,
|
||||
155, 170, 168, 138, 220, 219, 139, 164, 219, 202, 216, 137, 168, 186, 246, 185, 139, 116, 185, 219, 185, 138, 100, 100, 134, 100, 102,
|
||||
34, 68, 68, 100, 68, 168, 203, 221, 218, 168, 167, 154, 136, 104, 70, 164, 246, 171, 137, 139, 137, 155, 218, 219, 139};
|
||||
|
||||
static const uint8_t silk_NLSF_CB2_iCDF_NB_MB[72] = {255, 254, 253, 238, 14, 3, 2, 1, 0, 255, 254, 252, 218, 35, 3, 2, 1, 0, 255, 254, 250, 208, 59, 4, 2, 1, 0, 255, 254, 246, 194, 71, 10, 2, 1, 0,
|
||||
255, 252, 236, 183, 82, 8, 2, 1, 0, 255, 252, 235, 180, 90, 17, 2, 1, 0, 255, 248, 224, 171, 97, 30, 4, 1, 0, 255, 254, 236, 173, 95, 37, 7, 1, 0};
|
||||
|
||||
static const uint8_t silk_NLSF_CB2_BITS_NB_MB_Q5[72] = {255, 255, 255, 131, 6, 145, 255, 255, 255, 255, 255, 236, 93, 15, 96, 255, 255, 255, 255, 255, 194, 83, 25, 71,
|
||||
221, 255, 255, 255, 255, 162, 73, 34, 66, 162, 255, 255, 255, 210, 126, 73, 43, 57, 173, 255, 255, 255, 201, 125,
|
||||
71, 48, 58, 130, 255, 255, 255, 166, 110, 73, 57, 62, 104, 210, 255, 255, 251, 123, 65, 55, 68, 100, 171, 255};
|
||||
|
||||
static const uint8_t silk_NLSF_PRED_NB_MB_Q8[18] = {179, 138, 140, 148, 151, 149, 153, 151, 163, 116, 67, 82, 59, 92, 72, 100, 89, 92};
|
||||
|
||||
static const int16_t silk_NLSF_DELTA_MIN_NB_MB_Q15[11] = {250, 3, 6, 3, 3, 3, 4, 3, 3, 3, 461};
|
||||
|
||||
static const uint8_t silk_gain_iCDF[3][N_LEVELS_QGAIN / 8] = {{224, 112, 44, 15, 3, 2, 1, 0}, {254, 237, 192, 132, 70, 23, 4, 0}, {255, 252, 226, 155, 61, 11, 2, 0}};
|
||||
|
||||
static const uint8_t silk_delta_gain_iCDF[MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1] = {250, 245, 234, 203, 71, 50, 42, 38, 35, 33, 31, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20,
|
||||
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
|
||||
|
||||
static const uint8_t silk_pitch_lag_iCDF[2 * (PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS)] = {253, 250, 244, 233, 212, 182, 150, 131, 120, 110, 98, 85, 72, 60, 49, 40,
|
||||
32, 25, 19, 15, 13, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
|
||||
|
||||
static const uint8_t silk_pitch_delta_iCDF[21] = {210, 208, 206, 203, 199, 193, 183, 168, 142, 104, 74, 52, 37, 27, 20, 14, 10, 6, 4, 2, 0};
|
||||
|
||||
static const uint8_t silk_pitch_contour_iCDF[34] = {223, 201, 183, 167, 152, 138, 124, 111, 98, 88, 79, 70, 62, 56, 50, 44, 39, 35, 31, 27, 24, 21, 18, 16, 14, 12, 10, 8, 6, 4, 3, 2, 1, 0};
|
||||
|
||||
static const uint8_t silk_pitch_contour_NB_iCDF[11] = {188, 176, 155, 138, 119, 97, 67, 43, 26, 10, 0};
|
||||
|
||||
static const uint8_t silk_pitch_contour_10_ms_iCDF[12] = {165, 119, 80, 61, 47, 35, 27, 20, 14, 9, 4, 0};
|
||||
|
||||
static const uint8_t silk_pitch_contour_10_ms_NB_iCDF[3] = {113, 63, 0};
|
||||
|
||||
static const uint8_t silk_LTP_per_index_iCDF[3] = {179, 99, 0};
|
||||
|
||||
static const uint8_t silk_LTP_gain_iCDF_0[8] = {71, 56, 43, 30, 21, 12, 6, 0};
|
||||
|
||||
static const uint8_t silk_LTP_gain_iCDF_1[16] = {199, 165, 144, 124, 109, 96, 84, 71, 61, 51, 42, 32, 23, 15, 8, 0};
|
||||
|
||||
static const uint8_t silk_LTP_gain_iCDF_2[32] = {241, 225, 211, 199, 187, 175, 164, 153, 142, 132, 123, 114, 105, 96, 88, 80, 72, 64, 57, 50, 44, 38, 33, 29, 24, 20, 16, 12, 9, 5, 2, 0};
|
||||
|
||||
static const uint8_t silk_LTP_gain_BITS_Q5_0[8] = {15, 131, 138, 138, 155, 155, 173, 173};
|
||||
|
||||
static const uint8_t silk_LTP_gain_BITS_Q5_1[16] = {69, 93, 115, 118, 131, 138, 141, 138, 150, 150, 155, 150, 155, 160, 166, 160};
|
||||
|
||||
static const uint8_t silk_LTP_gain_BITS_Q5_2[32] = {131, 128, 134, 141, 141, 141, 145, 145, 145, 150, 155, 155, 155, 155, 160, 160,
|
||||
160, 160, 166, 166, 173, 173, 182, 192, 182, 192, 192, 192, 205, 192, 205, 224};
|
||||
|
||||
static const uint8_t* const silk_LTP_gain_iCDF_ptrs[NB_LTP_CBKS] = {silk_LTP_gain_iCDF_0, silk_LTP_gain_iCDF_1, silk_LTP_gain_iCDF_2};
|
||||
|
||||
static const uint8_t* const silk_LTP_gain_BITS_Q5_ptrs[NB_LTP_CBKS] = {silk_LTP_gain_BITS_Q5_0, silk_LTP_gain_BITS_Q5_1, silk_LTP_gain_BITS_Q5_2};
|
||||
|
||||
static const int8_t silk_LTP_gain_vq_0[8][5] = {{4, 6, 24, 7, 5}, {0, 0, 2, 0, 0}, {12, 28, 41, 13, -4}, {-9, 15, 42, 25, 14},
|
||||
{1, -2, 62, 41, -9}, {-10, 37, 65, -4, 3}, {-6, 4, 66, 7, -8}, {16, 14, 38, -3, 33}};
|
||||
|
||||
static const int8_t silk_LTP_gain_vq_1[16][5] = {{13, 22, 39, 23, 12}, {-1, 36, 64, 27, -6}, {-7, 10, 55, 43, 17}, {1, 1, 8, 1, 1}, {6, -11, 74, 53, -9}, {-12, 55, 76, -12, 8},
|
||||
{-3, 3, 93, 27, -4}, {26, 39, 59, 3, -8}, {2, 0, 77, 11, 9}, {-8, 22, 44, -6, 7}, {40, 9, 26, 3, 9}, {-7, 20, 101, -7, 4},
|
||||
{3, -8, 42, 26, 0}, {-15, 33, 68, 2, 23}, {-2, 55, 46, -2, 15}, {3, -1, 21, 16, 41}};
|
||||
|
||||
static const int8_t silk_LTP_gain_vq_2[32][5] = {
|
||||
{-6, 27, 61, 39, 5}, {-11, 42, 88, 4, 1}, {-2, 60, 65, 6, -4}, {-1, -5, 73, 56, 1}, {-9, 19, 94, 29, -9}, {0, 12, 99, 6, 4}, {8, -19, 102, 46, -13}, {3, 2, 13, 3, 2},
|
||||
{9, -21, 84, 72, -18}, {-11, 46, 104, -22, 8}, {18, 38, 48, 23, 0}, {-16, 70, 83, -21, 11}, {5, -11, 117, 22, -8}, {-6, 23, 117, -12, 3}, {3, -8, 95, 28, 4}, {-10, 15, 77, 60, -15},
|
||||
{-1, 4, 124, 2, -4}, {3, 38, 84, 24, -25}, {2, 13, 42, 13, 31}, {21, -4, 56, 46, -1}, {-1, 35, 79, -13, 19}, {-7, 65, 88, -9, -14}, {20, 4, 81, 49, -29}, {20, 0, 75, 3, -17},
|
||||
{5, -9, 44, 92, -8}, {1, -3, 22, 69, 31}, {-6, 95, 41, -12, 5}, {39, 67, 16, -4, 1}, {0, -6, 120, 55, -36}, {-13, 44, 122, 4, -24}, {81, 5, 11, 3, 7}, {2, 0, 9, 10, 88}};
|
||||
|
||||
static const uint8_t silk_NLSF_CB1_WB_Q8[512] = {
|
||||
7, 23, 38, 54, 69, 85, 100, 116, 131, 147, 162, 178, 193, 208, 223, 239, 13, 25, 41, 55, 69, 83, 98, 112, 127, 142, 157, 171, 187, 203, 220, 236, 15, 21, 34, 51, 61,
|
||||
78, 92, 106, 126, 136, 152, 167, 185, 205, 225, 240, 10, 21, 36, 50, 63, 79, 95, 110, 126, 141, 157, 173, 189, 205, 221, 237, 17, 20, 37, 51, 59, 78, 89, 107, 123, 134,
|
||||
150, 164, 184, 205, 224, 240, 10, 15, 32, 51, 67, 81, 96, 112, 129, 142, 158, 173, 189, 204, 220, 236, 8, 21, 37, 51, 65, 79, 98, 113, 126, 138, 155, 168, 179, 192, 209,
|
||||
218, 12, 15, 34, 55, 63, 78, 87, 108, 118, 131, 148, 167, 185, 203, 219, 236, 16, 19, 32, 36, 56, 79, 91, 108, 118, 136, 154, 171, 186, 204, 220, 237, 11, 28, 43, 58,
|
||||
74, 89, 105, 120, 135, 150, 165, 180, 196, 211, 226, 241, 6, 16, 33, 46, 60, 75, 92, 107, 123, 137, 156, 169, 185, 199, 214, 225, 11, 19, 30, 44, 57, 74, 89, 105, 121,
|
||||
135, 152, 169, 186, 202, 218, 234, 12, 19, 29, 46, 57, 71, 88, 100, 120, 132, 148, 165, 182, 199, 216, 233, 17, 23, 35, 46, 56, 77, 92, 106, 123, 134, 152, 167, 185, 204,
|
||||
222, 237, 14, 17, 45, 53, 63, 75, 89, 107, 115, 132, 151, 171, 188, 206, 221, 240, 9, 16, 29, 40, 56, 71, 88, 103, 119, 137, 154, 171, 189, 205, 222, 237, 16, 19, 36,
|
||||
48, 57, 76, 87, 105, 118, 132, 150, 167, 185, 202, 218, 236, 12, 17, 29, 54, 71, 81, 94, 104, 126, 136, 149, 164, 182, 201, 221, 237, 15, 28, 47, 62, 79, 97, 115, 129,
|
||||
142, 155, 168, 180, 194, 208, 223, 238, 8, 14, 30, 45, 62, 78, 94, 111, 127, 143, 159, 175, 192, 207, 223, 239, 17, 30, 49, 62, 79, 92, 107, 119, 132, 145, 160, 174, 190,
|
||||
204, 220, 235, 14, 19, 36, 45, 61, 76, 91, 108, 121, 138, 154, 172, 189, 205, 222, 238, 12, 18, 31, 45, 60, 76, 91, 107, 123, 138, 154, 171, 187, 204, 221, 236, 13, 17,
|
||||
31, 43, 53, 70, 83, 103, 114, 131, 149, 167, 185, 203, 220, 237, 17, 22, 35, 42, 58, 78, 93, 110, 125, 139, 155, 170, 188, 206, 224, 240, 8, 15, 34, 50, 67, 83, 99,
|
||||
115, 131, 146, 162, 178, 193, 209, 224, 239, 13, 16, 41, 66, 73, 86, 95, 111, 128, 137, 150, 163, 183, 206, 225, 241, 17, 25, 37, 52, 63, 75, 92, 102, 119, 132, 144, 160,
|
||||
175, 191, 212, 231, 19, 31, 49, 65, 83, 100, 117, 133, 147, 161, 174, 187, 200, 213, 227, 242, 18, 31, 52, 68, 88, 103, 117, 126, 138, 149, 163, 177, 192, 207, 223, 239, 16,
|
||||
29, 47, 61, 76, 90, 106, 119, 133, 147, 161, 176, 193, 209, 224, 240, 15, 21, 35, 50, 61, 73, 86, 97, 110, 119, 129, 141, 175, 198, 218, 237};
|
||||
|
||||
static const int16_t silk_NLSF_CB1_WB_Wght_Q9[512] = {
|
||||
3657, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2963, 2963, 2925, 2846, 3216, 3085, 2972, 3056, 3056, 3010, 3010, 3010, 2963, 2963, 3010, 2972, 2888, 2846, 2846, 2726,
|
||||
3920, 4014, 2981, 3207, 3207, 2934, 3056, 2846, 3122, 3244, 2925, 2846, 2620, 2553, 2780, 2925, 3516, 3197, 3010, 3103, 3019, 2888, 2925, 2925, 2925, 2925, 2888, 2888, 2888, 2888, 2888, 2753,
|
||||
5054, 5054, 2934, 3573, 3385, 3056, 3085, 2793, 3160, 3160, 2972, 2846, 2513, 2540, 2753, 2888, 4428, 4149, 2700, 2753, 2972, 3010, 2925, 2846, 2981, 3019, 2925, 2925, 2925, 2925, 2888, 2726,
|
||||
3620, 3019, 2972, 3056, 3056, 2873, 2806, 3056, 3216, 3047, 2981, 3291, 3291, 2981, 3310, 2991, 5227, 5014, 2540, 3338, 3526, 3385, 3197, 3094, 3376, 2981, 2700, 2647, 2687, 2793, 2846, 2673,
|
||||
5081, 5174, 4615, 4428, 2460, 2897, 3047, 3207, 3169, 2687, 2740, 2888, 2846, 2793, 2846, 2700, 3122, 2888, 2963, 2925, 2925, 2925, 2925, 2963, 2963, 2963, 2963, 2925, 2925, 2963, 2963, 2963,
|
||||
4202, 3207, 2981, 3103, 3010, 2888, 2888, 2925, 2972, 2873, 2916, 3019, 2972, 3010, 3197, 2873, 3760, 3760, 3244, 3103, 2981, 2888, 2925, 2888, 2972, 2934, 2793, 2793, 2846, 2888, 2888, 2660,
|
||||
3854, 4014, 3207, 3122, 3244, 2934, 3047, 2963, 2963, 3085, 2846, 2793, 2793, 2793, 2793, 2580, 3845, 4080, 3357, 3516, 3094, 2740, 3010, 2934, 3122, 3085, 2846, 2846, 2647, 2647, 2846, 2806,
|
||||
5147, 4894, 3225, 3845, 3441, 3169, 2897, 3413, 3451, 2700, 2580, 2673, 2740, 2846, 2806, 2753, 4109, 3789, 3291, 3160, 2925, 2888, 2888, 2925, 2793, 2740, 2793, 2740, 2793, 2846, 2888, 2806,
|
||||
5081, 5054, 3047, 3545, 3244, 3056, 3085, 2944, 3103, 2897, 2740, 2740, 2740, 2846, 2793, 2620, 4309, 4309, 2860, 2527, 3207, 3376, 3376, 3075, 3075, 3376, 3056, 2846, 2647, 2580, 2726, 2753,
|
||||
3056, 2916, 2806, 2888, 2740, 2687, 2897, 3103, 3150, 3150, 3216, 3169, 3056, 3010, 2963, 2846, 4375, 3882, 2925, 2888, 2846, 2888, 2846, 2846, 2888, 2888, 2888, 2846, 2888, 2925, 2888, 2846,
|
||||
2981, 2916, 2916, 2981, 2981, 3056, 3122, 3216, 3150, 3056, 3010, 2972, 2972, 2972, 2925, 2740, 4229, 4149, 3310, 3347, 2925, 2963, 2888, 2981, 2981, 2846, 2793, 2740, 2846, 2846, 2846, 2793,
|
||||
4080, 4014, 3103, 3010, 2925, 2925, 2925, 2888, 2925, 2925, 2846, 2846, 2846, 2793, 2888, 2780, 4615, 4575, 3169, 3441, 3207, 2981, 2897, 3038, 3122, 2740, 2687, 2687, 2687, 2740, 2793, 2700,
|
||||
4149, 4269, 3789, 3657, 2726, 2780, 2888, 2888, 3010, 2972, 2925, 2846, 2687, 2687, 2793, 2888, 4215, 3554, 2753, 2846, 2846, 2888, 2888, 2888, 2925, 2925, 2888, 2925, 2925, 2925, 2963, 2888,
|
||||
5174, 4921, 2261, 3432, 3789, 3479, 3347, 2846, 3310, 3479, 3150, 2897, 2460, 2487, 2753, 2925, 3451, 3685, 3122, 3197, 3357, 3047, 3207, 3207, 2981, 3216, 3085, 2925, 2925, 2687, 2540, 2434,
|
||||
2981, 3010, 2793, 2793, 2740, 2793, 2846, 2972, 3056, 3103, 3150, 3150, 3150, 3103, 3010, 3010, 2944, 2873, 2687, 2726, 2780, 3010, 3432, 3545, 3357, 3244, 3056, 3010, 2963, 2925, 2888, 2846,
|
||||
3019, 2944, 2897, 3010, 3010, 2972, 3019, 3103, 3056, 3056, 3010, 2888, 2846, 2925, 2925, 2888, 3920, 3967, 3010, 3197, 3357, 3216, 3291, 3291, 3479, 3704, 3441, 2726, 2181, 2460, 2580, 2607};
|
||||
|
||||
static const uint8_t silk_NLSF_CB1_iCDF_WB[64] = {225, 204, 201, 184, 183, 175, 158, 154, 153, 135, 119, 115, 113, 110, 109, 99, 98, 95, 79, 68, 52, 50, 48, 45, 43, 32, 31, 27, 18, 10, 3, 0,
|
||||
255, 251, 235, 230, 212, 201, 196, 182, 167, 166, 163, 151, 138, 124, 110, 104, 90, 78, 76, 70, 69, 57, 45, 34, 24, 21, 11, 6, 5, 4, 3, 0};
|
||||
|
||||
static const uint8_t silk_NLSF_CB2_SELECT_WB[256] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 100, 102, 102, 68, 68, 36, 34, 96, 164, 107, 158, 185, 180, 185, 139, 102, 64, 66, 36, 34, 34, 0, 1, 32, 208, 139, 141, 191, 152,
|
||||
185, 155, 104, 96, 171, 104, 166, 102, 102, 102, 132, 1, 0, 0, 0, 0, 16, 16, 0, 80, 109, 78, 107, 185, 139, 103, 101, 208, 212, 141, 139, 173, 153, 123, 103, 36, 0,
|
||||
0, 0, 0, 0, 0, 1, 48, 0, 0, 0, 0, 0, 0, 32, 68, 135, 123, 119, 119, 103, 69, 98, 68, 103, 120, 118, 118, 102, 71, 98, 134, 136, 157, 184, 182, 153, 139,
|
||||
134, 208, 168, 248, 75, 189, 143, 121, 107, 32, 49, 34, 34, 34, 0, 17, 2, 210, 235, 139, 123, 185, 137, 105, 134, 98, 135, 104, 182, 100, 183, 171, 134, 100, 70, 68, 70,
|
||||
66, 66, 34, 131, 64, 166, 102, 68, 36, 2, 1, 0, 134, 166, 102, 68, 34, 34, 66, 132, 212, 246, 158, 139, 107, 107, 87, 102, 100, 219, 125, 122, 137, 118, 103, 132, 114,
|
||||
135, 137, 105, 171, 106, 50, 34, 164, 214, 141, 143, 185, 151, 121, 103, 192, 34, 0, 0, 0, 0, 0, 1, 208, 109, 74, 187, 134, 249, 159, 137, 102, 110, 154, 118, 87, 101,
|
||||
119, 101, 0, 2, 0, 36, 36, 66, 68, 35, 96, 164, 102, 100, 36, 0, 2, 33, 167, 138, 174, 102, 100, 84, 2, 2, 100, 107, 120, 119, 36, 197, 24, 0};
|
||||
|
||||
static const uint8_t silk_NLSF_CB2_iCDF_WB[72] = {255, 254, 253, 244, 12, 3, 2, 1, 0, 255, 254, 252, 224, 38, 3, 2, 1, 0, 255, 254, 251, 209, 57, 4, 2, 1, 0, 255, 254, 244, 195, 69, 4, 2, 1, 0,
|
||||
255, 251, 232, 184, 84, 7, 2, 1, 0, 255, 254, 240, 186, 86, 14, 2, 1, 0, 255, 254, 239, 178, 91, 30, 5, 1, 0, 255, 248, 227, 177, 100, 19, 2, 1, 0};
|
||||
|
||||
static const uint8_t silk_NLSF_CB2_BITS_WB_Q5[72] = {255, 255, 255, 156, 4, 154, 255, 255, 255, 255, 255, 227, 102, 15, 92, 255, 255, 255, 255, 255, 213, 83, 24, 72,
|
||||
236, 255, 255, 255, 255, 150, 76, 33, 63, 214, 255, 255, 255, 190, 121, 77, 43, 55, 185, 255, 255, 255, 245, 137,
|
||||
71, 43, 59, 139, 255, 255, 255, 255, 131, 66, 50, 66, 107, 194, 255, 255, 166, 116, 76, 55, 53, 125, 255, 255};
|
||||
|
||||
static const uint8_t silk_NLSF_PRED_WB_Q8[30] = {175, 148, 160, 176, 178, 173, 174, 164, 177, 174, 196, 182, 198, 192, 182, 68, 62, 66, 60, 72, 117, 85, 90, 118, 136, 151, 142, 160, 142, 155};
|
||||
|
||||
static const int16_t silk_NLSF_DELTA_MIN_WB_Q15[17] = {100, 3, 40, 3, 3, 3, 5, 14, 14, 10, 11, 3, 8, 9, 7, 3, 347};
|
||||
|
||||
static const int8_t silk_CB_lags_stage2_10_ms[PE_MAX_NB_SUBFR >> 1][PE_NB_CBKS_STAGE2_10MS] = {{0, 1, 0}, {0, 0, 1}};
|
||||
|
||||
static const int8_t silk_CB_lags_stage3_10_ms[PE_MAX_NB_SUBFR >> 1][PE_NB_CBKS_STAGE3_10MS] = {{0, 0, 1, -1, 1, -1, 2, -2, 2, -2, 3, -3}, {0, 1, 0, 1, -1, 2, -1, 2, -2, 3, -2, 3}};
|
||||
|
||||
static const int8_t silk_Lag_range_stage3_10_ms[PE_MAX_NB_SUBFR >> 1][2] = {{-3, 7}, {-2, 7}};
|
||||
|
||||
static const int8_t silk_CB_lags_stage2[PE_MAX_NB_SUBFR][PE_NB_CBKS_STAGE2_EXT] = {{0, 2, -1, -1, -1, 0, 0, 1, 1, 0, 1},
|
||||
{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0},
|
||||
{0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0},
|
||||
{0, -1, 2, 1, 0, 1, 1, 0, 0, -1, -1}};
|
||||
|
||||
static const int8_t silk_CB_lags_stage3[PE_MAX_NB_SUBFR][PE_NB_CBKS_STAGE3_MAX] = {
|
||||
{0, 0, 1, -1, 0, 1, -1, 0, -1, 1, -2, 2, -2, -2, 2, -3, 2, 3, -3, -4, 3, -4, 4, 4, -5, 5, -6, -5, 6, -7, 6, 5, 8, -9},
|
||||
{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 1, -1, 0, 1, -1, -1, 1, -1, 2, 1, -1, 2, -2, -2, 2, -2, 2, 2, 3, -3},
|
||||
{0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, -1, 1, 0, 0, 2, 1, -1, 2, -1, -1, 2, -1, 2, 2, -1, 3, -2, -2, -2, 3},
|
||||
{0, 1, 0, 0, 1, 0, 1, -1, 2, -1, 2, -1, 2, 3, -2, 3, -2, -2, 4, 4, -3, 5, -3, -4, 6, -4, 6, 5, -5, 8, -6, -5, -7, 9}};
|
||||
|
||||
static const int8_t silk_Lag_range_stage3[SILK_PE_MAX_COMPLEX + 1][PE_MAX_NB_SUBFR][2] = {
|
||||
/* Lags to search for low number of stage3 cbks */
|
||||
{{-5, 8}, {-1, 6}, {-1, 6}, {-4, 10}},
|
||||
/* Lags to search for middle number of stage3 cbks */
|
||||
{{-6, 10}, {-2, 6}, {-1, 6}, {-5, 10}},
|
||||
/* Lags to search for max number of stage3 cbks */
|
||||
{{-9, 12}, {-3, 7}, {-2, 7}, {-7, 13}}};
|
||||
|
||||
/* Tables with delay compensation values to equalize total delay for different modes */
|
||||
static const int8_t delay_matrix_enc[5][3] = {
|
||||
/* in \ out 8 12 16 */
|
||||
/* 8 */ {6, 0, 3},
|
||||
/* 12 */ {0, 7, 3},
|
||||
/* 16 */ {0, 1, 10},
|
||||
/* 24 */ {0, 2, 6},
|
||||
/* 48 */ {18, 10, 12}};
|
||||
|
||||
static const int8_t delay_matrix_dec[3][5] = {
|
||||
/* in \ out 8 12 16 24 48 */
|
||||
/* 8 */ {4, 0, 2, 0, 0},
|
||||
/* 12 */ {0, 9, 4, 7, 4},
|
||||
/* 16 */ {0, 3, 12, 7, 7}};
|
||||
|
||||
/* Tables with IIR and FIR coefficients for fractional downsamplers (123 Words) */
|
||||
static const int16_t silk_Resampler_3_4_COEFS[2 + 3 * RESAMPLER_DOWN_ORDER_FIR0 / 2] = {
|
||||
-20694, -13867, -49, 64, 17, -157, 353, -496, 163, 11047, 22205, -39, 6, 91, -170, 186, 23, -896, 6336, 19928, -19, -36, 102, -89, -24, 328, -951, 2568, 15909,
|
||||
};
|
||||
|
||||
static const int16_t silk_Resampler_2_3_COEFS[2 + 2 * RESAMPLER_DOWN_ORDER_FIR0 / 2] = {
|
||||
-14457, -14019, 64, 128, -122, 36, 310, -768, 584, 9267, 17733, 12, 128, 18, -142, 288, -117, -865, 4123, 14459,
|
||||
};
|
||||
|
||||
static const int16_t silk_Resampler_1_2_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR1 / 2] = {
|
||||
616, -14323, -10, 39, 58, -46, -84, 120, 184, -315, -541, 1284, 5380, 9024,
|
||||
};
|
||||
|
||||
static const int16_t silk_Resampler_1_3_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR2 / 2] = {
|
||||
16102, -15162, -13, 0, 20, 26, 5, -31, -43, -4, 65, 90, 7, -157, -248, -44, 593, 1583, 2612, 3271,
|
||||
};
|
||||
|
||||
static const int16_t silk_Resampler_1_4_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR2 / 2] = {
|
||||
22500, -15099, 3, -14, -20, -15, 2, 25, 37, 25, -16, -71, -107, -79, 50, 292, 623, 982, 1288, 1464,
|
||||
};
|
||||
|
||||
static const int16_t silk_Resampler_1_6_COEFS[2 + RESAMPLER_DOWN_ORDER_FIR2 / 2] = {
|
||||
27540, -15257, 17, 12, 8, 1, -10, -22, -30, -32, -22, 3, 44, 100, 168, 243, 317, 381, 429, 455,
|
||||
};
|
||||
|
||||
static const int16_t silk_Resampler_2_3_COEFS_LQ[2 + 2 * 2] = {
|
||||
-2797, -6507, 4697, 10739, 1567, 8276,
|
||||
};
|
||||
|
||||
/* Table with interplation fractions of 1/24, 3/24, 5/24, ... , 23/24 : 23/24 (46 Words) */
|
||||
static const int16_t silk_resampler_frac_FIR_12[12][RESAMPLER_ORDER_FIR_12 / 2] = {
|
||||
{189, -600, 617, 30567}, {117, -159, -1070, 29704}, {52, 221, -2392, 28276}, {-4, 529, -3350, 26341}, {-48, 758, -3956, 23973}, {-80, 905, -4235, 21254},
|
||||
{-99, 972, -4222, 18278}, {-107, 967, -3957, 15143}, {-103, 896, -3487, 11950}, {-91, 773, -2865, 8798}, {-71, 611, -2143, 5784}, {-46, 425, -1375, 2996},
|
||||
};
|
||||
|
||||
static const int16_t HARM_ATT_Q15[NB_ATT] = {32440, 31130}; /* 0.99, 0.95 */
|
||||
static const int16_t PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = {31130, 26214}; /* 0.95, 0.8 */
|
||||
static const int16_t PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = {32440, 29491}; /* 0.99, 0.9 */
|
||||
|
||||
/* Tables for 2x downsampler */
|
||||
static const int16_t silk_resampler_down2_0 = 9872;
|
||||
static const int16_t silk_resampler_down2_1 = 39809 - 65536;
|
||||
|
||||
/* Tables for 2x upsampler, high quality */
|
||||
static const int16_t silk_resampler_up2_hq_0[3] = {1746, 14986, 39083 - 65536};
|
||||
static const int16_t silk_resampler_up2_hq_1[3] = {6854, 25769, 55542 - 65536};
|
||||
|
||||
/* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */
|
||||
static const int32_t sigm_LUT_slope_Q10[6] = {237, 153, 73, 30, 12, 7};
|
||||
/* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp(-(0:5))))); */
|
||||
static const int32_t sigm_LUT_pos_Q15[6] = {16384, 23955, 28861, 31213, 32178, 32548};
|
||||
/* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp((0:5))))); */
|
||||
static const int32_t sigm_LUT_neg_Q15[6] = {16384, 8812, 3906, 1554, 589, 219};
|
||||
|
||||
static const int8_t silk_nb_cbk_searchs_stage3[SILK_PE_MAX_COMPLEX + 1] = {PE_NB_CBKS_STAGE3_MIN, PE_NB_CBKS_STAGE3_MID, PE_NB_CBKS_STAGE3_MAX};
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,418 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
// #pragma GCC optimize ("O3")
|
||||
// #pragma GCC diagnostic ignored "-Wnarrowing"
|
||||
|
||||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
||||
* by the Xiph.Org Foundation https://xiph.org/ *
|
||||
* *
|
||||
********************************************************************/
|
||||
/*
|
||||
* vorbis_decoder.h
|
||||
* based on Xiph.Org Foundation vorbis decoder
|
||||
* adapted for the ESP32 by schreibfaul1
|
||||
*
|
||||
* Created on: 13.02.2023
|
||||
* Updated on: 19.06.2025
|
||||
*/
|
||||
|
||||
#include "../Audio.h"
|
||||
#include "../psram_unique_ptr.hpp"
|
||||
|
||||
class VorbisDecoder : public Decoder {
|
||||
|
||||
public:
|
||||
VorbisDecoder(Audio& audioRef) : Decoder(audioRef), audio(audioRef) {}
|
||||
~VorbisDecoder() { reset(); }
|
||||
bool init() override;
|
||||
void clear() override;
|
||||
void reset() override;
|
||||
bool isValid() override;
|
||||
int32_t findSyncWord(uint8_t* buf, int32_t nBytes) override;
|
||||
uint8_t getChannels() override;
|
||||
uint32_t getSampleRate() override;
|
||||
uint32_t getOutputSamples();
|
||||
uint8_t getBitsPerSample() override;
|
||||
uint32_t getBitRate() override;
|
||||
uint32_t getAudioDataStart() override;
|
||||
uint32_t getAudioFileDuration() override;
|
||||
const char* getStreamTitle() override;
|
||||
const char* whoIsIt() override;
|
||||
int32_t decode(uint8_t* inbuf, int32_t* bytesLeft, int32_t* outbuf) override;
|
||||
void setRawBlockParams(uint8_t channels, uint32_t sampleRate, uint8_t BPS, uint32_t tsis, uint32_t AuDaLength) override;
|
||||
std::vector<uint32_t> getMetadataBlockPicture() override;
|
||||
const char* arg1() override;
|
||||
const char* arg2() override;
|
||||
virtual int32_t val1() override;
|
||||
virtual int32_t val2() override;
|
||||
|
||||
enum : int8_t { VORBIS_CONTINUE = 110, VORBIS_PARSE_OGG_DONE = 100, VORBIS_NONE = 0, VORBIS_ERR = -1 };
|
||||
enum ParseResult { VORBIS_COMMENT_INVALID = -1, VORBIS_COMMENT_NEED_MORE = 100, VORBIS_COMMENT_DONE = 110 };
|
||||
|
||||
private:
|
||||
Audio& audio;
|
||||
|
||||
#define VI_FLOORB 2
|
||||
#define VIF_POSIT 63
|
||||
|
||||
#define LSP_FRACBITS 14
|
||||
|
||||
#define OV_EREAD -128
|
||||
#define OV_EFAULT -129
|
||||
#define OV_EIMPL -130
|
||||
#define OV_EINVAL -131
|
||||
#define OV_ENOTVORBIS -132
|
||||
#define OV_EBADHEADER -133
|
||||
#define OV_EVERSION -134
|
||||
#define OV_ENOTAUDIO -135
|
||||
#define OV_EBADPACKET -136
|
||||
#define OV_EBADLINK -137
|
||||
#define OV_ENOSEEK -138
|
||||
|
||||
#define INVSQ_LOOKUP_I_SHIFT 10
|
||||
#define INVSQ_LOOKUP_I_MASK 1023
|
||||
#define COS_LOOKUP_I_SHIFT 9
|
||||
#define COS_LOOKUP_I_MASK 511
|
||||
#define COS_LOOKUP_I_SZ 128
|
||||
|
||||
#define cPI3_8 (0x30fbc54d)
|
||||
#define cPI2_8 (0x5a82799a)
|
||||
#define cPI1_8 (0x7641af3d)
|
||||
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const uint32_t mask[33] = {0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff,
|
||||
0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff,
|
||||
0x003fffff, 0x007fffff, 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const uint16_t barklook[54] = {0, 51, 102, 154, 206, 258, 311, 365, 420, 477, 535, 594, 656, 719, 785, 854, 926, 1002,
|
||||
1082, 1166, 1256, 1352, 1454, 1564, 1683, 1812, 1953, 2107, 2276, 2463, 2670, 2900, 3155, 3440, 3756, 4106,
|
||||
4493, 4919, 5387, 5901, 6466, 7094, 7798, 8599, 9528, 10623, 11935, 13524, 15453, 17775, 20517, 23667, 27183, 31004};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const uint8_t MLOOP_1[64] = {
|
||||
0, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const uint8_t MLOOP_2[64] = {
|
||||
0, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
const uint8_t MLOOP_3[8] = {0, 1, 2, 2, 3, 3, 3, 3};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in 16.16 format returns in m.8 format */
|
||||
int32_t ADJUST_SQRT2[2] = {8192, 5792};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
typedef struct {
|
||||
char class_dim; /* 1 to 8 */
|
||||
char class_subs; /* 0,1,2,3 (bits: 1<<n poss) */
|
||||
uint8_t class_book; /* subs ^ dim entries */
|
||||
uint8_t class_subbook[8]; /* [VIF_CLASS][subs] */
|
||||
} floor1class_t;
|
||||
|
||||
typedef struct _submap {
|
||||
char floor;
|
||||
char residue;
|
||||
} submap_t;
|
||||
|
||||
typedef struct _coupling_step { // Mapping backend generic
|
||||
uint8_t mag;
|
||||
uint8_t ang;
|
||||
} coupling_step_t;
|
||||
|
||||
typedef struct { // mode
|
||||
uint8_t blockflag;
|
||||
uint8_t mapping;
|
||||
} vorbis_info_mode_t;
|
||||
|
||||
typedef struct _bitreader {
|
||||
uint8_t* data{}; // Anfang des Puffers
|
||||
uint8_t* headptr{}; // Aktuelle Leseposition (Byte)
|
||||
uint32_t length{}; // Gesamtlänge in Bytes
|
||||
uint32_t headend{}; // Verbleibende Bytes ab headptr
|
||||
uint8_t headbit{}; // Aktuelle Bitposition im Byte (0–7)
|
||||
|
||||
void reset() {
|
||||
*this = _bitreader{}; // reinitialize cleanly
|
||||
}
|
||||
} bitReader_t;
|
||||
bitReader_t m_bitReader;
|
||||
|
||||
union magic {
|
||||
struct {
|
||||
int32_t lo;
|
||||
int32_t hi;
|
||||
} halves;
|
||||
int64_t whole;
|
||||
};
|
||||
struct vorbis_dsp_state { // vorbis_dsp_state buffers the current vorbis audio analysis/synthesis state.
|
||||
ps_ptr<ps_ptr<int32_t>> work;
|
||||
ps_ptr<ps_ptr<int32_t>> mdctright;
|
||||
int32_t lW = 0; // last window
|
||||
int32_t W = 0; // window
|
||||
int32_t out_begin = -1;
|
||||
int32_t out_end = -1;
|
||||
};
|
||||
|
||||
struct vorbis_info_mapping {
|
||||
int32_t submaps{};
|
||||
ps_ptr<uint8_t> chmuxlist{};
|
||||
ps_ptr<submap_t> submaplist{};
|
||||
int32_t coupling_steps{};
|
||||
ps_ptr<coupling_step_t> coupling{};
|
||||
|
||||
void reset() {
|
||||
*this = vorbis_info_mapping{}; // sauber neu initialisieren
|
||||
}
|
||||
};
|
||||
|
||||
struct vorbis_info_residue {
|
||||
int32_t type{};
|
||||
ps_ptr<uint8_t> stagemasks{};
|
||||
ps_ptr<uint8_t> stagebooks{};
|
||||
/* block-partitioned VQ coded straight residue */
|
||||
uint32_t begin{};
|
||||
uint32_t end{};
|
||||
/* first stage (lossless partitioning) */
|
||||
uint32_t grouping{}; /* group n vectors per partition */
|
||||
char partitions{}; /* possible codebooks for a partition */
|
||||
uint8_t groupbook{}; /* huffbook for partitioning */
|
||||
char stages{};
|
||||
|
||||
void reset() {
|
||||
*this = vorbis_info_residue{}; // reinitialize cleanly
|
||||
}
|
||||
};
|
||||
|
||||
struct vorbis_info_floor {
|
||||
int32_t order{};
|
||||
int32_t rate{};
|
||||
int32_t barkmap{};
|
||||
int32_t ampbits{};
|
||||
int32_t ampdB{};
|
||||
int32_t numbooks{}; /* <= 16 */
|
||||
char books[16]{};
|
||||
ps_ptr<floor1class_t> _class{}; /* [VIF_CLASS] */
|
||||
ps_ptr<uint8_t> partitionclass{}; /* [VIF_PARTS]; 0 to 15 */
|
||||
ps_ptr<uint16_t> postlist{}; /* [VIF_POSIT+2]; first two implicit */
|
||||
ps_ptr<uint8_t> forward_index{}; /* [VIF_POSIT+2]; */
|
||||
ps_ptr<uint8_t> hineighbor{}; /* [VIF_POSIT]; */
|
||||
ps_ptr<uint8_t> loneighbor{}; /* [VIF_POSIT]; */
|
||||
int32_t partitions{}; /* 0 to 31 */
|
||||
int32_t posts{};
|
||||
int32_t mult{}; /* 1 2 3 or 4 */
|
||||
};
|
||||
|
||||
typedef struct _codebook {
|
||||
uint8_t dim{}; /* codebook dimensions (elements per vector) */
|
||||
int16_t entries{}; /* codebook entries */
|
||||
uint16_t used_entries{}; /* populated codebook entries */
|
||||
uint32_t dec_maxlength{};
|
||||
ps_ptr<uint16_t> dec_table{};
|
||||
uint32_t dec_nodeb{};
|
||||
uint32_t dec_leafw{};
|
||||
uint32_t dec_type{}; /* 0 = entry number
|
||||
1 = packed vector of values
|
||||
2 = packed vector of column offsets, maptype 1
|
||||
3 = scalar offset into value array, maptype 2 */
|
||||
int32_t q_min{};
|
||||
int32_t q_minp{};
|
||||
int32_t q_del{};
|
||||
int32_t q_delp{};
|
||||
int32_t q_seq{};
|
||||
int32_t q_bits{};
|
||||
uint8_t q_pack{};
|
||||
ps_ptr<uint16_t> q_val{};
|
||||
} codebook_t;
|
||||
|
||||
typedef struct _comment {
|
||||
uint32_t pointer{};
|
||||
uint32_t list_length{};
|
||||
bool oob{}; // out of bounds (block overflow)
|
||||
uint32_t save_len{};
|
||||
uint32_t comment_size{};
|
||||
uint32_t start_pos{}; // comment start file position
|
||||
uint32_t end_pos{}; // comment end file position
|
||||
uint8_t length_bytes[4]{}; // 🆕 Addition for split 4-byte length fields
|
||||
uint8_t partial_length{}; // how many of the 4 bytes have already been read
|
||||
uint32_t bytes_available{};
|
||||
|
||||
ps_ptr<char> stream_title{};
|
||||
ps_ptr<char> comment_content{};
|
||||
std::vector<uint32_t> item_vec;
|
||||
std::vector<uint32_t> pic_vec;
|
||||
|
||||
void reset() { *this = _comment{}; }
|
||||
} comment_t;
|
||||
comment_t m_comment;
|
||||
|
||||
typedef struct _ogg_items {
|
||||
std::deque<uint32_t> segment_table{};
|
||||
uint32_t bytes_consumed_from_other{};
|
||||
uint8_t* data_ptr{};
|
||||
uint32_t lastSegmentTableLen{};
|
||||
ps_ptr<uint8_t> lastSegmentTable{};
|
||||
void reset() { *this = _ogg_items{}; }
|
||||
} ogg_items_t;
|
||||
ogg_items_t m_ogg_items;
|
||||
|
||||
// global vars
|
||||
bool m_f_newSteamTitle = false; // streamTitle
|
||||
bool m_f_newMetadataBlockPicture = false;
|
||||
bool m_f_oggFirstPage = false;
|
||||
bool m_f_oggContinuedPage = false;
|
||||
bool m_f_oggLastPage = false;
|
||||
bool m_f_parseOggDone = true;
|
||||
bool m_f_isValid = false;
|
||||
bool m_f_comment_done = false;
|
||||
uint16_t m_identificatonHeaderLength = 0;
|
||||
uint16_t m_vorbisCommentHeaderLength = 0;
|
||||
uint8_t m_pageNr = 0;
|
||||
uint16_t m_oggHeaderSize = 0;
|
||||
uint8_t m_vorbisChannels = 0;
|
||||
uint16_t m_vorbisSamplerate = 0;
|
||||
uint32_t m_vorbisBitRate = 0;
|
||||
uint32_t m_vorbis_segment_length = 0;
|
||||
uint32_t m_vorbisCurrentFilePos = 0;
|
||||
uint32_t m_vorbisAudioDataStart = 0;
|
||||
|
||||
int32_t m_vorbisValidSamples = 0;
|
||||
int32_t m_commentBlockSegmentSize = 0;
|
||||
uint8_t m_vorbisOldMode = 0;
|
||||
uint32_t m_blocksizes[2];
|
||||
uint32_t m_vorbisBlockPicPos = 0;
|
||||
uint32_t m_vorbisBlockPicLen = 0;
|
||||
int32_t m_vorbisRemainBlockPicLen = 0;
|
||||
int32_t m_commentLength = 0;
|
||||
|
||||
uint8_t m_nrOfCodebooks = 0;
|
||||
uint8_t m_nrOfFloors = 0;
|
||||
uint8_t m_nrOfResidues = 0;
|
||||
uint8_t m_nrOfMaps = 0;
|
||||
uint8_t m_nrOfModes = 0;
|
||||
|
||||
uint16_t m_oggPage3Len = 0; // length of the current audio segment
|
||||
int8_t m_vorbisError = 0;
|
||||
float m_vorbisCompressionRatio = 0;
|
||||
|
||||
ps_ptr<codebook_t> m_codebooks;
|
||||
ps_ptr<ps_ptr<vorbis_info_floor>> m_floor_param{};
|
||||
ps_ptr<int8_t> m_floor_type;
|
||||
ps_ptr<vorbis_info_residue> m_residue_param;
|
||||
ps_ptr<vorbis_info_mapping> m_map_param;
|
||||
ps_ptr<vorbis_info_mode_t> m_mode_param;
|
||||
ps_ptr<vorbis_dsp_state> m_dsp_state;
|
||||
ps_ptr<int16_t> m_out16;
|
||||
|
||||
std::vector<uint32_t> m_vorbisBlockPicItem;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// ogg impl
|
||||
|
||||
ps_ptr<vorbis_info_floor> floor0_info_unpack();
|
||||
void setDefaults();
|
||||
void clearGlobalConfigurations();
|
||||
int32_t parse_OGG(uint8_t* inbuf, int32_t* bytesLeft);
|
||||
int32_t vorbisDecodePage1(uint8_t* inbuf, int32_t* bytesLeft, uint32_t segmentLength);
|
||||
int32_t vorbisDecodePage2(uint8_t* inbuf, int32_t* bytesLeft, uint32_t segmentLength, uint32_t current_file_pos);
|
||||
int32_t vorbisDecodePage3(uint8_t* inbuf, int32_t* bytesLeft, uint32_t segmentLength);
|
||||
int32_t vorbisDecodePage4(uint8_t* inbuf, int32_t* bytesLeft, uint32_t segmentLength, int16_t* outbuf);
|
||||
int32_t parseVorbisComment(uint8_t* inbuf, int16_t nBytes, uint32_t current_file_pos);
|
||||
int32_t parseVorbisCodebook();
|
||||
int32_t parseVorbisFirstPacket(uint8_t* inbuf, int16_t nBytes);
|
||||
int32_t vorbis_book_unpack(codebook_t* s);
|
||||
uint32_t decpack(int32_t entry, int32_t used_entry, uint8_t quantvals, codebook_t* b, int32_t maptype);
|
||||
int32_t oggpack_eop();
|
||||
ps_ptr<vorbis_info_floor> floor1_info_unpack();
|
||||
void vorbis_mergesort(uint8_t* index, uint16_t* vals, uint16_t n);
|
||||
int32_t res_unpack(vorbis_info_residue* info);
|
||||
int32_t mapping_info_unpack(vorbis_info_mapping* info);
|
||||
|
||||
// vorbis decoder impl
|
||||
int32_t vorbis_dsp_synthesis(uint8_t* inbuf, uint16_t len, int16_t* outbuf);
|
||||
ps_ptr<vorbis_dsp_state> vorbis_dsp_create();
|
||||
void vorbis_dsp_destroy(ps_ptr<vorbis_dsp_state>& v);
|
||||
void vorbis_book_clear(ps_ptr<codebook_t>& v);
|
||||
void mdct_shift_right(int32_t n, int32_t* in, int32_t* right);
|
||||
int32_t mapping_inverse(vorbis_info_mapping* info);
|
||||
int32_t floor0_memosize(ps_ptr<vorbis_info_floor>& i);
|
||||
int32_t floor1_memosize(ps_ptr<vorbis_info_floor>& i);
|
||||
int32_t* floor0_inverse1(ps_ptr<vorbis_info_floor>& i, int32_t* lsp);
|
||||
int32_t* floor1_inverse1(ps_ptr<vorbis_info_floor>& in, int32_t* fit_value);
|
||||
int32_t vorbis_book_decode(codebook_t* book);
|
||||
int32_t decode_packed_entry_number(codebook_t* book);
|
||||
int32_t render_point(int32_t x0, int32_t x1, int32_t y0, int32_t y1, int32_t x);
|
||||
int32_t vorbis_book_decodev_set(codebook_t* book, int32_t* a, int32_t n, int32_t point);
|
||||
int32_t decode_map(codebook_t* s, int32_t* v, int32_t point);
|
||||
int32_t res_inverse(vorbis_info_residue* info, int32_t** in, int32_t* nonzero, uint8_t ch);
|
||||
int32_t vorbis_book_decodev_add(codebook_t* book, int32_t* a, int32_t n, int32_t point);
|
||||
int32_t vorbis_book_decodevs_add(codebook_t* book, int32_t* a, int32_t n, int32_t point);
|
||||
int32_t floor0_inverse2(ps_ptr<vorbis_info_floor>& i, int32_t* lsp, int32_t* out);
|
||||
int32_t floor1_inverse2(ps_ptr<vorbis_info_floor>& in, int32_t* fit_value, int32_t* out);
|
||||
void render_line(int32_t n, int32_t x0, int32_t x1, int32_t y0, int32_t y1, int32_t* d);
|
||||
void vorbis_lsp_to_curve(int32_t* curve, int32_t n, int32_t ln, int32_t* lsp, int32_t m, int32_t amp, int32_t ampoffset, int32_t nyq);
|
||||
int32_t toBARK(int32_t n);
|
||||
int32_t vorbis_coslook_i(int32_t a);
|
||||
int32_t vorbis_coslook2_i(int32_t a);
|
||||
int32_t vorbis_fromdBlook_i(int32_t a);
|
||||
int32_t vorbis_invsqlook_i(int32_t a, int32_t e);
|
||||
void mdct_backward(int32_t n, int32_t* in);
|
||||
void presymmetry(int32_t* in, int32_t n2, int32_t step);
|
||||
void mdct_butterflies(int32_t* x, int32_t points, int32_t shift);
|
||||
void mdct_butterfly_generic(int32_t* x, int32_t points, int32_t step);
|
||||
void mdct_butterfly_32(int32_t* x);
|
||||
void mdct_butterfly_16(int32_t* x);
|
||||
void mdct_butterfly_8(int32_t* x);
|
||||
void mdct_bitreverse(int32_t* x, int32_t n, int32_t shift);
|
||||
int32_t bitrev12(int32_t x);
|
||||
void mdct_step7(int32_t* x, int32_t n, int32_t step);
|
||||
void mdct_step8(int32_t* x, int32_t n, int32_t step);
|
||||
int32_t vorbis_book_decodevv_add(codebook_t* book, int32_t** a, int32_t offset, uint8_t ch, int32_t n, int32_t point);
|
||||
int32_t vorbis_dsp_pcmout(int16_t* outBuff, int32_t outBuffSize);
|
||||
void mdct_unroll_lap(int32_t n0, int32_t n1, int32_t lW, int32_t W, int32_t* in, int32_t* right, const int32_t* w0, const int32_t* w1, int16_t* out, int32_t step,
|
||||
int32_t start, /* samples, this frame */
|
||||
int32_t end /* samples, this frame */);
|
||||
|
||||
// some helper functions
|
||||
int32_t special_index_of(uint8_t* base, const char* str, int32_t baselen, bool exact = false);
|
||||
void bitReader_setData(uint8_t* buff, uint32_t buffSize);
|
||||
int32_t bitReader(uint16_t bits);
|
||||
int32_t bitReader_look(uint16_t nBits);
|
||||
int8_t bitReader_adv(uint16_t bits);
|
||||
uint8_t _ilog(uint32_t v);
|
||||
int32_t ilog(uint32_t v);
|
||||
int32_t _float32_unpack(int32_t val, int32_t* point);
|
||||
int32_t _determine_node_bytes(uint32_t used, uint8_t leafwidth);
|
||||
int32_t _determine_leaf_words(int32_t nodeb, int32_t leafwidth);
|
||||
int32_t _make_decode_table(codebook_t* s, int32_t* lengthlist, uint8_t quantvals, int32_t maptype);
|
||||
int32_t _make_words(int32_t* l, uint16_t n, uint32_t* r, uint8_t quantvals, codebook_t* b, int32_t maptype);
|
||||
uint8_t _book_maptype1_quantvals(codebook_t* b);
|
||||
int32_t* _vorbis_window(int32_t left);
|
||||
|
||||
int32_t MULT32(int32_t x, int32_t y);
|
||||
int32_t MULT31_SHIFT15(int32_t x, int32_t y);
|
||||
int32_t MULT31(int32_t x, int32_t y);
|
||||
void XPROD31(int32_t a, int32_t b, int32_t t, int32_t v, int32_t* x, int32_t* y);
|
||||
void XNPROD31(int32_t a, int32_t b, int32_t t, int32_t v, int32_t* x, int32_t* y);
|
||||
int32_t CLIP_TO_15(int32_t x);
|
||||
int32_t specialIndexOf(uint8_t* base, const char* str, int32_t baselen, bool exact = false);
|
||||
int32_t specialIndexOf_icase(uint8_t* base, const char* str, int32_t baselen, bool exact = false);
|
||||
uint32_t little_endian(uint8_t* data);
|
||||
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
// Macro for comfortable calls
|
||||
#define VORBIS_LOG_ERROR(fmt, ...) Audio::AUDIO_LOG_IMPL(1, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define VORBIS_LOG_WARN(fmt, ...) Audio::AUDIO_LOG_IMPL(2, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define VORBIS_LOG_INFO(fmt, ...) Audio::AUDIO_LOG_IMPL(3, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define VORBIS_LOG_DEBUG(fmt, ...) Audio::AUDIO_LOG_IMPL(4, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
#define VORBIS_LOG_VERBOSE(fmt, ...) Audio::AUDIO_LOG_IMPL(5, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
|
||||
};
|
||||
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
@@ -62,95 +62,172 @@ void LCD_Init(void)
|
||||
Backlight_Init();
|
||||
SPI_Init();
|
||||
|
||||
LCD_Reset();
|
||||
//************* Start Initial Sequence **********//
|
||||
LCD_WriteCommand(0x11);
|
||||
// Reset LCD
|
||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_RST, LOW);
|
||||
delay(10);
|
||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_RST, HIGH);
|
||||
delay(50);
|
||||
|
||||
//************* JD9853 Start Initial Sequence **********//
|
||||
LCD_WriteCommand(0x11); // Sleep Out
|
||||
delay(120);
|
||||
LCD_WriteCommand(0x36);
|
||||
|
||||
LCD_WriteCommand(0xDF);
|
||||
LCD_WriteData(0x98);
|
||||
LCD_WriteData(0x53);
|
||||
|
||||
LCD_WriteCommand(0xB2);
|
||||
LCD_WriteData(0x23);
|
||||
|
||||
LCD_WriteCommand(0xB7);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x47);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x6F);
|
||||
|
||||
LCD_WriteCommand(0xBB);
|
||||
LCD_WriteData(0x1C);
|
||||
LCD_WriteData(0x1A);
|
||||
LCD_WriteData(0x55);
|
||||
LCD_WriteData(0x73);
|
||||
LCD_WriteData(0x63);
|
||||
LCD_WriteData(0xF0);
|
||||
|
||||
LCD_WriteCommand(0xC0);
|
||||
LCD_WriteData(0x44);
|
||||
LCD_WriteData(0xA4);
|
||||
|
||||
LCD_WriteCommand(0xC1);
|
||||
LCD_WriteData(0x16);
|
||||
|
||||
LCD_WriteCommand(0xC3);
|
||||
LCD_WriteData(0x7D);
|
||||
LCD_WriteData(0x07);
|
||||
LCD_WriteData(0x14);
|
||||
LCD_WriteData(0x06);
|
||||
LCD_WriteData(0xCF);
|
||||
LCD_WriteData(0x71);
|
||||
LCD_WriteData(0x72);
|
||||
LCD_WriteData(0x77);
|
||||
|
||||
LCD_WriteCommand(0xC4);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0xA0);
|
||||
LCD_WriteData(0x79);
|
||||
LCD_WriteData(0x0B);
|
||||
LCD_WriteData(0x0A);
|
||||
LCD_WriteData(0x16);
|
||||
LCD_WriteData(0x79);
|
||||
LCD_WriteData(0x0B);
|
||||
LCD_WriteData(0x0A);
|
||||
LCD_WriteData(0x16);
|
||||
LCD_WriteData(0x82);
|
||||
|
||||
LCD_WriteCommand(0xC8);
|
||||
const uint8_t c8_data[] = {
|
||||
0x3F, 0x32, 0x29, 0x29, 0x27, 0x2B, 0x27, 0x28, 0x28, 0x26, 0x25, 0x17, 0x12, 0x0D, 0x04, 0x00,
|
||||
0x3F, 0x32, 0x29, 0x29, 0x27, 0x2B, 0x27, 0x28, 0x28, 0x26, 0x25, 0x17, 0x12, 0x0D, 0x04, 0x00
|
||||
};
|
||||
for (int i = 0; i < 32; i++) {
|
||||
LCD_WriteData(c8_data[i]);
|
||||
}
|
||||
|
||||
LCD_WriteCommand(0xD0);
|
||||
LCD_WriteData(0x04);
|
||||
LCD_WriteData(0x06);
|
||||
LCD_WriteData(0x6B);
|
||||
LCD_WriteData(0x0F);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0xD7);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x30);
|
||||
|
||||
LCD_WriteCommand(0xE6);
|
||||
LCD_WriteData(0x14);
|
||||
|
||||
LCD_WriteCommand(0xDE);
|
||||
LCD_WriteData(0x01);
|
||||
|
||||
LCD_WriteCommand(0xB7);
|
||||
LCD_WriteData(0x03);
|
||||
LCD_WriteData(0x13);
|
||||
LCD_WriteData(0xEF);
|
||||
LCD_WriteData(0x35);
|
||||
LCD_WriteData(0x35);
|
||||
|
||||
LCD_WriteCommand(0xC1);
|
||||
LCD_WriteData(0x14);
|
||||
LCD_WriteData(0x15);
|
||||
LCD_WriteData(0xC0);
|
||||
|
||||
LCD_WriteCommand(0xC2);
|
||||
LCD_WriteData(0x06);
|
||||
LCD_WriteData(0x3A);
|
||||
|
||||
LCD_WriteCommand(0xC4);
|
||||
LCD_WriteData(0x72);
|
||||
LCD_WriteData(0x12);
|
||||
|
||||
LCD_WriteCommand(0xBE);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0xDE);
|
||||
LCD_WriteData(0x02);
|
||||
|
||||
LCD_WriteCommand(0xE5);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x02);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0xE5);
|
||||
LCD_WriteData(0x01);
|
||||
LCD_WriteData(0x02);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0xDE);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0x35);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0x3A);
|
||||
LCD_WriteData(0x05);
|
||||
|
||||
LCD_WriteCommand(0x2A);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x22);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0xCD);
|
||||
|
||||
LCD_WriteCommand(0x2B);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x01);
|
||||
LCD_WriteData(0x3F);
|
||||
|
||||
LCD_WriteCommand(0xDE);
|
||||
LCD_WriteData(0x02);
|
||||
|
||||
LCD_WriteCommand(0xE5);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x02);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0xDE);
|
||||
LCD_WriteData(0x00);
|
||||
|
||||
LCD_WriteCommand(0x36); // Rotation control
|
||||
if (HORIZONTAL)
|
||||
LCD_WriteData(0x00);
|
||||
else
|
||||
LCD_WriteData(0x70);
|
||||
|
||||
LCD_WriteCommand(0x3A);
|
||||
LCD_WriteData(0x05);
|
||||
LCD_WriteCommand(0x21); // Display Inversion On
|
||||
|
||||
LCD_WriteCommand(0xB0);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0xE8);
|
||||
|
||||
LCD_WriteCommand(0xB2);
|
||||
LCD_WriteData(0x0C);
|
||||
LCD_WriteData(0x0C);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x33);
|
||||
LCD_WriteData(0x33);
|
||||
|
||||
LCD_WriteCommand(0xB7);
|
||||
LCD_WriteData(0x35);
|
||||
|
||||
LCD_WriteCommand(0xBB);
|
||||
LCD_WriteData(0x35);
|
||||
|
||||
LCD_WriteCommand(0xC0);
|
||||
LCD_WriteData(0x2C);
|
||||
|
||||
LCD_WriteCommand(0xC2);
|
||||
LCD_WriteData(0x01);
|
||||
|
||||
LCD_WriteCommand(0xC3);
|
||||
LCD_WriteData(0x13);
|
||||
|
||||
LCD_WriteCommand(0xC4);
|
||||
LCD_WriteData(0x20);
|
||||
|
||||
LCD_WriteCommand(0xC6);
|
||||
LCD_WriteData(0x0F);
|
||||
|
||||
LCD_WriteCommand(0xD0);
|
||||
LCD_WriteData(0xA4);
|
||||
LCD_WriteData(0xA1);
|
||||
|
||||
LCD_WriteCommand(0xD6);
|
||||
LCD_WriteData(0xA1);
|
||||
|
||||
LCD_WriteCommand(0xE0);
|
||||
LCD_WriteData(0xF0);
|
||||
LCD_WriteData(0x00);
|
||||
LCD_WriteData(0x04);
|
||||
LCD_WriteData(0x04);
|
||||
LCD_WriteData(0x04);
|
||||
LCD_WriteData(0x05);
|
||||
LCD_WriteData(0x29);
|
||||
LCD_WriteData(0x33);
|
||||
LCD_WriteData(0x3E);
|
||||
LCD_WriteData(0x38);
|
||||
LCD_WriteData(0x12);
|
||||
LCD_WriteData(0x12);
|
||||
LCD_WriteData(0x28);
|
||||
LCD_WriteData(0x30);
|
||||
|
||||
LCD_WriteCommand(0xE1);
|
||||
LCD_WriteData(0xF0);
|
||||
LCD_WriteData(0x07);
|
||||
LCD_WriteData(0x0A);
|
||||
LCD_WriteData(0x0D);
|
||||
LCD_WriteData(0x0B);
|
||||
LCD_WriteData(0x07);
|
||||
LCD_WriteData(0x28);
|
||||
LCD_WriteData(0x33);
|
||||
LCD_WriteData(0x3E);
|
||||
LCD_WriteData(0x36);
|
||||
LCD_WriteData(0x14);
|
||||
LCD_WriteData(0x14);
|
||||
LCD_WriteData(0x29);
|
||||
LCD_WriteData(0x32);
|
||||
|
||||
LCD_WriteCommand(0x21);
|
||||
|
||||
LCD_WriteCommand(0x11);
|
||||
delay(120);
|
||||
LCD_WriteCommand(0x29);
|
||||
delay(10);
|
||||
LCD_WriteCommand(0x29); // Display On
|
||||
}
|
||||
/******************************************************************************
|
||||
function: Set the cursor position
|
||||
@@ -219,17 +296,16 @@ void LCD_addWindow(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yen
|
||||
// backlight
|
||||
void Backlight_Init(void)
|
||||
{
|
||||
ledcAttach(EXAMPLE_PIN_NUM_BK_LIGHT, Frequency, Resolution);
|
||||
ledcWrite(EXAMPLE_PIN_NUM_BK_LIGHT, 100);
|
||||
pinMode(EXAMPLE_PIN_NUM_BK_LIGHT, OUTPUT);
|
||||
digitalWrite(EXAMPLE_PIN_NUM_BK_LIGHT, HIGH); // Set backlight to full brightness
|
||||
}
|
||||
|
||||
void Set_Backlight(uint8_t Light) //
|
||||
{
|
||||
|
||||
if(Light > 100 || Light < 0)
|
||||
printf("Set Backlight parameters in the range of 0 to 100 \r\n");
|
||||
else{
|
||||
uint32_t Backlight = Light*10;
|
||||
ledcWrite(EXAMPLE_PIN_NUM_BK_LIGHT, Backlight);
|
||||
pinMode(EXAMPLE_PIN_NUM_BK_LIGHT, OUTPUT);
|
||||
if (Light > 0) {
|
||||
digitalWrite(EXAMPLE_PIN_NUM_BK_LIGHT, HIGH);
|
||||
} else {
|
||||
digitalWrite(EXAMPLE_PIN_NUM_BK_LIGHT, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
#define SPIFreq 80000000
|
||||
#define EXAMPLE_PIN_NUM_MISO -1
|
||||
#define EXAMPLE_PIN_NUM_MOSI 45
|
||||
#define EXAMPLE_PIN_NUM_SCLK 40
|
||||
#define EXAMPLE_PIN_NUM_LCD_CS 42
|
||||
#define EXAMPLE_PIN_NUM_LCD_DC 41
|
||||
#define EXAMPLE_PIN_NUM_LCD_RST 39
|
||||
#define EXAMPLE_PIN_NUM_BK_LIGHT 48
|
||||
#define EXAMPLE_PIN_NUM_MOSI 39
|
||||
#define EXAMPLE_PIN_NUM_SCLK 38
|
||||
#define EXAMPLE_PIN_NUM_LCD_CS 21
|
||||
#define EXAMPLE_PIN_NUM_LCD_DC 45
|
||||
#define EXAMPLE_PIN_NUM_LCD_RST 40
|
||||
#define EXAMPLE_PIN_NUM_BK_LIGHT 46
|
||||
#define Frequency 1000 // PWM frequencyconst
|
||||
#define Resolution 10
|
||||
|
||||
|
||||
@@ -122,8 +122,8 @@ void handleUpload() {
|
||||
}
|
||||
|
||||
void initWebServer() {
|
||||
// Start WiFi Access Point with SSID "love" and password "password"
|
||||
WiFi.softAP("love", "password");
|
||||
// Start WiFi Access Point with SSID "love" and password "love"
|
||||
WiFi.softAP("love", "love");
|
||||
IPAddress IP = WiFi.softAPIP();
|
||||
printf("WiFi AP Started. SSID: 'love'\r\n");
|
||||
printf("Web Server IP address: %s\r\n", IP.toString().c_str());
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "Web_Server.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define BOOT_KEY_PIN 9
|
||||
#define PIN_NEOPIXEL 38
|
||||
#define BOOT_KEY_PIN 0
|
||||
|
||||
// Playback states
|
||||
enum AppState {
|
||||
@@ -48,10 +47,6 @@ void setup() {
|
||||
printf("Starting Sound and Picture Player...\r\n");
|
||||
printf("==========================================\r\n");
|
||||
|
||||
// Setup NeoPixel
|
||||
pinMode(PIN_NEOPIXEL, OUTPUT);
|
||||
neopixelWrite(PIN_NEOPIXEL, 0, 0, 32); // Turn on solid blue to show booting
|
||||
|
||||
// Initialize Display and Backlight first so the screen lights up immediately
|
||||
LCD_Init();
|
||||
Set_Backlight(90);
|
||||
@@ -150,14 +145,6 @@ void handleQuadruplePress() {
|
||||
uint8_t nextVol = getPlayerVolume() + 4;
|
||||
if (nextVol > 20) nextVol = 4; // Loop back
|
||||
setPlayerVolume(nextVol);
|
||||
|
||||
// Quick flash NeoPixel white to indicate volume change
|
||||
for(int i = 0; i < 3; i++) {
|
||||
neopixelWrite(PIN_NEOPIXEL, 64, 64, 64);
|
||||
delay(50);
|
||||
neopixelWrite(PIN_NEOPIXEL, 0, 0, 0);
|
||||
delay(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,41 +165,7 @@ void handleLongPress() {
|
||||
}
|
||||
|
||||
void updateLEDStatus() {
|
||||
uint32_t now = millis();
|
||||
|
||||
// Pulse animation frequency
|
||||
if (now - lastLedPulseTime > 15) {
|
||||
lastLedPulseTime = now;
|
||||
if (pulseDirection) {
|
||||
pulseBrightness += 2;
|
||||
if (pulseBrightness >= 120) pulseDirection = false;
|
||||
} else {
|
||||
pulseBrightness -= 2;
|
||||
if (pulseBrightness <= 10) pulseDirection = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update LED color based on state
|
||||
if (hasError) {
|
||||
// Flashing red
|
||||
if ((now / 250) % 2 == 0) {
|
||||
neopixelWrite(PIN_NEOPIXEL, 64, 0, 0); // Dim Red
|
||||
} else {
|
||||
neopixelWrite(PIN_NEOPIXEL, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
else if (isAudioPlaying()) {
|
||||
// Pulsing Green
|
||||
neopixelWrite(PIN_NEOPIXEL, 0, pulseBrightness, 0);
|
||||
}
|
||||
else if (currentState == STATE_AUTOPLAY) {
|
||||
// Pulsing Purple (Red + Blue)
|
||||
neopixelWrite(PIN_NEOPIXEL, pulseBrightness / 2, 0, pulseBrightness);
|
||||
}
|
||||
else {
|
||||
// Solid Blue
|
||||
neopixelWrite(PIN_NEOPIXEL, 0, 0, 32);
|
||||
}
|
||||
// Disabled NeoPixel code to resolve hardware conflict with SPI SCLK (GPIO 38)
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Reference in New Issue
Block a user